32 #define DEBUG_TYPE "nvptx"
51 static const unsigned MaxAggrCopySize = 128;
54 return "Lower aggregate copies/intrinsics into loops";
60 bool NVPTXLowerAggrCopies::runOnFunction(
Function &
F) {
67 getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
73 if (
LoadInst *LI = dyn_cast<LoadInst>(II)) {
80 if (
StoreInst *
SI = dyn_cast<StoreInst>(LI->user_back())) {
81 if (
SI->getOperand(0) != LI)
85 }
else if (
MemIntrinsic *IntrCall = dyn_cast<MemIntrinsic>(II)) {
88 if (
ConstantInt *LenCI = dyn_cast<ConstantInt>(IntrCall->getLength())) {
89 if (LenCI->getZExtValue() >= MaxAggrCopySize) {
99 if (AggrLoads.
size() == 0 && MemCalls.
size() == 0) {
108 Value *SrcAddr = LI->getOperand(0);
133 LI->eraseFromParent();
138 if (
MemCpyInst *Memcpy = dyn_cast<MemCpyInst>(MemCall)) {
140 }
else if (
MemMoveInst *Memmove = dyn_cast<MemMoveInst>(MemCall)) {
142 }
else if (
MemSetInst *Memset = dyn_cast<MemSetInst>(MemCall)) {
145 MemCall->eraseFromParent();
158 "Lower aggregate copies, and llvm.mem* intrinsics into loops",
162 return new NVPTXLowerAggrCopies();
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
void push_back(const T &Elt)
A parsed version of the target data layout string in and methods for querying it. ...
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
bool isVolatile() const
Return true if this is a store to a volatile memory location.
void expandMemMoveAsLoop(MemMoveInst *MemMove)
Expand MemMove as a loop. MemMove is not deleted.
This class wraps the llvm.memset intrinsic.
An instruction for reading from memory.
void expandMemSetAsLoop(MemSetInst *MemSet)
Expand MemSet as a loop. MemSet is not deleted.
AnalysisUsage & addRequired()
This class wraps the llvm.memmove intrinsic.
void createMemCpyLoop(Instruction *InsertBefore, Value *SrcAddr, Value *DstAddr, Value *CopyLen, unsigned SrcAlign, unsigned DestAlign, bool SrcIsVolatile, bool DstIsVolatile)
Emit a loop implementing the semantics of llvm.memcpy with the equivalent arguments at InsertBefore...
An instruction for storing to memory.
unsigned getAlignment() const
Return the alignment of the access that is being performed.
void initializeNVPTXLowerAggrCopiesPass(PassRegistry &)
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...
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
Value * getOperand(unsigned i) const
This is the common base class for memset/memcpy/memmove.
Iterator for intrusive lists based on ilist_node.
This is the shared class of boolean and integer constants.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Module.h This file contains the declarations for the Module class.
This class wraps the llvm.memcpy intrinsic.
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.
INITIALIZE_PASS(NVPTXLowerAggrCopies,"nvptx-lower-aggr-copies","Lower aggregate copies, and llvm.mem* intrinsics into loops", false, false) FunctionPass *llvm
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
FunctionPass * createLowerAggrCopies()
static IntegerType * getInt32Ty(LLVMContext &C)
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
uint64_t getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
void createMemCpyLoopKnownSize(Instruction *InsertBefore, Value *SrcAddr, Value *DstAddr, ConstantInt *CopyLen, unsigned SrcAlign, unsigned DestAlign, bool SrcIsVolatile, bool DstIsVolatile, const TargetTransformInfo &TTI)
Emit a loop implementing the semantics of an llvm.memcpy whose size is a compile time constant...
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
StringRef - Represent a constant reference to a string, i.e.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
void expandMemCpyAsLoop(MemCpyInst *MemCpy, const TargetTransformInfo &TTI)
Expand MemCpy as a loop. MemCpy is not deleted.
LLVMContext & getContext() const
Get the global data context.