21#include "llvm/IR/IntrinsicsNVPTX.h"
34 NVPTXImageOptimizer();
49char NVPTXImageOptimizer::ID = 0;
51NVPTXImageOptimizer::NVPTXImageOptimizer()
54bool NVPTXImageOptimizer::runOnFunction(
Function &
F) {
59 InstrToDelete.clear();
64 if (
CallInst *CI = dyn_cast<CallInst>(&Instr)) {
65 Function *CalledF = CI->getCalledFunction();
70 case Intrinsic::nvvm_istypep_sampler:
71 Changed |= replaceIsTypePSampler(Instr);
73 case Intrinsic::nvvm_istypep_surface:
74 Changed |= replaceIsTypePSurface(Instr);
76 case Intrinsic::nvvm_istypep_texture:
77 Changed |= replaceIsTypePTexture(Instr);
92bool NVPTXImageOptimizer::replaceIsTypePSampler(
Instruction &
I) {
93 Value *TexHandle = cleanupValue(
I.getOperand(0));
98 }
else if (
isImage(*TexHandle)) {
108bool NVPTXImageOptimizer::replaceIsTypePSurface(
Instruction &
I) {
109 Value *TexHandle = cleanupValue(
I.getOperand(0));
127bool NVPTXImageOptimizer::replaceIsTypePTexture(
Instruction &
I) {
128 Value *TexHandle = cleanupValue(
I.getOperand(0));
151 if (
BranchInst *BI = dyn_cast<BranchInst>(U)) {
152 if (BI->isUnconditional())
continue;
156 Dest = BI->getSuccessor(1);
159 Dest = BI->getSuccessor(0);
161 InstrToDelete.push_back(BI);
164 From->replaceAllUsesWith(To);
165 InstrToDelete.push_back(
From);
168Value *NVPTXImageOptimizer::cleanupValue(
Value *V) {
170 return cleanupValue(EVI->getAggregateOperand());
176 return new NVPTXImageOptimizer();
BlockVerifier::State From
Module.h This file contains the declarations for the Module class.
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 isImage(const Value &val)
bool isImageReadOnly(const Value &val)
FunctionPass * createNVPTXImageOptimizerPass()
bool isImageWriteOnly(const Value &val)
bool isImageReadWrite(const Value &val)
bool isSampler(const Value &val)