23 #define DEBUG_TYPE "nvvm-intr-range"
36 } MaxBlockSize, MaxGridSize;
42 MaxBlockSize.x = 1024;
43 MaxBlockSize.y = 1024;
46 MaxGridSize.x = SmVersion >= 30 ? 0x7fffffff : 0xffff;
47 MaxGridSize.y = 0xffff;
48 MaxGridSize.z = 0xffff;
53 bool runOnFunction(
Function &)
override;
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) {
81 bool NVVMIntrRange::runOnFunction(
Function &
F) {
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);
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
This class represents a function call, abstracting a target machine's calling convention.
void initializeNVVMIntrRangePass(PassRegistry &)
initializer< Ty > init(const Ty &Val)
This is an important class for using LLVM in a threaded context.
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"))
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.
Function * getCalledFunction() const
Return the function called, or null if this is an indirect function invocation.
INITIALIZE_PASS(NVVMIntrRange,"nvvm-intr-range","Add !range metadata to NVVM intrinsics.", false, false) static bool addRangeMetadata(uint64_t Low
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
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...