blob: 0aada8a53c979b5f008f5a7bca9e28ffaa345df2 [file] [log] [blame]
Eugene Zelenko8361b0a2017-06-19 22:43:19 +00001//===- HexagonSubtarget.cpp - Hexagon Subtarget Information ---------------===//
Tony Linthicum1213a7a2011-12-12 21:14:40 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the Hexagon specific subclass of TargetSubtarget.
11//
12//===----------------------------------------------------------------------===//
13
Tony Linthicum1213a7a2011-12-12 21:14:40 +000014#include "Hexagon.h"
Eugene Zelenko8361b0a2017-06-19 22:43:19 +000015#include "HexagonInstrInfo.h"
Sirish Pande69295b82012-05-10 20:20:25 +000016#include "HexagonRegisterInfo.h"
Eugene Zelenko8361b0a2017-06-19 22:43:19 +000017#include "HexagonSubtarget.h"
18#include "llvm/ADT/STLExtras.h"
19#include "llvm/ADT/SmallSet.h"
20#include "llvm/ADT/SmallVector.h"
21#include "llvm/ADT/StringRef.h"
22#include "MCTargetDesc/HexagonMCTargetDesc.h"
23#include "llvm/CodeGen/MachineInstr.h"
24#include "llvm/CodeGen/MachineOperand.h"
Krzysztof Parzyszek9be66732016-07-15 17:48:09 +000025#include "llvm/CodeGen/ScheduleDAG.h"
26#include "llvm/CodeGen/ScheduleDAGInstrs.h"
Tony Linthicum1213a7a2011-12-12 21:14:40 +000027#include "llvm/Support/CommandLine.h"
28#include "llvm/Support/ErrorHandling.h"
Eugene Zelenko8361b0a2017-06-19 22:43:19 +000029#include <algorithm>
30#include <cassert>
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +000031#include <map>
32
Tony Linthicum1213a7a2011-12-12 21:14:40 +000033using namespace llvm;
34
Chandler Carruthe96dd892014-04-21 22:55:11 +000035#define DEBUG_TYPE "hexagon-subtarget"
36
Tony Linthicum1213a7a2011-12-12 21:14:40 +000037#define GET_SUBTARGETINFO_CTOR
38#define GET_SUBTARGETINFO_TARGET_DESC
39#include "HexagonGenSubtargetInfo.inc"
40
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +000041static cl::opt<bool> EnableMemOps("enable-hexagon-memops",
42 cl::Hidden, cl::ZeroOrMore, cl::ValueDisallowed, cl::init(true),
43 cl::desc("Generate V4 MEMOP in code generation for Hexagon target"));
Jyotsna Vermafdc660b2013-03-22 18:41:34 +000044
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +000045static cl::opt<bool> DisableMemOps("disable-hexagon-memops",
46 cl::Hidden, cl::ZeroOrMore, cl::ValueDisallowed, cl::init(false),
47 cl::desc("Do not generate V4 MEMOP in code generation for Hexagon target"));
Sirish Pande69295b82012-05-10 20:20:25 +000048
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +000049static cl::opt<bool> EnableIEEERndNear("enable-hexagon-ieee-rnd-near",
50 cl::Hidden, cl::ZeroOrMore, cl::init(false),
51 cl::desc("Generate non-chopped conversion from fp to int."));
Tony Linthicum1213a7a2011-12-12 21:14:40 +000052
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +000053static cl::opt<bool> EnableBSBSched("enable-bsb-sched",
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +000054 cl::Hidden, cl::ZeroOrMore, cl::init(true));
55
56static cl::opt<bool> EnableHexagonHVXDouble("enable-hexagon-hvx-double",
57 cl::Hidden, cl::ZeroOrMore, cl::init(false),
58 cl::desc("Enable Hexagon Double Vector eXtensions"));
59
60static cl::opt<bool> EnableHexagonHVX("enable-hexagon-hvx",
61 cl::Hidden, cl::ZeroOrMore, cl::init(false),
62 cl::desc("Enable Hexagon Vector eXtensions"));
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +000063
Krzysztof Parzyszek408e3002016-07-15 21:34:02 +000064static cl::opt<bool> EnableTCLatencySched("enable-tc-latency-sched",
65 cl::Hidden, cl::ZeroOrMore, cl::init(false));
66
67static cl::opt<bool> EnableDotCurSched("enable-cur-sched",
68 cl::Hidden, cl::ZeroOrMore, cl::init(true),
69 cl::desc("Enable the scheduler to generate .cur"));
70
71static cl::opt<bool> EnableVecFrwdSched("enable-evec-frwd-sched",
72 cl::Hidden, cl::ZeroOrMore, cl::init(true));
73
Eric Christopher5f141b02015-03-11 22:56:10 +000074static cl::opt<bool> DisableHexagonMISched("disable-hexagon-misched",
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +000075 cl::Hidden, cl::ZeroOrMore, cl::init(false),
76 cl::desc("Disable Hexagon MI Scheduling"));
77
Krzysztof Parzyszek07d75182016-05-28 02:02:51 +000078static cl::opt<bool> EnableSubregLiveness("hexagon-subreg-liveness",
Krzysztof Parzyszekb5ec4872016-08-24 17:17:39 +000079 cl::Hidden, cl::ZeroOrMore, cl::init(true),
Krzysztof Parzyszek07d75182016-05-28 02:02:51 +000080 cl::desc("Enable subregister liveness tracking for Hexagon"));
81
Krzysztof Parzyszek080bebd2016-07-25 14:42:11 +000082static cl::opt<bool> OverrideLongCalls("hexagon-long-calls",
83 cl::Hidden, cl::ZeroOrMore, cl::init(false),
84 cl::desc("If present, forces/disables the use of long calls"));
85
Krzysztof Parzyszekee93e002017-05-05 22:13:57 +000086static cl::opt<bool> EnablePredicatedCalls("hexagon-pred-calls",
87 cl::Hidden, cl::ZeroOrMore, cl::init(false),
88 cl::desc("Consider calls to be predicable"));
89
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +000090void HexagonSubtarget::initializeEnvironment() {
91 UseMemOps = false;
92 ModeIEEERndNear = false;
93 UseBSBScheduling = false;
94}
Eric Christopher5f141b02015-03-11 22:56:10 +000095
Eric Christopherc4c63ae2014-06-27 00:27:40 +000096HexagonSubtarget &
97HexagonSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) {
Krzysztof Parzyszek75e74ee2016-08-19 14:09:47 +000098 CPUString = Hexagon_MC::selectHexagonCPU(getTargetTriple(), CPU);
Sebastian Pop1a0bef62012-08-20 19:56:47 +000099
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +0000100 static std::map<StringRef, HexagonArchEnum> CpuTable {
101 { "hexagonv4", V4 },
102 { "hexagonv5", V5 },
103 { "hexagonv55", V55 },
104 { "hexagonv60", V60 },
Krzysztof Parzyszekf9015e62017-02-10 23:46:45 +0000105 { "hexagonv62", V62 },
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +0000106 };
107
108 auto foundIt = CpuTable.find(CPUString);
109 if (foundIt != CpuTable.end())
110 HexagonArchVersion = foundIt->second;
111 else
Sebastian Pop1a0bef62012-08-20 19:56:47 +0000112 llvm_unreachable("Unrecognized Hexagon processor version");
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000113
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +0000114 UseHVXOps = false;
115 UseHVXDblOps = false;
Krzysztof Parzyszek080bebd2016-07-25 14:42:11 +0000116 UseLongCalls = false;
Sebastian Pop1a0bef62012-08-20 19:56:47 +0000117 ParseSubtargetFeatures(CPUString, FS);
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +0000118
119 if (EnableHexagonHVX.getPosition())
120 UseHVXOps = EnableHexagonHVX;
121 if (EnableHexagonHVXDouble.getPosition())
122 UseHVXDblOps = EnableHexagonHVXDouble;
Krzysztof Parzyszek080bebd2016-07-25 14:42:11 +0000123 if (OverrideLongCalls.getPosition())
124 UseLongCalls = OverrideLongCalls;
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +0000125
Eric Christopherc4c63ae2014-06-27 00:27:40 +0000126 return *this;
127}
128
Daniel Sandersa73f1fd2015-06-10 12:11:26 +0000129HexagonSubtarget::HexagonSubtarget(const Triple &TT, StringRef CPU,
130 StringRef FS, const TargetMachine &TM)
Daniel Sanders50f17232015-09-15 16:17:27 +0000131 : HexagonGenSubtargetInfo(TT, CPU, FS), CPUString(CPU),
Eugene Zelenko8361b0a2017-06-19 22:43:19 +0000132 InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this) {
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +0000133 initializeEnvironment();
134
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000135 // Initialize scheduling itinerary for the specified CPU.
136 InstrItins = getInstrItineraryForCPU(CPUString);
137
Jyotsna Vermafdc660b2013-03-22 18:41:34 +0000138 // UseMemOps on by default unless disabled explicitly
139 if (DisableMemOps)
140 UseMemOps = false;
141 else if (EnableMemOps)
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000142 UseMemOps = true;
143 else
144 UseMemOps = false;
Sirish Pande69295b82012-05-10 20:20:25 +0000145
146 if (EnableIEEERndNear)
147 ModeIEEERndNear = true;
148 else
149 ModeIEEERndNear = false;
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000150
151 UseBSBScheduling = hasV60TOps() && EnableBSBSched;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000152}
Sirish Pande69295b82012-05-10 20:20:25 +0000153
Krzysztof Parzyszek2af50372017-05-03 20:10:36 +0000154/// \brief Perform target specific adjustments to the latency of a schedule
155/// dependency.
156void HexagonSubtarget::adjustSchedDependency(SUnit *Src, SUnit *Dst,
157 SDep &Dep) const {
158 MachineInstr *SrcInst = Src->getInstr();
159 MachineInstr *DstInst = Dst->getInstr();
160 if (!Src->isInstr() || !Dst->isInstr())
161 return;
162
163 const HexagonInstrInfo *QII = getInstrInfo();
164
165 // Instructions with .new operands have zero latency.
166 SmallSet<SUnit *, 4> ExclSrc;
167 SmallSet<SUnit *, 4> ExclDst;
168 if (QII->canExecuteInBundle(*SrcInst, *DstInst) &&
169 isBestZeroLatency(Src, Dst, QII, ExclSrc, ExclDst)) {
170 Dep.setLatency(0);
171 return;
172 }
173
174 if (!hasV60TOps())
175 return;
176
177 // If it's a REG_SEQUENCE, use its destination instruction to determine
178 // the correct latency.
179 if (DstInst->isRegSequence() && Dst->NumSuccs == 1) {
180 unsigned RSeqReg = DstInst->getOperand(0).getReg();
181 MachineInstr *RSeqDst = Dst->Succs[0].getSUnit()->getInstr();
182 unsigned UseIdx = -1;
183 for (unsigned OpNum = 0; OpNum < RSeqDst->getNumOperands(); OpNum++) {
184 const MachineOperand &MO = RSeqDst->getOperand(OpNum);
185 if (MO.isReg() && MO.getReg() && MO.isUse() && MO.getReg() == RSeqReg) {
186 UseIdx = OpNum;
187 break;
188 }
189 }
190 unsigned RSeqLatency = (InstrInfo.getOperandLatency(&InstrItins, *SrcInst,
191 0, *RSeqDst, UseIdx));
192 Dep.setLatency(RSeqLatency);
193 }
194
195 // Try to schedule uses near definitions to generate .cur.
196 ExclSrc.clear();
197 ExclDst.clear();
198 if (EnableDotCurSched && QII->isToBeScheduledASAP(*SrcInst, *DstInst) &&
199 isBestZeroLatency(Src, Dst, QII, ExclSrc, ExclDst)) {
200 Dep.setLatency(0);
201 return;
202 }
203
204 updateLatency(*SrcInst, *DstInst, Dep);
205}
206
Krzysztof Parzyszek9be66732016-07-15 17:48:09 +0000207void HexagonSubtarget::HexagonDAGMutation::apply(ScheduleDAGInstrs *DAG) {
208 for (auto &SU : DAG->SUnits) {
209 if (!SU.isInstr())
210 continue;
211 SmallVector<SDep, 4> Erase;
212 for (auto &D : SU.Preds)
213 if (D.getKind() == SDep::Output && D.getReg() == Hexagon::USR_OVF)
214 Erase.push_back(D);
215 for (auto &E : Erase)
216 SU.removePred(E);
217 }
218
219 for (auto &SU : DAG->SUnits) {
220 // Update the latency of chain edges between v60 vector load or store
Krzysztof Parzyszek2af50372017-05-03 20:10:36 +0000221 // instructions to be 1. These instruction cannot be scheduled in the
Krzysztof Parzyszek9be66732016-07-15 17:48:09 +0000222 // same packet.
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000223 MachineInstr &MI1 = *SU.getInstr();
Krzysztof Parzyszek9be66732016-07-15 17:48:09 +0000224 auto *QII = static_cast<const HexagonInstrInfo*>(DAG->TII);
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000225 bool IsStoreMI1 = MI1.mayStore();
226 bool IsLoadMI1 = MI1.mayLoad();
Krzysztof Parzyszek2af50372017-05-03 20:10:36 +0000227 if (!QII->isHVXVec(MI1) || !(IsStoreMI1 || IsLoadMI1))
Krzysztof Parzyszek9be66732016-07-15 17:48:09 +0000228 continue;
229 for (auto &SI : SU.Succs) {
230 if (SI.getKind() != SDep::Order || SI.getLatency() != 0)
231 continue;
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000232 MachineInstr &MI2 = *SI.getSUnit()->getInstr();
Krzysztof Parzyszek2af50372017-05-03 20:10:36 +0000233 if (!QII->isHVXVec(MI2))
Krzysztof Parzyszek9be66732016-07-15 17:48:09 +0000234 continue;
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000235 if ((IsStoreMI1 && MI2.mayStore()) || (IsLoadMI1 && MI2.mayLoad())) {
Krzysztof Parzyszek9be66732016-07-15 17:48:09 +0000236 SI.setLatency(1);
237 SU.setHeightDirty();
238 // Change the dependence in the opposite direction too.
239 for (auto &PI : SI.getSUnit()->Preds) {
240 if (PI.getSUnit() != &SU || PI.getKind() != SDep::Order)
241 continue;
242 PI.setLatency(1);
243 SI.getSUnit()->setDepthDirty();
244 }
245 }
246 }
247 }
248}
249
Krzysztof Parzyszek9be66732016-07-15 17:48:09 +0000250void HexagonSubtarget::getPostRAMutations(
Eugene Zelenko8361b0a2017-06-19 22:43:19 +0000251 std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations) const {
252 Mutations.push_back(
253 llvm::make_unique<HexagonSubtarget::HexagonDAGMutation>());
Krzysztof Parzyszek9be66732016-07-15 17:48:09 +0000254}
255
Krzysztof Parzyszek3885d872016-12-22 19:44:55 +0000256void HexagonSubtarget::getSMSMutations(
Eugene Zelenko8361b0a2017-06-19 22:43:19 +0000257 std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations) const {
258 Mutations.push_back(
259 llvm::make_unique<HexagonSubtarget::HexagonDAGMutation>());
Krzysztof Parzyszek3885d872016-12-22 19:44:55 +0000260}
261
Juergen Ributzkad12ccbd2013-11-19 00:57:56 +0000262// Pin the vtable to this file.
263void HexagonSubtarget::anchor() {}
Eric Christopher5f141b02015-03-11 22:56:10 +0000264
265bool HexagonSubtarget::enableMachineScheduler() const {
266 if (DisableHexagonMISched.getNumOccurrences())
267 return !DisableHexagonMISched;
268 return true;
269}
Krzysztof Parzyszek07d75182016-05-28 02:02:51 +0000270
Krzysztof Parzyszekee93e002017-05-05 22:13:57 +0000271bool HexagonSubtarget::usePredicatedCalls() const {
272 return EnablePredicatedCalls;
273}
274
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000275void HexagonSubtarget::updateLatency(MachineInstr &SrcInst,
276 MachineInstr &DstInst, SDep &Dep) const {
Krzysztof Parzyszek2af50372017-05-03 20:10:36 +0000277 if (Dep.isArtificial()) {
278 Dep.setLatency(1);
279 return;
280 }
281
Krzysztof Parzyszek408e3002016-07-15 21:34:02 +0000282 if (!hasV60TOps())
283 return;
284
285 auto &QII = static_cast<const HexagonInstrInfo&>(*getInstrInfo());
286
Krzysztof Parzyszek2af50372017-05-03 20:10:36 +0000287 // BSB scheduling.
288 if (QII.isHVXVec(SrcInst) || useBSBScheduling())
289 Dep.setLatency((Dep.getLatency() + 1) >> 1);
290}
291
292void HexagonSubtarget::restoreLatency(SUnit *Src, SUnit *Dst) const {
293 MachineInstr *SrcI = Src->getInstr();
294 for (auto &I : Src->Succs) {
295 if (!I.isAssignedRegDep() || I.getSUnit() != Dst)
296 continue;
297 unsigned DepR = I.getReg();
298 int DefIdx = -1;
299 for (unsigned OpNum = 0; OpNum < SrcI->getNumOperands(); OpNum++) {
300 const MachineOperand &MO = SrcI->getOperand(OpNum);
301 if (MO.isReg() && MO.isDef() && MO.getReg() == DepR)
302 DefIdx = OpNum;
303 }
304 assert(DefIdx >= 0 && "Def Reg not found in Src MI");
305 MachineInstr *DstI = Dst->getInstr();
306 for (unsigned OpNum = 0; OpNum < DstI->getNumOperands(); OpNum++) {
307 const MachineOperand &MO = DstI->getOperand(OpNum);
308 if (MO.isReg() && MO.isUse() && MO.getReg() == DepR) {
309 int Latency = (InstrInfo.getOperandLatency(&InstrItins, *SrcI,
310 DefIdx, *DstI, OpNum));
311
312 // For some instructions (ex: COPY), we might end up with < 0 latency
313 // as they don't have any Itinerary class associated with them.
314 if (Latency <= 0)
315 Latency = 1;
316
317 I.setLatency(Latency);
318 updateLatency(*SrcI, *DstI, I);
319 }
320 }
321
322 // Update the latency of opposite edge too.
323 for (auto &J : Dst->Preds) {
324 if (J.getSUnit() != Src)
325 continue;
326 J.setLatency(I.getLatency());
327 }
328 }
329}
330
331/// Change the latency between the two SUnits.
332void HexagonSubtarget::changeLatency(SUnit *Src, SUnit *Dst, unsigned Lat)
333 const {
334 for (auto &I : Src->Succs) {
335 if (I.getSUnit() != Dst)
336 continue;
337 SDep T = I;
338 I.setLatency(Lat);
339
340 // Update the latency of opposite edge too.
341 T.setSUnit(Src);
342 auto F = std::find(Dst->Preds.begin(), Dst->Preds.end(), T);
343 assert(F != Dst->Preds.end());
344 F->setLatency(I.getLatency());
Krzysztof Parzyszek408e3002016-07-15 21:34:02 +0000345 }
346}
347
Krzysztof Parzyszek748d3ef2016-07-18 14:23:10 +0000348/// If the SUnit has a zero latency edge, return the other SUnit.
349static SUnit *getZeroLatency(SUnit *N, SmallVector<SDep, 4> &Deps) {
350 for (auto &I : Deps)
351 if (I.isAssignedRegDep() && I.getLatency() == 0 &&
352 !I.getSUnit()->getInstr()->isPseudo())
353 return I.getSUnit();
354 return nullptr;
355}
356
Krzysztof Parzyszek408e3002016-07-15 21:34:02 +0000357// Return true if these are the best two instructions to schedule
358// together with a zero latency. Only one dependence should have a zero
359// latency. If there are multiple choices, choose the best, and change
Krzysztof Parzyszek2af50372017-05-03 20:10:36 +0000360// the others, if needed.
Krzysztof Parzyszek408e3002016-07-15 21:34:02 +0000361bool HexagonSubtarget::isBestZeroLatency(SUnit *Src, SUnit *Dst,
Krzysztof Parzyszek2af50372017-05-03 20:10:36 +0000362 const HexagonInstrInfo *TII, SmallSet<SUnit*, 4> &ExclSrc,
363 SmallSet<SUnit*, 4> &ExclDst) const {
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000364 MachineInstr &SrcInst = *Src->getInstr();
365 MachineInstr &DstInst = *Dst->getInstr();
Krzysztof Parzyszek408e3002016-07-15 21:34:02 +0000366
Ron Liebermanda5df7c2016-09-17 16:21:09 +0000367 // Ignore Boundary SU nodes as these have null instructions.
368 if (Dst->isBoundaryNode())
369 return false;
370
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000371 if (SrcInst.isPHI() || DstInst.isPHI())
Krzysztof Parzyszek408e3002016-07-15 21:34:02 +0000372 return false;
373
Krzysztof Parzyszek2af50372017-05-03 20:10:36 +0000374 if (!TII->isToBeScheduledASAP(SrcInst, DstInst) &&
375 !TII->canExecuteInBundle(SrcInst, DstInst))
376 return false;
377
378 // The architecture doesn't allow three dependent instructions in the same
379 // packet. So, if the destination has a zero latency successor, then it's
380 // not a candidate for a zero latency predecessor.
381 if (getZeroLatency(Dst, Dst->Succs) != nullptr)
382 return false;
383
Krzysztof Parzyszek748d3ef2016-07-18 14:23:10 +0000384 // Check if the Dst instruction is the best candidate first.
385 SUnit *Best = nullptr;
386 SUnit *DstBest = nullptr;
387 SUnit *SrcBest = getZeroLatency(Dst, Dst->Preds);
388 if (SrcBest == nullptr || Src->NodeNum >= SrcBest->NodeNum) {
389 // Check that Src doesn't have a better candidate.
390 DstBest = getZeroLatency(Src, Src->Succs);
391 if (DstBest == nullptr || Dst->NodeNum <= DstBest->NodeNum)
392 Best = Dst;
Krzysztof Parzyszek408e3002016-07-15 21:34:02 +0000393 }
Krzysztof Parzyszek748d3ef2016-07-18 14:23:10 +0000394 if (Best != Dst)
395 return false;
Krzysztof Parzyszek408e3002016-07-15 21:34:02 +0000396
Krzysztof Parzyszek2af50372017-05-03 20:10:36 +0000397 // The caller frequently adds the same dependence twice. If so, then
Krzysztof Parzyszek748d3ef2016-07-18 14:23:10 +0000398 // return true for this case too.
Krzysztof Parzyszek2af50372017-05-03 20:10:36 +0000399 if ((Src == SrcBest && Dst == DstBest ) ||
400 (SrcBest == nullptr && Dst == DstBest) ||
401 (Src == SrcBest && Dst == nullptr))
Krzysztof Parzyszek748d3ef2016-07-18 14:23:10 +0000402 return true;
403
404 // Reassign the latency for the previous bests, which requires setting
Krzysztof Parzyszek408e3002016-07-15 21:34:02 +0000405 // the dependence edge in both directions.
Krzysztof Parzyszek2af50372017-05-03 20:10:36 +0000406 if (SrcBest != nullptr) {
407 if (!hasV60TOps())
408 changeLatency(SrcBest, Dst, 1);
409 else
410 restoreLatency(SrcBest, Dst);
411 }
412 if (DstBest != nullptr) {
413 if (!hasV60TOps())
414 changeLatency(Src, DstBest, 1);
415 else
416 restoreLatency(Src, DstBest);
417 }
418
419 // Attempt to find another opprotunity for zero latency in a different
420 // dependence.
Krzysztof Parzyszek748d3ef2016-07-18 14:23:10 +0000421 if (SrcBest && DstBest)
Krzysztof Parzyszek2af50372017-05-03 20:10:36 +0000422 // If there is an edge from SrcBest to DstBst, then try to change that
423 // to 0 now.
424 changeLatency(SrcBest, DstBest, 0);
425 else if (DstBest) {
426 // Check if the previous best destination instruction has a new zero
427 // latency dependence opportunity.
428 ExclSrc.insert(Src);
429 for (auto &I : DstBest->Preds)
430 if (ExclSrc.count(I.getSUnit()) == 0 &&
431 isBestZeroLatency(I.getSUnit(), DstBest, TII, ExclSrc, ExclDst))
432 changeLatency(I.getSUnit(), DstBest, 0);
433 } else if (SrcBest) {
434 // Check if previous best source instruction has a new zero latency
435 // dependence opportunity.
436 ExclDst.insert(Dst);
437 for (auto &I : SrcBest->Succs)
438 if (ExclDst.count(I.getSUnit()) == 0 &&
439 isBestZeroLatency(SrcBest, I.getSUnit(), TII, ExclSrc, ExclDst))
440 changeLatency(SrcBest, I.getSUnit(), 0);
441 }
Krzysztof Parzyszek408e3002016-07-15 21:34:02 +0000442
Krzysztof Parzyszek748d3ef2016-07-18 14:23:10 +0000443 return true;
Krzysztof Parzyszek408e3002016-07-15 21:34:02 +0000444}
445
Krzysztof Parzyszekd3d0a4b2016-07-22 14:22:43 +0000446unsigned HexagonSubtarget::getL1CacheLineSize() const {
447 return 32;
448}
449
450unsigned HexagonSubtarget::getL1PrefetchDistance() const {
451 return 32;
452}
453
Krzysztof Parzyszek2af50372017-05-03 20:10:36 +0000454bool HexagonSubtarget::enableSubRegLiveness() const {
455 return EnableSubregLiveness;
456}