25#include "llvm/IR/IntrinsicsSPIRV.h"
29#define DEBUG_TYPE "spirv-pushconstant-access"
35 if (GV.getAddressSpace() !=
43 M.getContext(),
"spirv.PushConstant", {GV.getValueType()});
46 nullptr, GV.getName(),
47 &GV, GV.getThreadLocalMode(),
48 GV.getAddressSpace(), GV.isExternallyInitialized());
54 Value *GetPointerCall = Builder.CreateIntrinsic(
55 NewGV->
getType(), Intrinsic::spv_pushconstant_getpointer, {NewGV});
58 I->replaceUsesOfWith(&GV, GetPointerCall);
77class SPIRVPushConstantAccessLegacy :
public ModulePass {
81 bool runOnModule(
Module &M)
override {
87 return "SPIRV push constant Access";
89 SPIRVPushConstantAccessLegacy(SPIRVTargetMachine *TM)
90 : ModulePass(
ID), TM(TM) {}
94char SPIRVPushConstantAccessLegacy::ID = 0;
98 "SPIRV push constant Access",
false,
false)
102 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.
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)
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.