32 #define DEBUG_TYPE "nvptx" 51 static const unsigned MaxAggrCopySize = 128;
54 return "Lower aggregate copies/intrinsics into loops";
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);
123 LI->eraseFromParent();
128 if (
MemCpyInst *Memcpy = dyn_cast<MemCpyInst>(MemCall)) {
130 }
else if (
MemMoveInst *Memmove = dyn_cast<MemMoveInst>(MemCall)) {
132 }
else if (
MemSetInst *Memset = dyn_cast<MemSetInst>(MemCall)) {
135 MemCall->eraseFromParent();
148 "Lower aggregate copies, and llvm.mem* intrinsics into loops",
152 return new NVPTXLowerAggrCopies();
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
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.
This class represents lattice values for constants.
void expandMemMoveAsLoop(MemMoveInst *MemMove)
Expand MemMove as a loop. MemMove is not deleted.
void push_back(const T &Elt)
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()
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
This class wraps the llvm.memmove intrinsic.
LLVMContext & getContext() const
Get the global data context.
An instruction for storing to memory.
Value * getOperand(unsigned i) const
static bool runOnFunction(Function &F, bool PostInlining)
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.
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.
bool isVolatile() const
Return true if this is a store to a volatile memory location.
FunctionPass * createLowerAggrCopies()
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)
unsigned getAlignment() const
Return the alignment of the access that is being performed.
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.
uint64_t getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
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.
INITIALIZE_PASS(NVPTXLowerAggrCopies, "nvptx-lower-aggr-copies", "Lower aggregate copies, and llvm.mem* intrinsics into loops", false, false) FunctionPass *llvm