blob: 653a2018a77dddbc9c1ac73bfe685a5e1b8b469c [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,
Vikram S. Advec1521632001-10-22 13:31:53 +000065 NUM_REAL_OPCODES = PHI, // number of valid opcodes
Chris Lattnerc6495ee2001-09-14 03:56:45 +000066 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
Ruchira Sasanka20c82b12001-10-28 18:15:12 +0000116
117
118//----------------------------------------------------------------------------
119// class UltraSparcRegInfo
120//
121//----------------------------------------------------------------------------
122
123
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000124class LiveRange;
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000125class UltraSparc;
Ruchira Sasanka20c82b12001-10-28 18:15:12 +0000126class PhyRegAlloc;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000127
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000128
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000129class UltraSparcRegInfo : public MachineRegInfo
130{
131
132 private:
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000133
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000134 // The actual register classes in the Sparc
135
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000136 enum RegClassIDs {
137 IntRegClassID,
138 FloatRegClassID,
139 IntCCRegClassID,
140 FloatCCRegClassID
141 };
142
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000143
144 // Type of registers available in Sparc. There can be several reg types
145 // in the same class. For instace, the float reg class has Single/Double
146 // types
147 enum RegTypes {
148 IntRegType,
149 FPSingleRegType,
150 FPDoubleRegType,
151 IntCCRegType,
152 FloatCCRegType
153 };
154
Ruchira Sasanka20c82b12001-10-28 18:15:12 +0000155 // the size of a value (int, float, etc..) stored in the stack frame
156
157
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000158
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000159 // WARNING: If the above enum order must be changed, also modify
160 // getRegisterClassOfValue method below since it assumes this particular
161 // order for efficiency.
162
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000163
164 // reverse pointer to get info about the ultra sparc machine
165 const UltraSparc *const UltraSparcInfo;
166
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000167 // Both int and float rguments can be passed in 6 int regs -
168 // %o0 to %o5 (cannot be changed)
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000169 unsigned const NumOfIntArgRegs;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000170 unsigned const NumOfFloatArgRegs;
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000171 int const InvalidRegNum;
Ruchira Sasanka20c82b12001-10-28 18:15:12 +0000172 int SizeOfOperandOnStack;
173
174
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000175
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000176 //void setCallArgColor(LiveRange *const LR, const unsigned RegNo) const;
177
178 void setCallOrRetArgCol(LiveRange *const LR, const unsigned RegNo,
179 const MachineInstr *MI,AddedInstrMapType &AIMap)const;
180
181 MachineInstr * getCopy2RegMI(const Value *SrcVal, const unsigned Reg,
182 unsigned RegClassID) const ;
183
Ruchira Sasankacc3ccac2001-10-15 16:25:28 +0000184
185 void suggestReg4RetAddr(const MachineInstr * RetMI,
186 LiveRangeInfo& LRI) const;
187
Ruchira Sasankab3b6f532001-10-21 16:43:41 +0000188 void suggestReg4CallAddr(const MachineInstr * CallMI, LiveRangeInfo& LRI,
189 vector<RegClass *> RCList) const;
Ruchira Sasankacc3ccac2001-10-15 16:25:28 +0000190
191
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000192 Value *getValue4ReturnAddr( const MachineInstr * MInst ) const ;
193
194 int getRegType(const LiveRange *const LR) const {
195
196 unsigned Typ;
197
198 switch( (LR->getRegClass())->getID() ) {
199
200 case IntRegClassID: return IntRegType;
201
202 case FloatRegClassID:
203 Typ = LR->getTypeID();
204 if( Typ == Type::FloatTyID )
205 return FPSingleRegType;
206 else if( Typ == Type::DoubleTyID )
207 return FPDoubleRegType;
208 else assert(0 && "Unknown type in FloatRegClass");
209
210 case IntCCRegClassID: return IntCCRegType;
211
212 case FloatCCRegClassID: return FloatCCRegType ;
213
214 default: assert( 0 && "Unknown reg class ID");
215
216 }
217
218 }
219
220 int getRegType(const Value *const Val) const {
221
222 unsigned Typ;
223
224 switch( getRegClassIDOfValue(Val) ) {
225
226 case IntRegClassID: return IntRegType;
227
228 case FloatRegClassID:
229 Typ = (Val->getType())->getPrimitiveID();
230 if( Typ == Type::FloatTyID )
231 return FPSingleRegType;
232 else if( Typ == Type::DoubleTyID )
233 return FPDoubleRegType;
234 else assert(0 && "Unknown type in FloatRegClass");
235
236 case IntCCRegClassID: return IntCCRegType;
237
238 case FloatCCRegClassID: return FloatCCRegType ;
239
240 default: assert( 0 && "Unknown reg class ID");
241
242 }
243
244 }
245
246
247
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000248 // ***TODO: See this method is necessary
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000249
250 MachineInstr * cpValue2RegMI(Value * Val, const unsigned DestReg,
251 const int RegType) const;
252
Ruchira Sasankab3b6f532001-10-21 16:43:41 +0000253 const Value *getCallInstRetAddr(const MachineInstr *CallMI) const;
254 const unsigned getCallInstNumArgs(const MachineInstr *CallMI) const;
255
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000256
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000257 public:
258
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000259
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000260 UltraSparcRegInfo(const UltraSparc *const USI ) : UltraSparcInfo(USI),
261 NumOfIntArgRegs(6),
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000262 NumOfFloatArgRegs(32),
Ruchira Sasanka20c82b12001-10-28 18:15:12 +0000263 InvalidRegNum(1000),
264 SizeOfOperandOnStack(8)
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000265 {
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000266 MachineRegClassArr.push_back( new SparcIntRegClass(IntRegClassID) );
267 MachineRegClassArr.push_back( new SparcFloatRegClass(FloatRegClassID) );
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000268 MachineRegClassArr.push_back( new SparcIntCCRegClass(IntCCRegClassID) );
269 MachineRegClassArr.push_back( new SparcFloatCCRegClass(FloatCCRegClassID));
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000270
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000271 assert( SparcFloatRegOrder::StartOfNonVolatileRegs == 32 &&
272 "32 Float regs are used for float arg passing");
Ruchira Sasanka20c82b12001-10-28 18:15:12 +0000273
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000274 }
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000275
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000276 // ***** TODO Delete
277 ~UltraSparcRegInfo(void) { } // empty destructor
278
279
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000280 inline const UltraSparc & getUltraSparcInfo() const {
281 return *UltraSparcInfo;
282 }
283
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000284
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000285
286 inline unsigned getRegClassIDOfValue (const Value *const Val,
287 bool isCCReg = false) const {
288
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000289 Type::PrimitiveID ty = (Val->getType())->getPrimitiveID();
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000290
291 unsigned res;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000292
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000293 if( (ty && ty <= Type::LongTyID) || (ty == Type::LabelTyID) ||
294 (ty == Type::MethodTyID) || (ty == Type::PointerTyID) )
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000295 res = IntRegClassID; // sparc int reg (ty=0: void)
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000296 else if( ty <= Type::DoubleTyID)
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000297 res = FloatRegClassID; // sparc float reg class
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000298 else {
Chris Lattner1e23ed72001-10-15 18:15:27 +0000299 cerr << "TypeID: " << ty << endl;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000300 assert(0 && "Cannot resolve register class for type");
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000301 }
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000302
303 if(isCCReg)
304 return res + 2; // corresponidng condition code regiser
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000305 else
306 return res;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000307 }
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000308
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000309 // returns the register tha contains always zero
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000310 // this is the unified register number
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000311 inline int getZeroRegNum() const { return SparcIntRegOrder::g0; }
312
313 // returns the reg used for pushing the address when a method is called.
314 // This can be used for other purposes between calls
315 unsigned getCallAddressReg() const { return SparcIntRegOrder::o7; }
316
317
318 // and when we return from a method. It should be made sure that this
319 // register contains the return value when a return instruction is reached.
320 unsigned getReturnAddressReg() const { return SparcIntRegOrder::i7; }
321
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000322 void suggestRegs4MethodArgs(const Method *const Meth,
323 LiveRangeInfo& LRI) const;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000324
Ruchira Sasankacc3ccac2001-10-15 16:25:28 +0000325 void suggestRegs4CallArgs(const MachineInstr *const CallMI,
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000326 LiveRangeInfo& LRI, vector<RegClass *> RCL) const;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000327
Ruchira Sasankacc3ccac2001-10-15 16:25:28 +0000328 void suggestReg4RetValue(const MachineInstr *const RetMI,
329 LiveRangeInfo& LRI ) const;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000330
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000331
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000332 void colorMethodArgs(const Method *const Meth, LiveRangeInfo& LRI,
333 AddedInstrns *const FirstAI) const;
334
Ruchira Sasankacc3ccac2001-10-15 16:25:28 +0000335 void colorCallArgs(const MachineInstr *const CallMI, LiveRangeInfo& LRI,
Ruchira Sasanka20c82b12001-10-28 18:15:12 +0000336 AddedInstrns *const CallAI, PhyRegAlloc &PRA) const;
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000337
Ruchira Sasankacc3ccac2001-10-15 16:25:28 +0000338 void colorRetValue(const MachineInstr *const RetI, LiveRangeInfo& LRI,
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000339 AddedInstrns *const RetAI) const;
340
341
Ruchira Sasankacc3ccac2001-10-15 16:25:28 +0000342 // bool handleSpecialMInstr(const MachineInstr * MInst,
343 // LiveRangeInfo& LRI, vector<RegClass *> RCL) const;
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000344
345
346 static void printReg(const LiveRange *const LR) ;
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000347
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000348 // this method provides a unique number for each register
349 inline int getUnifiedRegNum(int RegClassID, int reg) const {
350
351 if( RegClassID == IntRegClassID && reg < 32 )
352 return reg;
353 else if ( RegClassID == FloatRegClassID && reg < 64)
354 return reg + 32; // we have 32 int regs
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000355 else if( RegClassID == FloatCCRegClassID && reg < 4)
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000356 return reg + 32 + 64; // 32 int, 64 float
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000357 else if( RegClassID == IntCCRegClassID )
358 return 4+ 32 + 64; // only int cc reg
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000359 else if (reg==InvalidRegNum)
360 return InvalidRegNum;
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000361 else
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000362 assert(0 && "Invalid register class or reg number");
363
364 }
365
366 // given the unified register number, this gives the name
367 inline const string getUnifiedRegName(int reg) const {
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000368 if( reg < 32 )
369 return SparcIntRegOrder::getRegName(reg);
370 else if ( reg < (64 + 32) )
371 return SparcFloatRegOrder::getRegName( reg - 32);
372 else if( reg < (64+32+4) )
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000373 return SparcFloatCCRegOrder::getRegName( reg -32 - 64);
374 else if ( reg == 64+32+4)
375 return "xcc"; // only integer cc reg
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000376
Vikram S. Advec1521632001-10-22 13:31:53 +0000377 else if (reg== InvalidRegNum) //****** TODO: Remove */
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000378 return "<*NoReg*>";
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000379 else
380 assert(0 && "Invalid register number");
381 }
382
Vikram S. Advec1521632001-10-22 13:31:53 +0000383 inline unsigned int getRegNumInCallersWindow(int reg) {
384 if (reg == InvalidRegNum || reg >= 32)
385 return reg;
386 return SparcIntRegOrder::getRegNumInCallersWindow(reg);
387 }
388
389 inline bool mustBeRemappedInCallersWindow(int reg) {
390 return (reg != InvalidRegNum && reg < 32);
391 }
392
Ruchira Sasankab3b6f532001-10-21 16:43:41 +0000393 const Value * getCallInstRetVal(const MachineInstr *CallMI) const;
394
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000395 MachineInstr * cpReg2RegMI(const unsigned SrcReg, const unsigned DestReg,
396 const int RegType) const;
397
398 MachineInstr * cpReg2MemMI(const unsigned SrcReg, const unsigned DestPtrReg,
399 const int Offset, const int RegType) const;
400
401 MachineInstr * cpMem2RegMI(const unsigned SrcPtrReg, const int Offset,
402 const unsigned DestReg, const int RegType) const;
403
404 inline bool isRegVolatile(const int RegClassID, const int Reg) const {
405 return (MachineRegClassArr[RegClassID])->isRegVolatile(Reg);
406 }
407
408
409 inline unsigned getFramePointer() const {
410 return SparcIntRegOrder::i6;
411 }
412
413 inline unsigned getStackPointer() const {
414 return SparcIntRegOrder::o6;
415 }
416
417 inline int getInvalidRegNum() const {
418 return InvalidRegNum;
419 }
420
Ruchira Sasanka20c82b12001-10-28 18:15:12 +0000421
422 void insertCallerSavingCode(const MachineInstr *MInst,
423 const BasicBlock *BB, PhyRegAlloc &PRA ) const;
424
425
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000426};
427
428
429
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000430/*---------------------------------------------------------------------------
431Scheduling guidelines for SPARC IIi:
432
433I-Cache alignment rules (pg 326)
434-- Align a branch target instruction so that it's entire group is within
435 the same cache line (may be 1-4 instructions).
436** Don't let a branch that is predicted taken be the last instruction
437 on an I-cache line: delay slot will need an entire line to be fetched
438-- Make a FP instruction or a branch be the 4th instruction in a group.
439 For branches, there are tradeoffs in reordering to make this happen
440 (see pg. 327).
441** Don't put a branch in a group that crosses a 32-byte boundary!
442 An artificial branch is inserted after every 32 bytes, and having
443 another branch will force the group to be broken into 2 groups.
444
445iTLB rules:
446-- Don't let a loop span two memory pages, if possible
447
448Branch prediction performance:
449-- Don't make the branch in a delay slot the target of a branch
450-- Try not to have 2 predicted branches within a group of 4 instructions
451 (because each such group has a single branch target field).
452-- Try to align branches in slots 0, 2, 4 or 6 of a cache line (to avoid
453 the wrong prediction bits being used in some cases).
454
455D-Cache timing constraints:
456-- Signed int loads of less than 64 bits have 3 cycle latency, not 2
457-- All other loads that hit in D-Cache have 2 cycle latency
458-- All loads are returned IN ORDER, so a D-Cache miss will delay a later hit
459-- Mis-aligned loads or stores cause a trap. In particular, replace
460 mis-aligned FP double precision l/s with 2 single-precision l/s.
461-- Simulations of integer codes show increase in avg. group size of
462 33% when code (including esp. non-faulting loads) is moved across
463 one branch, and 50% across 2 branches.
464
465E-Cache timing constraints:
466-- Scheduling for E-cache (D-Cache misses) is effective (due to load buffering)
467
468Store buffer timing constraints:
469-- Stores can be executed in same cycle as instruction producing the value
470-- Stores are buffered and have lower priority for E-cache until
471 highwater mark is reached in the store buffer (5 stores)
472
473Pipeline constraints:
474-- Shifts can only use IEU0.
475-- CC setting instructions can only use IEU1.
476-- Several other instructions must only use IEU1:
477 EDGE(?), ARRAY(?), CALL, JMPL, BPr, PST, and FCMP.
478-- Two instructions cannot store to the same register file in a single cycle
479 (single write port per file).
480
481Issue and grouping constraints:
482-- FP and branch instructions must use slot 4.
483-- Shift instructions cannot be grouped with other IEU0-specific instructions.
484-- CC setting instructions cannot be grouped with other IEU1-specific instrs.
485-- Several instructions must be issued in a single-instruction group:
486 MOVcc or MOVr, MULs/x and DIVs/x, SAVE/RESTORE, many others
487-- A CALL or JMPL breaks a group, ie, is not combined with subsequent instrs.
488--
489--
490
491Branch delay slot scheduling rules:
492-- A CTI couple (two back-to-back CTI instructions in the dynamic stream)
493 has a 9-instruction penalty: the entire pipeline is flushed when the
494 second instruction reaches stage 9 (W-Writeback).
495-- Avoid putting multicycle instructions, and instructions that may cause
496 load misses, in the delay slot of an annulling branch.
497-- Avoid putting WR, SAVE..., RESTORE and RETURN instructions in the
498 delay slot of an annulling branch.
499
500 *--------------------------------------------------------------------------- */
501
502//---------------------------------------------------------------------------
503// List of CPUResources for UltraSPARC IIi.
504//---------------------------------------------------------------------------
505
506const CPUResource AllIssueSlots( "All Instr Slots", 4);
507const CPUResource IntIssueSlots( "Int Instr Slots", 3);
508const CPUResource First3IssueSlots("Instr Slots 0-3", 3);
509const CPUResource LSIssueSlots( "Load-Store Instr Slot", 1);
510const CPUResource CTIIssueSlots( "Ctrl Transfer Instr Slot", 1);
511const CPUResource FPAIssueSlots( "Int Instr Slot 1", 1);
512const CPUResource FPMIssueSlots( "Int Instr Slot 1", 1);
513
514// IEUN instructions can use either Alu and should use IAluN.
515// IEU0 instructions must use Alu 1 and should use both IAluN and IAlu0.
516// IEU1 instructions must use Alu 2 and should use both IAluN and IAlu1.
517const CPUResource IAluN("Int ALU 1or2", 2);
518const CPUResource IAlu0("Int ALU 1", 1);
519const CPUResource IAlu1("Int ALU 2", 1);
520
521const CPUResource LSAluC1("Load/Store Unit Addr Cycle", 1);
522const CPUResource LSAluC2("Load/Store Unit Issue Cycle", 1);
523const CPUResource LdReturn("Load Return Unit", 1);
524
525const CPUResource FPMAluC1("FP Mul/Div Alu Cycle 1", 1);
526const CPUResource FPMAluC2("FP Mul/Div Alu Cycle 2", 1);
527const CPUResource FPMAluC3("FP Mul/Div Alu Cycle 3", 1);
528
529const CPUResource FPAAluC1("FP Other Alu Cycle 1", 1);
530const CPUResource FPAAluC2("FP Other Alu Cycle 2", 1);
531const CPUResource FPAAluC3("FP Other Alu Cycle 3", 1);
532
533const CPUResource IRegReadPorts("Int Reg ReadPorts", INT_MAX); // CHECK
534const CPUResource IRegWritePorts("Int Reg WritePorts", 2); // CHECK
535const CPUResource FPRegReadPorts("FP Reg Read Ports", INT_MAX); // CHECK
536const CPUResource FPRegWritePorts("FP Reg Write Ports", 1); // CHECK
537
538const CPUResource CTIDelayCycle( "CTI delay cycle", 1);
539const CPUResource FCMPDelayCycle("FCMP delay cycle", 1);
540
541
542//---------------------------------------------------------------------------
543// const InstrClassRUsage SparcRUsageDesc[]
544//
545// Purpose:
546// Resource usage information for instruction in each scheduling class.
547// The InstrRUsage Objects for individual classes are specified first.
548// Note that fetch and decode are decoupled from the execution pipelines
549// via an instr buffer, so they are not included in the cycles below.
550//---------------------------------------------------------------------------
551
552const InstrClassRUsage NoneClassRUsage = {
553 SPARC_NONE,
554 /*totCycles*/ 7,
555
556 /* maxIssueNum */ 4,
557 /* isSingleIssue */ false,
558 /* breaksGroup */ false,
559 /* numBubbles */ 0,
560
561 /*numSlots*/ 4,
562 /* feasibleSlots[] */ { 0, 1, 2, 3 },
563
564 /*numEntries*/ 0,
565 /* V[] */ {
566 /*Cycle G */
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000567 /*Ccle E */
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000568 /*Cycle C */
569 /*Cycle N1*/
570 /*Cycle N1*/
571 /*Cycle N1*/
572 /*Cycle W */
573 }
574};
575
576const InstrClassRUsage IEUNClassRUsage = {
577 SPARC_IEUN,
578 /*totCycles*/ 7,
579
580 /* maxIssueNum */ 3,
581 /* isSingleIssue */ false,
582 /* breaksGroup */ false,
583 /* numBubbles */ 0,
584
585 /*numSlots*/ 3,
586 /* feasibleSlots[] */ { 0, 1, 2 },
587
588 /*numEntries*/ 4,
589 /* V[] */ {
590 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
591 { IntIssueSlots.rid, 0, 1 },
592 /*Cycle E */ { IAluN.rid, 1, 1 },
593 /*Cycle C */
594 /*Cycle N1*/
595 /*Cycle N1*/
596 /*Cycle N1*/
597 /*Cycle W */ { IRegWritePorts.rid, 6, 1 }
598 }
599};
600
601const InstrClassRUsage IEU0ClassRUsage = {
602 SPARC_IEU0,
603 /*totCycles*/ 7,
604
605 /* maxIssueNum */ 1,
606 /* isSingleIssue */ false,
607 /* breaksGroup */ false,
608 /* numBubbles */ 0,
609
610 /*numSlots*/ 3,
611 /* feasibleSlots[] */ { 0, 1, 2 },
612
613 /*numEntries*/ 5,
614 /* V[] */ {
615 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
616 { IntIssueSlots.rid, 0, 1 },
617 /*Cycle E */ { IAluN.rid, 1, 1 },
618 { IAlu0.rid, 1, 1 },
619 /*Cycle C */
620 /*Cycle N1*/
621 /*Cycle N1*/
622 /*Cycle N1*/
623 /*Cycle W */ { IRegWritePorts.rid, 6, 1 }
624 }
625};
626
627const InstrClassRUsage IEU1ClassRUsage = {
628 SPARC_IEU1,
629 /*totCycles*/ 7,
630
631 /* maxIssueNum */ 1,
632 /* isSingleIssue */ false,
633 /* breaksGroup */ false,
634 /* numBubbles */ 0,
635
636 /*numSlots*/ 3,
637 /* feasibleSlots[] */ { 0, 1, 2 },
638
639 /*numEntries*/ 5,
640 /* V[] */ {
641 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
642 { IntIssueSlots.rid, 0, 1 },
643 /*Cycle E */ { IAluN.rid, 1, 1 },
644 { IAlu1.rid, 1, 1 },
645 /*Cycle C */
646 /*Cycle N1*/
647 /*Cycle N1*/
648 /*Cycle N1*/
649 /*Cycle W */ { IRegWritePorts.rid, 6, 1 }
650 }
651};
652
653const InstrClassRUsage FPMClassRUsage = {
654 SPARC_FPM,
655 /*totCycles*/ 7,
656
657 /* maxIssueNum */ 1,
658 /* isSingleIssue */ false,
659 /* breaksGroup */ false,
660 /* numBubbles */ 0,
661
662 /*numSlots*/ 4,
663 /* feasibleSlots[] */ { 0, 1, 2, 3 },
664
665 /*numEntries*/ 7,
666 /* V[] */ {
667 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
668 { FPMIssueSlots.rid, 0, 1 },
669 /*Cycle E */ { FPRegReadPorts.rid, 1, 1 },
670 /*Cycle C */ { FPMAluC1.rid, 2, 1 },
671 /*Cycle N1*/ { FPMAluC2.rid, 3, 1 },
672 /*Cycle N1*/ { FPMAluC3.rid, 4, 1 },
673 /*Cycle N1*/
674 /*Cycle W */ { FPRegWritePorts.rid, 6, 1 }
675 }
676};
677
678const InstrClassRUsage FPAClassRUsage = {
679 SPARC_FPA,
680 /*totCycles*/ 7,
681
682 /* maxIssueNum */ 1,
683 /* isSingleIssue */ false,
684 /* breaksGroup */ false,
685 /* numBubbles */ 0,
686
687 /*numSlots*/ 4,
688 /* feasibleSlots[] */ { 0, 1, 2, 3 },
689
690 /*numEntries*/ 7,
691 /* V[] */ {
692 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
693 { FPAIssueSlots.rid, 0, 1 },
694 /*Cycle E */ { FPRegReadPorts.rid, 1, 1 },
695 /*Cycle C */ { FPAAluC1.rid, 2, 1 },
696 /*Cycle N1*/ { FPAAluC2.rid, 3, 1 },
697 /*Cycle N1*/ { FPAAluC3.rid, 4, 1 },
698 /*Cycle N1*/
699 /*Cycle W */ { FPRegWritePorts.rid, 6, 1 }
700 }
701};
702
703const InstrClassRUsage LDClassRUsage = {
704 SPARC_LD,
705 /*totCycles*/ 7,
706
707 /* maxIssueNum */ 1,
708 /* isSingleIssue */ false,
709 /* breaksGroup */ false,
710 /* numBubbles */ 0,
711
712 /*numSlots*/ 3,
713 /* feasibleSlots[] */ { 0, 1, 2, },
714
715 /*numEntries*/ 6,
716 /* V[] */ {
717 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
718 { First3IssueSlots.rid, 0, 1 },
719 { LSIssueSlots.rid, 0, 1 },
720 /*Cycle E */ { LSAluC1.rid, 1, 1 },
721 /*Cycle C */ { LSAluC2.rid, 2, 1 },
722 { LdReturn.rid, 2, 1 },
723 /*Cycle N1*/
724 /*Cycle N1*/
725 /*Cycle N1*/
726 /*Cycle W */ { IRegWritePorts.rid, 6, 1 }
727 }
728};
729
730const InstrClassRUsage STClassRUsage = {
731 SPARC_ST,
732 /*totCycles*/ 7,
733
734 /* maxIssueNum */ 1,
735 /* isSingleIssue */ false,
736 /* breaksGroup */ false,
737 /* numBubbles */ 0,
738
739 /*numSlots*/ 3,
740 /* feasibleSlots[] */ { 0, 1, 2 },
741
742 /*numEntries*/ 4,
743 /* V[] */ {
744 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
745 { First3IssueSlots.rid, 0, 1 },
746 { LSIssueSlots.rid, 0, 1 },
747 /*Cycle E */ { LSAluC1.rid, 1, 1 },
748 /*Cycle C */ { LSAluC2.rid, 2, 1 }
749 /*Cycle N1*/
750 /*Cycle N1*/
751 /*Cycle N1*/
752 /*Cycle W */
753 }
754};
755
756const InstrClassRUsage CTIClassRUsage = {
757 SPARC_CTI,
758 /*totCycles*/ 7,
759
760 /* maxIssueNum */ 1,
761 /* isSingleIssue */ false,
762 /* breaksGroup */ false,
763 /* numBubbles */ 0,
764
765 /*numSlots*/ 4,
766 /* feasibleSlots[] */ { 0, 1, 2, 3 },
767
768 /*numEntries*/ 4,
769 /* V[] */ {
770 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
771 { CTIIssueSlots.rid, 0, 1 },
772 /*Cycle E */ { IAlu0.rid, 1, 1 },
773 /*Cycles E-C */ { CTIDelayCycle.rid, 1, 2 }
774 /*Cycle C */
775 /*Cycle N1*/
776 /*Cycle N1*/
777 /*Cycle N1*/
778 /*Cycle W */
779 }
780};
781
782const InstrClassRUsage SingleClassRUsage = {
783 SPARC_SINGLE,
784 /*totCycles*/ 7,
785
786 /* maxIssueNum */ 1,
787 /* isSingleIssue */ true,
788 /* breaksGroup */ false,
789 /* numBubbles */ 0,
790
791 /*numSlots*/ 1,
792 /* feasibleSlots[] */ { 0 },
793
794 /*numEntries*/ 5,
795 /* V[] */ {
796 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
797 { AllIssueSlots.rid, 0, 1 },
798 { AllIssueSlots.rid, 0, 1 },
799 { AllIssueSlots.rid, 0, 1 },
800 /*Cycle E */ { IAlu0.rid, 1, 1 }
801 /*Cycle C */
802 /*Cycle N1*/
803 /*Cycle N1*/
804 /*Cycle N1*/
805 /*Cycle W */
806 }
807};
808
809
810const InstrClassRUsage SparcRUsageDesc[] = {
811 NoneClassRUsage,
812 IEUNClassRUsage,
813 IEU0ClassRUsage,
814 IEU1ClassRUsage,
815 FPMClassRUsage,
816 FPAClassRUsage,
817 CTIClassRUsage,
818 LDClassRUsage,
819 STClassRUsage,
820 SingleClassRUsage
821};
822
823
824//---------------------------------------------------------------------------
825// const InstrIssueDelta SparcInstrIssueDeltas[]
826//
827// Purpose:
828// Changes to issue restrictions information in InstrClassRUsage for
829// instructions that differ from other instructions in their class.
830//---------------------------------------------------------------------------
831
832const InstrIssueDelta SparcInstrIssueDeltas[] = {
833
834 // opCode, isSingleIssue, breaksGroup, numBubbles
835
836 // Special cases for single-issue only
837 // Other single issue cases are below.
838//{ LDDA, true, true, 0 },
839//{ STDA, true, true, 0 },
840//{ LDDF, true, true, 0 },
841//{ LDDFA, true, true, 0 },
842 { ADDC, true, true, 0 },
843 { ADDCcc, true, true, 0 },
844 { SUBC, true, true, 0 },
845 { SUBCcc, true, true, 0 },
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000846//{ LDSTUB, true, true, 0 },
847//{ SWAP, true, true, 0 },
848//{ SWAPA, true, true, 0 },
849//{ CAS, true, true, 0 },
850//{ CASA, true, true, 0 },
851//{ CASX, true, true, 0 },
852//{ CASXA, true, true, 0 },
853//{ LDFSR, true, true, 0 },
854//{ LDFSRA, true, true, 0 },
855//{ LDXFSR, true, true, 0 },
856//{ LDXFSRA, true, true, 0 },
857//{ STFSR, true, true, 0 },
858//{ STFSRA, true, true, 0 },
859//{ STXFSR, true, true, 0 },
860//{ STXFSRA, true, true, 0 },
861//{ SAVED, true, true, 0 },
862//{ RESTORED, true, true, 0 },
863//{ FLUSH, true, true, 9 },
864//{ FLUSHW, true, true, 9 },
865//{ ALIGNADDR, true, true, 0 },
866 { RETURN, true, true, 0 },
867//{ DONE, true, true, 0 },
868//{ RETRY, true, true, 0 },
869//{ WR, true, true, 0 },
870//{ WRPR, true, true, 4 },
871//{ RD, true, true, 0 },
872//{ RDPR, true, true, 0 },
873//{ TCC, true, true, 0 },
874//{ SHUTDOWN, true, true, 0 },
875
876 // Special cases for breaking group *before*
877 // CURRENTLY NOT SUPPORTED!
878 { CALL, false, false, 0 },
Vikram S. Advec1521632001-10-22 13:31:53 +0000879 { JMPLCALL, false, false, 0 },
880 { JMPLRET, false, false, 0 },
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000881
882 // Special cases for breaking the group *after*
883 { MULX, true, true, (4+34)/2 },
884 { FDIVS, false, true, 0 },
885 { FDIVD, false, true, 0 },
886 { FDIVQ, false, true, 0 },
887 { FSQRTS, false, true, 0 },
888 { FSQRTD, false, true, 0 },
889 { FSQRTQ, false, true, 0 },
890//{ FCMP{LE,GT,NE,EQ}, false, true, 0 },
891
892 // Instructions that introduce bubbles
893//{ MULScc, true, true, 2 },
894//{ SMULcc, true, true, (4+18)/2 },
895//{ UMULcc, true, true, (4+19)/2 },
896 { SDIVX, true, true, 68 },
897 { UDIVX, true, true, 68 },
898//{ SDIVcc, true, true, 36 },
899//{ UDIVcc, true, true, 37 },
900//{ WR, false, false, 4 },
901//{ WRPR, false, false, 4 },
902};
903
904
905//---------------------------------------------------------------------------
906// const InstrRUsageDelta SparcInstrUsageDeltas[]
907//
908// Purpose:
909// Changes to resource usage information in InstrClassRUsage for
910// instructions that differ from other instructions in their class.
911//---------------------------------------------------------------------------
912
913const InstrRUsageDelta SparcInstrUsageDeltas[] = {
914
915 // MachineOpCode, Resource, Start cycle, Num cycles
916
917 //
918 // JMPL counts as a load/store instruction for issue!
919 //
Vikram S. Advec1521632001-10-22 13:31:53 +0000920 { JMPLCALL, LSIssueSlots.rid, 0, 1 },
921 { JMPLRET, LSIssueSlots.rid, 0, 1 },
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000922
923 //
924 // Many instructions cannot issue for the next 2 cycles after an FCMP
925 // We model that with a fake resource FCMPDelayCycle.
926 //
927 { FCMPS, FCMPDelayCycle.rid, 1, 3 },
928 { FCMPD, FCMPDelayCycle.rid, 1, 3 },
929 { FCMPQ, FCMPDelayCycle.rid, 1, 3 },
930
931 { MULX, FCMPDelayCycle.rid, 1, 1 },
932 { SDIVX, FCMPDelayCycle.rid, 1, 1 },
933 { UDIVX, FCMPDelayCycle.rid, 1, 1 },
934//{ SMULcc, FCMPDelayCycle.rid, 1, 1 },
935//{ UMULcc, FCMPDelayCycle.rid, 1, 1 },
936//{ SDIVcc, FCMPDelayCycle.rid, 1, 1 },
937//{ UDIVcc, FCMPDelayCycle.rid, 1, 1 },
938 { STD, FCMPDelayCycle.rid, 1, 1 },
939 { FMOVRSZ, FCMPDelayCycle.rid, 1, 1 },
940 { FMOVRSLEZ,FCMPDelayCycle.rid, 1, 1 },
941 { FMOVRSLZ, FCMPDelayCycle.rid, 1, 1 },
942 { FMOVRSNZ, FCMPDelayCycle.rid, 1, 1 },
943 { FMOVRSGZ, FCMPDelayCycle.rid, 1, 1 },
944 { FMOVRSGEZ,FCMPDelayCycle.rid, 1, 1 },
945
946 //
947 // Some instructions are stalled in the GROUP stage if a CTI is in
948 // the E or C stage
949 //
950 { LDD, CTIDelayCycle.rid, 1, 1 },
951//{ LDDA, CTIDelayCycle.rid, 1, 1 },
952//{ LDDSTUB, CTIDelayCycle.rid, 1, 1 },
953//{ LDDSTUBA, CTIDelayCycle.rid, 1, 1 },
954//{ SWAP, CTIDelayCycle.rid, 1, 1 },
955//{ SWAPA, CTIDelayCycle.rid, 1, 1 },
956//{ CAS, CTIDelayCycle.rid, 1, 1 },
957//{ CASA, CTIDelayCycle.rid, 1, 1 },
958//{ CASX, CTIDelayCycle.rid, 1, 1 },
959//{ CASXA, CTIDelayCycle.rid, 1, 1 },
960
961 //
962 // Signed int loads of less than dword size return data in cycle N1 (not C)
963 // and put all loads in consecutive cycles into delayed load return mode.
964 //
965 { LDSB, LdReturn.rid, 2, -1 },
966 { LDSB, LdReturn.rid, 3, 1 },
967
968 { LDSH, LdReturn.rid, 2, -1 },
969 { LDSH, LdReturn.rid, 3, 1 },
970
971 { LDSW, LdReturn.rid, 2, -1 },
972 { LDSW, LdReturn.rid, 3, 1 },
973
974
975#undef EXPLICIT_BUBBLES_NEEDED
976#ifdef EXPLICIT_BUBBLES_NEEDED
977 //
978 // MULScc inserts one bubble.
979 // This means it breaks the current group (captured in UltraSparcSchedInfo)
980 // *and occupies all issue slots for the next cycle
981 //
982//{ MULScc, AllIssueSlots.rid, 2, 2-1 },
983//{ MULScc, AllIssueSlots.rid, 2, 2-1 },
984//{ MULScc, AllIssueSlots.rid, 2, 2-1 },
985//{ MULScc, AllIssueSlots.rid, 2, 2-1 },
986
987 //
988 // SMULcc inserts between 4 and 18 bubbles, depending on #leading 0s in rs1.
989 // We just model this with a simple average.
990 //
991//{ SMULcc, AllIssueSlots.rid, 2, ((4+18)/2)-1 },
992//{ SMULcc, AllIssueSlots.rid, 2, ((4+18)/2)-1 },
993//{ SMULcc, AllIssueSlots.rid, 2, ((4+18)/2)-1 },
994//{ SMULcc, AllIssueSlots.rid, 2, ((4+18)/2)-1 },
995
996 // SMULcc inserts between 4 and 19 bubbles, depending on #leading 0s in rs1.
997//{ UMULcc, AllIssueSlots.rid, 2, ((4+19)/2)-1 },
998//{ UMULcc, AllIssueSlots.rid, 2, ((4+19)/2)-1 },
999//{ UMULcc, AllIssueSlots.rid, 2, ((4+19)/2)-1 },
1000//{ UMULcc, AllIssueSlots.rid, 2, ((4+19)/2)-1 },
1001
1002 //
1003 // MULX inserts between 4 and 34 bubbles, depending on #leading 0s in rs1.
1004 //
1005 { MULX, AllIssueSlots.rid, 2, ((4+34)/2)-1 },
1006 { MULX, AllIssueSlots.rid, 2, ((4+34)/2)-1 },
1007 { MULX, AllIssueSlots.rid, 2, ((4+34)/2)-1 },
1008 { MULX, AllIssueSlots.rid, 2, ((4+34)/2)-1 },
1009
1010 //
1011 // SDIVcc inserts 36 bubbles.
1012 //
1013//{ SDIVcc, AllIssueSlots.rid, 2, 36-1 },
1014//{ SDIVcc, AllIssueSlots.rid, 2, 36-1 },
1015//{ SDIVcc, AllIssueSlots.rid, 2, 36-1 },
1016//{ SDIVcc, AllIssueSlots.rid, 2, 36-1 },
1017
1018 // UDIVcc inserts 37 bubbles.
1019//{ UDIVcc, AllIssueSlots.rid, 2, 37-1 },
1020//{ UDIVcc, AllIssueSlots.rid, 2, 37-1 },
1021//{ UDIVcc, AllIssueSlots.rid, 2, 37-1 },
1022//{ UDIVcc, AllIssueSlots.rid, 2, 37-1 },
1023
1024 //
1025 // SDIVX inserts 68 bubbles.
1026 //
1027 { SDIVX, AllIssueSlots.rid, 2, 68-1 },
1028 { SDIVX, AllIssueSlots.rid, 2, 68-1 },
1029 { SDIVX, AllIssueSlots.rid, 2, 68-1 },
1030 { SDIVX, AllIssueSlots.rid, 2, 68-1 },
1031
1032 //
1033 // UDIVX inserts 68 bubbles.
1034 //
1035 { UDIVX, AllIssueSlots.rid, 2, 68-1 },
1036 { UDIVX, AllIssueSlots.rid, 2, 68-1 },
1037 { UDIVX, AllIssueSlots.rid, 2, 68-1 },
1038 { UDIVX, AllIssueSlots.rid, 2, 68-1 },
1039
1040 //
1041 // WR inserts 4 bubbles.
1042 //
1043//{ WR, AllIssueSlots.rid, 2, 68-1 },
1044//{ WR, AllIssueSlots.rid, 2, 68-1 },
1045//{ WR, AllIssueSlots.rid, 2, 68-1 },
1046//{ WR, AllIssueSlots.rid, 2, 68-1 },
1047
1048 //
1049 // WRPR inserts 4 bubbles.
1050 //
1051//{ WRPR, AllIssueSlots.rid, 2, 68-1 },
1052//{ WRPR, AllIssueSlots.rid, 2, 68-1 },
1053//{ WRPR, AllIssueSlots.rid, 2, 68-1 },
1054//{ WRPR, AllIssueSlots.rid, 2, 68-1 },
1055
1056 //
1057 // DONE inserts 9 bubbles.
1058 //
1059//{ DONE, AllIssueSlots.rid, 2, 9-1 },
1060//{ DONE, AllIssueSlots.rid, 2, 9-1 },
1061//{ DONE, AllIssueSlots.rid, 2, 9-1 },
1062//{ DONE, AllIssueSlots.rid, 2, 9-1 },
1063
1064 //
1065 // RETRY inserts 9 bubbles.
1066 //
1067//{ RETRY, AllIssueSlots.rid, 2, 9-1 },
1068//{ RETRY, AllIssueSlots.rid, 2, 9-1 },
1069//{ RETRY, AllIssueSlots.rid, 2, 9-1 },
1070//{ RETRY, AllIssueSlots.rid, 2, 9-1 },
1071
Chris Lattnere369fcb2001-10-13 06:54:54 +00001072#endif /*EXPLICIT_BUBBLES_NEEDED */
Chris Lattnerc6495ee2001-09-14 03:56:45 +00001073};
1074
1075
1076
1077// Additional delays to be captured in code:
1078// 1. RDPR from several state registers (page 349)
1079// 2. RD from *any* register (page 349)
1080// 3. Writes to TICK, PSTATE, TL registers and FLUSH{W} instr (page 349)
1081// 4. Integer store can be in same group as instr producing value to store.
1082// 5. BICC and BPICC can be in the same group as instr producing CC (pg 350)
1083// 6. FMOVr cannot be in the same or next group as an IEU instr (pg 351).
1084// 7. The second instr. of a CTI group inserts 9 bubbles (pg 351)
1085// 8. WR{PR}, SVAE, SAVED, RESTORE, RESTORED, RETURN, RETRY, and DONE that
1086// follow an annulling branch cannot be issued in the same group or in
1087// the 3 groups following the branch.
1088// 9. A predicted annulled load does not stall dependent instructions.
1089// Other annulled delay slot instructions *do* stall dependents, so
1090// nothing special needs to be done for them during scheduling.
1091//10. Do not put a load use that may be annulled in the same group as the
1092// branch. The group will stall until the load returns.
1093//11. Single-prec. FP loads lock 2 registers, for dependency checking.
1094//
1095//
1096// Additional delays we cannot or will not capture:
1097// 1. If DCTI is last word of cache line, it is delayed until next line can be
1098// fetched. Also, other DCTI alignment-related delays (pg 352)
1099// 2. Load-after-store is delayed by 7 extra cycles if load hits in D-Cache.
1100// Also, several other store-load and load-store conflicts (pg 358)
1101// 3. MEMBAR, LD{X}FSR, LDD{A} and a bunch of other load stalls (pg 358)
1102// 4. There can be at most 8 outstanding buffered store instructions
1103// (including some others like MEMBAR, LDSTUB, CAS{AX}, and FLUSH)
1104
1105
1106
1107//---------------------------------------------------------------------------
1108// class UltraSparcSchedInfo
1109//
1110// Purpose:
1111// Interface to instruction scheduling information for UltraSPARC.
1112// The parameter values above are based on UltraSPARC IIi.
1113//---------------------------------------------------------------------------
1114
1115
1116class UltraSparcSchedInfo: public MachineSchedInfo {
1117public:
1118 /*ctor*/ UltraSparcSchedInfo (const MachineInstrInfo* mii);
1119 /*dtor*/ virtual ~UltraSparcSchedInfo () {}
1120protected:
1121 virtual void initializeResources ();
1122};
1123
Chris Lattnerf6e0e282001-09-14 04:32:55 +00001124
1125//---------------------------------------------------------------------------
Vikram S. Advec1521632001-10-22 13:31:53 +00001126// class UltraSparcFrameInfo
1127//
1128// Purpose:
1129// Interface to stack frame layout info for the UltraSPARC.
1130// Note that there is no machine-independent interface to this information
1131//---------------------------------------------------------------------------
1132
1133class UltraSparcFrameInfo: public NonCopyable {
1134public:
1135 static const int MinStackFrameSize = 176;
1136 static const int FirstOutgoingArgOffsetFromSP = 128;
1137 static const int FirstOptionalOutgoingArgOffsetFromSP = 176;
1138 static const int StaticStackAreaOffsetFromFP = -1;
Ruchira Sasanka20c82b12001-10-28 18:15:12 +00001139
1140 static const int FirstIncomingArgOffsetFromFP = 126;
1141
Vikram S. Advec1521632001-10-22 13:31:53 +00001142 static int getFirstAutomaticVarOffsetFromFP (const Method* method);
1143 static int getRegSpillAreaOffsetFromFP (const Method* method);
1144 static int getFrameSizeBelowDynamicArea (const Method* method);
1145};
1146
1147
1148
1149//---------------------------------------------------------------------------
Chris Lattnerf6e0e282001-09-14 04:32:55 +00001150// class UltraSparcMachine
1151//
1152// Purpose:
1153// Primary interface to machine description for the UltraSPARC.
1154// Primarily just initializes machine-dependent parameters in
1155// class TargetMachine, and creates machine-dependent subclasses
Vikram S. Adve339084b2001-09-18 13:04:24 +00001156// for classes such as InstrInfo, SchedInfo and RegInfo.
Chris Lattnerf6e0e282001-09-14 04:32:55 +00001157//---------------------------------------------------------------------------
1158
1159class UltraSparc : public TargetMachine {
Vikram S. Adve339084b2001-09-18 13:04:24 +00001160private:
1161 UltraSparcInstrInfo instrInfo;
1162 UltraSparcSchedInfo schedInfo;
1163 UltraSparcRegInfo regInfo;
Vikram S. Advec1521632001-10-22 13:31:53 +00001164 UltraSparcFrameInfo frameInfo;
Chris Lattnerf6e0e282001-09-14 04:32:55 +00001165public:
1166 UltraSparc();
1167 virtual ~UltraSparc() {}
Vikram S. Adve339084b2001-09-18 13:04:24 +00001168
Chris Lattner32f600a2001-09-19 13:47:12 +00001169 virtual const MachineInstrInfo &getInstrInfo() const { return instrInfo; }
1170 virtual const MachineSchedInfo &getSchedInfo() const { return schedInfo; }
1171 virtual const MachineRegInfo &getRegInfo() const { return regInfo; }
Vikram S. Advec1521632001-10-22 13:31:53 +00001172 const UltraSparcFrameInfo &getFrameInfo() const { return frameInfo; }
1173
Vikram S. Adve339084b2001-09-18 13:04:24 +00001174
Chris Lattnerf6e0e282001-09-14 04:32:55 +00001175 // compileMethod - For the sparc, we do instruction selection, followed by
1176 // delay slot scheduling, then register allocation.
1177 //
1178 virtual bool compileMethod(Method *M);
Chris Lattner32f600a2001-09-19 13:47:12 +00001179
1180 //
1181 // emitAssembly - Output assembly language code (a .s file) for the specified
1182 // module. The specified module must have been compiled before this may be
1183 // used.
1184 //
Chris Lattnerec0a95f2001-10-15 15:54:43 +00001185 virtual void emitAssembly(const Module *M, ostream &OutStr) const;
Chris Lattnerf6e0e282001-09-14 04:32:55 +00001186};
1187
1188
Chris Lattnerc6495ee2001-09-14 03:56:45 +00001189#endif