Extensive additions for supporting instruction scheduling.
[oota-llvm.git] / include / llvm / CodeGen / Sparc.h
1 // $Id$ -*-c++-*-
2 //***************************************************************************
3 // File:
4 //      Sparc.cpp
5 // 
6 // Purpose:
7 //      
8 // History:
9 //      7/15/01  -  Vikram Adve  -  Created
10 //**************************************************************************/
11
12 #ifndef LLVM_CODEGEN_SPARC_H
13 #define LLVM_CODEGEN_SPARC_H
14
15 #include <sys/types.h>
16 #include "llvm/CodeGen/TargetMachine.h"
17
18 // OpCodeMask definitions for the Sparc V9
19 // 
20 const OpCodeMask        Immed           = 0x00002000; // immed or reg operand?
21 const OpCodeMask        Annul           = 0x20000000; // annul delay instr?
22 const OpCodeMask        PredictTaken    = 0x00080000; // predict branch taken?
23
24
25 enum SparcInstrSchedClass {
26   SPARC_NONE,           /* Instructions with no scheduling restrictions */
27   SPARC_IEUN,           /* Integer class that can use IEU0 or IEU1 */
28   SPARC_IEU0,           /* Integer class IEU0 */
29   SPARC_IEU1,           /* Integer class IEU1 */
30   SPARC_FPM,            /* FP Multiply or Divide instructions */
31   SPARC_FPA,            /* All other FP instructions */ 
32   SPARC_CTI,            /* Control-transfer instructions */
33   SPARC_LD,             /* Load instructions */
34   SPARC_ST,             /* Store instructions */
35   SPARC_SINGLE,         /* Instructions that must issue by themselves */
36   
37   SPARC_INV,            /* This should stay at the end for the next value */
38   SPARC_NUM_SCHED_CLASSES = SPARC_INV
39 };
40
41 // inline operator int (const SparcInstrSchedClass& si) {
42 //   return (int) si;
43 // }
44 // 
45 // inline operator SparcInstrSchedClass (int i) {
46 //   return (SparcInstrSchedClass) si;
47 // }
48 // 
49 // inline operator const SparcInstrSchedClass (int i) {
50 //   return (const SparcInstrSchedClass) si;
51 // }
52
53 //---------------------------------------------------------------------------
54 // enum SparcMachineOpCode. 
55 // const MachineInstrDescriptor SparcMachineInstrDesc[]
56 // 
57 // Purpose:
58 //   Description of UltraSparc machine instructions.
59 // 
60 //---------------------------------------------------------------------------
61
62
63 enum SparcMachineOpCode {
64
65   NOP,
66   
67   // Synthetic SPARC assembly opcodes for setting a register to a constant
68   SETSW,
69   SETUW,
70   
71   // Set high-order bits of register and clear low-order bits
72   SETHI,
73   
74   // Add or add with carry.
75   // Immed bit specifies if second operand is immediate(1) or register(0)
76   ADD,
77   ADDcc,
78   ADDC,
79   ADDCcc,
80
81   // Subtract or subtract with carry.
82   // Immed bit specifies if second operand is immediate(1) or register(0)
83   SUB,
84   SUBcc,
85   SUBC,
86   SUBCcc,
87   
88   // Integer multiply, signed divide, unsigned divide.
89   // Note that the deprecated 32-bit multiply and multiply-step are not used.
90   MULX,
91   SDIVX,
92   UDIVX,
93   
94   // Floating point add, subtract, compare
95   FADDS,
96   FADDD,
97   FADDQ,
98   FSUBS,
99   FSUBD,
100   FSUBQ,
101   FCMPS,
102   FCMPD,
103   FCMPQ,
104   // NOTE: FCMPE{S,D,Q}: FP Compare With Exception are currently unused!
105   
106   // Floating point multiply or divide.
107   FMULS,
108   FMULD,
109   FMULQ,
110   FSMULD,
111   FDMULQ,
112   FDIVS,
113   FDIVD,
114   FDIVQ,
115   FSQRTS,
116   FSQRTD,
117   FSQRTQ,
118   
119   // Logical operations
120   AND,
121   ANDcc,
122   ANDN,
123   ANDNcc,
124   OR,
125   ORcc,
126   ORN,
127   ORNcc,
128   XOR,
129   XORcc,
130   XNOR,
131   XNORcc,
132   
133   // Shift operations
134   SLL,
135   SRL,
136   SRA,
137   SLLX,
138   SRLX,
139   SRAX,
140   
141   // Floating point move, negate, and abs instructions
142   FMOVS,
143   FMOVD,
144 //FMOVQ,
145   FNEGS,
146   FNEGD,
147 //FNEGQ,
148   FABSS,
149   FABSD,
150 //FABSQ,
151   
152   // Convert from floating point to floating point formats
153   FSTOD,
154   FSTOQ,
155   FDTOS,
156   FDTOQ,
157   FQTOS,
158   FQTOD,
159   
160   // Convert from floating point to integer formats
161   FSTOX,
162   FDTOX,
163   FQTOX,
164   FSTOI,
165   FDTOI,
166   FQTOI,
167   
168   // Convert from integer to floating point formats
169   FXTOS,
170   FXTOD,
171   FXTOQ,
172   FITOS,
173   FITOD,
174   FITOQ,
175   
176   // Branch on integer comparison with zero.
177   // Annul bit specifies if intruction in delay slot is annulled(1) or not(0).
178   // PredictTaken bit hints if branch should be predicted taken(1) or not(0).
179   BRZ,
180   BRLEZ,
181   BRLZ,
182   BRNZ,
183   BRGZ,
184   BRGEZ,
185
186   // Branch on integer condition code.
187   // Annul bit specifies if intruction in delay slot is annulled(1) or not(0).
188   // PredictTaken bit hints if branch should be predicted taken(1) or not(0).
189   BA,
190   BN,
191   BNE,
192   BE,
193   BG,
194   BLE,
195   BGE,
196   BL,
197   BGU,
198   BLEU,
199   BCC,
200   BCS,
201   BPOS,
202   BNEG,
203   BVC,
204   BVS,
205
206   // Branch on floating point condition code.
207   // Annul bit specifies if intruction in delay slot is annulled(1) or not(0).
208   // PredictTaken bit hints if branch should be predicted taken(1) or not(0).
209   FBA,
210   FBN,
211   FBU,
212   FBG,
213   FBUG,
214   FBL,
215   FBUL,
216   FBLG,
217   FBNE,
218   FBE,
219   FBUE,
220   FBGE,
221   FBUGE,
222   FBLE,
223   FBULE,
224   FBO,
225
226   // Conditional move on integer comparison with zero.
227   MOVRZ,
228   MOVRLEZ,
229   MOVRLZ,
230   MOVRNZ,
231   MOVRGZ,
232   MOVRGEZ,
233
234   // Conditional move on integer condition code.
235   MOVA,
236   MOVN,
237   MOVNE,
238   MOVE,
239   MOVG,
240   MOVLE,
241   MOVGE,
242   MOVL,
243   MOVGU,
244   MOVLEU,
245   MOVCC,
246   MOVCS,
247   MOVPOS,
248   MOVNEG,
249   MOVVC,
250   MOVVS,
251
252   // Conditional move on floating point condition code.
253   // Note that the enum name is not the same as the assembly mnemonic below
254   // because that would duplicate some entries with those above.
255   // Therefore, we use MOVF here instead of MOV.
256   MOVFA,
257   MOVFN,
258   MOVFU,
259   MOVFG,
260   MOVFUG,
261   MOVFL,
262   MOVFUL,
263   MOVFLG,
264   MOVFNE,
265   MOVFE,
266   MOVFUE,
267   MOVFGE,
268   MOVFUGE,
269   MOVFLE,
270   MOVFULE,
271   MOVFO,
272
273   // Conditional move of floating point register on each of the above:
274   // i.   on integer comparison with zero.
275   // ii.  on integer condition code
276   // iii. on floating point condition code
277   // Note that the same set is repeated for S,D,Q register classes.
278   FMOVRSZ,
279   FMOVRSLEZ,
280   FMOVRSLZ,
281   FMOVRSNZ,
282   FMOVRSGZ,
283   FMOVRSGEZ,
284
285   FMOVSA,
286   FMOVSN,
287   FMOVSNE,
288   FMOVSE,
289   FMOVSG,
290   FMOVSLE,
291   FMOVSGE,
292   FMOVSL,
293   FMOVSGU,
294   FMOVSLEU,
295   FMOVSCC,
296   FMOVSCS,
297   FMOVSPOS,
298   FMOVSNEG,
299   FMOVSVC,
300   FMOVSVS,
301
302   FMOVSFA,
303   FMOVSFN,
304   FMOVSFU,
305   FMOVSFG,
306   FMOVSFUG,
307   FMOVSFL,
308   FMOVSFUL,
309   FMOVSFLG,
310   FMOVSFNE,
311   FMOVSFE,
312   FMOVSFUE,
313   FMOVSFGE,
314   FMOVSFUGE,
315   FMOVSFLE,
316   FMOVSFULE,
317   FMOVSFO,
318   
319   FMOVRDZ,
320   FMOVRDLEZ,
321   FMOVRDLZ,
322   FMOVRDNZ,
323   FMOVRDGZ,
324   FMOVRDGEZ,
325
326   FMOVDA,
327   FMOVDN,
328   FMOVDNE,
329   FMOVDE,
330   FMOVDG,
331   FMOVDLE,
332   FMOVDGE,
333   FMOVDL,
334   FMOVDGU,
335   FMOVDLEU,
336   FMOVDCC,
337   FMOVDCS,
338   FMOVDPOS,
339   FMOVDNEG,
340   FMOVDVC,
341   FMOVDVS,
342
343   FMOVDFA,
344   FMOVDFN,
345   FMOVDFU,
346   FMOVDFG,
347   FMOVDFUG,
348   FMOVDFL,
349   FMOVDFUL,
350   FMOVDFLG,
351   FMOVDFNE,
352   FMOVDFE,
353   FMOVDFUE,
354   FMOVDFGE,
355   FMOVDFUGE,
356   FMOVDFLE,
357   FMOVDFULE,
358   FMOVDFO,
359   
360   FMOVRQZ,
361   FMOVRQLEZ,
362   FMOVRQLZ,
363   FMOVRQNZ,
364   FMOVRQGZ,
365   FMOVRQGEZ,
366
367   FMOVQA,
368   FMOVQN,
369   FMOVQNE,
370   FMOVQE,
371   FMOVQG,
372   FMOVQLE,
373   FMOVQGE,
374   FMOVQL,
375   FMOVQGU,
376   FMOVQLEU,
377   FMOVQCC,
378   FMOVQCS,
379   FMOVQPOS,
380   FMOVQNEG,
381   FMOVQVC,
382   FMOVQVS,
383
384   FMOVQFA,
385   FMOVQFN,
386   FMOVQFU,
387   FMOVQFG,
388   FMOVQFUG,
389   FMOVQFL,
390   FMOVQFUL,
391   FMOVQFLG,
392   FMOVQFNE,
393   FMOVQFE,
394   FMOVQFUE,
395   FMOVQFGE,
396   FMOVQFUGE,
397   FMOVQFLE,
398   FMOVQFULE,
399   FMOVQFO,
400   
401   // Load integer instructions
402   LDSB,
403   LDSH,
404   LDSW,
405   LDUB,
406   LDUH,
407   LDUW,
408   LDX,
409   
410   // Load floating-point instructions
411   LD,
412   LDD,                  // use of this for integers is deprecated for Sparc V9
413   LDQ,
414   
415   // Store integer instructions
416   STB,
417   STH,
418   STW,
419   STX,
420   
421   // Store floating-point instructions
422   ST,
423   STD,
424   
425   // Call, Return, and "Jump and link"
426   // Immed bit specifies if second operand is immediate(1) or register(0)
427   CALL,
428   JMPL,
429   RETURN,                               // last valid opcode
430
431   // Synthetic phi operation for near-SSA form of machine code
432   PHI,
433   
434   // End-of-array marker
435   INVALID_OPCODE,
436   NUM_REAL_OPCODES = RETURN+1,          // number of valid opcodes
437   NUM_TOTAL_OPCODES = INVALID_OPCODE
438 };
439
440 const MachineInstrDescriptor SparcMachineInstrDesc[] = {
441   
442   // Fields of each structure:
443   // opCodeString,
444   //           numOperands,
445   //                resultPosition (0-based; -1 if no result),
446   //                     maxImmedConst,
447   //                         immedIsSignExtended,
448   //                                numDelaySlots (in cycles)
449   //                                    latency (in cycles)
450   //                                        instr sched class (defined above)
451   //                                            instr class flags (defined in TargretMachine.h)
452   
453   { "NOP",      0,  -1,  0,  false, 0,  1,  SPARC_NONE,  M_NOP_FLAG },
454   
455   // Synthetic SPARC assembly opcodes for setting a register to a constant.
456   // Max immediate constant should be ignored for both these instructions.
457   { "SETSW",    2,   1,  0,  true,  0,  1,  SPARC_IEUN,  M_INT_FLAG | M_ARITH_FLAG },
458   { "SETUW",    2,   1,  0,  false, 0,  1,  SPARC_IEUN,  M_INT_FLAG | M_LOGICAL_FLAG | M_ARITH_FLAG },
459
460   // Set high-order bits of register and clear low-order bits
461   { "SETHI",    2,  1,  (1 << 22) - 1, false, 0,  1,  SPARC_IEUN,  M_INT_FLAG | M_LOGICAL_FLAG | M_ARITH_FLAG },
462   
463   // Add or add with carry.
464   { "ADD",      3,  2,  (1 << 12) - 1, true, 0, 1, SPARC_IEUN,  M_INT_FLAG | M_ARITH_FLAG },
465   { "ADDcc",    4,  2,  (1 << 12) - 1, true, 0, 1, SPARC_IEU1,  M_INT_FLAG | M_ARITH_FLAG },
466   { "ADDC",     3,  2,  (1 << 12) - 1, true, 0, 1, SPARC_IEUN,  M_INT_FLAG | M_ARITH_FLAG },
467   { "ADDCcc",   4,  2,  (1 << 12) - 1, true, 0, 1, SPARC_IEU1,  M_INT_FLAG | M_ARITH_FLAG },
468
469   // Sub tract or subtract with carry.
470   { "SUB",      3,  2,  (1 << 12) - 1, true, 0, 1, SPARC_IEUN,  M_INT_FLAG | M_ARITH_FLAG },
471   { "SUBcc",    4,  2,  (1 << 12) - 1, true, 0, 1, SPARC_IEU1,  M_INT_FLAG | M_ARITH_FLAG },
472   { "SUBC",     3,  2,  (1 << 12) - 1, true, 0, 1, SPARC_IEUN,  M_INT_FLAG | M_ARITH_FLAG },
473   { "SUBCcc",   4,  2,  (1 << 12) - 1, true, 0, 1, SPARC_IEU1,  M_INT_FLAG | M_ARITH_FLAG },
474
475   // Integer multiply, signed divide, unsigned divide.
476   // Note that the deprecated 32-bit multiply and multiply-step are not used.
477   { "MULX",     3,  2,  (1 << 12) - 1, true, 0, 3, SPARC_IEUN,  M_INT_FLAG | M_ARITH_FLAG },
478   { "SDIVX",    3,  2,  (1 << 12) - 1, true, 0, 6, SPARC_IEUN,  M_INT_FLAG | M_ARITH_FLAG },
479   { "UDIVX",    3,  2,  (1 << 12) - 1, true, 0, 6, SPARC_IEUN,  M_INT_FLAG | M_ARITH_FLAG },
480   
481   // Floating point add, subtract, compare.
482   // Note that destination of FCMP* instructions is operand 0, not operand 2.
483   { "FADDS",    3,  2,  0,  false, 0, 3,  SPARC_FPA,  M_FLOAT_FLAG | M_ARITH_FLAG },
484   { "FADDD",    3,  2,  0,  false, 0, 3,  SPARC_FPA,  M_FLOAT_FLAG | M_ARITH_FLAG },
485   { "FADDQ",    3,  2,  0,  false, 0, 3,  SPARC_FPA,  M_FLOAT_FLAG | M_ARITH_FLAG },
486   { "FSUBS",    3,  2,  0,  false, 0, 3,  SPARC_FPA,  M_FLOAT_FLAG | M_ARITH_FLAG },
487   { "FSUBD",    3,  2,  0,  false, 0, 3,  SPARC_FPA,  M_FLOAT_FLAG | M_ARITH_FLAG },
488   { "FSUBQ",    3,  2,  0,  false, 0, 3,  SPARC_FPA,  M_FLOAT_FLAG | M_ARITH_FLAG },
489   { "FCMPS",    3,  0,  0,  false, 0, 3,  SPARC_FPA,  M_FLOAT_FLAG | M_ARITH_FLAG },
490   { "FCMPD",    3,  0,  0,  false, 0, 3,  SPARC_FPA,  M_FLOAT_FLAG | M_ARITH_FLAG },
491   { "FCMPQ",    3,  0,  0,  false, 0, 3,  SPARC_FPA,  M_FLOAT_FLAG | M_ARITH_FLAG },
492   // NOTE: FCMPE{S,D,Q}: FP Compare With Exception are currently unused!
493   
494   // Floating point multiply or divide.
495   { "FMULS",    3,  2,  0,  false, 0, 3,  SPARC_FPM,  M_FLOAT_FLAG | M_ARITH_FLAG },
496   { "FMULD",    3,  2,  0,  false, 0, 3,  SPARC_FPM,  M_FLOAT_FLAG | M_ARITH_FLAG },
497   { "FMULQ",    3,  2,  0,  false, 0, 0,  SPARC_FPM,  M_FLOAT_FLAG | M_ARITH_FLAG },
498   { "FSMULD",   3,  2,  0,  false, 0, 3,  SPARC_FPM,  M_FLOAT_FLAG | M_ARITH_FLAG },
499   { "FDMULQ",   3,  2,  0,  false, 0, 0,  SPARC_FPM,  M_FLOAT_FLAG | M_ARITH_FLAG },
500   { "FDIVS",    3,  2,  0,  false, 0, 12, SPARC_FPM,  M_FLOAT_FLAG | M_ARITH_FLAG },
501   { "FDIVD",    3,  2,  0,  false, 0, 22, SPARC_FPM,  M_FLOAT_FLAG | M_ARITH_FLAG },
502   { "FDIVQ",    3,  2,  0,  false, 0, 0,  SPARC_FPM,  M_FLOAT_FLAG | M_ARITH_FLAG },
503   { "FSQRTS",   3,  2,  0,  false, 0, 12, SPARC_FPM,  M_FLOAT_FLAG | M_ARITH_FLAG },
504   { "FSQRTD",   3,  2,  0,  false, 0, 22, SPARC_FPM,  M_FLOAT_FLAG | M_ARITH_FLAG },
505   { "FSQRTQ",   3,  2,  0,  false, 0, 0,  SPARC_FPM,  M_FLOAT_FLAG | M_ARITH_FLAG },
506   
507   // Logical operations
508   { "AND",      3,  2, (1 << 12) - 1, true, 0, 1, SPARC_IEUN,  M_INT_FLAG | M_LOGICAL_FLAG},
509   { "ANDcc",    4,  2, (1 << 12) - 1, true, 0, 1, SPARC_IEU1,  M_INT_FLAG | M_LOGICAL_FLAG},
510   { "ANDN",     3,  2, (1 << 12) - 1, true, 0, 1, SPARC_IEUN,  M_INT_FLAG | M_LOGICAL_FLAG},
511   { "ANDNcc",   4,  2, (1 << 12) - 1, true, 0, 1, SPARC_IEU1,  M_INT_FLAG | M_LOGICAL_FLAG},
512   { "OR",       3,  2, (1 << 12) - 1, true, 0, 1, SPARC_IEUN,  M_INT_FLAG | M_LOGICAL_FLAG},
513   { "ORcc",     4,  2, (1 << 12) - 1, true, 0, 1, SPARC_IEU1,  M_INT_FLAG | M_LOGICAL_FLAG},
514   { "ORN",      3,  2, (1 << 12) - 1, true, 0, 1, SPARC_IEUN,  M_INT_FLAG | M_LOGICAL_FLAG},
515   { "ORNcc",    4,  2, (1 << 12) - 1, true, 0, 1, SPARC_IEU1,  M_INT_FLAG | M_LOGICAL_FLAG},
516   { "XOR",      3,  2, (1 << 12) - 1, true, 0, 1, SPARC_IEUN,  M_INT_FLAG | M_LOGICAL_FLAG},
517   { "XORcc",    4,  2, (1 << 12) - 1, true, 0, 1, SPARC_IEU1,  M_INT_FLAG | M_LOGICAL_FLAG},
518   { "XNOR",     3,  2, (1 << 12) - 1, true, 0, 1, SPARC_IEUN,  M_INT_FLAG | M_LOGICAL_FLAG},
519   { "XNORcc",   4,  2, (1 << 12) - 1, true, 0, 1, SPARC_IEU1,  M_INT_FLAG | M_LOGICAL_FLAG},
520   
521   // Shift operations
522   { "SLL",      3,  2, (1 << 5) - 1, true, 0, 1, SPARC_IEU0,  M_INT_FLAG | M_LOGICAL_FLAG},
523   { "SRL",      3,  2, (1 << 5) - 1, true, 0, 1, SPARC_IEU0,  M_INT_FLAG | M_LOGICAL_FLAG},
524   { "SRA",      3,  2, (1 << 5) - 1, true, 0, 1, SPARC_IEU0,  M_INT_FLAG | M_ARITH_FLAG },
525   { "SLLX",     3,  2, (1 << 6) - 1, true, 0, 1, SPARC_IEU0,  M_INT_FLAG | M_LOGICAL_FLAG},
526   { "SRLX",     3,  2, (1 << 6) - 1, true, 0, 1, SPARC_IEU0,  M_INT_FLAG | M_LOGICAL_FLAG},
527   { "SRAX",     3,  2, (1 << 6) - 1, true, 0, 1, SPARC_IEU0,  M_INT_FLAG | M_ARITH_FLAG },
528   
529   // Floating point move, negate, and abs instructions
530   { "FMOVS",    2,  1,  0,  false,  0,  1,  SPARC_FPA,  M_FLOAT_FLAG },
531   { "FMOVD",    2,  1,  0,  false,  0,  1,  SPARC_FPA,  M_FLOAT_FLAG },
532 //{ "FMOVQ",    2,  1,  0,  false,  0,  ?,  SPARC_FPA,  M_FLOAT_FLAG },
533   { "FNEGS",    2,  1,  0,  false,  0,  1,  SPARC_FPA,  M_FLOAT_FLAG },
534   { "FNEGD",    2,  1,  0,  false,  0,  1,  SPARC_FPA,  M_FLOAT_FLAG },
535 //{ "FNEGQ",    2,  1,  0,  false,  0,  ?,  SPARC_FPA,  M_FLOAT_FLAG },
536   { "FABSS",    2,  1,  0,  false,  0,  1,  SPARC_FPA,  M_FLOAT_FLAG },
537   { "FABSD",    2,  1,  0,  false,  0,  1,  SPARC_FPA,  M_FLOAT_FLAG },
538 //{ "FABSQ",    2,  1,  0,  false,  0,  ?,  SPARC_FPA,  M_FLOAT_FLAG },
539   
540   // Convert from floating point to floating point formats
541   { "FSTOD",    2,  1,  0,  false,  0,  3,  SPARC_FPA,  M_FLOAT_FLAG | M_ARITH_FLAG },
542   { "FSTOQ",    2,  1,  0,  false,  0,  0,  SPARC_FPA,  M_FLOAT_FLAG | M_ARITH_FLAG },
543   { "FDTOS",    2,  1,  0,  false,  0,  3,  SPARC_FPA,  M_FLOAT_FLAG | M_ARITH_FLAG },
544   { "FDTOQ",    2,  1,  0,  false,  0,  0,  SPARC_FPA,  M_FLOAT_FLAG | M_ARITH_FLAG },
545   { "FQTOS",    2,  1,  0,  false,  0,  0,  SPARC_FPA,  M_FLOAT_FLAG | M_ARITH_FLAG },
546   { "FQTOD",    2,  1,  0,  false,  0,  0,  SPARC_FPA,  M_FLOAT_FLAG | M_ARITH_FLAG },
547   
548   // Convert from floating point to integer formats.
549   // Note that this accesses both integer and floating point registers.
550   { "FSTOX",    2,  1,  0,  false, 0, 3,  SPARC_FPA,  M_FLOAT_FLAG | M_INT_FLAG | M_ARITH_FLAG },
551   { "FDTOX",    2,  1,  0,  false, 0, 0,  SPARC_FPA,  M_FLOAT_FLAG | M_INT_FLAG | M_ARITH_FLAG },
552   { "FQTOX",    2,  1,  0,  false, 0, 2,  SPARC_FPA,  M_FLOAT_FLAG | M_INT_FLAG | M_ARITH_FLAG },
553   { "FSTOI",    2,  1,  0,  false, 0, 3,  SPARC_FPA,  M_FLOAT_FLAG | M_INT_FLAG | M_ARITH_FLAG },
554   { "FDTOI",    2,  1,  0,  false, 0, 3,  SPARC_FPA,  M_FLOAT_FLAG | M_INT_FLAG | M_ARITH_FLAG },
555   { "FQTOI",    2,  1,  0,  false, 0, 0,  SPARC_FPA,  M_FLOAT_FLAG | M_INT_FLAG | M_ARITH_FLAG },
556   
557   // Convert from integer to floating point formats
558   // Note that this accesses both integer and floating point registers.
559   { "FXTOS",    2,  1,  0,  false, 0, 3,  SPARC_FPA,  M_FLOAT_FLAG | M_INT_FLAG | M_ARITH_FLAG },
560   { "FXTOD",    2,  1,  0,  false, 0, 3,  SPARC_FPA,  M_FLOAT_FLAG | M_INT_FLAG | M_ARITH_FLAG },
561   { "FXTOQ",    2,  1,  0,  false, 0, 0,  SPARC_FPA,  M_FLOAT_FLAG | M_INT_FLAG | M_ARITH_FLAG },
562   { "FITOS",    2,  1,  0,  false, 0, 3,  SPARC_FPA,  M_FLOAT_FLAG | M_INT_FLAG | M_ARITH_FLAG },
563   { "FITOD",    2,  1,  0,  false, 0, 3,  SPARC_FPA,  M_FLOAT_FLAG | M_INT_FLAG | M_ARITH_FLAG },
564   { "FITOQ",    2,  1,  0,  false, 0, 0,  SPARC_FPA,  M_FLOAT_FLAG | M_INT_FLAG | M_ARITH_FLAG },
565   
566   // Branch on integer comparison with zero.
567   // Latency includes the delay slot.
568   { "BRZ",      2, -1, (1 << 15) - 1, true, 1, 2,  SPARC_CTI,  M_INT_FLAG | M_BRANCH_FLAG },
569   { "BRLEZ",    2, -1, (1 << 15) - 1, true, 1, 2,  SPARC_CTI,  M_INT_FLAG | M_BRANCH_FLAG },
570   { "BRLZ",     2, -1, (1 << 15) - 1, true, 1, 2,  SPARC_CTI,  M_INT_FLAG | M_BRANCH_FLAG },
571   { "BRNZ",     2, -1, (1 << 15) - 1, true, 1, 2,  SPARC_CTI,  M_INT_FLAG | M_BRANCH_FLAG },
572   { "BRGZ",     2, -1, (1 << 15) - 1, true, 1, 2,  SPARC_CTI,  M_INT_FLAG | M_BRANCH_FLAG },
573   { "BRGEZ",    2, -1, (1 << 15) - 1, true, 1, 2,  SPARC_CTI,  M_INT_FLAG | M_BRANCH_FLAG },
574
575   // Branch on condition code.
576   // The first argument specifies the ICC register: %icc or %xcc
577   // Latency includes the delay slot.
578   { "BA",       2,  -1, (1 << 21) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
579   { "BN",       2,  -1, (1 << 21) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
580   { "BNE",      2,  -1, (1 << 21) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
581   { "BE",       2,  -1, (1 << 21) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
582   { "BG",       2,  -1, (1 << 21) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
583   { "BLE",      2,  -1, (1 << 21) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
584   { "BGE",      2,  -1, (1 << 21) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
585   { "BL",       2,  -1, (1 << 21) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
586   { "BGU",      2,  -1, (1 << 21) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
587   { "BLEU",     2,  -1, (1 << 21) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
588   { "BCC",      2,  -1, (1 << 21) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
589   { "BCS",      2,  -1, (1 << 21) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
590   { "BPOS",     2,  -1, (1 << 21) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
591   { "BNEG",     2,  -1, (1 << 21) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
592   { "BVC",      2,  -1, (1 << 21) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
593   { "BVS",      2,  -1, (1 << 21) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
594
595   // Branch on floating point condition code.
596   // Annul bit specifies if intruction in delay slot is annulled(1) or not(0).
597   // PredictTaken bit hints if branch should be predicted taken(1) or not(0).
598   // The first argument is the FCCn register (0 <= n <= 3).
599   // Latency includes the delay slot.
600   { "FBA",      2,  -1, (1 << 18) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
601   { "FBN",      2,  -1, (1 << 18) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
602   { "FBU",      2,  -1, (1 << 18) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
603   { "FBG",      2,  -1, (1 << 18) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
604   { "FBUG",     2,  -1, (1 << 18) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
605   { "FBL",      2,  -1, (1 << 18) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
606   { "FBUL",     2,  -1, (1 << 18) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
607   { "FBLG",     2,  -1, (1 << 18) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
608   { "FBNE",     2,  -1, (1 << 18) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
609   { "FBE",      2,  -1, (1 << 18) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
610   { "FBUE",     2,  -1, (1 << 18) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
611   { "FBGE",     2,  -1, (1 << 18) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
612   { "FBUGE",    2,  -1, (1 << 18) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
613   { "FBLE",     2,  -1, (1 << 18) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
614   { "FBULE",    2,  -1, (1 << 18) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
615   { "FBO",      2,  -1, (1 << 18) - 1, true, 1, 2,  SPARC_CTI,  M_CC_FLAG | M_BRANCH_FLAG },
616
617   // Conditional move on integer comparison with zero.
618   { "MOVRZ",    3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CONDL_FLAG | M_INT_FLAG },
619   { "MOVRLEZ",  3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CONDL_FLAG | M_INT_FLAG },
620   { "MOVRLZ",   3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CONDL_FLAG | M_INT_FLAG },
621   { "MOVRNZ",   3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CONDL_FLAG | M_INT_FLAG },
622   { "MOVRGZ",   3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CONDL_FLAG | M_INT_FLAG },
623   { "MOVRGEZ",  3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CONDL_FLAG | M_INT_FLAG },
624
625   // Conditional move on integer condition code.
626   // The first argument specifies the ICC register: %icc or %xcc
627   { "MOVA",     3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
628   { "MOVN",     3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
629   { "MOVNE",    3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
630   { "MOVE",     3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
631   { "MOVG",     3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
632   { "MOVLE",    3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
633   { "MOVGE",    3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
634   { "MOVL",     3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
635   { "MOVGU",    3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
636   { "MOVLEU",   3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
637   { "MOVCC",    3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
638   { "MOVCS",    3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
639   { "MOVPOS",   3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
640   { "MOVNEG",   3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
641   { "MOVVC",    3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
642   { "MOVVS",    3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
643
644   // Conditional move (of integer register) on floating point condition code.
645   // The first argument is the FCCn register (0 <= n <= 3).
646   // Note that the enum name above is not the same as the assembly mnemonic
647   // because some of the assembly mnemonics are the same as the move on
648   // integer CC (e.g., MOVG), and we cannot have the same enum entry twice.
649   { "MOVA",     3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
650   { "MOVN",     3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
651   { "MOVU",     3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
652   { "MOVG",     3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
653   { "MOVUG",    3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
654   { "MOVL",     3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
655   { "MOVUL",    3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
656   { "MOVLG",    3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
657   { "MOVNE",    3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
658   { "MOVE",     3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
659   { "MOVUE",    3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
660   { "MOVGE",    3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
661   { "MOVUGE",   3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
662   { "MOVLE",    3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
663   { "MOVULE",   3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
664   { "MOVO",     3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_INT_FLAG },
665
666   // Conditional move of floating point register on each of the above:
667   // i.   on integer comparison with zero.
668   // ii.  on integer condition code
669   // iii. on floating point condition code
670   // Note that the same set is repeated for S,D,Q register classes.
671   { "FMOVRSZ",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CONDL_FLAG | M_FLOAT_FLAG | M_INT_FLAG },
672   { "FMOVRSLEZ",3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CONDL_FLAG | M_FLOAT_FLAG | M_INT_FLAG },
673   { "FMOVRSLZ", 3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CONDL_FLAG | M_FLOAT_FLAG | M_INT_FLAG },
674   { "FMOVRSNZ", 3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CONDL_FLAG | M_FLOAT_FLAG | M_INT_FLAG },
675   { "FMOVRSGZ", 3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CONDL_FLAG | M_FLOAT_FLAG | M_INT_FLAG },
676   { "FMOVRSGEZ",3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CONDL_FLAG | M_FLOAT_FLAG | M_INT_FLAG },
677
678   { "FMOVSA",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
679   { "FMOVSN",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
680   { "FMOVSNE",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
681   { "FMOVSE",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
682   { "FMOVSG",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
683   { "FMOVSLE",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
684   { "FMOVSGE",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
685   { "FMOVSL",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
686   { "FMOVSGU",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
687   { "FMOVSLEU", 3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
688   { "FMOVSCC",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
689   { "FMOVSCS",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
690   { "FMOVSPOS", 3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
691   { "FMOVSNEG", 3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
692   { "FMOVSVC",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
693   { "FMOVSVS",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
694
695   { "FMOVSA",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
696   { "FMOVSN",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
697   { "FMOVSU",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
698   { "FMOVSG",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
699   { "FMOVSUG",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
700   { "FMOVSL",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
701   { "FMOVSUL",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
702   { "FMOVSLG",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
703   { "FMOVSNE",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
704   { "FMOVSE",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
705   { "FMOVSUE",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
706   { "FMOVSGE",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
707   { "FMOVSUGE", 3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
708   { "FMOVSLE",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
709   { "FMOVSULE", 3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
710   { "FMOVSO",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
711
712   { "FMOVRDZ",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CONDL_FLAG | M_FLOAT_FLAG | M_INT_FLAG },
713   { "FMOVRDLEZ",3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CONDL_FLAG | M_FLOAT_FLAG | M_INT_FLAG },
714   { "FMOVRDLZ", 3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CONDL_FLAG | M_FLOAT_FLAG | M_INT_FLAG },
715   { "FMOVRDNZ", 3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CONDL_FLAG | M_FLOAT_FLAG | M_INT_FLAG },
716   { "FMOVRDGZ", 3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CONDL_FLAG | M_FLOAT_FLAG | M_INT_FLAG },
717   { "FMOVRDGEZ",3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CONDL_FLAG | M_FLOAT_FLAG | M_INT_FLAG },
718
719   { "FMOVDA",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
720   { "FMOVDN",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
721   { "FMOVDNE",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
722   { "FMOVDE",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
723   { "FMOVDG",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
724   { "FMOVDLE",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
725   { "FMOVDGE",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
726   { "FMOVDL",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
727   { "FMOVDGU",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
728   { "FMOVDLEU", 3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
729   { "FMOVDCC",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
730   { "FMOVDCS",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
731   { "FMOVDPOS", 3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
732   { "FMOVDNEG", 3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
733   { "FMOVDVC",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
734   { "FMOVDVS",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
735
736   { "FMOVDA",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
737   { "FMOVDN",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
738   { "FMOVDU",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
739   { "FMOVDG",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
740   { "FMOVDUG",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
741   { "FMOVDL",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
742   { "FMOVDUL",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
743   { "FMOVDLG",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
744   { "FMOVDNE",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
745   { "FMOVDE",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
746   { "FMOVDUE",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
747   { "FMOVDGE",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
748   { "FMOVDUGE", 3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
749   { "FMOVDLE",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
750   { "FMOVDULE", 3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
751   { "FMOVDO",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
752
753   { "FMOVRQZ",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CONDL_FLAG | M_FLOAT_FLAG | M_INT_FLAG },
754   { "FMOVRQLEZ",3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CONDL_FLAG | M_FLOAT_FLAG | M_INT_FLAG },
755   { "FMOVRQLZ", 3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CONDL_FLAG | M_FLOAT_FLAG | M_INT_FLAG },
756   { "FMOVRQNZ", 3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CONDL_FLAG | M_FLOAT_FLAG | M_INT_FLAG },
757   { "FMOVRQGZ", 3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CONDL_FLAG | M_FLOAT_FLAG | M_INT_FLAG },
758   { "FMOVRQGEZ",3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CONDL_FLAG | M_FLOAT_FLAG | M_INT_FLAG },
759
760   { "FMOVQA",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
761   { "FMOVQN",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
762   { "FMOVQNE",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
763   { "FMOVQE",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
764   { "FMOVQG",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
765   { "FMOVQLE",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
766   { "FMOVQGE",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
767   { "FMOVQL",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
768   { "FMOVQGU",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
769   { "FMOVQLEU", 3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
770   { "FMOVQCC",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
771   { "FMOVQCS",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
772   { "FMOVQPOS", 3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
773   { "FMOVQNEG", 3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
774   { "FMOVQVC",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
775   { "FMOVQVS",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
776
777   { "FMOVQA",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
778   { "FMOVQN",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
779   { "FMOVQU",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
780   { "FMOVQG",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
781   { "FMOVQUG",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
782   { "FMOVQL",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
783   { "FMOVQUL",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
784   { "FMOVQLG",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
785   { "FMOVQNE",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
786   { "FMOVQE",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
787   { "FMOVQUE",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
788   { "FMOVQGE",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
789   { "FMOVQUGE", 3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
790   { "FMOVQLE",  3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
791   { "FMOVQULE", 3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
792   { "FMOVQO",   3,  2, 0,  false, 0, 2,  SPARC_SINGLE,  M_CC_FLAG | M_FLOAT_FLAG },
793   
794   // Load integer instructions
795   // Latency includes 1 cycle for address generation (Sparc IIi)
796   // Signed loads of less than 64 bits need an extra cycle for sign-extension.
797   //
798   // Not reflected here: After a 3-cycle loads, all subsequent consecutive
799   // loads also require 3 cycles to avoid contention for the load return
800   // stage.  Latency returns to 2 cycles after the first cycle with no load.
801   { "LDSB",     3,  2, (1 << 12) - 1,  true, 0, 3,  SPARC_LD,  M_INT_FLAG | M_LOAD_FLAG },
802   { "LDSH",     3,  2, (1 << 12) - 1,  true, 0, 3,  SPARC_LD,  M_INT_FLAG | M_LOAD_FLAG },
803   { "LDSW",     3,  2, (1 << 12) - 1,  true, 0, 3,  SPARC_LD,  M_INT_FLAG | M_LOAD_FLAG },
804   { "LDUB",     3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_LD,  M_INT_FLAG | M_LOAD_FLAG },
805   { "LDUH",     3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_LD,  M_INT_FLAG | M_LOAD_FLAG },
806   { "LDUW",     3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_LD,  M_INT_FLAG | M_LOAD_FLAG },
807   { "LDX",      3,  2, (1 << 12) - 1,  true, 0, 2,  SPARC_LD,  M_INT_FLAG | M_LOAD_FLAG },
808   
809   // Load floating-point instructions
810   // Latency includes 1 cycle for address generation (Sparc IIi)
811   { "LD",       3, 2, (1 << 12) - 1, true, 0, 2,  SPARC_LD,  M_FLOAT_FLAG | M_LOAD_FLAG },
812   { "LDD",      3, 2, (1 << 12) - 1, true, 0, 2,  SPARC_LD,  M_FLOAT_FLAG | M_LOAD_FLAG },
813   { "LDQ",      3, 2, (1 << 12) - 1, true, 0, 2,  SPARC_LD,  M_FLOAT_FLAG | M_LOAD_FLAG },
814   
815   // Store integer instructions
816   // Latency includes 1 cycle for address generation (Sparc IIi)
817   { "STB",      3, -1, (1 << 12) - 1, true, 0, 2,  SPARC_ST,  M_INT_FLAG | M_STORE_FLAG },
818   { "STH",      3, -1, (1 << 12) - 1, true, 0, 2,  SPARC_ST,  M_INT_FLAG | M_STORE_FLAG },
819   { "STW",      3, -1, (1 << 12) - 1, true, 0, 2,  SPARC_ST,  M_INT_FLAG | M_STORE_FLAG },
820   { "STX",      3, -1, (1 << 12) - 1, true, 0, 3,  SPARC_ST,  M_INT_FLAG | M_STORE_FLAG },
821   
822   // Store floating-point instructions (Sparc IIi)
823   { "ST",       3, -1, (1 << 12) - 1, true, 0, 2,  SPARC_ST,  M_FLOAT_FLAG | M_STORE_FLAG},
824   { "STD",      3, -1, (1 << 12) - 1, true, 0, 2,  SPARC_ST,  M_FLOAT_FLAG | M_STORE_FLAG},
825   
826   // Call, Return and "Jump and link".
827   // Latency includes the delay slot.
828   { "CALL",     1, -1, (1 << 29) - 1, true, 1, 2,  SPARC_CTI,  M_BRANCH_FLAG | M_CALL_FLAG},
829   { "JMPL",     3, -1, (1 << 12) - 1, true, 1, 2,  SPARC_CTI,  M_BRANCH_FLAG | M_CALL_FLAG},
830   { "RETURN",   2, -1,  0,           false, 1, 2,  SPARC_CTI,  M_BRANCH_FLAG | M_RET_FLAG },
831   
832   // Synthetic phi operation for near-SSA form of machine code
833   // Number of operands is variable, indicated by -1.  Result is the first op.
834   { "PHI",      -1,  0,  0,  false, 0, 0, SPARC_INV,  M_DUMMY_PHI_FLAG },
835 };
836
837
838
839 //---------------------------------------------------------------------------
840 // class UltraSparcInstrInfo 
841 // 
842 // Purpose:
843 //   Information about individual instructions.
844 //   Most information is stored in the SparcMachineInstrDesc array above.
845 //   Other information is computed on demand, and most such functions
846 //   default to member functions in base class MachineInstrInfo. 
847 //---------------------------------------------------------------------------
848
849 class UltraSparcInstrInfo : public MachineInstrInfo {
850 public:
851   /*ctor*/      UltraSparcInstrInfo();
852   
853   virtual bool          hasResultInterlock      (MachineOpCode opCode)
854   {
855     // All UltraSPARC instructions have interlocks (note that delay slots
856     // are not considered here).
857     // However, instructions that use the result of an FCMP produce a
858     // 9-cycle stall if they are issued less than 3 cycles after the FCMP.
859     // Force the compiler to insert a software interlock (i.e., gap of
860     // 2 other groups, including NOPs if necessary).
861     return (opCode == FCMPS || opCode == FCMPD || opCode == FCMPQ);
862   }
863 };
864
865
866 //---------------------------------------------------------------------------
867 // class UltraSparcMachine 
868 // 
869 // Purpose:
870 //   Primary interface to machine description for the UltraSPARC.
871 //   Primarily just initializes machine-dependent parameters in
872 //   class TargetMachine, and creates machine-dependent subclasses
873 //   for classes such as MachineInstrInfo. 
874 //---------------------------------------------------------------------------
875
876 class UltraSparc: public TargetMachine {
877 public:
878   /*ctor*/              UltraSparc      ();
879   /*dtor*/ virtual      ~UltraSparc     ();
880 };
881
882
883 /*---------------------------------------------------------------------------
884 Scheduling guidelines for SPARC IIi:
885
886 I-Cache alignment rules (pg 326)
887 -- Align a branch target instruction so that it's entire group is within
888    the same cache line (may be 1-4 instructions).
889 ** Don't let a branch that is predicted taken be the last instruction
890    on an I-cache line: delay slot will need an entire line to be fetched
891 -- Make a FP instruction or a branch be the 4th instruction in a group.
892    For branches, there are tradeoffs in reordering to make this happen
893    (see pg. 327).
894 ** Don't put a branch in a group that crosses a 32-byte boundary!
895    An artificial branch is inserted after every 32 bytes, and having
896    another branch will force the group to be broken into 2 groups. 
897
898 iTLB rules:
899 -- Don't let a loop span two memory pages, if possible
900
901 Branch prediction performance:
902 -- Don't make the branch in a delay slot the target of a branch
903 -- Try not to have 2 predicted branches within a group of 4 instructions
904    (because each such group has a single branch target field).
905 -- Try to align branches in slots 0, 2, 4 or 6 of a cache line (to avoid
906    the wrong prediction bits being used in some cases).
907
908 D-Cache timing constraints:
909 -- Signed int loads of less than 64 bits have 3 cycle latency, not 2
910 -- All other loads that hit in D-Cache have 2 cycle latency
911 -- All loads are returned IN ORDER, so a D-Cache miss will delay a later hit
912 -- Mis-aligned loads or stores cause a trap.  In particular, replace
913    mis-aligned FP double precision l/s with 2 single-precision l/s.
914 -- Simulations of integer codes show increase in avg. group size of
915    33% when code (including esp. non-faulting loads) is moved across
916    one branch, and 50% across 2 branches.
917
918 E-Cache timing constraints:
919 -- Scheduling for E-cache (D-Cache misses) is effective (due to load buffering)
920
921 Store buffer timing constraints:
922 -- Stores can be executed in same cycle as instruction producing the value
923 -- Stores are buffered and have lower priority for E-cache until
924    highwater mark is reached in the store buffer (5 stores)
925
926 Pipeline constraints:
927 -- Shifts can only use IEU0.
928 -- CC setting instructions can only use IEU1.
929 -- Several other instructions must only use IEU1:
930    EDGE(?), ARRAY(?), CALL, JMPL, BPr, PST, and FCMP.
931 -- Two instructions cannot store to the same register file in a single cycle
932    (single write port per file).
933
934 Issue and grouping constraints:
935 -- FP and branch instructions must use slot 4.
936 -- Shift instructions cannot be grouped with other IEU0-specific instructions.
937 -- CC setting instructions cannot be grouped with other IEU1-specific instrs.
938 -- Several instructions must be issued in a single-instruction group:
939         MOVcc or MOVr, MULs/x and DIVs/x, SAVE/RESTORE, many others
940 -- A CALL or JMPL breaks a group, ie, is not combined with subsequent instrs.
941 -- 
942 -- 
943
944 Branch delay slot scheduling rules:
945 -- A CTI couple (two back-to-back CTI instructions in the dynamic stream)
946    has a 9-instruction penalty: the entire pipeline is flushed when the
947    second instruction reaches stage 9 (W-Writeback).
948 -- Avoid putting multicycle instructions, and instructions that may cause
949    load misses, in the delay slot of an annulling branch.
950 -- Avoid putting WR, SAVE..., RESTORE and RETURN instructions in the
951    delay slot of an annulling branch.
952
953  *--------------------------------------------------------------------------- */
954
955 //---------------------------------------------------------------------------
956 // List of CPUResources for UltraSPARC IIi.
957 //---------------------------------------------------------------------------
958
959 const CPUResource  AllIssueSlots(   "All Instr Slots", 4);
960 const CPUResource  IntIssueSlots(   "Int Instr Slots", 3);
961 const CPUResource  First3IssueSlots("Instr Slots 0-3", 3);
962 const CPUResource  LSIssueSlots(    "Load-Store Instr Slot", 1);
963 const CPUResource  CTIIssueSlots(   "Ctrl Transfer Instr Slot", 1);
964 const CPUResource  FPAIssueSlots(   "Int Instr Slot 1", 1);
965 const CPUResource  FPMIssueSlots(   "Int Instr Slot 1", 1);
966
967 // IEUN instructions can use either Alu and should use IAluN.
968 // IEU0 instructions must use Alu 1 and should use both IAluN and IAlu0. 
969 // IEU1 instructions must use Alu 2 and should use both IAluN and IAlu1. 
970 const CPUResource  IAluN("Int ALU 1or2", 2);
971 const CPUResource  IAlu0("Int ALU 1",    1);
972 const CPUResource  IAlu1("Int ALU 2",    1);
973
974 const CPUResource  LSAluC1("Load/Store Unit Addr Cycle", 1);
975 const CPUResource  LSAluC2("Load/Store Unit Issue Cycle", 1);
976 const CPUResource  LdReturn("Load Return Unit", 1);
977
978 const CPUResource  FPMAluC1("FP Mul/Div Alu Cycle 1", 1);
979 const CPUResource  FPMAluC2("FP Mul/Div Alu Cycle 2", 1);
980 const CPUResource  FPMAluC3("FP Mul/Div Alu Cycle 3", 1);
981
982 const CPUResource  FPAAluC1("FP Other Alu Cycle 1", 1);
983 const CPUResource  FPAAluC2("FP Other Alu Cycle 2", 1);
984 const CPUResource  FPAAluC3("FP Other Alu Cycle 3", 1);
985
986 const CPUResource  IRegReadPorts("Int Reg ReadPorts", INT_MAX);  // CHECK
987 const CPUResource  IRegWritePorts("Int Reg WritePorts", 2);      // CHECK
988 const CPUResource  FPRegReadPorts("FP Reg Read Ports", INT_MAX); // CHECK
989 const CPUResource  FPRegWritePorts("FP Reg Write Ports", 1);     // CHECK
990
991 const CPUResource  CTIDelayCycle( "CTI  delay cycle", 1);
992 const CPUResource  FCMPDelayCycle("FCMP delay cycle", 1);
993
994
995 //---------------------------------------------------------------------------
996 // const InstrClassRUsage SparcRUsageDesc[]
997 // 
998 // Purpose:
999 //   Resource usage information for instruction in each scheduling class.
1000 //   The InstrRUsage Objects for individual classes are specified first.
1001 //   Note that fetch and decode are decoupled from the execution pipelines
1002 //   via an instr buffer, so they are not included in the cycles below.
1003 //---------------------------------------------------------------------------
1004
1005 const InstrClassRUsage NoneClassRUsage = {
1006   SPARC_NONE,
1007   /*totCycles*/ 7,
1008   
1009   /* maxIssueNum */ 4,
1010   /* isSingleIssue */ false,
1011   /* breaksGroup */ false,
1012   /* numBubbles */ 0,
1013   
1014   /*numSlots*/ 4,
1015   /* feasibleSlots[] */ { 0, 1, 2, 3 },
1016   
1017   /*numEntries*/ 0,
1018   /* V[] */ {
1019     /*Cycle G */
1020     /*Cycle E */
1021     /*Cycle C */
1022     /*Cycle N1*/
1023     /*Cycle N1*/
1024     /*Cycle N1*/
1025     /*Cycle W */
1026   }
1027 };
1028
1029 const InstrClassRUsage IEUNClassRUsage = {
1030   SPARC_IEUN,
1031   /*totCycles*/ 7,
1032   
1033   /* maxIssueNum */ 3,
1034   /* isSingleIssue */ false,
1035   /* breaksGroup */ false,
1036   /* numBubbles */ 0,
1037   
1038   /*numSlots*/ 3,
1039   /* feasibleSlots[] */ { 0, 1, 2 },
1040   
1041   /*numEntries*/ 4,
1042   /* V[] */ {
1043     /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
1044                  { IntIssueSlots.rid, 0, 1 },
1045     /*Cycle E */ { IAluN.rid, 1, 1 },
1046     /*Cycle C */
1047     /*Cycle N1*/
1048     /*Cycle N1*/
1049     /*Cycle N1*/
1050     /*Cycle W */ { IRegWritePorts.rid, 6, 1  }
1051   }
1052 };
1053
1054 const InstrClassRUsage IEU0ClassRUsage = {
1055   SPARC_IEU0,
1056   /*totCycles*/ 7,
1057   
1058   /* maxIssueNum */ 1,
1059   /* isSingleIssue */ false,
1060   /* breaksGroup */ false,
1061   /* numBubbles */ 0,
1062   
1063   /*numSlots*/ 3,
1064   /* feasibleSlots[] */ { 0, 1, 2 },
1065   
1066   /*numEntries*/ 5,
1067   /* V[] */ {
1068     /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
1069                  { IntIssueSlots.rid, 0, 1 },
1070     /*Cycle E */ { IAluN.rid, 1, 1 },
1071                  { IAlu0.rid, 1, 1 },
1072     /*Cycle C */
1073     /*Cycle N1*/
1074     /*Cycle N1*/
1075     /*Cycle N1*/
1076     /*Cycle W */ { IRegWritePorts.rid, 6, 1 }
1077   }
1078 };
1079
1080 const InstrClassRUsage IEU1ClassRUsage = {
1081   SPARC_IEU1,
1082   /*totCycles*/ 7,
1083   
1084   /* maxIssueNum */ 1,
1085   /* isSingleIssue */ false,
1086   /* breaksGroup */ false,
1087   /* numBubbles */ 0,
1088   
1089   /*numSlots*/ 3,
1090   /* feasibleSlots[] */ { 0, 1, 2 },
1091   
1092   /*numEntries*/ 5,
1093   /* V[] */ {
1094     /*Cycle G */ { AllIssueSlots.rid, 0, 1 },
1095                { IntIssueSlots.rid, 0, 1 },
1096     /*Cycle E */ { IAluN.rid, 1, 1 },
1097                { IAlu1.rid, 1, 1 },
1098     /*Cycle C */
1099     /*Cycle N1*/
1100     /*Cycle N1*/
1101     /*Cycle N1*/
1102     /*Cycle W */ { IRegWritePorts.rid, 6, 1 }
1103   }
1104 };
1105
1106 const InstrClassRUsage FPMClassRUsage = {
1107   SPARC_FPM,
1108   /*totCycles*/ 7,
1109   
1110   /* maxIssueNum */ 1,
1111   /* isSingleIssue */ false,
1112   /* breaksGroup */ false,
1113   /* numBubbles */ 0,
1114   
1115   /*numSlots*/ 4,
1116   /* feasibleSlots[] */ { 0, 1, 2, 3 },
1117   
1118   /*numEntries*/ 7,
1119   /* V[] */ {
1120     /*Cycle G */ { AllIssueSlots.rid,   0, 1 },
1121                  { FPMIssueSlots.rid,   0, 1 },
1122     /*Cycle E */ { FPRegReadPorts.rid,  1, 1 },
1123     /*Cycle C */ { FPMAluC1.rid,        2, 1 },
1124     /*Cycle N1*/ { FPMAluC2.rid,        3, 1 },
1125     /*Cycle N1*/ { FPMAluC3.rid,        4, 1 },
1126     /*Cycle N1*/
1127     /*Cycle W */ { FPRegWritePorts.rid, 6, 1 }
1128   }
1129 };
1130
1131 const InstrClassRUsage FPAClassRUsage = {
1132   SPARC_FPA,
1133   /*totCycles*/ 7,
1134   
1135   /* maxIssueNum */ 1,
1136   /* isSingleIssue */ false,
1137   /* breaksGroup */ false,
1138   /* numBubbles */ 0,
1139   
1140   /*numSlots*/ 4,
1141   /* feasibleSlots[] */ { 0, 1, 2, 3 },
1142   
1143   /*numEntries*/ 7,
1144   /* V[] */ {
1145     /*Cycle G */ { AllIssueSlots.rid,   0, 1 },
1146                  { FPAIssueSlots.rid,   0, 1 },
1147     /*Cycle E */ { FPRegReadPorts.rid,  1, 1 },
1148     /*Cycle C */ { FPAAluC1.rid,        2, 1 },
1149     /*Cycle N1*/ { FPAAluC2.rid,        3, 1 },
1150     /*Cycle N1*/ { FPAAluC3.rid,        4, 1 },
1151     /*Cycle N1*/
1152     /*Cycle W */ { FPRegWritePorts.rid, 6, 1 }
1153   }
1154 };
1155
1156 const InstrClassRUsage LDClassRUsage = {
1157   SPARC_LD,
1158   /*totCycles*/ 7,
1159   
1160   /* maxIssueNum */ 1,
1161   /* isSingleIssue */ false,
1162   /* breaksGroup */ false,
1163   /* numBubbles */ 0,
1164   
1165   /*numSlots*/ 3,
1166   /* feasibleSlots[] */ { 0, 1, 2, },
1167   
1168   /*numEntries*/ 6,
1169   /* V[] */ {
1170     /*Cycle G */ { AllIssueSlots.rid,    0, 1 },
1171                  { First3IssueSlots.rid, 0, 1 },
1172                  { LSIssueSlots.rid,     0, 1 },
1173     /*Cycle E */ { LSAluC1.rid,          1, 1 },
1174     /*Cycle C */ { LSAluC2.rid,          2, 1 },
1175                  { LdReturn.rid,         2, 1 },
1176     /*Cycle N1*/
1177     /*Cycle N1*/
1178     /*Cycle N1*/
1179     /*Cycle W */ { IRegWritePorts.rid,   6, 1 }
1180   }
1181 };
1182
1183 const InstrClassRUsage STClassRUsage = {
1184   SPARC_ST,
1185   /*totCycles*/ 7,
1186   
1187   /* maxIssueNum */ 1,
1188   /* isSingleIssue */ false,
1189   /* breaksGroup */ false,
1190   /* numBubbles */ 0,
1191   
1192   /*numSlots*/ 3,
1193   /* feasibleSlots[] */ { 0, 1, 2 },
1194   
1195   /*numEntries*/ 4,
1196   /* V[] */ {
1197     /*Cycle G */ { AllIssueSlots.rid,    0, 1 },
1198                  { First3IssueSlots.rid, 0, 1 },
1199                  { LSIssueSlots.rid,     0, 1 },
1200     /*Cycle E */ { LSAluC1.rid,          1, 1 },
1201     /*Cycle C */ { LSAluC2.rid,          2, 1 }
1202     /*Cycle N1*/
1203     /*Cycle N1*/
1204     /*Cycle N1*/
1205     /*Cycle W */
1206   }
1207 };
1208
1209 const InstrClassRUsage CTIClassRUsage = {
1210   SPARC_CTI,
1211   /*totCycles*/ 7,
1212   
1213   /* maxIssueNum */ 1,
1214   /* isSingleIssue */ false,
1215   /* breaksGroup */ false,
1216   /* numBubbles */ 0,
1217   
1218   /*numSlots*/ 4,
1219   /* feasibleSlots[] */ { 0, 1, 2, 3 },
1220   
1221   /*numEntries*/ 4,
1222   /* V[] */ {
1223     /*Cycle G */ { AllIssueSlots.rid,    0, 1 },
1224                  { CTIIssueSlots.rid,    0, 1 },
1225     /*Cycle E */ { IAlu0.rid,            1, 1 },
1226     /*Cycles E-C */ { CTIDelayCycle.rid, 1, 2 }
1227     /*Cycle C */             
1228     /*Cycle N1*/
1229     /*Cycle N1*/
1230     /*Cycle N1*/
1231     /*Cycle W */
1232   }
1233 };
1234
1235 const InstrClassRUsage SingleClassRUsage = {
1236   SPARC_SINGLE,
1237   /*totCycles*/ 7,
1238   
1239   /* maxIssueNum */ 1,
1240   /* isSingleIssue */ true,
1241   /* breaksGroup */ false,
1242   /* numBubbles */ 0,
1243   
1244   /*numSlots*/ 1,
1245   /* feasibleSlots[] */ { 0 },
1246   
1247   /*numEntries*/ 5,
1248   /* V[] */ {
1249     /*Cycle G */ { AllIssueSlots.rid,    0, 1 },
1250                  { AllIssueSlots.rid,    0, 1 },
1251                  { AllIssueSlots.rid,    0, 1 },
1252                  { AllIssueSlots.rid,    0, 1 },
1253     /*Cycle E */ { IAlu0.rid,            1, 1 }
1254     /*Cycle C */
1255     /*Cycle N1*/
1256     /*Cycle N1*/
1257     /*Cycle N1*/
1258     /*Cycle W */
1259   }
1260 };
1261
1262
1263 const InstrClassRUsage SparcRUsageDesc[] = {
1264   NoneClassRUsage,
1265   IEUNClassRUsage,
1266   IEU0ClassRUsage,
1267   IEU1ClassRUsage,
1268   FPMClassRUsage,
1269   FPAClassRUsage,
1270   CTIClassRUsage,
1271   LDClassRUsage,
1272   STClassRUsage,
1273   SingleClassRUsage
1274 };
1275
1276
1277 //---------------------------------------------------------------------------
1278 // const InstrIssueDelta  SparcInstrIssueDeltas[]
1279 // 
1280 // Purpose:
1281 //   Changes to issue restrictions information in InstrClassRUsage for
1282 //   instructions that differ from other instructions in their class.
1283 //---------------------------------------------------------------------------
1284
1285 const InstrIssueDelta  SparcInstrIssueDeltas[] = {
1286
1287   // opCode,  isSingleIssue,  breaksGroup,  numBubbles
1288
1289                                 // Special cases for single-issue only
1290                                 // Other single issue cases are below.
1291 //{ LDDA,       true,   true,   0 },
1292 //{ STDA,       true,   true,   0 },
1293 //{ LDDF,       true,   true,   0 },
1294 //{ LDDFA,      true,   true,   0 },
1295   { ADDC,       true,   true,   0 },
1296   { ADDCcc,     true,   true,   0 },
1297   { SUBC,       true,   true,   0 },
1298   { SUBCcc,     true,   true,   0 },
1299 //{ SAVE,       true,   true,   0 },
1300 //{ RESTORE,    true,   true,   0 },
1301 //{ LDSTUB,     true,   true,   0 },
1302 //{ SWAP,       true,   true,   0 },
1303 //{ SWAPA,      true,   true,   0 },
1304 //{ CAS,        true,   true,   0 },
1305 //{ CASA,       true,   true,   0 },
1306 //{ CASX,       true,   true,   0 },
1307 //{ CASXA,      true,   true,   0 },
1308 //{ LDFSR,      true,   true,   0 },
1309 //{ LDFSRA,     true,   true,   0 },
1310 //{ LDXFSR,     true,   true,   0 },
1311 //{ LDXFSRA,    true,   true,   0 },
1312 //{ STFSR,      true,   true,   0 },
1313 //{ STFSRA,     true,   true,   0 },
1314 //{ STXFSR,     true,   true,   0 },
1315 //{ STXFSRA,    true,   true,   0 },
1316 //{ SAVED,      true,   true,   0 },
1317 //{ RESTORED,   true,   true,   0 },
1318 //{ FLUSH,      true,   true,   9 },
1319 //{ FLUSHW,     true,   true,   9 },
1320 //{ ALIGNADDR,  true,   true,   0 },
1321   { RETURN,     true,   true,   0 },
1322 //{ DONE,       true,   true,   0 },
1323 //{ RETRY,      true,   true,   0 },
1324 //{ WR,         true,   true,   0 },
1325 //{ WRPR,       true,   true,   4 },
1326 //{ RD,         true,   true,   0 },
1327 //{ RDPR,       true,   true,   0 },
1328 //{ TCC,        true,   true,   0 },
1329 //{ SHUTDOWN,   true,   true,   0 },
1330   
1331                                 // Special cases for breaking group *before*
1332                                 // CURRENTLY NOT SUPPORTED!
1333   { CALL,       false,  false,  0 },
1334   { JMPL,       false,  false,  0 },
1335   
1336                                 // Special cases for breaking the group *after*
1337   { MULX,       true,   true,   (4+34)/2 },
1338   { FDIVS,      false,  true,   0 },
1339   { FDIVD,      false,  true,   0 },
1340   { FDIVQ,      false,  true,   0 },
1341   { FSQRTS,     false,  true,   0 },
1342   { FSQRTD,     false,  true,   0 },
1343   { FSQRTQ,     false,  true,   0 },
1344 //{ FCMP{LE,GT,NE,EQ}, false, true, 0 },
1345   
1346                                 // Instructions that introduce bubbles
1347 //{ MULScc,     true,   true,   2 },
1348 //{ SMULcc,     true,   true,   (4+18)/2 },
1349 //{ UMULcc,     true,   true,   (4+19)/2 },
1350   { SDIVX,      true,   true,   68 },
1351   { UDIVX,      true,   true,   68 },
1352 //{ SDIVcc,     true,   true,   36 },
1353 //{ UDIVcc,     true,   true,   37 },
1354 //{ WR,         false,  false,  4 },
1355 //{ WRPR,       false,  false,  4 },
1356 };
1357
1358
1359 //---------------------------------------------------------------------------
1360 // const InstrRUsageDelta SparcInstrUsageDeltas[]
1361 // 
1362 // Purpose:
1363 //   Changes to resource usage information in InstrClassRUsage for
1364 //   instructions that differ from other instructions in their class.
1365 //---------------------------------------------------------------------------
1366
1367 const InstrRUsageDelta SparcInstrUsageDeltas[] = {
1368
1369   // MachineOpCode, Resource, Start cycle, Num cycles
1370
1371   // 
1372   // JMPL counts as a load/store instruction for issue!
1373   //
1374   { JMPL,     LSIssueSlots.rid,  0,  1 },
1375   
1376   // 
1377   // Many instructions cannot issue for the next 2 cycles after an FCMP
1378   // We model that with a fake resource FCMPDelayCycle.
1379   // 
1380   { FCMPS,    FCMPDelayCycle.rid, 1, 3 },
1381   { FCMPD,    FCMPDelayCycle.rid, 1, 3 },
1382   { FCMPQ,    FCMPDelayCycle.rid, 1, 3 },
1383   
1384   { MULX,     FCMPDelayCycle.rid, 1, 1 },
1385   { SDIVX,    FCMPDelayCycle.rid, 1, 1 },
1386   { UDIVX,    FCMPDelayCycle.rid, 1, 1 },
1387 //{ SMULcc,   FCMPDelayCycle.rid, 1, 1 },
1388 //{ UMULcc,   FCMPDelayCycle.rid, 1, 1 },
1389 //{ SDIVcc,   FCMPDelayCycle.rid, 1, 1 },
1390 //{ UDIVcc,   FCMPDelayCycle.rid, 1, 1 },
1391   { STD,      FCMPDelayCycle.rid, 1, 1 },
1392   { FMOVRSZ,  FCMPDelayCycle.rid, 1, 1 },
1393   { FMOVRSLEZ,FCMPDelayCycle.rid, 1, 1 },
1394   { FMOVRSLZ, FCMPDelayCycle.rid, 1, 1 },
1395   { FMOVRSNZ, FCMPDelayCycle.rid, 1, 1 },
1396   { FMOVRSGZ, FCMPDelayCycle.rid, 1, 1 },
1397   { FMOVRSGEZ,FCMPDelayCycle.rid, 1, 1 },
1398   
1399   // 
1400   // Some instructions are stalled in the GROUP stage if a CTI is in
1401   // the E or C stage
1402   // 
1403   { LDD,      CTIDelayCycle.rid,  1, 1 },
1404 //{ LDDA,     CTIDelayCycle.rid,  1, 1 },
1405 //{ LDDSTUB,  CTIDelayCycle.rid,  1, 1 },
1406 //{ LDDSTUBA, CTIDelayCycle.rid,  1, 1 },
1407 //{ SWAP,     CTIDelayCycle.rid,  1, 1 },
1408 //{ SWAPA,    CTIDelayCycle.rid,  1, 1 },
1409 //{ CAS,      CTIDelayCycle.rid,  1, 1 },
1410 //{ CASA,     CTIDelayCycle.rid,  1, 1 },
1411 //{ CASX,     CTIDelayCycle.rid,  1, 1 },
1412 //{ CASXA,    CTIDelayCycle.rid,  1, 1 },
1413   
1414   //
1415   // Signed int loads of less than dword size return data in cycle N1 (not C)
1416   // and put all loads in consecutive cycles into delayed load return mode.
1417   //
1418   { LDSB,    LdReturn.rid,  2, -1 },
1419   { LDSB,    LdReturn.rid,  3,  1 },
1420   
1421   { LDSH,    LdReturn.rid,  2, -1 },
1422   { LDSH,    LdReturn.rid,  3,  1 },
1423   
1424   { LDSW,    LdReturn.rid,  2, -1 },
1425   { LDSW,    LdReturn.rid,  3,  1 },
1426
1427
1428 #undef EXPLICIT_BUBBLES_NEEDED
1429 #ifdef EXPLICIT_BUBBLES_NEEDED
1430   // 
1431   // MULScc inserts one bubble.
1432   // This means it breaks the current group (captured in UltraSparcSchedInfo)
1433   // *and occupies all issue slots for the next cycle
1434   // 
1435 //{ MULScc,  AllIssueSlots.rid, 2, 2-1 },
1436 //{ MULScc,  AllIssueSlots.rid, 2, 2-1 },
1437 //{ MULScc,  AllIssueSlots.rid, 2, 2-1 },
1438 //{ MULScc,  AllIssueSlots.rid,  2, 2-1 },
1439   
1440   // 
1441   // SMULcc inserts between 4 and 18 bubbles, depending on #leading 0s in rs1.
1442   // We just model this with a simple average.
1443   // 
1444 //{ SMULcc,  AllIssueSlots.rid, 2, ((4+18)/2)-1 },
1445 //{ SMULcc,  AllIssueSlots.rid, 2, ((4+18)/2)-1 },
1446 //{ SMULcc,  AllIssueSlots.rid, 2, ((4+18)/2)-1 },
1447 //{ SMULcc,  AllIssueSlots.rid,  2, ((4+18)/2)-1 },
1448   
1449   // SMULcc inserts between 4 and 19 bubbles, depending on #leading 0s in rs1.
1450 //{ UMULcc,  AllIssueSlots.rid, 2, ((4+19)/2)-1 },
1451 //{ UMULcc,  AllIssueSlots.rid, 2, ((4+19)/2)-1 },
1452 //{ UMULcc,  AllIssueSlots.rid, 2, ((4+19)/2)-1 },
1453 //{ UMULcc,  AllIssueSlots.rid,  2, ((4+19)/2)-1 },
1454   
1455   // 
1456   // MULX inserts between 4 and 34 bubbles, depending on #leading 0s in rs1.
1457   // 
1458   { MULX,    AllIssueSlots.rid, 2, ((4+34)/2)-1 },
1459   { MULX,    AllIssueSlots.rid, 2, ((4+34)/2)-1 },
1460   { MULX,    AllIssueSlots.rid, 2, ((4+34)/2)-1 },
1461   { MULX,    AllIssueSlots.rid,  2, ((4+34)/2)-1 },
1462   
1463   // 
1464   // SDIVcc inserts 36 bubbles.
1465   // 
1466 //{ SDIVcc,  AllIssueSlots.rid, 2, 36-1 },
1467 //{ SDIVcc,  AllIssueSlots.rid, 2, 36-1 },
1468 //{ SDIVcc,  AllIssueSlots.rid, 2, 36-1 },
1469 //{ SDIVcc,  AllIssueSlots.rid,  2, 36-1 },
1470   
1471   // UDIVcc inserts 37 bubbles.
1472 //{ UDIVcc,  AllIssueSlots.rid, 2, 37-1 },
1473 //{ UDIVcc,  AllIssueSlots.rid, 2, 37-1 },
1474 //{ UDIVcc,  AllIssueSlots.rid, 2, 37-1 },
1475 //{ UDIVcc,  AllIssueSlots.rid,  2, 37-1 },
1476   
1477   // 
1478   // SDIVX inserts 68 bubbles.
1479   // 
1480   { SDIVX,   AllIssueSlots.rid, 2, 68-1 },
1481   { SDIVX,   AllIssueSlots.rid, 2, 68-1 },
1482   { SDIVX,   AllIssueSlots.rid, 2, 68-1 },
1483   { SDIVX,   AllIssueSlots.rid,  2, 68-1 },
1484   
1485   // 
1486   // UDIVX inserts 68 bubbles.
1487   // 
1488   { UDIVX,   AllIssueSlots.rid, 2, 68-1 },
1489   { UDIVX,   AllIssueSlots.rid, 2, 68-1 },
1490   { UDIVX,   AllIssueSlots.rid, 2, 68-1 },
1491   { UDIVX,   AllIssueSlots.rid,  2, 68-1 },
1492   
1493   // 
1494   // WR inserts 4 bubbles.
1495   // 
1496 //{ WR,     AllIssueSlots.rid, 2, 68-1 },
1497 //{ WR,     AllIssueSlots.rid, 2, 68-1 },
1498 //{ WR,     AllIssueSlots.rid, 2, 68-1 },
1499 //{ WR,     AllIssueSlots.rid,  2, 68-1 },
1500   
1501   // 
1502   // WRPR inserts 4 bubbles.
1503   // 
1504 //{ WRPR,   AllIssueSlots.rid, 2, 68-1 },
1505 //{ WRPR,   AllIssueSlots.rid, 2, 68-1 },
1506 //{ WRPR,   AllIssueSlots.rid, 2, 68-1 },
1507 //{ WRPR,   AllIssueSlots.rid,  2, 68-1 },
1508   
1509   // 
1510   // DONE inserts 9 bubbles.
1511   // 
1512 //{ DONE,   AllIssueSlots.rid, 2, 9-1 },
1513 //{ DONE,   AllIssueSlots.rid, 2, 9-1 },
1514 //{ DONE,   AllIssueSlots.rid, 2, 9-1 },
1515 //{ DONE,   AllIssueSlots.rid, 2, 9-1 },
1516   
1517   // 
1518   // RETRY inserts 9 bubbles.
1519   // 
1520 //{ RETRY,   AllIssueSlots.rid, 2, 9-1 },
1521 //{ RETRY,   AllIssueSlots.rid, 2, 9-1 },
1522 //{ RETRY,   AllIssueSlots.rid, 2, 9-1 },
1523 //{ RETRY,   AllIssueSlots.rid,  2, 9-1 },
1524
1525 #endif EXPLICIT_BUBBLES_NEEDED
1526 };
1527
1528
1529
1530 // Additional delays to be captured in code:
1531 // 1. RDPR from several state registers (page 349)
1532 // 2. RD   from *any* register (page 349)
1533 // 3. Writes to TICK, PSTATE, TL registers and FLUSH{W} instr (page 349)
1534 // 4. Integer store can be in same group as instr producing value to store.
1535 // 5. BICC and BPICC can be in the same group as instr producing CC (pg 350)
1536 // 6. FMOVr cannot be in the same or next group as an IEU instr (pg 351).
1537 // 7. The second instr. of a CTI group inserts 9 bubbles (pg 351)
1538 // 8. WR{PR}, SVAE, SAVED, RESTORE, RESTORED, RETURN, RETRY, and DONE that
1539 //    follow an annulling branch cannot be issued in the same group or in
1540 //    the 3 groups following the branch.
1541 // 9. A predicted annulled load does not stall dependent instructions.
1542 //    Other annulled delay slot instructions *do* stall dependents, so
1543 //    nothing special needs to be done for them during scheduling.
1544 //10. Do not put a load use that may be annulled in the same group as the
1545 //    branch.  The group will stall until the load returns.
1546 //11. Single-prec. FP loads lock 2 registers, for dependency checking.
1547 //
1548 // 
1549 // Additional delays we cannot or will not capture:
1550 // 1. If DCTI is last word of cache line, it is delayed until next line can be
1551 //    fetched.  Also, other DCTI alignment-related delays (pg 352)
1552 // 2. Load-after-store is delayed by 7 extra cycles if load hits in D-Cache.
1553 //    Also, several other store-load and load-store conflicts (pg 358)
1554 // 3. MEMBAR, LD{X}FSR, LDD{A} and a bunch of other load stalls (pg 358)
1555 // 4. There can be at most 8 outstanding buffered store instructions
1556 //     (including some others like MEMBAR, LDSTUB, CAS{AX}, and FLUSH)
1557
1558
1559
1560 //---------------------------------------------------------------------------
1561 // class UltraSparcSchedInfo
1562 // 
1563 // Purpose:
1564 //   Interface to instruction scheduling information for UltraSPARC.
1565 //   The parameter values above are based on UltraSPARC IIi.
1566 //---------------------------------------------------------------------------
1567
1568
1569 class UltraSparcSchedInfo: public MachineSchedInfo {
1570 public:
1571   /*ctor*/         UltraSparcSchedInfo  (const MachineInstrInfo* mii);
1572   /*dtor*/ virtual ~UltraSparcSchedInfo () {}
1573 protected:
1574   virtual void  initializeResources     ();
1575 };
1576
1577
1578 /***************************************************************************/
1579
1580 #endif