blob: 8851a23ae8acee154fe70ecd3a9a9bd014d4af04 [file] [log] [blame]
Jia Liub22310f2012-02-18 12:03:15 +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
14#include "HexagonSubtarget.h"
15#include "Hexagon.h"
Sirish Pande69295b82012-05-10 20:20:25 +000016#include "HexagonRegisterInfo.h"
Krzysztof Parzyszek9be66732016-07-15 17:48:09 +000017#include "llvm/CodeGen/ScheduleDAG.h"
18#include "llvm/CodeGen/ScheduleDAGInstrs.h"
Tony Linthicum1213a7a2011-12-12 21:14:40 +000019#include "llvm/Support/CommandLine.h"
20#include "llvm/Support/ErrorHandling.h"
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +000021#include <map>
22
Tony Linthicum1213a7a2011-12-12 21:14:40 +000023using namespace llvm;
24
Chandler Carruthe96dd892014-04-21 22:55:11 +000025#define DEBUG_TYPE "hexagon-subtarget"
26
Tony Linthicum1213a7a2011-12-12 21:14:40 +000027#define GET_SUBTARGETINFO_CTOR
28#define GET_SUBTARGETINFO_TARGET_DESC
29#include "HexagonGenSubtargetInfo.inc"
30
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +000031static cl::opt<bool> EnableMemOps("enable-hexagon-memops",
32 cl::Hidden, cl::ZeroOrMore, cl::ValueDisallowed, cl::init(true),
33 cl::desc("Generate V4 MEMOP in code generation for Hexagon target"));
Jyotsna Vermafdc660b2013-03-22 18:41:34 +000034
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +000035static cl::opt<bool> DisableMemOps("disable-hexagon-memops",
36 cl::Hidden, cl::ZeroOrMore, cl::ValueDisallowed, cl::init(false),
37 cl::desc("Do not generate V4 MEMOP in code generation for Hexagon target"));
Sirish Pande69295b82012-05-10 20:20:25 +000038
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +000039static cl::opt<bool> EnableIEEERndNear("enable-hexagon-ieee-rnd-near",
40 cl::Hidden, cl::ZeroOrMore, cl::init(false),
41 cl::desc("Generate non-chopped conversion from fp to int."));
Tony Linthicum1213a7a2011-12-12 21:14:40 +000042
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +000043static cl::opt<bool> EnableBSBSched("enable-bsb-sched",
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +000044 cl::Hidden, cl::ZeroOrMore, cl::init(true));
45
46static cl::opt<bool> EnableHexagonHVXDouble("enable-hexagon-hvx-double",
47 cl::Hidden, cl::ZeroOrMore, cl::init(false),
48 cl::desc("Enable Hexagon Double Vector eXtensions"));
49
50static cl::opt<bool> EnableHexagonHVX("enable-hexagon-hvx",
51 cl::Hidden, cl::ZeroOrMore, cl::init(false),
52 cl::desc("Enable Hexagon Vector eXtensions"));
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +000053
Krzysztof Parzyszek408e3002016-07-15 21:34:02 +000054static cl::opt<bool> EnableTCLatencySched("enable-tc-latency-sched",
55 cl::Hidden, cl::ZeroOrMore, cl::init(false));
56
57static cl::opt<bool> EnableDotCurSched("enable-cur-sched",
58 cl::Hidden, cl::ZeroOrMore, cl::init(true),
59 cl::desc("Enable the scheduler to generate .cur"));
60
61static cl::opt<bool> EnableVecFrwdSched("enable-evec-frwd-sched",
62 cl::Hidden, cl::ZeroOrMore, cl::init(true));
63
Eric Christopher5f141b02015-03-11 22:56:10 +000064static cl::opt<bool> DisableHexagonMISched("disable-hexagon-misched",
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +000065 cl::Hidden, cl::ZeroOrMore, cl::init(false),
66 cl::desc("Disable Hexagon MI Scheduling"));
67
Krzysztof Parzyszek07d75182016-05-28 02:02:51 +000068static cl::opt<bool> EnableSubregLiveness("hexagon-subreg-liveness",
Krzysztof Parzyszekb5ec4872016-08-24 17:17:39 +000069 cl::Hidden, cl::ZeroOrMore, cl::init(true),
Krzysztof Parzyszek07d75182016-05-28 02:02:51 +000070 cl::desc("Enable subregister liveness tracking for Hexagon"));
71
Krzysztof Parzyszek080bebd2016-07-25 14:42:11 +000072static cl::opt<bool> OverrideLongCalls("hexagon-long-calls",
73 cl::Hidden, cl::ZeroOrMore, cl::init(false),
74 cl::desc("If present, forces/disables the use of long calls"));
75
Krzysztof Parzyszekee93e002017-05-05 22:13:57 +000076static cl::opt<bool> EnablePredicatedCalls("hexagon-pred-calls",
77 cl::Hidden, cl::ZeroOrMore, cl::init(false),
78 cl::desc("Consider calls to be predicable"));
79
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +000080void HexagonSubtarget::initializeEnvironment() {
81 UseMemOps = false;
82 ModeIEEERndNear = false;
83 UseBSBScheduling = false;
84}
Eric Christopher5f141b02015-03-11 22:56:10 +000085
Eric Christopherc4c63ae2014-06-27 00:27:40 +000086HexagonSubtarget &
87HexagonSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) {
Krzysztof Parzyszek75e74ee2016-08-19 14:09:47 +000088 CPUString = Hexagon_MC::selectHexagonCPU(getTargetTriple(), CPU);
Sebastian Pop1a0bef62012-08-20 19:56:47 +000089
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +000090 static std::map<StringRef, HexagonArchEnum> CpuTable {
91 { "hexagonv4", V4 },
92 { "hexagonv5", V5 },
93 { "hexagonv55", V55 },
94 { "hexagonv60", V60 },
Krzysztof Parzyszekf9015e62017-02-10 23:46:45 +000095 { "hexagonv62", V62 },
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +000096 };
97
98 auto foundIt = CpuTable.find(CPUString);
99 if (foundIt != CpuTable.end())
100 HexagonArchVersion = foundIt->second;
101 else
Sebastian Pop1a0bef62012-08-20 19:56:47 +0000102 llvm_unreachable("Unrecognized Hexagon processor version");
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000103
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +0000104 UseHVXOps = false;
105 UseHVXDblOps = false;
Krzysztof Parzyszek080bebd2016-07-25 14:42:11 +0000106 UseLongCalls = false;
Sebastian Pop1a0bef62012-08-20 19:56:47 +0000107 ParseSubtargetFeatures(CPUString, FS);
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +0000108
109 if (EnableHexagonHVX.getPosition())
110 UseHVXOps = EnableHexagonHVX;
111 if (EnableHexagonHVXDouble.getPosition())
112 UseHVXDblOps = EnableHexagonHVXDouble;
Krzysztof Parzyszek080bebd2016-07-25 14:42:11 +0000113 if (OverrideLongCalls.getPosition())
114 UseLongCalls = OverrideLongCalls;
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +0000115
Eric Christopherc4c63ae2014-06-27 00:27:40 +0000116 return *this;
117}
118
Daniel Sandersa73f1fd2015-06-10 12:11:26 +0000119HexagonSubtarget::HexagonSubtarget(const Triple &TT, StringRef CPU,
120 StringRef FS, const TargetMachine &TM)
Daniel Sanders50f17232015-09-15 16:17:27 +0000121 : HexagonGenSubtargetInfo(TT, CPU, FS), CPUString(CPU),
Eric Christopherd737b762015-02-02 22:11:36 +0000122 InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
Mehdi Amini157e5a62015-07-09 02:10:08 +0000123 FrameLowering() {
Sebastian Pop1a0bef62012-08-20 19:56:47 +0000124
Krzysztof Parzyszek207c13f2015-11-25 20:30:59 +0000125 initializeEnvironment();
126
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000127 // Initialize scheduling itinerary for the specified CPU.
128 InstrItins = getInstrItineraryForCPU(CPUString);
129
Jyotsna Vermafdc660b2013-03-22 18:41:34 +0000130 // UseMemOps on by default unless disabled explicitly
131 if (DisableMemOps)
132 UseMemOps = false;
133 else if (EnableMemOps)
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000134 UseMemOps = true;
135 else
136 UseMemOps = false;
Sirish Pande69295b82012-05-10 20:20:25 +0000137
138 if (EnableIEEERndNear)
139 ModeIEEERndNear = true;
140 else
141 ModeIEEERndNear = false;
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000142
143 UseBSBScheduling = hasV60TOps() && EnableBSBSched;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000144}
Sirish Pande69295b82012-05-10 20:20:25 +0000145
Krzysztof Parzyszek2af50372017-05-03 20:10:36 +0000146/// \brief Perform target specific adjustments to the latency of a schedule
147/// dependency.
148void HexagonSubtarget::adjustSchedDependency(SUnit *Src, SUnit *Dst,
149 SDep &Dep) const {
150 MachineInstr *SrcInst = Src->getInstr();
151 MachineInstr *DstInst = Dst->getInstr();
152 if (!Src->isInstr() || !Dst->isInstr())
153 return;
154
155 const HexagonInstrInfo *QII = getInstrInfo();
156
157 // Instructions with .new operands have zero latency.
158 SmallSet<SUnit *, 4> ExclSrc;
159 SmallSet<SUnit *, 4> ExclDst;
160 if (QII->canExecuteInBundle(*SrcInst, *DstInst) &&
161 isBestZeroLatency(Src, Dst, QII, ExclSrc, ExclDst)) {
162 Dep.setLatency(0);
163 return;
164 }
165
166 if (!hasV60TOps())
167 return;
168
169 // If it's a REG_SEQUENCE, use its destination instruction to determine
170 // the correct latency.
171 if (DstInst->isRegSequence() && Dst->NumSuccs == 1) {
172 unsigned RSeqReg = DstInst->getOperand(0).getReg();
173 MachineInstr *RSeqDst = Dst->Succs[0].getSUnit()->getInstr();
174 unsigned UseIdx = -1;
175 for (unsigned OpNum = 0; OpNum < RSeqDst->getNumOperands(); OpNum++) {
176 const MachineOperand &MO = RSeqDst->getOperand(OpNum);
177 if (MO.isReg() && MO.getReg() && MO.isUse() && MO.getReg() == RSeqReg) {
178 UseIdx = OpNum;
179 break;
180 }
181 }
182 unsigned RSeqLatency = (InstrInfo.getOperandLatency(&InstrItins, *SrcInst,
183 0, *RSeqDst, UseIdx));
184 Dep.setLatency(RSeqLatency);
185 }
186
187 // Try to schedule uses near definitions to generate .cur.
188 ExclSrc.clear();
189 ExclDst.clear();
190 if (EnableDotCurSched && QII->isToBeScheduledASAP(*SrcInst, *DstInst) &&
191 isBestZeroLatency(Src, Dst, QII, ExclSrc, ExclDst)) {
192 Dep.setLatency(0);
193 return;
194 }
195
196 updateLatency(*SrcInst, *DstInst, Dep);
197}
198
Krzysztof Parzyszek9be66732016-07-15 17:48:09 +0000199
200void HexagonSubtarget::HexagonDAGMutation::apply(ScheduleDAGInstrs *DAG) {
201 for (auto &SU : DAG->SUnits) {
202 if (!SU.isInstr())
203 continue;
204 SmallVector<SDep, 4> Erase;
205 for (auto &D : SU.Preds)
206 if (D.getKind() == SDep::Output && D.getReg() == Hexagon::USR_OVF)
207 Erase.push_back(D);
208 for (auto &E : Erase)
209 SU.removePred(E);
210 }
211
212 for (auto &SU : DAG->SUnits) {
213 // Update the latency of chain edges between v60 vector load or store
Krzysztof Parzyszek2af50372017-05-03 20:10:36 +0000214 // instructions to be 1. These instruction cannot be scheduled in the
Krzysztof Parzyszek9be66732016-07-15 17:48:09 +0000215 // same packet.
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000216 MachineInstr &MI1 = *SU.getInstr();
Krzysztof Parzyszek9be66732016-07-15 17:48:09 +0000217 auto *QII = static_cast<const HexagonInstrInfo*>(DAG->TII);
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000218 bool IsStoreMI1 = MI1.mayStore();
219 bool IsLoadMI1 = MI1.mayLoad();
Krzysztof Parzyszek2af50372017-05-03 20:10:36 +0000220 if (!QII->isHVXVec(MI1) || !(IsStoreMI1 || IsLoadMI1))
Krzysztof Parzyszek9be66732016-07-15 17:48:09 +0000221 continue;
222 for (auto &SI : SU.Succs) {
223 if (SI.getKind() != SDep::Order || SI.getLatency() != 0)
224 continue;
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000225 MachineInstr &MI2 = *SI.getSUnit()->getInstr();
Krzysztof Parzyszek2af50372017-05-03 20:10:36 +0000226 if (!QII->isHVXVec(MI2))
Krzysztof Parzyszek9be66732016-07-15 17:48:09 +0000227 continue;
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000228 if ((IsStoreMI1 && MI2.mayStore()) || (IsLoadMI1 && MI2.mayLoad())) {
Krzysztof Parzyszek9be66732016-07-15 17:48:09 +0000229 SI.setLatency(1);
230 SU.setHeightDirty();
231 // Change the dependence in the opposite direction too.
232 for (auto &PI : SI.getSUnit()->Preds) {
233 if (PI.getSUnit() != &SU || PI.getKind() != SDep::Order)
234 continue;
235 PI.setLatency(1);
236 SI.getSUnit()->setDepthDirty();
237 }
238 }
239 }
240 }
241}
242
243
244void HexagonSubtarget::getPostRAMutations(
245 std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations) const {
246 Mutations.push_back(make_unique<HexagonSubtarget::HexagonDAGMutation>());
247}
248
Krzysztof Parzyszek3885d872016-12-22 19:44:55 +0000249void HexagonSubtarget::getSMSMutations(
250 std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations) const {
251 Mutations.push_back(make_unique<HexagonSubtarget::HexagonDAGMutation>());
252}
253
Krzysztof Parzyszek9be66732016-07-15 17:48:09 +0000254
Juergen Ributzkad12ccbd2013-11-19 00:57:56 +0000255// Pin the vtable to this file.
256void HexagonSubtarget::anchor() {}
Eric Christopher5f141b02015-03-11 22:56:10 +0000257
258bool HexagonSubtarget::enableMachineScheduler() const {
259 if (DisableHexagonMISched.getNumOccurrences())
260 return !DisableHexagonMISched;
261 return true;
262}
Krzysztof Parzyszek07d75182016-05-28 02:02:51 +0000263
Krzysztof Parzyszekee93e002017-05-05 22:13:57 +0000264bool HexagonSubtarget::usePredicatedCalls() const {
265 return EnablePredicatedCalls;
266}
267
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000268void HexagonSubtarget::updateLatency(MachineInstr &SrcInst,
269 MachineInstr &DstInst, SDep &Dep) const {
Krzysztof Parzyszek2af50372017-05-03 20:10:36 +0000270 if (Dep.isArtificial()) {
271 Dep.setLatency(1);
272 return;
273 }
274
Krzysztof Parzyszek408e3002016-07-15 21:34:02 +0000275 if (!hasV60TOps())
276 return;
277
278 auto &QII = static_cast<const HexagonInstrInfo&>(*getInstrInfo());
279
Krzysztof Parzyszek2af50372017-05-03 20:10:36 +0000280 // BSB scheduling.
281 if (QII.isHVXVec(SrcInst) || useBSBScheduling())
282 Dep.setLatency((Dep.getLatency() + 1) >> 1);
283}
284
285void HexagonSubtarget::restoreLatency(SUnit *Src, SUnit *Dst) const {
286 MachineInstr *SrcI = Src->getInstr();
287 for (auto &I : Src->Succs) {
288 if (!I.isAssignedRegDep() || I.getSUnit() != Dst)
289 continue;
290 unsigned DepR = I.getReg();
291 int DefIdx = -1;
292 for (unsigned OpNum = 0; OpNum < SrcI->getNumOperands(); OpNum++) {
293 const MachineOperand &MO = SrcI->getOperand(OpNum);
294 if (MO.isReg() && MO.isDef() && MO.getReg() == DepR)
295 DefIdx = OpNum;
296 }
297 assert(DefIdx >= 0 && "Def Reg not found in Src MI");
298 MachineInstr *DstI = Dst->getInstr();
299 for (unsigned OpNum = 0; OpNum < DstI->getNumOperands(); OpNum++) {
300 const MachineOperand &MO = DstI->getOperand(OpNum);
301 if (MO.isReg() && MO.isUse() && MO.getReg() == DepR) {
302 int Latency = (InstrInfo.getOperandLatency(&InstrItins, *SrcI,
303 DefIdx, *DstI, OpNum));
304
305 // For some instructions (ex: COPY), we might end up with < 0 latency
306 // as they don't have any Itinerary class associated with them.
307 if (Latency <= 0)
308 Latency = 1;
309
310 I.setLatency(Latency);
311 updateLatency(*SrcI, *DstI, I);
312 }
313 }
314
315 // Update the latency of opposite edge too.
316 for (auto &J : Dst->Preds) {
317 if (J.getSUnit() != Src)
318 continue;
319 J.setLatency(I.getLatency());
320 }
321 }
322}
323
324/// Change the latency between the two SUnits.
325void HexagonSubtarget::changeLatency(SUnit *Src, SUnit *Dst, unsigned Lat)
326 const {
327 for (auto &I : Src->Succs) {
328 if (I.getSUnit() != Dst)
329 continue;
330 SDep T = I;
331 I.setLatency(Lat);
332
333 // Update the latency of opposite edge too.
334 T.setSUnit(Src);
335 auto F = std::find(Dst->Preds.begin(), Dst->Preds.end(), T);
336 assert(F != Dst->Preds.end());
337 F->setLatency(I.getLatency());
Krzysztof Parzyszek408e3002016-07-15 21:34:02 +0000338 }
339}
340
Krzysztof Parzyszek748d3ef2016-07-18 14:23:10 +0000341/// If the SUnit has a zero latency edge, return the other SUnit.
342static SUnit *getZeroLatency(SUnit *N, SmallVector<SDep, 4> &Deps) {
343 for (auto &I : Deps)
344 if (I.isAssignedRegDep() && I.getLatency() == 0 &&
345 !I.getSUnit()->getInstr()->isPseudo())
346 return I.getSUnit();
347 return nullptr;
348}
349
Krzysztof Parzyszek408e3002016-07-15 21:34:02 +0000350// Return true if these are the best two instructions to schedule
351// together with a zero latency. Only one dependence should have a zero
352// latency. If there are multiple choices, choose the best, and change
Krzysztof Parzyszek2af50372017-05-03 20:10:36 +0000353// the others, if needed.
Krzysztof Parzyszek408e3002016-07-15 21:34:02 +0000354bool HexagonSubtarget::isBestZeroLatency(SUnit *Src, SUnit *Dst,
Krzysztof Parzyszek2af50372017-05-03 20:10:36 +0000355 const HexagonInstrInfo *TII, SmallSet<SUnit*, 4> &ExclSrc,
356 SmallSet<SUnit*, 4> &ExclDst) const {
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000357 MachineInstr &SrcInst = *Src->getInstr();
358 MachineInstr &DstInst = *Dst->getInstr();
Krzysztof Parzyszek408e3002016-07-15 21:34:02 +0000359
Ron Liebermanda5df7c2016-09-17 16:21:09 +0000360 // Ignore Boundary SU nodes as these have null instructions.
361 if (Dst->isBoundaryNode())
362 return false;
363
Krzysztof Parzyszekf0b34a52016-07-29 21:49:42 +0000364 if (SrcInst.isPHI() || DstInst.isPHI())
Krzysztof Parzyszek408e3002016-07-15 21:34:02 +0000365 return false;
366
Krzysztof Parzyszek2af50372017-05-03 20:10:36 +0000367 if (!TII->isToBeScheduledASAP(SrcInst, DstInst) &&
368 !TII->canExecuteInBundle(SrcInst, DstInst))
369 return false;
370
371 // The architecture doesn't allow three dependent instructions in the same
372 // packet. So, if the destination has a zero latency successor, then it's
373 // not a candidate for a zero latency predecessor.
374 if (getZeroLatency(Dst, Dst->Succs) != nullptr)
375 return false;
376
Krzysztof Parzyszek748d3ef2016-07-18 14:23:10 +0000377 // Check if the Dst instruction is the best candidate first.
378 SUnit *Best = nullptr;
379 SUnit *DstBest = nullptr;
380 SUnit *SrcBest = getZeroLatency(Dst, Dst->Preds);
381 if (SrcBest == nullptr || Src->NodeNum >= SrcBest->NodeNum) {
382 // Check that Src doesn't have a better candidate.
383 DstBest = getZeroLatency(Src, Src->Succs);
384 if (DstBest == nullptr || Dst->NodeNum <= DstBest->NodeNum)
385 Best = Dst;
Krzysztof Parzyszek408e3002016-07-15 21:34:02 +0000386 }
Krzysztof Parzyszek748d3ef2016-07-18 14:23:10 +0000387 if (Best != Dst)
388 return false;
Krzysztof Parzyszek408e3002016-07-15 21:34:02 +0000389
Krzysztof Parzyszek2af50372017-05-03 20:10:36 +0000390 // The caller frequently adds the same dependence twice. If so, then
Krzysztof Parzyszek748d3ef2016-07-18 14:23:10 +0000391 // return true for this case too.
Krzysztof Parzyszek2af50372017-05-03 20:10:36 +0000392 if ((Src == SrcBest && Dst == DstBest ) ||
393 (SrcBest == nullptr && Dst == DstBest) ||
394 (Src == SrcBest && Dst == nullptr))
Krzysztof Parzyszek748d3ef2016-07-18 14:23:10 +0000395 return true;
396
397 // Reassign the latency for the previous bests, which requires setting
Krzysztof Parzyszek408e3002016-07-15 21:34:02 +0000398 // the dependence edge in both directions.
Krzysztof Parzyszek2af50372017-05-03 20:10:36 +0000399 if (SrcBest != nullptr) {
400 if (!hasV60TOps())
401 changeLatency(SrcBest, Dst, 1);
402 else
403 restoreLatency(SrcBest, Dst);
404 }
405 if (DstBest != nullptr) {
406 if (!hasV60TOps())
407 changeLatency(Src, DstBest, 1);
408 else
409 restoreLatency(Src, DstBest);
410 }
411
412 // Attempt to find another opprotunity for zero latency in a different
413 // dependence.
Krzysztof Parzyszek748d3ef2016-07-18 14:23:10 +0000414 if (SrcBest && DstBest)
Krzysztof Parzyszek2af50372017-05-03 20:10:36 +0000415 // If there is an edge from SrcBest to DstBst, then try to change that
416 // to 0 now.
417 changeLatency(SrcBest, DstBest, 0);
418 else if (DstBest) {
419 // Check if the previous best destination instruction has a new zero
420 // latency dependence opportunity.
421 ExclSrc.insert(Src);
422 for (auto &I : DstBest->Preds)
423 if (ExclSrc.count(I.getSUnit()) == 0 &&
424 isBestZeroLatency(I.getSUnit(), DstBest, TII, ExclSrc, ExclDst))
425 changeLatency(I.getSUnit(), DstBest, 0);
426 } else if (SrcBest) {
427 // Check if previous best source instruction has a new zero latency
428 // dependence opportunity.
429 ExclDst.insert(Dst);
430 for (auto &I : SrcBest->Succs)
431 if (ExclDst.count(I.getSUnit()) == 0 &&
432 isBestZeroLatency(SrcBest, I.getSUnit(), TII, ExclSrc, ExclDst))
433 changeLatency(SrcBest, I.getSUnit(), 0);
434 }
Krzysztof Parzyszek408e3002016-07-15 21:34:02 +0000435
Krzysztof Parzyszek748d3ef2016-07-18 14:23:10 +0000436 return true;
Krzysztof Parzyszek408e3002016-07-15 21:34:02 +0000437}
438
Krzysztof Parzyszekd3d0a4b2016-07-22 14:22:43 +0000439unsigned HexagonSubtarget::getL1CacheLineSize() const {
440 return 32;
441}
442
443unsigned HexagonSubtarget::getL1PrefetchDistance() const {
444 return 32;
445}
446
Krzysztof Parzyszek2af50372017-05-03 20:10:36 +0000447bool HexagonSubtarget::enableSubRegLiveness() const {
448 return EnableSubregLiveness;
449}
450