30 cl::desc(
"Restrict range of loopN instructions (testing only)"));
48 const char *getPassName()
const override {
49 return "Hexagon Hardware Loop Fixup";
73 "Hexagon Hardware Loops Fixup",
false,
false)
76 return new HexagonFixupHwLoops();
81 return MI->
getOpcode() == Hexagon::J2_loop0r ||
88 return fixupLoopInstrs(MF);
102 unsigned InstOffset = 0;
111 if (MBB.getAlignment()) {
115 int ByteAlign = (1u << MBB.getAlignment()) - 1;
116 InstOffset = (InstOffset + ByteAlign) & ~(ByteAlign);
119 BlockToInstOffset[&MBB] = InstOffset;
127 bool Changed =
false;
129 InstOffset = BlockToInstOffset[&MBB];
135 InstOffset += HII->
getSize(&*MII);
136 if (MII->isDebugValue()) {
141 assert(MII->getOperand(0).isMBB() &&
142 "Expect a basic block as loop operand");
143 int diff = InstOffset - BlockToInstOffset[MII->getOperand(0).getMBB()];
145 useExtLoopInstr(MF, MII);
146 MII = MBB.erase(MII);
168 switch (MII->getOpcode()) {
169 case Hexagon::J2_loop0r:
170 newOp = Hexagon::J2_loop0rext;
172 case Hexagon::J2_loop0i:
173 newOp = Hexagon::J2_loop0iext;
175 case Hexagon::J2_loop1r:
176 newOp = Hexagon::J2_loop1rext;
178 case Hexagon::J2_loop1i:
179 newOp = Hexagon::J2_loop1iext;
184 MIB =
BuildMI(*MBB, MII, DL, TII->
get(newOp));
186 for (
unsigned i = 0; i < MII->getNumOperands(); ++i)
const MachineFunction * getParent() const
getParent - Return the MachineFunction containing this basic block.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
static cl::opt< unsigned > MaxLoopRange("hexagon-loop-range", cl::Hidden, cl::init(200), cl::desc("Restrict range of loopN instructions (testing only)"))
void initializeHexagonFixupHwLoopsPass(PassRegistry &)
static bool isHardwareLoop(const MachineInstr *MI)
Returns true if the instruction is a hardware loop instruction.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const HexagonInstrInfo * TII
unsigned getSize(const MachineInstr *MI) const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
TargetInstrInfo - Interface to description of machine instruction set.
bundle_iterator< MachineInstr, instr_iterator > iterator
initializer< Ty > init(const Ty &Val)
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
MachineInstrBuilder BuildMI(MachineFunction &MF, DebugLoc DL, const MCInstrDesc &MCID)
BuildMI - Builder interface.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
void setPreservesCFG()
This function should be called by the pass, iff they do not:
Representation of each machine instruction.
FunctionPass * createHexagonFixupHwLoops()
APFloat abs(APFloat X)
Returns the absolute value of the argument.
virtual const TargetInstrInfo * getInstrInfo() const
const MachineInstrBuilder & addOperand(const MachineOperand &MO) const
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
INITIALIZE_PASS(HexagonFixupHwLoops,"hwloopsfixup","Hexagon Hardware Loops Fixup", false, false) FunctionPass *llvm