Added instruction format class 3.15 and floating-point compare instructions.
[oota-llvm.git] / lib / Target / SparcV9 / SparcV9_F3.td
1 //===- Sparc.td - Target Description for Sparc V9 Target --------*- C++ -*-===//
2 // vim:ft=cpp
3 //===----------------------------------------------------------------------===//
4
5 //===----------------------------------------------------------------------===//
6 // Format #3 classes
7 //
8
9 // F3 - Common superclass of all F3 instructions.  All instructions have an op3
10 // field.
11 class F3 : InstV9 {
12   bits<6> op3;
13   set op{1} = 1;   // Op = 2 or 3
14   set Inst{24-19} = op3;
15 }
16
17 // F3_rs1 - Common class of instructions that have an rs1 field
18 class F3_rs1 : F3 {
19   bits<5> rs1;
20   set Inst{18-14} = rs1;
21 }
22
23 // F3_rs1rs2 - Common class of instructions that only have rs1 and rs2 fields
24 class F3_rs1rs2 : F3_rs1 {
25   bits<5> rs2;
26   set Inst{4-0} = rs2;
27 }
28
29 // F3_rs1rs2 - Common class of instructions that only have rs1 and rs2 fields
30 class F3_rs1rs2rd : F3_rs1rs2 {
31   bits<5> rd;
32   set Inst{29-25} = rd;
33   set Inst{4-0} = rs2;
34 }
35
36 // F3_rs1simm13 - Common class of instructions that only have rs1 and simm13
37 class F3_rs1simm13 : F3_rs1 {
38   bits<13> simm13;
39   set Inst{12-0} = simm13;
40 }
41
42 class F3_rs1simm13rd : F3_rs1simm13 {
43   bits<5> rd;
44   set Inst{29-25} = rd;
45 }
46
47 // F3_rs1rd - Common class of instructions that have an rs1 and rd fields
48 class F3_rs1rd : F3_rs1 {
49   bits<5> rd;
50   set Inst{29-25} = rd;
51 }
52
53 // F3_rs2 - Common class of instructions that don't use an rs1
54 class F3_rs2 : F3 {
55   bits<5> rs2;
56   set Inst{4-0} = rs2;
57 }
58
59 // F3_rs2rd - Common class of instructions use rs2 and rd, but not rs1
60 class F3_rs2rd : F3_rs2 {
61   bits<5> rd;
62   set Inst{29-25} = rd;
63 }
64
65 // F3_rd - Common class of instructions that have an rd field
66 class F3_rd : F3 {
67   bits<5> rd;
68   set Inst{29-25} = rd;
69 }
70
71 // F3_rdrs1 - Common class of instructions that have rd and rs1 fields
72 class F3_rdrs1 : F3_rd {
73   bits<5> rs1;
74   set Inst{18-14} = rs1;
75 }
76
77 // F3_rdrs1simm13 - Common class of instructions that have rd, rs1, and simm13
78 class F3_rdrs1simm13 : F3_rd {
79   bits<13> simm13;
80   set Inst{12-0} = simm13;
81 }
82
83
84 // F3_rdrs1rs2 - Common class of instructions that have rd, rs1, and rs2 fields
85 class F3_rdrs1rs2 : F3_rs1 {
86   bits<5> rs2;
87   set Inst{4-0} = rs2;
88 }
89
90
91 // Specific F3 classes...
92 //
93
94 class F3_1<bits<2> opVal, bits<6> op3val, string name> : F3_rs1rs2rd {
95   set op  = opVal;
96   set op3 = op3val;
97   set Name = name;
98   set Inst{13} = 0;   // i field = 0
99   //set Inst{12-5} = dontcare;
100 }
101
102 // The store instructions seem to like to see rd first, then rs1 and rs2
103 class F3_1rd<bits<2> opVal, bits<6> op3val, string name> : F3_rdrs1rs2 {
104   set op  = opVal;
105   set op3 = op3val;
106   set Name = name;
107   set Inst{13} = 0;   // i field = 0
108   //set Inst{12-5} = dontcare;
109 }
110
111 class F3_2<bits<2> opVal, bits<6> op3val, string name> : F3_rs1simm13rd {
112   set op  = opVal;
113   set op3 = op3val;
114   set Name = name;
115   set Inst{13} = 1;   // i field = 1
116 }
117
118 // The store instructions seem to like to see rd first, then rs1 and imm
119 class F3_2rd<bits<2> opVal, bits<6> op3val, string name> : F3_rdrs1simm13 {
120   set op  = opVal;
121   set op3 = op3val;
122   set Name = name;
123   set Inst{13} = 1;   // i field = 1
124 }
125
126 class F3_3<bits<2> opVal, bits<6> op3val, string name> : F3_rs1rs2 {
127   set op   = opVal;
128   set op3  = op3val;
129   set Name = name;
130   set Inst{13}  = 0;
131 }
132
133 class F3_4<bits<2> opVal, bits<6> op3Val, string name> : F3_rs1simm13 {
134   bits<13> simm;
135   set op   = opVal;
136   set op3  = op3Val;
137   set Name = name;
138   //set Inst{29-25} = dontcare;
139   set Inst{13}  = 1;
140   set Inst{12-0} = simm;
141 }
142
143 class F3_5<bits<2> opVal, bits<6> op3Val, bits<3> rcondVal,
144            string name> : F3_rs1rs2rd {
145   set op  = opVal;
146   set op3 = op3Val;
147   set Name = name;
148   set Inst{13} = 0;           // i field = 0
149   set Inst{12-10} = rcondVal; // rcond field
150 }
151
152 class F3_6<bits<2> opVal, bits<6> op3Val, bits<3> rcondVal,
153            string name> : F3_rs1 {
154   bits<10> simm10;
155   bits<5>  rd;
156
157   set op  = opVal;
158   set op3 = op3Val;
159   set Name = name;
160   set Inst{13} = 1;           // i field = 1
161   set Inst{12-10} = rcondVal; // rcond field
162 }
163
164 //FIXME: classes 7-10 not defined!!
165
166 class F3_11<bits<2> opVal, bits<6> op3Val, string name> : F3_rs1rs2rd {
167   bit x;
168   set op = opVal;
169   set op3 = op3Val;
170   set Name = name;
171   set Inst{13} = 0; // i field = 0
172   set Inst{12} = x;
173   //set Inst{11-5} = dontcare;
174 }
175
176 class F3_12<bits<2> opVal, bits<6> op3Val, string name> : F3_rs1 {
177   bits<5> shcnt;
178   bits<5> rd;
179
180   set op  = opVal;
181   set op3 = op3Val;
182   set Name = name;
183   set Inst{29-25} = rd;
184   set Inst{13} = 1; // i field = 1
185   set Inst{12} = 0; // x field = 0
186   //set Inst{11-5} = dontcare;
187   set Inst{4-0} = shcnt;
188 }
189
190 class F3_13<bits<2> opVal, bits<6> op3Val, string name> : F3_rs1 {
191   bits<6> shcnt;
192   bits<5> rd;
193
194   set op  = opVal;
195   set op3 = op3Val;
196   set Name = name;
197   set Inst{29-25} = rd;
198   set Inst{13} = 1; // i field = 1
199   set Inst{12} = 1; // x field = 1
200   //set Inst{11-6} = dontcare;
201   set Inst{5-0} = shcnt;
202 }
203
204 class F3_14<bits<2> opVal, bits<6> op3Val,
205             bits<9> opfVal, string name> : F3_rs2rd {
206   set op  = opVal;
207   set op3 = op3Val;
208   set Name = name;
209   //set Inst{18-14} = dontcare;
210   set Inst{13-5} = opfVal;
211 }
212
213 class F3_15<bits<2> opVal, bits<6> op3Val,
214             bits<9> opfVal, string name> : F3 {
215   bits<2> cc;
216   bits<5> rs1;
217   bits<5> rs2;
218
219   set op  = opVal;
220   set op3 = op3Val;
221   set Inst{26-25} = cc;
222   set Inst{18-14} = rs1;
223   set Inst{13-5}  = opfVal;
224   set Inst{4-0}   = rs2;
225 }
226   
227 class F3_16<bits<2> opVal,  bits<6> op3Val,
228             bits<9> opfval, string name> : F3_rs1rs2rd {
229   set op  = opVal;
230   set op3 = op3Val;
231   set Name = name;
232   set Inst{13-5} = opfval;
233 }
234
235 class F3_17<bits<2> opVal, bits<6> op3Val, string name> : F3_rs1rd {
236   set op = opVal;
237   set op3 = op3Val;
238   set Name = name;
239   //Inst{13-0} = dontcare;
240 }
241
242 class F3_18<bits<5> fcn, string name> : F3 {
243   set op = 2;
244   set op3 = 0b111110;
245   set Name = name;
246   set Inst{29-25} = fcn;
247   //set Inst{18-0 } = dontcare;
248 }
249
250 class F3_19<bits<2> opVal, bits<6> op3Val, string name> : F3_rd {
251   set op = opVal;
252   set op3 = op3Val;
253   set Name = name;
254   //Inst{18-0} = dontcare;
255 }
256
257 // FIXME: class F3_20
258 // FIXME: class F3_21