46 return "NVPTX Proxy Register Instruction Erasure";
64 INITIALIZE_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::ProxyRegF16:
77 case NVPTX::ProxyRegF16x2:
78 case NVPTX::ProxyRegF32:
79 case NVPTX::ProxyRegF64:
80 replaceMachineInstructionUsage(MF,
MI);
87 for (
auto *
MI : RemoveList) {
88 MI->eraseFromParent();
91 return !RemoveList.empty();
94 void NVPTXProxyRegErasure::replaceMachineInstructionUsage(
MachineFunction &MF,
96 auto &InOp = *MI.
uses().begin();
97 auto &OutOp = *MI.
defs().begin();
99 assert(InOp.isReg() &&
"ProxyReg input operand should be a register.");
100 assert(OutOp.isReg() &&
"ProxyReg output operand should be a register.");
102 for (
auto &BB : MF) {
104 replaceRegisterUsage(
I, OutOp, InOp);
109 void NVPTXProxyRegErasure::replaceRegisterUsage(
MachineInstr &Instr,
112 for (
auto &
Op : Instr.
uses()) {
113 if (
Op.isReg() &&
Op.getReg() == From.
getReg()) {
120 return new NVPTXProxyRegErasure();
MachineFunctionPass * createNVPTXProxyRegErasurePass()
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
This class represents lattice values for constants.
iterator_range< mop_iterator > uses()
Returns a range that includes all operands that are register uses.
void push_back(const T &Elt)
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.
Represent the analysis usage information of a pass.
iterator_range< mop_iterator > defs()
Returns a range over all explicit operands that are register definitions.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
BlockVerifier::State From
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
void initializeNVPTXProxyRegErasurePass(PassRegistry &)
Representation of each machine instruction.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef - Represent a constant reference to a string, i.e.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Register getReg() const
getReg - Returns the register number.