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()) {
92 case Intrinsic::nvvm_read_ptx_sreg_tid_x:
93 Changed |= addRangeMetadata(0, MaxBlockSize.x, Call);
95 case Intrinsic::nvvm_read_ptx_sreg_tid_y:
96 Changed |= addRangeMetadata(0, MaxBlockSize.y, Call);
98 case Intrinsic::nvvm_read_ptx_sreg_tid_z:
99 Changed |= addRangeMetadata(0, MaxBlockSize.z, Call);
103 case Intrinsic::nvvm_read_ptx_sreg_ntid_x:
104 Changed |= addRangeMetadata(1, MaxBlockSize.x+1, Call);
106 case Intrinsic::nvvm_read_ptx_sreg_ntid_y:
107 Changed |= addRangeMetadata(1, MaxBlockSize.y+1, Call);
109 case Intrinsic::nvvm_read_ptx_sreg_ntid_z:
110 Changed |= addRangeMetadata(1, MaxBlockSize.z+1, Call);
114 case Intrinsic::nvvm_read_ptx_sreg_ctaid_x:
115 Changed |= addRangeMetadata(0, MaxGridSize.x, Call);
117 case Intrinsic::nvvm_read_ptx_sreg_ctaid_y:
118 Changed |= addRangeMetadata(0, MaxGridSize.y, Call);
120 case Intrinsic::nvvm_read_ptx_sreg_ctaid_z:
121 Changed |= addRangeMetadata(0, MaxGridSize.z, Call);
125 case Intrinsic::nvvm_read_ptx_sreg_nctaid_x:
126 Changed |= addRangeMetadata(1, MaxGridSize.x+1, Call);
128 case Intrinsic::nvvm_read_ptx_sreg_nctaid_y:
129 Changed |= addRangeMetadata(1, MaxGridSize.y+1, Call);
131 case Intrinsic::nvvm_read_ptx_sreg_nctaid_z:
132 Changed |= addRangeMetadata(1, MaxGridSize.z+1, Call);
136 case Intrinsic::nvvm_read_ptx_sreg_warpsize:
137 Changed |= addRangeMetadata(32, 32+1, Call);
141 case Intrinsic::nvvm_read_ptx_sreg_laneid:
142 Changed |= addRangeMetadata(0, 32, Call);
Function * getCalledFunction() const
Return the function called, or null if this is an indirect function invocation.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Compute iterated dominance frontiers using a linear time algorithm.
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)
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