blob: 3cd7d9cf4545084ac1ec70da6ecfe82efab5dbd7 [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 },
Misha Brukman24b22a12003-05-27 22:33:39 +0000423 { V9::ADDCr, true, true, 0 },
424 { V9::ADDCi, true, true, 0 },
425 { V9::ADDCccr, true, true, 0 },
426 { V9::ADDCcci, true, true, 0 },
427 { V9::SUBCr, true, true, 0 },
428 { V9::SUBCi, true, true, 0 },
429 { V9::SUBCccr, true, true, 0 },
430 { V9::SUBCcci, true, true, 0 },
Misha Brukmana98cd452003-05-20 20:32:24 +0000431//{ V9::LDSTUB, true, true, 0 },
432//{ V9::SWAP, true, true, 0 },
433//{ V9::SWAPA, true, true, 0 },
434//{ V9::CAS, true, true, 0 },
435//{ V9::CASA, true, true, 0 },
436//{ V9::CASX, true, true, 0 },
437//{ V9::CASXA, true, true, 0 },
438//{ V9::LDFSR, true, true, 0 },
439//{ V9::LDFSRA, true, true, 0 },
440//{ V9::LDXFSR, true, true, 0 },
441//{ V9::LDXFSRA, true, true, 0 },
442//{ V9::STFSR, true, true, 0 },
443//{ V9::STFSRA, true, true, 0 },
444//{ V9::STXFSR, true, true, 0 },
445//{ V9::STXFSRA, true, true, 0 },
446//{ V9::SAVED, true, true, 0 },
447//{ V9::RESTORED, true, true, 0 },
448//{ V9::FLUSH, true, true, 9 },
449//{ V9::FLUSHW, true, true, 9 },
450//{ V9::ALIGNADDR, true, true, 0 },
Misha Brukman24b22a12003-05-27 22:33:39 +0000451 { V9::RETURNr, true, true, 0 },
452 { V9::RETURNi, true, true, 0 },
Misha Brukmana98cd452003-05-20 20:32:24 +0000453//{ V9::DONE, true, true, 0 },
454//{ V9::RETRY, true, true, 0 },
455//{ V9::TCC, true, true, 0 },
456//{ V9::SHUTDOWN, true, true, 0 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000457
458 // Special cases for breaking group *before*
459 // CURRENTLY NOT SUPPORTED!
Misha Brukmana98cd452003-05-20 20:32:24 +0000460 { V9::CALL, false, false, 0 },
Misha Brukman24b22a12003-05-27 22:33:39 +0000461 { V9::JMPLCALLr, false, false, 0 },
462 { V9::JMPLCALLi, false, false, 0 },
463 { V9::JMPLRETr, false, false, 0 },
464 { V9::JMPLRETi, false, false, 0 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000465
466 // Special cases for breaking the group *after*
Misha Brukman24b22a12003-05-27 22:33:39 +0000467 { V9::MULXr, true, true, (4+34)/2 },
468 { V9::MULXi, true, true, (4+34)/2 },
Misha Brukmana98cd452003-05-20 20:32:24 +0000469 { V9::FDIVS, false, true, 0 },
470 { V9::FDIVD, false, true, 0 },
471 { V9::FDIVQ, false, true, 0 },
472 { V9::FSQRTS, false, true, 0 },
473 { V9::FSQRTD, false, true, 0 },
474 { V9::FSQRTQ, false, true, 0 },
475//{ V9::FCMP{LE,GT,NE,EQ}, false, true, 0 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000476
477 // Instructions that introduce bubbles
Misha Brukmana98cd452003-05-20 20:32:24 +0000478//{ V9::MULScc, true, true, 2 },
479//{ V9::SMULcc, true, true, (4+18)/2 },
480//{ V9::UMULcc, true, true, (4+19)/2 },
Misha Brukman24b22a12003-05-27 22:33:39 +0000481 { V9::SDIVXr, true, true, 68 },
482 { V9::SDIVXi, true, true, 68 },
483 { V9::UDIVXr, true, true, 68 },
484 { V9::UDIVXi, true, true, 68 },
Misha Brukmana98cd452003-05-20 20:32:24 +0000485//{ V9::SDIVcc, true, true, 36 },
486//{ V9::UDIVcc, true, true, 37 },
487 { V9::WRCCR, true, true, 4 },
488//{ V9::WRPR, true, true, 4 },
489//{ V9::RDCCR, true, true, 0 }, // no bubbles after, but see below
490//{ V9::RDPR, true, true, 0 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000491};
492
493
494
495
496//---------------------------------------------------------------------------
497// const InstrRUsageDelta SparcInstrUsageDeltas[]
498//
499// Purpose:
500// Changes to resource usage information in InstrClassRUsage for
501// instructions that differ from other instructions in their class.
502//---------------------------------------------------------------------------
503
504static const InstrRUsageDelta SparcInstrUsageDeltas[] = {
505
506 // MachineOpCode, Resource, Start cycle, Num cycles
507
508 //
509 // JMPL counts as a load/store instruction for issue!
510 //
Misha Brukman24b22a12003-05-27 22:33:39 +0000511 { V9::JMPLCALLr, LSIssueSlots.rid, 0, 1 },
512 { V9::JMPLCALLi, LSIssueSlots.rid, 0, 1 },
513 { V9::JMPLRETr, LSIssueSlots.rid, 0, 1 },
514 { V9::JMPLRETi, LSIssueSlots.rid, 0, 1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000515
516 //
517 // Many instructions cannot issue for the next 2 cycles after an FCMP
518 // We model that with a fake resource FCMPDelayCycle.
519 //
Misha Brukmana98cd452003-05-20 20:32:24 +0000520 { V9::FCMPS, FCMPDelayCycle.rid, 1, 3 },
521 { V9::FCMPD, FCMPDelayCycle.rid, 1, 3 },
522 { V9::FCMPQ, FCMPDelayCycle.rid, 1, 3 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000523
Misha Brukman24b22a12003-05-27 22:33:39 +0000524 { V9::MULXr, FCMPDelayCycle.rid, 1, 1 },
525 { V9::MULXi, FCMPDelayCycle.rid, 1, 1 },
526 { V9::SDIVXr, FCMPDelayCycle.rid, 1, 1 },
527 { V9::SDIVXi, FCMPDelayCycle.rid, 1, 1 },
528 { V9::UDIVXr, FCMPDelayCycle.rid, 1, 1 },
529 { V9::UDIVXi, FCMPDelayCycle.rid, 1, 1 },
Misha Brukmana98cd452003-05-20 20:32:24 +0000530//{ V9::SMULcc, FCMPDelayCycle.rid, 1, 1 },
531//{ V9::UMULcc, FCMPDelayCycle.rid, 1, 1 },
532//{ V9::SDIVcc, FCMPDelayCycle.rid, 1, 1 },
533//{ V9::UDIVcc, FCMPDelayCycle.rid, 1, 1 },
Misha Brukman24b22a12003-05-27 22:33:39 +0000534 { V9::STDFr, FCMPDelayCycle.rid, 1, 1 },
535 { V9::STDFi, FCMPDelayCycle.rid, 1, 1 },
Misha Brukmana98cd452003-05-20 20:32:24 +0000536 { V9::FMOVRSZ, FCMPDelayCycle.rid, 1, 1 },
537 { V9::FMOVRSLEZ,FCMPDelayCycle.rid, 1, 1 },
538 { V9::FMOVRSLZ, FCMPDelayCycle.rid, 1, 1 },
539 { V9::FMOVRSNZ, FCMPDelayCycle.rid, 1, 1 },
540 { V9::FMOVRSGZ, FCMPDelayCycle.rid, 1, 1 },
541 { V9::FMOVRSGEZ,FCMPDelayCycle.rid, 1, 1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000542
543 //
544 // Some instructions are stalled in the GROUP stage if a CTI is in
545 // the E or C stage. We model that with a fake resource CTIDelayCycle.
546 //
Misha Brukman24b22a12003-05-27 22:33:39 +0000547 { V9::LDDFr, CTIDelayCycle.rid, 1, 1 },
548 { V9::LDDFi, CTIDelayCycle.rid, 1, 1 },
Misha Brukmana98cd452003-05-20 20:32:24 +0000549//{ V9::LDDA, CTIDelayCycle.rid, 1, 1 },
550//{ V9::LDDSTUB, CTIDelayCycle.rid, 1, 1 },
551//{ V9::LDDSTUBA, CTIDelayCycle.rid, 1, 1 },
552//{ V9::SWAP, CTIDelayCycle.rid, 1, 1 },
553//{ V9::SWAPA, CTIDelayCycle.rid, 1, 1 },
554//{ V9::CAS, CTIDelayCycle.rid, 1, 1 },
555//{ V9::CASA, CTIDelayCycle.rid, 1, 1 },
556//{ V9::CASX, CTIDelayCycle.rid, 1, 1 },
557//{ V9::CASXA, CTIDelayCycle.rid, 1, 1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000558
559 //
560 // Signed int loads of less than dword size return data in cycle N1 (not C)
561 // and put all loads in consecutive cycles into delayed load return mode.
562 //
Misha Brukman24b22a12003-05-27 22:33:39 +0000563 { V9::LDSBr, LdReturn.rid, 2, -1 },
564 { V9::LDSBr, LdReturn.rid, 3, 1 },
565 { V9::LDSBi, LdReturn.rid, 2, -1 },
566 { V9::LDSBi, LdReturn.rid, 3, 1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000567
Misha Brukman24b22a12003-05-27 22:33:39 +0000568 { V9::LDSHr, LdReturn.rid, 2, -1 },
569 { V9::LDSHr, LdReturn.rid, 3, 1 },
570 { V9::LDSHi, LdReturn.rid, 2, -1 },
571 { V9::LDSHi, LdReturn.rid, 3, 1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000572
Misha Brukman24b22a12003-05-27 22:33:39 +0000573 { V9::LDSWr, LdReturn.rid, 2, -1 },
574 { V9::LDSWr, LdReturn.rid, 3, 1 },
575 { V9::LDSWi, LdReturn.rid, 2, -1 },
576 { V9::LDSWi, LdReturn.rid, 3, 1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000577
578 //
579 // RDPR from certain registers and RD from any register are not dispatchable
580 // until four clocks after they reach the head of the instr. buffer.
581 // Together with their single-issue requirement, this means all four issue
582 // slots are effectively blocked for those cycles, plus the issue cycle.
583 // This does not increase the latency of the instruction itself.
584 //
Misha Brukmana98cd452003-05-20 20:32:24 +0000585 { V9::RDCCR, AllIssueSlots.rid, 0, 5 },
586 { V9::RDCCR, AllIssueSlots.rid, 0, 5 },
587 { V9::RDCCR, AllIssueSlots.rid, 0, 5 },
588 { V9::RDCCR, AllIssueSlots.rid, 0, 5 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000589
590#undef EXPLICIT_BUBBLES_NEEDED
591#ifdef EXPLICIT_BUBBLES_NEEDED
592 //
593 // MULScc inserts one bubble.
594 // This means it breaks the current group (captured in UltraSparcSchedInfo)
595 // *and occupies all issue slots for the next cycle
596 //
Misha Brukmana98cd452003-05-20 20:32:24 +0000597//{ V9::MULScc, AllIssueSlots.rid, 2, 2-1 },
598//{ V9::MULScc, AllIssueSlots.rid, 2, 2-1 },
599//{ V9::MULScc, AllIssueSlots.rid, 2, 2-1 },
Misha Brukman24b22a12003-05-27 22:33:39 +0000600//{ V9::MULScc, AllIssueSlots.rid, 2, 2-1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000601
602 //
603 // SMULcc inserts between 4 and 18 bubbles, depending on #leading 0s in rs1.
604 // We just model this with a simple average.
605 //
Misha Brukmana98cd452003-05-20 20:32:24 +0000606//{ V9::SMULcc, AllIssueSlots.rid, 2, ((4+18)/2)-1 },
607//{ V9::SMULcc, AllIssueSlots.rid, 2, ((4+18)/2)-1 },
608//{ V9::SMULcc, AllIssueSlots.rid, 2, ((4+18)/2)-1 },
Misha Brukman24b22a12003-05-27 22:33:39 +0000609//{ V9::SMULcc, AllIssueSlots.rid, 2, ((4+18)/2)-1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000610
611 // SMULcc inserts between 4 and 19 bubbles, depending on #leading 0s in rs1.
Misha Brukmana98cd452003-05-20 20:32:24 +0000612//{ V9::UMULcc, AllIssueSlots.rid, 2, ((4+19)/2)-1 },
613//{ V9::UMULcc, AllIssueSlots.rid, 2, ((4+19)/2)-1 },
614//{ V9::UMULcc, AllIssueSlots.rid, 2, ((4+19)/2)-1 },
Misha Brukman24b22a12003-05-27 22:33:39 +0000615//{ V9::UMULcc, AllIssueSlots.rid, 2, ((4+19)/2)-1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000616
617 //
618 // MULX inserts between 4 and 34 bubbles, depending on #leading 0s in rs1.
619 //
Misha Brukmana98cd452003-05-20 20:32:24 +0000620 { V9::MULX, AllIssueSlots.rid, 2, ((4+34)/2)-1 },
621 { V9::MULX, AllIssueSlots.rid, 2, ((4+34)/2)-1 },
622 { V9::MULX, AllIssueSlots.rid, 2, ((4+34)/2)-1 },
Misha Brukman24b22a12003-05-27 22:33:39 +0000623 { V9::MULX, AllIssueSlots.rid, 2, ((4+34)/2)-1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000624
625 //
626 // SDIVcc inserts 36 bubbles.
627 //
Misha Brukmana98cd452003-05-20 20:32:24 +0000628//{ V9::SDIVcc, AllIssueSlots.rid, 2, 36-1 },
629//{ V9::SDIVcc, AllIssueSlots.rid, 2, 36-1 },
630//{ V9::SDIVcc, AllIssueSlots.rid, 2, 36-1 },
Misha Brukman24b22a12003-05-27 22:33:39 +0000631//{ V9::SDIVcc, AllIssueSlots.rid, 2, 36-1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000632
633 // UDIVcc inserts 37 bubbles.
Misha Brukmana98cd452003-05-20 20:32:24 +0000634//{ V9::UDIVcc, AllIssueSlots.rid, 2, 37-1 },
635//{ V9::UDIVcc, AllIssueSlots.rid, 2, 37-1 },
636//{ V9::UDIVcc, AllIssueSlots.rid, 2, 37-1 },
Misha Brukman24b22a12003-05-27 22:33:39 +0000637//{ V9::UDIVcc, AllIssueSlots.rid, 2, 37-1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000638
639 //
640 // SDIVX inserts 68 bubbles.
641 //
Misha Brukmana98cd452003-05-20 20:32:24 +0000642 { V9::SDIVX, AllIssueSlots.rid, 2, 68-1 },
643 { V9::SDIVX, AllIssueSlots.rid, 2, 68-1 },
644 { V9::SDIVX, AllIssueSlots.rid, 2, 68-1 },
Misha Brukman24b22a12003-05-27 22:33:39 +0000645 { V9::SDIVX, AllIssueSlots.rid, 2, 68-1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000646
647 //
648 // UDIVX inserts 68 bubbles.
649 //
Misha Brukmana98cd452003-05-20 20:32:24 +0000650 { V9::UDIVX, AllIssueSlots.rid, 2, 68-1 },
651 { V9::UDIVX, AllIssueSlots.rid, 2, 68-1 },
652 { V9::UDIVX, AllIssueSlots.rid, 2, 68-1 },
Misha Brukman24b22a12003-05-27 22:33:39 +0000653 { V9::UDIVX, AllIssueSlots.rid, 2, 68-1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000654
655 //
656 // WR inserts 4 bubbles.
657 //
Misha Brukmana98cd452003-05-20 20:32:24 +0000658//{ V9::WR, AllIssueSlots.rid, 2, 68-1 },
659//{ V9::WR, AllIssueSlots.rid, 2, 68-1 },
660//{ V9::WR, AllIssueSlots.rid, 2, 68-1 },
Misha Brukman24b22a12003-05-27 22:33:39 +0000661//{ V9::WR, AllIssueSlots.rid, 2, 68-1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000662
663 //
664 // WRPR inserts 4 bubbles.
665 //
Misha Brukmana98cd452003-05-20 20:32:24 +0000666//{ V9::WRPR, AllIssueSlots.rid, 2, 68-1 },
667//{ V9::WRPR, AllIssueSlots.rid, 2, 68-1 },
668//{ V9::WRPR, AllIssueSlots.rid, 2, 68-1 },
Misha Brukman24b22a12003-05-27 22:33:39 +0000669//{ V9::WRPR, AllIssueSlots.rid, 2, 68-1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000670
671 //
672 // DONE inserts 9 bubbles.
673 //
Misha Brukmana98cd452003-05-20 20:32:24 +0000674//{ V9::DONE, AllIssueSlots.rid, 2, 9-1 },
675//{ V9::DONE, AllIssueSlots.rid, 2, 9-1 },
676//{ V9::DONE, AllIssueSlots.rid, 2, 9-1 },
677//{ V9::DONE, AllIssueSlots.rid, 2, 9-1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000678
679 //
680 // RETRY inserts 9 bubbles.
681 //
Misha Brukmana98cd452003-05-20 20:32:24 +0000682//{ V9::RETRY, AllIssueSlots.rid, 2, 9-1 },
683//{ V9::RETRY, AllIssueSlots.rid, 2, 9-1 },
684//{ V9::RETRY, AllIssueSlots.rid, 2, 9-1 },
Misha Brukman24b22a12003-05-27 22:33:39 +0000685//{ V9::RETRY, AllIssueSlots.rid, 2, 9-1 },
Chris Lattner6b04e712002-02-04 00:39:14 +0000686
687#endif /*EXPLICIT_BUBBLES_NEEDED */
688};
689
690// Additional delays to be captured in code:
691// 1. RDPR from several state registers (page 349)
692// 2. RD from *any* register (page 349)
693// 3. Writes to TICK, PSTATE, TL registers and FLUSH{W} instr (page 349)
694// 4. Integer store can be in same group as instr producing value to store.
695// 5. BICC and BPICC can be in the same group as instr producing CC (pg 350)
696// 6. FMOVr cannot be in the same or next group as an IEU instr (pg 351).
697// 7. The second instr. of a CTI group inserts 9 bubbles (pg 351)
698// 8. WR{PR}, SVAE, SAVED, RESTORE, RESTORED, RETURN, RETRY, and DONE that
699// follow an annulling branch cannot be issued in the same group or in
700// the 3 groups following the branch.
701// 9. A predicted annulled load does not stall dependent instructions.
702// Other annulled delay slot instructions *do* stall dependents, so
703// nothing special needs to be done for them during scheduling.
704//10. Do not put a load use that may be annulled in the same group as the
705// branch. The group will stall until the load returns.
706//11. Single-prec. FP loads lock 2 registers, for dependency checking.
707//
708//
709// Additional delays we cannot or will not capture:
710// 1. If DCTI is last word of cache line, it is delayed until next line can be
711// fetched. Also, other DCTI alignment-related delays (pg 352)
712// 2. Load-after-store is delayed by 7 extra cycles if load hits in D-Cache.
713// Also, several other store-load and load-store conflicts (pg 358)
714// 3. MEMBAR, LD{X}FSR, LDD{A} and a bunch of other load stalls (pg 358)
715// 4. There can be at most 8 outstanding buffered store instructions
716// (including some others like MEMBAR, LDSTUB, CAS{AX}, and FLUSH)
717
718
719
720//---------------------------------------------------------------------------
721// class UltraSparcSchedInfo
722//
723// Purpose:
724// Scheduling information for the UltraSPARC.
725// Primarily just initializes machine-dependent parameters in
Chris Lattnerd0f166a2002-12-29 03:13:05 +0000726// class TargetSchedInfo.
Chris Lattner6b04e712002-02-04 00:39:14 +0000727//---------------------------------------------------------------------------
728
729/*ctor*/
730UltraSparcSchedInfo::UltraSparcSchedInfo(const TargetMachine& tgt)
Chris Lattnerd0f166a2002-12-29 03:13:05 +0000731 : TargetSchedInfo(tgt,
Chris Lattner6b04e712002-02-04 00:39:14 +0000732 (unsigned int) SPARC_NUM_SCHED_CLASSES,
733 SparcRUsageDesc,
734 SparcInstrUsageDeltas,
735 SparcInstrIssueDeltas,
736 sizeof(SparcInstrUsageDeltas)/sizeof(InstrRUsageDelta),
737 sizeof(SparcInstrIssueDeltas)/sizeof(InstrIssueDelta))
738{
739 maxNumIssueTotal = 4;
740 longestIssueConflict = 0; // computed from issuesGaps[]
741
742 branchMispredictPenalty = 4; // 4 for SPARC IIi
743 branchTargetUnknownPenalty = 2; // 2 for SPARC IIi
744 l1DCacheMissPenalty = 8; // 7 or 9 for SPARC IIi
745 l1ICacheMissPenalty = 8; // ? for SPARC IIi
746
747 inOrderLoads = true; // true for SPARC IIi
748 inOrderIssue = true; // true for SPARC IIi
749 inOrderExec = false; // false for most architectures
750 inOrderRetire= true; // true for most architectures
751
752 // must be called after above parameters are initialized.
753 initializeResources();
754}
755
756void
757UltraSparcSchedInfo::initializeResources()
758{
Chris Lattnerd0f166a2002-12-29 03:13:05 +0000759 // Compute TargetSchedInfo::instrRUsages and TargetSchedInfo::issueGaps
760 TargetSchedInfo::initializeResources();
Chris Lattner6b04e712002-02-04 00:39:14 +0000761
762 // Machine-dependent fixups go here. None for now.
763}