29 #define DEBUG_TYPE "mlx-expansion" 36 STATISTIC(NumExpand,
"Number of fp MLA / MLS instructions expanded");
46 return "ARM MLA / MLS expansion pass";
68 unsigned MulOpc,
unsigned AddSubOpc,
69 bool NegAcc,
bool HasLane);
75 void MLxExpansion::clearStack() {
76 std::fill(LastMIs, LastMIs + 4,
nullptr);
101 DefMI =
MRI->getVRegDef(Reg);
107 DefMI =
MRI->getVRegDef(Reg);
116 unsigned MLxExpansion::getDefReg(
MachineInstr *MI)
const {
130 UseMI = &*
MRI->use_instr_nodbg_begin(Reg);
140 bool MLxExpansion::hasLoopHazard(
MachineInstr *MI)
const {
152 if (DefMI->
isPHI()) {
157 DefMI =
MRI->getVRegDef(SrcReg);
165 DefMI =
MRI->getVRegDef(Reg);
171 DefMI =
MRI->getVRegDef(Reg);
227 IgnoreStall.insert(DefMI);
237 if (IgnoreStall.count(MI))
245 unsigned Limit1 = isLikeA9 ? 1 : 4;
246 unsigned Limit2 = isLikeA9 ? 1 : 4;
247 for (
unsigned i = 1; i <= 4; ++i) {
248 int Idx = ((int)MIIdx - i + 4) % 4;
270 unsigned MulOpc,
unsigned AddSubOpc,
271 bool NegAcc,
bool HasLane) {
280 unsigned NextOp = HasLane ? 5 : 4;
288 MRI->createVirtualRegister(
TII->getRegClass(MCID1, 0,
TRI, MF));
301 bool AccKill =
MRI->hasOneNonDBGUse(AccReg);
310 dbgs() <<
"Expanding: " << *
MI;
313 MII = std::prev(MII);
315 MII = std::prev(MII);
317 dbgs() <<
" " << MI1;
318 dbgs() <<
" " << MI2;
326 bool Changed =
false;
354 unsigned MulOpc, AddSubOpc;
355 bool NegAcc, HasLane;
357 MulOpc, AddSubOpc, NegAcc, HasLane) ||
361 ExpandFPMLxInstruction(MBB, MI, MulOpc, AddSubOpc, NegAcc, HasLane);
385 Modified |= ExpandFPMLxInstructions(MBB);
391 return new MLxExpansion();
FunctionPass * createMLxExpansionPass()
MachineBasicBlock * getMBB() const
This class represents lattice values for constants.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
Describe properties that are true of each instruction in the target description file.
STATISTIC(NumFunctions, "Total number of functions")
unsigned const TargetRegisterInfo * TRI
bool isCopyLike() const
Return true if the instruction behaves like a copy.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const HexagonInstrInfo * TII
unsigned getNumOperands() const
Retuns the total number of operands.
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
static cl::opt< unsigned > ExpandLimit("expand-limit", cl::init(~0U), cl::Hidden)
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
static cl::opt< bool > ForceExapnd("expand-all-fp-mlx", cl::init(false), cl::Hidden)
virtual const TargetInstrInfo * getInstrInfo() const
reverse_iterator rbegin()
unsigned getKillRegState(bool B)
unsigned getDeadRegState(bool B)
unsigned getDefRegState(bool B)
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
bool mayStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly modify memory.
initializer< Ty > init(const Ty &Val)
unsigned const MachineRegisterInfo * MRI
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineInstrBuilder & UseMI
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
FunctionPass class - This class is used to implement most global optimizations.
bool isImplicitDef() const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
static bool hasRAWHazard(MachineInstr *DefMI, MachineInstr *MI, const TargetRegisterInfo &TRI)
bool readsRegister(Register Reg, const TargetRegisterInfo *TRI=nullptr) const
Return true if the MachineInstr reads the specified register.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
bool isInsertSubreg() const
MachineInstrBuilder MachineInstrBuilder & DefMI
const Function & getFunction() const
Return the LLVM function that this machine code represents.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
Representation of each machine instruction.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
unsigned getOpcode() const
Return the opcode number for this descriptor.
bool isBarrier(QueryType Type=AnyInBundle) const
Returns true if the specified instruction stops control flow from executing the instruction immediate...
StringRef - Represent a constant reference to a string, i.e.
Register getReg() const
getReg - Returns the register number.
const MachineOperand & getOperand(unsigned i) const
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
static bool isFpMulInstruction(unsigned Opcode)
Wrapper class representing virtual and physical registers.