29 cl::desc(
"Restrict range of loopN instructions (testing only)"));
49 MachineFunctionProperties::Property::NoVRegs);
53 return "Hexagon Hardware Loop Fixup";
73 char HexagonFixupHwLoops::ID = 0;
77 "Hexagon Hardware Loops Fixup",
false,
false)
80 return new HexagonFixupHwLoops();
85 return MI.getOpcode() == Hexagon::J2_loop0r ||
86 MI.getOpcode() == Hexagon::J2_loop0i ||
87 MI.getOpcode() == Hexagon::J2_loop1r ||
88 MI.getOpcode() == Hexagon::J2_loop1i;
94 return fixupLoopInstrs(MF);
108 unsigned InstOffset = 0;
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);
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;
193 for (
unsigned i = 0; i < MII->getNumOperands(); ++i)
194 MIB.
add(MII->getOperand(i));
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file defines the DenseMap class.
const HexagonInstrInfo * TII
static cl::opt< unsigned > MaxLoopRange("hexagon-loop-range", cl::Hidden, cl::init(200), cl::desc("Restrict range of loopN instructions (testing only)"))
static bool isHardwareLoop(const MachineInstr &MI)
Returns true if the instruction is a hardware loop instruction.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Represent the analysis usage information of a pass.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
FunctionPass class - This class is used to implement most global optimizations.
unsigned getSize(const MachineInstr &MI) const
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
Align getAlignment() const
Return alignment of the basic block.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
virtual MachineFunctionProperties getRequiredProperties() const
Properties which a MachineFunction may have at a given point in time.
MachineFunctionProperties & set(Property P)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Function & getFunction()
Return the LLVM function that this machine code represents.
const MachineInstrBuilder & add(const MachineOperand &MO) const
Representation of each machine instruction.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
StringRef - Represent a constant reference to a string, i.e.
TargetInstrInfo - Interface to description of machine instruction set.
virtual const TargetInstrInfo * getInstrInfo() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
FunctionPass * createHexagonFixupHwLoops()
void initializeHexagonFixupHwLoopsPass(PassRegistry &)
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
constexpr T AbsoluteDifference(U X, V Y)
Subtract two unsigned integers, X and Y, of type T and return the absolute value of the result.
This struct is a compact representation of a valid (non-zero power of two) alignment.