34 NVPTXImageOptimizer();
49 NVPTXImageOptimizer::NVPTXImageOptimizer()
52 bool NVPTXImageOptimizer::runOnFunction(
Function &
F) {
54 InstrToDelete.clear();
62 if (
CallInst *CI = dyn_cast<CallInst>(
I)) {
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);
84 for (
unsigned i = 0, e = InstrToDelete.size(); i != e; ++i)
85 InstrToDelete[i]->eraseFromParent();
90 bool NVPTXImageOptimizer::replaceIsTypePSampler(
Instruction &
I) {
108 bool NVPTXImageOptimizer::replaceIsTypePSurface(
Instruction &I) {
127 bool NVPTXImageOptimizer::replaceIsTypePTexture(
Instruction &I) {
152 if (
BranchInst *BI = dyn_cast<BranchInst>(*UI)) {
153 if (BI->isUnconditional())
continue;
157 Dest = BI->getSuccessor(1);
160 Dest = BI->getSuccessor(0);
161 BranchInst::Create(Dest, BI);
162 InstrToDelete.push_back(BI);
166 InstrToDelete.push_back(From);
169 Value *NVPTXImageOptimizer::cleanupValue(
Value *V) {
171 return cleanupValue(EVI->getAggregateOperand());
177 return new NVPTXImageOptimizer();
CallInst - This class represents a function call, abstracting a target machine's calling convention...
static Constant * getTrue(Type *Ty)
getTrue - For a boolean type, or a vector of boolean type, return true, or a vector with every elemen...
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
bool isImageReadWrite(const llvm::Value &)
FunctionPass * createNVPTXImageOptimizerPass()
LLVM Basic Block Representation.
BranchInst - Conditional or Unconditional Branch instruction.
bool isImageWriteOnly(const llvm::Value &)
FunctionPass class - This class is used to implement most global optimizations.
Value * getOperand(unsigned i) const
LLVMContext & getContext() const
All values hold a context through their type.
bool isImageReadOnly(const llvm::Value &)
This is the shared class of boolean and integer constants.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Module.h This file contains the declarations for the Module class.
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
static Constant * getFalse(Type *Ty)
getFalse - For a boolean type, or a vector of boolean type, return false, or a vector with every elem...
bool isSampler(const llvm::Value &)
LLVM Value Representation.