32 NVPTXProxyRegErasure() : MachineFunctionPass(ID) {}
34 bool runOnMachineFunction(MachineFunction &MF)
override;
36 StringRef getPassName()
const override {
37 return "NVPTX Proxy Register Instruction Erasure";
40 void getAnalysisUsage(AnalysisUsage &AU)
const override {
47char NVPTXProxyRegErasure::ID = 0;
50 "NVPTX ProxyReg Erasure",
false,
false)
61 switch (
MI.getOpcode()) {
62 case NVPTX::ProxyRegB1:
63 case NVPTX::ProxyRegB16:
64 case NVPTX::ProxyRegB32:
65 case NVPTX::ProxyRegB64: {
66 auto &InOp = *
MI.uses().begin();
67 auto &OutOp = *
MI.defs().begin();
68 assert(InOp.isReg() &&
"ProxyReg input should be a register.");
69 assert(OutOp.isReg() &&
"ProxyReg output should be a register.");
71 Register replacement = InOp.getReg();
73 if (
auto it = RAUWBatch.
find(replacement); it != RAUWBatch.
end())
74 replacement = it->second;
83 if (RemoveList.
empty())
87 for (
auto *
MI : RemoveList) {
88 MI->eraseFromParent();
93 for (
auto [From, To] : RAUWBatch) {
102 return new NVPTXProxyRegErasure();
for(const MachineOperand &MO :llvm::drop_begin(OldMI.operands(), Desc.getNumOperands()))
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
iterator find(const_arg_type_t< KeyT > Val)
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
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.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
LLVM_ABI void clearKillFlags(Register Reg) const
clearKillFlags - Iterate over all the uses of the given register and clear the kill flag from the Mac...
LLVM_ABI void replaceRegWith(Register FromReg, Register ToReg)
replaceRegWith - Replace all instances of FromReg with ToReg in the machine function.
Wrapper class representing virtual and physical registers.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This is an optimization pass for GlobalISel generic memory operations.
MachineFunctionPass * createNVPTXProxyRegErasurePass()