LLVM 24.0.0git
DXILResourceAccess.cpp File Reference

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "dxil-resource-access"

Functions

static void diagnoseNonUniqueResourceAccess (Instruction *I, ArrayRef< IntrinsicInst * > Handles)
static Value * traverseGEPOffsets (const DataLayout &DL, IRBuilder<> &Builder, Value *Ptr, uint64_t AccessSize)
static void createTypedBufferStore (IntrinsicInst *II, StoreInst *SI, dxil::ResourceTypeInfo &RTI)
static Value * getNullOffsetsFor (IRBuilder<> &Builder, Value *Coords)
 Build a zero-initialized offset operand matching the shape of the given coordinate operand.
static void createTextureStore (IntrinsicInst *II, StoreInst *SI, dxil::ResourceTypeInfo &RTI)
static void emitRawStore (IRBuilder<> &Builder, Value *Buffer, Value *Index, Value *Offset, Value *V, dxil::ResourceTypeInfo &RTI)
static void createRawStores (IntrinsicInst *II, StoreInst *SI, dxil::ResourceTypeInfo &RTI)
static void createStoreIntrinsic (IntrinsicInst *II, StoreInst *SI, dxil::ResourceTypeInfo &RTI)
static std::optional< dxil::AtomicBinOpCode > getAtomicBinOpCode (AtomicRMWInst::BinOp BinOp)
static std::pair< Value *, Value * > getAtomicResourceCoords (IntrinsicInst *II, Value *PointerOperand, dxil::ResourceTypeInfo &RTI, IRBuilder<> &Builder, const DataLayout &DL)
static SmallVector< Value *, 3 > getTextureAtomicCoords (IntrinsicInst *II, IRBuilder<> &Builder)
static void emitAtomicBinOp (IRBuilder<> &Builder, AtomicRMWInst *AI, Value *Handle, ArrayRef< Value * > Coords)
static void createBufferAtomicBinOp (IntrinsicInst *II, AtomicRMWInst *AI, dxil::ResourceTypeInfo &RTI)
static void createTextureAtomicBinOp (IntrinsicInst *II, AtomicRMWInst *AI, dxil::ResourceTypeInfo &RTI)
static void emitAtomicCompareExchange (IRBuilder<> &Builder, AtomicCmpXchgInst *AI, Value *Handle, ArrayRef< Value * > Coords)
static void createBufferAtomicCompareExchange (IntrinsicInst *II, AtomicCmpXchgInst *AI, dxil::ResourceTypeInfo &RTI)
static void createTextureAtomicCompareExchange (IntrinsicInst *II, AtomicCmpXchgInst *AI, dxil::ResourceTypeInfo &RTI)
static void createAtomicBinOpIntrinsic (IntrinsicInst *II, AtomicRMWInst *AI, dxil::ResourceTypeInfo &RTI)
static void createAtomicCompareExchangeIntrinsic (IntrinsicInst *II, AtomicCmpXchgInst *AI, dxil::ResourceTypeInfo &RTI)
static void createTypedBufferLoad (IntrinsicInst *II, LoadInst *LI, dxil::ResourceTypeInfo &RTI)
static void createTextureLoad (IntrinsicInst *II, LoadInst *LI, dxil::ResourceTypeInfo &RTI)
static Value * emitRawLoad (IRBuilder<> &Builder, Type *Ty, Value *Buffer, Value *Index, Value *Offset, dxil::ResourceTypeInfo &RTI)
static void createRawLoads (IntrinsicInst *II, LoadInst *LI, dxil::ResourceTypeInfo &RTI)
static Value * loadCBufferRowIntoWindow (IRBuilder<> &Builder, const CBufferRowIntrin &Intrin, Value *Handle, Value *FirstRow, Value *Window, unsigned RowNumber, StringRef Name)
static Value * createDynamicCBufferLoad (IntrinsicInst *II, LoadInst *LI, const CBufferRowIntrin &Intrin, Value *BaseRow, Value *ByteOffset, const KnownBits &WithinRow)
static KnownBits computeCBufferOffsetKnownBits (Value *Offset, const DataLayout &DL, const Instruction *CxtI)
static void createCBufferLoad (IntrinsicInst *II, LoadInst *LI, dxil::ResourceTypeInfo &RTI)
static void createLoadIntrinsic (IntrinsicInst *II, LoadInst *LI, dxil::ResourceTypeInfo &RTI)
static Instruction * getHandleOperand (Instruction *AI)
static Instruction * getHandleRoot (Instruction *I)
static SmallVector< IntrinsicInst * > collectUsedHandles (Value *Ptr)
static hlsl::Binding getHandleIntrinsicBinding (IntrinsicInst *Handle, DXILResourceTypeMap &DRTM)
static Value * accumulateGEPOffset (GetElementPtrInst *GEP, IRBuilder<> &Builder)
static AccessIndices getAccessIndices (Instruction *I, SmallSetVector< Instruction *, 16 > &DeadInsts, PhiAccessIndicesMap &VisitedPhis)
static void replaceHandleWithIndices (Instruction *Ptr, IntrinsicInst *OldHandle, SmallSetVector< Instruction *, 16 > &DeadInsts, PhiAccessIndicesMap &VisitedPhis)
static bool legalizeResourceHandles (Function &F, DXILResourceTypeMap &DRTM)
static void replaceAccess (IntrinsicInst *II, dxil::ResourceTypeInfo &RTI)
static bool transformResourcePointers (Function &F, DXILResourceTypeMap &DRTM)
 INITIALIZE_PASS_BEGIN (DXILResourceAccessLegacy, DEBUG_TYPE, "DXIL Resource Access", false, false) INITIALIZE_PASS_END(DXILResourceAccessLegacy

Variables

static const std::array< Intrinsic::ID, 2 > HandleIntrins
 DEBUG_TYPE
DXIL Resource Access
DXIL Resource false

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "dxil-resource-access"

Definition at line 40 of file DXILResourceAccess.cpp.

Function Documentation

◆ accumulateGEPOffset()

Value * accumulateGEPOffset ( GetElementPtrInst * GEP,
IRBuilder<> & Builder )
static

◆ collectUsedHandles()

◆ computeCBufferOffsetKnownBits()

KnownBits computeCBufferOffsetKnownBits ( Value * Offset,
const DataLayout & DL,
const Instruction * CxtI )
static

◆ createAtomicBinOpIntrinsic()

◆ createAtomicCompareExchangeIntrinsic()

◆ createBufferAtomicBinOp()

◆ createBufferAtomicCompareExchange()

◆ createCBufferLoad()

◆ createDynamicCBufferLoad()

◆ createLoadIntrinsic()

◆ createRawLoads()

◆ createRawStores()

◆ createStoreIntrinsic()

◆ createTextureAtomicBinOp()

◆ createTextureAtomicCompareExchange()

◆ createTextureLoad()

◆ createTextureStore()

◆ createTypedBufferLoad()

◆ createTypedBufferStore()

◆ diagnoseNonUniqueResourceAccess()

void diagnoseNonUniqueResourceAccess ( Instruction * I,
ArrayRef< IntrinsicInst * > Handles )
static

Definition at line 45 of file DXILResourceAccess.cpp.

References llvm::DS_Note, I, and llvm::report_fatal_error().

Referenced by legalizeResourceHandles().

◆ emitAtomicBinOp()

◆ emitAtomicCompareExchange()

◆ emitRawLoad()

Value * emitRawLoad ( IRBuilder<> & Builder,
Type * Ty,
Value * Buffer,
Value * Index,
Value * Offset,
dxil::ResourceTypeInfo & RTI )
static

◆ emitRawStore()

void emitRawStore ( IRBuilder<> & Builder,
Value * Buffer,
Value * Index,
Value * Offset,
Value * V,
dxil::ResourceTypeInfo & RTI )
static

◆ getAccessIndices()

◆ getAtomicBinOpCode()

◆ getAtomicResourceCoords()

std::pair< Value *, Value * > getAtomicResourceCoords ( IntrinsicInst * II,
Value * PointerOperand,
dxil::ResourceTypeInfo & RTI,
IRBuilder<> & Builder,
const DataLayout & DL )
static

◆ getHandleIntrinsicBinding()

◆ getHandleOperand()

Instruction * getHandleOperand ( Instruction * AI)
static

Definition at line 1029 of file DXILResourceAccess.cpp.

References llvm::dyn_cast(), and II.

Referenced by legalizeResourceHandles().

◆ getHandleRoot()

Instruction * getHandleRoot ( Instruction * I)
static

Definition at line 1045 of file DXILResourceAccess.cpp.

References llvm::dyn_cast(), GEP, and I.

Referenced by legalizeResourceHandles().

◆ getNullOffsetsFor()

Value * getNullOffsetsFor ( IRBuilder<> & Builder,
Value * Coords )
static

Build a zero-initialized offset operand matching the shape of the given coordinate operand.

Accesses through operator[] never have offsets.

Definition at line 161 of file DXILResourceAccess.cpp.

References llvm::dyn_cast(), llvm::FixedVectorType::get(), llvm::Type::getInt32Ty(), llvm::Constant::getNullValue(), and llvm::Value::getType().

Referenced by createTextureLoad(), and createTextureStore().

◆ getTextureAtomicCoords()

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( DXILResourceAccessLegacy ,
DEBUG_TYPE ,
"DXIL Resource Access" ,
false ,
false  )

◆ legalizeResourceHandles()

◆ loadCBufferRowIntoWindow()

Value * loadCBufferRowIntoWindow ( IRBuilder<> & Builder,
const CBufferRowIntrin & Intrin,
Value * Handle,
Value * FirstRow,
Value * Window,
unsigned RowNumber,
StringRef Name )
static

Definition at line 755 of file DXILResourceAccess.cpp.

Referenced by createDynamicCBufferLoad().

◆ replaceAccess()

◆ replaceHandleWithIndices()

◆ transformResourcePointers()

bool transformResourcePointers ( Function & F,
DXILResourceTypeMap & DRTM )
static

◆ traverseGEPOffsets()

Variable Documentation

◆ Access

◆ DEBUG_TYPE

DEBUG_TYPE

Definition at line 1531 of file DXILResourceAccess.cpp.

◆ false

DXIL Resource false

Definition at line 1532 of file DXILResourceAccess.cpp.

◆ HandleIntrins

const std::array<Intrinsic::ID, 2> HandleIntrins
static
Initial value:
= {
Intrinsic::dx_resource_handlefrombinding,
Intrinsic::dx_resource_handlefromimplicitbinding,
}

Definition at line 1055 of file DXILResourceAccess.cpp.

Referenced by collectUsedHandles(), getAccessIndices(), and getHandleIntrinsicBinding().