LLVM 20.0.0git
|
#include "AMDGPU.h"
#include "AMDGPUTargetMachine.h"
#include "GCNSubtarget.h"
#include "SIDefines.h"
#include "llvm/ADT/SetOperations.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Analysis/Utils/Local.h"
#include "llvm/CodeGen/TargetPassConfig.h"
#include "llvm/IR/AttributeMask.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/InstVisitor.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/IntrinsicsAMDGPU.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Operator.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/IR/ReplaceConstant.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/Support/Alignment.h"
#include "llvm/Support/AtomicOrdering.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/ValueMapper.h"
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "amdgpu-lower-buffer-fat-pointers" |
#define | PASS_DESC "Lower buffer fat pointer operations to buffer resources" |
Typedefs | |
using | PtrParts = std::pair< Value *, Value * > |
Functions | |
static bool | isBufferFatPtrOrVector (Type *Ty) |
static bool | isSplitFatPtr (Type *Ty) |
static bool | isBufferFatPtrConst (Constant *C) |
static std::pair< Constant *, Constant * > | splitLoweredFatBufferConst (Constant *C) |
Return the ptr addrspace(8) and i32 (resource and offset parts) in a lowered buffer fat pointer constant. | |
static Value * | rsrcPartRoot (Value *V) |
Returns the instruction that defines the resource part of the value V. | |
static bool | isRemovablePointerIntrinsic (Intrinsic::ID IID) |
Returns true if this intrinsic needs to be removed when it is applied to ptr addrspace(7) values. | |
static bool | containsBufferFatPointers (const Function &F, BufferFatPtrToStructTypeMap *TypeMap) |
Returns true if there are values that have a buffer fat pointer in them, which means we'll need to perform rewrites on this function. | |
static bool | hasFatPointerInterface (const Function &F, BufferFatPtrToStructTypeMap *TypeMap) |
static Function * | moveFunctionAdaptingType (Function *OldF, FunctionType *NewTy, ValueToValueMapTy &CloneMap) |
Move the body of OldF into a new function, returning it. | |
static void | makeCloneInPraceMap (Function *F, ValueToValueMapTy &CloneMap) |
INITIALIZE_PASS_BEGIN (AMDGPULowerBufferFatPointers, DEBUG_TYPE, PASS_DESC, false, false) INITIALIZE_PASS_END(AMDGPULowerBufferFatPointers | |
Variables | |
static constexpr unsigned | BufferOffsetWidth = 32 |
DEBUG_TYPE | |
PASS_DESC | |
false | |
#define DEBUG_TYPE "amdgpu-lower-buffer-fat-pointers" |
Definition at line 250 of file AMDGPULowerBufferFatPointers.cpp.
#define PASS_DESC "Lower buffer fat pointer operations to buffer resources" |
Definition at line 2399 of file AMDGPULowerBufferFatPointers.cpp.
Definition at line 1232 of file AMDGPULowerBufferFatPointers.cpp.
|
static |
Returns true if there are values that have a buffer fat pointer in them, which means we'll need to perform rewrites on this function.
As a side effect, this will populate the type remapping cache.
Definition at line 2195 of file AMDGPULowerBufferFatPointers.cpp.
|
static |
Definition at line 2204 of file AMDGPULowerBufferFatPointers.cpp.
References F.
INITIALIZE_PASS_BEGIN | ( | AMDGPULowerBufferFatPointers | , |
DEBUG_TYPE | , | ||
PASS_DESC | , | ||
false | , | ||
false | |||
) |
Definition at line 418 of file AMDGPULowerBufferFatPointers.cpp.
References llvm::any_of(), llvm::CallingConv::C, and isBufferFatPtrOrVector().
Definition at line 394 of file AMDGPULowerBufferFatPointers.cpp.
References llvm::AMDGPUAS::BUFFER_FAT_POINTER, and llvm::Type::getScalarType().
Referenced by isBufferFatPtrConst().
|
static |
Returns true if this intrinsic needs to be removed when it is applied to ptr addrspace(7)
values.
Calls to these intrinsics are rewritten into calls to versions of that intrinsic on the resource descriptor.
Definition at line 2066 of file AMDGPULowerBufferFatPointers.cpp.
Definition at line 402 of file AMDGPULowerBufferFatPointers.cpp.
References llvm::AMDGPUAS::BUFFER_RESOURCE, and BufferOffsetWidth.
Referenced by splitLoweredFatBufferConst().
|
static |
Definition at line 2264 of file AMDGPULowerBufferFatPointers.cpp.
|
static |
Move the body of OldF
into a new function, returning it.
Definition at line 2211 of file AMDGPULowerBufferFatPointers.cpp.
References llvm::Function::args(), llvm::Function::copyAttributesFrom(), llvm::GlobalObject::copyMetadata(), llvm::Function::Create(), llvm::Function::empty(), llvm::enumerate(), llvm::Function::front(), llvm::AttributeList::get(), llvm::GlobalValue::getAddressSpace(), llvm::Function::getAttributes(), llvm::Function::getContext(), llvm::GlobalValue::getDLLStorageClass(), llvm::AttributeList::getFnAttrs(), llvm::Module::getFunctionList(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::GlobalValue::getLinkage(), llvm::AttributeList::getParamAttrs(), llvm::GlobalValue::getParent(), llvm::AttributeList::getRetAttrs(), llvm::Function::getReturnType(), I, llvm::iplist_impl< IntrusiveListT, TraitsT >::insertAfter(), llvm::BasicBlock::insertInto(), llvm::Function::isIntrinsic(), llvm::Function::IsNewDbgInfoFormat, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::AttributeSet::removeAttributes(), llvm::BasicBlock::removeFromParent(), llvm::Function::setAttributes(), llvm::GlobalValue::setDLLStorageClass(), llvm::Value::takeName(), llvm::AttributeFuncs::typeIncompatible(), and llvm::Function::updateAfterNameChange().
Returns the instruction that defines the resource part of the value V.
Note that this is not getUnderlyingObject(), since that looks through operations like ptrmask which might modify the resource part.
We can limit ourselves to just looking through GEPs followed by looking through addrspacecasts because only those two operations preserve the resource part, and because operations on an addrspace(8)
(which is the legal input to this addrspacecast) would produce a different resource part.
Definition at line 1378 of file AMDGPULowerBufferFatPointers.cpp.
References GEP.
Return the ptr addrspace(8) and i32 (resource and offset parts) in a lowered buffer fat pointer constant.
Definition at line 1139 of file AMDGPULowerBufferFatPointers.cpp.
References assert(), llvm::CallingConv::C, and isSplitFatPtr().
|
staticconstexpr |
Definition at line 254 of file AMDGPULowerBufferFatPointers.cpp.
Referenced by isSplitFatPtr().
DEBUG_TYPE |
Definition at line 2403 of file AMDGPULowerBufferFatPointers.cpp.
false |
Definition at line 2403 of file AMDGPULowerBufferFatPointers.cpp.
PASS_DESC |
Definition at line 2403 of file AMDGPULowerBufferFatPointers.cpp.