24#define RISCV_POST_RA_EXPAND_PSEUDO_NAME \
25 "RISC-V post-regalloc pseudo instruction expansion pass"
53 return RISCVPostRAExpandPseudoImpl().run(MF);
68bool RISCVPostRAExpandPseudoImpl::expandMI(
71 switch (
MBBI->getOpcode()) {
72 case RISCV::PseudoMovImm:
74 case RISCV::PseudoMovAddr:
75 return expandMovAddr(
MBB,
MBBI);
76 case RISCV::PseudoAddUpperImm:
77 return expandAddUpperImm(
MBB,
MBBI);
78 case RISCV::PseudoMERGE:
85bool RISCVPostRAExpandPseudoImpl::expandMovImm(
89 int64_t Val =
MBBI->getOperand(1).getImm();
92 bool DstIsDead =
MBBI->getOperand(0).isDead();
102bool RISCVPostRAExpandPseudoImpl::expandMovAddr(
107 bool DstIsDead =
MBBI->getOperand(0).isDead();
122bool RISCVPostRAExpandPseudoImpl::expandAddUpperImm(
127 bool DstIsDead =
MBBI->getOperand(0).isDead();
130 int64_t
Hi =
MBBI->getOperand(2).getImm();
152 assert(MO.isReg() && MO.getReg());
158bool RISCVPostRAExpandPseudoImpl::expandMERGE(
164 if (DstReg ==
MI.getOperand(3).getReg()) {
167 .
add(
MI.getOperand(0))
168 .
add(
MI.getOperand(3))
169 .
add(
MI.getOperand(2))
170 .
add(
MI.getOperand(1));
172 }
else if (DstReg ==
MBBI->getOperand(2).getReg()) {
175 .
add(
MI.getOperand(0))
176 .
add(
MI.getOperand(2))
177 .
add(
MI.getOperand(3))
178 .
add(
MI.getOperand(1));
180 }
else if (DstReg ==
MI.getOperand(1).getReg()) {
183 .
add(
MI.getOperand(0))
184 .
add(
MI.getOperand(1))
185 .
add(
MI.getOperand(2))
186 .
add(
MI.getOperand(3));
193 MI.getOperand(1).getReg() !=
194 MI.getOperand(2).getReg() &&
195 MI.getOperand(1).getReg() !=
MI.getOperand(3).getReg());
201 .
add(
MI.getOperand(0))
204 MI.getOperand(0).isRenamable()))
205 .
add(
MI.getOperand(2))
206 .
add(
MI.getOperand(3));
209 MI.eraseFromParent();
213char RISCVPostRAExpandPseudoLegacy::ID = 0;
219 return new RISCVPostRAExpandPseudoLegacy();
225 bool Changed = RISCVPostRAExpandPseudoImpl().run(MF);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
const HexagonInstrInfo * TII
Promote Memory to Register
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
#define RISCV_POST_RA_EXPAND_PSEUDO_NAME
static void transferImpOps(const MachineInstr &OldMI, MachineInstrBuilder &MI)
Transfer implicit operands on the pseudo instruction to the instructions created from the expansion.
Represent the analysis usage information of a pass.
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.
FunctionPass class - This class is used to implement most global optimizations.
Describe properties that are true of each instruction in the target description file.
LLVM_ABI void eraseFromParent()
This method unlinks 'this' from the containing function and deletes it.
MachineInstrBundleIterator< MachineInstr > iterator
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.
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & add(const MachineOperand &MO) const
const MachineInstrBuilder & addDef(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a virtual register definition operand.
Representation of each machine instruction.
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
MachineOperand class - Representation of each machine instruction operand.
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.
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Represent a constant reference to a string, i.e.
BaseReg
Stack frame base register. Bit 0 of FREInfo.Info.
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
FunctionPass * createRISCVPostRAExpandPseudoLegacyPass()
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
RegState
Flags to represent properties of register accesses.
@ Renamable
Register that may be renamed.
constexpr RegState getKillRegState(bool B)
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
constexpr RegState getDeadRegState(bool B)
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
constexpr RegState getRenamableRegState(bool B)