19#include "llvm/IR/IntrinsicsNVPTX.h"
25#define DEBUG_TYPE "nvvm-intr-range"
41 NVVMIntrRange(
unsigned int SmVersion)
55char NVVMIntrRange::ID = 0;
57 "Add !range metadata to NVVM intrinsics.",
false,
false)
63 if (
C->getMetadata(LLVMContext::MD_range))
78 } MaxBlockSize, MaxGridSize;
79 MaxBlockSize.x = 1024;
80 MaxBlockSize.y = 1024;
83 MaxGridSize.x =
SmVersion >= 30 ? 0x7fffffff : 0xffff;
84 MaxGridSize.y = 0xffff;
85 MaxGridSize.z = 0xffff;
94 if (
Function *Callee = Call->getCalledFunction()) {
95 switch (Callee->getIntrinsicID()) {
97 case Intrinsic::nvvm_read_ptx_sreg_tid_x:
98 Changed |= addRangeMetadata(0, MaxBlockSize.x, Call);
100 case Intrinsic::nvvm_read_ptx_sreg_tid_y:
101 Changed |= addRangeMetadata(0, MaxBlockSize.y, Call);
103 case Intrinsic::nvvm_read_ptx_sreg_tid_z:
104 Changed |= addRangeMetadata(0, MaxBlockSize.z, Call);
108 case Intrinsic::nvvm_read_ptx_sreg_ntid_x:
109 Changed |= addRangeMetadata(1, MaxBlockSize.x+1, Call);
111 case Intrinsic::nvvm_read_ptx_sreg_ntid_y:
112 Changed |= addRangeMetadata(1, MaxBlockSize.y+1, Call);
114 case Intrinsic::nvvm_read_ptx_sreg_ntid_z:
115 Changed |= addRangeMetadata(1, MaxBlockSize.z+1, Call);
119 case Intrinsic::nvvm_read_ptx_sreg_ctaid_x:
120 Changed |= addRangeMetadata(0, MaxGridSize.x, Call);
122 case Intrinsic::nvvm_read_ptx_sreg_ctaid_y:
123 Changed |= addRangeMetadata(0, MaxGridSize.y, Call);
125 case Intrinsic::nvvm_read_ptx_sreg_ctaid_z:
126 Changed |= addRangeMetadata(0, MaxGridSize.z, Call);
130 case Intrinsic::nvvm_read_ptx_sreg_nctaid_x:
131 Changed |= addRangeMetadata(1, MaxGridSize.x+1, Call);
133 case Intrinsic::nvvm_read_ptx_sreg_nctaid_y:
134 Changed |= addRangeMetadata(1, MaxGridSize.y+1, Call);
136 case Intrinsic::nvvm_read_ptx_sreg_nctaid_z:
137 Changed |= addRangeMetadata(1, MaxGridSize.z+1, Call);
141 case Intrinsic::nvvm_read_ptx_sreg_warpsize:
142 Changed |= addRangeMetadata(32, 32+1, Call);
146 case Intrinsic::nvvm_read_ptx_sreg_laneid:
147 Changed |= addRangeMetadata(0, 32, Call);
159bool NVVMIntrRange::runOnFunction(
Function &
F) {
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Select target instructions out of generic instructions
static cl::opt< unsigned > NVVMIntrRangeSM("nvvm-intr-range-sm", cl::init(20), cl::Hidden, cl::desc("SM variant"))
static bool runNVVMIntrRange(Function &F, unsigned SmVersion)
This header defines various interfaces for pass management in LLVM.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
A container for analyses that lazily runs them and caches their results.
This class represents a function call, abstracting a target machine's calling convention.
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 class - This class is used to implement most global optimizations.
virtual bool runOnFunction(Function &F)=0
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
Class to represent integer types.
This is an important class for using LLVM in a threaded context.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
static IntegerType * getInt32Ty(LLVMContext &C)
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
@ Low
Lower the current thread's priority such that it does not affect foreground tasks significantly.
FunctionPass * createNVVMIntrRangePass(unsigned int SmVersion)
void initializeNVVMIntrRangePass(PassRegistry &)
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)