LLVM 17.0.0git
Macros | Typedefs | Enumerations | Functions | Variables
Function.cpp File Reference
#include "llvm/IR/Function.h"
#include "SymbolTableListTraitsImpl.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/AbstractCallSite.h"
#include "llvm/IR/Argument.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/IntrinsicsAArch64.h"
#include "llvm/IR/IntrinsicsAMDGPU.h"
#include "llvm/IR/IntrinsicsARM.h"
#include "llvm/IR/IntrinsicsBPF.h"
#include "llvm/IR/IntrinsicsDirectX.h"
#include "llvm/IR/IntrinsicsHexagon.h"
#include "llvm/IR/IntrinsicsMips.h"
#include "llvm/IR/IntrinsicsNVPTX.h"
#include "llvm/IR/IntrinsicsPowerPC.h"
#include "llvm/IR/IntrinsicsR600.h"
#include "llvm/IR/IntrinsicsRISCV.h"
#include "llvm/IR/IntrinsicsS390.h"
#include "llvm/IR/IntrinsicsVE.h"
#include "llvm/IR/IntrinsicsWebAssembly.h"
#include "llvm/IR/IntrinsicsX86.h"
#include "llvm/IR/IntrinsicsXCore.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Operator.h"
#include "llvm/IR/SymbolTableListTraits.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Use.h"
#include "llvm/IR/User.h"
#include "llvm/IR/Value.h"
#include "llvm/IR/ValueSymbolTable.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ModRef.h"
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <string>
#include "llvm/IR/ConstrainedOps.def"
#include "llvm/IR/IntrinsicImpl.inc"

Go to the source code of this file.

Macros

#define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC)    case Intrinsic::INTRINSIC:
 
#define GET_INTRINSIC_NAME_TABLE
 
#define GET_INTRINSIC_TARGET_DATA
 Table of per-target intrinsic name tables.
 
#define GET_INTRINSIC_GENERATOR_GLOBAL
 
#define GET_INTRINSIC_OVERLOAD_TABLE
 
#define GET_INTRINSIC_ATTRIBUTES
 This defines the "Intrinsic::getAttributes(ID id)" method.
 
#define GET_LLVM_INTRINSIC_FOR_CLANG_BUILTIN
 
#define GET_LLVM_INTRINSIC_FOR_MS_BUILTIN
 

Typedefs

using ProfileCount = Function::ProfileCount
 
using DeferredIntrinsicMatchPair = std::pair< Type *, ArrayRef< Intrinsic::IITDescriptor > >
 

Enumerations

enum  IIT_Info {
  IIT_Done = 0 , IIT_I1 = 1 , IIT_I8 = 2 , IIT_I16 = 3 ,
  IIT_I32 = 4 , IIT_I64 = 5 , IIT_F16 = 6 , IIT_F32 = 7 ,
  IIT_F64 = 8 , IIT_V2 = 9 , IIT_V4 = 10 , IIT_V8 = 11 ,
  IIT_V16 = 12 , IIT_V32 = 13 , IIT_PTR = 14 , IIT_ARG = 15 ,
  IIT_V64 = 16 , IIT_MMX = 17 , IIT_TOKEN = 18 , IIT_METADATA = 19 ,
  IIT_EMPTYSTRUCT = 20 , IIT_STRUCT2 = 21 , IIT_STRUCT3 = 22 , IIT_STRUCT4 = 23 ,
  IIT_STRUCT5 = 24 , IIT_EXTEND_ARG = 25 , IIT_TRUNC_ARG = 26 , IIT_ANYPTR = 27 ,
  IIT_V1 = 28 , IIT_VARARG = 29 , IIT_HALF_VEC_ARG = 30 , IIT_SAME_VEC_WIDTH_ARG = 31 ,
  IIT_PTR_TO_ARG = 32 , IIT_PTR_TO_ELT = 33 , IIT_VEC_OF_ANYPTRS_TO_ELT = 34 , IIT_I128 = 35 ,
  IIT_V512 = 36 , IIT_V1024 = 37 , IIT_STRUCT6 = 38 , IIT_STRUCT7 = 39 ,
  IIT_STRUCT8 = 40 , IIT_F128 = 41 , IIT_VEC_ELEMENT = 42 , IIT_SCALABLE_VEC = 43 ,
  IIT_SUBDIVIDE2_ARG = 44 , IIT_SUBDIVIDE4_ARG = 45 , IIT_VEC_OF_BITCASTS_TO_INT = 46 , IIT_V128 = 47 ,
  IIT_BF16 = 48 , IIT_STRUCT9 = 49 , IIT_V256 = 50 , IIT_AMX = 51 ,
  IIT_PPCF128 = 52 , IIT_V3 = 53 , IIT_EXTERNREF = 54 , IIT_FUNCREF = 55 ,
  IIT_ANYPTR_TO_ELT = 56 , IIT_I2 = 57 , IIT_I4 = 58
}
 IIT_Info - These are enumerators that describe the entries returned by the getIntrinsicInfoTableEntries function. More...
 

Functions

