28#define DEBUG_TYPE "hlx-expand-pseudos"
34 cl::desc(
"Disable expansion of HLX pseudo instructions"));
42 unsigned Opc =
MI.getOpcode();
43 return Opc == Hexagon::LX_L16b_pseudo ||
Opc == Hexagon::LX_S16b_pseudo;
51 HLXExpandPseudos() : MachineFunctionPass(ID) {}
53 StringRef getPassName()
const override {
return "HLX Expand Pseudos"; }
55 MachineFunctionProperties getRequiredProperties()
const override {
56 return MachineFunctionProperties().set(
57 MachineFunctionProperties::Property::NoVRegs);
63 const HexagonInstrInfo *HII =
nullptr;
65 bool expandPseudos(MachineInstr &
MI);
66 bool expandPseudosInBundle(MachineInstr &
MI);
71char HLXExpandPseudos::ID = 0;
77 bool IsBundled =
MI.isBundled();
81 auto ExpandLoad = [&](
unsigned AssignOpc,
unsigned LoadOpc) {
95 End->bundleWithPred();
101 auto ExpandStore = [&](
unsigned AssignOpc,
unsigned StoreOpc) {
116 End->bundleWithPred();
122 switch (
MI.getOpcode()) {
125 case Hexagon::LX_L16b_pseudo:
126 return ExpandLoad(Hexagon::LX_assign, Hexagon::LX_L16b_tmp);
127 case Hexagon::LX_S16b_pseudo:
128 return ExpandStore(Hexagon::LX_assign, Hexagon::LX_S16b_new);
136 bool MadeChange =
false;
137 for (++MII; MII != MIE && MII->isInsideBundle() && !MII->isBundle(); ++MII) {
143 for (
auto It : EraseList)
144 It->eraseFromBundle();
153 HII =
static_cast<const HexagonInstrInfo *
>(HST.getInstrInfo());
155 bool MadeChange =
false;
156 for (MachineBasicBlock &
MBB : MF) {
159 MadeChange |= expandPseudosInBundle(
MI);
161 MadeChange |= expandPseudos(
MI);
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static cl::opt< bool > DisableHLXExpandPseudos("disable-hlx-expand-pseudos", cl::init(false), cl::Hidden, cl::desc("Disable expansion of HLX pseudo instructions"))
static bool isHLXLoadStorePseudo(const MachineInstr &MI)
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
FunctionPass class - This class is used to implement most global optimizations.
Instructions::iterator instr_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 & add(const MachineOperand &MO) const
const MachineInstrBuilder & cloneMemRefs(const MachineInstr &OtherMI) const
MachineInstr * getInstr() const
If conversion operators fail, use this method to get the MachineInstr explicitly.
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
void setIsInternalRead(bool Val=true)
Register getReg() const
getReg - Returns the register number.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Wrapper class representing virtual and physical registers.
void push_back(const T &Elt)
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void finalizeBundle(MachineBasicBlock &MBB, MachineBasicBlock::instr_iterator FirstMI, MachineBasicBlock::instr_iterator LastMI)
finalizeBundle - Finalize a machine instruction bundle which includes a sequence of instructions star...
FunctionPass * createHLXExpandPseudos()
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
@ Kill
The last use of a register.
@ InternalRead
Register reads a value that is defined inside the same instruction or bundle.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
void initializeHLXExpandPseudosPass(PassRegistry &)
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
@ End
Run the machine verifier once, at the end of the pipeline.