blob: ffaa3e05c847909b90aa14c6f903f74456084e9f [file] [log] [blame]
Chris Lattner2cab1352006-03-07 06:32:48 +00001//===-- PPCHazardRecognizers.cpp - PowerPC Hazard Recognizer Impls --------===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Chris Lattner2cab1352006-03-07 06:32:48 +00006//
7//===----------------------------------------------------------------------===//
8//
9// This file implements hazard recognizers for scheduling on PowerPC processors.
10//
11//===----------------------------------------------------------------------===//
12
Chris Lattner2cab1352006-03-07 06:32:48 +000013#include "PPCHazardRecognizers.h"
Chris Lattner51348c52006-03-12 09:13:49 +000014#include "PPCInstrInfo.h"
Dmitri Gribenko5438cc62019-06-06 16:47:06 +000015#include "PPCSubtarget.h"
Dan Gohman7e105f02009-01-15 22:18:12 +000016#include "llvm/CodeGen/ScheduleDAG.h"
Chris Lattner2cab1352006-03-07 06:32:48 +000017#include "llvm/Support/Debug.h"
Torok Edwin56d06592009-07-11 20:10:48 +000018#include "llvm/Support/ErrorHandling.h"
Chris Lattneraf29ea62009-08-23 06:49:22 +000019#include "llvm/Support/raw_ostream.h"
Chris Lattner2cab1352006-03-07 06:32:48 +000020using namespace llvm;
21
Chandler Carruth84e68b22014-04-22 02:41:26 +000022#define DEBUG_TYPE "pre-RA-sched"
23
Hal Finkelceb1f122013-12-12 00:19:11 +000024bool PPCDispatchGroupSBHazardRecognizer::isLoadAfterStore(SUnit *SU) {
25 // FIXME: Move this.
26 if (isBCTRAfterSet(SU))
27 return true;
28
29 const MCInstrDesc *MCID = DAG->getInstrDesc(SU);
30 if (!MCID)
31 return false;
32
33 if (!MCID->mayLoad())
34 return false;
35
36 // SU is a load; for any predecessors in this dispatch group, that are stores,
37 // and with which we have an ordering dependency, return true.
38 for (unsigned i = 0, ie = (unsigned) SU->Preds.size(); i != ie; ++i) {
39 const MCInstrDesc *PredMCID = DAG->getInstrDesc(SU->Preds[i].getSUnit());
40 if (!PredMCID || !PredMCID->mayStore())
41 continue;
42
43 if (!SU->Preds[i].isNormalMemory() && !SU->Preds[i].isBarrier())
44 continue;
45
46 for (unsigned j = 0, je = CurGroup.size(); j != je; ++j)
47 if (SU->Preds[i].getSUnit() == CurGroup[j])
48 return true;
49 }
50
Fangrui Songf78650a2018-07-30 19:41:25 +000051 return false;
Hal Finkelceb1f122013-12-12 00:19:11 +000052}
53
54bool PPCDispatchGroupSBHazardRecognizer::isBCTRAfterSet(SUnit *SU) {
55 const MCInstrDesc *MCID = DAG->getInstrDesc(SU);
56 if (!MCID)
57 return false;
58
59 if (!MCID->isBranch())
60 return false;
61
62 // SU is a branch; for any predecessors in this dispatch group, with which we
63 // have a data dependence and set the counter register, return true.
64 for (unsigned i = 0, ie = (unsigned) SU->Preds.size(); i != ie; ++i) {
65 const MCInstrDesc *PredMCID = DAG->getInstrDesc(SU->Preds[i].getSUnit());
66 if (!PredMCID || PredMCID->getSchedClass() != PPC::Sched::IIC_SprMTSPR)
67 continue;
68
69 if (SU->Preds[i].isCtrl())
70 continue;
71
72 for (unsigned j = 0, je = CurGroup.size(); j != je; ++j)
73 if (SU->Preds[i].getSUnit() == CurGroup[j])
74 return true;
75 }
76
Fangrui Songf78650a2018-07-30 19:41:25 +000077 return false;
Hal Finkelceb1f122013-12-12 00:19:11 +000078}
79
80// FIXME: Remove this when we don't need this:
81namespace llvm { namespace PPC { extern int getNonRecordFormOpcode(uint16_t); } }
82
83// FIXME: A lot of code in PPCDispatchGroupSBHazardRecognizer is P7 specific.
84
85bool PPCDispatchGroupSBHazardRecognizer::mustComeFirst(const MCInstrDesc *MCID,
86 unsigned &NSlots) {
87 // FIXME: Indirectly, this information is contained in the itinerary, and
88 // we should derive it from there instead of separately specifying it
89 // here.
90 unsigned IIC = MCID->getSchedClass();
91 switch (IIC) {
92 default:
93 NSlots = 1;
94 break;
95 case PPC::Sched::IIC_IntDivW:
96 case PPC::Sched::IIC_IntDivD:
97 case PPC::Sched::IIC_LdStLoadUpd:
98 case PPC::Sched::IIC_LdStLDU:
99 case PPC::Sched::IIC_LdStLFDU:
100 case PPC::Sched::IIC_LdStLFDUX:
101 case PPC::Sched::IIC_LdStLHA:
102 case PPC::Sched::IIC_LdStLHAU:
103 case PPC::Sched::IIC_LdStLWA:
Jinsong Ji9a0ed202018-11-20 15:11:42 +0000104 case PPC::Sched::IIC_LdStSTU:
Hal Finkelceb1f122013-12-12 00:19:11 +0000105 case PPC::Sched::IIC_LdStSTFDU:
106 NSlots = 2;
107 break;
108 case PPC::Sched::IIC_LdStLoadUpdX:
109 case PPC::Sched::IIC_LdStLDUX:
110 case PPC::Sched::IIC_LdStLHAUX:
111 case PPC::Sched::IIC_LdStLWARX:
112 case PPC::Sched::IIC_LdStLDARX:
Jinsong Ji9a0ed202018-11-20 15:11:42 +0000113 case PPC::Sched::IIC_LdStSTUX:
Hal Finkelceb1f122013-12-12 00:19:11 +0000114 case PPC::Sched::IIC_LdStSTDCX:
115 case PPC::Sched::IIC_LdStSTWCX:
116 case PPC::Sched::IIC_BrMCRX: // mtcr
117 // FIXME: Add sync/isync (here and in the itinerary).
118 NSlots = 4;
119 break;
120 }
121
122 // FIXME: record-form instructions need a different itinerary class.
123 if (NSlots == 1 && PPC::getNonRecordFormOpcode(MCID->getOpcode()) != -1)
124 NSlots = 2;
125
126 switch (IIC) {
127 default:
128 // All multi-slot instructions must come first.
129 return NSlots > 1;
Hal Finkel1d429f22014-01-02 21:38:26 +0000130 case PPC::Sched::IIC_BrCR: // cr logicals
Hal Finkelceb1f122013-12-12 00:19:11 +0000131 case PPC::Sched::IIC_SprMFCR:
132 case PPC::Sched::IIC_SprMFCRF:
133 case PPC::Sched::IIC_SprMTSPR:
134 return true;
135 }
136}
137
138ScheduleHazardRecognizer::HazardType
139PPCDispatchGroupSBHazardRecognizer::getHazardType(SUnit *SU, int Stalls) {
140 if (Stalls == 0 && isLoadAfterStore(SU))
141 return NoopHazard;
142
143 return ScoreboardHazardRecognizer::getHazardType(SU, Stalls);
144}
145
146bool PPCDispatchGroupSBHazardRecognizer::ShouldPreferAnother(SUnit *SU) {
147 const MCInstrDesc *MCID = DAG->getInstrDesc(SU);
148 unsigned NSlots;
149 if (MCID && mustComeFirst(MCID, NSlots) && CurSlots)
150 return true;
151
152 return ScoreboardHazardRecognizer::ShouldPreferAnother(SU);
153}
154
155unsigned PPCDispatchGroupSBHazardRecognizer::PreEmitNoops(SUnit *SU) {
156 // We only need to fill out a maximum of 5 slots here: The 6th slot could
157 // only be a second branch, and otherwise the next instruction will start a
158 // new group.
159 if (isLoadAfterStore(SU) && CurSlots < 6) {
160 unsigned Directive =
Kit Barton85e4f5b2019-11-15 15:48:34 -0600161 DAG->MF.getSubtarget<PPCSubtarget>().getCPUDirective();
Hal Finkelceb1f122013-12-12 00:19:11 +0000162 // If we're using a special group-terminating nop, then we need only one.
Nemanja Ivanovic6e29baf2016-05-09 18:54:58 +0000163 // FIXME: the same for P9 as previous gen until POWER9 scheduling is ready
Will Schmidt970ff642014-06-26 13:36:19 +0000164 if (Directive == PPC::DIR_PWR6 || Directive == PPC::DIR_PWR7 ||
Nemanja Ivanovic6e29baf2016-05-09 18:54:58 +0000165 Directive == PPC::DIR_PWR8 || Directive == PPC::DIR_PWR9)
Hal Finkelceb1f122013-12-12 00:19:11 +0000166 return 1;
167
168 return 5 - CurSlots;
169 }
170
171 return ScoreboardHazardRecognizer::PreEmitNoops(SU);
172}
173
174void PPCDispatchGroupSBHazardRecognizer::EmitInstruction(SUnit *SU) {
175 const MCInstrDesc *MCID = DAG->getInstrDesc(SU);
176 if (MCID) {
177 if (CurSlots == 5 || (MCID->isBranch() && CurBranches == 1)) {
178 CurGroup.clear();
179 CurSlots = CurBranches = 0;
180 } else {
Matthias Braun726e12c2018-09-19 00:23:35 +0000181 LLVM_DEBUG(dbgs() << "**** Adding to dispatch group: ");
182 LLVM_DEBUG(DAG->dumpNode(*SU));
Hal Finkelceb1f122013-12-12 00:19:11 +0000183
184 unsigned NSlots;
185 bool MustBeFirst = mustComeFirst(MCID, NSlots);
186
187 // If this instruction must come first, but does not, then it starts a
188 // new group.
189 if (MustBeFirst && CurSlots) {
190 CurSlots = CurBranches = 0;
191 CurGroup.clear();
192 }
193
194 CurSlots += NSlots;
195 CurGroup.push_back(SU);
196
197 if (MCID->isBranch())
198 ++CurBranches;
199 }
200 }
201
202 return ScoreboardHazardRecognizer::EmitInstruction(SU);
203}
204
205void PPCDispatchGroupSBHazardRecognizer::AdvanceCycle() {
206 return ScoreboardHazardRecognizer::AdvanceCycle();
207}
208
209void PPCDispatchGroupSBHazardRecognizer::RecedeCycle() {
210 llvm_unreachable("Bottom-up scheduling not supported");
211}
212
213void PPCDispatchGroupSBHazardRecognizer::Reset() {
214 CurGroup.clear();
215 CurSlots = CurBranches = 0;
216 return ScoreboardHazardRecognizer::Reset();
217}
218
219void PPCDispatchGroupSBHazardRecognizer::EmitNoop() {
220 unsigned Directive =
Kit Barton85e4f5b2019-11-15 15:48:34 -0600221 DAG->MF.getSubtarget<PPCSubtarget>().getCPUDirective();
Hal Finkelceb1f122013-12-12 00:19:11 +0000222 // If the group has now filled all of its slots, or if we're using a special
223 // group-terminating nop, the group is complete.
Nemanja Ivanovic6e29baf2016-05-09 18:54:58 +0000224 // FIXME: the same for P9 as previous gen until POWER9 scheduling is ready
Hal Finkelceb1f122013-12-12 00:19:11 +0000225 if (Directive == PPC::DIR_PWR6 || Directive == PPC::DIR_PWR7 ||
Nemanja Ivanovic9163ca02016-07-27 13:24:54 +0000226 Directive == PPC::DIR_PWR8 || Directive == PPC::DIR_PWR9 ||
Nemanja Ivanovic6e29baf2016-05-09 18:54:58 +0000227 CurSlots == 6) {
Hal Finkelceb1f122013-12-12 00:19:11 +0000228 CurGroup.clear();
229 CurSlots = CurBranches = 0;
230 } else {
Craig Topper062a2ba2014-04-25 05:30:21 +0000231 CurGroup.push_back(nullptr);
Hal Finkelceb1f122013-12-12 00:19:11 +0000232 ++CurSlots;
233 }
234}
235
Chris Lattner2cab1352006-03-07 06:32:48 +0000236//===----------------------------------------------------------------------===//
237// PowerPC 970 Hazard Recognizer
238//
Chris Lattner05ad1282006-03-07 06:44:19 +0000239// This models the dispatch group formation of the PPC970 processor. Dispatch
Chris Lattner51348c52006-03-12 09:13:49 +0000240// groups are bundles of up to five instructions that can contain various mixes
Andrew Trickc416ba62010-12-24 04:28:06 +0000241// of instructions. The PPC970 can dispatch a peak of 4 non-branch and one
Chris Lattner51348c52006-03-12 09:13:49 +0000242// branch instruction per-cycle.
Chris Lattner05ad1282006-03-07 06:44:19 +0000243//
Chris Lattner51348c52006-03-12 09:13:49 +0000244// There are a number of restrictions to dispatch group formation: some
245// instructions can only be issued in the first slot of a dispatch group, & some
246// instructions fill an entire dispatch group. Additionally, only branches can
247// issue in the 5th (last) slot.
Chris Lattner05ad1282006-03-07 06:44:19 +0000248//
249// Finally, there are a number of "structural" hazards on the PPC970. These
250// conditions cause large performance penalties due to misprediction, recovery,
251// and replay logic that has to happen. These cases include setting a CTR and
252// branching through it in the same dispatch group, and storing to an address,
253// then loading from the same address within a dispatch group. To avoid these
254// conditions, we insert no-op instructions when appropriate.
255//
Chris Lattner2cab1352006-03-07 06:32:48 +0000256// FIXME: This is missing some significant cases:
Chris Lattner2cab1352006-03-07 06:32:48 +0000257// 1. Modeling of microcoded instructions.
Chris Lattner4fbb6122006-03-13 05:20:04 +0000258// 2. Handling of serialized operations.
259// 3. Handling of the esoteric cases in "Resource-based Instruction Grouping".
Chris Lattner2cab1352006-03-07 06:32:48 +0000260//
Chris Lattner2cab1352006-03-07 06:32:48 +0000261
Eric Christopher1dcea732014-06-12 21:48:52 +0000262PPCHazardRecognizer970::PPCHazardRecognizer970(const ScheduleDAG &DAG)
263 : DAG(DAG) {
Chris Lattner543832d2006-03-08 04:25:59 +0000264 EndDispatchGroup();
265}
266
Chris Lattner2cab1352006-03-07 06:32:48 +0000267void PPCHazardRecognizer970::EndDispatchGroup() {
Nicola Zaghend34e60c2018-05-14 12:53:11 +0000268 LLVM_DEBUG(errs() << "=== Start of dispatch group\n");
Chris Lattner2cab1352006-03-07 06:32:48 +0000269 NumIssued = 0;
Andrew Trickc416ba62010-12-24 04:28:06 +0000270
Chris Lattner2cab1352006-03-07 06:32:48 +0000271 // Structural hazard info.
272 HasCTRSet = false;
Chris Lattner51348c52006-03-12 09:13:49 +0000273 NumStores = 0;
Chris Lattner2cab1352006-03-07 06:32:48 +0000274}
275
276
Andrew Trickc416ba62010-12-24 04:28:06 +0000277PPCII::PPC970_Unit
Chris Lattner51348c52006-03-12 09:13:49 +0000278PPCHazardRecognizer970::GetInstrType(unsigned Opcode,
279 bool &isFirst, bool &isSingle,
Chris Lattner4fbb6122006-03-13 05:20:04 +0000280 bool &isCracked,
281 bool &isLoad, bool &isStore) {
Eric Christopher1dcea732014-06-12 21:48:52 +0000282 const MCInstrDesc &MCID = DAG.TII->get(Opcode);
Andrew Trickc416ba62010-12-24 04:28:06 +0000283
Evan Cheng6cc775f2011-06-28 19:10:37 +0000284 isLoad = MCID.mayLoad();
285 isStore = MCID.mayStore();
Andrew Trickc416ba62010-12-24 04:28:06 +0000286
Evan Cheng6cc775f2011-06-28 19:10:37 +0000287 uint64_t TSFlags = MCID.TSFlags;
Andrew Trickc416ba62010-12-24 04:28:06 +0000288
Chris Lattner4fbb6122006-03-13 05:20:04 +0000289 isFirst = TSFlags & PPCII::PPC970_First;
290 isSingle = TSFlags & PPCII::PPC970_Single;
291 isCracked = TSFlags & PPCII::PPC970_Cracked;
Chris Lattner51348c52006-03-12 09:13:49 +0000292 return (PPCII::PPC970_Unit)(TSFlags & PPCII::PPC970_Mask);
Chris Lattner2cab1352006-03-07 06:32:48 +0000293}
294
Chris Lattner2cab1352006-03-07 06:32:48 +0000295/// isLoadOfStoredAddress - If we have a load from the previously stored pointer
296/// as indicated by StorePtr1/StorePtr2/StoreSize, return true.
297bool PPCHazardRecognizer970::
Hal Finkel58ca3602011-12-02 04:58:02 +0000298isLoadOfStoredAddress(uint64_t LoadSize, int64_t LoadOffset,
299 const Value *LoadValue) const {
Chris Lattner51348c52006-03-12 09:13:49 +0000300 for (unsigned i = 0, e = NumStores; i != e; ++i) {
301 // Handle exact and commuted addresses.
Hal Finkel58ca3602011-12-02 04:58:02 +0000302 if (LoadValue == StoreValue[i] && LoadOffset == StoreOffset[i])
Chris Lattner51348c52006-03-12 09:13:49 +0000303 return true;
Andrew Trickc416ba62010-12-24 04:28:06 +0000304
Chris Lattner51348c52006-03-12 09:13:49 +0000305 // Okay, we don't have an exact match, if this is an indexed offset, see if
306 // we have overlap (which happens during fp->int conversion for example).
Hal Finkel58ca3602011-12-02 04:58:02 +0000307 if (StoreValue[i] == LoadValue) {
308 // Okay the base pointers match, so we have [c1+r] vs [c2+r]. Check
309 // to see if the load and store actually overlap.
310 if (StoreOffset[i] < LoadOffset) {
311 if (int64_t(StoreOffset[i]+StoreSize[i]) > LoadOffset) return true;
312 } else {
313 if (int64_t(LoadOffset+LoadSize) > StoreOffset[i]) return true;
314 }
Chris Lattner51348c52006-03-12 09:13:49 +0000315 }
Chris Lattner2cab1352006-03-07 06:32:48 +0000316 }
317 return false;
318}
319
320/// getHazardType - We return hazard for any non-branch instruction that would
Dan Gohman4a618822010-02-10 16:03:48 +0000321/// terminate the dispatch group. We turn NoopHazard for any
Chris Lattner2cab1352006-03-07 06:32:48 +0000322/// instructions that wouldn't terminate the dispatch group that would cause a
323/// pipeline flush.
Dan Gohman7e105f02009-01-15 22:18:12 +0000324ScheduleHazardRecognizer::HazardType PPCHazardRecognizer970::
Andrew Trick10ffc2b2010-12-24 05:03:26 +0000325getHazardType(SUnit *SU, int Stalls) {
326 assert(Stalls == 0 && "PPC hazards don't support scoreboard lookahead");
327
Hal Finkel58ca3602011-12-02 04:58:02 +0000328 MachineInstr *MI = SU->getInstr();
329
Shiva Chen801bf7e2018-05-09 02:42:00 +0000330 if (MI->isDebugInstr())
Hal Finkel58ca3602011-12-02 04:58:02 +0000331 return NoHazard;
332
333 unsigned Opcode = MI->getOpcode();
Chris Lattner4fbb6122006-03-13 05:20:04 +0000334 bool isFirst, isSingle, isCracked, isLoad, isStore;
Andrew Trickc416ba62010-12-24 04:28:06 +0000335 PPCII::PPC970_Unit InstrType =
Hal Finkel58ca3602011-12-02 04:58:02 +0000336 GetInstrType(Opcode, isFirst, isSingle, isCracked,
Chris Lattner4fbb6122006-03-13 05:20:04 +0000337 isLoad, isStore);
Andrew Trickc416ba62010-12-24 04:28:06 +0000338 if (InstrType == PPCII::PPC970_Pseudo) return NoHazard;
Chris Lattner2cab1352006-03-07 06:32:48 +0000339
Chris Lattner51348c52006-03-12 09:13:49 +0000340 // We can only issue a PPC970_First/PPC970_Single instruction (such as
341 // crand/mtspr/etc) if this is the first cycle of the dispatch group.
Chris Lattner4fbb6122006-03-13 05:20:04 +0000342 if (NumIssued != 0 && (isFirst || isSingle))
Chris Lattner51348c52006-03-12 09:13:49 +0000343 return Hazard;
Andrew Trickc416ba62010-12-24 04:28:06 +0000344
Chris Lattner4fbb6122006-03-13 05:20:04 +0000345 // If this instruction is cracked into two ops by the decoder, we know that
346 // it is not a branch and that it cannot issue if 3 other instructions are
347 // already in the dispatch group.
348 if (isCracked && NumIssued > 2)
349 return Hazard;
Andrew Trickc416ba62010-12-24 04:28:06 +0000350
Chris Lattner2cab1352006-03-07 06:32:48 +0000351 switch (InstrType) {
Torok Edwinfbcc6632009-07-14 16:55:14 +0000352 default: llvm_unreachable("Unknown instruction type!");
Chris Lattner51348c52006-03-12 09:13:49 +0000353 case PPCII::PPC970_FXU:
354 case PPCII::PPC970_LSU:
355 case PPCII::PPC970_FPU:
356 case PPCII::PPC970_VALU:
357 case PPCII::PPC970_VPERM:
358 // We can only issue a branch as the last instruction in a group.
359 if (NumIssued == 4) return Hazard;
360 break;
361 case PPCII::PPC970_CRU:
362 // We can only issue a CR instruction in the first two slots.
363 if (NumIssued >= 2) return Hazard;
364 break;
365 case PPCII::PPC970_BRU:
366 break;
Chris Lattner2cab1352006-03-07 06:32:48 +0000367 }
Andrew Trickc416ba62010-12-24 04:28:06 +0000368
Chris Lattner2cab1352006-03-07 06:32:48 +0000369 // Do not allow MTCTR and BCTRL to be in the same dispatch group.
Ulrich Weigandf62e83f2013-03-22 15:24:13 +0000370 if (HasCTRSet && Opcode == PPC::BCTRL)
Chris Lattner2cab1352006-03-07 06:32:48 +0000371 return NoopHazard;
Andrew Trickc416ba62010-12-24 04:28:06 +0000372
Chris Lattner2cab1352006-03-07 06:32:48 +0000373 // If this is a load following a store, make sure it's not to the same or
374 // overlapping address.
Hal Finkel58ca3602011-12-02 04:58:02 +0000375 if (isLoad && NumStores && !MI->memoperands_empty()) {
376 MachineMemOperand *MO = *MI->memoperands_begin();
377 if (isLoadOfStoredAddress(MO->getSize(),
378 MO->getOffset(), MO->getValue()))
Chris Lattner2cab1352006-03-07 06:32:48 +0000379 return NoopHazard;
380 }
Andrew Trickc416ba62010-12-24 04:28:06 +0000381
Chris Lattner2cab1352006-03-07 06:32:48 +0000382 return NoHazard;
383}
384
Dan Gohman7e105f02009-01-15 22:18:12 +0000385void PPCHazardRecognizer970::EmitInstruction(SUnit *SU) {
Hal Finkel58ca3602011-12-02 04:58:02 +0000386 MachineInstr *MI = SU->getInstr();
387
Shiva Chen801bf7e2018-05-09 02:42:00 +0000388 if (MI->isDebugInstr())
Hal Finkel58ca3602011-12-02 04:58:02 +0000389 return;
390
391 unsigned Opcode = MI->getOpcode();
Chris Lattner4fbb6122006-03-13 05:20:04 +0000392 bool isFirst, isSingle, isCracked, isLoad, isStore;
Andrew Trickc416ba62010-12-24 04:28:06 +0000393 PPCII::PPC970_Unit InstrType =
Hal Finkel58ca3602011-12-02 04:58:02 +0000394 GetInstrType(Opcode, isFirst, isSingle, isCracked,
Chris Lattner4fbb6122006-03-13 05:20:04 +0000395 isLoad, isStore);
Andrew Trickc416ba62010-12-24 04:28:06 +0000396 if (InstrType == PPCII::PPC970_Pseudo) return;
Chris Lattner2cab1352006-03-07 06:32:48 +0000397
398 // Update structural hazard information.
Roman Divackya4a59ae2011-06-03 15:47:49 +0000399 if (Opcode == PPC::MTCTR || Opcode == PPC::MTCTR8) HasCTRSet = true;
Andrew Trickc416ba62010-12-24 04:28:06 +0000400
Chris Lattner2cab1352006-03-07 06:32:48 +0000401 // Track the address stored to.
Hal Finkel58ca3602011-12-02 04:58:02 +0000402 if (isStore && NumStores < 4 && !MI->memoperands_empty()) {
403 MachineMemOperand *MO = *MI->memoperands_begin();
404 StoreSize[NumStores] = MO->getSize();
405 StoreOffset[NumStores] = MO->getOffset();
406 StoreValue[NumStores] = MO->getValue();
Chris Lattner51348c52006-03-12 09:13:49 +0000407 ++NumStores;
Chris Lattner2cab1352006-03-07 06:32:48 +0000408 }
Andrew Trickc416ba62010-12-24 04:28:06 +0000409
Chris Lattner51348c52006-03-12 09:13:49 +0000410 if (InstrType == PPCII::PPC970_BRU || isSingle)
411 NumIssued = 4; // Terminate a d-group.
Chris Lattner2cab1352006-03-07 06:32:48 +0000412 ++NumIssued;
Andrew Trickc416ba62010-12-24 04:28:06 +0000413
Chris Lattner4fbb6122006-03-13 05:20:04 +0000414 // If this instruction is cracked into two ops by the decoder, remember that
415 // we issued two pieces.
416 if (isCracked)
417 ++NumIssued;
Andrew Trickc416ba62010-12-24 04:28:06 +0000418
Chris Lattner2cab1352006-03-07 06:32:48 +0000419 if (NumIssued == 5)
420 EndDispatchGroup();
421}
422
423void PPCHazardRecognizer970::AdvanceCycle() {
424 assert(NumIssued < 5 && "Illegal dispatch group!");
425 ++NumIssued;
426 if (NumIssued == 5)
427 EndDispatchGroup();
428}
Hal Finkel58ca3602011-12-02 04:58:02 +0000429
430void PPCHazardRecognizer970::Reset() {
431 EndDispatchGroup();
432}
433