35 NVPTXReplaceImageHandles();
40 return "NVPTX Replace Image Handles";
52 NVPTXReplaceImageHandles::NVPTXReplaceImageHandles()
55 bool NVPTXReplaceImageHandles::runOnMachineFunction(
MachineFunction &MF) {
57 InstrsToRemove.clear();
64 Changed |= processInstr(MI);
73 E = InstrsToRemove.end();
I !=
E; ++
I) {
74 (*I)->eraseFromParent();
87 replaceImageHandle(TexHandle, MF);
91 replaceImageHandle(SampHandle, MF);
102 replaceImageHandle(SurfHandle, MF);
109 replaceImageHandle(SurfHandle, MF);
116 replaceImageHandle(Handle, MF);
124 void NVPTXReplaceImageHandles::
127 if (findIndexForHandle(Op, MF, Idx)) {
132 bool NVPTXReplaceImageHandles::
142 switch (TexHandleDef.getOpcode()) {
143 case NVPTX::LD_i64_avar: {
153 assert(TexHandleDef.getOperand(6).isSymbol() &&
"Load is not a symbol!");
154 StringRef Sym = TexHandleDef.getOperand(6).getSymbolName();
155 std::string ParamBaseName = MF.
getName();
156 ParamBaseName +=
"_param_";
157 assert(Sym.startswith(ParamBaseName) &&
"Invalid symbol reference");
158 unsigned Param = atoi(Sym.data()+ParamBaseName.size());
161 NewSymStr << MF.
getName() <<
"_param_" << Param;
163 InstrsToRemove.insert(&TexHandleDef);
167 case NVPTX::texsurf_handles: {
169 assert(TexHandleDef.getOperand(1).isGlobal() &&
"Load is not a global!");
171 assert(GV->hasName() &&
"Global sampler must be named!");
172 InstrsToRemove.insert(&TexHandleDef);
177 case TargetOpcode::COPY: {
178 bool Res = findIndexForHandle(TexHandleDef.getOperand(1), MF, Idx);
180 InstrsToRemove.insert(&TexHandleDef);
190 return new NVPTXReplaceImageHandles();
This class represents lattice values for constants.
Implements a dense probed hash-table based set.
Describe properties that are true of each instruction in the target description file.
unsigned getReg() const
getReg - Returns the register number.
unsigned getImageHandleSymbolIndex(const char *Symbol)
Returns the index for the symbol Symbol.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
MachineInstr * getVRegDef(unsigned Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
Value * getOperand(unsigned i) const
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
void ChangeToImmediate(int64_t ImmVal)
ChangeToImmediate - Replace this operand with a new immediate operand of the specified value...
unsigned const MachineRegisterInfo * MRI
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
MachineFunctionPass * createNVPTXReplaceImageHandlesPass()
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
NVPTX::DrvInterface getDrvInterface() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Iterator for intrusive lists based on ilist_node.
MachineOperand class - Representation of each machine instruction operand.
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
Representation of each machine instruction.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
bool isReg() const
isReg - Tests if this is a MO_Register operand.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A raw_ostream that writes to an std::string.
StringRef - Represent a constant reference to a string, i.e.
const MachineOperand & getOperand(unsigned i) const