2012-04-14 13:54:10 +00:00
|
|
|
//===-- HexagonSubtarget.cpp - Hexagon Subtarget Information --------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements the Hexagon specific subclass of TargetSubtarget.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "HexagonSubtarget.h"
|
|
|
|
#include "Hexagon.h"
|
2012-08-15 19:34:23 +00:00
|
|
|
#include "HexagonRegisterInfo.h"
|
2016-07-23 20:41:05 +00:00
|
|
|
#include "llvm/CodeGen/ScheduleDAG.h"
|
|
|
|
#include "llvm/CodeGen/ScheduleDAGInstrs.h"
|
2012-04-14 13:54:10 +00:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2015-12-30 11:46:15 +00:00
|
|
|
#include <map>
|
|
|
|
|
2012-04-14 13:54:10 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
2014-11-24 09:08:18 +00:00
|
|
|
#define DEBUG_TYPE "hexagon-subtarget"
|
|
|
|
|
2012-04-14 13:54:10 +00:00
|
|
|
#define GET_SUBTARGETINFO_CTOR
|
|
|
|
#define GET_SUBTARGETINFO_TARGET_DESC
|
|
|
|
#include "HexagonGenSubtargetInfo.inc"
|
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
static cl::opt<bool> EnableMemOps("enable-hexagon-memops",
|
|
|
|
cl::Hidden, cl::ZeroOrMore, cl::ValueDisallowed, cl::init(true),
|
|
|
|
cl::desc("Generate V4 MEMOP in code generation for Hexagon target"));
|
|
|
|
|
|
|
|
static cl::opt<bool> DisableMemOps("disable-hexagon-memops",
|
|
|
|
cl::Hidden, cl::ZeroOrMore, cl::ValueDisallowed, cl::init(false),
|
|
|
|
cl::desc("Do not generate V4 MEMOP in code generation for Hexagon target"));
|
|
|
|
|
|
|
|
static cl::opt<bool> EnableIEEERndNear("enable-hexagon-ieee-rnd-near",
|
|
|
|
cl::Hidden, cl::ZeroOrMore, cl::init(false),
|
|
|
|
cl::desc("Generate non-chopped conversion from fp to int."));
|
|
|
|
|
|
|
|
static cl::opt<bool> EnableBSBSched("enable-bsb-sched",
|
|
|
|
cl::Hidden, cl::ZeroOrMore, cl::init(true));
|
|
|
|
|
|
|
|
static cl::opt<bool> EnableHexagonHVXDouble("enable-hexagon-hvx-double",
|
|
|
|
cl::Hidden, cl::ZeroOrMore, cl::init(false),
|
|
|
|
cl::desc("Enable Hexagon Double Vector eXtensions"));
|
|
|
|
|
|
|
|
static cl::opt<bool> EnableHexagonHVX("enable-hexagon-hvx",
|
|
|
|
cl::Hidden, cl::ZeroOrMore, cl::init(false),
|
|
|
|
cl::desc("Enable Hexagon Vector eXtensions"));
|
2012-04-14 13:54:10 +00:00
|
|
|
|
2016-07-23 20:41:05 +00:00
|
|
|
static cl::opt<bool> EnableTCLatencySched("enable-tc-latency-sched",
|
|
|
|
cl::Hidden, cl::ZeroOrMore, cl::init(false));
|
|
|
|
|
|
|
|
static cl::opt<bool> EnableDotCurSched("enable-cur-sched",
|
|
|
|
cl::Hidden, cl::ZeroOrMore, cl::init(true),
|
|
|
|
cl::desc("Enable the scheduler to generate .cur"));
|
|
|
|
|
|
|
|
static cl::opt<bool> EnableVecFrwdSched("enable-evec-frwd-sched",
|
|
|
|
cl::Hidden, cl::ZeroOrMore, cl::init(true));
|
|
|
|
|
2015-05-27 18:44:32 +00:00
|
|
|
static cl::opt<bool> DisableHexagonMISched("disable-hexagon-misched",
|
2015-12-30 11:46:15 +00:00
|
|
|
cl::Hidden, cl::ZeroOrMore, cl::init(false),
|
|
|
|
cl::desc("Disable Hexagon MI Scheduling"));
|
|
|
|
|
2016-07-23 20:41:05 +00:00
|
|
|
static cl::opt<bool> EnableSubregLiveness("hexagon-subreg-liveness",
|
2017-01-02 19:17:04 +00:00
|
|
|
cl::Hidden, cl::ZeroOrMore, cl::init(true),
|
2016-07-23 20:41:05 +00:00
|
|
|
cl::desc("Enable subregister liveness tracking for Hexagon"));
|
|
|
|
|
2017-01-02 19:17:04 +00:00
|
|
|
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"));
|
|
|
|
|
2017-05-08 17:12:57 +00:00
|
|
|
static cl::opt<bool> EnablePredicatedCalls("hexagon-pred-calls",
|
|
|
|
cl::Hidden, cl::ZeroOrMore, cl::init(false),
|
|
|
|
cl::desc("Consider calls to be predicable"));
|
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
void HexagonSubtarget::initializeEnvironment() {
|
|
|
|
UseMemOps = false;
|
|
|
|
ModeIEEERndNear = false;
|
|
|
|
UseBSBScheduling = false;
|
|
|
|
}
|
2015-05-27 18:44:32 +00:00
|
|
|
|
2014-11-24 09:08:18 +00:00
|
|
|
HexagonSubtarget &
|
|
|
|
HexagonSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) {
|
2017-01-02 19:17:04 +00:00
|
|
|
CPUString = Hexagon_MC::selectHexagonCPU(getTargetTriple(), CPU);
|
2015-12-30 11:46:15 +00:00
|
|
|
|
|
|
|
static std::map<StringRef, HexagonArchEnum> CpuTable {
|
|
|
|
{ "hexagonv4", V4 },
|
|
|
|
{ "hexagonv5", V5 },
|
|
|
|
{ "hexagonv55", V55 },
|
|
|
|
{ "hexagonv60", V60 },
|
2017-04-16 16:01:22 +00:00
|
|
|
{ "hexagonv62", V62 },
|
2015-12-30 11:46:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
auto foundIt = CpuTable.find(CPUString);
|
|
|
|
if (foundIt != CpuTable.end())
|
|
|
|
HexagonArchVersion = foundIt->second;
|
|
|
|
else
|
2012-12-02 13:10:19 +00:00
|
|
|
llvm_unreachable("Unrecognized Hexagon processor version");
|
2012-04-14 13:54:10 +00:00
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
UseHVXOps = false;
|
|
|
|
UseHVXDblOps = false;
|
2017-01-02 19:17:04 +00:00
|
|
|
UseLongCalls = false;
|
2012-12-02 13:10:19 +00:00
|
|
|
ParseSubtargetFeatures(CPUString, FS);
|
2015-12-30 11:46:15 +00:00
|
|
|
|
|
|
|
if (EnableHexagonHVX.getPosition())
|
|
|
|
UseHVXOps = EnableHexagonHVX;
|
|
|
|
if (EnableHexagonHVXDouble.getPosition())
|
|
|
|
UseHVXDblOps = EnableHexagonHVXDouble;
|
2017-01-02 19:17:04 +00:00
|
|
|
if (OverrideLongCalls.getPosition())
|
|
|
|
UseLongCalls = OverrideLongCalls;
|
2015-12-30 11:46:15 +00:00
|
|
|
|
2014-11-24 09:08:18 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-06-21 13:59:01 +00:00
|
|
|
HexagonSubtarget::HexagonSubtarget(const Triple &TT, StringRef CPU,
|
|
|
|
StringRef FS, const TargetMachine &TM)
|
2015-05-27 18:44:32 +00:00
|
|
|
: HexagonGenSubtargetInfo(TT, CPU, FS), CPUString(CPU),
|
|
|
|
InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
|
2015-08-07 23:01:33 +00:00
|
|
|
FrameLowering() {
|
2012-12-02 13:10:19 +00:00
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
initializeEnvironment();
|
|
|
|
|
2012-04-14 13:54:10 +00:00
|
|
|
// Initialize scheduling itinerary for the specified CPU.
|
|
|
|
InstrItins = getInstrItineraryForCPU(CPUString);
|
|
|
|
|
2013-04-08 18:41:23 +00:00
|
|
|
// UseMemOps on by default unless disabled explicitly
|
|
|
|
if (DisableMemOps)
|
|
|
|
UseMemOps = false;
|
|
|
|
else if (EnableMemOps)
|
2012-04-14 13:54:10 +00:00
|
|
|
UseMemOps = true;
|
|
|
|
else
|
|
|
|
UseMemOps = false;
|
2012-08-15 19:34:23 +00:00
|
|
|
|
|
|
|
if (EnableIEEERndNear)
|
|
|
|
ModeIEEERndNear = true;
|
|
|
|
else
|
|
|
|
ModeIEEERndNear = false;
|
2015-12-30 11:46:15 +00:00
|
|
|
|
|
|
|
UseBSBScheduling = hasV60TOps() && EnableBSBSched;
|
2012-04-14 13:54:10 +00:00
|
|
|
}
|
2012-08-15 19:34:23 +00:00
|
|
|
|
2017-05-08 17:12:57 +00:00
|
|
|
/// \brief Perform target specific adjustments to the latency of a schedule
|
|
|
|
/// dependency.
|
|
|
|
void HexagonSubtarget::adjustSchedDependency(SUnit *Src, SUnit *Dst,
|
|
|
|
SDep &Dep) const {
|
|
|
|
MachineInstr *SrcInst = Src->getInstr();
|
|
|
|
MachineInstr *DstInst = Dst->getInstr();
|
|
|
|
if (!Src->isInstr() || !Dst->isInstr())
|
|
|
|
return;
|
|
|
|
|
|
|
|
const HexagonInstrInfo *QII = getInstrInfo();
|
|
|
|
|
|
|
|
// Instructions with .new operands have zero latency.
|
|
|
|
SmallSet<SUnit *, 4> ExclSrc;
|
|
|
|
SmallSet<SUnit *, 4> ExclDst;
|
|
|
|
if (QII->canExecuteInBundle(*SrcInst, *DstInst) &&
|
|
|
|
isBestZeroLatency(Src, Dst, QII, ExclSrc, ExclDst)) {
|
|
|
|
Dep.setLatency(0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!hasV60TOps())
|
|
|
|
return;
|
|
|
|
|
|
|
|
// If it's a REG_SEQUENCE, use its destination instruction to determine
|
|
|
|
// the correct latency.
|
|
|
|
if (DstInst->isRegSequence() && Dst->NumSuccs == 1) {
|
|
|
|
unsigned RSeqReg = DstInst->getOperand(0).getReg();
|
|
|
|
MachineInstr *RSeqDst = Dst->Succs[0].getSUnit()->getInstr();
|
|
|
|
unsigned UseIdx = -1;
|
|
|
|
for (unsigned OpNum = 0; OpNum < RSeqDst->getNumOperands(); OpNum++) {
|
|
|
|
const MachineOperand &MO = RSeqDst->getOperand(OpNum);
|
|
|
|
if (MO.isReg() && MO.getReg() && MO.isUse() && MO.getReg() == RSeqReg) {
|
|
|
|
UseIdx = OpNum;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
unsigned RSeqLatency = (InstrInfo.getOperandLatency(&InstrItins, *SrcInst,
|
|
|
|
0, *RSeqDst, UseIdx));
|
|
|
|
Dep.setLatency(RSeqLatency);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try to schedule uses near definitions to generate .cur.
|
|
|
|
ExclSrc.clear();
|
|
|
|
ExclDst.clear();
|
|
|
|
if (EnableDotCurSched && QII->isToBeScheduledASAP(*SrcInst, *DstInst) &&
|
|
|
|
isBestZeroLatency(Src, Dst, QII, ExclSrc, ExclDst)) {
|
|
|
|
Dep.setLatency(0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
updateLatency(*SrcInst, *DstInst, Dep);
|
|
|
|
}
|
|
|
|
|
2016-07-23 20:41:05 +00:00
|
|
|
|
|
|
|
void HexagonSubtarget::HexagonDAGMutation::apply(ScheduleDAGInstrs *DAG) {
|
|
|
|
for (auto &SU : DAG->SUnits) {
|
|
|
|
if (!SU.isInstr())
|
|
|
|
continue;
|
|
|
|
SmallVector<SDep, 4> Erase;
|
|
|
|
for (auto &D : SU.Preds)
|
|
|
|
if (D.getKind() == SDep::Output && D.getReg() == Hexagon::USR_OVF)
|
|
|
|
Erase.push_back(D);
|
|
|
|
for (auto &E : Erase)
|
|
|
|
SU.removePred(E);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto &SU : DAG->SUnits) {
|
|
|
|
// Update the latency of chain edges between v60 vector load or store
|
2017-05-08 17:12:57 +00:00
|
|
|
// instructions to be 1. These instruction cannot be scheduled in the
|
2016-07-23 20:41:05 +00:00
|
|
|
// same packet.
|
2017-01-02 19:17:04 +00:00
|
|
|
MachineInstr &MI1 = *SU.getInstr();
|
2016-07-23 20:41:05 +00:00
|
|
|
auto *QII = static_cast<const HexagonInstrInfo*>(DAG->TII);
|
2017-01-02 19:17:04 +00:00
|
|
|
bool IsStoreMI1 = MI1.mayStore();
|
|
|
|
bool IsLoadMI1 = MI1.mayLoad();
|
2017-05-08 17:12:57 +00:00
|
|
|
if (!QII->isHVXVec(MI1) || !(IsStoreMI1 || IsLoadMI1))
|
2016-07-23 20:41:05 +00:00
|
|
|
continue;
|
|
|
|
for (auto &SI : SU.Succs) {
|
|
|
|
if (SI.getKind() != SDep::Order || SI.getLatency() != 0)
|
|
|
|
continue;
|
2017-01-02 19:17:04 +00:00
|
|
|
MachineInstr &MI2 = *SI.getSUnit()->getInstr();
|
2017-05-08 17:12:57 +00:00
|
|
|
if (!QII->isHVXVec(MI2))
|
2016-07-23 20:41:05 +00:00
|
|
|
continue;
|
2017-01-02 19:17:04 +00:00
|
|
|
if ((IsStoreMI1 && MI2.mayStore()) || (IsLoadMI1 && MI2.mayLoad())) {
|
2016-07-23 20:41:05 +00:00
|
|
|
SI.setLatency(1);
|
|
|
|
SU.setHeightDirty();
|
|
|
|
// Change the dependence in the opposite direction too.
|
|
|
|
for (auto &PI : SI.getSUnit()->Preds) {
|
|
|
|
if (PI.getSUnit() != &SU || PI.getKind() != SDep::Order)
|
|
|
|
continue;
|
|
|
|
PI.setLatency(1);
|
|
|
|
SI.getSUnit()->setDepthDirty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void HexagonSubtarget::getPostRAMutations(
|
|
|
|
std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations) const {
|
|
|
|
Mutations.push_back(make_unique<HexagonSubtarget::HexagonDAGMutation>());
|
|
|
|
}
|
|
|
|
|
2017-01-02 19:17:04 +00:00
|
|
|
void HexagonSubtarget::getSMSMutations(
|
|
|
|
std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations) const {
|
|
|
|
Mutations.push_back(make_unique<HexagonSubtarget::HexagonDAGMutation>());
|
|
|
|
}
|
|
|
|
|
2016-07-23 20:41:05 +00:00
|
|
|
|
2013-12-22 00:04:03 +00:00
|
|
|
// Pin the vtable to this file.
|
|
|
|
void HexagonSubtarget::anchor() {}
|
2015-05-27 18:44:32 +00:00
|
|
|
|
|
|
|
bool HexagonSubtarget::enableMachineScheduler() const {
|
|
|
|
if (DisableHexagonMISched.getNumOccurrences())
|
|
|
|
return !DisableHexagonMISched;
|
|
|
|
return true;
|
|
|
|
}
|
2016-07-23 20:41:05 +00:00
|
|
|
|
2017-05-08 17:12:57 +00:00
|
|
|
bool HexagonSubtarget::usePredicatedCalls() const {
|
|
|
|
return EnablePredicatedCalls;
|
2016-07-23 20:41:05 +00:00
|
|
|
}
|
|
|
|
|
2017-01-02 19:17:04 +00:00
|
|
|
void HexagonSubtarget::updateLatency(MachineInstr &SrcInst,
|
|
|
|
MachineInstr &DstInst, SDep &Dep) const {
|
2017-05-08 17:12:57 +00:00
|
|
|
if (Dep.isArtificial()) {
|
|
|
|
Dep.setLatency(1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-07-23 20:41:05 +00:00
|
|
|
if (!hasV60TOps())
|
|
|
|
return;
|
|
|
|
|
|
|
|
auto &QII = static_cast<const HexagonInstrInfo&>(*getInstrInfo());
|
|
|
|
|
2017-05-08 17:12:57 +00:00
|
|
|
// BSB scheduling.
|
|
|
|
if (QII.isHVXVec(SrcInst) || useBSBScheduling())
|
|
|
|
Dep.setLatency((Dep.getLatency() + 1) >> 1);
|
2016-07-23 20:41:05 +00:00
|
|
|
}
|
|
|
|
|
2017-05-08 17:12:57 +00:00
|
|
|
void HexagonSubtarget::restoreLatency(SUnit *Src, SUnit *Dst) const {
|
|
|
|
MachineInstr *SrcI = Src->getInstr();
|
|
|
|
for (auto &I : Src->Succs) {
|
|
|
|
if (!I.isAssignedRegDep() || I.getSUnit() != Dst)
|
|
|
|
continue;
|
|
|
|
unsigned DepR = I.getReg();
|
|
|
|
int DefIdx = -1;
|
|
|
|
for (unsigned OpNum = 0; OpNum < SrcI->getNumOperands(); OpNum++) {
|
|
|
|
const MachineOperand &MO = SrcI->getOperand(OpNum);
|
|
|
|
if (MO.isReg() && MO.isDef() && MO.getReg() == DepR)
|
|
|
|
DefIdx = OpNum;
|
|
|
|
}
|
|
|
|
assert(DefIdx >= 0 && "Def Reg not found in Src MI");
|
|
|
|
MachineInstr *DstI = Dst->getInstr();
|
|
|
|
for (unsigned OpNum = 0; OpNum < DstI->getNumOperands(); OpNum++) {
|
|
|
|
const MachineOperand &MO = DstI->getOperand(OpNum);
|
|
|
|
if (MO.isReg() && MO.isUse() && MO.getReg() == DepR) {
|
|
|
|
int Latency = (InstrInfo.getOperandLatency(&InstrItins, *SrcI,
|
|
|
|
DefIdx, *DstI, OpNum));
|
|
|
|
|
|
|
|
// For some instructions (ex: COPY), we might end up with < 0 latency
|
|
|
|
// as they don't have any Itinerary class associated with them.
|
|
|
|
if (Latency <= 0)
|
|
|
|
Latency = 1;
|
|
|
|
|
|
|
|
I.setLatency(Latency);
|
|
|
|
updateLatency(*SrcI, *DstI, I);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update the latency of opposite edge too.
|
|
|
|
for (auto &J : Dst->Preds) {
|
|
|
|
if (J.getSUnit() != Src)
|
|
|
|
continue;
|
|
|
|
J.setLatency(I.getLatency());
|
|
|
|
}
|
|
|
|
}
|
2016-07-23 20:41:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Change the latency between the two SUnits.
|
2017-05-08 17:12:57 +00:00
|
|
|
void HexagonSubtarget::changeLatency(SUnit *Src, SUnit *Dst, unsigned Lat)
|
|
|
|
const {
|
|
|
|
for (auto &I : Src->Succs) {
|
2016-07-23 20:41:05 +00:00
|
|
|
if (I.getSUnit() != Dst)
|
|
|
|
continue;
|
2017-05-08 17:12:57 +00:00
|
|
|
SDep T = I;
|
2016-07-23 20:41:05 +00:00
|
|
|
I.setLatency(Lat);
|
2017-05-08 17:12:57 +00:00
|
|
|
|
2016-07-23 20:41:05 +00:00
|
|
|
// Update the latency of opposite edge too.
|
2017-05-08 17:12:57 +00:00
|
|
|
T.setSUnit(Src);
|
|
|
|
auto F = std::find(Dst->Preds.begin(), Dst->Preds.end(), T);
|
|
|
|
assert(F != Dst->Preds.end());
|
|
|
|
F->setLatency(I.getLatency());
|
2016-07-23 20:41:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-08 17:12:57 +00:00
|
|
|
/// If the SUnit has a zero latency edge, return the other SUnit.
|
|
|
|
static SUnit *getZeroLatency(SUnit *N, SmallVector<SDep, 4> &Deps) {
|
|
|
|
for (auto &I : Deps)
|
|
|
|
if (I.isAssignedRegDep() && I.getLatency() == 0 &&
|
|
|
|
!I.getSUnit()->getInstr()->isPseudo())
|
|
|
|
return I.getSUnit();
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-07-23 20:41:05 +00:00
|
|
|
// Return true if these are the best two instructions to schedule
|
|
|
|
// together with a zero latency. Only one dependence should have a zero
|
|
|
|
// latency. If there are multiple choices, choose the best, and change
|
2017-05-08 17:12:57 +00:00
|
|
|
// the others, if needed.
|
2016-07-23 20:41:05 +00:00
|
|
|
bool HexagonSubtarget::isBestZeroLatency(SUnit *Src, SUnit *Dst,
|
2017-05-08 17:12:57 +00:00
|
|
|
const HexagonInstrInfo *TII, SmallSet<SUnit*, 4> &ExclSrc,
|
|
|
|
SmallSet<SUnit*, 4> &ExclDst) const {
|
2017-01-02 19:17:04 +00:00
|
|
|
MachineInstr &SrcInst = *Src->getInstr();
|
|
|
|
MachineInstr &DstInst = *Dst->getInstr();
|
|
|
|
|
|
|
|
// Ignore Boundary SU nodes as these have null instructions.
|
|
|
|
if (Dst->isBoundaryNode())
|
|
|
|
return false;
|
2016-07-23 20:41:05 +00:00
|
|
|
|
2017-01-02 19:17:04 +00:00
|
|
|
if (SrcInst.isPHI() || DstInst.isPHI())
|
2016-07-23 20:41:05 +00:00
|
|
|
return false;
|
|
|
|
|
2017-05-08 17:12:57 +00:00
|
|
|
if (!TII->isToBeScheduledASAP(SrcInst, DstInst) &&
|
|
|
|
!TII->canExecuteInBundle(SrcInst, DstInst))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// The architecture doesn't allow three dependent instructions in the same
|
|
|
|
// packet. So, if the destination has a zero latency successor, then it's
|
|
|
|
// not a candidate for a zero latency predecessor.
|
|
|
|
if (getZeroLatency(Dst, Dst->Succs) != nullptr)
|
|
|
|
return false;
|
|
|
|
|
2016-07-23 20:41:05 +00:00
|
|
|
// Check if the Dst instruction is the best candidate first.
|
|
|
|
SUnit *Best = nullptr;
|
|
|
|
SUnit *DstBest = nullptr;
|
|
|
|
SUnit *SrcBest = getZeroLatency(Dst, Dst->Preds);
|
|
|
|
if (SrcBest == nullptr || Src->NodeNum >= SrcBest->NodeNum) {
|
|
|
|
// Check that Src doesn't have a better candidate.
|
|
|
|
DstBest = getZeroLatency(Src, Src->Succs);
|
|
|
|
if (DstBest == nullptr || Dst->NodeNum <= DstBest->NodeNum)
|
|
|
|
Best = Dst;
|
|
|
|
}
|
|
|
|
if (Best != Dst)
|
|
|
|
return false;
|
|
|
|
|
2017-05-08 17:12:57 +00:00
|
|
|
// The caller frequently adds the same dependence twice. If so, then
|
2016-07-23 20:41:05 +00:00
|
|
|
// return true for this case too.
|
2017-05-08 17:12:57 +00:00
|
|
|
if ((Src == SrcBest && Dst == DstBest ) ||
|
|
|
|
(SrcBest == nullptr && Dst == DstBest) ||
|
|
|
|
(Src == SrcBest && Dst == nullptr))
|
2016-07-23 20:41:05 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
// Reassign the latency for the previous bests, which requires setting
|
|
|
|
// the dependence edge in both directions.
|
2017-05-08 17:12:57 +00:00
|
|
|
if (SrcBest != nullptr) {
|
|
|
|
if (!hasV60TOps())
|
|
|
|
changeLatency(SrcBest, Dst, 1);
|
|
|
|
else
|
|
|
|
restoreLatency(SrcBest, Dst);
|
2016-07-23 20:41:05 +00:00
|
|
|
}
|
2017-05-08 17:12:57 +00:00
|
|
|
if (DstBest != nullptr) {
|
|
|
|
if (!hasV60TOps())
|
|
|
|
changeLatency(Src, DstBest, 1);
|
|
|
|
else
|
|
|
|
restoreLatency(Src, DstBest);
|
2016-07-23 20:41:05 +00:00
|
|
|
}
|
|
|
|
|
2017-05-08 17:12:57 +00:00
|
|
|
// Attempt to find another opprotunity for zero latency in a different
|
|
|
|
// dependence.
|
|
|
|
if (SrcBest && DstBest)
|
|
|
|
// If there is an edge from SrcBest to DstBst, then try to change that
|
|
|
|
// to 0 now.
|
|
|
|
changeLatency(SrcBest, DstBest, 0);
|
|
|
|
else if (DstBest) {
|
|
|
|
// Check if the previous best destination instruction has a new zero
|
|
|
|
// latency dependence opportunity.
|
|
|
|
ExclSrc.insert(Src);
|
|
|
|
for (auto &I : DstBest->Preds)
|
|
|
|
if (ExclSrc.count(I.getSUnit()) == 0 &&
|
|
|
|
isBestZeroLatency(I.getSUnit(), DstBest, TII, ExclSrc, ExclDst))
|
|
|
|
changeLatency(I.getSUnit(), DstBest, 0);
|
|
|
|
} else if (SrcBest) {
|
|
|
|
// Check if previous best source instruction has a new zero latency
|
|
|
|
// dependence opportunity.
|
|
|
|
ExclDst.insert(Dst);
|
|
|
|
for (auto &I : SrcBest->Succs)
|
|
|
|
if (ExclDst.count(I.getSUnit()) == 0 &&
|
|
|
|
isBestZeroLatency(SrcBest, I.getSUnit(), TII, ExclSrc, ExclDst))
|
|
|
|
changeLatency(SrcBest, I.getSUnit(), 0);
|
2016-07-23 20:41:05 +00:00
|
|
|
}
|
|
|
|
|
2017-05-08 17:12:57 +00:00
|
|
|
return true;
|
2017-01-02 19:17:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned HexagonSubtarget::getL1CacheLineSize() const {
|
|
|
|
return 32;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned HexagonSubtarget::getL1PrefetchDistance() const {
|
|
|
|
return 32;
|
2016-07-23 20:41:05 +00:00
|
|
|
}
|
|
|
|
|
2017-05-08 17:12:57 +00:00
|
|
|
bool HexagonSubtarget::enableSubRegLiveness() const {
|
|
|
|
return EnableSubregLiveness;
|
|
|
|
}
|
|
|
|
|