25#include "llvm/IR/IntrinsicsSPIRV.h"
29#define DEBUG_TYPE "spirv-pushconstant-access"
35 if (GV.getAddressSpace() !=
39 GV.removeDeadConstantUsers();
45 M.getContext(),
"spirv.PushConstant", {GV->getValueType()});
47 M, PCType, GV->isConstant(), GV->getLinkage(),
48 nullptr, GV->getName(),
49 GV, GV->getThreadLocalMode(), GV->getAddressSpace(),
50 GV->isExternallyInitialized());
56 Value *GetPointerCall = Builder.CreateIntrinsic(
57 NewGV->
getType(), Intrinsic::spv_pushconstant_getpointer, {NewGV});
60 for (
unsigned N = 0;
N <
I->getNumOperands(); ++
N) {
61 if (
I->getOperand(
N) == GV)
62 I->setOperand(
N, GetPointerCall);
66 GV->eraseFromParent();
81class SPIRVPushConstantAccessLegacy :
public ModulePass {
85 bool runOnModule(
Module &M)
override {
91 return "SPIRV push constant Access";
93 SPIRVPushConstantAccessLegacy(SPIRVTargetMachine *TM)
94 : ModulePass(
ID), TM(TM) {}
98char SPIRVPushConstantAccessLegacy::ID = 0;
102 "SPIRV push constant Access",
false,
false)
106 return new SPIRVPushConstantAccessLegacy(TM);
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 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
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.
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)
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.