37 switch (
MI.getOpcode()) {
38 case NVPTX::ProxyRegB1:
39 case NVPTX::ProxyRegB16:
40 case NVPTX::ProxyRegB32:
41 case NVPTX::ProxyRegB64: {
42 auto &InOp = *
MI.uses().begin();
43 auto &OutOp = *
MI.defs().begin();
44 assert(InOp.isReg() &&
"ProxyReg input should be a register.");
45 assert(OutOp.isReg() &&
"ProxyReg output should be a register.");
47 Register replacement = InOp.getReg();
49 if (
auto it = RAUWBatch.
find(replacement); it != RAUWBatch.
end())
50 replacement = it->second;
59 if (RemoveList.
empty())
63 for (
auto *
MI : RemoveList) {
64 MI->eraseFromParent();
69 for (
auto [From, To] : RAUWBatch) {
81 NVPTXProxyRegErasureLegacyPass() : MachineFunctionPass(ID) {}
83 bool runOnMachineFunction(MachineFunction &MF)
override {
87 StringRef getPassName()
const override {
88 return "NVPTX Proxy Register Instruction Erasure";
91 void getAnalysisUsage(AnalysisUsage &AU)
const override {
99char NVPTXProxyRegErasureLegacyPass::ID = 0;
102 "NVPTX ProxyReg Erasure",
false,
false)
105 return new NVPTXProxyRegErasureLegacyPass();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static bool eraseProxyRegs(MachineFunction &MF)
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
Represents analyses that only rely on functions' control flow.
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 & getRegInfo()
getRegInfo - Return information about the registers currently in use.
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.
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
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.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
MachineFunctionPass * createNVPTXProxyRegErasureLegacyPass()