Removed unnecessary assignment (it was taken care by a superclass) and clarified
[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 }
34
35 // F3_rs1simm13 - Common class of instructions that only have rs1 and simm13
36 class F3_rs1simm13 : F3_rs1 {
37   bits<13> simm13;
38   set Inst{12-0} = simm13;
39 }
40
41 class F3_rs1simm13rd : F3_rs1simm13 {
42   bits<5> rd;
43   set Inst{29-25} = rd;
44 }
45
46 // F3_rs1rd - Common class of instructions that have an rs1 and rd fields
47 class F3_rs1rd : F3_rs1 {
48   bits<5> rd;
49   set Inst{29-25} = rd;
50 }
51
52 // F3_rs2 - Common class of instructions that don't use an rs1
53 class F3_rs2 : F3 {
54   bits<5> rs2;
55   set Inst{4-0} = rs2;
56 }
57
58 // F3_rs2rd - Common class of instructions that use rs2 and rd, but not rs1
59 class F3_rs2rd : F3_rs2 {
60   bits<5> rd;
61   set Inst{29-25} = rd;
62 }
63
64 // F3_rd - Common class of instructions that have an rd field
65 class F3_rd : F3 {
66   bits<5> rd;
67   set Inst{29-25} = rd;
68 }
69
70 // F3_rdrs1 - Common class of instructions that have rd and rs1 fields
71 class F3_rdrs1 : F3_rd {
72   bits<5> rs1;
73   set Inst{18-14} = rs1;
74 }
75
76 // F3_rdrs1simm13 - Common class of instructions that have rd, rs1, and simm13
77 class F3_rdrs1simm13 : F3_rdrs1 {
78   bits<13> simm13;
79   set Inst{12-0} = simm13;
80 }
81
82 // F3_rdrs1rs2 - Common class of instructions that have rd, rs1, and rs2 fields
83 class F3_rdrs1rs2 : F3_rdrs1 {
84   bits<5> rs2;
85   set Inst{4-0} = rs2;
86 }
87
88
89 // Specific F3 classes...
90 //
91
92 class F3_1<bits<2> opVal, bits<6> op3val, string name> : F3_rs1rs2rd {
93   set op  = opVal;
94   set op3 = op3val;
95   set Name = name;
96   set Inst{13} = 0;   // i field = 0
97   set Inst{12-5} = 0; // don't care
98 }
99
100 // The store instructions seem to like to see rd first, then rs1 and rs2
101 class F3_1rd<bits<2> opVal, bits<6> op3val, string name> : F3_rdrs1rs2 {
102   set op  = opVal;
103   set op3 = op3val;
104   set Name = name;
105   set Inst{13} = 0;   // i field = 0
106   set Inst{12-5} = 0; // don't care
107 }
108
109 class F3_2<bits<2> opVal, bits<6> op3val, string name> : F3_rs1simm13rd {
110   set op  = opVal;
111   set op3 = op3val;
112   set Name = name;
113   set Inst{13} = 1;   // i field = 1
114 }
115
116 // The store instructions seem to like to see rd first, then rs1 and imm
117 class F3_2rd<bits<2> opVal, bits<6> op3val, string name> : F3_rdrs1simm13 {
118   set op  = opVal;
119   set op3 = op3val;
120   set Name = name;
121   set Inst{13} = 1;   // i field = 1
122 }
123
124 class F3_3<bits<2> opVal, bits<6> op3val, string name> : F3_rs1rs2 {
125   set op   = opVal;
126   set op3  = op3val;
127   set Name = name;
128   set Inst{29-25} = 0; // don't care
129   set Inst{13} = 0;    // i field = 0
130   set Inst{12-5} = 0;  // don't care
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} = 0; // don't care
139   set Inst{13} = 1;    // i field = 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   set Inst{9-5} = 0;          // don't care
151 }
152
153 class F3_6<bits<2> opVal, bits<6> op3Val, bits<3> rcondVal,
154            string name> : F3_rs1 {
155   bits<10> simm10;
156   bits<5>  rd;
157
158   set op  = opVal;
159   set op3 = op3Val;
160   set Name = name;
161   set Inst{29-25} = rd;
162   set Inst{13} = 1;           // i field = 1
163   set Inst{12-10} = rcondVal; // rcond field
164   set Inst{9-0} = simm10;
165 }
166
167 //FIXME: classes 7-10 not defined!!
168
169 class F3_11<bits<2> opVal, bits<6> op3Val, string name> : F3_rs1rs2rd {
170   bit x;
171   set op = opVal;
172   set op3 = op3Val;
173   set Name = name;
174   set Inst{13} = 0; // i field = 0
175   set Inst{12} = x;
176   set Inst{11-5} = 0; // don't care
177 }
178
179 class F3_12<bits<2> opVal, bits<6> op3Val, string name> : F3_rs1 {
180   bits<5> shcnt;
181   bits<5> rd;
182
183   set op  = opVal;
184   set op3 = op3Val;
185   set Name = name;
186   set Inst{29-25} = rd;
187   set Inst{13} = 1; // i field = 1
188   set Inst{12} = 0; // x field = 0
189   set Inst{11-5} = 0; // don't care
190   set Inst{4-0} = shcnt;
191 }
192
193 class F3_13<bits<2> opVal, bits<6> op3Val, string name> : F3_rs1 {
194   bits<6> shcnt;
195   bits<5> rd;
196
197   set op  = opVal;
198   set op3 = op3Val;
199   set Name = name;
200   set Inst{29-25} = rd;
201   set Inst{13} = 1; // i field = 1
202   set Inst{12} = 1; // x field = 1
203   set Inst{11-6} = 0; // don't care
204   set Inst{5-0} = shcnt;
205 }
206
207 class F3_14<bits<2> opVal, bits<6> op3Val,
208             bits<9> opfVal, string name> : F3_rs2rd {
209   set op  = opVal;
210   set op3 = op3Val;
211   set Name = name;
212   set Inst{18-14} = 0; // don't care
213   set Inst{13-5} = opfVal;
214 }
215
216 class F3_15<bits<2> opVal, bits<6> op3Val,
217             bits<9> opfVal, string name> : F3 {
218   bits<2> cc;
219   bits<5> rs1;
220   bits<5> rs2;
221
222   set op  = opVal;
223   set op3 = op3Val;
224   set Name = name;
225   set Inst{29-27} = 0; // defined to be zero
226   set Inst{26-25} = cc;
227   set Inst{18-14} = rs1;
228   set Inst{13-5}  = opfVal;
229   set Inst{4-0}   = rs2;
230 }
231   
232 class F3_16<bits<2> opVal,  bits<6> op3Val,
233             bits<9> opfval, string name> : F3_rs1rs2rd {
234   set op  = opVal;
235   set op3 = op3Val;
236   set Name = name;
237   set Inst{13-5} = opfval;
238 }
239
240 class F3_17<bits<2> opVal, bits<6> op3Val, string name> : F3_rs1rd {
241   set op = opVal;
242   set op3 = op3Val;
243   set Name = name;
244   set Inst{13-0} = 0; // don't care
245 }
246
247 class F3_18<bits<5> fcn, string name> : F3 {
248   set op = 2;
249   set op3 = 0b111110;
250   set Name = name;
251   set Inst{29-25} = fcn;
252   set Inst{18-0 } = 0; // don't care;
253 }
254
255 class F3_19<bits<2> opVal, bits<6> op3Val, string name> : F3_rd {
256   set op = opVal;
257   set op3 = op3Val;
258   set Name = name;
259   set Inst{18-0} = 0; // don't care
260 }
261
262 // FIXME: class F3_20
263 // FIXME: class F3_21