15 #define DEBUG_TYPE "mlx-expansion"
36 STATISTIC(NumExpand,
"Number of fp MLA / MLS instructions expanded");
45 virtual const char *getPassName()
const {
46 return "ARM MLA / MLS expansion pass";
68 unsigned MulOpc,
unsigned AddSubOpc,
69 bool NegAcc,
bool HasLane);
75 void MLxExpansion::clearStack() {
101 DefMI =
MRI->getVRegDef(Reg);
107 DefMI =
MRI->getVRegDef(Reg);
116 unsigned MLxExpansion::getDefReg(
MachineInstr *MI)
const {
119 !
MRI->hasOneNonDBGUse(Reg))
130 !
MRI->hasOneNonDBGUse(Reg))
132 UseMI = &*
MRI->use_nodbg_begin(Reg);
142 bool MLxExpansion::hasLoopHazard(
MachineInstr *MI)
const {
154 if (DefMI->
isPHI()) {
155 for (
unsigned i = 1, e = DefMI->
getNumOperands(); i < e; i += 2) {
159 DefMI =
MRI->getVRegDef(SrcReg);
167 DefMI =
MRI->getVRegDef(Reg);
173 DefMI =
MRI->getVRegDef(Reg);
229 IgnoreStall.insert(DefMI);
239 if (IgnoreStall.count(MI))
247 unsigned Limit1 = isLikeA9 ? 1 : 4;
248 unsigned Limit2 = isLikeA9 ? 1 : 4;
249 for (
unsigned i = 1; i <= 4; ++i) {
250 int Idx = ((int)MIIdx - i + 4) % 4;
272 unsigned MulOpc,
unsigned AddSubOpc,
273 bool NegAcc,
bool HasLane) {
282 unsigned NextOp = HasLane ? 5 : 4;
289 unsigned TmpReg =
MRI->createVirtualRegister(
290 TII->getRegClass(MCID1, 0, TRI, MF));
303 bool AccKill =
MRI->hasOneNonDBGUse(AccReg);
312 dbgs() <<
"Expanding: " << *
MI;
319 dbgs() <<
" " << MI1;
320 dbgs() <<
" " << MI2;
328 bool Changed =
false;
359 unsigned MulOpc, AddSubOpc;
360 bool NegAcc, HasLane;
362 MulOpc, AddSubOpc, NegAcc, HasLane) ||
366 ExpandFPMLxInstruction(MBB, MI, MulOpc, AddSubOpc, NegAcc, HasLane);
387 bool Modified =
false;
391 Modified |= ExpandFPMLxInstructions(MBB);
398 return new MLxExpansion();
const MachineFunction * getParent() const
FunctionPass * createMLxExpansionPass()
MachineBasicBlock * getMBB() const
bool mayStore(QueryType Type=AnyInBundle) const
static bool isVirtualRegister(unsigned Reg)
const MCInstrDesc & getDesc() const
const HexagonInstrInfo * TII
ID
LLVM Calling Convention Representation.
const MachineInstrBuilder & addImm(int64_t Val) const
unsigned getNumOperands() const
static cl::opt< unsigned > ExpandLimit("expand-limit", cl::init(~0U), cl::Hidden)
static cl::opt< bool > ForceExapnd("expand-all-fp-mlx", cl::init(false), cl::Hidden)
bool readsRegister(unsigned Reg, const TargetRegisterInfo *TRI=NULL) const
reverse_iterator rbegin()
unsigned getKillRegState(bool B)
const MachineBasicBlock * getParent() const
unsigned getDeadRegState(bool B)
bool isImplicitDef() const
bool isInsertSubreg() const
unsigned getDefRegState(bool B)
bundle_iterator< MachineInstr, instr_iterator > iterator
initializer< Ty > init(const Ty &Val)
const MachineOperand & getOperand(unsigned i) const
MachineInstrBuilder BuildMI(MachineFunction &MF, DebugLoc DL, const MCInstrDesc &MCID)
unsigned getOpcode() const
Return the opcode number for this descriptor.
virtual const TargetInstrInfo * getInstrInfo() const
static bool hasRAWHazard(MachineInstr *DefMI, MachineInstr *MI, const TargetRegisterInfo &TRI)
const STC & getSubtarget() const
raw_ostream & dbgs()
dbgs - Return a circular-buffered debug stream.
STATISTIC(NumExpand,"Number of fp MLA / MLS instructions expanded")
static bool isPhysicalRegister(unsigned Reg)
MachineRegisterInfo & getRegInfo()
const TargetMachine & getTarget() const
virtual const TargetRegisterInfo * getRegisterInfo() const
unsigned getReg() const
getReg - Returns the register number.
std::reverse_iterator< iterator > reverse_iterator
BasicBlockListType::iterator iterator
ItTy prior(ItTy it, Dist n)
const MCRegisterInfo & MRI
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
bool isBarrier(QueryType Type=AnyInBundle) const
static bool isFpMulInstruction(unsigned Opcode)
DebugLoc getDebugLoc() const