22#define RISCV_POST_RA_EXPAND_PSEUDO_NAME \
23 "RISC-V post-regalloc pseudo instruction expansion pass"
51char RISCVPostRAExpandPseudo::ID = 0;
53bool RISCVPostRAExpandPseudo::runOnMachineFunction(
MachineFunction &MF) {
77 switch (
MBBI->getOpcode()) {
78 case RISCV::PseudoMovImm:
80 case RISCV::PseudoMovAddr:
81 return expandMovAddr(
MBB,
MBBI);
82 case RISCV::PseudoAddUpperImm:
83 return expandAddUpperImm(
MBB,
MBBI);
84 case RISCV::PseudoMERGE:
95 int64_t Val =
MBBI->getOperand(1).getImm();
98 bool DstIsDead =
MBBI->getOperand(0).isDead();
104 MBBI->eraseFromParent();
113 bool DstIsDead =
MBBI->getOperand(0).isDead();
124 MBBI->eraseFromParent();
128bool RISCVPostRAExpandPseudo::expandAddUpperImm(
133 bool DstIsDead =
MBBI->getOperand(0).isDead();
136 int64_t
Hi =
MBBI->getOperand(2).getImm();
148 MBBI->eraseFromParent();
158 assert(MO.isReg() && MO.getReg());
170 if (DstReg ==
MI.getOperand(3).getReg()) {
173 .
add(
MI.getOperand(0))
174 .
add(
MI.getOperand(3))
175 .
add(
MI.getOperand(2))
176 .
add(
MI.getOperand(1));
177 transferImpOps(*
MBBI,
I);
178 }
else if (DstReg ==
MBBI->getOperand(2).getReg()) {
181 .
add(
MI.getOperand(0))
182 .
add(
MI.getOperand(2))
183 .
add(
MI.getOperand(3))
184 .
add(
MI.getOperand(1));
185 transferImpOps(*
MBBI,
I);
186 }
else if (DstReg ==
MI.getOperand(1).getReg()) {
189 .
add(
MI.getOperand(0))
190 .
add(
MI.getOperand(1))
191 .
add(
MI.getOperand(2))
192 .
add(
MI.getOperand(3));
193 transferImpOps(*
MBBI,
I);
199 MI.getOperand(1).getReg() !=
200 MI.getOperand(2).getReg() &&
201 MI.getOperand(1).getReg() !=
MI.getOperand(3).getReg());
207 .
add(
MI.getOperand(0))
210 MI.getOperand(0).isRenamable()))
211 .
add(
MI.getOperand(2))
212 .
add(
MI.getOperand(3));
213 transferImpOps(*
MBBI,
I);
215 MI.eraseFromParent();
226 return new RISCVPostRAExpandPseudo();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
const HexagonInstrInfo * TII
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
#define RISCV_POST_RA_EXPAND_PSEUDO_NAME
FunctionPass class - This class is used to implement most global optimizations.
Describe properties that are true of each instruction in the target description file.
MachineInstrBundleIterator< MachineInstr > iterator
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
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.
Wrapper class representing virtual and physical registers.
Represent a constant reference to a string, i.e.
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.
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.
@ Kill
The last use of a register.
@ Define
Register definition.
@ Renamable
Register that may be renamed.
constexpr RegState getKillRegState(bool B)
FunctionPass * createRISCVPostRAExpandPseudoPass()
constexpr RegState getDeadRegState(bool B)
constexpr RegState getRenamableRegState(bool B)