16#include "llvm/IR/IntrinsicsDirectX.h"
23#define DEBUG_TYPE "dxil-cbuffer-access"
31 assert(UseInst &&
"Non-instruction use of cbuffer");
36 Value *Ptr = Builder.CreateIntrinsic(
37 Global->getType(), Intrinsic::dx_resource_getpointer,
39 ConstantInt::get(Builder.getInt32Ty(), Offset)});
43 Global->removeFromParent();
62 CBufMD->eraseFromModule();
76class DXILCBufferAccessLegacy :
public ModulePass {
79 StringRef getPassName()
const override {
return "DXIL CBuffer Access"; }
80 DXILCBufferAccessLegacy() : ModulePass(
ID) {}
84char DXILCBufferAccessLegacy::ID = 0;
91 return new DXILCBufferAccessLegacy();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static bool replaceCBufferAccesses(Module &M)
static void replaceUsersOfGlobal(GlobalVariable *Global, GlobalVariable *HandleGV, size_t Offset)
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Type * getValueType() const
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
An instruction for reading from memory.
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 all()
Construct a special preserved set that preserves all passes.
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.
A Use represents the edge between a Value definition and its users.
LLVM Value Representation.
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
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.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
ModulePass * createDXILCBufferAccessLegacyPass()
Pass to translate loads in the cbuffer address space to intrinsics.
LLVM_ABI bool convertUsersOfConstantsToInstructions(ArrayRef< Constant * > Consts, Function *RestrictToFunc=nullptr, bool RemoveDeadConstants=true, bool IncludeSelf=false)
Replace constant expressions users of the given constants with instructions.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
@ Global
Append to llvm.global_dtors.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.