21#include "llvm/IR/IntrinsicsNVPTX.h"
33 NVPTXImageOptimizer();
48char NVPTXImageOptimizer::ID = 0;
50NVPTXImageOptimizer::NVPTXImageOptimizer()
53bool NVPTXImageOptimizer::runOnFunction(
Function &
F) {
58 InstrToDelete.clear();
63 if (
CallInst *CI = dyn_cast<CallInst>(&Instr)) {
64 Function *CalledF = CI->getCalledFunction();
69 case Intrinsic::nvvm_istypep_sampler:
70 Changed |= replaceIsTypePSampler(Instr);
72 case Intrinsic::nvvm_istypep_surface:
73 Changed |= replaceIsTypePSurface(Instr);
75 case Intrinsic::nvvm_istypep_texture:
76 Changed |= replaceIsTypePTexture(Instr);
91bool NVPTXImageOptimizer::replaceIsTypePSampler(
Instruction &
I) {
92 Value *TexHandle = cleanupValue(
I.getOperand(0));
97 }
else if (
isImage(*TexHandle)) {
107bool NVPTXImageOptimizer::replaceIsTypePSurface(
Instruction &
I) {
108 Value *TexHandle = cleanupValue(
I.getOperand(0));
126bool NVPTXImageOptimizer::replaceIsTypePTexture(
Instruction &
I) {
127 Value *TexHandle = cleanupValue(
I.getOperand(0));
150 if (
BranchInst *BI = dyn_cast<BranchInst>(U)) {
151 if (BI->isUnconditional())
continue;
155 Dest = BI->getSuccessor(1);
158 Dest = BI->getSuccessor(0);
160 InstrToDelete.push_back(BI);
163 From->replaceAllUsesWith(To);
164 InstrToDelete.push_back(
From);
167Value *NVPTXImageOptimizer::cleanupValue(
Value *V) {
169 return cleanupValue(EVI->getAggregateOperand());
175 return new NVPTXImageOptimizer();
BlockVerifier::State From
LLVM Basic Block Representation.
Conditional or Unconditional Branch instruction.
static BranchInst * Create(BasicBlock *IfTrue, InsertPosition InsertBefore=nullptr)
This class represents a function call, abstracting a target machine's calling convention.
This is the shared class of boolean and integer constants.
static ConstantInt * getTrue(LLVMContext &Context)
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
static ConstantInt * getFalse(LLVMContext &Context)
FunctionPass class - This class is used to implement most global optimizations.
virtual bool runOnFunction(Function &F)=0
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
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.".
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
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.
A Use represents the edge between a Value definition and its users.
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.
bool isImageReadWrite(const Value &V)
bool isImageReadOnly(const Value &V)
bool isImage(const Value &V)
bool isSampler(const Value &V)
FunctionPass * createNVPTXImageOptimizerPass()
bool isImageWriteOnly(const Value &V)