LLVM 20.0.0git
Macros | Typedefs | Functions | Variables
AMDGPULowerBufferFatPointers.cpp File Reference
#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/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 ValuersrcPartRoot (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 FunctionmoveFunctionAdaptingType (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
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "amdgpu-lower-buffer-fat-pointers"

Definition at line 228 of file AMDGPULowerBufferFatPointers.cpp.

◆ PASS_DESC

#define PASS_DESC   "Lower buffer fat pointer operations to buffer resources"

Definition at line 1850 of file AMDGPULowerBufferFatPointers.cpp.

Typedef Documentation

◆ PtrParts

using PtrParts = std::pair<Value *, Value *>

Definition at line 675 of file AMDGPULowerBufferFatPointers.cpp.

Function Documentation

◆ containsBufferFatPointers()

static bool containsBufferFatPointers ( const Function F,
BufferFatPtrToStructTypeMap *  TypeMap 
)
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 1646 of file AMDGPULowerBufferFatPointers.cpp.

References F, and I.

◆ hasFatPointerInterface()

static bool hasFatPointerInterface ( const Function F,
BufferFatPtrToStructTypeMap *  TypeMap 
)
static

Definition at line 1655 of file AMDGPULowerBufferFatPointers.cpp.

References F.

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( AMDGPULowerBufferFatPointers  ,
DEBUG_TYPE  ,
PASS_DESC  ,
false  ,
false   
)

◆ isBufferFatPtrConst()

static bool isBufferFatPtrConst ( Constant C)
static

◆ isBufferFatPtrOrVector()

static bool isBufferFatPtrOrVector ( Type Ty)
static

◆ isRemovablePointerIntrinsic()

static bool isRemovablePointerIntrinsic ( Intrinsic::ID  IID)
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 1517 of file AMDGPULowerBufferFatPointers.cpp.

◆ isSplitFatPtr()

static bool isSplitFatPtr ( Type Ty)
static

◆ makeCloneInPraceMap()

static void makeCloneInPraceMap ( Function F,
ValueToValueMapTy CloneMap 
)
static

Definition at line 1719 of file AMDGPULowerBufferFatPointers.cpp.

References A, F, and I.

◆ moveFunctionAdaptingType()

static Function * moveFunctionAdaptingType ( Function OldF,
FunctionType NewTy,
ValueToValueMapTy CloneMap 
)
static

◆ rsrcPartRoot()

static Value * rsrcPartRoot ( Value V)
static

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 821 of file AMDGPULowerBufferFatPointers.cpp.

References GEP.

◆ splitLoweredFatBufferConst()

static std::pair< Constant *, Constant * > splitLoweredFatBufferConst ( Constant C)
static

Return the ptr addrspace(8) and i32 (resource and offset parts) in a lowered buffer fat pointer constant.

Definition at line 582 of file AMDGPULowerBufferFatPointers.cpp.

References assert(), llvm::CallingConv::C, and isSplitFatPtr().

Variable Documentation

◆ BufferOffsetWidth

constexpr unsigned BufferOffsetWidth = 32
staticconstexpr

Definition at line 232 of file AMDGPULowerBufferFatPointers.cpp.

Referenced by isSplitFatPtr().

◆ DEBUG_TYPE

DEBUG_TYPE

Definition at line 1854 of file AMDGPULowerBufferFatPointers.cpp.

◆ false

false

Definition at line 1854 of file AMDGPULowerBufferFatPointers.cpp.

◆ PASS_DESC

PASS_DESC

Definition at line 1854 of file AMDGPULowerBufferFatPointers.cpp.