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) {
73 case Intrinsic::memcpy: {
74 auto *Memcpy = cast<MemCpyInst>(Inst);
75 if (shouldExpandOperationWithSize(Memcpy->getLength())) {
78 getAnalysis<TargetTransformInfoWrapperPass>().getTTI(*ParentFunc);
81 Memcpy->eraseFromParent();
86 case Intrinsic::memmove: {
87 auto *Memmove = cast<MemMoveInst>(Inst);
88 if (shouldExpandOperationWithSize(Memmove->getLength())) {
91 Memmove->eraseFromParent();
96 case Intrinsic::memset: {
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>();
121 bool Changed =
false;
123 for (
auto *U : F.
users()) {
128 Changed |= ST.makeLIDRangeMetadata(CI);
133 bool AMDGPULowerIntrinsics::runOnModule(
Module &M) {
134 bool Changed =
false;
141 case Intrinsic::memcpy:
142 case Intrinsic::memmove:
143 case Intrinsic::memset:
144 if (expandMemIntrinsicUses(F))
148 case Intrinsic::amdgcn_workitem_id_x:
149 case Intrinsic::r600_read_tidig_x:
150 case Intrinsic::amdgcn_workitem_id_y:
151 case Intrinsic::r600_read_tidig_y:
152 case Intrinsic::amdgcn_workitem_id_z:
153 case Intrinsic::r600_read_tidig_z:
154 case Intrinsic::r600_read_local_size_x:
155 case Intrinsic::r600_read_local_size_y:
156 case Intrinsic::r600_read_local_size_z:
157 Changed |= makeLIDRangeMetadata(F);
169 return new AMDGPULowerIntrinsics();
AMDGPU specific subclass of TargetSubtarget.
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. ...
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.
AnalysisUsage & addRequired()
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
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.
const STC & getSubtarget(const Function &F) const
This method returns a pointer to the specified type of TargetSubtargetInfo.
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()
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
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
user_iterator user_begin()
INITIALIZE_PASS(AMDGPULowerIntrinsics, DEBUG_TYPE,"Lower intrinsics", false, false) static bool shouldExpandOperationWithSize(Value *Size)
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.