30 cl::desc(
"Restrict range of loopN instructions (testing only)"));
54 return "Hexagon Hardware Loop Fixup";
78 "Hexagon Hardware Loops Fixup",
false,
false)
81 return new HexagonFixupHwLoops();
86 return MI.
getOpcode() == Hexagon::J2_loop0r ||
95 return fixupLoopInstrs(MF);
109 unsigned InstOffset = 0;
118 if (MBB.getAlignment()) {
122 int ByteAlign = (1u << MBB.getAlignment()) - 1;
123 InstOffset = (InstOffset + ByteAlign) & ~(ByteAlign);
126 BlockToInstOffset[&MBB] = InstOffset;
133 bool Changed =
false;
135 InstOffset = BlockToInstOffset[&MBB];
141 unsigned InstSize = HII->
getSize(*MII);
142 if (MII->isMetaInstruction()) {
147 assert(MII->getOperand(0).isMBB() &&
148 "Expect a basic block as loop operand");
151 BlockToInstOffset[TargetBB]);
153 useExtLoopInstr(MF, MII);
154 MII = MBB.erase(MII);
162 InstOffset += InstSize;
177 switch (MII->getOpcode()) {
178 case Hexagon::J2_loop0r:
179 newOp = Hexagon::J2_loop0rext;
181 case Hexagon::J2_loop0i:
182 newOp = Hexagon::J2_loop0iext;
184 case Hexagon::J2_loop1r:
185 newOp = Hexagon::J2_loop1rext;
187 case Hexagon::J2_loop1i:
188 newOp = Hexagon::J2_loop1iext;
193 MIB =
BuildMI(*MBB, MII, DL, TII->
get(newOp));
195 for (
unsigned i = 0; i < MII->getNumOperands(); ++i)
196 MIB.
add(MII->getOperand(i));
INITIALIZE_PASS(HexagonFixupHwLoops, "hwloopsfixup", "Hexagon Hardware Loops Fixup", false, false) FunctionPass *llvm
const MachineInstrBuilder & add(const MachineOperand &MO) const
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
This class represents lattice values for constants.
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 &)
unsigned getSize(const MachineInstr &MI) const
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.
virtual const TargetInstrInfo * getInstrInfo() const
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)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
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.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
const Function & getFunction() const
Return the LLVM function that this machine code represents.
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()
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
std::enable_if< std::is_unsigned< T >::value, T >::type AbsoluteDifference(T X, T Y)
Subtract two unsigned integers, X and Y, of type T and return the absolute value of the result...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef - Represent a constant reference to a string, i.e.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Properties which a MachineFunction may have at a given point in time.