static TypegetMemoryParamAllocType (AttributeSet ParamAttrs)
 For a byval, sret, inalloca, or preallocated parameter, get the in-memory parameter type.
 
static unsigned computeAddrSpace (unsigned AddrSpace, Module *M)
 
static MutableArrayRef< ArgumentmakeArgArray (Argument *Args, size_t Count)
 
static ArrayRef< const char * > findTargetSubtable (StringRef Name)
 Find the segment of IntrinsicNameTable for intrinsics with the same target as Name, or the generic table if Name is not target specific.
 
static std::string getMangledTypeStr (Type *Ty, bool &HasUnnamedType)
 Returns a stable mangling for the type specified for use in the name mangling scheme used by 'any' types in intrinsic signatures.
 
static std::string getIntrinsicNameImpl (Intrinsic::ID Id, ArrayRef< Type * > Tys, Module *M, FunctionType *FT, bool EarlyModuleCheck)
 
static void DecodeIITType (unsigned &NextElt, ArrayRef< unsigned char > Infos, IIT_Info LastInfo, SmallVectorImpl< Intrinsic::IITDescriptor > &OutputTable)
 
static TypeDecodeFixedType (ArrayRef< Intrinsic::IITDescriptor > &Infos, ArrayRef< Type * > Tys, LLVMContext &Context)
 
static bool matchIntrinsicType (Type *Ty, ArrayRef< Intrinsic::IITDescriptor > &Infos, SmallVectorImpl< Type * > &ArgTys, SmallVectorImpl< DeferredIntrinsicMatchPair > &DeferredChecks, bool IsDeferredCheck)
 

Variables

static cl::opt< unsignedNonGlobalValueMaxNameSize ("non-global-value-max-name-size", cl::Hidden, cl::init(1024), cl::desc("Maximum size for the name of non-global values."))
 
static const char *const IntrinsicNameTable []
 Table of string intrinsic names indexed by enum value.
 

Macro Definition Documentation

◆ GET_INTRINSIC_ATTRIBUTES

#define GET_INTRINSIC_ATTRIBUTES

This defines the "Intrinsic::getAttributes(ID id)" method.

Definition at line 1502 of file Function.cpp.

◆ GET_INTRINSIC_GENERATOR_GLOBAL

#define GET_INTRINSIC_GENERATOR_GLOBAL

Definition at line 1332 of file Function.cpp.

◆ GET_INTRINSIC_NAME_TABLE

#define GET_INTRINSIC_NAME_TABLE

◆ GET_INTRINSIC_OVERLOAD_TABLE

#define GET_INTRINSIC_OVERLOAD_TABLE

◆ GET_INTRINSIC_TARGET_DATA

#define GET_INTRINSIC_TARGET_DATA

Table of per-target intrinsic name tables.

Definition at line 827 of file Function.cpp.

◆ GET_LLVM_INTRINSIC_FOR_CLANG_BUILTIN

#define GET_LLVM_INTRINSIC_FOR_CLANG_BUILTIN

Definition at line 1517 of file Function.cpp.

◆ GET_LLVM_INTRINSIC_FOR_MS_BUILTIN

#define GET_LLVM_INTRINSIC_FOR_MS_BUILTIN

Definition at line 1522 of file Function.cpp.

◆ INSTRUCTION

#define INSTRUCTION (   NAME,
  NARG,
  ROUND_MODE,
  INTRINSIC 
)     case Intrinsic::INTRINSIC:

Typedef Documentation

◆ DeferredIntrinsicMatchPair

Definition at line 1526 of file Function.cpp.

◆ ProfileCount

Definition at line 73 of file Function.cpp.

Enumeration Type Documentation

◆ IIT_Info

enum IIT_Info

IIT_Info - These are enumerators that describe the entries returned by the getIntrinsicInfoTableEntries function.

NOTE: This must be kept in synch with the copy in TblGen/IntrinsicEmitter!

Enumerator
IIT_Done 
IIT_I1 
IIT_I8 
IIT_I16 
IIT_I32 
IIT_I64 
IIT_F16 
IIT_F32 
IIT_F64 
IIT_V2 
IIT_V4 
IIT_V8 
IIT_V16 
IIT_V32 
IIT_PTR 
IIT_ARG 
IIT_V64 
IIT_MMX 
IIT_TOKEN 
IIT_METADATA 
IIT_EMPTYSTRUCT 
IIT_STRUCT2 
IIT_STRUCT3 
IIT_STRUCT4 
IIT_STRUCT5 
IIT_EXTEND_ARG 
IIT_TRUNC_ARG 
IIT_ANYPTR 
IIT_V1 
IIT_VARARG 
IIT_HALF_VEC_ARG 
IIT_SAME_VEC_WIDTH_ARG 
IIT_PTR_TO_ARG 
IIT_PTR_TO_ELT 
IIT_VEC_OF_ANYPTRS_TO_ELT 
IIT_I128 
IIT_V512 
IIT_V1024 
IIT_STRUCT6 
IIT_STRUCT7 
IIT_STRUCT8 
IIT_F128 
IIT_VEC_ELEMENT 
IIT_SCALABLE_VEC 
IIT_SUBDIVIDE2_ARG 
IIT_SUBDIVIDE4_ARG 
IIT_VEC_OF_BITCASTS_TO_INT 
IIT_V128 
IIT_BF16 
IIT_STRUCT9 
IIT_V256 
IIT_AMX 
IIT_PPCF128 
IIT_V3 
IIT_EXTERNREF 
IIT_FUNCREF 
IIT_ANYPTR_TO_ELT 
IIT_I2 
IIT_I4 

