blob: 6828a68e66706f69d0a9c28947f9e41d7fe4186f [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
174 void suggestReg4CallAddr(const MachineInstr * CallMI) const;
175
176
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000177 Value *getValue4ReturnAddr( const MachineInstr * MInst ) const ;
178
179 int getRegType(const LiveRange *const LR) const {
180
181 unsigned Typ;
182
183 switch( (LR->getRegClass())->getID() ) {
184
185 case IntRegClassID: return IntRegType;
186
187 case FloatRegClassID:
188 Typ = LR->getTypeID();
189 if( Typ == Type::FloatTyID )
190 return FPSingleRegType;
191 else if( Typ == Type::DoubleTyID )
192 return FPDoubleRegType;
193 else assert(0 && "Unknown type in FloatRegClass");
194
195 case IntCCRegClassID: return IntCCRegType;
196
197 case FloatCCRegClassID: return FloatCCRegType ;
198
199 default: assert( 0 && "Unknown reg class ID");
200
201 }
202
203 }
204
205 int getRegType(const Value *const Val) const {
206
207 unsigned Typ;
208
209 switch( getRegClassIDOfValue(Val) ) {
210
211 case IntRegClassID: return IntRegType;
212
213 case FloatRegClassID:
214 Typ = (Val->getType())->getPrimitiveID();
215 if( Typ == Type::FloatTyID )
216 return FPSingleRegType;
217 else if( Typ == Type::DoubleTyID )
218 return FPDoubleRegType;
219 else assert(0 && "Unknown type in FloatRegClass");
220
221 case IntCCRegClassID: return IntCCRegType;
222
223 case FloatCCRegClassID: return FloatCCRegType ;
224
225 default: assert( 0 && "Unknown reg class ID");
226
227 }
228
229 }
230
231
232
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000233 // ***TODO: See this method is necessary
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000234
235 MachineInstr * cpValue2RegMI(Value * Val, const unsigned DestReg,
236 const int RegType) const;
237
238
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000239 public:
240
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000241
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000242 UltraSparcRegInfo(const UltraSparc *const USI ) : UltraSparcInfo(USI),
243 NumOfIntArgRegs(6),
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000244 NumOfFloatArgRegs(32),
245 InvalidRegNum(1000)
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000246 {
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000247 MachineRegClassArr.push_back( new SparcIntRegClass(IntRegClassID) );
248 MachineRegClassArr.push_back( new SparcFloatRegClass(FloatRegClassID) );
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000249 MachineRegClassArr.push_back( new SparcIntCCRegClass(IntCCRegClassID) );
250 MachineRegClassArr.push_back( new SparcFloatCCRegClass(FloatCCRegClassID));
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000251
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000252 assert( SparcFloatRegOrder::StartOfNonVolatileRegs == 32 &&
253 "32 Float regs are used for float arg passing");
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000254 }
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000255
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000256 // ***** TODO Delete
257 ~UltraSparcRegInfo(void) { } // empty destructor
258
259
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000260 inline const UltraSparc & getUltraSparcInfo() const {
261 return *UltraSparcInfo;
262 }
263
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000264
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000265
266 inline unsigned getRegClassIDOfValue (const Value *const Val,
267 bool isCCReg = false) const {
268
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000269 Type::PrimitiveID ty = (Val->getType())->getPrimitiveID();
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000270
271 unsigned res;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000272
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000273 if( (ty && ty <= Type::LongTyID) || (ty == Type::LabelTyID) ||
274 (ty == Type::MethodTyID) || (ty == Type::PointerTyID) )
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000275 res = IntRegClassID; // sparc int reg (ty=0: void)
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000276 else if( ty <= Type::DoubleTyID)
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000277 res = FloatRegClassID; // sparc float reg class
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000278 else {
Chris Lattner1e23ed72001-10-15 18:15:27 +0000279 cerr << "TypeID: " << ty << endl;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000280 assert(0 && "Cannot resolve register class for type");
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000281 }
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000282
283 if(isCCReg)
284 return res + 2; // corresponidng condition code regiser
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000285 else
286 return res;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000287 }
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000288
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000289 // returns the register tha contains always zero
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000290 // this is the unified register number
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000291 inline int getZeroRegNum() const { return SparcIntRegOrder::g0; }
292
293 // returns the reg used for pushing the address when a method is called.
294 // This can be used for other purposes between calls
295 unsigned getCallAddressReg() const { return SparcIntRegOrder::o7; }
296
297
298 // and when we return from a method. It should be made sure that this
299 // register contains the return value when a return instruction is reached.
300 unsigned getReturnAddressReg() const { return SparcIntRegOrder::i7; }
301
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000302 void suggestRegs4MethodArgs(const Method *const Meth,
303 LiveRangeInfo& LRI) const;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000304
Ruchira Sasankacc3ccac2001-10-15 16:25:28 +0000305 void suggestRegs4CallArgs(const MachineInstr *const CallMI,
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000306 LiveRangeInfo& LRI, vector<RegClass *> RCL) const;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000307
Ruchira Sasankacc3ccac2001-10-15 16:25:28 +0000308 void suggestReg4RetValue(const MachineInstr *const RetMI,
309 LiveRangeInfo& LRI ) const;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000310
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000311
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000312 void colorMethodArgs(const Method *const Meth, LiveRangeInfo& LRI,
313 AddedInstrns *const FirstAI) const;
314
Ruchira Sasankacc3ccac2001-10-15 16:25:28 +0000315 void colorCallArgs(const MachineInstr *const CallMI, LiveRangeInfo& LRI,
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000316 AddedInstrns *const CallAI) const;
317
Ruchira Sasankacc3ccac2001-10-15 16:25:28 +0000318 void colorRetValue(const MachineInstr *const RetI, LiveRangeInfo& LRI,
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000319 AddedInstrns *const RetAI) const;
320
321
Ruchira Sasankacc3ccac2001-10-15 16:25:28 +0000322 // bool handleSpecialMInstr(const MachineInstr * MInst,
323 // LiveRangeInfo& LRI, vector<RegClass *> RCL) const;
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000324
325
326 static void printReg(const LiveRange *const LR) ;
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000327
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000328 // this method provides a unique number for each register
329 inline int getUnifiedRegNum(int RegClassID, int reg) const {
330
331 if( RegClassID == IntRegClassID && reg < 32 )
332 return reg;
333 else if ( RegClassID == FloatRegClassID && reg < 64)
334 return reg + 32; // we have 32 int regs
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000335 else if( RegClassID == FloatCCRegClassID && reg < 4)
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000336 return reg + 32 + 64; // 32 int, 64 float
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000337 else if( RegClassID == IntCCRegClassID )
338 return 4+ 32 + 64; // only int cc reg
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000339 else if (reg==InvalidRegNum)
340 return InvalidRegNum;
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000341 else
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000342 assert(0 && "Invalid register class or reg number");
343
344 }
345
346 // given the unified register number, this gives the name
347 inline const string getUnifiedRegName(int reg) const {
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000348 if( reg < 32 )
349 return SparcIntRegOrder::getRegName(reg);
350 else if ( reg < (64 + 32) )
351 return SparcFloatRegOrder::getRegName( reg - 32);
352 else if( reg < (64+32+4) )
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000353 return SparcFloatCCRegOrder::getRegName( reg -32 - 64);
354 else if ( reg == 64+32+4)
355 return "xcc"; // only integer cc reg
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000356
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000357 else if (reg== InvalidRegNum) //****** TODO: Remove
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000358 return "<*NoReg*>";
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000359 else
360 assert(0 && "Invalid register number");
361 }
362
363
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000364 MachineInstr * cpReg2RegMI(const unsigned SrcReg, const unsigned DestReg,
365 const int RegType) const;
366
367 MachineInstr * cpReg2MemMI(const unsigned SrcReg, const unsigned DestPtrReg,
368 const int Offset, const int RegType) const;
369
370 MachineInstr * cpMem2RegMI(const unsigned SrcPtrReg, const int Offset,
371 const unsigned DestReg, const int RegType) const;
372
373 inline bool isRegVolatile(const int RegClassID, const int Reg) const {
374 return (MachineRegClassArr[RegClassID])->isRegVolatile(Reg);
375 }
376
377
378 inline unsigned getFramePointer() const {
379 return SparcIntRegOrder::i6;
380 }
381
382 inline unsigned getStackPointer() const {
383 return SparcIntRegOrder::o6;
384 }
385
386 inline int getInvalidRegNum() const {
387 return InvalidRegNum;
388 }
389
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000390};
391
392
393
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000394/*---------------------------------------------------------------------------
395Scheduling guidelines for SPARC IIi:
396
397I-Cache alignment rules (pg 326)
398-- Align a branch target instruction so that it's entire group is within
399 the same cache line (may be 1-4 instructions).
400** Don't let a branch that is predicted taken be the last instruction
401 on an I-cache line: delay slot will need an entire line to be fetched
402-- Make a FP instruction or a branch be the 4th instruction in a group.
403 For branches, there are tradeoffs in reordering to make this happen
404 (see pg. 327).
405** Don't put a branch in a group that crosses a 32-byte boundary!
406 An artificial branch is inserted after every 32 bytes, and having
407 another branch will force the group to be broken into 2 groups.
408
409iTLB rules:
410-- Don't let a loop span two memory pages, if possible
411
412Branch prediction performance:
413-- Don't make the branch in a delay slot the target of a branch
414-- Try not to have 2 predicted branches within a group of 4 instructions
415 (because each such group has a single branch target field).
416-- Try to align branches in slots 0, 2, 4 or 6 of a cache line (to avoid
417 the wrong prediction bits being used in some cases).
418
419D-Cache timing constraints:
420-- Signed int loads of less than 64 bits have 3 cycle latency, not 2
421-- All other loads that hit in D-Cache have 2 cycle latency
422-- All loads are returned IN ORDER, so a D-Cache miss will delay a later hit
423-- Mis-aligned loads or stores cause a trap. In particular, replace
424 mis-aligned FP double precision l/s with 2 single-precision l/s.
425-- Simulations of integer codes show increase in avg. group size of
426 33% when code (including esp. non-faulting loads) is moved across
427 one branch, and 50% across 2 branches.
428
429E-Cache timing constraints:
430-- Scheduling for E-cache (D-Cache misses) is effective (due to load buffering)
431
432Store buffer timing constraints:
433-- Stores can be executed in same cycle as instruction producing the value
434-- Stores are buffered and have lower priority for E-cache until
435 highwater mark is reached in the store buffer (5 stores)
436
437Pipeline constraints:
438-- Shifts can only use IEU0.
439-- CC setting instructions can only use IEU1.
440-- Several other instructions must only use IEU1:
441 EDGE(?), ARRAY(?), CALL, JMPL, BPr, PST, and FCMP.
442-- Two instructions cannot store to the same register file in a single cycle
443 (single write port per file).
444
445Issue and grouping constraints:
446-- FP and branch instructions must use slot 4.
447-- Shift instructions cannot be grouped with other IEU0-specific instructions.
448-- CC setting instructions cannot be grouped with other IEU1-specific instrs.
449-- Several instructions must be issued in a single-instruction group:
450 MOVcc or MOVr, MULs/x and DIVs/x, SAVE/RESTORE, many others
451-- A CALL or JMPL breaks a group, ie, is not combined with subsequent instrs.
452--
453--
454
455Branch delay slot scheduling rules:
456-- A CTI couple (two back-to-back CTI instructions in the dynamic stream)
457 has a 9-instruction penalty: the entire pipeline is flushed when the
458 second instruction reaches stage 9 (W-Writeback).
459-- Avoid putting multicycle instructions, and instructions that may cause
460 load misses, in the delay slot of an annulling branch.
461-- Avoid putting WR, SAVE..., RESTORE and RETURN instructions in the
462 delay slot of an annulling branch.
463
464 *--------------------------------------------------------------------------- */
465
466//---------------------------------------------------------------------------
467// List of CPUResources for UltraSPARC IIi.
468//---------------------------------------------------------------------------
469
470const CPUResource AllIssueSlots( "All Instr Slots", 4);
471const CPUResource IntIssueSlots( "Int Instr Slots", 3);
472const CPUResource First3IssueSlots("Instr Slots 0-3", 3);
473const CPUResource LSIssueSlots( "Load-Store Instr Slot", 1);
474const CPUResource CTIIssueSlots( "Ctrl Transfer Instr Slot", 1);
475const CPUResource FPAIssueSlots( "Int Instr Slot 1", 1);
476const CPUResource FPMIssueSlots( "Int Instr Slot 1", 1);
477
478// IEUN instructions can use either Alu and should use IAluN.
479// IEU0 instructions must use Alu 1 and should use both IAluN and IAlu0.
480// IEU1 instructions must use Alu 2 and should use both IAluN and IAlu1.
481const CPUResource IAluN("Int ALU 1or2", 2);
482const CPUResource IAlu0("Int ALU 1", 1);
483const CPUResource IAlu1("Int ALU 2", 1);
484
485const CPUResource LSAluC1("Load/Store Unit Addr Cycle", 1);
486const CPUResource LSAluC2("Load/Store Unit Issue Cycle", 1);
487const CPUResource LdReturn("Load Return Unit", 1);
488
489const CPUResource FPMAluC1("FP Mul/Div Alu Cycle 1", 1);
490const CPUResource FPMAluC2("FP Mul/Div Alu Cycle 2", 1);
491const CPUResource FPMAluC3("FP Mul/Div Alu Cycle 3", 1);
492
493const CPUResource FPAAluC1("FP Other Alu Cycle 1", 1);
494const CPUResource FPAAluC2("FP Other Alu Cycle 2", 1);
495const CPUResource FPAAluC3("FP Other Alu Cycle 3", 1);
496
497const CPUResource IRegReadPorts("Int Reg ReadPorts", INT_MAX); // CHECK
498const CPUResource IRegWritePorts("Int Reg WritePorts", 2); // CHECK
499const CPUResource FPRegReadPorts("FP Reg Read Ports", INT_MAX); // CHECK
500const CPUResource FPRegWritePorts("FP Reg Write Ports", 1); // CHECK
501
502const CPUResource CTIDelayCycle( "CTI delay cycle", 1);
503const CPUResource FCMPDelayCycle("FCMP delay cycle", 1);
504
505
506//---------------------------------------------------------------------------
507// const InstrClassRUsage SparcRUsageDesc[]
508//
509// Purpose:
510// Resource usage information for instruction in each scheduling class.
511// The InstrRUsage Objects for individual classes are specified first.
512// Note that fetch and decode are decoupled from the execution pipelines
513// via an instr buffer, so they are not included in the cycles below.
514//---------------------------------------------------------------------------
515
516const InstrClassRUsage NoneClassRUsage = {
517 SPARC_NONE,
518 /*totCycles*/ 7,
519
520 /* maxIssueNum */ 4,
521 /* isSingleIssue */ false,
522 /* breaksGroup */ false,
523 /* numBubbles */ 0,
524
525 /*numSlots*/ 4,
526 /* feasibleSlots[] */ { 0, 1, 2, 3 },
527
528 /*numEntries*/ 0,
529 /* V[] */ {
530 /*Cycle G */
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000531 /*Ccle E */
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000532 /*Cycle C */
533 /*Cycle N1*/
534 /*Cycle N1*/
535 /*Cycle N1*/
536 /*Cycle W */
537 }
538};
539
540const InstrClassRUsage IEUNClassRUsage = {
541 SPARC_IEUN,
542 /*totCycles*/ 7,
543
544 /* maxIssueNum */ 3,
545 /* isSingleIssue */ false,
546 /* breaksGroup */ false,
547 /* numBubbles */ 0,
548
549 /*numSlots*/ 3,
550 /* feasibleSlots[] */ { 0, 1, 2 },
551
552 /*numEntries*/ 4,
553 /* V[] */ {
554 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
555 { IntIssueSlots.rid, 0, 1 },
556 /*Cycle E */ { IAluN.rid, 1, 1 },
557 /*Cycle C */
558 /*Cycle N1*/
559 /*Cycle N1*/
560 /*Cycle N1*/
561 /*Cycle W */ { IRegWritePorts.rid, 6, 1 }
562 }
563};
564
565const InstrClassRUsage IEU0ClassRUsage = {
566 SPARC_IEU0,
567 /*totCycles*/ 7,
568
569 /* maxIssueNum */ 1,
570 /* isSingleIssue */ false,
571 /* breaksGroup */ false,
572 /* numBubbles */ 0,
573
574 /*numSlots*/ 3,
575 /* feasibleSlots[] */ { 0, 1, 2 },
576
577 /*numEntries*/ 5,
578 /* V[] */ {
579 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
580 { IntIssueSlots.rid, 0, 1 },
581 /*Cycle E */ { IAluN.rid, 1, 1 },
582 { IAlu0.rid, 1, 1 },
583 /*Cycle C */
584 /*Cycle N1*/
585 /*Cycle N1*/
586 /*Cycle N1*/
587 /*Cycle W */ { IRegWritePorts.rid, 6, 1 }
588 }
589};
590
591const InstrClassRUsage IEU1ClassRUsage = {
592 SPARC_IEU1,
593 /*totCycles*/ 7,
594
595 /* maxIssueNum */ 1,
596 /* isSingleIssue */ false,
597 /* breaksGroup */ false,
598 /* numBubbles */ 0,
599
600 /*numSlots*/ 3,
601 /* feasibleSlots[] */ { 0, 1, 2 },
602
603 /*numEntries*/ 5,
604 /* V[] */ {
605 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
606 { IntIssueSlots.rid, 0, 1 },
607 /*Cycle E */ { IAluN.rid, 1, 1 },
608 { IAlu1.rid, 1, 1 },
609 /*Cycle C */
610 /*Cycle N1*/
611 /*Cycle N1*/
612 /*Cycle N1*/
613 /*Cycle W */ { IRegWritePorts.rid, 6, 1 }
614 }
615};
616
617const InstrClassRUsage FPMClassRUsage = {
618 SPARC_FPM,
619 /*totCycles*/ 7,
620
621 /* maxIssueNum */ 1,
622 /* isSingleIssue */ false,
623 /* breaksGroup */ false,
624 /* numBubbles */ 0,
625
626 /*numSlots*/ 4,
627 /* feasibleSlots[] */ { 0, 1, 2, 3 },
628
629 /*numEntries*/ 7,
630 /* V[] */ {
631 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
632 { FPMIssueSlots.rid, 0, 1 },
633 /*Cycle E */ { FPRegReadPorts.rid, 1, 1 },
634 /*Cycle C */ { FPMAluC1.rid, 2, 1 },
635 /*Cycle N1*/ { FPMAluC2.rid, 3, 1 },
636 /*Cycle N1*/ { FPMAluC3.rid, 4, 1 },
637 /*Cycle N1*/
638 /*Cycle W */ { FPRegWritePorts.rid, 6, 1 }
639 }
640};
641
642const InstrClassRUsage FPAClassRUsage = {
643 SPARC_FPA,
644 /*totCycles*/ 7,
645
646 /* maxIssueNum */ 1,
647 /* isSingleIssue */ false,
648 /* breaksGroup */ false,
649 /* numBubbles */ 0,
650
651 /*numSlots*/ 4,
652 /* feasibleSlots[] */ { 0, 1, 2, 3 },
653
654 /*numEntries*/ 7,
655 /* V[] */ {
656 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
657 { FPAIssueSlots.rid, 0, 1 },
658 /*Cycle E */ { FPRegReadPorts.rid, 1, 1 },
659 /*Cycle C */ { FPAAluC1.rid, 2, 1 },
660 /*Cycle N1*/ { FPAAluC2.rid, 3, 1 },
661 /*Cycle N1*/ { FPAAluC3.rid, 4, 1 },
662 /*Cycle N1*/
663 /*Cycle W */ { FPRegWritePorts.rid, 6, 1 }
664 }
665};
666
667const InstrClassRUsage LDClassRUsage = {
668 SPARC_LD,
669 /*totCycles*/ 7,
670
671 /* maxIssueNum */ 1,
672 /* isSingleIssue */ false,
673 /* breaksGroup */ false,
674 /* numBubbles */ 0,
675
676 /*numSlots*/ 3,
677 /* feasibleSlots[] */ { 0, 1, 2, },
678
679 /*numEntries*/ 6,
680 /* V[] */ {
681 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
682 { First3IssueSlots.rid, 0, 1 },
683 { LSIssueSlots.rid, 0, 1 },
684 /*Cycle E */ { LSAluC1.rid, 1, 1 },
685 /*Cycle C */ { LSAluC2.rid, 2, 1 },
686 { LdReturn.rid, 2, 1 },
687 /*Cycle N1*/
688 /*Cycle N1*/
689 /*Cycle N1*/
690 /*Cycle W */ { IRegWritePorts.rid, 6, 1 }
691 }
692};
693
694const InstrClassRUsage STClassRUsage = {
695 SPARC_ST,
696 /*totCycles*/ 7,
697
698 /* maxIssueNum */ 1,
699 /* isSingleIssue */ false,
700 /* breaksGroup */ false,
701 /* numBubbles */ 0,
702
703 /*numSlots*/ 3,
704 /* feasibleSlots[] */ { 0, 1, 2 },
705
706 /*numEntries*/ 4,
707 /* V[] */ {
708 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
709 { First3IssueSlots.rid, 0, 1 },
710 { LSIssueSlots.rid, 0, 1 },
711 /*Cycle E */ { LSAluC1.rid, 1, 1 },
712 /*Cycle C */ { LSAluC2.rid, 2, 1 }
713 /*Cycle N1*/
714 /*Cycle N1*/
715 /*Cycle N1*/
716 /*Cycle W */
717 }
718};
719
720const InstrClassRUsage CTIClassRUsage = {
721 SPARC_CTI,
722 /*totCycles*/ 7,
723
724 /* maxIssueNum */ 1,
725 /* isSingleIssue */ false,
726 /* breaksGroup */ false,
727 /* numBubbles */ 0,
728
729 /*numSlots*/ 4,
730 /* feasibleSlots[] */ { 0, 1, 2, 3 },
731
732 /*numEntries*/ 4,
733 /* V[] */ {
734 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
735 { CTIIssueSlots.rid, 0, 1 },
736 /*Cycle E */ { IAlu0.rid, 1, 1 },
737 /*Cycles E-C */ { CTIDelayCycle.rid, 1, 2 }
738 /*Cycle C */
739 /*Cycle N1*/
740 /*Cycle N1*/
741 /*Cycle N1*/
742 /*Cycle W */
743 }
744};
745
746const InstrClassRUsage SingleClassRUsage = {
747 SPARC_SINGLE,
748 /*totCycles*/ 7,
749
750 /* maxIssueNum */ 1,
751 /* isSingleIssue */ true,
752 /* breaksGroup */ false,
753 /* numBubbles */ 0,
754
755 /*numSlots*/ 1,
756 /* feasibleSlots[] */ { 0 },
757
758 /*numEntries*/ 5,
759 /* V[] */ {
760 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
761 { AllIssueSlots.rid, 0, 1 },
762 { AllIssueSlots.rid, 0, 1 },
763 { AllIssueSlots.rid, 0, 1 },
764 /*Cycle E */ { IAlu0.rid, 1, 1 }
765 /*Cycle C */
766 /*Cycle N1*/
767 /*Cycle N1*/
768 /*Cycle N1*/
769 /*Cycle W */
770 }
771};
772
773
774const InstrClassRUsage SparcRUsageDesc[] = {
775 NoneClassRUsage,
776 IEUNClassRUsage,
777 IEU0ClassRUsage,
778 IEU1ClassRUsage,
779 FPMClassRUsage,
780 FPAClassRUsage,
781 CTIClassRUsage,
782 LDClassRUsage,
783 STClassRUsage,
784 SingleClassRUsage
785};
786
787
788//---------------------------------------------------------------------------
789// const InstrIssueDelta SparcInstrIssueDeltas[]
790//
791// Purpose:
792// Changes to issue restrictions information in InstrClassRUsage for
793// instructions that differ from other instructions in their class.
794//---------------------------------------------------------------------------
795
796const InstrIssueDelta SparcInstrIssueDeltas[] = {
797
798 // opCode, isSingleIssue, breaksGroup, numBubbles
799
800 // Special cases for single-issue only
801 // Other single issue cases are below.
802//{ LDDA, true, true, 0 },
803//{ STDA, true, true, 0 },
804//{ LDDF, true, true, 0 },
805//{ LDDFA, true, true, 0 },
806 { ADDC, true, true, 0 },
807 { ADDCcc, true, true, 0 },
808 { SUBC, true, true, 0 },
809 { SUBCcc, true, true, 0 },
810//{ SAVE, true, true, 0 },
811//{ RESTORE, true, true, 0 },
812//{ LDSTUB, true, true, 0 },
813//{ SWAP, true, true, 0 },
814//{ SWAPA, true, true, 0 },
815//{ CAS, true, true, 0 },
816//{ CASA, true, true, 0 },
817//{ CASX, true, true, 0 },
818//{ CASXA, true, true, 0 },
819//{ LDFSR, true, true, 0 },
820//{ LDFSRA, true, true, 0 },
821//{ LDXFSR, true, true, 0 },
822//{ LDXFSRA, true, true, 0 },
823//{ STFSR, true, true, 0 },
824//{ STFSRA, true, true, 0 },
825//{ STXFSR, true, true, 0 },
826//{ STXFSRA, true, true, 0 },
827//{ SAVED, true, true, 0 },
828//{ RESTORED, true, true, 0 },
829//{ FLUSH, true, true, 9 },
830//{ FLUSHW, true, true, 9 },
831//{ ALIGNADDR, true, true, 0 },
832 { RETURN, true, true, 0 },
833//{ DONE, true, true, 0 },
834//{ RETRY, true, true, 0 },
835//{ WR, true, true, 0 },
836//{ WRPR, true, true, 4 },
837//{ RD, true, true, 0 },
838//{ RDPR, true, true, 0 },
839//{ TCC, true, true, 0 },
840//{ SHUTDOWN, true, true, 0 },
841
842 // Special cases for breaking group *before*
843 // CURRENTLY NOT SUPPORTED!
844 { CALL, false, false, 0 },
845 { JMPL, false, false, 0 },
846
847 // Special cases for breaking the group *after*
848 { MULX, true, true, (4+34)/2 },
849 { FDIVS, false, true, 0 },
850 { FDIVD, false, true, 0 },
851 { FDIVQ, false, true, 0 },
852 { FSQRTS, false, true, 0 },
853 { FSQRTD, false, true, 0 },
854 { FSQRTQ, false, true, 0 },
855//{ FCMP{LE,GT,NE,EQ}, false, true, 0 },
856
857 // Instructions that introduce bubbles
858//{ MULScc, true, true, 2 },
859//{ SMULcc, true, true, (4+18)/2 },
860//{ UMULcc, true, true, (4+19)/2 },
861 { SDIVX, true, true, 68 },
862 { UDIVX, true, true, 68 },
863//{ SDIVcc, true, true, 36 },
864//{ UDIVcc, true, true, 37 },
865//{ WR, false, false, 4 },
866//{ WRPR, false, false, 4 },
867};
868
869
870//---------------------------------------------------------------------------
871// const InstrRUsageDelta SparcInstrUsageDeltas[]
872//
873// Purpose:
874// Changes to resource usage information in InstrClassRUsage for
875// instructions that differ from other instructions in their class.
876//---------------------------------------------------------------------------
877
878const InstrRUsageDelta SparcInstrUsageDeltas[] = {
879
880 // MachineOpCode, Resource, Start cycle, Num cycles
881
882 //
883 // JMPL counts as a load/store instruction for issue!
884 //
885 { JMPL, LSIssueSlots.rid, 0, 1 },
886
887 //
888 // Many instructions cannot issue for the next 2 cycles after an FCMP
889 // We model that with a fake resource FCMPDelayCycle.
890 //
891 { FCMPS, FCMPDelayCycle.rid, 1, 3 },
892 { FCMPD, FCMPDelayCycle.rid, 1, 3 },
893 { FCMPQ, FCMPDelayCycle.rid, 1, 3 },
894
895 { MULX, FCMPDelayCycle.rid, 1, 1 },
896 { SDIVX, FCMPDelayCycle.rid, 1, 1 },
897 { UDIVX, FCMPDelayCycle.rid, 1, 1 },
898//{ SMULcc, FCMPDelayCycle.rid, 1, 1 },
899//{ UMULcc, FCMPDelayCycle.rid, 1, 1 },
900//{ SDIVcc, FCMPDelayCycle.rid, 1, 1 },
901//{ UDIVcc, FCMPDelayCycle.rid, 1, 1 },
902 { STD, FCMPDelayCycle.rid, 1, 1 },
903 { FMOVRSZ, FCMPDelayCycle.rid, 1, 1 },
904 { FMOVRSLEZ,FCMPDelayCycle.rid, 1, 1 },
905 { FMOVRSLZ, FCMPDelayCycle.rid, 1, 1 },
906 { FMOVRSNZ, FCMPDelayCycle.rid, 1, 1 },
907 { FMOVRSGZ, FCMPDelayCycle.rid, 1, 1 },
908 { FMOVRSGEZ,FCMPDelayCycle.rid, 1, 1 },
909
910 //
911 // Some instructions are stalled in the GROUP stage if a CTI is in
912 // the E or C stage
913 //
914 { LDD, CTIDelayCycle.rid, 1, 1 },
915//{ LDDA, CTIDelayCycle.rid, 1, 1 },
916//{ LDDSTUB, CTIDelayCycle.rid, 1, 1 },
917//{ LDDSTUBA, CTIDelayCycle.rid, 1, 1 },
918//{ SWAP, CTIDelayCycle.rid, 1, 1 },
919//{ SWAPA, CTIDelayCycle.rid, 1, 1 },
920//{ CAS, CTIDelayCycle.rid, 1, 1 },
921//{ CASA, CTIDelayCycle.rid, 1, 1 },
922//{ CASX, CTIDelayCycle.rid, 1, 1 },
923//{ CASXA, CTIDelayCycle.rid, 1, 1 },
924
925 //
926 // Signed int loads of less than dword size return data in cycle N1 (not C)
927 // and put all loads in consecutive cycles into delayed load return mode.
928 //
929 { LDSB, LdReturn.rid, 2, -1 },
930 { LDSB, LdReturn.rid, 3, 1 },
931
932 { LDSH, LdReturn.rid, 2, -1 },
933 { LDSH, LdReturn.rid, 3, 1 },
934
935 { LDSW, LdReturn.rid, 2, -1 },
936 { LDSW, LdReturn.rid, 3, 1 },
937
938
939#undef EXPLICIT_BUBBLES_NEEDED
940#ifdef EXPLICIT_BUBBLES_NEEDED
941 //
942 // MULScc inserts one bubble.
943 // This means it breaks the current group (captured in UltraSparcSchedInfo)
944 // *and occupies all issue slots for the next cycle
945 //
946//{ MULScc, AllIssueSlots.rid, 2, 2-1 },
947//{ MULScc, AllIssueSlots.rid, 2, 2-1 },
948//{ MULScc, AllIssueSlots.rid, 2, 2-1 },
949//{ MULScc, AllIssueSlots.rid, 2, 2-1 },
950
951 //
952 // SMULcc inserts between 4 and 18 bubbles, depending on #leading 0s in rs1.
953 // We just model this with a simple average.
954 //
955//{ SMULcc, AllIssueSlots.rid, 2, ((4+18)/2)-1 },
956//{ SMULcc, AllIssueSlots.rid, 2, ((4+18)/2)-1 },
957//{ SMULcc, AllIssueSlots.rid, 2, ((4+18)/2)-1 },
958//{ SMULcc, AllIssueSlots.rid, 2, ((4+18)/2)-1 },
959
960 // SMULcc inserts between 4 and 19 bubbles, depending on #leading 0s in rs1.
961//{ UMULcc, AllIssueSlots.rid, 2, ((4+19)/2)-1 },
962//{ UMULcc, AllIssueSlots.rid, 2, ((4+19)/2)-1 },
963//{ UMULcc, AllIssueSlots.rid, 2, ((4+19)/2)-1 },
964//{ UMULcc, AllIssueSlots.rid, 2, ((4+19)/2)-1 },
965
966 //
967 // MULX inserts between 4 and 34 bubbles, depending on #leading 0s in rs1.
968 //
969 { MULX, AllIssueSlots.rid, 2, ((4+34)/2)-1 },
970 { MULX, AllIssueSlots.rid, 2, ((4+34)/2)-1 },
971 { MULX, AllIssueSlots.rid, 2, ((4+34)/2)-1 },
972 { MULX, AllIssueSlots.rid, 2, ((4+34)/2)-1 },
973
974 //
975 // SDIVcc inserts 36 bubbles.
976 //
977//{ SDIVcc, AllIssueSlots.rid, 2, 36-1 },
978//{ SDIVcc, AllIssueSlots.rid, 2, 36-1 },
979//{ SDIVcc, AllIssueSlots.rid, 2, 36-1 },
980//{ SDIVcc, AllIssueSlots.rid, 2, 36-1 },
981
982 // UDIVcc inserts 37 bubbles.
983//{ UDIVcc, AllIssueSlots.rid, 2, 37-1 },
984//{ UDIVcc, AllIssueSlots.rid, 2, 37-1 },
985//{ UDIVcc, AllIssueSlots.rid, 2, 37-1 },
986//{ UDIVcc, AllIssueSlots.rid, 2, 37-1 },
987
988 //
989 // SDIVX inserts 68 bubbles.
990 //
991 { SDIVX, AllIssueSlots.rid, 2, 68-1 },
992 { SDIVX, AllIssueSlots.rid, 2, 68-1 },
993 { SDIVX, AllIssueSlots.rid, 2, 68-1 },
994 { SDIVX, AllIssueSlots.rid, 2, 68-1 },
995
996 //
997 // UDIVX inserts 68 bubbles.
998 //
999 { UDIVX, AllIssueSlots.rid, 2, 68-1 },
1000 { UDIVX, AllIssueSlots.rid, 2, 68-1 },
1001 { UDIVX, AllIssueSlots.rid, 2, 68-1 },
1002 { UDIVX, AllIssueSlots.rid, 2, 68-1 },
1003
1004 //
1005 // WR inserts 4 bubbles.
1006 //
1007//{ WR, AllIssueSlots.rid, 2, 68-1 },
1008//{ WR, AllIssueSlots.rid, 2, 68-1 },
1009//{ WR, AllIssueSlots.rid, 2, 68-1 },
1010//{ WR, AllIssueSlots.rid, 2, 68-1 },
1011
1012 //
1013 // WRPR inserts 4 bubbles.
1014 //
1015//{ WRPR, AllIssueSlots.rid, 2, 68-1 },
1016//{ WRPR, AllIssueSlots.rid, 2, 68-1 },
1017//{ WRPR, AllIssueSlots.rid, 2, 68-1 },
1018//{ WRPR, AllIssueSlots.rid, 2, 68-1 },
1019
1020 //
1021 // DONE inserts 9 bubbles.
1022 //
1023//{ DONE, AllIssueSlots.rid, 2, 9-1 },
1024//{ DONE, AllIssueSlots.rid, 2, 9-1 },
1025//{ DONE, AllIssueSlots.rid, 2, 9-1 },
1026//{ DONE, AllIssueSlots.rid, 2, 9-1 },
1027
1028 //
1029 // RETRY inserts 9 bubbles.
1030 //
1031//{ RETRY, AllIssueSlots.rid, 2, 9-1 },
1032//{ RETRY, AllIssueSlots.rid, 2, 9-1 },
1033//{ RETRY, AllIssueSlots.rid, 2, 9-1 },
1034//{ RETRY, AllIssueSlots.rid, 2, 9-1 },
1035
Chris Lattnere369fcb2001-10-13 06:54:54 +00001036#endif /*EXPLICIT_BUBBLES_NEEDED */
Chris Lattnerc6495ee2001-09-14 03:56:45 +00001037};
1038
1039
1040
1041// Additional delays to be captured in code:
1042// 1. RDPR from several state registers (page 349)
1043// 2. RD from *any* register (page 349)
1044// 3. Writes to TICK, PSTATE, TL registers and FLUSH{W} instr (page 349)
1045// 4. Integer store can be in same group as instr producing value to store.
1046// 5. BICC and BPICC can be in the same group as instr producing CC (pg 350)
1047// 6. FMOVr cannot be in the same or next group as an IEU instr (pg 351).
1048// 7. The second instr. of a CTI group inserts 9 bubbles (pg 351)
1049// 8. WR{PR}, SVAE, SAVED, RESTORE, RESTORED, RETURN, RETRY, and DONE that
1050// follow an annulling branch cannot be issued in the same group or in
1051// the 3 groups following the branch.
1052// 9. A predicted annulled load does not stall dependent instructions.
1053// Other annulled delay slot instructions *do* stall dependents, so
1054// nothing special needs to be done for them during scheduling.
1055//10. Do not put a load use that may be annulled in the same group as the
1056// branch. The group will stall until the load returns.
1057//11. Single-prec. FP loads lock 2 registers, for dependency checking.
1058//
1059//
1060// Additional delays we cannot or will not capture:
1061// 1. If DCTI is last word of cache line, it is delayed until next line can be
1062// fetched. Also, other DCTI alignment-related delays (pg 352)
1063// 2. Load-after-store is delayed by 7 extra cycles if load hits in D-Cache.
1064// Also, several other store-load and load-store conflicts (pg 358)
1065// 3. MEMBAR, LD{X}FSR, LDD{A} and a bunch of other load stalls (pg 358)
1066// 4. There can be at most 8 outstanding buffered store instructions
1067// (including some others like MEMBAR, LDSTUB, CAS{AX}, and FLUSH)
1068
1069
1070
1071//---------------------------------------------------------------------------
1072// class UltraSparcSchedInfo
1073//
1074// Purpose:
1075// Interface to instruction scheduling information for UltraSPARC.
1076// The parameter values above are based on UltraSPARC IIi.
1077//---------------------------------------------------------------------------
1078
1079
1080class UltraSparcSchedInfo: public MachineSchedInfo {
1081public:
1082 /*ctor*/ UltraSparcSchedInfo (const MachineInstrInfo* mii);
1083 /*dtor*/ virtual ~UltraSparcSchedInfo () {}
1084protected:
1085 virtual void initializeResources ();
1086};
1087
Chris Lattnerf6e0e282001-09-14 04:32:55 +00001088
1089//---------------------------------------------------------------------------
1090// class UltraSparcMachine
1091//
1092// Purpose:
1093// Primary interface to machine description for the UltraSPARC.
1094// Primarily just initializes machine-dependent parameters in
1095// class TargetMachine, and creates machine-dependent subclasses
Vikram S. Adve339084b2001-09-18 13:04:24 +00001096// for classes such as InstrInfo, SchedInfo and RegInfo.
Chris Lattnerf6e0e282001-09-14 04:32:55 +00001097//---------------------------------------------------------------------------
1098
1099class UltraSparc : public TargetMachine {
Vikram S. Adve339084b2001-09-18 13:04:24 +00001100private:
1101 UltraSparcInstrInfo instrInfo;
1102 UltraSparcSchedInfo schedInfo;
1103 UltraSparcRegInfo regInfo;
Chris Lattnerf6e0e282001-09-14 04:32:55 +00001104public:
1105 UltraSparc();
1106 virtual ~UltraSparc() {}
Vikram S. Adve339084b2001-09-18 13:04:24 +00001107
Chris Lattner32f600a2001-09-19 13:47:12 +00001108 virtual const MachineInstrInfo &getInstrInfo() const { return instrInfo; }
1109 virtual const MachineSchedInfo &getSchedInfo() const { return schedInfo; }
1110 virtual const MachineRegInfo &getRegInfo() const { return regInfo; }
Vikram S. Adve339084b2001-09-18 13:04:24 +00001111
Chris Lattnerf6e0e282001-09-14 04:32:55 +00001112 // compileMethod - For the sparc, we do instruction selection, followed by
1113 // delay slot scheduling, then register allocation.
1114 //
1115 virtual bool compileMethod(Method *M);
Chris Lattner32f600a2001-09-19 13:47:12 +00001116
1117 //
1118 // emitAssembly - Output assembly language code (a .s file) for the specified
1119 // module. The specified module must have been compiled before this may be
1120 // used.
1121 //
Chris Lattnerec0a95f2001-10-15 15:54:43 +00001122 virtual void emitAssembly(const Module *M, ostream &OutStr) const;
Chris Lattnerf6e0e282001-09-14 04:32:55 +00001123};
1124
1125
Chris Lattnerc6495ee2001-09-14 03:56:45 +00001126#endif