Jia Liu | b22310f | 2012-02-18 12:03:15 +0000 | [diff] [blame] | 1 | //===-- HexagonSubtarget.cpp - Hexagon Subtarget Information --------------===// |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 2 | // |
| 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 Pande | 69295b8 | 2012-05-10 20:20:25 +0000 | [diff] [blame] | 16 | #include "HexagonRegisterInfo.h" |
Krzysztof Parzyszek | 9be6673 | 2016-07-15 17:48:09 +0000 | [diff] [blame] | 17 | #include "llvm/CodeGen/ScheduleDAG.h" |
| 18 | #include "llvm/CodeGen/ScheduleDAGInstrs.h" |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 19 | #include "llvm/Support/CommandLine.h" |
| 20 | #include "llvm/Support/ErrorHandling.h" |
Krzysztof Parzyszek | 207c13f | 2015-11-25 20:30:59 +0000 | [diff] [blame] | 21 | #include <map> |
| 22 | |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 23 | using namespace llvm; |
| 24 | |
Chandler Carruth | e96dd89 | 2014-04-21 22:55:11 +0000 | [diff] [blame] | 25 | #define DEBUG_TYPE "hexagon-subtarget" |
| 26 | |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 27 | #define GET_SUBTARGETINFO_CTOR |
| 28 | #define GET_SUBTARGETINFO_TARGET_DESC |
| 29 | #include "HexagonGenSubtargetInfo.inc" |
| 30 | |
Krzysztof Parzyszek | 207c13f | 2015-11-25 20:30:59 +0000 | [diff] [blame] | 31 | static 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 Verma | fdc660b | 2013-03-22 18:41:34 +0000 | [diff] [blame] | 34 | |
Krzysztof Parzyszek | 207c13f | 2015-11-25 20:30:59 +0000 | [diff] [blame] | 35 | static 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 Pande | 69295b8 | 2012-05-10 20:20:25 +0000 | [diff] [blame] | 38 | |
Krzysztof Parzyszek | 207c13f | 2015-11-25 20:30:59 +0000 | [diff] [blame] | 39 | static 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 Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 42 | |
Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 43 | static cl::opt<bool> EnableBSBSched("enable-bsb-sched", |
Krzysztof Parzyszek | 207c13f | 2015-11-25 20:30:59 +0000 | [diff] [blame] | 44 | cl::Hidden, cl::ZeroOrMore, cl::init(true)); |
| 45 | |
| 46 | static 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 | |
| 50 | static cl::opt<bool> EnableHexagonHVX("enable-hexagon-hvx", |
| 51 | cl::Hidden, cl::ZeroOrMore, cl::init(false), |
| 52 | cl::desc("Enable Hexagon Vector eXtensions")); |
Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 53 | |
Krzysztof Parzyszek | 408e300 | 2016-07-15 21:34:02 +0000 | [diff] [blame] | 54 | static cl::opt<bool> EnableTCLatencySched("enable-tc-latency-sched", |
| 55 | cl::Hidden, cl::ZeroOrMore, cl::init(false)); |
| 56 | |
| 57 | static 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 | |
| 61 | static cl::opt<bool> EnableVecFrwdSched("enable-evec-frwd-sched", |
| 62 | cl::Hidden, cl::ZeroOrMore, cl::init(true)); |
| 63 | |
Eric Christopher | 5f141b0 | 2015-03-11 22:56:10 +0000 | [diff] [blame] | 64 | static cl::opt<bool> DisableHexagonMISched("disable-hexagon-misched", |
Krzysztof Parzyszek | 207c13f | 2015-11-25 20:30:59 +0000 | [diff] [blame] | 65 | cl::Hidden, cl::ZeroOrMore, cl::init(false), |
| 66 | cl::desc("Disable Hexagon MI Scheduling")); |
| 67 | |
Krzysztof Parzyszek | 07d7518 | 2016-05-28 02:02:51 +0000 | [diff] [blame] | 68 | static cl::opt<bool> EnableSubregLiveness("hexagon-subreg-liveness", |
| 69 | cl::Hidden, cl::ZeroOrMore, cl::init(false), |
| 70 | cl::desc("Enable subregister liveness tracking for Hexagon")); |
| 71 | |
Krzysztof Parzyszek | 080bebd | 2016-07-25 14:42:11 +0000 | [diff] [blame^] | 72 | static 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 Parzyszek | 207c13f | 2015-11-25 20:30:59 +0000 | [diff] [blame] | 76 | void HexagonSubtarget::initializeEnvironment() { |
| 77 | UseMemOps = false; |
| 78 | ModeIEEERndNear = false; |
| 79 | UseBSBScheduling = false; |
| 80 | } |
Eric Christopher | 5f141b0 | 2015-03-11 22:56:10 +0000 | [diff] [blame] | 81 | |
Eric Christopher | c4c63ae | 2014-06-27 00:27:40 +0000 | [diff] [blame] | 82 | HexagonSubtarget & |
| 83 | HexagonSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) { |
Krzysztof Parzyszek | 759a7d0 | 2015-12-14 15:03:54 +0000 | [diff] [blame] | 84 | CPUString = HEXAGON_MC::selectHexagonCPU(getTargetTriple(), CPU); |
Sebastian Pop | 1a0bef6 | 2012-08-20 19:56:47 +0000 | [diff] [blame] | 85 | |
Krzysztof Parzyszek | 207c13f | 2015-11-25 20:30:59 +0000 | [diff] [blame] | 86 | static std::map<StringRef, HexagonArchEnum> CpuTable { |
| 87 | { "hexagonv4", V4 }, |
| 88 | { "hexagonv5", V5 }, |
| 89 | { "hexagonv55", V55 }, |
| 90 | { "hexagonv60", V60 }, |
| 91 | }; |
| 92 | |
| 93 | auto foundIt = CpuTable.find(CPUString); |
| 94 | if (foundIt != CpuTable.end()) |
| 95 | HexagonArchVersion = foundIt->second; |
| 96 | else |
Sebastian Pop | 1a0bef6 | 2012-08-20 19:56:47 +0000 | [diff] [blame] | 97 | llvm_unreachable("Unrecognized Hexagon processor version"); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 98 | |
Krzysztof Parzyszek | 207c13f | 2015-11-25 20:30:59 +0000 | [diff] [blame] | 99 | UseHVXOps = false; |
| 100 | UseHVXDblOps = false; |
Krzysztof Parzyszek | 080bebd | 2016-07-25 14:42:11 +0000 | [diff] [blame^] | 101 | UseLongCalls = false; |
Sebastian Pop | 1a0bef6 | 2012-08-20 19:56:47 +0000 | [diff] [blame] | 102 | ParseSubtargetFeatures(CPUString, FS); |
Krzysztof Parzyszek | 207c13f | 2015-11-25 20:30:59 +0000 | [diff] [blame] | 103 | |
| 104 | if (EnableHexagonHVX.getPosition()) |
| 105 | UseHVXOps = EnableHexagonHVX; |
| 106 | if (EnableHexagonHVXDouble.getPosition()) |
| 107 | UseHVXDblOps = EnableHexagonHVXDouble; |
Krzysztof Parzyszek | 080bebd | 2016-07-25 14:42:11 +0000 | [diff] [blame^] | 108 | if (OverrideLongCalls.getPosition()) |
| 109 | UseLongCalls = OverrideLongCalls; |
Krzysztof Parzyszek | 207c13f | 2015-11-25 20:30:59 +0000 | [diff] [blame] | 110 | |
Eric Christopher | c4c63ae | 2014-06-27 00:27:40 +0000 | [diff] [blame] | 111 | return *this; |
| 112 | } |
| 113 | |
Daniel Sanders | a73f1fd | 2015-06-10 12:11:26 +0000 | [diff] [blame] | 114 | HexagonSubtarget::HexagonSubtarget(const Triple &TT, StringRef CPU, |
| 115 | StringRef FS, const TargetMachine &TM) |
Daniel Sanders | 50f1723 | 2015-09-15 16:17:27 +0000 | [diff] [blame] | 116 | : HexagonGenSubtargetInfo(TT, CPU, FS), CPUString(CPU), |
Eric Christopher | d737b76 | 2015-02-02 22:11:36 +0000 | [diff] [blame] | 117 | InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this), |
Mehdi Amini | 157e5a6 | 2015-07-09 02:10:08 +0000 | [diff] [blame] | 118 | FrameLowering() { |
Sebastian Pop | 1a0bef6 | 2012-08-20 19:56:47 +0000 | [diff] [blame] | 119 | |
Krzysztof Parzyszek | 207c13f | 2015-11-25 20:30:59 +0000 | [diff] [blame] | 120 | initializeEnvironment(); |
| 121 | |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 122 | // Initialize scheduling itinerary for the specified CPU. |
| 123 | InstrItins = getInstrItineraryForCPU(CPUString); |
| 124 | |
Jyotsna Verma | fdc660b | 2013-03-22 18:41:34 +0000 | [diff] [blame] | 125 | // UseMemOps on by default unless disabled explicitly |
| 126 | if (DisableMemOps) |
| 127 | UseMemOps = false; |
| 128 | else if (EnableMemOps) |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 129 | UseMemOps = true; |
| 130 | else |
| 131 | UseMemOps = false; |
Sirish Pande | 69295b8 | 2012-05-10 20:20:25 +0000 | [diff] [blame] | 132 | |
| 133 | if (EnableIEEERndNear) |
| 134 | ModeIEEERndNear = true; |
| 135 | else |
| 136 | ModeIEEERndNear = false; |
Krzysztof Parzyszek | b9a1c3a | 2015-11-24 14:55:26 +0000 | [diff] [blame] | 137 | |
| 138 | UseBSBScheduling = hasV60TOps() && EnableBSBSched; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 139 | } |
Sirish Pande | 69295b8 | 2012-05-10 20:20:25 +0000 | [diff] [blame] | 140 | |
Krzysztof Parzyszek | 9be6673 | 2016-07-15 17:48:09 +0000 | [diff] [blame] | 141 | |
| 142 | void HexagonSubtarget::HexagonDAGMutation::apply(ScheduleDAGInstrs *DAG) { |
| 143 | for (auto &SU : DAG->SUnits) { |
| 144 | if (!SU.isInstr()) |
| 145 | continue; |
| 146 | SmallVector<SDep, 4> Erase; |
| 147 | for (auto &D : SU.Preds) |
| 148 | if (D.getKind() == SDep::Output && D.getReg() == Hexagon::USR_OVF) |
| 149 | Erase.push_back(D); |
| 150 | for (auto &E : Erase) |
| 151 | SU.removePred(E); |
| 152 | } |
| 153 | |
| 154 | for (auto &SU : DAG->SUnits) { |
| 155 | // Update the latency of chain edges between v60 vector load or store |
| 156 | // instructions to be 1. These instructions cannot be scheduled in the |
| 157 | // same packet. |
| 158 | MachineInstr *MI1 = SU.getInstr(); |
| 159 | auto *QII = static_cast<const HexagonInstrInfo*>(DAG->TII); |
| 160 | bool IsStoreMI1 = MI1->mayStore(); |
| 161 | bool IsLoadMI1 = MI1->mayLoad(); |
| 162 | if (!QII->isV60VectorInstruction(MI1) || !(IsStoreMI1 || IsLoadMI1)) |
| 163 | continue; |
| 164 | for (auto &SI : SU.Succs) { |
| 165 | if (SI.getKind() != SDep::Order || SI.getLatency() != 0) |
| 166 | continue; |
| 167 | MachineInstr *MI2 = SI.getSUnit()->getInstr(); |
| 168 | if (!QII->isV60VectorInstruction(MI2)) |
| 169 | continue; |
| 170 | if ((IsStoreMI1 && MI2->mayStore()) || (IsLoadMI1 && MI2->mayLoad())) { |
| 171 | SI.setLatency(1); |
| 172 | SU.setHeightDirty(); |
| 173 | // Change the dependence in the opposite direction too. |
| 174 | for (auto &PI : SI.getSUnit()->Preds) { |
| 175 | if (PI.getSUnit() != &SU || PI.getKind() != SDep::Order) |
| 176 | continue; |
| 177 | PI.setLatency(1); |
| 178 | SI.getSUnit()->setDepthDirty(); |
| 179 | } |
| 180 | } |
| 181 | } |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | |
| 186 | void HexagonSubtarget::getPostRAMutations( |
| 187 | std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations) const { |
| 188 | Mutations.push_back(make_unique<HexagonSubtarget::HexagonDAGMutation>()); |
| 189 | } |
| 190 | |
| 191 | |
Juergen Ributzka | d12ccbd | 2013-11-19 00:57:56 +0000 | [diff] [blame] | 192 | // Pin the vtable to this file. |
| 193 | void HexagonSubtarget::anchor() {} |
Eric Christopher | 5f141b0 | 2015-03-11 22:56:10 +0000 | [diff] [blame] | 194 | |
| 195 | bool HexagonSubtarget::enableMachineScheduler() const { |
| 196 | if (DisableHexagonMISched.getNumOccurrences()) |
| 197 | return !DisableHexagonMISched; |
| 198 | return true; |
| 199 | } |
Krzysztof Parzyszek | 07d7518 | 2016-05-28 02:02:51 +0000 | [diff] [blame] | 200 | |
| 201 | bool HexagonSubtarget::enableSubRegLiveness() const { |
| 202 | return EnableSubregLiveness; |
| 203 | } |
| 204 | |
Krzysztof Parzyszek | 408e300 | 2016-07-15 21:34:02 +0000 | [diff] [blame] | 205 | // This helper function is responsible for increasing the latency only. |
| 206 | void HexagonSubtarget::updateLatency(MachineInstr *SrcInst, |
| 207 | MachineInstr *DstInst, SDep &Dep) const { |
| 208 | if (!hasV60TOps()) |
| 209 | return; |
| 210 | |
| 211 | auto &QII = static_cast<const HexagonInstrInfo&>(*getInstrInfo()); |
| 212 | |
| 213 | if (EnableVecFrwdSched && QII.addLatencyToSchedule(SrcInst, DstInst)) { |
| 214 | // Vec frwd scheduling. |
| 215 | Dep.setLatency(Dep.getLatency() + 1); |
| 216 | } else if (useBSBScheduling() && |
| 217 | QII.isLateInstrFeedsEarlyInstr(SrcInst, DstInst)) { |
| 218 | // BSB scheduling. |
| 219 | Dep.setLatency(Dep.getLatency() + 1); |
| 220 | } else if (EnableTCLatencySched) { |
| 221 | // TClass latency scheduling. |
| 222 | // Check if SrcInst produces in 2C an operand of DstInst taken in stage 2B. |
| 223 | if (QII.isTC1(SrcInst) || QII.isTC2(SrcInst)) |
| 224 | if (!QII.isTC1(DstInst) && !QII.isTC2(DstInst)) |
| 225 | Dep.setLatency(Dep.getLatency() + 1); |
| 226 | } |
| 227 | } |
| 228 | |
Krzysztof Parzyszek | 748d3ef | 2016-07-18 14:23:10 +0000 | [diff] [blame] | 229 | /// If the SUnit has a zero latency edge, return the other SUnit. |
| 230 | static SUnit *getZeroLatency(SUnit *N, SmallVector<SDep, 4> &Deps) { |
| 231 | for (auto &I : Deps) |
| 232 | if (I.isAssignedRegDep() && I.getLatency() == 0 && |
| 233 | !I.getSUnit()->getInstr()->isPseudo()) |
| 234 | return I.getSUnit(); |
| 235 | return nullptr; |
| 236 | } |
| 237 | |
| 238 | /// Change the latency between the two SUnits. |
| 239 | void HexagonSubtarget::changeLatency(SUnit *Src, SmallVector<SDep, 4> &Deps, |
| 240 | SUnit *Dst, unsigned Lat) const { |
| 241 | MachineInstr *SrcI = Src->getInstr(); |
| 242 | for (auto &I : Deps) { |
| 243 | if (I.getSUnit() != Dst) |
| 244 | continue; |
| 245 | I.setLatency(Lat); |
| 246 | SUnit *UpdateDst = I.getSUnit(); |
| 247 | updateLatency(SrcI, UpdateDst->getInstr(), I); |
| 248 | // Update the latency of opposite edge too. |
| 249 | for (auto &PI : UpdateDst->Preds) { |
| 250 | if (PI.getSUnit() != Src || !PI.isAssignedRegDep()) |
| 251 | continue; |
| 252 | PI.setLatency(Lat); |
| 253 | updateLatency(SrcI, UpdateDst->getInstr(), PI); |
| 254 | } |
| 255 | } |
| 256 | } |
| 257 | |
Krzysztof Parzyszek | 408e300 | 2016-07-15 21:34:02 +0000 | [diff] [blame] | 258 | // Return true if these are the best two instructions to schedule |
| 259 | // together with a zero latency. Only one dependence should have a zero |
| 260 | // latency. If there are multiple choices, choose the best, and change |
| 261 | // ther others, if needed. |
| 262 | bool HexagonSubtarget::isBestZeroLatency(SUnit *Src, SUnit *Dst, |
| 263 | const HexagonInstrInfo *TII) const { |
| 264 | MachineInstr *SrcInst = Src->getInstr(); |
| 265 | MachineInstr *DstInst = Dst->getInstr(); |
Krzysztof Parzyszek | 408e300 | 2016-07-15 21:34:02 +0000 | [diff] [blame] | 266 | |
| 267 | if (SrcInst->isPHI() || DstInst->isPHI()) |
| 268 | return false; |
| 269 | |
Krzysztof Parzyszek | 748d3ef | 2016-07-18 14:23:10 +0000 | [diff] [blame] | 270 | // Check if the Dst instruction is the best candidate first. |
| 271 | SUnit *Best = nullptr; |
| 272 | SUnit *DstBest = nullptr; |
| 273 | SUnit *SrcBest = getZeroLatency(Dst, Dst->Preds); |
| 274 | if (SrcBest == nullptr || Src->NodeNum >= SrcBest->NodeNum) { |
| 275 | // Check that Src doesn't have a better candidate. |
| 276 | DstBest = getZeroLatency(Src, Src->Succs); |
| 277 | if (DstBest == nullptr || Dst->NodeNum <= DstBest->NodeNum) |
| 278 | Best = Dst; |
Krzysztof Parzyszek | 408e300 | 2016-07-15 21:34:02 +0000 | [diff] [blame] | 279 | } |
Krzysztof Parzyszek | 748d3ef | 2016-07-18 14:23:10 +0000 | [diff] [blame] | 280 | if (Best != Dst) |
| 281 | return false; |
Krzysztof Parzyszek | 408e300 | 2016-07-15 21:34:02 +0000 | [diff] [blame] | 282 | |
Krzysztof Parzyszek | 748d3ef | 2016-07-18 14:23:10 +0000 | [diff] [blame] | 283 | // The caller frequents adds the same dependence twice. If so, then |
| 284 | // return true for this case too. |
| 285 | if (Src == SrcBest && Dst == DstBest) |
| 286 | return true; |
| 287 | |
| 288 | // Reassign the latency for the previous bests, which requires setting |
Krzysztof Parzyszek | 408e300 | 2016-07-15 21:34:02 +0000 | [diff] [blame] | 289 | // the dependence edge in both directions. |
Krzysztof Parzyszek | 748d3ef | 2016-07-18 14:23:10 +0000 | [diff] [blame] | 290 | if (SrcBest != nullptr) |
| 291 | changeLatency(SrcBest, SrcBest->Succs, Dst, 1); |
| 292 | if (DstBest != nullptr) |
| 293 | changeLatency(Src, Src->Succs, DstBest, 1); |
| 294 | // If there is an edge from SrcBest to DstBst, then try to change that |
| 295 | // to 0 now. |
| 296 | if (SrcBest && DstBest) |
| 297 | changeLatency(SrcBest, SrcBest->Succs, DstBest, 0); |
Krzysztof Parzyszek | 408e300 | 2016-07-15 21:34:02 +0000 | [diff] [blame] | 298 | |
Krzysztof Parzyszek | 748d3ef | 2016-07-18 14:23:10 +0000 | [diff] [blame] | 299 | return true; |
Krzysztof Parzyszek | 408e300 | 2016-07-15 21:34:02 +0000 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | // Update the latency of a Phi when the Phi bridges two instructions that |
| 303 | // require a multi-cycle latency. |
| 304 | void HexagonSubtarget::changePhiLatency(MachineInstr *SrcInst, SUnit *Dst, |
| 305 | SDep &Dep) const { |
| 306 | if (!SrcInst->isPHI() || Dst->NumPreds == 0 || Dep.getLatency() != 0) |
| 307 | return; |
| 308 | |
| 309 | for (const SDep &PI : Dst->Preds) { |
| 310 | if (PI.getLatency() != 0) |
| 311 | continue; |
| 312 | Dep.setLatency(2); |
| 313 | break; |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | /// \brief Perform target specific adjustments to the latency of a schedule |
| 318 | /// dependency. |
| 319 | void HexagonSubtarget::adjustSchedDependency(SUnit *Src, SUnit *Dst, |
| 320 | SDep &Dep) const { |
| 321 | MachineInstr *SrcInst = Src->getInstr(); |
| 322 | MachineInstr *DstInst = Dst->getInstr(); |
| 323 | if (!Src->isInstr() || !Dst->isInstr()) |
| 324 | return; |
| 325 | |
| 326 | const HexagonInstrInfo *QII = static_cast<const HexagonInstrInfo *>(getInstrInfo()); |
| 327 | |
| 328 | // Instructions with .new operands have zero latency. |
| 329 | if (QII->canExecuteInBundle(SrcInst, DstInst) && |
| 330 | isBestZeroLatency(Src, Dst, QII)) { |
| 331 | Dep.setLatency(0); |
| 332 | return; |
| 333 | } |
| 334 | |
| 335 | if (!hasV60TOps()) |
| 336 | return; |
| 337 | |
| 338 | // Don't adjust the latency of post-increment part of the instruction. |
| 339 | if (QII->isPostIncrement(SrcInst) && Dep.isAssignedRegDep()) { |
| 340 | if (SrcInst->mayStore()) |
| 341 | return; |
| 342 | if (Dep.getReg() != SrcInst->getOperand(0).getReg()) |
| 343 | return; |
| 344 | } else if (QII->isPostIncrement(DstInst) && Dep.getKind() == SDep::Anti) { |
| 345 | if (DstInst->mayStore()) |
| 346 | return; |
| 347 | if (Dep.getReg() != DstInst->getOperand(0).getReg()) |
| 348 | return; |
| 349 | } else if (QII->isPostIncrement(DstInst) && DstInst->mayStore() && |
| 350 | Dep.isAssignedRegDep()) { |
| 351 | MachineOperand &Op = DstInst->getOperand(DstInst->getNumOperands() - 1); |
| 352 | if (Op.isReg() && Dep.getReg() != Op.getReg()) |
| 353 | return; |
| 354 | } |
| 355 | |
| 356 | // Check if we need to change any the latency values when Phis are added. |
| 357 | if (useBSBScheduling() && SrcInst->isPHI()) { |
| 358 | changePhiLatency(SrcInst, Dst, Dep); |
| 359 | return; |
| 360 | } |
| 361 | |
Krzysztof Parzyszek | 748d3ef | 2016-07-18 14:23:10 +0000 | [diff] [blame] | 362 | // If it's a REG_SEQUENCE, use its destination instruction to determine |
| 363 | // the correct latency. |
| 364 | if (DstInst->isRegSequence() && Dst->NumSuccs == 1) |
| 365 | DstInst = Dst->Succs[0].getSUnit()->getInstr(); |
| 366 | |
Krzysztof Parzyszek | 408e300 | 2016-07-15 21:34:02 +0000 | [diff] [blame] | 367 | // Try to schedule uses near definitions to generate .cur. |
| 368 | if (EnableDotCurSched && QII->isToBeScheduledASAP(SrcInst, DstInst) && |
| 369 | isBestZeroLatency(Src, Dst, QII)) { |
| 370 | Dep.setLatency(0); |
| 371 | return; |
| 372 | } |
| 373 | |
| 374 | updateLatency(SrcInst, DstInst, Dep); |
| 375 | } |
| 376 | |
Krzysztof Parzyszek | d3d0a4b | 2016-07-22 14:22:43 +0000 | [diff] [blame] | 377 | unsigned HexagonSubtarget::getL1CacheLineSize() const { |
| 378 | return 32; |
| 379 | } |
| 380 | |
| 381 | unsigned HexagonSubtarget::getL1PrefetchDistance() const { |
| 382 | return 32; |
| 383 | } |
| 384 | |