blob: e19d3044953107271a7ced509eb51b05b56f58b5 [file] [log] [blame]
Chris Lattnerc6495ee2001-09-14 03:56:45 +00001//===-- SparcInternals.h - Header file for Sparc backend ---------*- C++ -*--=//
2//
3// This file defines stuff that is to be private to the Sparc backend, but is
4// shared among different portions of the backend.
5//
6//===----------------------------------------------------------------------===//
7
8#ifndef SPARC_INTERNALS_H
9#define SPARC_INTERNALS_H
10
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +000011
12#include "SparcRegClassInfo.h"
13#include "llvm/Target/TargetMachine.h"
14#include "llvm/Target/MachineInstrInfo.h"
15
Vikram S. Adve339084b2001-09-18 13:04:24 +000016#include "llvm/Target/MachineSchedInfo.h"
Ruchira Sasankaab304c42001-09-30 23:19:57 +000017#include "llvm/CodeGen/RegClass.h"
Chris Lattnerc6495ee2001-09-14 03:56:45 +000018#include "llvm/Type.h"
Vikram S. Adve339084b2001-09-18 13:04:24 +000019
Chris Lattner46cbff62001-09-14 16:56:32 +000020#include <sys/types.h>
Chris Lattnerc6495ee2001-09-14 03:56:45 +000021
Chris Lattnerf6e0e282001-09-14 04:32:55 +000022class UltraSparc;
23
Chris Lattnerc6495ee2001-09-14 03:56:45 +000024// OpCodeMask definitions for the Sparc V9
25//
26const OpCodeMask Immed = 0x00002000; // immed or reg operand?
27const OpCodeMask Annul = 0x20000000; // annul delay instr?
28const OpCodeMask PredictTaken = 0x00080000; // predict branch taken?
29
30
31enum SparcInstrSchedClass {
32 SPARC_NONE, /* Instructions with no scheduling restrictions */
33 SPARC_IEUN, /* Integer class that can use IEU0 or IEU1 */
34 SPARC_IEU0, /* Integer class IEU0 */
35 SPARC_IEU1, /* Integer class IEU1 */
36 SPARC_FPM, /* FP Multiply or Divide instructions */
37 SPARC_FPA, /* All other FP instructions */
38 SPARC_CTI, /* Control-transfer instructions */
39 SPARC_LD, /* Load instructions */
40 SPARC_ST, /* Store instructions */
41 SPARC_SINGLE, /* Instructions that must issue by themselves */
42
43 SPARC_INV, /* This should stay at the end for the next value */
44 SPARC_NUM_SCHED_CLASSES = SPARC_INV
45};
46
Chris Lattnerc6495ee2001-09-14 03:56:45 +000047
48//---------------------------------------------------------------------------
49// enum SparcMachineOpCode.
50// const MachineInstrDescriptor SparcMachineInstrDesc[]
51//
52// Purpose:
53// Description of UltraSparc machine instructions.
54//
55//---------------------------------------------------------------------------
56
Chris Lattnerc6495ee2001-09-14 03:56:45 +000057enum SparcMachineOpCode {
Chris Lattner9a3d63b2001-09-19 15:56:23 +000058#define I(ENUM, OPCODESTRING, NUMOPERANDS, RESULTPOS, MAXIMM, IMMSE, \
59 NUMDELAYSLOTS, LATENCY, SCHEDCLASS, INSTFLAGS) \
60 ENUM,
61#include "SparcInstr.def"
Chris Lattnerc6495ee2001-09-14 03:56:45 +000062
Chris Lattnerc6495ee2001-09-14 03:56:45 +000063 // End-of-array marker
64 INVALID_OPCODE,
65 NUM_REAL_OPCODES = RETURN+1, // number of valid opcodes
66 NUM_TOTAL_OPCODES = INVALID_OPCODE
67};
68
Chris Lattnerc6495ee2001-09-14 03:56:45 +000069
Chris Lattner9a3d63b2001-09-19 15:56:23 +000070// Array of machine instruction descriptions...
71extern const MachineInstrDescriptor SparcMachineInstrDesc[];
Chris Lattnerc6495ee2001-09-14 03:56:45 +000072
73
74//---------------------------------------------------------------------------
75// class UltraSparcInstrInfo
76//
77// Purpose:
78// Information about individual instructions.
79// Most information is stored in the SparcMachineInstrDesc array above.
80// Other information is computed on demand, and most such functions
81// default to member functions in base class MachineInstrInfo.
82//---------------------------------------------------------------------------
83
84class UltraSparcInstrInfo : public MachineInstrInfo {
85public:
86 /*ctor*/ UltraSparcInstrInfo();
87
Vikram S. Adve5684c4e2001-10-18 00:02:06 +000088 virtual bool hasResultInterlock (MachineOpCode opCode) const
Chris Lattnerc6495ee2001-09-14 03:56:45 +000089 {
90 // All UltraSPARC instructions have interlocks (note that delay slots
91 // are not considered here).
92 // However, instructions that use the result of an FCMP produce a
93 // 9-cycle stall if they are issued less than 3 cycles after the FCMP.
94 // Force the compiler to insert a software interlock (i.e., gap of
95 // 2 other groups, including NOPs if necessary).
96 return (opCode == FCMPS || opCode == FCMPD || opCode == FCMPQ);
97 }
98
Vikram S. Adve5684c4e2001-10-18 00:02:06 +000099 //-------------------------------------------------------------------------
100 // Code generation support for creating individual machine instructions
101 //-------------------------------------------------------------------------
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000102
Vikram S. Adve5684c4e2001-10-18 00:02:06 +0000103 // Create an instruction sequence to put the constant `val' into
104 // the virtual register `dest'. The generated instructions are
105 // returned in `minstrVec'. Any temporary registers (TmpInstruction)
106 // created are returned in `tempVec'.
107 //
108 virtual void CreateCodeToLoadConst(Value* val,
109 Instruction* dest,
110 vector<MachineInstr*>& minstrVec,
111 vector<TmpInstruction*>& tempVec) const;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000112};
113
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000114
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000115
116class LiveRange;
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000117class UltraSparc;
118
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000119
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000120
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000121class UltraSparcRegInfo : public MachineRegInfo
122{
123
124 private:
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000125
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000126 // The actual register classes in the Sparc
127
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000128 enum RegClassIDs {
129 IntRegClassID,
130 FloatRegClassID,
131 IntCCRegClassID,
132 FloatCCRegClassID
133 };
134
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000135
136 // Type of registers available in Sparc. There can be several reg types
137 // in the same class. For instace, the float reg class has Single/Double
138 // types
139 enum RegTypes {
140 IntRegType,
141 FPSingleRegType,
142 FPDoubleRegType,
143 IntCCRegType,
144 FloatCCRegType
145 };
146
147
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000148 // WARNING: If the above enum order must be changed, also modify
149 // getRegisterClassOfValue method below since it assumes this particular
150 // order for efficiency.
151
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000152
153 // reverse pointer to get info about the ultra sparc machine
154 const UltraSparc *const UltraSparcInfo;
155
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000156 // Both int and float rguments can be passed in 6 int regs -
157 // %o0 to %o5 (cannot be changed)
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000158 unsigned const NumOfIntArgRegs;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000159 unsigned const NumOfFloatArgRegs;
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000160 int const InvalidRegNum;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000161
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000162 //void setCallArgColor(LiveRange *const LR, const unsigned RegNo) const;
163
164 void setCallOrRetArgCol(LiveRange *const LR, const unsigned RegNo,
165 const MachineInstr *MI,AddedInstrMapType &AIMap)const;
166
167 MachineInstr * getCopy2RegMI(const Value *SrcVal, const unsigned Reg,
168 unsigned RegClassID) const ;
169
Ruchira Sasankacc3ccac2001-10-15 16:25:28 +0000170
171 void suggestReg4RetAddr(const MachineInstr * RetMI,
172 LiveRangeInfo& LRI) const;
173
Ruchira Sasankab3b6f532001-10-21 16:43:41 +0000174 void suggestReg4CallAddr(const MachineInstr * CallMI, LiveRangeInfo& LRI,
175 vector<RegClass *> RCList) const;
Ruchira Sasankacc3ccac2001-10-15 16:25:28 +0000176
177
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000178 Value *getValue4ReturnAddr( const MachineInstr * MInst ) const ;
179
180 int getRegType(const LiveRange *const LR) const {
181
182 unsigned Typ;
183
184 switch( (LR->getRegClass())->getID() ) {
185
186 case IntRegClassID: return IntRegType;
187
188 case FloatRegClassID:
189 Typ = LR->getTypeID();
190 if( Typ == Type::FloatTyID )
191 return FPSingleRegType;
192 else if( Typ == Type::DoubleTyID )
193 return FPDoubleRegType;
194 else assert(0 && "Unknown type in FloatRegClass");
195
196 case IntCCRegClassID: return IntCCRegType;
197
198 case FloatCCRegClassID: return FloatCCRegType ;
199
200 default: assert( 0 && "Unknown reg class ID");
201
202 }
203
204 }
205
206 int getRegType(const Value *const Val) const {
207
208 unsigned Typ;
209
210 switch( getRegClassIDOfValue(Val) ) {
211
212 case IntRegClassID: return IntRegType;
213
214 case FloatRegClassID:
215 Typ = (Val->getType())->getPrimitiveID();
216 if( Typ == Type::FloatTyID )
217 return FPSingleRegType;
218 else if( Typ == Type::DoubleTyID )
219 return FPDoubleRegType;
220 else assert(0 && "Unknown type in FloatRegClass");
221
222 case IntCCRegClassID: return IntCCRegType;
223
224 case FloatCCRegClassID: return FloatCCRegType ;
225
226 default: assert( 0 && "Unknown reg class ID");
227
228 }
229
230 }
231
232
233
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000234 // ***TODO: See this method is necessary
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000235
236 MachineInstr * cpValue2RegMI(Value * Val, const unsigned DestReg,
237 const int RegType) const;
238
Ruchira Sasankab3b6f532001-10-21 16:43:41 +0000239 const Value *getCallInstRetAddr(const MachineInstr *CallMI) const;
240 const unsigned getCallInstNumArgs(const MachineInstr *CallMI) const;
241
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000242
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000243 public:
244
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000245
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000246 UltraSparcRegInfo(const UltraSparc *const USI ) : UltraSparcInfo(USI),
247 NumOfIntArgRegs(6),
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000248 NumOfFloatArgRegs(32),
249 InvalidRegNum(1000)
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000250 {
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000251 MachineRegClassArr.push_back( new SparcIntRegClass(IntRegClassID) );
252 MachineRegClassArr.push_back( new SparcFloatRegClass(FloatRegClassID) );
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000253 MachineRegClassArr.push_back( new SparcIntCCRegClass(IntCCRegClassID) );
254 MachineRegClassArr.push_back( new SparcFloatCCRegClass(FloatCCRegClassID));
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000255
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000256 assert( SparcFloatRegOrder::StartOfNonVolatileRegs == 32 &&
257 "32 Float regs are used for float arg passing");
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000258 }
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000259
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000260 // ***** TODO Delete
261 ~UltraSparcRegInfo(void) { } // empty destructor
262
263
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000264 inline const UltraSparc & getUltraSparcInfo() const {
265 return *UltraSparcInfo;
266 }
267
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000268
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000269
270 inline unsigned getRegClassIDOfValue (const Value *const Val,
271 bool isCCReg = false) const {
272
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000273 Type::PrimitiveID ty = (Val->getType())->getPrimitiveID();
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000274
275 unsigned res;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000276
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000277 if( (ty && ty <= Type::LongTyID) || (ty == Type::LabelTyID) ||
278 (ty == Type::MethodTyID) || (ty == Type::PointerTyID) )
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000279 res = IntRegClassID; // sparc int reg (ty=0: void)
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000280 else if( ty <= Type::DoubleTyID)
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000281 res = FloatRegClassID; // sparc float reg class
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000282 else {
Chris Lattner1e23ed72001-10-15 18:15:27 +0000283 cerr << "TypeID: " << ty << endl;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000284 assert(0 && "Cannot resolve register class for type");
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000285 }
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000286
287 if(isCCReg)
288 return res + 2; // corresponidng condition code regiser
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000289 else
290 return res;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000291 }
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000292
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000293 // returns the register tha contains always zero
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000294 // this is the unified register number
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000295 inline int getZeroRegNum() const { return SparcIntRegOrder::g0; }
296
297 // returns the reg used for pushing the address when a method is called.
298 // This can be used for other purposes between calls
299 unsigned getCallAddressReg() const { return SparcIntRegOrder::o7; }
300
301
302 // and when we return from a method. It should be made sure that this
303 // register contains the return value when a return instruction is reached.
304 unsigned getReturnAddressReg() const { return SparcIntRegOrder::i7; }
305
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000306 void suggestRegs4MethodArgs(const Method *const Meth,
307 LiveRangeInfo& LRI) const;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000308
Ruchira Sasankacc3ccac2001-10-15 16:25:28 +0000309 void suggestRegs4CallArgs(const MachineInstr *const CallMI,
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000310 LiveRangeInfo& LRI, vector<RegClass *> RCL) const;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000311
Ruchira Sasankacc3ccac2001-10-15 16:25:28 +0000312 void suggestReg4RetValue(const MachineInstr *const RetMI,
313 LiveRangeInfo& LRI ) const;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000314
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000315
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000316 void colorMethodArgs(const Method *const Meth, LiveRangeInfo& LRI,
317 AddedInstrns *const FirstAI) const;
318
Ruchira Sasankacc3ccac2001-10-15 16:25:28 +0000319 void colorCallArgs(const MachineInstr *const CallMI, LiveRangeInfo& LRI,
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000320 AddedInstrns *const CallAI) const;
321
Ruchira Sasankacc3ccac2001-10-15 16:25:28 +0000322 void colorRetValue(const MachineInstr *const RetI, LiveRangeInfo& LRI,
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000323 AddedInstrns *const RetAI) const;
324
325
Ruchira Sasankacc3ccac2001-10-15 16:25:28 +0000326 // bool handleSpecialMInstr(const MachineInstr * MInst,
327 // LiveRangeInfo& LRI, vector<RegClass *> RCL) const;
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000328
329
330 static void printReg(const LiveRange *const LR) ;
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000331
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000332 // this method provides a unique number for each register
333 inline int getUnifiedRegNum(int RegClassID, int reg) const {
334
335 if( RegClassID == IntRegClassID && reg < 32 )
336 return reg;
337 else if ( RegClassID == FloatRegClassID && reg < 64)
338 return reg + 32; // we have 32 int regs
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000339 else if( RegClassID == FloatCCRegClassID && reg < 4)
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000340 return reg + 32 + 64; // 32 int, 64 float
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000341 else if( RegClassID == IntCCRegClassID )
342 return 4+ 32 + 64; // only int cc reg
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000343 else if (reg==InvalidRegNum)
344 return InvalidRegNum;
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000345 else
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000346 assert(0 && "Invalid register class or reg number");
347
348 }
349
350 // given the unified register number, this gives the name
351 inline const string getUnifiedRegName(int reg) const {
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000352 if( reg < 32 )
353 return SparcIntRegOrder::getRegName(reg);
354 else if ( reg < (64 + 32) )
355 return SparcFloatRegOrder::getRegName( reg - 32);
356 else if( reg < (64+32+4) )
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000357 return SparcFloatCCRegOrder::getRegName( reg -32 - 64);
358 else if ( reg == 64+32+4)
359 return "xcc"; // only integer cc reg
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000360
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000361 else if (reg== InvalidRegNum) //****** TODO: Remove
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000362 return "<*NoReg*>";
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000363 else
364 assert(0 && "Invalid register number");
365 }
366
367
Ruchira Sasankab3b6f532001-10-21 16:43:41 +0000368 const Value * getCallInstRetVal(const MachineInstr *CallMI) const;
369
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000370 MachineInstr * cpReg2RegMI(const unsigned SrcReg, const unsigned DestReg,
371 const int RegType) const;
372
373 MachineInstr * cpReg2MemMI(const unsigned SrcReg, const unsigned DestPtrReg,
374 const int Offset, const int RegType) const;
375
376 MachineInstr * cpMem2RegMI(const unsigned SrcPtrReg, const int Offset,
377 const unsigned DestReg, const int RegType) const;
378
379 inline bool isRegVolatile(const int RegClassID, const int Reg) const {
380 return (MachineRegClassArr[RegClassID])->isRegVolatile(Reg);
381 }
382
383
384 inline unsigned getFramePointer() const {
385 return SparcIntRegOrder::i6;
386 }
387
388 inline unsigned getStackPointer() const {
389 return SparcIntRegOrder::o6;
390 }
391
392 inline int getInvalidRegNum() const {
393 return InvalidRegNum;
394 }
395
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000396};
397
398
399
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000400/*---------------------------------------------------------------------------
401Scheduling guidelines for SPARC IIi:
402
403I-Cache alignment rules (pg 326)
404-- Align a branch target instruction so that it's entire group is within
405 the same cache line (may be 1-4 instructions).
406** Don't let a branch that is predicted taken be the last instruction
407 on an I-cache line: delay slot will need an entire line to be fetched
408-- Make a FP instruction or a branch be the 4th instruction in a group.
409 For branches, there are tradeoffs in reordering to make this happen
410 (see pg. 327).
411** Don't put a branch in a group that crosses a 32-byte boundary!
412 An artificial branch is inserted after every 32 bytes, and having
413 another branch will force the group to be broken into 2 groups.
414
415iTLB rules:
416-- Don't let a loop span two memory pages, if possible
417
418Branch prediction performance:
419-- Don't make the branch in a delay slot the target of a branch
420-- Try not to have 2 predicted branches within a group of 4 instructions
421 (because each such group has a single branch target field).
422-- Try to align branches in slots 0, 2, 4 or 6 of a cache line (to avoid
423 the wrong prediction bits being used in some cases).
424
425D-Cache timing constraints:
426-- Signed int loads of less than 64 bits have 3 cycle latency, not 2
427-- All other loads that hit in D-Cache have 2 cycle latency
428-- All loads are returned IN ORDER, so a D-Cache miss will delay a later hit
429-- Mis-aligned loads or stores cause a trap. In particular, replace
430 mis-aligned FP double precision l/s with 2 single-precision l/s.
431-- Simulations of integer codes show increase in avg. group size of
432 33% when code (including esp. non-faulting loads) is moved across
433 one branch, and 50% across 2 branches.
434
435E-Cache timing constraints:
436-- Scheduling for E-cache (D-Cache misses) is effective (due to load buffering)
437
438Store buffer timing constraints:
439-- Stores can be executed in same cycle as instruction producing the value
440-- Stores are buffered and have lower priority for E-cache until
441 highwater mark is reached in the store buffer (5 stores)
442
443Pipeline constraints:
444-- Shifts can only use IEU0.
445-- CC setting instructions can only use IEU1.
446-- Several other instructions must only use IEU1:
447 EDGE(?), ARRAY(?), CALL, JMPL, BPr, PST, and FCMP.
448-- Two instructions cannot store to the same register file in a single cycle
449 (single write port per file).
450
451Issue and grouping constraints:
452-- FP and branch instructions must use slot 4.
453-- Shift instructions cannot be grouped with other IEU0-specific instructions.
454-- CC setting instructions cannot be grouped with other IEU1-specific instrs.
455-- Several instructions must be issued in a single-instruction group:
456 MOVcc or MOVr, MULs/x and DIVs/x, SAVE/RESTORE, many others
457-- A CALL or JMPL breaks a group, ie, is not combined with subsequent instrs.
458--
459--
460
461Branch delay slot scheduling rules:
462-- A CTI couple (two back-to-back CTI instructions in the dynamic stream)
463 has a 9-instruction penalty: the entire pipeline is flushed when the
464 second instruction reaches stage 9 (W-Writeback).
465-- Avoid putting multicycle instructions, and instructions that may cause
466 load misses, in the delay slot of an annulling branch.
467-- Avoid putting WR, SAVE..., RESTORE and RETURN instructions in the
468 delay slot of an annulling branch.
469
470 *--------------------------------------------------------------------------- */
471
472//---------------------------------------------------------------------------
473// List of CPUResources for UltraSPARC IIi.
474//---------------------------------------------------------------------------
475
476const CPUResource AllIssueSlots( "All Instr Slots", 4);
477const CPUResource IntIssueSlots( "Int Instr Slots", 3);
478const CPUResource First3IssueSlots("Instr Slots 0-3", 3);
479const CPUResource LSIssueSlots( "Load-Store Instr Slot", 1);
480const CPUResource CTIIssueSlots( "Ctrl Transfer Instr Slot", 1);
481const CPUResource FPAIssueSlots( "Int Instr Slot 1", 1);
482const CPUResource FPMIssueSlots( "Int Instr Slot 1", 1);
483
484// IEUN instructions can use either Alu and should use IAluN.
485// IEU0 instructions must use Alu 1 and should use both IAluN and IAlu0.
486// IEU1 instructions must use Alu 2 and should use both IAluN and IAlu1.
487const CPUResource IAluN("Int ALU 1or2", 2);
488const CPUResource IAlu0("Int ALU 1", 1);
489const CPUResource IAlu1("Int ALU 2", 1);
490
491const CPUResource LSAluC1("Load/Store Unit Addr Cycle", 1);
492const CPUResource LSAluC2("Load/Store Unit Issue Cycle", 1);
493const CPUResource LdReturn("Load Return Unit", 1);
494
495const CPUResource FPMAluC1("FP Mul/Div Alu Cycle 1", 1);
496const CPUResource FPMAluC2("FP Mul/Div Alu Cycle 2", 1);
497const CPUResource FPMAluC3("FP Mul/Div Alu Cycle 3", 1);
498
499const CPUResource FPAAluC1("FP Other Alu Cycle 1", 1);
500const CPUResource FPAAluC2("FP Other Alu Cycle 2", 1);
501const CPUResource FPAAluC3("FP Other Alu Cycle 3", 1);
502
503const CPUResource IRegReadPorts("Int Reg ReadPorts", INT_MAX); // CHECK
504const CPUResource IRegWritePorts("Int Reg WritePorts", 2); // CHECK
505const CPUResource FPRegReadPorts("FP Reg Read Ports", INT_MAX); // CHECK
506const CPUResource FPRegWritePorts("FP Reg Write Ports", 1); // CHECK
507
508const CPUResource CTIDelayCycle( "CTI delay cycle", 1);
509const CPUResource FCMPDelayCycle("FCMP delay cycle", 1);
510
511
512//---------------------------------------------------------------------------
513// const InstrClassRUsage SparcRUsageDesc[]
514//
515// Purpose:
516// Resource usage information for instruction in each scheduling class.
517// The InstrRUsage Objects for individual classes are specified first.
518// Note that fetch and decode are decoupled from the execution pipelines
519// via an instr buffer, so they are not included in the cycles below.
520//---------------------------------------------------------------------------
521
522const InstrClassRUsage NoneClassRUsage = {
523 SPARC_NONE,
524 /*totCycles*/ 7,
525
526 /* maxIssueNum */ 4,
527 /* isSingleIssue */ false,
528 /* breaksGroup */ false,
529 /* numBubbles */ 0,
530
531 /*numSlots*/ 4,
532 /* feasibleSlots[] */ { 0, 1, 2, 3 },
533
534 /*numEntries*/ 0,
535 /* V[] */ {
536 /*Cycle G */
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000537 /*Ccle E */
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000538 /*Cycle C */
539 /*Cycle N1*/
540 /*Cycle N1*/
541 /*Cycle N1*/
542 /*Cycle W */
543 }
544};
545
546const InstrClassRUsage IEUNClassRUsage = {
547 SPARC_IEUN,
548 /*totCycles*/ 7,
549
550 /* maxIssueNum */ 3,
551 /* isSingleIssue */ false,
552 /* breaksGroup */ false,
553 /* numBubbles */ 0,
554
555 /*numSlots*/ 3,
556 /* feasibleSlots[] */ { 0, 1, 2 },
557
558 /*numEntries*/ 4,
559 /* V[] */ {
560 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
561 { IntIssueSlots.rid, 0, 1 },
562 /*Cycle E */ { IAluN.rid, 1, 1 },
563 /*Cycle C */
564 /*Cycle N1*/
565 /*Cycle N1*/
566 /*Cycle N1*/
567 /*Cycle W */ { IRegWritePorts.rid, 6, 1 }
568 }
569};
570
571const InstrClassRUsage IEU0ClassRUsage = {
572 SPARC_IEU0,
573 /*totCycles*/ 7,
574
575 /* maxIssueNum */ 1,
576 /* isSingleIssue */ false,
577 /* breaksGroup */ false,
578 /* numBubbles */ 0,
579
580 /*numSlots*/ 3,
581 /* feasibleSlots[] */ { 0, 1, 2 },
582
583 /*numEntries*/ 5,
584 /* V[] */ {
585 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
586 { IntIssueSlots.rid, 0, 1 },
587 /*Cycle E */ { IAluN.rid, 1, 1 },
588 { IAlu0.rid, 1, 1 },
589 /*Cycle C */
590 /*Cycle N1*/
591 /*Cycle N1*/
592 /*Cycle N1*/
593 /*Cycle W */ { IRegWritePorts.rid, 6, 1 }
594 }
595};
596
597const InstrClassRUsage IEU1ClassRUsage = {
598 SPARC_IEU1,
599 /*totCycles*/ 7,
600
601 /* maxIssueNum */ 1,
602 /* isSingleIssue */ false,
603 /* breaksGroup */ false,
604 /* numBubbles */ 0,
605
606 /*numSlots*/ 3,
607 /* feasibleSlots[] */ { 0, 1, 2 },
608
609 /*numEntries*/ 5,
610 /* V[] */ {
611 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
612 { IntIssueSlots.rid, 0, 1 },
613 /*Cycle E */ { IAluN.rid, 1, 1 },
614 { IAlu1.rid, 1, 1 },
615 /*Cycle C */
616 /*Cycle N1*/
617 /*Cycle N1*/
618 /*Cycle N1*/
619 /*Cycle W */ { IRegWritePorts.rid, 6, 1 }
620 }
621};
622
623const InstrClassRUsage FPMClassRUsage = {
624 SPARC_FPM,
625 /*totCycles*/ 7,
626
627 /* maxIssueNum */ 1,
628 /* isSingleIssue */ false,
629 /* breaksGroup */ false,
630 /* numBubbles */ 0,
631
632 /*numSlots*/ 4,
633 /* feasibleSlots[] */ { 0, 1, 2, 3 },
634
635 /*numEntries*/ 7,
636 /* V[] */ {
637 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
638 { FPMIssueSlots.rid, 0, 1 },
639 /*Cycle E */ { FPRegReadPorts.rid, 1, 1 },
640 /*Cycle C */ { FPMAluC1.rid, 2, 1 },
641 /*Cycle N1*/ { FPMAluC2.rid, 3, 1 },
642 /*Cycle N1*/ { FPMAluC3.rid, 4, 1 },
643 /*Cycle N1*/
644 /*Cycle W */ { FPRegWritePorts.rid, 6, 1 }
645 }
646};
647
648const InstrClassRUsage FPAClassRUsage = {
649 SPARC_FPA,
650 /*totCycles*/ 7,
651
652 /* maxIssueNum */ 1,
653 /* isSingleIssue */ false,
654 /* breaksGroup */ false,
655 /* numBubbles */ 0,
656
657 /*numSlots*/ 4,
658 /* feasibleSlots[] */ { 0, 1, 2, 3 },
659
660 /*numEntries*/ 7,
661 /* V[] */ {
662 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
663 { FPAIssueSlots.rid, 0, 1 },
664 /*Cycle E */ { FPRegReadPorts.rid, 1, 1 },
665 /*Cycle C */ { FPAAluC1.rid, 2, 1 },
666 /*Cycle N1*/ { FPAAluC2.rid, 3, 1 },
667 /*Cycle N1*/ { FPAAluC3.rid, 4, 1 },
668 /*Cycle N1*/
669 /*Cycle W */ { FPRegWritePorts.rid, 6, 1 }
670 }
671};
672
673const InstrClassRUsage LDClassRUsage = {
674 SPARC_LD,
675 /*totCycles*/ 7,
676
677 /* maxIssueNum */ 1,
678 /* isSingleIssue */ false,
679 /* breaksGroup */ false,
680 /* numBubbles */ 0,
681
682 /*numSlots*/ 3,
683 /* feasibleSlots[] */ { 0, 1, 2, },
684
685 /*numEntries*/ 6,
686 /* V[] */ {
687 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
688 { First3IssueSlots.rid, 0, 1 },
689 { LSIssueSlots.rid, 0, 1 },
690 /*Cycle E */ { LSAluC1.rid, 1, 1 },
691 /*Cycle C */ { LSAluC2.rid, 2, 1 },
692 { LdReturn.rid, 2, 1 },
693 /*Cycle N1*/
694 /*Cycle N1*/
695 /*Cycle N1*/
696 /*Cycle W */ { IRegWritePorts.rid, 6, 1 }
697 }
698};
699
700const InstrClassRUsage STClassRUsage = {
701 SPARC_ST,
702 /*totCycles*/ 7,
703
704 /* maxIssueNum */ 1,
705 /* isSingleIssue */ false,
706 /* breaksGroup */ false,
707 /* numBubbles */ 0,
708
709 /*numSlots*/ 3,
710 /* feasibleSlots[] */ { 0, 1, 2 },
711
712 /*numEntries*/ 4,
713 /* V[] */ {
714 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
715 { First3IssueSlots.rid, 0, 1 },
716 { LSIssueSlots.rid, 0, 1 },
717 /*Cycle E */ { LSAluC1.rid, 1, 1 },
718 /*Cycle C */ { LSAluC2.rid, 2, 1 }
719 /*Cycle N1*/
720 /*Cycle N1*/
721 /*Cycle N1*/
722 /*Cycle W */
723 }
724};
725
726const InstrClassRUsage CTIClassRUsage = {
727 SPARC_CTI,
728 /*totCycles*/ 7,
729
730 /* maxIssueNum */ 1,
731 /* isSingleIssue */ false,
732 /* breaksGroup */ false,
733 /* numBubbles */ 0,
734
735 /*numSlots*/ 4,
736 /* feasibleSlots[] */ { 0, 1, 2, 3 },
737
738 /*numEntries*/ 4,
739 /* V[] */ {
740 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
741 { CTIIssueSlots.rid, 0, 1 },
742 /*Cycle E */ { IAlu0.rid, 1, 1 },
743 /*Cycles E-C */ { CTIDelayCycle.rid, 1, 2 }
744 /*Cycle C */
745 /*Cycle N1*/
746 /*Cycle N1*/
747 /*Cycle N1*/
748 /*Cycle W */
749 }
750};
751
752const InstrClassRUsage SingleClassRUsage = {
753 SPARC_SINGLE,
754 /*totCycles*/ 7,
755
756 /* maxIssueNum */ 1,
757 /* isSingleIssue */ true,
758 /* breaksGroup */ false,
759 /* numBubbles */ 0,
760
761 /*numSlots*/ 1,
762 /* feasibleSlots[] */ { 0 },
763
764 /*numEntries*/ 5,
765 /* V[] */ {
766 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
767 { AllIssueSlots.rid, 0, 1 },
768 { AllIssueSlots.rid, 0, 1 },
769 { AllIssueSlots.rid, 0, 1 },
770 /*Cycle E */ { IAlu0.rid, 1, 1 }
771 /*Cycle C */
772 /*Cycle N1*/
773 /*Cycle N1*/
774 /*Cycle N1*/
775 /*Cycle W */
776 }
777};
778
779
780const InstrClassRUsage SparcRUsageDesc[] = {
781 NoneClassRUsage,
782 IEUNClassRUsage,
783 IEU0ClassRUsage,
784 IEU1ClassRUsage,
785 FPMClassRUsage,
786 FPAClassRUsage,
787 CTIClassRUsage,
788 LDClassRUsage,
789 STClassRUsage,
790 SingleClassRUsage
791};
792
793
794//---------------------------------------------------------------------------
795// const InstrIssueDelta SparcInstrIssueDeltas[]
796//
797// Purpose:
798// Changes to issue restrictions information in InstrClassRUsage for
799// instructions that differ from other instructions in their class.
800//---------------------------------------------------------------------------
801
802const InstrIssueDelta SparcInstrIssueDeltas[] = {
803
804 // opCode, isSingleIssue, breaksGroup, numBubbles
805
806 // Special cases for single-issue only
807 // Other single issue cases are below.
808//{ LDDA, true, true, 0 },
809//{ STDA, true, true, 0 },
810//{ LDDF, true, true, 0 },
811//{ LDDFA, true, true, 0 },
812 { ADDC, true, true, 0 },
813 { ADDCcc, true, true, 0 },
814 { SUBC, true, true, 0 },
815 { SUBCcc, true, true, 0 },
816//{ SAVE, true, true, 0 },
817//{ RESTORE, true, true, 0 },
818//{ LDSTUB, true, true, 0 },
819//{ SWAP, true, true, 0 },
820//{ SWAPA, true, true, 0 },
821//{ CAS, true, true, 0 },
822//{ CASA, true, true, 0 },
823//{ CASX, true, true, 0 },
824//{ CASXA, true, true, 0 },
825//{ LDFSR, true, true, 0 },
826//{ LDFSRA, true, true, 0 },
827//{ LDXFSR, true, true, 0 },
828//{ LDXFSRA, true, true, 0 },
829//{ STFSR, true, true, 0 },
830//{ STFSRA, true, true, 0 },
831//{ STXFSR, true, true, 0 },
832//{ STXFSRA, true, true, 0 },
833//{ SAVED, true, true, 0 },
834//{ RESTORED, true, true, 0 },
835//{ FLUSH, true, true, 9 },
836//{ FLUSHW, true, true, 9 },
837//{ ALIGNADDR, true, true, 0 },
838 { RETURN, true, true, 0 },
839//{ DONE, true, true, 0 },
840//{ RETRY, true, true, 0 },
841//{ WR, true, true, 0 },
842//{ WRPR, true, true, 4 },
843//{ RD, true, true, 0 },
844//{ RDPR, true, true, 0 },
845//{ TCC, true, true, 0 },
846//{ SHUTDOWN, true, true, 0 },
847
848 // Special cases for breaking group *before*
849 // CURRENTLY NOT SUPPORTED!
850 { CALL, false, false, 0 },
851 { JMPL, false, false, 0 },
852
853 // Special cases for breaking the group *after*
854 { MULX, true, true, (4+34)/2 },
855 { FDIVS, false, true, 0 },
856 { FDIVD, false, true, 0 },
857 { FDIVQ, false, true, 0 },
858 { FSQRTS, false, true, 0 },
859 { FSQRTD, false, true, 0 },
860 { FSQRTQ, false, true, 0 },
861//{ FCMP{LE,GT,NE,EQ}, false, true, 0 },
862
863 // Instructions that introduce bubbles
864//{ MULScc, true, true, 2 },
865//{ SMULcc, true, true, (4+18)/2 },
866//{ UMULcc, true, true, (4+19)/2 },
867 { SDIVX, true, true, 68 },
868 { UDIVX, true, true, 68 },
869//{ SDIVcc, true, true, 36 },
870//{ UDIVcc, true, true, 37 },
871//{ WR, false, false, 4 },
872//{ WRPR, false, false, 4 },
873};
874
875
876//---------------------------------------------------------------------------
877// const InstrRUsageDelta SparcInstrUsageDeltas[]
878//
879// Purpose:
880// Changes to resource usage information in InstrClassRUsage for
881// instructions that differ from other instructions in their class.
882//---------------------------------------------------------------------------
883
884const InstrRUsageDelta SparcInstrUsageDeltas[] = {
885
886 // MachineOpCode, Resource, Start cycle, Num cycles
887
888 //
889 // JMPL counts as a load/store instruction for issue!
890 //
891 { JMPL, LSIssueSlots.rid, 0, 1 },
892
893 //
894 // Many instructions cannot issue for the next 2 cycles after an FCMP
895 // We model that with a fake resource FCMPDelayCycle.
896 //
897 { FCMPS, FCMPDelayCycle.rid, 1, 3 },
898 { FCMPD, FCMPDelayCycle.rid, 1, 3 },
899 { FCMPQ, FCMPDelayCycle.rid, 1, 3 },
900
901 { MULX, FCMPDelayCycle.rid, 1, 1 },
902 { SDIVX, FCMPDelayCycle.rid, 1, 1 },
903 { UDIVX, FCMPDelayCycle.rid, 1, 1 },
904//{ SMULcc, FCMPDelayCycle.rid, 1, 1 },
905//{ UMULcc, FCMPDelayCycle.rid, 1, 1 },
906//{ SDIVcc, FCMPDelayCycle.rid, 1, 1 },
907//{ UDIVcc, FCMPDelayCycle.rid, 1, 1 },
908 { STD, FCMPDelayCycle.rid, 1, 1 },
909 { FMOVRSZ, FCMPDelayCycle.rid, 1, 1 },
910 { FMOVRSLEZ,FCMPDelayCycle.rid, 1, 1 },
911 { FMOVRSLZ, FCMPDelayCycle.rid, 1, 1 },
912 { FMOVRSNZ, FCMPDelayCycle.rid, 1, 1 },
913 { FMOVRSGZ, FCMPDelayCycle.rid, 1, 1 },
914 { FMOVRSGEZ,FCMPDelayCycle.rid, 1, 1 },
915
916 //
917 // Some instructions are stalled in the GROUP stage if a CTI is in
918 // the E or C stage
919 //
920 { LDD, CTIDelayCycle.rid, 1, 1 },
921//{ LDDA, CTIDelayCycle.rid, 1, 1 },
922//{ LDDSTUB, CTIDelayCycle.rid, 1, 1 },
923//{ LDDSTUBA, CTIDelayCycle.rid, 1, 1 },
924//{ SWAP, CTIDelayCycle.rid, 1, 1 },
925//{ SWAPA, CTIDelayCycle.rid, 1, 1 },
926//{ CAS, CTIDelayCycle.rid, 1, 1 },
927//{ CASA, CTIDelayCycle.rid, 1, 1 },
928//{ CASX, CTIDelayCycle.rid, 1, 1 },
929//{ CASXA, CTIDelayCycle.rid, 1, 1 },
930
931 //
932 // Signed int loads of less than dword size return data in cycle N1 (not C)
933 // and put all loads in consecutive cycles into delayed load return mode.
934 //
935 { LDSB, LdReturn.rid, 2, -1 },
936 { LDSB, LdReturn.rid, 3, 1 },
937
938 { LDSH, LdReturn.rid, 2, -1 },
939 { LDSH, LdReturn.rid, 3, 1 },
940
941 { LDSW, LdReturn.rid, 2, -1 },
942 { LDSW, LdReturn.rid, 3, 1 },
943
944
945#undef EXPLICIT_BUBBLES_NEEDED
946#ifdef EXPLICIT_BUBBLES_NEEDED
947 //
948 // MULScc inserts one bubble.
949 // This means it breaks the current group (captured in UltraSparcSchedInfo)
950 // *and occupies all issue slots for the next cycle
951 //
952//{ MULScc, AllIssueSlots.rid, 2, 2-1 },
953//{ MULScc, AllIssueSlots.rid, 2, 2-1 },
954//{ MULScc, AllIssueSlots.rid, 2, 2-1 },
955//{ MULScc, AllIssueSlots.rid, 2, 2-1 },
956
957 //
958 // SMULcc inserts between 4 and 18 bubbles, depending on #leading 0s in rs1.
959 // We just model this with a simple average.
960 //
961//{ SMULcc, AllIssueSlots.rid, 2, ((4+18)/2)-1 },
962//{ SMULcc, AllIssueSlots.rid, 2, ((4+18)/2)-1 },
963//{ SMULcc, AllIssueSlots.rid, 2, ((4+18)/2)-1 },
964//{ SMULcc, AllIssueSlots.rid, 2, ((4+18)/2)-1 },
965
966 // SMULcc inserts between 4 and 19 bubbles, depending on #leading 0s in rs1.
967//{ UMULcc, AllIssueSlots.rid, 2, ((4+19)/2)-1 },
968//{ UMULcc, AllIssueSlots.rid, 2, ((4+19)/2)-1 },
969//{ UMULcc, AllIssueSlots.rid, 2, ((4+19)/2)-1 },
970//{ UMULcc, AllIssueSlots.rid, 2, ((4+19)/2)-1 },
971
972 //
973 // MULX inserts between 4 and 34 bubbles, depending on #leading 0s in rs1.
974 //
975 { MULX, AllIssueSlots.rid, 2, ((4+34)/2)-1 },
976 { MULX, AllIssueSlots.rid, 2, ((4+34)/2)-1 },
977 { MULX, AllIssueSlots.rid, 2, ((4+34)/2)-1 },
978 { MULX, AllIssueSlots.rid, 2, ((4+34)/2)-1 },
979
980 //
981 // SDIVcc inserts 36 bubbles.
982 //
983//{ SDIVcc, AllIssueSlots.rid, 2, 36-1 },
984//{ SDIVcc, AllIssueSlots.rid, 2, 36-1 },
985//{ SDIVcc, AllIssueSlots.rid, 2, 36-1 },
986//{ SDIVcc, AllIssueSlots.rid, 2, 36-1 },
987
988 // UDIVcc inserts 37 bubbles.
989//{ UDIVcc, AllIssueSlots.rid, 2, 37-1 },
990//{ UDIVcc, AllIssueSlots.rid, 2, 37-1 },
991//{ UDIVcc, AllIssueSlots.rid, 2, 37-1 },
992//{ UDIVcc, AllIssueSlots.rid, 2, 37-1 },
993
994 //
995 // SDIVX inserts 68 bubbles.
996 //
997 { SDIVX, AllIssueSlots.rid, 2, 68-1 },
998 { SDIVX, AllIssueSlots.rid, 2, 68-1 },
999 { SDIVX, AllIssueSlots.rid, 2, 68-1 },
1000 { SDIVX, AllIssueSlots.rid, 2, 68-1 },
1001
1002 //
1003 // UDIVX inserts 68 bubbles.
1004 //
1005 { UDIVX, AllIssueSlots.rid, 2, 68-1 },
1006 { UDIVX, AllIssueSlots.rid, 2, 68-1 },
1007 { UDIVX, AllIssueSlots.rid, 2, 68-1 },
1008 { UDIVX, AllIssueSlots.rid, 2, 68-1 },
1009
1010 //
1011 // WR inserts 4 bubbles.
1012 //
1013//{ WR, AllIssueSlots.rid, 2, 68-1 },
1014//{ WR, AllIssueSlots.rid, 2, 68-1 },
1015//{ WR, AllIssueSlots.rid, 2, 68-1 },
1016//{ WR, AllIssueSlots.rid, 2, 68-1 },
1017
1018 //
1019 // WRPR inserts 4 bubbles.
1020 //
1021//{ WRPR, AllIssueSlots.rid, 2, 68-1 },
1022//{ WRPR, AllIssueSlots.rid, 2, 68-1 },
1023//{ WRPR, AllIssueSlots.rid, 2, 68-1 },
1024//{ WRPR, AllIssueSlots.rid, 2, 68-1 },
1025
1026 //
1027 // DONE inserts 9 bubbles.
1028 //
1029//{ DONE, AllIssueSlots.rid, 2, 9-1 },
1030//{ DONE, AllIssueSlots.rid, 2, 9-1 },
1031//{ DONE, AllIssueSlots.rid, 2, 9-1 },
1032//{ DONE, AllIssueSlots.rid, 2, 9-1 },
1033
1034 //
1035 // RETRY inserts 9 bubbles.
1036 //
1037//{ RETRY, AllIssueSlots.rid, 2, 9-1 },
1038//{ RETRY, AllIssueSlots.rid, 2, 9-1 },
1039//{ RETRY, AllIssueSlots.rid, 2, 9-1 },
1040//{ RETRY, AllIssueSlots.rid, 2, 9-1 },
1041
Chris Lattnere369fcb2001-10-13 06:54:54 +00001042#endif /*EXPLICIT_BUBBLES_NEEDED */
Chris Lattnerc6495ee2001-09-14 03:56:45 +00001043};
1044
1045
1046
1047// Additional delays to be captured in code:
1048// 1. RDPR from several state registers (page 349)
1049// 2. RD from *any* register (page 349)
1050// 3. Writes to TICK, PSTATE, TL registers and FLUSH{W} instr (page 349)
1051// 4. Integer store can be in same group as instr producing value to store.
1052// 5. BICC and BPICC can be in the same group as instr producing CC (pg 350)
1053// 6. FMOVr cannot be in the same or next group as an IEU instr (pg 351).
1054// 7. The second instr. of a CTI group inserts 9 bubbles (pg 351)
1055// 8. WR{PR}, SVAE, SAVED, RESTORE, RESTORED, RETURN, RETRY, and DONE that
1056// follow an annulling branch cannot be issued in the same group or in
1057// the 3 groups following the branch.
1058// 9. A predicted annulled load does not stall dependent instructions.
1059// Other annulled delay slot instructions *do* stall dependents, so
1060// nothing special needs to be done for them during scheduling.
1061//10. Do not put a load use that may be annulled in the same group as the
1062// branch. The group will stall until the load returns.
1063//11. Single-prec. FP loads lock 2 registers, for dependency checking.
1064//
1065//
1066// Additional delays we cannot or will not capture:
1067// 1. If DCTI is last word of cache line, it is delayed until next line can be
1068// fetched. Also, other DCTI alignment-related delays (pg 352)
1069// 2. Load-after-store is delayed by 7 extra cycles if load hits in D-Cache.
1070// Also, several other store-load and load-store conflicts (pg 358)
1071// 3. MEMBAR, LD{X}FSR, LDD{A} and a bunch of other load stalls (pg 358)
1072// 4. There can be at most 8 outstanding buffered store instructions
1073// (including some others like MEMBAR, LDSTUB, CAS{AX}, and FLUSH)
1074
1075
1076
1077//---------------------------------------------------------------------------
1078// class UltraSparcSchedInfo
1079//
1080// Purpose:
1081// Interface to instruction scheduling information for UltraSPARC.
1082// The parameter values above are based on UltraSPARC IIi.
1083//---------------------------------------------------------------------------
1084
1085
1086class UltraSparcSchedInfo: public MachineSchedInfo {
1087public:
1088 /*ctor*/ UltraSparcSchedInfo (const MachineInstrInfo* mii);
1089 /*dtor*/ virtual ~UltraSparcSchedInfo () {}
1090protected:
1091 virtual void initializeResources ();
1092};
1093
Chris Lattnerf6e0e282001-09-14 04:32:55 +00001094
1095//---------------------------------------------------------------------------
1096// class UltraSparcMachine
1097//
1098// Purpose:
1099// Primary interface to machine description for the UltraSPARC.
1100// Primarily just initializes machine-dependent parameters in
1101// class TargetMachine, and creates machine-dependent subclasses
Vikram S. Adve339084b2001-09-18 13:04:24 +00001102// for classes such as InstrInfo, SchedInfo and RegInfo.
Chris Lattnerf6e0e282001-09-14 04:32:55 +00001103//---------------------------------------------------------------------------
1104
1105class UltraSparc : public TargetMachine {
Vikram S. Adve339084b2001-09-18 13:04:24 +00001106private:
1107 UltraSparcInstrInfo instrInfo;
1108 UltraSparcSchedInfo schedInfo;
1109 UltraSparcRegInfo regInfo;
Chris Lattnerf6e0e282001-09-14 04:32:55 +00001110public:
1111 UltraSparc();
1112 virtual ~UltraSparc() {}
Vikram S. Adve339084b2001-09-18 13:04:24 +00001113
Chris Lattner32f600a2001-09-19 13:47:12 +00001114 virtual const MachineInstrInfo &getInstrInfo() const { return instrInfo; }
1115 virtual const MachineSchedInfo &getSchedInfo() const { return schedInfo; }
1116 virtual const MachineRegInfo &getRegInfo() const { return regInfo; }
Vikram S. Adve339084b2001-09-18 13:04:24 +00001117
Chris Lattnerf6e0e282001-09-14 04:32:55 +00001118 // compileMethod - For the sparc, we do instruction selection, followed by
1119 // delay slot scheduling, then register allocation.
1120 //
1121 virtual bool compileMethod(Method *M);
Chris Lattner32f600a2001-09-19 13:47:12 +00001122
1123 //
1124 // emitAssembly - Output assembly language code (a .s file) for the specified
1125 // module. The specified module must have been compiled before this may be
1126 // used.
1127 //
Chris Lattnerec0a95f2001-10-15 15:54:43 +00001128 virtual void emitAssembly(const Module *M, ostream &OutStr) const;
Chris Lattnerf6e0e282001-09-14 04:32:55 +00001129};
1130
1131
Chris Lattnerc6495ee2001-09-14 03:56:45 +00001132#endif