46 return "NVPTX Proxy Register Instruction Erasure";
62char NVPTXProxyRegErasure::ID = 0;
64INITIALIZE_PASS(NVPTXProxyRegErasure,
"nvptx-proxyreg-erasure",
"NVPTX ProxyReg Erasure",
false,
false)
71 switch (
MI.getOpcode()) {
72 case NVPTX::ProxyRegI1:
73 case NVPTX::ProxyRegI16:
74 case NVPTX::ProxyRegI32:
75 case NVPTX::ProxyRegI64:
76 case NVPTX::ProxyRegF32:
77 case NVPTX::ProxyRegF64:
78 replaceMachineInstructionUsage(MF,
MI);
85 for (
auto *
MI : RemoveList) {
86 MI->eraseFromParent();
89 return !RemoveList.empty();
92void NVPTXProxyRegErasure::replaceMachineInstructionUsage(
MachineFunction &MF,
94 auto &InOp = *
MI.uses().begin();
95 auto &OutOp = *
MI.defs().begin();
97 assert(InOp.isReg() &&
"ProxyReg input operand should be a register.");
98 assert(OutOp.isReg() &&
"ProxyReg output operand should be a register.");
100 for (
auto &BB : MF) {
102 replaceRegisterUsage(
I, OutOp, InOp);
107void NVPTXProxyRegErasure::replaceRegisterUsage(
MachineInstr &Instr,
110 for (
auto &
Op :
Instr.uses()) {
111 if (
Op.isReg() &&
Op.getReg() ==
From.getReg()) {
118 return new NVPTXProxyRegErasure();
BlockVerifier::State From
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Represent the analysis usage information of a pass.
This class represents an Operation in the Expression.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
Register getReg() const
getReg - Returns the register number.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
void push_back(const T &Elt)
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.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
NodeAddr< InstrNode * > Instr
This is an optimization pass for GlobalISel generic memory operations.
MachineFunctionPass * createNVPTXProxyRegErasurePass()
void initializeNVPTXProxyRegErasurePass(PassRegistry &)