The 'rd' register is consistently mentioned last in instruction definitions.
[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 class F3_rd : F3 {
18   bits<5> rd;
19   set Inst{29-25} = rd;
20 }
21
22 class F3_rdsimm13 : F3_rd {
23   bits<13> simm13;
24   set Inst{12-0} = simm13;
25 }
26
27 class F3_rdsimm13rs1 : F3_rdsimm13 {
28   bits<5> rs1;
29   set Inst{18-14} = rs1;
30 }
31
32 // F3_rdrs1 - Common superclass of instructions that use rd & rs1
33 class F3_rdrs1 : F3_rd {
34   bits<5> rs1;
35   set Inst{18-14} = rs1;
36 }
37
38 // F3_rs1rdrs2 - Common superclass of instructions with rd, rs1, & rs2 fields
39 class F3_rdrs1rs2 : F3_rdrs1 {
40   bits<5> rs2;
41   set Inst{4-0} = rs2;
42 }
43
44 // F3_rs1 - Common class of instructions that do not have an rd field,
45 // but start at rs1
46 class F3_rs1 : F3 {
47   bits<5> rs1;
48   //set Inst{29-25} = dontcare;
49   set Inst{18-14} = rs1;
50 }
51
52 // F3_rs1rs2 - Common class of instructions that only have rs1 and rs2 fields
53 class F3_rs1rs2 : F3_rs1 {
54   bits<5> rs2;
55   //set Inst{12-5} = dontcare;
56   set Inst{4-0} = rs2;
57 }
58
59 // F3_rs1rs2 - Common class of instructions that only have rs1 and rs2 fields
60 class F3_rs1rs2rd : F3_rs1rs2 {
61   bits<5> rd;
62   set Inst{29-25} = rd;
63   set Inst{4-0} = rs2;
64 }
65
66 // F3_rs1simm13 - Common class of instructions that only have rs1 and simm13
67 class F3_rs1simm13 : F3_rs1 {
68   bits<13> simm13;
69   set Inst{12-0} = simm13;
70 }
71
72 class F3_rs1simm13rd : F3_rs1simm13 {
73   bits<5> rd;
74   set Inst{29-25} = rd;
75 }
76
77 // F3_rs2 - Common class of instructions that don't use an rs1
78 class F3_rs2 : F3 {
79   bits<5> rs2;
80   set Inst{4-0} = rs2;
81 }
82
83 // F3_rs2rd - Common class of instructions use rs2 and rd, but not rs1
84 class F3_rs2rd : F3_rs2 {
85   bits<5> rd;
86   set Inst{29-25} = rd;
87 }
88
89
90 // Specific F3 classes...
91 //
92
93 class F3_1<bits<2> opVal, bits<6> op3val, string name> : F3_rs1rs2rd {
94   set op  = opVal;
95   set op3 = op3val;
96   set Name = name;
97   set Inst{13} = 0;   // i field = 0
98   //set Inst{12-5} = dontcare;
99 }
100
101 class F3_2<bits<2> opVal, bits<6> op3val, string name> : F3_rs1simm13rd {
102   set op  = opVal;
103   set op3 = op3val;
104   set Name = name;
105   set Inst{13} = 1;   // i field = 1
106 }
107
108 #if 0
109 // The ordering is actually incorrect in these: in the assemble syntax,
110 // rd appears last!
111 class F3_1a<bits<2> opVal, bits<6> op3val, string name> : F3_rdrs1rs2 {
112   set op  = opVal;
113   set op3 = op3val;
114   set Name = name;
115   set Inst{13} = 0;   // i field = 0
116   //set Inst{12-5} = dontcare;
117 }
118
119 class F3_2a<bits<2> opVal, bits<6> op3val, string name> : F3_rdsimm13rs1 {
120   set op  = opVal;
121   set op3 = op3val;
122   set Name = name;
123   set Inst{13} = 1;   // i field = 1
124 }
125 #endif
126
127
128 class F3_3<bits<2> opVal, bits<6> op3val, string name> : F3_rs1rs2 {
129   set op   = opVal;
130   set op3  = op3val;
131   set Name = name;
132   set Inst{13}  = 0;
133 }
134
135 class F3_4<bits<2> opVal, bits<6> op3Val, string name> : F3_rs1simm13 {
136   bits<13> simm;
137   set op   = opVal;
138   set op3  = op3Val;
139   set Name = name;
140   //set Inst{29-25} = dontcare;
141   set Inst{13}  = 1;
142   set Inst{12-0} = simm;
143 }
144
145 class F3_11<bits<2> opVal, bits<6> op3Val, string name> : F3_rdrs1rs2 {
146   bit x;
147   set op = opVal;
148   set op3 = op3Val;
149   set Name = name;
150   set Inst{13} = 0; // i field = 0
151   set Inst{12} = x;
152   //set Inst{11-5} = dontcare;
153 }
154
155 class F3_12<bits<2> opVal, bits<6> op3Val, string name> : F3_rd {
156   bits<5> shcnt;
157   bits<5> rs1;
158
159   set op  = opVal;
160   set op3 = op3Val;
161   set Name = name;
162   set Inst{18-14} = rs1;
163   set Inst{13} = 1; // i field = 1
164   set Inst{12} = 0; // x field = 0
165   //set Inst{11-5} = dontcare;
166   set Inst{4-0} = shcnt;
167 }
168
169 class F3_13<bits<2> opVal, bits<6> op3Val, string name> : F3_rs1 {
170   bits<6> shcnt;
171   bits<5> rd;
172
173   set op  = opVal;
174   set op3 = op3Val;
175   set Name = name;
176   set Inst{29-25} = rd;
177   set Inst{13} = 1; // i field = 1
178   set Inst{12} = 1; // x field = 1
179   //set Inst{11-6} = dontcare;
180   set Inst{5-0} = shcnt;
181 }
182
183 class F3_14<bits<2> opVal, bits<6> op3Val,
184             bits<9> opfval, string name> : F3_rs2rd {
185   set op  = opVal;
186   set op3 = op3Val;
187   set Name = name;
188   //set Inst{18-14} = dontcare;
189   set Inst{13-5} = opfval;
190 }
191   
192 class F3_16<bits<2> opVal,  bits<6> op3Val,
193             bits<9> opfval, string name> : F3_rdrs1rs2 {
194   set op  = opVal;
195   set op3 = op3Val;
196   set Name = name;
197   set Inst{13-5} = opfval;
198 }
199
200 class F3_17<bits<2> opVal, bits<6> op3Val, string name> : F3_rdrs1 {
201   set op = opVal;
202   set op3 = op3Val;
203   set Name = name;
204   //Inst{13-0} = dontcare;
205 }
206
207 class F3_18<bits<5> fcn, string name> : F3 {
208   set op = 2;
209   set op3 = 0b111110;
210   set Name = name;
211   set Inst{29-25} = fcn;
212   //set Inst{18-0 } = dontcare;
213 }
214
215 class F3_19<bits<2> opVal, bits<6> op3Val, string name> : F3_rd {
216   set op = opVal;
217   set op3 = op3Val;
218   set Name = name;
219   //Inst{18-0} = dontcare;
220 }
221
222 // FIXME: class F3_20
223 // FIXME: class F3_21