24#define DEBUG_TYPE "arc-expand-pseudos"
35 StringRef getPassName()
const override {
return "ARC Expand Pseudos"; }
45char ARCExpandPseudos::ID = 0;
64 MachineInstr &
SI = *SII;
67 isUInt<6>(
SI.getOperand(2).getImm()) ? ARC::ADD_rru6 : ARC::ADD_rrlimm;
68 BuildMI(*
SI.getParent(), SI,
SI.getDebugLoc(),
TII->get(AddOpc), AddrReg)
79void ARCExpandPseudos::expandCTLZ(MachineFunction &MF,
87 MachineInstr &
MI = *MII;
88 const MachineOperand &Dest =
MI.getOperand(0);
89 const MachineOperand &Src =
MI.getOperand(1);
95 BuildMI(*
MI.getParent(),
MI,
MI.getDebugLoc(),
TII->get(ARC::MOV_cc_ru6), Rb)
105 MI.eraseFromParent();
108void ARCExpandPseudos::expandCTTZ(MachineFunction &MF,
115 MachineInstr &
MI = *MII;
116 const MachineOperand &Dest =
MI.getOperand(0);
117 const MachineOperand &Src =
MI.getOperand(1);
128 MI.eraseFromParent();
131bool ARCExpandPseudos::runOnMachineFunction(MachineFunction &MF) {
132 const ARCSubtarget *STI = &MF.
getSubtarget<ARCSubtarget>();
134 bool Expanded =
false;
135 for (
auto &
MBB : MF) {
139 switch (
MBBI->getOpcode()) {
143 expandStore(MF,
MBBI);
147 expandCTLZ(MF,
MBBI);
151 expandCTTZ(MF,
MBBI);
164 return new ARCExpandPseudos();
static unsigned getMappedOp(unsigned PseudoOp)
MachineBasicBlock MachineBasicBlock::iterator MBBI
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
const HexagonInstrInfo * TII
Promote Memory to Register
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
const ARCInstrInfo * getInstrInfo() const override
FunctionPass class - This class is used to implement most global optimizations.
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.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & add(const MachineOperand &MO) const
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
LLVM_ABI Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
StringRef - Represent a constant reference to a string, i.e.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
FunctionPass * createARCExpandPseudosPass()
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.