22#include "llvm/IR/IntrinsicsNVPTX.h"
31 SmallVector<Instruction*, 4> InstrToDelete;
34 NVPTXImageOptimizer();
38 StringRef getPassName()
const override {
return "NVPTX Image Optimizer"; }
43 void replaceWith(Instruction *From, ConstantInt *To);
47char NVPTXImageOptimizer::ID = 0;
49NVPTXImageOptimizer::NVPTXImageOptimizer()
52bool NVPTXImageOptimizer::runOnFunction(
Function &
F) {
57 InstrToDelete.
clear();
60 for (BasicBlock &BB :
F) {
61 for (Instruction &Instr : BB) {
63 Function *CalledF = CI->getCalledFunction();
68 case Intrinsic::nvvm_istypep_sampler:
69 Changed |= replaceIsTypeP(Instr, PTXOpaqueType::Sampler);
71 case Intrinsic::nvvm_istypep_surface:
72 Changed |= replaceIsTypeP(Instr, PTXOpaqueType::Surface);
74 case Intrinsic::nvvm_istypep_texture:
75 Changed |= replaceIsTypeP(Instr, PTXOpaqueType::Texture);
84 for (Instruction *
I : InstrToDelete)
90bool NVPTXImageOptimizer::replaceIsTypeP(Instruction &
I,
93 if (OT == PTXOpaqueType::None)
99void NVPTXImageOptimizer::replaceWith(Instruction *From, ConstantInt *To) {
103 for (Use &U : From->
uses()) {
107 InstrToDelete.push_back(BI);
111 InstrToDelete.push_back(From);
114Value *NVPTXImageOptimizer::cleanupValue(
Value *V) {
116 return cleanupValue(EVI->getAggregateOperand());
122 return new NVPTXImageOptimizer();
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static bool runOnFunction(Function &F, bool PostInlining)
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.".
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()
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ BasicBlock
Various leaf nodes.
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
FunctionPass * createNVPTXImageOptimizerPass()
PTXOpaqueType getPTXOpaqueType(const GlobalVariable &GV)