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;
121 InstOffset =
alignTo(InstOffset, MBB.getAlignment());
124 BlockToInstOffset[&MBB] = InstOffset;
131 bool Changed =
false;
133 InstOffset = BlockToInstOffset[&MBB];
139 unsigned InstSize = HII->
getSize(*MII);
140 if (MII->isMetaInstruction()) {
145 assert(MII->getOperand(0).isMBB() &&
146 "Expect a basic block as loop operand");
149 BlockToInstOffset[TargetBB]);
151 useExtLoopInstr(MF, MII);
152 MII = MBB.erase(MII);
160 InstOffset += InstSize;
175 switch (MII->getOpcode()) {
176 case Hexagon::J2_loop0r:
177 newOp = Hexagon::J2_loop0rext;
179 case Hexagon::J2_loop0i:
180 newOp = Hexagon::J2_loop0iext;
182 case Hexagon::J2_loop1r:
183 newOp = Hexagon::J2_loop1rext;
185 case Hexagon::J2_loop1i:
186 newOp = Hexagon::J2_loop1iext;
191 MIB =
BuildMI(*MBB, MII, DL, TII->
get(newOp));
193 for (
unsigned i = 0; i < MII->getNumOperands(); ++i)
194 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.
static constexpr const Align None()
Returns a default constructed Align which corresponds to no alignment.
#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.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
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.