LLVM 22.0.0git
|
#include "DXILCBufferAccess.h"
#include "DirectX.h"
#include "llvm/Frontend/HLSL/CBuffer.h"
#include "llvm/Frontend/HLSL/HLSLResource.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/IntrinsicsDirectX.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Transforms/Utils/Local.h"
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "dxil-cbuffer-access" |
Functions | |
static void | replaceLoad (LoadInst *LI, CBufferResource &CBR, SmallVectorImpl< WeakTrackingVH > &DeadInsts) |
Replace load via cbuffer global with a load from the cbuffer handle itself. | |
static void | copyArrayElemsForMemCpy (IRBuilder<> &Builder, MemCpyInst *MCI, CBufferResource &CBR, ArrayType *ArrTy, size_t ArrOffset, size_t N, const Twine &Name="") |
This function recursively copies N array elements from the cbuffer resource CBR to the MemCpy Destination. | |
static void | replaceMemCpy (MemCpyInst *MCI, CBufferResource &CBR) |
Replace memcpy from a cbuffer global with a memcpy from the cbuffer handle itself. | |
static void | replaceAccessesWithHandle (CBufferResource &CBR) |
static bool | replaceCBufferAccesses (Module &M) |
INITIALIZE_PASS (DXILCBufferAccessLegacy, DEBUG_TYPE, "DXIL CBuffer Access", false, false) ModulePass *llvm | |
#define DEBUG_TYPE "dxil-cbuffer-access" |
Definition at line 21 of file DXILCBufferAccess.cpp.
|
static |
This function recursively copies N array elements from the cbuffer resource CBR to the MemCpy Destination.
Recursion is used to unravel multidimensional arrays into a sequence of scalar/vector extracts and stores.
Definition at line 200 of file DXILCBufferAccess.cpp.
References copyArrayElemsForMemCpy(), llvm::IRBuilderBase::CreateInBoundsGEP(), llvm::IRBuilderBase::CreateStore(), DL, GEP, llvm::Instruction::getDataLayout(), llvm::MemIntrinsicBase< Derived >::getDest(), llvm::IRBuilderBase::getInt8Ty(), llvm::MemTransferBase< BaseCL >::getSource(), llvm::Value::getType(), llvm::APInt::getZExtValue(), I, llvm::MemIntrinsic::isVolatile(), N, Name, llvm::Offset, and llvm::hlsl::translateCBufArrayOffset().
Referenced by copyArrayElemsForMemCpy(), and replaceMemCpy().
INITIALIZE_PASS | ( | DXILCBufferAccessLegacy | , |
DEBUG_TYPE | , | ||
"DXIL CBuffer Access" | , | ||
false | , | ||
false | |||
) |
Definition at line 341 of file DXILCBufferAccess.cpp.
|
static |
Definition at line 273 of file DXILCBufferAccess.cpp.
References llvm_unreachable, llvm::RecursivelyDeleteTriviallyDeadInstructions(), replaceLoad(), replaceMemCpy(), llvm::Value::user_begin(), and llvm::Value::user_end().
Referenced by replaceCBufferAccesses().
Definition at line 304 of file DXILCBufferAccess.cpp.
References llvm::hlsl::CBufferMetadata::get(), and replaceAccessesWithHandle().
Referenced by llvm::DXILCBufferAccess::run().
|
static |
Replace load via cbuffer global with a load from the cbuffer handle itself.
Definition at line 187 of file DXILCBufferAccess.cpp.
References llvm::Value::getName(), llvm::LoadInst::getPointerOperand(), llvm::Value::getType(), llvm::Offset, llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::Value::replaceAllUsesWith().
Referenced by replaceAccessesWithHandle().
|
static |
Replace memcpy from a cbuffer global with a memcpy from the cbuffer handle itself.
Assumes the cbuffer global is an array, and the length of bytes to copy is divisible by array element allocation size. The memcpy source must also be a direct cbuffer global reference, not a GEP.
Definition at line 235 of file DXILCBufferAccess.cpp.
References assert(), copyArrayElemsForMemCpy(), DL, llvm::Instruction::eraseFromParent(), llvm::MemIntrinsicBase< Derived >::getDest(), llvm::MemIntrinsicBase< Derived >::getLength(), llvm::Value::getName(), llvm::MemTransferBase< BaseCL >::getSource(), llvm::Length, and llvm::reportFatalUsageError().
Referenced by replaceAccessesWithHandle().