blob: cf3547f3cfb04f538e86ea91a78450ed694caad3 [file] [log] [blame]
Chris Lattner2cab1352006-03-07 06:32:48 +00001//===-- PPCHazardRecognizers.cpp - PowerPC Hazard Recognizer Impls --------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Chris Lattner2cab1352006-03-07 06:32:48 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file implements hazard recognizers for scheduling on PowerPC processors.
11//
12//===----------------------------------------------------------------------===//
13
Chris Lattner2cab1352006-03-07 06:32:48 +000014#include "PPCHazardRecognizers.h"
15#include "PPC.h"
Chris Lattner51348c52006-03-12 09:13:49 +000016#include "PPCInstrInfo.h"
Hal Finkelceb1f122013-12-12 00:19:11 +000017#include "PPCTargetMachine.h"
Dan Gohman7e105f02009-01-15 22:18:12 +000018#include "llvm/CodeGen/ScheduleDAG.h"
Chris Lattner2cab1352006-03-07 06:32:48 +000019#include "llvm/Support/Debug.h"
Torok Edwin56d06592009-07-11 20:10:48 +000020#include "llvm/Support/ErrorHandling.h"
Chris Lattneraf29ea62009-08-23 06:49:22 +000021#include "llvm/Support/raw_ostream.h"
Chris Lattner2cab1352006-03-07 06:32:48 +000022using namespace llvm;
23
Chandler Carruth84e68b22014-04-22 02:41:26 +000024#define DEBUG_TYPE "pre-RA-sched"
25
Hal Finkelceb1f122013-12-12 00:19:11 +000026bool PPCDispatchGroupSBHazardRecognizer::isLoadAfterStore(SUnit *SU) {
27 // FIXME: Move this.
28 if (isBCTRAfterSet(SU))
29 return true;
30
31 const MCInstrDesc *MCID = DAG->getInstrDesc(SU);
32 if (!MCID)
33 return false;
34
35 if (!MCID->mayLoad())
36 return false;
37
38 // SU is a load; for any predecessors in this dispatch group, that are stores,
39 // and with which we have an ordering dependency, return true.
40 for (unsigned i = 0, ie = (unsigned) SU->Preds.size(); i != ie; ++i) {
41 const MCInstrDesc *PredMCID = DAG->getInstrDesc(SU->Preds[i].getSUnit());
42 if (!PredMCID || !PredMCID->mayStore())
43 continue;
44
45 if (!SU->Preds[i].isNormalMemory() && !SU->Preds[i].isBarrier())
46 continue;
47
48 for (unsigned j = 0, je = CurGroup.size(); j != je; ++j)
49 if (SU->Preds[i].getSUnit() == CurGroup[j])
50 return true;
51 }
52
Fangrui Songf78650a2018-07-30 19:41:25 +000053 return false;
Hal Finkelceb1f122013-12-12 00:19:11 +000054}
55
56bool PPCDispatchGroupSBHazardRecognizer::isBCTRAfterSet(SUnit *SU) {
57 const MCInstrDesc *MCID = DAG->getInstrDesc(SU);
58 if (!MCID)
59 return false;
60
61 if (!MCID->isBranch())
62 return false;
63
64 // SU is a branch; for any predecessors in this dispatch group, with which we
65 // have a data dependence and set the counter register, return true.
66 for (unsigned i = 0, ie = (unsigned) SU->Preds.size(); i != ie; ++i) {
67 const MCInstrDesc *PredMCID = DAG->getInstrDesc(SU->Preds[i].getSUnit());
68 if (!PredMCID || PredMCID->getSchedClass() != PPC::Sched::IIC_SprMTSPR)
69 continue;
70
71 if (SU->Preds[i].isCtrl())
72 continue;
73
74 for (unsigned j = 0, je = CurGroup.size(); j != je; ++j)
75 if (SU->Preds[i].getSUnit() == CurGroup[j])
76 return true;
77 }
78
Fangrui Songf78650a2018-07-30 19:41:25 +000079 return false;
Hal Finkelceb1f122013-12-12 00:19:11 +000080}
81
82// FIXME: Remove this when we don't need this:
83namespace llvm { namespace PPC { extern int getNonRecordFormOpcode(uint16_t); } }
84
85// FIXME: A lot of code in PPCDispatchGroupSBHazardRecognizer is P7 specific.
86
87bool PPCDispatchGroupSBHazardRecognizer::mustComeFirst(const MCInstrDesc *MCID,
88 unsigned &NSlots) {
89 // FIXME: Indirectly, this information is contained in the itinerary, and
90 // we should derive it from there instead of separately specifying it
91 // here.
92 unsigned IIC = MCID->getSchedClass();
93 switch (IIC) {
94 default:
95 NSlots = 1;
96 break;
97 case PPC::Sched::IIC_IntDivW:
98 case PPC::Sched::IIC_IntDivD:
99 case PPC::Sched::IIC_LdStLoadUpd:
100 case PPC::Sched::IIC_LdStLDU:
101 case PPC::Sched::IIC_LdStLFDU:
102 case PPC::Sched::IIC_LdStLFDUX:
103 case PPC::Sched::IIC_LdStLHA:
104 case PPC::Sched::IIC_LdStLHAU:
105 case PPC::Sched::IIC_LdStLWA:
106 case PPC::Sched::IIC_LdStSTDU:
107 case PPC::Sched::IIC_LdStSTFDU:
108 NSlots = 2;
109 break;
110 case PPC::Sched::IIC_LdStLoadUpdX:
111 case PPC::Sched::IIC_LdStLDUX:
112 case PPC::Sched::IIC_LdStLHAUX:
113 case PPC::Sched::IIC_LdStLWARX:
114 case PPC::Sched::IIC_LdStLDARX:
115 case PPC::Sched::IIC_LdStSTDUX:
116 case PPC::Sched::IIC_LdStSTDCX:
117 case PPC::Sched::IIC_LdStSTWCX:
118 case PPC::Sched::IIC_BrMCRX: // mtcr
119 // FIXME: Add sync/isync (here and in the itinerary).
120 NSlots = 4;
121 break;
122 }
123
124 // FIXME: record-form instructions need a different itinerary class.
125 if (NSlots == 1 && PPC::getNonRecordFormOpcode(MCID->getOpcode()) != -1)
126 NSlots = 2;
127
128 switch (IIC) {
129 default:
130 // All multi-slot instructions must come first.
131 return NSlots > 1;
Hal Finkel1d429f22014-01-02 21:38:26 +0000132 case PPC::Sched::IIC_BrCR: // cr logicals
Hal Finkelceb1f122013-12-12 00:19:11 +0000133 case PPC::Sched::IIC_SprMFCR:
134 case PPC::Sched::IIC_SprMFCRF:
135 case PPC::Sched::IIC_SprMTSPR:
136 return true;
137 }
138}
139
140ScheduleHazardRecognizer::HazardType
141PPCDispatchGroupSBHazardRecognizer::getHazardType(SUnit *SU, int Stalls) {
142 if (Stalls == 0 && isLoadAfterStore(SU))
143 return NoopHazard;
144
145 return ScoreboardHazardRecognizer::getHazardType(SU, Stalls);
146}
147
148bool PPCDispatchGroupSBHazardRecognizer::ShouldPreferAnother(SUnit *SU) {
149 const MCInstrDesc *MCID = DAG->getInstrDesc(SU);
150 unsigned NSlots;
151 if (MCID && mustComeFirst(MCID, NSlots) && CurSlots)
152 return true;
153
154 return ScoreboardHazardRecognizer::ShouldPreferAnother(SU);
155}
156
157unsigned PPCDispatchGroupSBHazardRecognizer::PreEmitNoops(SUnit *SU) {
158 // We only need to fill out a maximum of 5 slots here: The 6th slot could
159 // only be a second branch, and otherwise the next instruction will start a
160 // new group.
161 if (isLoadAfterStore(SU) && CurSlots < 6) {
162 unsigned Directive =
Eric Christophercccae792015-01-30 22:02:31 +0000163 DAG->MF.getSubtarget<PPCSubtarget>().getDarwinDirective();
Hal Finkelceb1f122013-12-12 00:19:11 +0000164 // If we're using a special group-terminating nop, then we need only one.
Nemanja Ivanovic6e29baf2016-05-09 18:54:58 +0000165 // FIXME: the same for P9 as previous gen until POWER9 scheduling is ready
Will Schmidt970ff642014-06-26 13:36:19 +0000166 if (Directive == PPC::DIR_PWR6 || Directive == PPC::DIR_PWR7 ||
Nemanja Ivanovic6e29baf2016-05-09 18:54:58 +0000167 Directive == PPC::DIR_PWR8 || Directive == PPC::DIR_PWR9)
Hal Finkelceb1f122013-12-12 00:19:11 +0000168 return 1;
169
170 return 5 - CurSlots;
171 }
172
173 return ScoreboardHazardRecognizer::PreEmitNoops(SU);
174}
175
176void PPCDispatchGroupSBHazardRecognizer::EmitInstruction(SUnit *SU) {
177 const MCInstrDesc *MCID = DAG->getInstrDesc(SU);
178 if (MCID) {
179 if (CurSlots == 5 || (MCID->isBranch() && CurBranches == 1)) {
180 CurGroup.clear();
181 CurSlots = CurBranches = 0;
182 } else {
Matthias Braun726e12c2018-09-19 00:23:35 +0000183 LLVM_DEBUG(dbgs() << "**** Adding to dispatch group: ");
184 LLVM_DEBUG(DAG->dumpNode(*SU));
Hal Finkelceb1f122013-12-12 00:19:11 +0000185
186 unsigned NSlots;
187 bool MustBeFirst = mustComeFirst(MCID, NSlots);
188
189 // If this instruction must come first, but does not, then it starts a
190 // new group.
191 if (MustBeFirst && CurSlots) {
192 CurSlots = CurBranches = 0;
193 CurGroup.clear();
194 }
195
196 CurSlots += NSlots;
197 CurGroup.push_back(SU);
198
199 if (MCID->isBranch())
200 ++CurBranches;
201 }
202 }
203
204 return ScoreboardHazardRecognizer::EmitInstruction(SU);
205}
206
207void PPCDispatchGroupSBHazardRecognizer::AdvanceCycle() {
208 return ScoreboardHazardRecognizer::AdvanceCycle();
209}
210
211void PPCDispatchGroupSBHazardRecognizer::RecedeCycle() {
212 llvm_unreachable("Bottom-up scheduling not supported");
213}
214
215void PPCDispatchGroupSBHazardRecognizer::Reset() {
216 CurGroup.clear();
217 CurSlots = CurBranches = 0;
218 return ScoreboardHazardRecognizer::Reset();
219}
220
221void PPCDispatchGroupSBHazardRecognizer::EmitNoop() {
222 unsigned Directive =
Eric Christophercccae792015-01-30 22:02:31 +0000223 DAG->MF.getSubtarget<PPCSubtarget>().getDarwinDirective();
Hal Finkelceb1f122013-12-12 00:19:11 +0000224 // If the group has now filled all of its slots, or if we're using a special
225 // group-terminating nop, the group is complete.
Nemanja Ivanovic6e29baf2016-05-09 18:54:58 +0000226 // FIXME: the same for P9 as previous gen until POWER9 scheduling is ready
Hal Finkelceb1f122013-12-12 00:19:11 +0000227 if (Directive == PPC::DIR_PWR6 || Directive == PPC::DIR_PWR7 ||
Nemanja Ivanovic9163ca02016-07-27 13:24:54 +0000228 Directive == PPC::DIR_PWR8 || Directive == PPC::DIR_PWR9 ||
Nemanja Ivanovic6e29baf2016-05-09 18:54:58 +0000229 CurSlots == 6) {
Hal Finkelceb1f122013-12-12 00:19:11 +0000230 CurGroup.clear();
231 CurSlots = CurBranches = 0;
232 } else {
Craig Topper062a2ba2014-04-25 05:30:21 +0000233 CurGroup.push_back(nullptr);
Hal Finkelceb1f122013-12-12 00:19:11 +0000234 ++CurSlots;
235 }
236}
237
Chris Lattner2cab1352006-03-07 06:32:48 +0000238//===----------------------------------------------------------------------===//
239// PowerPC 970 Hazard Recognizer
240//
Chris Lattner05ad1282006-03-07 06:44:19 +0000241// This models the dispatch group formation of the PPC970 processor. Dispatch
Chris Lattner51348c52006-03-12 09:13:49 +0000242// groups are bundles of up to five instructions that can contain various mixes
Andrew Trickc416ba62010-12-24 04:28:06 +0000243// of instructions. The PPC970 can dispatch a peak of 4 non-branch and one
Chris Lattner51348c52006-03-12 09:13:49 +0000244// branch instruction per-cycle.
Chris Lattner05ad1282006-03-07 06:44:19 +0000245//
Chris Lattner51348c52006-03-12 09:13:49 +0000246// There are a number of restrictions to dispatch group formation: some
247// instructions can only be issued in the first slot of a dispatch group, & some
248// instructions fill an entire dispatch group. Additionally, only branches can
249// issue in the 5th (last) slot.
Chris Lattner05ad1282006-03-07 06:44:19 +0000250//
251// Finally, there are a number of "structural" hazards on the PPC970. These
252// conditions cause large performance penalties due to misprediction, recovery,
253// and replay logic that has to happen. These cases include setting a CTR and
254// branching through it in the same dispatch group, and storing to an address,
255// then loading from the same address within a dispatch group. To avoid these
256// conditions, we insert no-op instructions when appropriate.
257//
Chris Lattner2cab1352006-03-07 06:32:48 +0000258// FIXME: This is missing some significant cases:
Chris Lattner2cab1352006-03-07 06:32:48 +0000259// 1. Modeling of microcoded instructions.
Chris Lattner4fbb6122006-03-13 05:20:04 +0000260// 2. Handling of serialized operations.
261// 3. Handling of the esoteric cases in "Resource-based Instruction Grouping".
Chris Lattner2cab1352006-03-07 06:32:48 +0000262//
Chris Lattner2cab1352006-03-07 06:32:48 +0000263
Eric Christopher1dcea732014-06-12 21:48:52 +0000264PPCHazardRecognizer970::PPCHazardRecognizer970(const ScheduleDAG &DAG)
265 : DAG(DAG) {
Chris Lattner543832d2006-03-08 04:25:59 +0000266 EndDispatchGroup();
267}
268
Chris Lattner2cab1352006-03-07 06:32:48 +0000269void PPCHazardRecognizer970::EndDispatchGroup() {
Nicola Zaghend34e60c2018-05-14 12:53:11 +0000270 LLVM_DEBUG(errs() << "=== Start of dispatch group\n");
Chris Lattner2cab1352006-03-07 06:32:48 +0000271 NumIssued = 0;
Andrew Trickc416ba62010-12-24 04:28:06 +0000272
Chris Lattner2cab1352006-03-07 06:32:48 +0000273 // Structural hazard info.
274 HasCTRSet = false;
Chris Lattner51348c52006-03-12 09:13:49 +0000275 NumStores = 0;
Chris Lattner2cab1352006-03-07 06:32:48 +0000276}
277
278
Andrew Trickc416ba62010-12-24 04:28:06 +0000279PPCII::PPC970_Unit
Chris Lattner51348c52006-03-12 09:13:49 +0000280PPCHazardRecognizer970::GetInstrType(unsigned Opcode,
281 bool &isFirst, bool &isSingle,
Chris Lattner4fbb6122006-03-13 05:20:04 +0000282 bool &isCracked,
283 bool &isLoad, bool &isStore) {
Eric Christopher1dcea732014-06-12 21:48:52 +0000284 const MCInstrDesc &MCID = DAG.TII->get(Opcode);
Andrew Trickc416ba62010-12-24 04:28:06 +0000285
Evan Cheng6cc775f2011-06-28 19:10:37 +0000286 isLoad = MCID.mayLoad();
287 isStore = MCID.mayStore();
Andrew Trickc416ba62010-12-24 04:28:06 +0000288
Evan Cheng6cc775f2011-06-28 19:10:37 +0000289 uint64_t TSFlags = MCID.TSFlags;
Andrew Trickc416ba62010-12-24 04:28:06 +0000290
Chris Lattner4fbb6122006-03-13 05:20:04 +0000291 isFirst = TSFlags & PPCII::PPC970_First;
292 isSingle = TSFlags & PPCII::PPC970_Single;
293 isCracked = TSFlags & PPCII::PPC970_Cracked;
Chris Lattner51348c52006-03-12 09:13:49 +0000294 return (PPCII::PPC970_Unit)(TSFlags & PPCII::PPC970_Mask);
Chris Lattner2cab1352006-03-07 06:32:48 +0000295}
296
Chris Lattner2cab1352006-03-07 06:32:48 +0000297/// isLoadOfStoredAddress - If we have a load from the previously stored pointer
298/// as indicated by StorePtr1/StorePtr2/StoreSize, return true.
299bool PPCHazardRecognizer970::
Hal Finkel58ca3602011-12-02 04:58:02 +0000300isLoadOfStoredAddress(uint64_t LoadSize, int64_t LoadOffset,
301 const Value *LoadValue) const {
Chris Lattner51348c52006-03-12 09:13:49 +0000302 for (unsigned i = 0, e = NumStores; i != e; ++i) {
303 // Handle exact and commuted addresses.
Hal Finkel58ca3602011-12-02 04:58:02 +0000304 if (LoadValue == StoreValue[i] && LoadOffset == StoreOffset[i])
Chris Lattner51348c52006-03-12 09:13:49 +0000305 return true;
Andrew Trickc416ba62010-12-24 04:28:06 +0000306
Chris Lattner51348c52006-03-12 09:13:49 +0000307 // Okay, we don't have an exact match, if this is an indexed offset, see if
308 // we have overlap (which happens during fp->int conversion for example).
Hal Finkel58ca3602011-12-02 04:58:02 +0000309 if (StoreValue[i] == LoadValue) {
310 // Okay the base pointers match, so we have [c1+r] vs [c2+r]. Check
311 // to see if the load and store actually overlap.
312 if (StoreOffset[i] < LoadOffset) {
313 if (int64_t(StoreOffset[i]+StoreSize[i]) > LoadOffset) return true;
314 } else {
315 if (int64_t(LoadOffset+LoadSize) > StoreOffset[i]) return true;
316 }
Chris Lattner51348c52006-03-12 09:13:49 +0000317 }
Chris Lattner2cab1352006-03-07 06:32:48 +0000318 }
319 return false;
320}
321
322/// getHazardType - We return hazard for any non-branch instruction that would
Dan Gohman4a618822010-02-10 16:03:48 +0000323/// terminate the dispatch group. We turn NoopHazard for any
Chris Lattner2cab1352006-03-07 06:32:48 +0000324/// instructions that wouldn't terminate the dispatch group that would cause a
325/// pipeline flush.
Dan Gohman7e105f02009-01-15 22:18:12 +0000326ScheduleHazardRecognizer::HazardType PPCHazardRecognizer970::
Andrew Trick10ffc2b2010-12-24 05:03:26 +0000327getHazardType(SUnit *SU, int Stalls) {
328 assert(Stalls == 0 && "PPC hazards don't support scoreboard lookahead");
329
Hal Finkel58ca3602011-12-02 04:58:02 +0000330 MachineInstr *MI = SU->getInstr();
331
Shiva Chen801bf7e2018-05-09 02:42:00 +0000332 if (MI->isDebugInstr())
Hal Finkel58ca3602011-12-02 04:58:02 +0000333 return NoHazard;
334
335 unsigned Opcode = MI->getOpcode();
Chris Lattner4fbb6122006-03-13 05:20:04 +0000336 bool isFirst, isSingle, isCracked, isLoad, isStore;
Andrew Trickc416ba62010-12-24 04:28:06 +0000337 PPCII::PPC970_Unit InstrType =
Hal Finkel58ca3602011-12-02 04:58:02 +0000338 GetInstrType(Opcode, isFirst, isSingle, isCracked,
Chris Lattner4fbb6122006-03-13 05:20:04 +0000339 isLoad, isStore);
Andrew Trickc416ba62010-12-24 04:28:06 +0000340 if (InstrType == PPCII::PPC970_Pseudo) return NoHazard;
Chris Lattner2cab1352006-03-07 06:32:48 +0000341
Chris Lattner51348c52006-03-12 09:13:49 +0000342 // We can only issue a PPC970_First/PPC970_Single instruction (such as
343 // crand/mtspr/etc) if this is the first cycle of the dispatch group.
Chris Lattner4fbb6122006-03-13 05:20:04 +0000344 if (NumIssued != 0 && (isFirst || isSingle))
Chris Lattner51348c52006-03-12 09:13:49 +0000345 return Hazard;
Andrew Trickc416ba62010-12-24 04:28:06 +0000346
Chris Lattner4fbb6122006-03-13 05:20:04 +0000347 // If this instruction is cracked into two ops by the decoder, we know that
348 // it is not a branch and that it cannot issue if 3 other instructions are
349 // already in the dispatch group.
350 if (isCracked && NumIssued > 2)
351 return Hazard;
Andrew Trickc416ba62010-12-24 04:28:06 +0000352
Chris Lattner2cab1352006-03-07 06:32:48 +0000353 switch (InstrType) {
Torok Edwinfbcc6632009-07-14 16:55:14 +0000354 default: llvm_unreachable("Unknown instruction type!");
Chris Lattner51348c52006-03-12 09:13:49 +0000355 case PPCII::PPC970_FXU:
356 case PPCII::PPC970_LSU:
357 case PPCII::PPC970_FPU:
358 case PPCII::PPC970_VALU:
359 case PPCII::PPC970_VPERM:
360 // We can only issue a branch as the last instruction in a group.
361 if (NumIssued == 4) return Hazard;
362 break;
363 case PPCII::PPC970_CRU:
364 // We can only issue a CR instruction in the first two slots.
365 if (NumIssued >= 2) return Hazard;
366 break;
367 case PPCII::PPC970_BRU:
368 break;
Chris Lattner2cab1352006-03-07 06:32:48 +0000369 }
Andrew Trickc416ba62010-12-24 04:28:06 +0000370
Chris Lattner2cab1352006-03-07 06:32:48 +0000371 // Do not allow MTCTR and BCTRL to be in the same dispatch group.
Ulrich Weigandf62e83f2013-03-22 15:24:13 +0000372 if (HasCTRSet && Opcode == PPC::BCTRL)
Chris Lattner2cab1352006-03-07 06:32:48 +0000373 return NoopHazard;
Andrew Trickc416ba62010-12-24 04:28:06 +0000374
Chris Lattner2cab1352006-03-07 06:32:48 +0000375 // If this is a load following a store, make sure it's not to the same or
376 // overlapping address.
Hal Finkel58ca3602011-12-02 04:58:02 +0000377 if (isLoad && NumStores && !MI->memoperands_empty()) {
378 MachineMemOperand *MO = *MI->memoperands_begin();
379 if (isLoadOfStoredAddress(MO->getSize(),
380 MO->getOffset(), MO->getValue()))
Chris Lattner2cab1352006-03-07 06:32:48 +0000381 return NoopHazard;
382 }
Andrew Trickc416ba62010-12-24 04:28:06 +0000383
Chris Lattner2cab1352006-03-07 06:32:48 +0000384 return NoHazard;
385}
386
Dan Gohman7e105f02009-01-15 22:18:12 +0000387void PPCHazardRecognizer970::EmitInstruction(SUnit *SU) {
Hal Finkel58ca3602011-12-02 04:58:02 +0000388 MachineInstr *MI = SU->getInstr();
389
Shiva Chen801bf7e2018-05-09 02:42:00 +0000390 if (MI->isDebugInstr())
Hal Finkel58ca3602011-12-02 04:58:02 +0000391 return;
392
393 unsigned Opcode = MI->getOpcode();
Chris Lattner4fbb6122006-03-13 05:20:04 +0000394 bool isFirst, isSingle, isCracked, isLoad, isStore;
Andrew Trickc416ba62010-12-24 04:28:06 +0000395 PPCII::PPC970_Unit InstrType =
Hal Finkel58ca3602011-12-02 04:58:02 +0000396 GetInstrType(Opcode, isFirst, isSingle, isCracked,
Chris Lattner4fbb6122006-03-13 05:20:04 +0000397 isLoad, isStore);
Andrew Trickc416ba62010-12-24 04:28:06 +0000398 if (InstrType == PPCII::PPC970_Pseudo) return;
Chris Lattner2cab1352006-03-07 06:32:48 +0000399
400 // Update structural hazard information.
Roman Divackya4a59ae2011-06-03 15:47:49 +0000401 if (Opcode == PPC::MTCTR || Opcode == PPC::MTCTR8) HasCTRSet = true;
Andrew Trickc416ba62010-12-24 04:28:06 +0000402
Chris Lattner2cab1352006-03-07 06:32:48 +0000403 // Track the address stored to.
Hal Finkel58ca3602011-12-02 04:58:02 +0000404 if (isStore && NumStores < 4 && !MI->memoperands_empty()) {
405 MachineMemOperand *MO = *MI->memoperands_begin();
406 StoreSize[NumStores] = MO->getSize();
407 StoreOffset[NumStores] = MO->getOffset();
408 StoreValue[NumStores] = MO->getValue();
Chris Lattner51348c52006-03-12 09:13:49 +0000409 ++NumStores;
Chris Lattner2cab1352006-03-07 06:32:48 +0000410 }
Andrew Trickc416ba62010-12-24 04:28:06 +0000411
Chris Lattner51348c52006-03-12 09:13:49 +0000412 if (InstrType == PPCII::PPC970_BRU || isSingle)
413 NumIssued = 4; // Terminate a d-group.
Chris Lattner2cab1352006-03-07 06:32:48 +0000414 ++NumIssued;
Andrew Trickc416ba62010-12-24 04:28:06 +0000415
Chris Lattner4fbb6122006-03-13 05:20:04 +0000416 // If this instruction is cracked into two ops by the decoder, remember that
417 // we issued two pieces.
418 if (isCracked)
419 ++NumIssued;
Andrew Trickc416ba62010-12-24 04:28:06 +0000420
Chris Lattner2cab1352006-03-07 06:32:48 +0000421 if (NumIssued == 5)
422 EndDispatchGroup();
423}
424
425void PPCHazardRecognizer970::AdvanceCycle() {
426 assert(NumIssued < 5 && "Illegal dispatch group!");
427 ++NumIssued;
428 if (NumIssued == 5)
429 EndDispatchGroup();
430}
Hal Finkel58ca3602011-12-02 04:58:02 +0000431
432void PPCHazardRecognizer970::Reset() {
433 EndDispatchGroup();
434}
435