19 #define DEBUG_TYPE "amdgpu-lower-intrinsics" 25 const unsigned MaxStaticSize = 1024;
27 class AMDGPULowerIntrinsics :
public ModulePass {
29 bool makeLIDRangeMetadata(
Function &
F)
const;
36 bool runOnModule(
Module &M)
override;
37 bool expandMemIntrinsicUses(
Function &F);
39 return "AMDGPU Lower Intrinsics";
58 static
bool shouldExpandOperationWithSize(
Value *
Size) {
63 bool AMDGPULowerIntrinsics::expandMemIntrinsicUses(
Function &
F) {
72 case Intrinsic::memcpy: {
73 auto *Memcpy = cast<MemCpyInst>(Inst);
74 if (shouldExpandOperationWithSize(Memcpy->getLength())) {
77 getAnalysis<TargetTransformInfoWrapperPass>().getTTI(*ParentFunc);
80 Memcpy->eraseFromParent();
85 case Intrinsic::memmove: {
86 auto *Memmove = cast<MemMoveInst>(Inst);
87 if (shouldExpandOperationWithSize(Memmove->getLength())) {
90 Memmove->eraseFromParent();
95 case Intrinsic::memset: {
96 auto *Memset = cast<MemSetInst>(Inst);
97 if (shouldExpandOperationWithSize(Memset->getLength())) {
100 Memset->eraseFromParent();
113 bool AMDGPULowerIntrinsics::makeLIDRangeMetadata(
Function &F)
const {
114 auto *TPC = getAnalysisIfAvailable<TargetPassConfig>();
119 bool Changed =
false;
121 for (
auto *U : F.
users()) {
131 bool AMDGPULowerIntrinsics::runOnModule(
Module &M) {
132 bool Changed =
false;
139 case Intrinsic::memcpy:
140 case Intrinsic::memmove:
141 case Intrinsic::memset:
142 if (expandMemIntrinsicUses(F))
146 case Intrinsic::amdgcn_workitem_id_x:
147 case Intrinsic::r600_read_tidig_x:
148 case Intrinsic::amdgcn_workitem_id_y:
149 case Intrinsic::r600_read_tidig_y:
150 case Intrinsic::amdgcn_workitem_id_z:
151 case Intrinsic::r600_read_tidig_z:
152 case Intrinsic::r600_read_local_size_x:
153 case Intrinsic::r600_read_local_size_y:
154 case Intrinsic::r600_read_local_size_z:
155 Changed |= makeLIDRangeMetadata(F);
167 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.