22#define RISCV_POST_RA_EXPAND_PSEUDO_NAME \
23 "RISC-V post-regalloc pseudo instruction expansion pass"
49char RISCVPostRAExpandPseudo::ID = 0;
51bool RISCVPostRAExpandPseudo::runOnMachineFunction(
MachineFunction &MF) {
75 switch (
MBBI->getOpcode()) {
76 case RISCV::PseudoMovImm:
78 case RISCV::PseudoMovAddr:
79 return expandMovAddr(
MBB,
MBBI);
80 case RISCV::PseudoMERGE:
91 int64_t Val =
MBBI->getOperand(1).getImm();
94 bool DstIsDead =
MBBI->getOperand(0).isDead();
100 MBBI->eraseFromParent();
109 bool DstIsDead =
MBBI->getOperand(0).isDead();
120 MBBI->eraseFromParent();
130 assert(MO.isReg() && MO.getReg());
142 if (DstReg ==
MI.getOperand(3).getReg()) {
145 .
add(
MI.getOperand(0))
146 .
add(
MI.getOperand(3))
147 .
add(
MI.getOperand(2))
148 .
add(
MI.getOperand(1));
149 transferImpOps(*
MBBI,
I);
150 }
else if (DstReg ==
MBBI->getOperand(2).getReg()) {
153 .
add(
MI.getOperand(0))
154 .
add(
MI.getOperand(2))
155 .
add(
MI.getOperand(3))
156 .
add(
MI.getOperand(1));
157 transferImpOps(*
MBBI,
I);
158 }
else if (DstReg ==
MI.getOperand(1).getReg()) {
161 .
add(
MI.getOperand(0))
162 .
add(
MI.getOperand(1))
163 .
add(
MI.getOperand(2))
164 .
add(
MI.getOperand(3));
165 transferImpOps(*
MBBI,
I);
171 MI.getOperand(1).getReg() !=
172 MI.getOperand(2).getReg() &&
173 MI.getOperand(1).getReg() !=
MI.getOperand(3).getReg());
179 .
add(
MI.getOperand(0))
182 MI.getOperand(0).isRenamable()))
183 .
add(
MI.getOperand(2))
184 .
add(
MI.getOperand(3));
185 transferImpOps(*
MBBI,
I);
187 MI.eraseFromParent();
198 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.
StringRef - Represent a constant reference to a string, i.e.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
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)