blob: 2f151b788789fec89fe60db6c61704a215f00927 [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
Ruchira Sasanka3839e6e2001-11-03 19:59:59 +0000257 MachineInstr * cpCCR2IntMI(const unsigned IntReg) const;
258 MachineInstr * cpInt2CCRMI(const unsigned IntReg) const;
259
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000260 public:
261
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000262
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000263 UltraSparcRegInfo(const UltraSparc *const USI ) : UltraSparcInfo(USI),
264 NumOfIntArgRegs(6),
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000265 NumOfFloatArgRegs(32),
Ruchira Sasanka20c82b12001-10-28 18:15:12 +0000266 InvalidRegNum(1000),
267 SizeOfOperandOnStack(8)
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000268 {
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000269 MachineRegClassArr.push_back( new SparcIntRegClass(IntRegClassID) );
270 MachineRegClassArr.push_back( new SparcFloatRegClass(FloatRegClassID) );
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000271 MachineRegClassArr.push_back( new SparcIntCCRegClass(IntCCRegClassID) );
272 MachineRegClassArr.push_back( new SparcFloatCCRegClass(FloatCCRegClassID));
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000273
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000274 assert( SparcFloatRegOrder::StartOfNonVolatileRegs == 32 &&
275 "32 Float regs are used for float arg passing");
Ruchira Sasanka20c82b12001-10-28 18:15:12 +0000276
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000277 }
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000278
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000279 // ***** TODO Delete
280 ~UltraSparcRegInfo(void) { } // empty destructor
281
282
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000283 inline const UltraSparc & getUltraSparcInfo() const {
284 return *UltraSparcInfo;
285 }
286
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000287
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000288
289 inline unsigned getRegClassIDOfValue (const Value *const Val,
290 bool isCCReg = false) const {
291
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000292 Type::PrimitiveID ty = (Val->getType())->getPrimitiveID();
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000293
294 unsigned res;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000295
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000296 if( (ty && ty <= Type::LongTyID) || (ty == Type::LabelTyID) ||
297 (ty == Type::MethodTyID) || (ty == Type::PointerTyID) )
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000298 res = IntRegClassID; // sparc int reg (ty=0: void)
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000299 else if( ty <= Type::DoubleTyID)
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000300 res = FloatRegClassID; // sparc float reg class
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000301 else {
Chris Lattner1e23ed72001-10-15 18:15:27 +0000302 cerr << "TypeID: " << ty << endl;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000303 assert(0 && "Cannot resolve register class for type");
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000304 }
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000305
306 if(isCCReg)
307 return res + 2; // corresponidng condition code regiser
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000308 else
309 return res;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000310 }
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000311
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000312 // returns the register tha contains always zero
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000313 // this is the unified register number
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000314 inline int getZeroRegNum() const { return SparcIntRegOrder::g0; }
315
316 // returns the reg used for pushing the address when a method is called.
317 // This can be used for other purposes between calls
318 unsigned getCallAddressReg() const { return SparcIntRegOrder::o7; }
319
320
321 // and when we return from a method. It should be made sure that this
322 // register contains the return value when a return instruction is reached.
323 unsigned getReturnAddressReg() const { return SparcIntRegOrder::i7; }
324
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000325 void suggestRegs4MethodArgs(const Method *const Meth,
326 LiveRangeInfo& LRI) const;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000327
Ruchira Sasankacc3ccac2001-10-15 16:25:28 +0000328 void suggestRegs4CallArgs(const MachineInstr *const CallMI,
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000329 LiveRangeInfo& LRI, vector<RegClass *> RCL) const;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000330
Ruchira Sasankacc3ccac2001-10-15 16:25:28 +0000331 void suggestReg4RetValue(const MachineInstr *const RetMI,
332 LiveRangeInfo& LRI ) const;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000333
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000334
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000335 void colorMethodArgs(const Method *const Meth, LiveRangeInfo& LRI,
336 AddedInstrns *const FirstAI) const;
337
Ruchira Sasankacc3ccac2001-10-15 16:25:28 +0000338 void colorCallArgs(const MachineInstr *const CallMI, LiveRangeInfo& LRI,
Ruchira Sasanka20c82b12001-10-28 18:15:12 +0000339 AddedInstrns *const CallAI, PhyRegAlloc &PRA) const;
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000340
Ruchira Sasankacc3ccac2001-10-15 16:25:28 +0000341 void colorRetValue(const MachineInstr *const RetI, LiveRangeInfo& LRI,
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000342 AddedInstrns *const RetAI) const;
343
344
Ruchira Sasankacc3ccac2001-10-15 16:25:28 +0000345 // bool handleSpecialMInstr(const MachineInstr * MInst,
346 // LiveRangeInfo& LRI, vector<RegClass *> RCL) const;
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000347
348
349 static void printReg(const LiveRange *const LR) ;
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000350
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000351 // this method provides a unique number for each register
352 inline int getUnifiedRegNum(int RegClassID, int reg) const {
353
354 if( RegClassID == IntRegClassID && reg < 32 )
355 return reg;
356 else if ( RegClassID == FloatRegClassID && reg < 64)
357 return reg + 32; // we have 32 int regs
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000358 else if( RegClassID == FloatCCRegClassID && reg < 4)
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000359 return reg + 32 + 64; // 32 int, 64 float
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000360 else if( RegClassID == IntCCRegClassID )
361 return 4+ 32 + 64; // only int cc reg
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000362 else if (reg==InvalidRegNum)
363 return InvalidRegNum;
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000364 else
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000365 assert(0 && "Invalid register class or reg number");
366
367 }
368
369 // given the unified register number, this gives the name
370 inline const string getUnifiedRegName(int reg) const {
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000371 if( reg < 32 )
372 return SparcIntRegOrder::getRegName(reg);
373 else if ( reg < (64 + 32) )
374 return SparcFloatRegOrder::getRegName( reg - 32);
375 else if( reg < (64+32+4) )
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000376 return SparcFloatCCRegOrder::getRegName( reg -32 - 64);
Ruchira Sasanka3839e6e2001-11-03 19:59:59 +0000377 else if( reg < (64+32+4+2) ) // two names: %xcc and %ccr
378 return SparcIntCCRegOrder::getRegName( reg -32 - 64 - 4);
Vikram S. Advec1521632001-10-22 13:31:53 +0000379 else if (reg== InvalidRegNum) //****** TODO: Remove */
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000380 return "<*NoReg*>";
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000381 else
382 assert(0 && "Invalid register number");
383 }
384
Vikram S. Advec1521632001-10-22 13:31:53 +0000385 inline unsigned int getRegNumInCallersWindow(int reg) {
386 if (reg == InvalidRegNum || reg >= 32)
387 return reg;
388 return SparcIntRegOrder::getRegNumInCallersWindow(reg);
389 }
390
391 inline bool mustBeRemappedInCallersWindow(int reg) {
392 return (reg != InvalidRegNum && reg < 32);
393 }
394
Ruchira Sasankab3b6f532001-10-21 16:43:41 +0000395 const Value * getCallInstRetVal(const MachineInstr *CallMI) const;
396
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000397 MachineInstr * cpReg2RegMI(const unsigned SrcReg, const unsigned DestReg,
398 const int RegType) const;
399
400 MachineInstr * cpReg2MemMI(const unsigned SrcReg, const unsigned DestPtrReg,
401 const int Offset, const int RegType) const;
402
403 MachineInstr * cpMem2RegMI(const unsigned SrcPtrReg, const int Offset,
404 const unsigned DestReg, const int RegType) const;
405
Ruchira Sasankaef1b0cb2001-11-03 17:13:27 +0000406 MachineInstr* cpValue2Value(Value *Src, Value *Dest) const;
407
408
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000409 inline bool isRegVolatile(const int RegClassID, const int Reg) const {
410 return (MachineRegClassArr[RegClassID])->isRegVolatile(Reg);
411 }
412
413
414 inline unsigned getFramePointer() const {
415 return SparcIntRegOrder::i6;
416 }
417
418 inline unsigned getStackPointer() const {
419 return SparcIntRegOrder::o6;
420 }
421
422 inline int getInvalidRegNum() const {
423 return InvalidRegNum;
424 }
425
Ruchira Sasanka20c82b12001-10-28 18:15:12 +0000426
427 void insertCallerSavingCode(const MachineInstr *MInst,
428 const BasicBlock *BB, PhyRegAlloc &PRA ) const;
429
430
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000431};
432
433
434
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000435/*---------------------------------------------------------------------------
436Scheduling guidelines for SPARC IIi:
437
438I-Cache alignment rules (pg 326)
439-- Align a branch target instruction so that it's entire group is within
440 the same cache line (may be 1-4 instructions).
441** Don't let a branch that is predicted taken be the last instruction
442 on an I-cache line: delay slot will need an entire line to be fetched
443-- Make a FP instruction or a branch be the 4th instruction in a group.
444 For branches, there are tradeoffs in reordering to make this happen
445 (see pg. 327).
446** Don't put a branch in a group that crosses a 32-byte boundary!
447 An artificial branch is inserted after every 32 bytes, and having
448 another branch will force the group to be broken into 2 groups.
449
450iTLB rules:
451-- Don't let a loop span two memory pages, if possible
452
453Branch prediction performance:
454-- Don't make the branch in a delay slot the target of a branch
455-- Try not to have 2 predicted branches within a group of 4 instructions
456 (because each such group has a single branch target field).
457-- Try to align branches in slots 0, 2, 4 or 6 of a cache line (to avoid
458 the wrong prediction bits being used in some cases).
459
460D-Cache timing constraints:
461-- Signed int loads of less than 64 bits have 3 cycle latency, not 2
462-- All other loads that hit in D-Cache have 2 cycle latency
463-- All loads are returned IN ORDER, so a D-Cache miss will delay a later hit
464-- Mis-aligned loads or stores cause a trap. In particular, replace
465 mis-aligned FP double precision l/s with 2 single-precision l/s.
466-- Simulations of integer codes show increase in avg. group size of
467 33% when code (including esp. non-faulting loads) is moved across
468 one branch, and 50% across 2 branches.
469
470E-Cache timing constraints:
471-- Scheduling for E-cache (D-Cache misses) is effective (due to load buffering)
472
473Store buffer timing constraints:
474-- Stores can be executed in same cycle as instruction producing the value
475-- Stores are buffered and have lower priority for E-cache until
476 highwater mark is reached in the store buffer (5 stores)
477
478Pipeline constraints:
479-- Shifts can only use IEU0.
480-- CC setting instructions can only use IEU1.
481-- Several other instructions must only use IEU1:
482 EDGE(?), ARRAY(?), CALL, JMPL, BPr, PST, and FCMP.
483-- Two instructions cannot store to the same register file in a single cycle
484 (single write port per file).
485
486Issue and grouping constraints:
487-- FP and branch instructions must use slot 4.
488-- Shift instructions cannot be grouped with other IEU0-specific instructions.
489-- CC setting instructions cannot be grouped with other IEU1-specific instrs.
490-- Several instructions must be issued in a single-instruction group:
491 MOVcc or MOVr, MULs/x and DIVs/x, SAVE/RESTORE, many others
492-- A CALL or JMPL breaks a group, ie, is not combined with subsequent instrs.
493--
494--
495
496Branch delay slot scheduling rules:
497-- A CTI couple (two back-to-back CTI instructions in the dynamic stream)
498 has a 9-instruction penalty: the entire pipeline is flushed when the
499 second instruction reaches stage 9 (W-Writeback).
500-- Avoid putting multicycle instructions, and instructions that may cause
501 load misses, in the delay slot of an annulling branch.
502-- Avoid putting WR, SAVE..., RESTORE and RETURN instructions in the
503 delay slot of an annulling branch.
504
505 *--------------------------------------------------------------------------- */
506
507//---------------------------------------------------------------------------
508// List of CPUResources for UltraSPARC IIi.
509//---------------------------------------------------------------------------
510
511const CPUResource AllIssueSlots( "All Instr Slots", 4);
512const CPUResource IntIssueSlots( "Int Instr Slots", 3);
513const CPUResource First3IssueSlots("Instr Slots 0-3", 3);
514const CPUResource LSIssueSlots( "Load-Store Instr Slot", 1);
515const CPUResource CTIIssueSlots( "Ctrl Transfer Instr Slot", 1);
516const CPUResource FPAIssueSlots( "Int Instr Slot 1", 1);
517const CPUResource FPMIssueSlots( "Int Instr Slot 1", 1);
518
519// IEUN instructions can use either Alu and should use IAluN.
520// IEU0 instructions must use Alu 1 and should use both IAluN and IAlu0.
521// IEU1 instructions must use Alu 2 and should use both IAluN and IAlu1.
522const CPUResource IAluN("Int ALU 1or2", 2);
523const CPUResource IAlu0("Int ALU 1", 1);
524const CPUResource IAlu1("Int ALU 2", 1);
525
526const CPUResource LSAluC1("Load/Store Unit Addr Cycle", 1);
527const CPUResource LSAluC2("Load/Store Unit Issue Cycle", 1);
528const CPUResource LdReturn("Load Return Unit", 1);
529
530const CPUResource FPMAluC1("FP Mul/Div Alu Cycle 1", 1);
531const CPUResource FPMAluC2("FP Mul/Div Alu Cycle 2", 1);
532const CPUResource FPMAluC3("FP Mul/Div Alu Cycle 3", 1);
533
534const CPUResource FPAAluC1("FP Other Alu Cycle 1", 1);
535const CPUResource FPAAluC2("FP Other Alu Cycle 2", 1);
536const CPUResource FPAAluC3("FP Other Alu Cycle 3", 1);
537
538const CPUResource IRegReadPorts("Int Reg ReadPorts", INT_MAX); // CHECK
539const CPUResource IRegWritePorts("Int Reg WritePorts", 2); // CHECK
540const CPUResource FPRegReadPorts("FP Reg Read Ports", INT_MAX); // CHECK
541const CPUResource FPRegWritePorts("FP Reg Write Ports", 1); // CHECK
542
543const CPUResource CTIDelayCycle( "CTI delay cycle", 1);
544const CPUResource FCMPDelayCycle("FCMP delay cycle", 1);
545
546
547//---------------------------------------------------------------------------
548// const InstrClassRUsage SparcRUsageDesc[]
549//
550// Purpose:
551// Resource usage information for instruction in each scheduling class.
552// The InstrRUsage Objects for individual classes are specified first.
553// Note that fetch and decode are decoupled from the execution pipelines
554// via an instr buffer, so they are not included in the cycles below.
555//---------------------------------------------------------------------------
556
557const InstrClassRUsage NoneClassRUsage = {
558 SPARC_NONE,
559 /*totCycles*/ 7,
560
561 /* maxIssueNum */ 4,
562 /* isSingleIssue */ false,
563 /* breaksGroup */ false,
564 /* numBubbles */ 0,
565
566 /*numSlots*/ 4,
567 /* feasibleSlots[] */ { 0, 1, 2, 3 },
568
569 /*numEntries*/ 0,
570 /* V[] */ {
571 /*Cycle G */
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000572 /*Ccle E */
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000573 /*Cycle C */
574 /*Cycle N1*/
575 /*Cycle N1*/
576 /*Cycle N1*/
577 /*Cycle W */
578 }
579};
580
581const InstrClassRUsage IEUNClassRUsage = {
582 SPARC_IEUN,
583 /*totCycles*/ 7,
584
585 /* maxIssueNum */ 3,
586 /* isSingleIssue */ false,
587 /* breaksGroup */ false,
588 /* numBubbles */ 0,
589
590 /*numSlots*/ 3,
591 /* feasibleSlots[] */ { 0, 1, 2 },
592
593 /*numEntries*/ 4,
594 /* V[] */ {
595 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
596 { IntIssueSlots.rid, 0, 1 },
597 /*Cycle E */ { IAluN.rid, 1, 1 },
598 /*Cycle C */
599 /*Cycle N1*/
600 /*Cycle N1*/
601 /*Cycle N1*/
602 /*Cycle W */ { IRegWritePorts.rid, 6, 1 }
603 }
604};
605
606const InstrClassRUsage IEU0ClassRUsage = {
607 SPARC_IEU0,
608 /*totCycles*/ 7,
609
610 /* maxIssueNum */ 1,
611 /* isSingleIssue */ false,
612 /* breaksGroup */ false,
613 /* numBubbles */ 0,
614
615 /*numSlots*/ 3,
616 /* feasibleSlots[] */ { 0, 1, 2 },
617
618 /*numEntries*/ 5,
619 /* V[] */ {
620 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
621 { IntIssueSlots.rid, 0, 1 },
622 /*Cycle E */ { IAluN.rid, 1, 1 },
623 { IAlu0.rid, 1, 1 },
624 /*Cycle C */
625 /*Cycle N1*/
626 /*Cycle N1*/
627 /*Cycle N1*/
628 /*Cycle W */ { IRegWritePorts.rid, 6, 1 }
629 }
630};
631
632const InstrClassRUsage IEU1ClassRUsage = {
633 SPARC_IEU1,
634 /*totCycles*/ 7,
635
636 /* maxIssueNum */ 1,
637 /* isSingleIssue */ false,
638 /* breaksGroup */ false,
639 /* numBubbles */ 0,
640
641 /*numSlots*/ 3,
642 /* feasibleSlots[] */ { 0, 1, 2 },
643
644 /*numEntries*/ 5,
645 /* V[] */ {
646 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
647 { IntIssueSlots.rid, 0, 1 },
648 /*Cycle E */ { IAluN.rid, 1, 1 },
649 { IAlu1.rid, 1, 1 },
650 /*Cycle C */
651 /*Cycle N1*/
652 /*Cycle N1*/
653 /*Cycle N1*/
654 /*Cycle W */ { IRegWritePorts.rid, 6, 1 }
655 }
656};
657
658const InstrClassRUsage FPMClassRUsage = {
659 SPARC_FPM,
660 /*totCycles*/ 7,
661
662 /* maxIssueNum */ 1,
663 /* isSingleIssue */ false,
664 /* breaksGroup */ false,
665 /* numBubbles */ 0,
666
667 /*numSlots*/ 4,
668 /* feasibleSlots[] */ { 0, 1, 2, 3 },
669
670 /*numEntries*/ 7,
671 /* V[] */ {
672 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
673 { FPMIssueSlots.rid, 0, 1 },
674 /*Cycle E */ { FPRegReadPorts.rid, 1, 1 },
675 /*Cycle C */ { FPMAluC1.rid, 2, 1 },
676 /*Cycle N1*/ { FPMAluC2.rid, 3, 1 },
677 /*Cycle N1*/ { FPMAluC3.rid, 4, 1 },
678 /*Cycle N1*/
679 /*Cycle W */ { FPRegWritePorts.rid, 6, 1 }
680 }
681};
682
683const InstrClassRUsage FPAClassRUsage = {
684 SPARC_FPA,
685 /*totCycles*/ 7,
686
687 /* maxIssueNum */ 1,
688 /* isSingleIssue */ false,
689 /* breaksGroup */ false,
690 /* numBubbles */ 0,
691
692 /*numSlots*/ 4,
693 /* feasibleSlots[] */ { 0, 1, 2, 3 },
694
695 /*numEntries*/ 7,
696 /* V[] */ {
697 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
698 { FPAIssueSlots.rid, 0, 1 },
699 /*Cycle E */ { FPRegReadPorts.rid, 1, 1 },
700 /*Cycle C */ { FPAAluC1.rid, 2, 1 },
701 /*Cycle N1*/ { FPAAluC2.rid, 3, 1 },
702 /*Cycle N1*/ { FPAAluC3.rid, 4, 1 },
703 /*Cycle N1*/
704 /*Cycle W */ { FPRegWritePorts.rid, 6, 1 }
705 }
706};
707
708const InstrClassRUsage LDClassRUsage = {
709 SPARC_LD,
710 /*totCycles*/ 7,
711
712 /* maxIssueNum */ 1,
713 /* isSingleIssue */ false,
714 /* breaksGroup */ false,
715 /* numBubbles */ 0,
716
717 /*numSlots*/ 3,
718 /* feasibleSlots[] */ { 0, 1, 2, },
719
720 /*numEntries*/ 6,
721 /* V[] */ {
722 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
723 { First3IssueSlots.rid, 0, 1 },
724 { LSIssueSlots.rid, 0, 1 },
725 /*Cycle E */ { LSAluC1.rid, 1, 1 },
726 /*Cycle C */ { LSAluC2.rid, 2, 1 },
727 { LdReturn.rid, 2, 1 },
728 /*Cycle N1*/
729 /*Cycle N1*/
730 /*Cycle N1*/
731 /*Cycle W */ { IRegWritePorts.rid, 6, 1 }
732 }
733};
734
735const InstrClassRUsage STClassRUsage = {
736 SPARC_ST,
737 /*totCycles*/ 7,
738
739 /* maxIssueNum */ 1,
740 /* isSingleIssue */ false,
741 /* breaksGroup */ false,
742 /* numBubbles */ 0,
743
744 /*numSlots*/ 3,
745 /* feasibleSlots[] */ { 0, 1, 2 },
746
747 /*numEntries*/ 4,
748 /* V[] */ {
749 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
750 { First3IssueSlots.rid, 0, 1 },
751 { LSIssueSlots.rid, 0, 1 },
752 /*Cycle E */ { LSAluC1.rid, 1, 1 },
753 /*Cycle C */ { LSAluC2.rid, 2, 1 }
754 /*Cycle N1*/
755 /*Cycle N1*/
756 /*Cycle N1*/
757 /*Cycle W */
758 }
759};
760
761const InstrClassRUsage CTIClassRUsage = {
762 SPARC_CTI,
763 /*totCycles*/ 7,
764
765 /* maxIssueNum */ 1,
766 /* isSingleIssue */ false,
767 /* breaksGroup */ false,
768 /* numBubbles */ 0,
769
770 /*numSlots*/ 4,
771 /* feasibleSlots[] */ { 0, 1, 2, 3 },
772
773 /*numEntries*/ 4,
774 /* V[] */ {
775 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
776 { CTIIssueSlots.rid, 0, 1 },
777 /*Cycle E */ { IAlu0.rid, 1, 1 },
778 /*Cycles E-C */ { CTIDelayCycle.rid, 1, 2 }
779 /*Cycle C */
780 /*Cycle N1*/
781 /*Cycle N1*/
782 /*Cycle N1*/
783 /*Cycle W */
784 }
785};
786
787const InstrClassRUsage SingleClassRUsage = {
788 SPARC_SINGLE,
789 /*totCycles*/ 7,
790
791 /* maxIssueNum */ 1,
792 /* isSingleIssue */ true,
793 /* breaksGroup */ false,
794 /* numBubbles */ 0,
795
796 /*numSlots*/ 1,
797 /* feasibleSlots[] */ { 0 },
798
799 /*numEntries*/ 5,
800 /* V[] */ {
801 /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
802 { AllIssueSlots.rid, 0, 1 },
803 { AllIssueSlots.rid, 0, 1 },
804 { AllIssueSlots.rid, 0, 1 },
805 /*Cycle E */ { IAlu0.rid, 1, 1 }
806 /*Cycle C */
807 /*Cycle N1*/
808 /*Cycle N1*/
809 /*Cycle N1*/
810 /*Cycle W */
811 }
812};
813
814
815const InstrClassRUsage SparcRUsageDesc[] = {
816 NoneClassRUsage,
817 IEUNClassRUsage,
818 IEU0ClassRUsage,
819 IEU1ClassRUsage,
820 FPMClassRUsage,
821 FPAClassRUsage,
822 CTIClassRUsage,
823 LDClassRUsage,
824 STClassRUsage,
825 SingleClassRUsage
826};
827
828
829//---------------------------------------------------------------------------
830// const InstrIssueDelta SparcInstrIssueDeltas[]
831//
832// Purpose:
833// Changes to issue restrictions information in InstrClassRUsage for
834// instructions that differ from other instructions in their class.
835//---------------------------------------------------------------------------
836
837const InstrIssueDelta SparcInstrIssueDeltas[] = {
838
839 // opCode, isSingleIssue, breaksGroup, numBubbles
840
841 // Special cases for single-issue only
842 // Other single issue cases are below.
843//{ LDDA, true, true, 0 },
844//{ STDA, true, true, 0 },
845//{ LDDF, true, true, 0 },
846//{ LDDFA, true, true, 0 },
847 { ADDC, true, true, 0 },
848 { ADDCcc, true, true, 0 },
849 { SUBC, true, true, 0 },
850 { SUBCcc, true, true, 0 },
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000851//{ LDSTUB, true, true, 0 },
852//{ SWAP, true, true, 0 },
853//{ SWAPA, true, true, 0 },
854//{ CAS, true, true, 0 },
855//{ CASA, true, true, 0 },
856//{ CASX, true, true, 0 },
857//{ CASXA, true, true, 0 },
858//{ LDFSR, true, true, 0 },
859//{ LDFSRA, true, true, 0 },
860//{ LDXFSR, true, true, 0 },
861//{ LDXFSRA, true, true, 0 },
862//{ STFSR, true, true, 0 },
863//{ STFSRA, true, true, 0 },
864//{ STXFSR, true, true, 0 },
865//{ STXFSRA, true, true, 0 },
866//{ SAVED, true, true, 0 },
867//{ RESTORED, true, true, 0 },
868//{ FLUSH, true, true, 9 },
869//{ FLUSHW, true, true, 9 },
870//{ ALIGNADDR, true, true, 0 },
871 { RETURN, true, true, 0 },
872//{ DONE, true, true, 0 },
873//{ RETRY, true, true, 0 },
874//{ WR, true, true, 0 },
875//{ WRPR, true, true, 4 },
876//{ RD, true, true, 0 },
877//{ RDPR, true, true, 0 },
878//{ TCC, true, true, 0 },
879//{ SHUTDOWN, true, true, 0 },
880
881 // Special cases for breaking group *before*
882 // CURRENTLY NOT SUPPORTED!
883 { CALL, false, false, 0 },
Vikram S. Advec1521632001-10-22 13:31:53 +0000884 { JMPLCALL, false, false, 0 },
885 { JMPLRET, false, false, 0 },
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000886
887 // Special cases for breaking the group *after*
888 { MULX, true, true, (4+34)/2 },
889 { FDIVS, false, true, 0 },
890 { FDIVD, false, true, 0 },
891 { FDIVQ, false, true, 0 },
892 { FSQRTS, false, true, 0 },
893 { FSQRTD, false, true, 0 },
894 { FSQRTQ, false, true, 0 },
895//{ FCMP{LE,GT,NE,EQ}, false, true, 0 },
896
897 // Instructions that introduce bubbles
898//{ MULScc, true, true, 2 },
899//{ SMULcc, true, true, (4+18)/2 },
900//{ UMULcc, true, true, (4+19)/2 },
901 { SDIVX, true, true, 68 },
902 { UDIVX, true, true, 68 },
903//{ SDIVcc, true, true, 36 },
904//{ UDIVcc, true, true, 37 },
905//{ WR, false, false, 4 },
906//{ WRPR, false, false, 4 },
907};
908
909
910//---------------------------------------------------------------------------
911// const InstrRUsageDelta SparcInstrUsageDeltas[]
912//
913// Purpose:
914// Changes to resource usage information in InstrClassRUsage for
915// instructions that differ from other instructions in their class.
916//---------------------------------------------------------------------------
917
918const InstrRUsageDelta SparcInstrUsageDeltas[] = {
919
920 // MachineOpCode, Resource, Start cycle, Num cycles
921
922 //
923 // JMPL counts as a load/store instruction for issue!
924 //
Vikram S. Advec1521632001-10-22 13:31:53 +0000925 { JMPLCALL, LSIssueSlots.rid, 0, 1 },
926 { JMPLRET, LSIssueSlots.rid, 0, 1 },
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000927
928 //
929 // Many instructions cannot issue for the next 2 cycles after an FCMP
930 // We model that with a fake resource FCMPDelayCycle.
931 //
932 { FCMPS, FCMPDelayCycle.rid, 1, 3 },
933 { FCMPD, FCMPDelayCycle.rid, 1, 3 },
934 { FCMPQ, FCMPDelayCycle.rid, 1, 3 },
935
936 { MULX, FCMPDelayCycle.rid, 1, 1 },
937 { SDIVX, FCMPDelayCycle.rid, 1, 1 },
938 { UDIVX, FCMPDelayCycle.rid, 1, 1 },
939//{ SMULcc, FCMPDelayCycle.rid, 1, 1 },
940//{ UMULcc, FCMPDelayCycle.rid, 1, 1 },
941//{ SDIVcc, FCMPDelayCycle.rid, 1, 1 },
942//{ UDIVcc, FCMPDelayCycle.rid, 1, 1 },
943 { STD, FCMPDelayCycle.rid, 1, 1 },
944 { FMOVRSZ, FCMPDelayCycle.rid, 1, 1 },
945 { FMOVRSLEZ,FCMPDelayCycle.rid, 1, 1 },
946 { FMOVRSLZ, FCMPDelayCycle.rid, 1, 1 },
947 { FMOVRSNZ, FCMPDelayCycle.rid, 1, 1 },
948 { FMOVRSGZ, FCMPDelayCycle.rid, 1, 1 },
949 { FMOVRSGEZ,FCMPDelayCycle.rid, 1, 1 },
950
951 //
952 // Some instructions are stalled in the GROUP stage if a CTI is in
953 // the E or C stage
954 //
955 { LDD, CTIDelayCycle.rid, 1, 1 },
956//{ LDDA, CTIDelayCycle.rid, 1, 1 },
957//{ LDDSTUB, CTIDelayCycle.rid, 1, 1 },
958//{ LDDSTUBA, CTIDelayCycle.rid, 1, 1 },
959//{ SWAP, CTIDelayCycle.rid, 1, 1 },
960//{ SWAPA, CTIDelayCycle.rid, 1, 1 },
961//{ CAS, CTIDelayCycle.rid, 1, 1 },
962//{ CASA, CTIDelayCycle.rid, 1, 1 },
963//{ CASX, CTIDelayCycle.rid, 1, 1 },
964//{ CASXA, CTIDelayCycle.rid, 1, 1 },
965
966 //
967 // Signed int loads of less than dword size return data in cycle N1 (not C)
968 // and put all loads in consecutive cycles into delayed load return mode.
969 //
970 { LDSB, LdReturn.rid, 2, -1 },
971 { LDSB, LdReturn.rid, 3, 1 },
972
973 { LDSH, LdReturn.rid, 2, -1 },
974 { LDSH, LdReturn.rid, 3, 1 },
975
976 { LDSW, LdReturn.rid, 2, -1 },
977 { LDSW, LdReturn.rid, 3, 1 },
978
979
980#undef EXPLICIT_BUBBLES_NEEDED
981#ifdef EXPLICIT_BUBBLES_NEEDED
982 //
983 // MULScc inserts one bubble.
984 // This means it breaks the current group (captured in UltraSparcSchedInfo)
985 // *and occupies all issue slots for the next cycle
986 //
987//{ MULScc, AllIssueSlots.rid, 2, 2-1 },
988//{ MULScc, AllIssueSlots.rid, 2, 2-1 },
989//{ MULScc, AllIssueSlots.rid, 2, 2-1 },
990//{ MULScc, AllIssueSlots.rid, 2, 2-1 },
991
992 //
993 // SMULcc inserts between 4 and 18 bubbles, depending on #leading 0s in rs1.
994 // We just model this with a simple average.
995 //
996//{ SMULcc, AllIssueSlots.rid, 2, ((4+18)/2)-1 },
997//{ SMULcc, AllIssueSlots.rid, 2, ((4+18)/2)-1 },
998//{ SMULcc, AllIssueSlots.rid, 2, ((4+18)/2)-1 },
999//{ SMULcc, AllIssueSlots.rid, 2, ((4+18)/2)-1 },
1000
1001 // SMULcc inserts between 4 and 19 bubbles, depending on #leading 0s in rs1.
1002//{ UMULcc, AllIssueSlots.rid, 2, ((4+19)/2)-1 },
1003//{ UMULcc, AllIssueSlots.rid, 2, ((4+19)/2)-1 },
1004//{ UMULcc, AllIssueSlots.rid, 2, ((4+19)/2)-1 },
1005//{ UMULcc, AllIssueSlots.rid, 2, ((4+19)/2)-1 },
1006
1007 //
1008 // MULX inserts between 4 and 34 bubbles, depending on #leading 0s in rs1.
1009 //
1010 { MULX, AllIssueSlots.rid, 2, ((4+34)/2)-1 },
1011 { MULX, AllIssueSlots.rid, 2, ((4+34)/2)-1 },
1012 { MULX, AllIssueSlots.rid, 2, ((4+34)/2)-1 },
1013 { MULX, AllIssueSlots.rid, 2, ((4+34)/2)-1 },
1014
1015 //
1016 // SDIVcc inserts 36 bubbles.
1017 //
1018//{ SDIVcc, AllIssueSlots.rid, 2, 36-1 },
1019//{ SDIVcc, AllIssueSlots.rid, 2, 36-1 },
1020//{ SDIVcc, AllIssueSlots.rid, 2, 36-1 },
1021//{ SDIVcc, AllIssueSlots.rid, 2, 36-1 },
1022
1023 // UDIVcc inserts 37 bubbles.
1024//{ UDIVcc, AllIssueSlots.rid, 2, 37-1 },
1025//{ UDIVcc, AllIssueSlots.rid, 2, 37-1 },
1026//{ UDIVcc, AllIssueSlots.rid, 2, 37-1 },
1027//{ UDIVcc, AllIssueSlots.rid, 2, 37-1 },
1028
1029 //
1030 // SDIVX inserts 68 bubbles.
1031 //
1032 { SDIVX, AllIssueSlots.rid, 2, 68-1 },
1033 { SDIVX, AllIssueSlots.rid, 2, 68-1 },
1034 { SDIVX, AllIssueSlots.rid, 2, 68-1 },
1035 { SDIVX, AllIssueSlots.rid, 2, 68-1 },
1036
1037 //
1038 // UDIVX inserts 68 bubbles.
1039 //
1040 { UDIVX, AllIssueSlots.rid, 2, 68-1 },
1041 { UDIVX, AllIssueSlots.rid, 2, 68-1 },
1042 { UDIVX, AllIssueSlots.rid, 2, 68-1 },
1043 { UDIVX, AllIssueSlots.rid, 2, 68-1 },
1044
1045 //
1046 // WR inserts 4 bubbles.
1047 //
1048//{ WR, AllIssueSlots.rid, 2, 68-1 },
1049//{ WR, AllIssueSlots.rid, 2, 68-1 },
1050//{ WR, AllIssueSlots.rid, 2, 68-1 },
1051//{ WR, AllIssueSlots.rid, 2, 68-1 },
1052
1053 //
1054 // WRPR inserts 4 bubbles.
1055 //
1056//{ WRPR, AllIssueSlots.rid, 2, 68-1 },
1057//{ WRPR, AllIssueSlots.rid, 2, 68-1 },
1058//{ WRPR, AllIssueSlots.rid, 2, 68-1 },
1059//{ WRPR, AllIssueSlots.rid, 2, 68-1 },
1060
1061 //
1062 // DONE inserts 9 bubbles.
1063 //
1064//{ DONE, AllIssueSlots.rid, 2, 9-1 },
1065//{ DONE, AllIssueSlots.rid, 2, 9-1 },
1066//{ DONE, AllIssueSlots.rid, 2, 9-1 },
1067//{ DONE, AllIssueSlots.rid, 2, 9-1 },
1068
1069 //
1070 // RETRY inserts 9 bubbles.
1071 //
1072//{ RETRY, AllIssueSlots.rid, 2, 9-1 },
1073//{ RETRY, AllIssueSlots.rid, 2, 9-1 },
1074//{ RETRY, AllIssueSlots.rid, 2, 9-1 },
1075//{ RETRY, AllIssueSlots.rid, 2, 9-1 },
1076
Chris Lattnere369fcb2001-10-13 06:54:54 +00001077#endif /*EXPLICIT_BUBBLES_NEEDED */
Chris Lattnerc6495ee2001-09-14 03:56:45 +00001078};
1079
1080
1081
1082// Additional delays to be captured in code:
1083// 1. RDPR from several state registers (page 349)
1084// 2. RD from *any* register (page 349)
1085// 3. Writes to TICK, PSTATE, TL registers and FLUSH{W} instr (page 349)
1086// 4. Integer store can be in same group as instr producing value to store.
1087// 5. BICC and BPICC can be in the same group as instr producing CC (pg 350)
1088// 6. FMOVr cannot be in the same or next group as an IEU instr (pg 351).
1089// 7. The second instr. of a CTI group inserts 9 bubbles (pg 351)
1090// 8. WR{PR}, SVAE, SAVED, RESTORE, RESTORED, RETURN, RETRY, and DONE that
1091// follow an annulling branch cannot be issued in the same group or in
1092// the 3 groups following the branch.
1093// 9. A predicted annulled load does not stall dependent instructions.
1094// Other annulled delay slot instructions *do* stall dependents, so
1095// nothing special needs to be done for them during scheduling.
1096//10. Do not put a load use that may be annulled in the same group as the
1097// branch. The group will stall until the load returns.
1098//11. Single-prec. FP loads lock 2 registers, for dependency checking.
1099//
1100//
1101// Additional delays we cannot or will not capture:
1102// 1. If DCTI is last word of cache line, it is delayed until next line can be
1103// fetched. Also, other DCTI alignment-related delays (pg 352)
1104// 2. Load-after-store is delayed by 7 extra cycles if load hits in D-Cache.
1105// Also, several other store-load and load-store conflicts (pg 358)
1106// 3. MEMBAR, LD{X}FSR, LDD{A} and a bunch of other load stalls (pg 358)
1107// 4. There can be at most 8 outstanding buffered store instructions
1108// (including some others like MEMBAR, LDSTUB, CAS{AX}, and FLUSH)
1109
1110
1111
1112//---------------------------------------------------------------------------
1113// class UltraSparcSchedInfo
1114//
1115// Purpose:
1116// Interface to instruction scheduling information for UltraSPARC.
1117// The parameter values above are based on UltraSPARC IIi.
1118//---------------------------------------------------------------------------
1119
1120
1121class UltraSparcSchedInfo: public MachineSchedInfo {
1122public:
1123 /*ctor*/ UltraSparcSchedInfo (const MachineInstrInfo* mii);
1124 /*dtor*/ virtual ~UltraSparcSchedInfo () {}
1125protected:
1126 virtual void initializeResources ();
1127};
1128
Chris Lattnerf6e0e282001-09-14 04:32:55 +00001129
1130//---------------------------------------------------------------------------
Vikram S. Advec1521632001-10-22 13:31:53 +00001131// class UltraSparcFrameInfo
1132//
1133// Purpose:
1134// Interface to stack frame layout info for the UltraSPARC.
1135// Note that there is no machine-independent interface to this information
1136//---------------------------------------------------------------------------
1137
1138class UltraSparcFrameInfo: public NonCopyable {
1139public:
1140 static const int MinStackFrameSize = 176;
1141 static const int FirstOutgoingArgOffsetFromSP = 128;
1142 static const int FirstOptionalOutgoingArgOffsetFromSP = 176;
1143 static const int StaticStackAreaOffsetFromFP = -1;
Ruchira Sasanka20c82b12001-10-28 18:15:12 +00001144
1145 static const int FirstIncomingArgOffsetFromFP = 126;
1146
Vikram S. Advec1521632001-10-22 13:31:53 +00001147 static int getFirstAutomaticVarOffsetFromFP (const Method* method);
1148 static int getRegSpillAreaOffsetFromFP (const Method* method);
1149 static int getFrameSizeBelowDynamicArea (const Method* method);
1150};
1151
1152
1153
1154//---------------------------------------------------------------------------
Chris Lattnerf6e0e282001-09-14 04:32:55 +00001155// class UltraSparcMachine
1156//
1157// Purpose:
1158// Primary interface to machine description for the UltraSPARC.
1159// Primarily just initializes machine-dependent parameters in
1160// class TargetMachine, and creates machine-dependent subclasses
Vikram S. Adve339084b2001-09-18 13:04:24 +00001161// for classes such as InstrInfo, SchedInfo and RegInfo.
Chris Lattnerf6e0e282001-09-14 04:32:55 +00001162//---------------------------------------------------------------------------
1163
1164class UltraSparc : public TargetMachine {
Vikram S. Adve339084b2001-09-18 13:04:24 +00001165private:
1166 UltraSparcInstrInfo instrInfo;
1167 UltraSparcSchedInfo schedInfo;
1168 UltraSparcRegInfo regInfo;
Vikram S. Advec1521632001-10-22 13:31:53 +00001169 UltraSparcFrameInfo frameInfo;
Chris Lattnerf6e0e282001-09-14 04:32:55 +00001170public:
1171 UltraSparc();
1172 virtual ~UltraSparc() {}
Vikram S. Adve339084b2001-09-18 13:04:24 +00001173
Chris Lattner32f600a2001-09-19 13:47:12 +00001174 virtual const MachineInstrInfo &getInstrInfo() const { return instrInfo; }
1175 virtual const MachineSchedInfo &getSchedInfo() const { return schedInfo; }
1176 virtual const MachineRegInfo &getRegInfo() const { return regInfo; }
Vikram S. Advec1521632001-10-22 13:31:53 +00001177 const UltraSparcFrameInfo &getFrameInfo() const { return frameInfo; }
1178
Vikram S. Adve339084b2001-09-18 13:04:24 +00001179
Chris Lattnerf6e0e282001-09-14 04:32:55 +00001180 // compileMethod - For the sparc, we do instruction selection, followed by
1181 // delay slot scheduling, then register allocation.
1182 //
1183 virtual bool compileMethod(Method *M);
Chris Lattner32f600a2001-09-19 13:47:12 +00001184
1185 //
1186 // emitAssembly - Output assembly language code (a .s file) for the specified
1187 // module. The specified module must have been compiled before this may be
1188 // used.
1189 //
Chris Lattnerec0a95f2001-10-15 15:54:43 +00001190 virtual void emitAssembly(const Module *M, ostream &OutStr) const;
Chris Lattnerf6e0e282001-09-14 04:32:55 +00001191};
1192
1193
Chris Lattnerc6495ee2001-09-14 03:56:45 +00001194#endif