20 #define DEBUG_TYPE "amdgpu-lower-intrinsics" 26 const unsigned MaxStaticSize = 1024;
28 class AMDGPULowerIntrinsics :
public ModulePass {
30 bool makeLIDRangeMetadata(
Function &
F)
const;
37 bool runOnModule(
Module &M)
override;
38 bool expandMemIntrinsicUses(
Function &F);
40 return "AMDGPU Lower Intrinsics";
59 static
bool shouldExpandOperationWithSize(
Value *
Size) {
64 bool AMDGPULowerIntrinsics::expandMemIntrinsicUses(
Function &
F) {
74 auto *Memcpy = cast<MemCpyInst>(Inst);
75 if (shouldExpandOperationWithSize(Memcpy->getLength())) {
78 getAnalysis<TargetTransformInfoWrapperPass>().getTTI(*ParentFunc);
81 Memcpy->eraseFromParent();
87 auto *Memmove = cast<MemMoveInst>(Inst);
88 if (shouldExpandOperationWithSize(Memmove->getLength())) {
91 Memmove->eraseFromParent();
97 auto *Memset = cast<MemSetInst>(Inst);
98 if (shouldExpandOperationWithSize(Memset->getLength())) {
101 Memset->eraseFromParent();
114 bool AMDGPULowerIntrinsics::makeLIDRangeMetadata(
Function &F)
const {
115 auto *TPC = getAnalysisIfAvailable<TargetPassConfig>();
120 bool Changed =
false;
122 for (
auto *U : F.
users()) {
132 bool AMDGPULowerIntrinsics::runOnModule(
Module &M) {
133 bool Changed =
false;
143 if (expandMemIntrinsicUses(F))
156 Changed |= makeLIDRangeMetadata(F);
168 return new AMDGPULowerIntrinsics();
bool makeLIDRangeMetadata(Instruction *I) const
Creates value range metadata on an workitemid.* inrinsic call or load.
AMDGPU specific subclass of TargetSubtarget.
This class represents lattice values for constants.
void expandMemMoveAsLoop(MemMoveInst *MemMove)
Expand MemMove as a loop. MemMove is not deleted.
A Module instance is used to store all the information related to an LLVM module. ...
INITIALIZE_PASS(AMDGPULowerIntrinsics, DEBUG_TYPE, "Lower intrinsics", false, false) static bool shouldExpandOperationWithSize(Value *Size)
This class represents a function call, abstracting a target machine's calling convention.
void expandMemSetAsLoop(MemSetInst *MemSet)
Expand MemSet as a loop. MemSet is not deleted.
static const AMDGPUSubtarget & get(const MachineFunction &MF)
AnalysisUsage & addRequired()
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Represent the analysis usage information of a pass.
ModulePass * createAMDGPULowerIntrinsicsPass()
This is the shared class of boolean and integer constants.
Module.h This file contains the declarations for the Module class.
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
iterator_range< user_iterator > users()
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
char & AMDGPULowerIntrinsicsID
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
user_iterator user_begin()
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
Primary interface to the complete machine description for the target machine.
StringRef - Represent a constant reference to a string, i.e.
void expandMemCpyAsLoop(MemCpyInst *MemCpy, const TargetTransformInfo &TTI)
Expand MemCpy as a loop. MemCpy is not deleted.