34 NVPTXImageOptimizer();
49 NVPTXImageOptimizer::NVPTXImageOptimizer()
52 bool NVPTXImageOptimizer::runOnFunction(
Function &
F) {
57 InstrToDelete.clear();
65 if (
CallInst *CI = dyn_cast<CallInst>(
I)) {
66 Function *CalledF = CI->getCalledFunction();
71 case Intrinsic::nvvm_istypep_sampler:
72 Changed |= replaceIsTypePSampler(Instr);
74 case Intrinsic::nvvm_istypep_surface:
75 Changed |= replaceIsTypePSurface(Instr);
77 case Intrinsic::nvvm_istypep_texture:
78 Changed |= replaceIsTypePTexture(Instr);
87 for (
unsigned i = 0, e = InstrToDelete.size();
i != e; ++
i)
88 InstrToDelete[
i]->eraseFromParent();
93 bool NVPTXImageOptimizer::replaceIsTypePSampler(
Instruction &
I) {
111 bool NVPTXImageOptimizer::replaceIsTypePSurface(
Instruction &I) {
130 bool NVPTXImageOptimizer::replaceIsTypePTexture(
Instruction &I) {
155 if (
BranchInst *BI = dyn_cast<BranchInst>(*UI)) {
156 if (BI->isUnconditional())
continue;
160 Dest = BI->getSuccessor(1);
163 Dest = BI->getSuccessor(0);
164 BranchInst::Create(Dest, BI);
165 InstrToDelete.push_back(BI);
169 InstrToDelete.push_back(From);
172 Value *NVPTXImageOptimizer::cleanupValue(
Value *V) {
174 return cleanupValue(EVI->getAggregateOperand());
180 return new NVPTXImageOptimizer();
This class represents a function call, abstracting a target machine's calling convention.
bool isIntrinsic() const
isIntrinsic - Returns true if the function's name starts with "llvm.".
static Constant * getTrue(Type *Ty)
For a boolean type, or a vector of boolean type, return true, or a vector with every element true...
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
FunctionPass * createNVPTXImageOptimizerPass()
bool isSampler(const Value &val)
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
LLVM Basic Block Representation.
Conditional or Unconditional Branch instruction.
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.
Iterator for intrusive lists based on ilist_node.
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 isImageReadWrite(const Value &val)
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)
For a boolean type, or a vector of boolean type, return false, or a vector with every element false...
bool isImageReadOnly(const Value &val)
LLVM Value Representation.
bool isImageWriteOnly(const Value &val)