22#include "llvm/IR/IntrinsicsNVPTX.h"
28class NVPTXImageOptimizer {
29 SmallVector<Instruction *, 4> InstrToDelete;
37 void replaceWith(Instruction *From, ConstantInt *To);
41bool NVPTXImageOptimizer::run(
Function &
F) {
43 InstrToDelete.
clear();
46 for (BasicBlock &BB :
F) {
47 for (Instruction &Instr : BB) {
49 Function *CalledF = CI->getCalledFunction();
54 case Intrinsic::nvvm_istypep_sampler:
55 Changed |= replaceIsTypeP(Instr, PTXOpaqueType::Sampler);
57 case Intrinsic::nvvm_istypep_surface:
58 Changed |= replaceIsTypeP(Instr, PTXOpaqueType::Surface);
60 case Intrinsic::nvvm_istypep_texture:
61 Changed |= replaceIsTypeP(Instr, PTXOpaqueType::Texture);
70 for (Instruction *
I : InstrToDelete)
76bool NVPTXImageOptimizer::replaceIsTypeP(Instruction &
I,
79 if (OT == PTXOpaqueType::None)
85void NVPTXImageOptimizer::replaceWith(Instruction *From, ConstantInt *To) {
89 for (Use &U : From->
uses()) {
93 InstrToDelete.push_back(BI);
97 InstrToDelete.push_back(From);
100Value *NVPTXImageOptimizer::cleanupValue(
Value *V) {
102 return cleanupValue(EVI->getAggregateOperand());
108class NVPTXImageOptimizerLegacyPass :
public FunctionPass {
111 NVPTXImageOptimizerLegacyPass() : FunctionPass(
ID) {}
116 return NVPTXImageOptimizer().run(
F);
119 StringRef getPassName()
const override {
return "NVPTX Image Optimizer"; }
123char NVPTXImageOptimizerLegacyPass::ID = 0;
126 return new NVPTXImageOptimizerLegacyPass();
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static bool runOnFunction(Function &F, bool PostInlining)
FunctionAnalysisManager FAM
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
static LLVM_ABI ConstantInt * getBool(LLVMContext &Context, bool V)
FunctionPass class - This class is used to implement most global optimizations.
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
bool isIntrinsic() const
isIntrinsic - Returns true if the function's name starts with "llvm.".
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
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.
static UncondBrInst * Create(BasicBlock *Target, InsertPosition InsertBefore=nullptr)
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
iterator_range< use_iterator > uses()
@ BasicBlock
Various leaf nodes.
DXILDebugInfoMap run(Module &M)
This is an optimization pass for GlobalISel generic memory operations.
FunctionPass * createNVPTXImageOptimizerLegacyPass()
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
PTXOpaqueType getPTXOpaqueType(const GlobalVariable &)
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.