25#include "llvm/IR/IntrinsicsSPIRV.h"
28#define DEBUG_TYPE "spirv-pushconstant-access"
34 if (GV.getAddressSpace() !=
38 GV.removeDeadConstantUsers();
41 M.getContext(),
"spirv.PushConstant", {GV.getValueType()});
44 nullptr, GV.getName(),
45 &GV, GV.getThreadLocalMode(),
46 GV.getAddressSpace(), GV.isExternallyInitialized());
51 Value *GetPointerCall = Builder.CreateIntrinsic(
52 NewGV->
getType(), Intrinsic::spv_pushconstant_getpointer, {NewGV});
55 I->replaceUsesOfWith(&GV, GetPointerCall);
74class SPIRVPushConstantAccessLegacy :
public ModulePass {
78 bool runOnModule(
Module &M)
override {
84 return "SPIRV push constant Access";
86 SPIRVPushConstantAccessLegacy(SPIRVTargetMachine *TM)
87 : ModulePass(
ID), TM(TM) {}
91char SPIRVPushConstantAccessLegacy::ID = 0;
95 "SPIRV push constant Access",
false,
false)
99 return new SPIRVPushConstantAccessLegacy(TM);
Module.h This file contains the declarations for the Module class.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static bool replacePushConstantAccesses(Module &M, SPIRVGlobalRegistry *GR)
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.
void buildAssignPtr(IRBuilder<> &B, Type *ElemTy, Value *Arg)
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
const SPIRVSubtarget * getSubtargetImpl() const
StringRef - Represent a constant reference to a string, i.e.
static LLVM_ABI TargetExtType * get(LLVMContext &Context, StringRef Name, ArrayRef< Type * > Types={}, ArrayRef< unsigned > Ints={})
Return a target extension type having the specified name and optional type and integer parameters.
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
ModulePass * createSPIRVPushConstantAccessLegacyPass(SPIRVTargetMachine *TM)
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...
constexpr unsigned storageClassToAddressSpace(SPIRV::StorageClass::StorageClass SC)
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.