36#include "llvm/IR/IntrinsicsSPIRV.h"
39#define DEBUG_TYPE "spirv-cbuffer-access"
64 Mapping.Handle->getName());
71 for (
uint32_t Index = 0; Index < Mapping.Members.size(); ++Index) {
78 Value *IndexVal = Builder.getInt32(Index);
80 Value *GetPointerCall = Builder.CreateIntrinsic(
81 PtrType, Intrinsic::spv_resource_getpointer, {HandleDef, IndexVal});
87 U->replaceUsesOfWith(MemberGV, GetPointerCall);
94 for (
const auto &Member : Mapping.Members) {
95 Member.GV->eraseFromParent();
105 I->eraseFromParent();
107 Mapping.Handle->eraseFromParent();
110 CBufMD->eraseFromModule();
123class SPIRVCBufferAccessLegacy :
public ModulePass {
126 StringRef getPassName()
const override {
return "SPIRV CBuffer Access"; }
127 SPIRVCBufferAccessLegacy() : ModulePass(
ID) {}
131char SPIRVCBufferAccessLegacy::ID = 0;
138 return new SPIRVCBufferAccessLegacy();
static bool replaceCBufferAccesses(Module &M)
Module.h This file contains the declarations for the Module class.
iv Induction Variable Users
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static bool replaceCBufferAccesses(Module &M)
static Instruction * findHandleDef(GlobalVariable *HandleVar)
PointerType * getType() const
Global values are always pointers.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
A Module instance is used to store all the information related to an LLVM module.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
iterator_range< user_iterator > users()
NodeTy * getNextNode()
Get the next node, or nullptr for the list tail.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
ModulePass * createSPIRVCBufferAccessLegacyPass()
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.