blob: 03aa3ed4addec1e6e3dee7e2fbdb021d52b8006b [file] [log] [blame]
Chris Lattner6b04e712002-02-04 00:39:14 +00001//===-- UltraSparcSchedInfo.cpp -------------------------------------------===//
2//
3// Describe the scheduling characteristics of the UltraSparc
4//
5//===----------------------------------------------------------------------===//
6
7#include "SparcInternals.h"
8
9/*---------------------------------------------------------------------------
10Scheduling guidelines for SPARC IIi:
11
12I-Cache alignment rules (pg 326)
13-- Align a branch target instruction so that it's entire group is within
14 the same cache line (may be 1-4 instructions).
15** Don't let a branch that is predicted taken be the last instruction
16 on an I-cache line: delay slot will need an entire line to be fetched
17-- Make a FP instruction or a branch be the 4th instruction in a group.
18 For branches, there are tradeoffs in reordering to make this happen
19 (see pg. 327).
20** Don't put a branch in a group that crosses a 32-byte boundary!
21 An artificial branch is inserted after every 32 bytes, and having
22 another branch will force the group to be broken into 2 groups.
23
24iTLB rules:
25-- Don't let a loop span two memory pages, if possible
26
27Branch prediction performance:
28-- Don't make the branch in a delay slot the target of a branch
29-- Try not to have 2 predicted branches within a group of 4 instructions
30 (because each such group has a single branch target field).
31-- Try to align branches in slots 0, 2, 4 or 6 of a cache line (to avoid
32 the wrong prediction bits being used in some cases).
33
34D-Cache timing constraints:
35-- Signed int loads of less than 64 bits have 3 cycle latency, not 2
36-- All other loads that hit in D-Cache have 2 cycle latency
37-- All loads are returned IN ORDER, so a D-Cache miss will delay a later hit
38-- Mis-aligned loads or stores cause a trap. In particular, replace
39 mis-aligned FP double precision l/s with 2 single-precision l/s.
40-- Simulations of integer codes show increase in avg. group size of
41 33% when code (including esp. non-faulting loads) is moved across
42 one branch, and 50% across 2 branches.
43
44E-Cache timing constraints:
45-- Scheduling for E-cache (D-Cache misses) is effective (due to load buffering)
46
47Store buffer timing constraints:
48-- Stores can be executed in same cycle as instruction producing the value
49-- Stores are buffered and have lower priority for E-cache until
50 highwater mark is reached in the store buffer (5 stores)
51
52Pipeline constraints:
53-- Shifts can only use IEU0.
54-- CC setting instructions can only use IEU1.
55-- Several other instructions must only use IEU1:
56 EDGE(?), ARRAY(?), CALL, JMPL, BPr, PST, and FCMP.
57-- Two instructions cannot store to the same register file in a single cycle
58 (single write port per file).
59
60Issue and grouping constraints:
61-- FP and branch instructions must use slot 4.
62-- Shift instructions cannot be grouped with other IEU0-specific instructions.
63-- CC setting instructions cannot be grouped with other IEU1-specific instrs.
64-- Several instructions must be issued in a single-instruction group:
65 MOVcc or MOVr, MULs/x and DIVs/x, SAVE/RESTORE, many others
66-- A CALL or JMPL breaks a group, ie, is not combined with subsequent instrs.
67--
68--
69
70Branch delay slot scheduling rules:
71-- A CTI couple (two back-to-back CTI instructions in the dynamic stream)
72 has a 9-instruction penalty: the entire pipeline is flushed when the
73 second instruction reaches stage 9 (W-Writeback).
74-- Avoid putting multicycle instructions, and instructions that may cause
75 load misses, in the delay slot of an annulling branch.
76-- Avoid putting WR, SAVE..., RESTORE and RETURN instructions in the
77 delay slot of an annulling branch.
78
79 *--------------------------------------------------------------------------- */
80
81//---------------------------------------------------------------------------
82// List of CPUResources for UltraSPARC IIi.
83//---------------------------------------------------------------------------
84
85static const CPUResource AllIssueSlots( "All Instr Slots", 4);
86static const CPUResource IntIssueSlots( "Int Instr Slots", 3);
87static const CPUResource First3IssueSlots("Instr Slots 0-3", 3);
88static const CPUResource LSIssueSlots( "Load-Store Instr Slot", 1);
89static const CPUResource CTIIssueSlots( "Ctrl Transfer Instr Slot", 1);
Vikram S. Adve10472ce2002-08-22 02:58:57 +000090static const CPUResource FPAIssueSlots( "FP Instr Slot 1", 1);
91static const CPUResource FPMIssueSlots( "FP Instr Slot 2", 1);
Chris Lattner6b04e712002-02-04 00:39:14 +000092
93// IEUN instructions can use either Alu and should use IAluN.
94// IEU0 instructions must use Alu 1 and should use both IAluN and IAlu0.
95// IEU1 instructions must use Alu 2 and should use both IAluN and IAlu1.
96static const CPUResource IAluN("Int ALU 1or2", 2);
97static const CPUResource IAlu0("Int ALU 1", 1);
98static const CPUResource IAlu1("Int ALU 2", 1);
99
100static const CPUResource LSAluC1("Load/Store Unit Addr Cycle", 1);
101static const CPUResource LSAluC2("Load/Store Unit Issue Cycle", 1);
102static const CPUResource LdReturn("Load Return Unit", 1);
103
104static const CPUResource FPMAluC1("FP Mul/Div Alu Cycle 1", 1);
105static const CPUResource FPMAluC2("FP Mul/Div Alu Cycle 2", 1);
106static const CPUResource FPMAluC3("FP Mul/Div Alu Cycle 3", 1);
107
108static const CPUResource FPAAluC1("FP Other Alu Cycle 1", 1);
109static const CPUResource FPAAluC2("FP Other Alu Cycle 2", 1);
110static const CPUResource FPAAluC3("FP Other Alu Cycle 3", 1);
111
112static const CPUResource IRegReadPorts("Int Reg ReadPorts", INT_MAX); // CHECK
113static const CPUResource IRegWritePorts("Int Reg WritePorts", 2); // CHECK
114static const CPUResource FPRegReadPorts("FP Reg Read Ports", INT_MAX);// CHECK
115static const CPUResource FPRegWritePorts("FP Reg Write Ports", 1); // CHECK
116
117static const CPUResource CTIDelayCycle( "CTI delay cycle", 1);
118static const CPUResource FCMPDelayCycle("FCMP delay cycle", 1);
119
120
121
122//---------------------------------------------------------------------------
123// const InstrClassRUsage SparcRUsageDesc[]
124//
125// Purpose:
126// Resource usage information for instruction in each scheduling class.
127// The InstrRUsage Objects for individual classes are specified first.
128// Note that fetch and decode are decoupled from the execution pipelines
129// via an instr buffer, so they are not included in the cycles below.
130//---------------------------------------------------------------------------
131
132static const InstrClassRUsage NoneClassRUsage = {
133 SPARC_NONE,
134 /*totCycles*/ 7,
135
136 /* maxIssueNum */ 4,
137 /* isSingleIssue */ false,
138 /* breaksGroup */ false,
139 /* numBubbles */ 0,
140
141 /*numSlots*/ 4,
142 /* feasibleSlots[] */ { 0, 1, 2, 3 },
143
144 /*numEntries*/ 0,
145 /* V[] */ {
146 /*Cycle G */
147 /*Ccle E */
148 /*Cycle C */
149 /*Cycle N1*/
150 /*Cycle N1*/
151 /*Cycle N1*/
152 /*Cycle W */
153 }
154};
155
156static const InstrClassRUsage IEUNClassRUsage = {
157 SPARC_IEUN,
158 /*totCycles*/ 7,
159
160 /* maxIssueNum */ 3,
161 /* isSingleIssue */ false,
162 /* breaksGroup */ false,
163 /* numBubbles */ 0,
164
165 /*numSlots*/ 3,
166 /* feasibleSlots[] */ { 0, 1, 2 },
167
168 /*numEntries*/ 4,
169 /* V[] */ {
170 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
171 { IntIssueSlots.rid, 0, 1 },
172 /*Cycle E */ { IAluN.rid, 1, 1 },
173 /*Cycle C */
174 /*Cycle N1*/
175 /*Cycle N1*/
176 /*Cycle N1*/
177 /*Cycle W */ { IRegWritePorts.rid, 6, 1 }
178 }
179};
180
181static const InstrClassRUsage IEU0ClassRUsage = {
182 SPARC_IEU0,
183 /*totCycles*/ 7,
184
185 /* maxIssueNum */ 1,
186 /* isSingleIssue */ false,
187 /* breaksGroup */ false,
188 /* numBubbles */ 0,
189
190 /*numSlots*/ 3,
191 /* feasibleSlots[] */ { 0, 1, 2 },
192
193 /*numEntries*/ 5,
194 /* V[] */ {
195 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
196 { IntIssueSlots.rid, 0, 1 },
197 /*Cycle E */ { IAluN.rid, 1, 1 },
198 { IAlu0.rid, 1, 1 },
199 /*Cycle C */
200 /*Cycle N1*/
201 /*Cycle N1*/
202 /*Cycle N1*/
203 /*Cycle W */ { IRegWritePorts.rid, 6, 1 }
204 }
205};
206
207static const InstrClassRUsage IEU1ClassRUsage = {
208 SPARC_IEU1,
209 /*totCycles*/ 7,
210
211 /* maxIssueNum */ 1,
212 /* isSingleIssue */ false,
213 /* breaksGroup */ false,
214 /* numBubbles */ 0,
215
216 /*numSlots*/ 3,
217 /* feasibleSlots[] */ { 0, 1, 2 },
218
219 /*numEntries*/ 5,
220 /* V[] */ {
221 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
222 { IntIssueSlots.rid, 0, 1 },
223 /*Cycle E */ { IAluN.rid, 1, 1 },
224 { IAlu1.rid, 1, 1 },
225 /*Cycle C */
226 /*Cycle N1*/
227 /*Cycle N1*/
228 /*Cycle N1*/
229 /*Cycle W */ { IRegWritePorts.rid, 6, 1 }
230 }
231};
232
233static const InstrClassRUsage FPMClassRUsage = {
234 SPARC_FPM,
235 /*totCycles*/ 7,
236
237 /* maxIssueNum */ 1,
238 /* isSingleIssue */ false,
239 /* breaksGroup */ false,
240 /* numBubbles */ 0,
241
242 /*numSlots*/ 4,
243 /* feasibleSlots[] */ { 0, 1, 2, 3 },
244
245 /*numEntries*/ 7,
246 /* V[] */ {
247 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
248 { FPMIssueSlots.rid, 0, 1 },
249 /*Cycle E */ { FPRegReadPorts.rid, 1, 1 },
250 /*Cycle C */ { FPMAluC1.rid, 2, 1 },
251 /*Cycle N1*/ { FPMAluC2.rid, 3, 1 },
252 /*Cycle N1*/ { FPMAluC3.rid, 4, 1 },
253 /*Cycle N1*/
254 /*Cycle W */ { FPRegWritePorts.rid, 6, 1 }
255 }
256};
257
258static const InstrClassRUsage FPAClassRUsage = {
259 SPARC_FPA,
260 /*totCycles*/ 7,
261
262 /* maxIssueNum */ 1,
263 /* isSingleIssue */ false,
264 /* breaksGroup */ false,
265 /* numBubbles */ 0,
266
267 /*numSlots*/ 4,
268 /* feasibleSlots[] */ { 0, 1, 2, 3 },
269
270 /*numEntries*/ 7,
271 /* V[] */ {
272 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
273 { FPAIssueSlots.rid, 0, 1 },
274 /*Cycle E */ { FPRegReadPorts.rid, 1, 1 },
275 /*Cycle C */ { FPAAluC1.rid, 2, 1 },
276 /*Cycle N1*/ { FPAAluC2.rid, 3, 1 },
277 /*Cycle N1*/ { FPAAluC3.rid, 4, 1 },
278 /*Cycle N1*/
279 /*Cycle W */ { FPRegWritePorts.rid, 6, 1 }
280 }
281};
282
283static const InstrClassRUsage LDClassRUsage = {
284 SPARC_LD,
285 /*totCycles*/ 7,
286
287 /* maxIssueNum */ 1,
288 /* isSingleIssue */ false,
289 /* breaksGroup */ false,
290 /* numBubbles */ 0,
291
292 /*numSlots*/ 3,
293 /* feasibleSlots[] */ { 0, 1, 2, },
294
295 /*numEntries*/ 6,
296 /* V[] */ {
297 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
298 { First3IssueSlots.rid, 0, 1 },
299 { LSIssueSlots.rid, 0, 1 },
300 /*Cycle E */ { LSAluC1.rid, 1, 1 },
301 /*Cycle C */ { LSAluC2.rid, 2, 1 },
302 { LdReturn.rid, 2, 1 },
303 /*Cycle N1*/
304 /*Cycle N1*/
305 /*Cycle N1*/
306 /*Cycle W */ { IRegWritePorts.rid, 6, 1 }
307 }
308};
309
310static const InstrClassRUsage STClassRUsage = {
311 SPARC_ST,
312 /*totCycles*/ 7,
313
314 /* maxIssueNum */ 1,
315 /* isSingleIssue */ false,
316 /* breaksGroup */ false,
317 /* numBubbles */ 0,
318
319 /*numSlots*/ 3,
320 /* feasibleSlots[] */ { 0, 1, 2 },
321
322 /*numEntries*/ 4,
323 /* V[] */ {
324 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
325 { First3IssueSlots.rid, 0, 1 },
326 { LSIssueSlots.rid, 0, 1 },
327 /*Cycle E */ { LSAluC1.rid, 1, 1 },
328 /*Cycle C */ { LSAluC2.rid, 2, 1 }
329 /*Cycle N1*/
330 /*Cycle N1*/
331 /*Cycle N1*/
332 /*Cycle W */
333 }
334};
335
336static const InstrClassRUsage CTIClassRUsage = {
337 SPARC_CTI,
338 /*totCycles*/ 7,
339
340 /* maxIssueNum */ 1,
341 /* isSingleIssue */ false,
342 /* breaksGroup */ false,
343 /* numBubbles */ 0,
344
345 /*numSlots*/ 4,
346 /* feasibleSlots[] */ { 0, 1, 2, 3 },
347
348 /*numEntries*/ 4,
349 /* V[] */ {
350 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
351 { CTIIssueSlots.rid, 0, 1 },
352 /*Cycle E */ { IAlu0.rid, 1, 1 },
353 /*Cycles E-C */ { CTIDelayCycle.rid, 1, 2 }
354 /*Cycle C */
355 /*Cycle N1*/
356 /*Cycle N1*/
357 /*Cycle N1*/
358 /*Cycle W */
359 }
360};
361
362static const InstrClassRUsage SingleClassRUsage = {
363 SPARC_SINGLE,
364 /*totCycles*/ 7,
365
366 /* maxIssueNum */ 1,
367 /* isSingleIssue */ true,
368 /* breaksGroup */ false,
369 /* numBubbles */ 0,
370
371 /*numSlots*/ 1,
372 /* feasibleSlots[] */ { 0 },
373
374 /*numEntries*/ 5,
375 /* V[] */ {
376 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
377 { AllIssueSlots.rid, 0, 1 },
378 { AllIssueSlots.rid, 0, 1 },
379 { AllIssueSlots.rid, 0, 1 },
380 /*Cycle E */ { IAlu0.rid, 1, 1 }
381 /*Cycle C */
382 /*Cycle N1*/
383 /*Cycle N1*/
384 /*Cycle N1*/
385 /*Cycle W */
386 }
387};
388
389
390static const InstrClassRUsage SparcRUsageDesc[] = {
391 NoneClassRUsage,
392 IEUNClassRUsage,
393 IEU0ClassRUsage,
394 IEU1ClassRUsage,
395 FPMClassRUsage,
396 FPAClassRUsage,
397 CTIClassRUsage,
398 LDClassRUsage,
399 STClassRUsage,
400 SingleClassRUsage
401};
402
403
404
405//---------------------------------------------------------------------------
406// const InstrIssueDelta SparcInstrIssueDeltas[]
407//
408// Purpose:
409// Changes to issue restrictions information in InstrClassRUsage for
410// instructions that differ from other instructions in their class.
411//---------------------------------------------------------------------------
412
413static const InstrIssueDelta SparcInstrIssueDeltas[] = {
414
415 // opCode, isSingleIssue, breaksGroup, numBubbles
416
417 // Special cases for single-issue only
418 // Other single issue cases are below.
Misha Brukmana98cd452003-05-20 20:32:24 +0000419//{ V9::LDDA, true, true, 0 },
420//{ V9::STDA, true, true, 0 },
421//{ V9::LDDF, true, true, 0 },
422//{ V9::LDDFA, true, true, 0 },
423 { V9::ADDC, true, true, 0 },
424 { V9::ADDCcc, true, true, 0 },
425 { V9::SUBC, true, true, 0 },
426 { V9::SUBCcc, true, true, 0 },
427//{ V9::LDSTUB, true, true, 0 },
428//{ V9::SWAP, true, true, 0 },
429//{ V9::SWAPA, true, true, 0 },
430//{ V9::CAS, true, true, 0 },
431//{ V9::CASA, true, true, 0 },
432//{ V9::CASX, true, true, 0 },
433//{ V9::CASXA, true, true, 0 },
434//{ V9::LDFSR, true, true, 0 },
435//{ V9::LDFSRA, true, true, 0 },
436//{ V9::LDXFSR, true, true, 0 },
437//{ V9::LDXFSRA, true, true, 0 },
438//{ V9::STFSR, true, true, 0 },
439//{ V9::STFSRA, true, true, 0 },
440//{ V9::STXFSR, true, true, 0 },
441//{ V9::STXFSRA, true, true, 0 },
442//{ V9::SAVED, true, true, 0 },
443//{ V9::RESTORED, true, true, 0 },
444//{ V9::FLUSH, true, true, 9 },
445//{ V9::FLUSHW, true, true, 9 },
446//{ V9::ALIGNADDR, true, true, 0 },
447 { V9::RETURN, true, true, 0 },
448//{ V9::DONE, true, true, 0 },
449//{ V9::RETRY, true, true, 0 },
450//{ V9::TCC, true, true, 0 },
451//{ V9::SHUTDOWN, true, true, 0 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000452
453 // Special cases for breaking group *before*
454 // CURRENTLY NOT SUPPORTED!
Misha Brukmana98cd452003-05-20 20:32:24 +0000455 { V9::CALL, false, false, 0 },
456 { V9::JMPLCALL, false, false, 0 },
457 { V9::JMPLRET, false, false, 0 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000458
459 // Special cases for breaking the group *after*
Misha Brukmana98cd452003-05-20 20:32:24 +0000460 { V9::MULX, true, true, (4+34)/2 },
461 { V9::FDIVS, false, true, 0 },
462 { V9::FDIVD, false, true, 0 },
463 { V9::FDIVQ, false, true, 0 },
464 { V9::FSQRTS, false, true, 0 },
465 { V9::FSQRTD, false, true, 0 },
466 { V9::FSQRTQ, false, true, 0 },
467//{ V9::FCMP{LE,GT,NE,EQ}, false, true, 0 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000468
469 // Instructions that introduce bubbles
Misha Brukmana98cd452003-05-20 20:32:24 +0000470//{ V9::MULScc, true, true, 2 },
471//{ V9::SMULcc, true, true, (4+18)/2 },
472//{ V9::UMULcc, true, true, (4+19)/2 },
473 { V9::SDIVX, true, true, 68 },
474 { V9::UDIVX, true, true, 68 },
475//{ V9::SDIVcc, true, true, 36 },
476//{ V9::UDIVcc, true, true, 37 },
477 { V9::WRCCR, true, true, 4 },
478//{ V9::WRPR, true, true, 4 },
479//{ V9::RDCCR, true, true, 0 }, // no bubbles after, but see below
480//{ V9::RDPR, true, true, 0 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000481};
482
483
484
485
486//---------------------------------------------------------------------------
487// const InstrRUsageDelta SparcInstrUsageDeltas[]
488//
489// Purpose:
490// Changes to resource usage information in InstrClassRUsage for
491// instructions that differ from other instructions in their class.
492//---------------------------------------------------------------------------
493
494static const InstrRUsageDelta SparcInstrUsageDeltas[] = {
495
496 // MachineOpCode, Resource, Start cycle, Num cycles
497
498 //
499 // JMPL counts as a load/store instruction for issue!
500 //
Misha Brukmana98cd452003-05-20 20:32:24 +0000501 { V9::JMPLCALL, LSIssueSlots.rid, 0, 1 },
502 { V9::JMPLRET, LSIssueSlots.rid, 0, 1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000503
504 //
505 // Many instructions cannot issue for the next 2 cycles after an FCMP
506 // We model that with a fake resource FCMPDelayCycle.
507 //
Misha Brukmana98cd452003-05-20 20:32:24 +0000508 { V9::FCMPS, FCMPDelayCycle.rid, 1, 3 },
509 { V9::FCMPD, FCMPDelayCycle.rid, 1, 3 },
510 { V9::FCMPQ, FCMPDelayCycle.rid, 1, 3 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000511
Misha Brukmana98cd452003-05-20 20:32:24 +0000512 { V9::MULX, FCMPDelayCycle.rid, 1, 1 },
513 { V9::SDIVX, FCMPDelayCycle.rid, 1, 1 },
514 { V9::UDIVX, FCMPDelayCycle.rid, 1, 1 },
515//{ V9::SMULcc, FCMPDelayCycle.rid, 1, 1 },
516//{ V9::UMULcc, FCMPDelayCycle.rid, 1, 1 },
517//{ V9::SDIVcc, FCMPDelayCycle.rid, 1, 1 },
518//{ V9::UDIVcc, FCMPDelayCycle.rid, 1, 1 },
519 { V9::STD, FCMPDelayCycle.rid, 1, 1 },
520 { V9::FMOVRSZ, FCMPDelayCycle.rid, 1, 1 },
521 { V9::FMOVRSLEZ,FCMPDelayCycle.rid, 1, 1 },
522 { V9::FMOVRSLZ, FCMPDelayCycle.rid, 1, 1 },
523 { V9::FMOVRSNZ, FCMPDelayCycle.rid, 1, 1 },
524 { V9::FMOVRSGZ, FCMPDelayCycle.rid, 1, 1 },
525 { V9::FMOVRSGEZ,FCMPDelayCycle.rid, 1, 1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000526
527 //
528 // Some instructions are stalled in the GROUP stage if a CTI is in
529 // the E or C stage. We model that with a fake resource CTIDelayCycle.
530 //
Misha Brukmana98cd452003-05-20 20:32:24 +0000531 { V9::LDD, CTIDelayCycle.rid, 1, 1 },
532//{ V9::LDDA, CTIDelayCycle.rid, 1, 1 },
533//{ V9::LDDSTUB, CTIDelayCycle.rid, 1, 1 },
534//{ V9::LDDSTUBA, CTIDelayCycle.rid, 1, 1 },
535//{ V9::SWAP, CTIDelayCycle.rid, 1, 1 },
536//{ V9::SWAPA, CTIDelayCycle.rid, 1, 1 },
537//{ V9::CAS, CTIDelayCycle.rid, 1, 1 },
538//{ V9::CASA, CTIDelayCycle.rid, 1, 1 },
539//{ V9::CASX, CTIDelayCycle.rid, 1, 1 },
540//{ V9::CASXA, CTIDelayCycle.rid, 1, 1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000541
542 //
543 // Signed int loads of less than dword size return data in cycle N1 (not C)
544 // and put all loads in consecutive cycles into delayed load return mode.
545 //
Misha Brukmana98cd452003-05-20 20:32:24 +0000546 { V9::LDSB, LdReturn.rid, 2, -1 },
547 { V9::LDSB, LdReturn.rid, 3, 1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000548
Misha Brukmana98cd452003-05-20 20:32:24 +0000549 { V9::LDSH, LdReturn.rid, 2, -1 },
550 { V9::LDSH, LdReturn.rid, 3, 1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000551
Misha Brukmana98cd452003-05-20 20:32:24 +0000552 { V9::LDSW, LdReturn.rid, 2, -1 },
553 { V9::LDSW, LdReturn.rid, 3, 1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000554
555 //
556 // RDPR from certain registers and RD from any register are not dispatchable
557 // until four clocks after they reach the head of the instr. buffer.
558 // Together with their single-issue requirement, this means all four issue
559 // slots are effectively blocked for those cycles, plus the issue cycle.
560 // This does not increase the latency of the instruction itself.
561 //
Misha Brukmana98cd452003-05-20 20:32:24 +0000562 { V9::RDCCR, AllIssueSlots.rid, 0, 5 },
563 { V9::RDCCR, AllIssueSlots.rid, 0, 5 },
564 { V9::RDCCR, AllIssueSlots.rid, 0, 5 },
565 { V9::RDCCR, AllIssueSlots.rid, 0, 5 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000566
567#undef EXPLICIT_BUBBLES_NEEDED
568#ifdef EXPLICIT_BUBBLES_NEEDED
569 //
570 // MULScc inserts one bubble.
571 // This means it breaks the current group (captured in UltraSparcSchedInfo)
572 // *and occupies all issue slots for the next cycle
573 //
Misha Brukmana98cd452003-05-20 20:32:24 +0000574//{ V9::MULScc, AllIssueSlots.rid, 2, 2-1 },
575//{ V9::MULScc, AllIssueSlots.rid, 2, 2-1 },
576//{ V9::MULScc, AllIssueSlots.rid, 2, 2-1 },
577//{ V9::MULScc, AllIssueSlots.rid, 2, 2-1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000578
579 //
580 // SMULcc inserts between 4 and 18 bubbles, depending on #leading 0s in rs1.
581 // We just model this with a simple average.
582 //
Misha Brukmana98cd452003-05-20 20:32:24 +0000583//{ V9::SMULcc, AllIssueSlots.rid, 2, ((4+18)/2)-1 },
584//{ V9::SMULcc, AllIssueSlots.rid, 2, ((4+18)/2)-1 },
585//{ V9::SMULcc, AllIssueSlots.rid, 2, ((4+18)/2)-1 },
586//{ V9::SMULcc, AllIssueSlots.rid, 2, ((4+18)/2)-1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000587
588 // SMULcc inserts between 4 and 19 bubbles, depending on #leading 0s in rs1.
Misha Brukmana98cd452003-05-20 20:32:24 +0000589//{ V9::UMULcc, AllIssueSlots.rid, 2, ((4+19)/2)-1 },
590//{ V9::UMULcc, AllIssueSlots.rid, 2, ((4+19)/2)-1 },
591//{ V9::UMULcc, AllIssueSlots.rid, 2, ((4+19)/2)-1 },
592//{ V9::UMULcc, AllIssueSlots.rid, 2, ((4+19)/2)-1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000593
594 //
595 // MULX inserts between 4 and 34 bubbles, depending on #leading 0s in rs1.
596 //
Misha Brukmana98cd452003-05-20 20:32:24 +0000597 { V9::MULX, AllIssueSlots.rid, 2, ((4+34)/2)-1 },
598 { V9::MULX, AllIssueSlots.rid, 2, ((4+34)/2)-1 },
599 { V9::MULX, AllIssueSlots.rid, 2, ((4+34)/2)-1 },
600 { V9::MULX, AllIssueSlots.rid, 2, ((4+34)/2)-1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000601
602 //
603 // SDIVcc inserts 36 bubbles.
604 //
Misha Brukmana98cd452003-05-20 20:32:24 +0000605//{ V9::SDIVcc, AllIssueSlots.rid, 2, 36-1 },
606//{ V9::SDIVcc, AllIssueSlots.rid, 2, 36-1 },
607//{ V9::SDIVcc, AllIssueSlots.rid, 2, 36-1 },
608//{ V9::SDIVcc, AllIssueSlots.rid, 2, 36-1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000609
610 // UDIVcc inserts 37 bubbles.
Misha Brukmana98cd452003-05-20 20:32:24 +0000611//{ V9::UDIVcc, AllIssueSlots.rid, 2, 37-1 },
612//{ V9::UDIVcc, AllIssueSlots.rid, 2, 37-1 },
613//{ V9::UDIVcc, AllIssueSlots.rid, 2, 37-1 },
614//{ V9::UDIVcc, AllIssueSlots.rid, 2, 37-1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000615
616 //
617 // SDIVX inserts 68 bubbles.
618 //
Misha Brukmana98cd452003-05-20 20:32:24 +0000619 { V9::SDIVX, AllIssueSlots.rid, 2, 68-1 },
620 { V9::SDIVX, AllIssueSlots.rid, 2, 68-1 },
621 { V9::SDIVX, AllIssueSlots.rid, 2, 68-1 },
622 { V9::SDIVX, AllIssueSlots.rid, 2, 68-1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000623
624 //
625 // UDIVX inserts 68 bubbles.
626 //
Misha Brukmana98cd452003-05-20 20:32:24 +0000627 { V9::UDIVX, AllIssueSlots.rid, 2, 68-1 },
628 { V9::UDIVX, AllIssueSlots.rid, 2, 68-1 },
629 { V9::UDIVX, AllIssueSlots.rid, 2, 68-1 },
630 { V9::UDIVX, AllIssueSlots.rid, 2, 68-1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000631
632 //
633 // WR inserts 4 bubbles.
634 //
Misha Brukmana98cd452003-05-20 20:32:24 +0000635//{ V9::WR, AllIssueSlots.rid, 2, 68-1 },
636//{ V9::WR, AllIssueSlots.rid, 2, 68-1 },
637//{ V9::WR, AllIssueSlots.rid, 2, 68-1 },
638//{ V9::WR, AllIssueSlots.rid, 2, 68-1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000639
640 //
641 // WRPR inserts 4 bubbles.
642 //
Misha Brukmana98cd452003-05-20 20:32:24 +0000643//{ V9::WRPR, AllIssueSlots.rid, 2, 68-1 },
644//{ V9::WRPR, AllIssueSlots.rid, 2, 68-1 },
645//{ V9::WRPR, AllIssueSlots.rid, 2, 68-1 },
646//{ V9::WRPR, AllIssueSlots.rid, 2, 68-1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000647
648 //
649 // DONE inserts 9 bubbles.
650 //
Misha Brukmana98cd452003-05-20 20:32:24 +0000651//{ V9::DONE, AllIssueSlots.rid, 2, 9-1 },
652//{ V9::DONE, AllIssueSlots.rid, 2, 9-1 },
653//{ V9::DONE, AllIssueSlots.rid, 2, 9-1 },
654//{ V9::DONE, AllIssueSlots.rid, 2, 9-1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000655
656 //
657 // RETRY inserts 9 bubbles.
658 //
Misha Brukmana98cd452003-05-20 20:32:24 +0000659//{ V9::RETRY, AllIssueSlots.rid, 2, 9-1 },
660//{ V9::RETRY, AllIssueSlots.rid, 2, 9-1 },
661//{ V9::RETRY, AllIssueSlots.rid, 2, 9-1 },
662//{ V9::RETRY, AllIssueSlots.rid, 2, 9-1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000663
664#endif /*EXPLICIT_BUBBLES_NEEDED */
665};
666
667// Additional delays to be captured in code:
668// 1. RDPR from several state registers (page 349)
669// 2. RD from *any* register (page 349)
670// 3. Writes to TICK, PSTATE, TL registers and FLUSH{W} instr (page 349)
671// 4. Integer store can be in same group as instr producing value to store.
672// 5. BICC and BPICC can be in the same group as instr producing CC (pg 350)
673// 6. FMOVr cannot be in the same or next group as an IEU instr (pg 351).
674// 7. The second instr. of a CTI group inserts 9 bubbles (pg 351)
675// 8. WR{PR}, SVAE, SAVED, RESTORE, RESTORED, RETURN, RETRY, and DONE that
676// follow an annulling branch cannot be issued in the same group or in
677// the 3 groups following the branch.
678// 9. A predicted annulled load does not stall dependent instructions.
679// Other annulled delay slot instructions *do* stall dependents, so
680// nothing special needs to be done for them during scheduling.
681//10. Do not put a load use that may be annulled in the same group as the
682// branch. The group will stall until the load returns.
683//11. Single-prec. FP loads lock 2 registers, for dependency checking.
684//
685//
686// Additional delays we cannot or will not capture:
687// 1. If DCTI is last word of cache line, it is delayed until next line can be
688// fetched. Also, other DCTI alignment-related delays (pg 352)
689// 2. Load-after-store is delayed by 7 extra cycles if load hits in D-Cache.
690// Also, several other store-load and load-store conflicts (pg 358)
691// 3. MEMBAR, LD{X}FSR, LDD{A} and a bunch of other load stalls (pg 358)
692// 4. There can be at most 8 outstanding buffered store instructions
693// (including some others like MEMBAR, LDSTUB, CAS{AX}, and FLUSH)
694
695
696
697//---------------------------------------------------------------------------
698// class UltraSparcSchedInfo
699//
700// Purpose:
701// Scheduling information for the UltraSPARC.
702// Primarily just initializes machine-dependent parameters in
Chris Lattnerd0f166a2002-12-29 03:13:05 +0000703// class TargetSchedInfo.
Chris Lattner6b04e712002-02-04 00:39:14 +0000704//---------------------------------------------------------------------------
705
706/*ctor*/
707UltraSparcSchedInfo::UltraSparcSchedInfo(const TargetMachine& tgt)
Chris Lattnerd0f166a2002-12-29 03:13:05 +0000708 : TargetSchedInfo(tgt,
Chris Lattner6b04e712002-02-04 00:39:14 +0000709 (unsigned int) SPARC_NUM_SCHED_CLASSES,
710 SparcRUsageDesc,
711 SparcInstrUsageDeltas,
712 SparcInstrIssueDeltas,
713 sizeof(SparcInstrUsageDeltas)/sizeof(InstrRUsageDelta),
714 sizeof(SparcInstrIssueDeltas)/sizeof(InstrIssueDelta))
715{
716 maxNumIssueTotal = 4;
717 longestIssueConflict = 0; // computed from issuesGaps[]
718
719 branchMispredictPenalty = 4; // 4 for SPARC IIi
720 branchTargetUnknownPenalty = 2; // 2 for SPARC IIi
721 l1DCacheMissPenalty = 8; // 7 or 9 for SPARC IIi
722 l1ICacheMissPenalty = 8; // ? for SPARC IIi
723
724 inOrderLoads = true; // true for SPARC IIi
725 inOrderIssue = true; // true for SPARC IIi
726 inOrderExec = false; // false for most architectures
727 inOrderRetire= true; // true for most architectures
728
729 // must be called after above parameters are initialized.
730 initializeResources();
731}
732
733void
734UltraSparcSchedInfo::initializeResources()
735{
Chris Lattnerd0f166a2002-12-29 03:13:05 +0000736 // Compute TargetSchedInfo::instrRUsages and TargetSchedInfo::issueGaps
737 TargetSchedInfo::initializeResources();
Chris Lattner6b04e712002-02-04 00:39:14 +0000738
739 // Machine-dependent fixups go here. None for now.
740}