diff options
Diffstat (limited to 'contrib/llvm/lib/Target/Hexagon/HexagonSubtarget.cpp')
-rw-r--r-- | contrib/llvm/lib/Target/Hexagon/HexagonSubtarget.cpp | 72 |
1 files changed, 48 insertions, 24 deletions
diff --git a/contrib/llvm/lib/Target/Hexagon/HexagonSubtarget.cpp b/contrib/llvm/lib/Target/Hexagon/HexagonSubtarget.cpp index fb315a7..8c23a24 100644 --- a/contrib/llvm/lib/Target/Hexagon/HexagonSubtarget.cpp +++ b/contrib/llvm/lib/Target/Hexagon/HexagonSubtarget.cpp @@ -66,9 +66,13 @@ static cl::opt<bool> DisableHexagonMISched("disable-hexagon-misched", cl::desc("Disable Hexagon MI Scheduling")); static cl::opt<bool> EnableSubregLiveness("hexagon-subreg-liveness", - cl::Hidden, cl::ZeroOrMore, cl::init(false), + cl::Hidden, cl::ZeroOrMore, cl::init(true), cl::desc("Enable subregister liveness tracking for Hexagon")); +static cl::opt<bool> OverrideLongCalls("hexagon-long-calls", + cl::Hidden, cl::ZeroOrMore, cl::init(false), + cl::desc("If present, forces/disables the use of long calls")); + void HexagonSubtarget::initializeEnvironment() { UseMemOps = false; ModeIEEERndNear = false; @@ -77,7 +81,7 @@ void HexagonSubtarget::initializeEnvironment() { HexagonSubtarget & HexagonSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) { - CPUString = HEXAGON_MC::selectHexagonCPU(getTargetTriple(), CPU); + CPUString = Hexagon_MC::selectHexagonCPU(getTargetTriple(), CPU); static std::map<StringRef, HexagonArchEnum> CpuTable { { "hexagonv4", V4 }, @@ -94,12 +98,15 @@ HexagonSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) { UseHVXOps = false; UseHVXDblOps = false; + UseLongCalls = false; ParseSubtargetFeatures(CPUString, FS); if (EnableHexagonHVX.getPosition()) UseHVXOps = EnableHexagonHVX; if (EnableHexagonHVXDouble.getPosition()) UseHVXDblOps = EnableHexagonHVXDouble; + if (OverrideLongCalls.getPosition()) + UseLongCalls = OverrideLongCalls; return *this; } @@ -148,19 +155,19 @@ void HexagonSubtarget::HexagonDAGMutation::apply(ScheduleDAGInstrs *DAG) { // Update the latency of chain edges between v60 vector load or store // instructions to be 1. These instructions cannot be scheduled in the // same packet. - MachineInstr *MI1 = SU.getInstr(); + MachineInstr &MI1 = *SU.getInstr(); auto *QII = static_cast<const HexagonInstrInfo*>(DAG->TII); - bool IsStoreMI1 = MI1->mayStore(); - bool IsLoadMI1 = MI1->mayLoad(); + bool IsStoreMI1 = MI1.mayStore(); + bool IsLoadMI1 = MI1.mayLoad(); if (!QII->isV60VectorInstruction(MI1) || !(IsStoreMI1 || IsLoadMI1)) continue; for (auto &SI : SU.Succs) { if (SI.getKind() != SDep::Order || SI.getLatency() != 0) continue; - MachineInstr *MI2 = SI.getSUnit()->getInstr(); + MachineInstr &MI2 = *SI.getSUnit()->getInstr(); if (!QII->isV60VectorInstruction(MI2)) continue; - if ((IsStoreMI1 && MI2->mayStore()) || (IsLoadMI1 && MI2->mayLoad())) { + if ((IsStoreMI1 && MI2.mayStore()) || (IsLoadMI1 && MI2.mayLoad())) { SI.setLatency(1); SU.setHeightDirty(); // Change the dependence in the opposite direction too. @@ -181,6 +188,11 @@ void HexagonSubtarget::getPostRAMutations( Mutations.push_back(make_unique<HexagonSubtarget::HexagonDAGMutation>()); } +void HexagonSubtarget::getSMSMutations( + std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations) const { + Mutations.push_back(make_unique<HexagonSubtarget::HexagonDAGMutation>()); +} + // Pin the vtable to this file. void HexagonSubtarget::anchor() {} @@ -196,8 +208,8 @@ bool HexagonSubtarget::enableSubRegLiveness() const { } // This helper function is responsible for increasing the latency only. -void HexagonSubtarget::updateLatency(MachineInstr *SrcInst, - MachineInstr *DstInst, SDep &Dep) const { +void HexagonSubtarget::updateLatency(MachineInstr &SrcInst, + MachineInstr &DstInst, SDep &Dep) const { if (!hasV60TOps()) return; @@ -231,19 +243,19 @@ static SUnit *getZeroLatency(SUnit *N, SmallVector<SDep, 4> &Deps) { /// Change the latency between the two SUnits. void HexagonSubtarget::changeLatency(SUnit *Src, SmallVector<SDep, 4> &Deps, SUnit *Dst, unsigned Lat) const { - MachineInstr *SrcI = Src->getInstr(); + MachineInstr &SrcI = *Src->getInstr(); for (auto &I : Deps) { if (I.getSUnit() != Dst) continue; I.setLatency(Lat); SUnit *UpdateDst = I.getSUnit(); - updateLatency(SrcI, UpdateDst->getInstr(), I); + updateLatency(SrcI, *UpdateDst->getInstr(), I); // Update the latency of opposite edge too. for (auto &PI : UpdateDst->Preds) { if (PI.getSUnit() != Src || !PI.isAssignedRegDep()) continue; PI.setLatency(Lat); - updateLatency(SrcI, UpdateDst->getInstr(), PI); + updateLatency(SrcI, *UpdateDst->getInstr(), PI); } } } @@ -254,10 +266,14 @@ void HexagonSubtarget::changeLatency(SUnit *Src, SmallVector<SDep, 4> &Deps, // ther others, if needed. bool HexagonSubtarget::isBestZeroLatency(SUnit *Src, SUnit *Dst, const HexagonInstrInfo *TII) const { - MachineInstr *SrcInst = Src->getInstr(); - MachineInstr *DstInst = Dst->getInstr(); + MachineInstr &SrcInst = *Src->getInstr(); + MachineInstr &DstInst = *Dst->getInstr(); + + // Ignore Boundary SU nodes as these have null instructions. + if (Dst->isBoundaryNode()) + return false; - if (SrcInst->isPHI() || DstInst->isPHI()) + if (SrcInst.isPHI() || DstInst.isPHI()) return false; // Check if the Dst instruction is the best candidate first. @@ -294,9 +310,9 @@ bool HexagonSubtarget::isBestZeroLatency(SUnit *Src, SUnit *Dst, // Update the latency of a Phi when the Phi bridges two instructions that // require a multi-cycle latency. -void HexagonSubtarget::changePhiLatency(MachineInstr *SrcInst, SUnit *Dst, +void HexagonSubtarget::changePhiLatency(MachineInstr &SrcInst, SUnit *Dst, SDep &Dep) const { - if (!SrcInst->isPHI() || Dst->NumPreds == 0 || Dep.getLatency() != 0) + if (!SrcInst.isPHI() || Dst->NumPreds == 0 || Dep.getLatency() != 0) return; for (const SDep &PI : Dst->Preds) { @@ -319,7 +335,7 @@ void HexagonSubtarget::adjustSchedDependency(SUnit *Src, SUnit *Dst, const HexagonInstrInfo *QII = static_cast<const HexagonInstrInfo *>(getInstrInfo()); // Instructions with .new operands have zero latency. - if (QII->canExecuteInBundle(SrcInst, DstInst) && + if (QII->canExecuteInBundle(*SrcInst, *DstInst) && isBestZeroLatency(Src, Dst, QII)) { Dep.setLatency(0); return; @@ -329,17 +345,17 @@ void HexagonSubtarget::adjustSchedDependency(SUnit *Src, SUnit *Dst, return; // Don't adjust the latency of post-increment part of the instruction. - if (QII->isPostIncrement(SrcInst) && Dep.isAssignedRegDep()) { + if (QII->isPostIncrement(*SrcInst) && Dep.isAssignedRegDep()) { if (SrcInst->mayStore()) return; if (Dep.getReg() != SrcInst->getOperand(0).getReg()) return; - } else if (QII->isPostIncrement(DstInst) && Dep.getKind() == SDep::Anti) { + } else if (QII->isPostIncrement(*DstInst) && Dep.getKind() == SDep::Anti) { if (DstInst->mayStore()) return; if (Dep.getReg() != DstInst->getOperand(0).getReg()) return; - } else if (QII->isPostIncrement(DstInst) && DstInst->mayStore() && + } else if (QII->isPostIncrement(*DstInst) && DstInst->mayStore() && Dep.isAssignedRegDep()) { MachineOperand &Op = DstInst->getOperand(DstInst->getNumOperands() - 1); if (Op.isReg() && Dep.getReg() != Op.getReg()) @@ -348,7 +364,7 @@ void HexagonSubtarget::adjustSchedDependency(SUnit *Src, SUnit *Dst, // Check if we need to change any the latency values when Phis are added. if (useBSBScheduling() && SrcInst->isPHI()) { - changePhiLatency(SrcInst, Dst, Dep); + changePhiLatency(*SrcInst, Dst, Dep); return; } @@ -358,12 +374,20 @@ void HexagonSubtarget::adjustSchedDependency(SUnit *Src, SUnit *Dst, DstInst = Dst->Succs[0].getSUnit()->getInstr(); // Try to schedule uses near definitions to generate .cur. - if (EnableDotCurSched && QII->isToBeScheduledASAP(SrcInst, DstInst) && + if (EnableDotCurSched && QII->isToBeScheduledASAP(*SrcInst, *DstInst) && isBestZeroLatency(Src, Dst, QII)) { Dep.setLatency(0); return; } - updateLatency(SrcInst, DstInst, Dep); + updateLatency(*SrcInst, *DstInst, Dep); +} + +unsigned HexagonSubtarget::getL1CacheLineSize() const { + return 32; +} + +unsigned HexagonSubtarget::getL1PrefetchDistance() const { + return 32; } |