27 template <
class ArgIt>
29 ArgIt ArgBegin, ArgIt ArgEnd,
32 std::vector<Type *> ParamTys;
33 for (ArgIt
I = ArgBegin;
I != ArgEnd; ++
I)
34 ParamTys.push_back(
I->getType());
40 const char *DName,
const char *LDName) {
64 template <
class ArgIt>
66 ArgIt ArgBegin, ArgIt ArgEnd,
72 std::vector<Type *> ParamTys;
73 for (ArgIt
I = ArgBegin;
I != ArgEnd; ++
I)
74 ParamTys.push_back((*I)->getType());
80 CallInst *NewCI = Builder.CreateCall(FCache, Args);
88 #if defined(_MSC_VER) && defined(setjmp) && \ 89 !defined(setjmp_undefined_for_msvc) 90 # pragma push_macro("setjmp") 92 # define setjmp_undefined_for_msvc 98 if (
F.isDeclaration() && !
F.use_empty())
99 switch (
F.getIntrinsicID()) {
114 M.getOrInsertFunction(
"memcpy",
121 M.getOrInsertFunction(
"memmove",
128 M.getOrInsertFunction(
"memset",
179 V = Builder.
CreateOr(Tmp1, Tmp2,
"bswap.i16");
197 Tmp4 = Builder.
CreateOr(Tmp4, Tmp3,
"bswap.or1");
198 Tmp2 = Builder.
CreateOr(Tmp2, Tmp1,
"bswap.or2");
199 V = Builder.
CreateOr(Tmp4, Tmp2,
"bswap.i32");
224 0xFF000000000000ULL),
246 Tmp8 = Builder.
CreateOr(Tmp8, Tmp7,
"bswap.or1");
247 Tmp6 = Builder.
CreateOr(Tmp6, Tmp5,
"bswap.or2");
248 Tmp4 = Builder.
CreateOr(Tmp4, Tmp3,
"bswap.or3");
249 Tmp2 = Builder.
CreateOr(Tmp2, Tmp1,
"bswap.or4");
250 Tmp8 = Builder.
CreateOr(Tmp8, Tmp6,
"bswap.or5");
251 Tmp4 = Builder.
CreateOr(Tmp4, Tmp2,
"bswap.or6");
252 V = Builder.
CreateOr(Tmp8, Tmp4,
"bswap.i64");
263 static const uint64_t MaskValues[6] = {
264 0x5555555555555555ULL, 0x3333333333333333ULL,
265 0x0F0F0F0F0F0F0F0FULL, 0x00FF00FF00FF00FFULL,
266 0x0000FFFF0000FFFFULL, 0x00000000FFFFFFFFULL
272 unsigned WordSize = (BitSize + 63) / 64;
275 for (
unsigned n = 0; n < WordSize; ++n) {
276 Value *PartValue = V;
277 for (
unsigned i = 1, ct = 0; i < (BitSize>64 ? 64 : BitSize);
285 PartValue = Builder.
CreateAdd(LHS, RHS,
"ctpop.step");
287 Count = Builder.
CreateAdd(PartValue, Count,
"ctpop.part");
304 for (
unsigned i = 1; i < BitSize; i <<= 1) {
306 ShVal = Builder.
CreateLShr(V, ShVal,
"ctlz.sh");
307 V = Builder.
CreateOr(V, ShVal,
"ctlz.step");
316 const char *LDname) {
342 assert(Callee &&
"Cannot lower an indirect call!");
415 errs() <<
"WARNING: this target does not support the llvm.stack" 417 "save" :
"restore") <<
" intrinsic.\n";
425 errs() <<
"WARNING: this target does not support the custom llvm.get." 426 "dynamic.area.offset. It is being lowered to a constant 0\n";
433 errs() <<
"WARNING: this target does not support the llvm." 435 "return" :
"frame") <<
"address intrinsic.\n";
440 errs() <<
"WARNING: this target does not support the " 441 "llvm.addressofreturnaddress intrinsic.\n";
452 errs() <<
"WARNING: this target does not support the llvm.readcyclecoun" 453 <<
"ter intrinsic. It is being lowered to a constant 0\n";
587 "Lowering should have eliminated any uses of the intrinsic call!");
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
static Type * getDoubleTy(LLVMContext &C)
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
Constant * getOrInsertFunction(StringRef Name, FunctionType *T, AttributeList AttributeList)
Look up the specified function in the module symbol table.
A Module instance is used to store all the information related to an LLVM module. ...
static CallInst * ReplaceCallWith(const char *NewFn, CallInst *CI, ArgIt ArgBegin, ArgIt ArgEnd, Type *RetTy)
This function is used when we want to lower an intrinsic call to a call of an external function...
2: 32-bit floating point type
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
This class represents a function call, abstracting a target machine's calling convention.
LLVMContext & getContext() const
All values hold a context through their type.
4: 80-bit floating point type (X87)
static IntegerType * getInt64Ty(LLVMContext &C)
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
Value * CreateNot(Value *V, const Twine &Name="")
Value * getArgOperand(unsigned i) const
amdgpu Simplify well known AMD library false Value Value const Twine & Name
static Type * getFloatTy(LLVMContext &C)
TypeID getTypeID() const
Return the type id for the type.
LLVMContext & getContext() const
Get the global data context.
bool isIntegerTy() const
True if this is an instance of IntegerType.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
static void EnsureFunctionExists(Module &M, const char *Name, ArgIt ArgBegin, ArgIt ArgEnd, Type *RetTy)
static void ReplaceFPIntrinsicWithCall(CallInst *CI, const char *Fname, const char *Dname, const char *LDname)
Value * CreateAdd(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
void setName(const Twine &Name)
Change the name of the value.
Type * getType() const
All values are typed, get the type of this value.
Value * CreateSub(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
amdgpu Simplify well known AMD library false Value * Callee
Function * getDeclaration(Module *M, ID id, ArrayRef< Type *> Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
Value * getOperand(unsigned i) const
Value * CreateOr(Value *LHS, Value *RHS, const Twine &Name="")
bool isVoidTy() const
Return true if this is 'void'.
IntegerType * getIntPtrType(LLVMContext &C, unsigned AddressSpace=0) const
Returns an integer type with size at least as big as that of a pointer in the given address space...
static ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
static Value * LowerBSWAP(LLVMContext &Context, Value *V, Instruction *IP)
Emit the code to lower bswap of V before the specified instruction IP.
This is an important base class in LLVM.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static Type * getVoidTy(LLVMContext &C)
static void EnsureFPIntrinsicsExist(Module &M, Function &Fn, const char *FName, const char *DName, const char *LDName)
6: 128-bit floating point type (two 64-bits, PowerPC)
static FunctionType * get(Type *Result, ArrayRef< Type *> Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
self_iterator getIterator()
Class to represent integer types.
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static Value * LowerCTPOP(LLVMContext &Context, Value *V, Instruction *IP)
Emit the code to lower ctpop of V before the specified instruction IP.
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type...
Value * CreateIntCast(Value *V, Type *DestTy, bool isSigned, const Twine &Name="")
Module.h This file contains the declarations for the Module class.
void AddPrototypes(Module &M)
Add all of the prototypes that might be needed by an intrinsic lowering implementation to be inserted...
static Value * LowerCTLZ(LLVMContext &Context, Value *V, Instruction *IP)
Emit the code to lower ctlz of V before the specified instruction IP.
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
Value * CreateShl(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
static bool LowerToByteSwap(CallInst *CI)
Try to replace a call instruction with a call to a bswap intrinsic.
unsigned getNumArgOperands() const
static IntegerType * getInt32Ty(LLVMContext &C)
void LowerIntrinsicCall(CallInst *CI)
Replace a call to the specified intrinsic function.
StringRef getName() const
Return a constant reference to the value's name.
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Value * CreateAnd(Value *LHS, Value *RHS, const Twine &Name="")
3: 64-bit floating point type
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
LLVM Value Representation.
Value * CreateLShr(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
const BasicBlock * getParent() const
5: 128-bit floating point type (112-bit mantissa)