void HexagonInstrInfo::anchor() {}
HexagonInstrInfo::HexagonInstrInfo(HexagonSubtarget &ST)
- : HexagonGenInstrInfo(Hexagon::ADJCALLSTACKDOWN, Hexagon::ADJCALLSTACKUP) {}
+ : HexagonGenInstrInfo(Hexagon::ADJCALLSTACKDOWN, Hexagon::ADJCALLSTACKUP),
+ Subtarget(ST) {}
static bool isIntRegForSubInst(unsigned Reg) {
return (Reg >= Hexagon::R0 && Reg <= Hexagon::R7) ||
unsigned NewLoopCount = createVR(MF, MVT::i32);
MachineInstr *NewAdd = BuildMI(&MBB, DL, get(Hexagon::A2_addi), NewLoopCount).
addReg(LoopCount).addImm(-1);
- const auto &HRI = *MF->getSubtarget<HexagonSubtarget>().getRegisterInfo();
+ const HexagonRegisterInfo &HRI = *Subtarget.getRegisterInfo();
// Update the previously generated instructions with the new loop counter.
for (SmallVectorImpl<MachineInstr *>::iterator I = PrevInsts.begin(),
E = PrevInsts.end(); I != E; ++I)
MachineBasicBlock::iterator I,
const DebugLoc &DL, unsigned DestReg,
unsigned SrcReg, bool KillSrc) const {
- MachineFunction &MF = *MBB.getParent();
- auto &HRI = *MF.getSubtarget<HexagonSubtarget>().getRegisterInfo();
+ const HexagonRegisterInfo &HRI = *Subtarget.getRegisterInfo();
unsigned KillFlag = getKillRegState(KillSrc);
if (Hexagon::IntRegsRegClass.contains(SrcReg, DestReg)) {
unsigned RegAlign = TRI->getSpillAlignment(*RC);
unsigned KillFlag = getKillRegState(isKill);
bool HasAlloca = MFI.hasVarSizedObjects();
- const auto &HST = MF.getSubtarget<HexagonSubtarget>();
- const HexagonFrameLowering &HFI = *HST.getFrameLowering();
+ const HexagonFrameLowering &HFI = *Subtarget.getFrameLowering();
MachineMemOperand *MMO = MF.getMachineMemOperand(
MachinePointerInfo::getFixedStack(MF, FI), MachineMemOperand::MOStore,
unsigned SlotAlign = MFI.getObjectAlignment(FI);
unsigned RegAlign = TRI->getSpillAlignment(*RC);
bool HasAlloca = MFI.hasVarSizedObjects();
- const auto &HST = MF.getSubtarget<HexagonSubtarget>();
- const HexagonFrameLowering &HFI = *HST.getFrameLowering();
+ const HexagonFrameLowering &HFI = *Subtarget.getFrameLowering();
MachineMemOperand *MMO = MF.getMachineMemOperand(
MachinePointerInfo::getFixedStack(MF, FI), MachineMemOperand::MOLoad,
MachineBasicBlock &MBB = *MI.getParent();
MachineFunction &MF = *MBB.getParent();
MachineRegisterInfo &MRI = MF.getRegInfo();
- const auto &HRI = *MF.getSubtarget<HexagonSubtarget>().getRegisterInfo();
+ const HexagonRegisterInfo &HRI = *Subtarget.getRegisterInfo();
DebugLoc DL = MI.getDebugLoc();
unsigned Opc = MI.getOpcode();
bool HexagonInstrInfo::DefinesPredicate(MachineInstr &MI,
std::vector<MachineOperand> &Pred) const {
- MachineFunction &MF = *MI.getParent()->getParent();
- const auto &HRI = *MF.getSubtarget<HexagonSubtarget>().getRegisterInfo();
+ const HexagonRegisterInfo &HRI = *Subtarget.getRegisterInfo();
for (unsigned oper = 0; oper < MI.getNumOperands(); ++oper) {
MachineOperand MO = MI.getOperand(oper);
return false;
if (MI.isCall() || isTailCall(MI)) {
- const MachineFunction &MF = *MI.getParent()->getParent();
- if (!MF.getSubtarget<HexagonSubtarget>().usePredicatedCalls())
+ if (!Subtarget.usePredicatedCalls())
return false;
}
return true;
ScheduleHazardRecognizer*
HexagonInstrInfo::CreateTargetPostRAHazardRecognizer(
const InstrItineraryData *II, const ScheduleDAG *DAG) const {
- if (UseDFAHazardRec) {
- auto &HST = DAG->MF.getSubtarget<HexagonSubtarget>();
- return new HexagonHazardRecognizer(II, this, HST);
- }
+ if (UseDFAHazardRec)
+ return new HexagonHazardRecognizer(II, this, Subtarget);
return TargetInstrInfo::CreateTargetPostRAHazardRecognizer(II, DAG);
}
}
bool HexagonInstrInfo::isComplex(const MachineInstr &MI) const {
- const MachineFunction *MF = MI.getParent()->getParent();
- const TargetInstrInfo *TII = MF->getSubtarget().getInstrInfo();
- const HexagonInstrInfo *QII = (const HexagonInstrInfo *) TII;
-
- if (!(isTC1(MI))
- && !(QII->isTC2Early(MI))
- && !(MI.getDesc().mayLoad())
- && !(MI.getDesc().mayStore())
- && (MI.getDesc().getOpcode() != Hexagon::S2_allocframe)
- && (MI.getDesc().getOpcode() != Hexagon::L2_deallocframe)
- && !(QII->isMemOp(MI))
- && !(MI.isBranch())
- && !(MI.isReturn())
- && !MI.isCall())
- return true;
-
- return false;
+ return !isTC1(MI) && !isTC2Early(MI) && !MI.getDesc().mayLoad() &&
+ !MI.getDesc().mayStore() &&
+ MI.getDesc().getOpcode() != Hexagon::S2_allocframe &&
+ MI.getDesc().getOpcode() != Hexagon::L2_deallocframe &&
+ !isMemOp(MI) && !MI.isBranch() && !MI.isReturn() && !MI.isCall();
}
// Return true if the instruction is a compund branch instruction.
const MachineInstr &ConsMI) const {
if (!ProdMI.getDesc().getNumDefs())
return false;
- const MachineFunction &MF = *ProdMI.getParent()->getParent();
- const auto &HRI = *MF.getSubtarget<HexagonSubtarget>().getRegisterInfo();
+ const HexagonRegisterInfo &HRI = *Subtarget.getRegisterInfo();
SmallVector<unsigned, 4> DefsA;
SmallVector<unsigned, 4> DefsB;
// Returns true, if a LD insn can be promoted to a cur load.
bool HexagonInstrInfo::mayBeCurLoad(const MachineInstr &MI) const {
- auto &HST = MI.getParent()->getParent()->getSubtarget<HexagonSubtarget>();
const uint64_t F = MI.getDesc().TSFlags;
return ((F >> HexagonII::mayCVLoadPos) & HexagonII::mayCVLoadMask) &&
- HST.hasV60TOps();
+ Subtarget.hasV60TOps();
}
// Returns true, if a ST insn can be promoted to a new-value store.
}
int HexagonInstrInfo::getDotOldOp(const MachineInstr &MI) const {
- const MachineFunction &MF = *MI.getParent()->getParent();
- const HexagonSubtarget &HST = MF.getSubtarget<HexagonSubtarget>();
int NewOp = MI.getOpcode();
if (isPredicated(NewOp) && isPredicatedNew(NewOp)) { // Get predicate old form
NewOp = Hexagon::getPredOldOpcode(NewOp);
// All Hexagon architectures have prediction bits on dot-new branches,
// but only Hexagon V60+ has prediction bits on dot-old ones. Make sure
// to pick the right opcode when converting back to dot-old.
- if (!HST.getFeatureBits()[Hexagon::ArchV60]) {
+ if (!Subtarget.getFeatureBits()[Hexagon::ArchV60]) {
switch (NewOp) {
case Hexagon::J2_jumptpt:
NewOp = Hexagon::J2_jumpt;
assert(NewOp >= 0 && "Couldn't change new-value store to its old form.");
}
- if (HST.hasV60TOps())
+ if (Subtarget.hasV60TOps())
return NewOp;
// Subtargets prior to V60 didn't support 'taken' forms of predicated jumps.
HexagonII::SubInstructionGroup HexagonInstrInfo::getDuplexCandidateGroup(
const MachineInstr &MI) const {
unsigned DstReg, SrcReg, Src1Reg, Src2Reg;
- const MachineFunction &MF = *MI.getParent()->getParent();
- const auto &HRI = *MF.getSubtarget<HexagonSubtarget>().getRegisterInfo();
+ const HexagonRegisterInfo &HRI = *Subtarget.getRegisterInfo();
switch (MI.getOpcode()) {
default:
unsigned DefIdx,
const MachineInstr &UseMI,
unsigned UseIdx) const {
- const MachineFunction &MF = *DefMI.getParent()->getParent();
- const auto &HRI = *MF.getSubtarget<HexagonSubtarget>().getRegisterInfo();
+ const HexagonRegisterInfo &HRI = *Subtarget.getRegisterInfo();
// Get DefIdx and UseIdx for super registers.
MachineOperand DefMO = DefMI.getOperand(DefIdx);
if (Size != 0)
return Size;
- const MachineFunction &MF = *MI.getParent()->getParent();
- const auto &HRI = *MF.getSubtarget<HexagonSubtarget>().getRegisterInfo();
-
// Handle vector access sizes.
+ const HexagonRegisterInfo &HRI = *Subtarget.getRegisterInfo();
switch (S) {
case HexagonII::HVXVectorAccess:
return HRI.getSpillSize(Hexagon::HvxVRRegClass);
}
unsigned HexagonInstrInfo::getUnits(const MachineInstr &MI) const {
- const TargetSubtargetInfo &ST = MI.getParent()->getParent()->getSubtarget();
- const InstrItineraryData &II = *ST.getInstrItineraryData();
+ const InstrItineraryData &II = *Subtarget.getInstrItineraryData();
const InstrStage &IS = *II.beginStage(MI.getDesc().getSchedClass());
return IS.getUnits();