23 #define DEBUG_TYPE "nvvm-intr-range" 36 } MaxBlockSize, MaxGridSize;
40 NVVMIntrRange() : NVVMIntrRange(NVVMIntrRangeSM) {}
41 NVVMIntrRange(
unsigned int SmVersion) :
FunctionPass(ID) {
42 MaxBlockSize.x = 1024;
43 MaxBlockSize.y = 1024;
46 MaxGridSize.x = SmVersion >= 30 ? 0x7fffffff : 0xffff;
47 MaxGridSize.y = 0xffff;
48 MaxGridSize.z = 0xffff;
58 return new NVVMIntrRange(SmVersion);
63 "Add !range metadata to NVVM intrinsics.",
false,
false)
67 static
bool addRangeMetadata(uint64_t Low, uint64_t
High,
CallInst *
C) {
90 switch (
Callee->getIntrinsicID()) {
93 Changed |= addRangeMetadata(0, MaxBlockSize.x, Call);
96 Changed |= addRangeMetadata(0, MaxBlockSize.y, Call);
99 Changed |= addRangeMetadata(0, MaxBlockSize.z, Call);
104 Changed |= addRangeMetadata(1, MaxBlockSize.x+1, Call);
107 Changed |= addRangeMetadata(1, MaxBlockSize.y+1, Call);
110 Changed |= addRangeMetadata(1, MaxBlockSize.z+1, Call);
115 Changed |= addRangeMetadata(0, MaxGridSize.x, Call);
118 Changed |= addRangeMetadata(0, MaxGridSize.y, Call);
121 Changed |= addRangeMetadata(0, MaxGridSize.z, Call);
126 Changed |= addRangeMetadata(1, MaxGridSize.x+1, Call);
129 Changed |= addRangeMetadata(1, MaxGridSize.y+1, Call);
132 Changed |= addRangeMetadata(1, MaxGridSize.z+1, Call);
137 Changed |= addRangeMetadata(32, 32+1, Call);
142 Changed |= addRangeMetadata(0, 32, Call);
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
This class represents lattice values for constants.
This class represents a function call, abstracting a target machine's calling convention.
LLVMContext & getContext() const
Get the context in which this basic block lives.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
amdgpu Simplify well known AMD library false Value * Callee
void initializeNVVMIntrRangePass(PassRegistry &)
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata *> MDs)
static bool runOnFunction(Function &F, bool PostInlining)
initializer< Ty > init(const Ty &Val)
This is an important class for using LLVM in a threaded context.
INITIALIZE_PASS(NVVMIntrRange, "nvvm-intr-range", "Add !range metadata to NVVM intrinsics.", false, false) static bool addRangeMetadata(uint64_t Low
This file contains the declarations for the subclasses of Constant, which represent the different fla...
FunctionPass class - This class is used to implement most global optimizations.
Class to represent integer types.
static cl::opt< unsigned > NVVMIntrRangeSM("nvvm-intr-range-sm", cl::init(20), cl::Hidden, cl::desc("SM variant"))
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
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.
FunctionPass * createNVVMIntrRangePass(unsigned int SmVersion)
static IntegerType * getInt32Ty(LLVMContext &C)
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)
inst_range instructions(Function *F)
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
const BasicBlock * getParent() const