Go to the documentation of this file.
21 #include "llvm/IR/IntrinsicsNVPTX.h"
34 NVPTXImageOptimizer();
49 NVPTXImageOptimizer::NVPTXImageOptimizer()
57 InstrToDelete.clear();
62 if (
CallInst *CI = dyn_cast<CallInst>(&Instr)) {
63 Function *CalledF = CI->getCalledFunction();
68 case Intrinsic::nvvm_istypep_sampler:
69 Changed |= replaceIsTypePSampler(Instr);
71 case Intrinsic::nvvm_istypep_surface:
72 Changed |= replaceIsTypePSurface(Instr);
74 case Intrinsic::nvvm_istypep_texture:
75 Changed |= replaceIsTypePTexture(Instr);
90 bool NVPTXImageOptimizer::replaceIsTypePSampler(
Instruction &
I) {
91 Value *TexHandle = cleanupValue(
I.getOperand(0));
96 }
else if (
isImage(*TexHandle)) {
106 bool NVPTXImageOptimizer::replaceIsTypePSurface(
Instruction &
I) {
107 Value *TexHandle = cleanupValue(
I.getOperand(0));
125 bool NVPTXImageOptimizer::replaceIsTypePTexture(
Instruction &
I) {
126 Value *TexHandle = cleanupValue(
I.getOperand(0));
149 if (
BranchInst *BI = dyn_cast<BranchInst>(U)) {
150 if (BI->isUnconditional())
continue;
154 Dest = BI->getSuccessor(1);
157 Dest = BI->getSuccessor(0);
158 BranchInst::Create(Dest, BI);
159 InstrToDelete.push_back(BI);
162 From->replaceAllUsesWith(To);
163 InstrToDelete.push_back(
From);
166 Value *NVPTXImageOptimizer::cleanupValue(
Value *V) {
168 return cleanupValue(EVI->getAggregateOperand());
174 return new NVPTXImageOptimizer();
bool isIntrinsic() const
isIntrinsic - Returns true if the function's name starts with "llvm.".
This is an optimization pass for GlobalISel generic memory operations.
bool isImageReadWrite(const Value &val)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
bool isImage(const Value &val)
bool isSampler(const Value &val)
LLVM Basic Block Representation.
This is the shared class of boolean and integer constants.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
bool isImageReadOnly(const Value &val)
static Constant * getFalse(Type *Ty)
For a boolean type or a vector of boolean type, return false or a vector with every element false.
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
static bool runOnFunction(Function &F, bool PostInlining)
FunctionPass * createNVPTXImageOptimizerPass()
bool isImageWriteOnly(const Value &val)
static Constant * getTrue(Type *Ty)
For a boolean type or a vector of boolean type, return true or a vector with every element true.
FunctionPass class - This class is used to implement most global optimizations.
This class represents a function call, abstracting a target machine's calling convention.
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
BlockVerifier::State From
Conditional or Unconditional Branch instruction.
LLVM Value Representation.
A Use represents the edge between a Value definition and its users.