Go to the documentation of this file.
102 using namespace llvm;
121 void markPointerAsGlobal(
Value *Ptr);
128 return "Lower pointer arguments of CUDA kernels";
139 "Lower arguments (NVPTX)",
false,
false)
154 void NVPTXLowerArgs::handleByValParam(
Argument *
Arg) {
156 Instruction *FirstInst = &(Func->getEntryBlock().front());
159 assert(PType &&
"Expecting pointer type in handleByValParam");
162 const DataLayout &
DL = Func->getParent()->getDataLayout();
163 unsigned AS =
DL.getAllocaAddrSpace();
170 Arg->replaceAllUsesWith(AllocA);
180 false, AllocA->
getAlign(), FirstInst);
184 void NVPTXLowerArgs::markPointerAsGlobal(
Value *Ptr) {
192 InsertPt =
Arg->getParent()->getEntryBlock().begin();
195 InsertPt = ++cast<Instruction>(Ptr)->getIterator();
196 assert(InsertPt != InsertPt->getParent()->end() &&
197 "We don't call this function with Ptr being a terminator.");
214 bool NVPTXLowerArgs::runOnKernelFunction(
Function &
F) {
219 if (
LoadInst *LI = dyn_cast<LoadInst>(&
I)) {
220 if (LI->getType()->isPointerTy()) {
223 if (
Arg->hasByValAttr()) {
225 markPointerAsGlobal(LI);
235 if (
Arg.getType()->isPointerTy()) {
236 if (
Arg.hasByValAttr())
237 handleByValParam(&
Arg);
239 markPointerAsGlobal(&
Arg);
246 bool NVPTXLowerArgs::runOnDeviceFunction(
Function &
F) {
248 if (
Arg.getType()->isPointerTy() &&
Arg.hasByValAttr())
249 handleByValParam(&
Arg);
259 return new NVPTXLowerArgs(
TM);
Value * getUnderlyingObject(Value *V, unsigned MaxLookup=6)
This method strips off any GEP address adjustments and pointer casts from the specified value,...
This class represents an incoming formal argument to a Function.
This class represents lattice values for constants.
A parsed version of the target data layout string in and methods for querying it.
InstListType::iterator iterator
Instruction iterators...
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
Type * getElementType() const
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
The instances of the Type class are immutable: once they are created, they are never changed.
FunctionPass * createNVPTXLowerArgsPass(const NVPTXTargetMachine *TM)
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
This class represents a conversion between pointers from one address space to another.
INITIALIZE_PASS(NVPTXLowerArgs, "nvptx-lower-args", "Lower arguments (NVPTX)", false, false) void NVPTXLowerArgs
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
bool isKernelFunction(const Function &F)
An instruction for storing to memory.
Class to represent pointers.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void setOperand(unsigned i, Value *Val)
Class to represent struct types.
StringRef - Represent a constant reference to a string, i.e.
Type * getType() const
All values are typed, get the type of this value.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
StringRef getName() const
Return a constant reference to the value's name.
An instruction for reading from memory.
static bool runOnFunction(Function &F, bool PostInlining)
void setAlignment(Align Align)
Type * getPointerElementType() const
void initializeNVPTXLowerArgsPass(PassRegistry &)
FunctionPass class - This class is used to implement most global optimizations.
an instruction to allocate memory on the stack
LLVM Value Representation.