Definition at line 1027 of file Function.cpp.

Function Documentation

◆ computeAddrSpace()

static unsigned computeAddrSpace ( unsigned  AddrSpace,
Module M 
)
static

Definition at line 391 of file Function.cpp.

◆ DecodeFixedType()

static Type * DecodeFixedType ( ArrayRef< Intrinsic::IITDescriptor > &  Infos,
ArrayRef< Type * >  Tys,
LLVMContext Context 
)
static

◆ DecodeIITType()

static void DecodeIITType ( unsigned NextElt,
ArrayRef< unsigned char Infos,
IIT_Info  LastInfo,
SmallVectorImpl< Intrinsic::IITDescriptor > &  OutputTable 
)
static

◆ findTargetSubtable()

static ArrayRef< const char * > findTargetSubtable ( StringRef  Name)
static

Find the segment of IntrinsicNameTable for intrinsics with the same target as Name, or the generic table if Name is not target specific.

Returns the relevant slice of IntrinsicNameTable

Definition at line 843 of file Function.cpp.

References assert(), IntrinsicNameTable, Name, llvm::partition_point(), and Targets.

Referenced by llvm::Function::lookupIntrinsicID().

◆ getIntrinsicNameImpl()

static std::string getIntrinsicNameImpl ( Intrinsic::ID  Id,
ArrayRef< Type * >  Tys,
Module M,
FunctionType FT,
bool  EarlyModuleCheck 
)
static

◆ getMangledTypeStr()

static std::string getMangledTypeStr ( Type Ty,
bool HasUnnamedType 
)
static

Returns a stable mangling for the type specified for use in the name mangling scheme used by 'any' types in intrinsic signatures.

The mangling of named types is simply their name. Manglings for unnamed types consist of a prefix ('p' for pointers, 'a' for arrays, 'f_' for functions) combined with the mangling of their component types. A vararg function type will have a suffix of 'vararg'. Since function types can contain other function types, we close a function type mangling with suffix 'f' which can't be confused with it's prefix. This ensures we don't have collisions between two unrelated function types. Otherwise, you might parse ffXX as f(fXX) or f(fX)X. (X is a placeholder for any other type.) The HasUnnamedType boolean is set if an unnamed type was encountered, indicating that extra care must be taken to ensure a unique name.

Definition at line 903 of file Function.cpp.

References llvm::Type::BFloatTyID, llvm::Type::DoubleTyID, llvm::Type::FloatTyID, llvm::Type::FP128TyID, getBitWidth(), getMangledTypeStr(), llvm::Type::getTypeID(), llvm::Type::HalfTyID, llvm::Type::IntegerTyID, llvm_unreachable, llvm::Type::MetadataTyID, llvm::Type::PPC_FP128TyID, llvm::Type::VoidTyID, llvm::Type::X86_AMXTyID, llvm::Type::X86_FP80TyID, and llvm::Type::X86_MMXTyID.

Referenced by getIntrinsicNameImpl(), and getMangledTypeStr().

◆ getMemoryParamAllocType()

static Type * getMemoryParamAllocType ( AttributeSet  ParamAttrs)
static

◆ makeArgArray()

static MutableArrayRef< Argument > makeArgArray ( Argument Args,
size_t  Count 
)
static

Definition at line 458 of file Function.cpp.

Referenced by llvm::Function::stealArgumentListFrom().

◆ matchIntrinsicType()

static bool matchIntrinsicType ( Type Ty,
ArrayRef< Intrinsic::IITDescriptor > &  Infos,
SmallVectorImpl< Type * > &  ArgTys,
SmallVectorImpl< DeferredIntrinsicMatchPair > &  DeferredChecks,
bool  IsDeferredCheck 
)
static

Variable Documentation

◆ IntrinsicNameTable

const char* const IntrinsicNameTable[]
static
Initial value:
= {
"not_intrinsic",
#define GET_INTRINSIC_NAME_TABLE
}

Table of string intrinsic names indexed by enum value.

Definition at line 819 of file Function.cpp.

Referenced by findTargetSubtable(), llvm::Intrinsic::getBaseName(), and llvm::Function::lookupIntrinsicID().

◆ NonGlobalValueMaxNameSize

cl::opt< unsigned > NonGlobalValueMaxNameSize("non-global-value-max-name-size", cl::Hidden, cl::init(1024), cl::desc("Maximum size for the name of non-global values.")) ( "non-global-value-max-name-size"  ,
cl::Hidden  ,
cl::init(1024)  ,
cl::desc("Maximum size for the name of non-global values.")   
)
static