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