29 cl::desc(
"Restrict range of loopN instructions (testing only)"));
53 return "Hexagon Hardware Loop Fixup";
77 "Hexagon Hardware Loops Fixup",
false,
false)
80 return new HexagonFixupHwLoops();
85 return MI.
getOpcode() == Hexagon::J2_loop0r ||
94 return fixupLoopInstrs(MF);
108 unsigned InstOffset = 0;
117 if (MBB.getAlignment()) {
121 int ByteAlign = (1u << MBB.getAlignment()) - 1;
122 InstOffset = (InstOffset + ByteAlign) & ~(ByteAlign);
125 BlockToInstOffset[&MBB] = InstOffset;
132 bool Changed =
false;
134 InstOffset = BlockToInstOffset[&MBB];
140 InstOffset += HII->
getSize(*MII);
141 if (MII->isDebugValue()) {
146 assert(MII->getOperand(0).isMBB() &&
147 "Expect a basic block as loop operand");
148 int diff = InstOffset - BlockToInstOffset[MII->getOperand(0).getMBB()];
150 useExtLoopInstr(MF, MII);
151 MII = MBB.erase(MII);
173 switch (MII->getOpcode()) {
174 case Hexagon::J2_loop0r:
175 newOp = Hexagon::J2_loop0rext;
177 case Hexagon::J2_loop0i:
178 newOp = Hexagon::J2_loop0iext;
180 case Hexagon::J2_loop1r:
181 newOp = Hexagon::J2_loop1rext;
183 case Hexagon::J2_loop1i:
184 newOp = Hexagon::J2_loop1iext;
189 MIB =
BuildMI(*MBB, MII, DL, TII->
get(newOp));
191 for (
unsigned i = 0; i < MII->getNumOperands(); ++i)
192 MIB.
add(MII->getOperand(i));
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
const MachineInstrBuilder & add(const MachineOperand &MO) const
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 &)
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
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 getOpcode() const
Returns the opcode of this MachineInstr.
TargetInstrInfo - Interface to description of machine instruction set.
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
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.
unsigned getSize(const MachineInstr &MI) const
FunctionPass class - This class is used to implement most global optimizations.
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:
llvm_unreachable("Unknown RegBank!")
MachineFunctionProperties & set(Property P)
Representation of each machine instruction.
static bool isHardwareLoop(const MachineInstr &MI)
Returns true if the instruction is a hardware loop instruction.
FunctionPass * createHexagonFixupHwLoops()
APFloat abs(APFloat X)
Returns the absolute value of the argument.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
virtual const TargetInstrInfo * getInstrInfo() const
StringRef - Represent a constant reference to a string, i.e.
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
Properties which a MachineFunction may have at a given point in time.