24#include "llvm/IR/IntrinsicsSPIRV.h"
28#define DEBUG_TYPE "spirv-pushconstant-access"
34 if (GV.getAddressSpace() !=
42 M.getContext(),
"spirv.PushConstant", {GV.getValueType()});
45 nullptr, GV.getName(),
46 &GV, GV.getThreadLocalMode(),
47 GV.getAddressSpace(), GV.isExternallyInitialized());
53 Value *GetPointerCall = Builder.CreateIntrinsic(
54 NewGV->
getType(), Intrinsic::spv_pushconstant_getpointer, {NewGV});
57 I->replaceUsesOfWith(&GV, GetPointerCall);
76class SPIRVPushConstantAccessLegacy :
public ModulePass {
80 bool runOnModule(
Module &M)
override {
86 return "SPIRV push constant Access";
88 SPIRVPushConstantAccessLegacy(SPIRVTargetMachine *TM)
89 : ModulePass(
ID), TM(TM) {}
93char SPIRVPushConstantAccessLegacy::ID = 0;
97 "SPIRV push constant Access",
false,
false)
101 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.
void setVisibility(VisibilityTypes V)
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
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
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.
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)
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.
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.