[Sparc] Add support for parsing fcmp with %fcc registers.
[oota-llvm.git] / lib / Target / Sparc / SparcInstrFormats.td
1 //===-- SparcInstrFormats.td - Sparc Instruction Formats ---*- tablegen -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 class InstSP<dag outs, dag ins, string asmstr, list<dag> pattern>
11           : Instruction {
12   field bits<32> Inst;
13
14   let Namespace = "SP";
15   let Size = 4;
16
17   bits<2> op;
18   let Inst{31-30} = op;               // Top two bits are the 'op' field
19
20   dag OutOperandList = outs;
21   dag InOperandList = ins;
22   let AsmString   = asmstr;
23   let Pattern = pattern;
24
25   let DecoderNamespace = "Sparc";
26   field bits<32> SoftFail = 0;
27 }
28
29 //===----------------------------------------------------------------------===//
30 // Format #2 instruction classes in the Sparc
31 //===----------------------------------------------------------------------===//
32
33 // Format 2 instructions
34 class F2<dag outs, dag ins, string asmstr, list<dag> pattern>
35    : InstSP<outs, ins, asmstr, pattern> {
36   bits<3>  op2;
37   bits<22> imm22;
38   let op          = 0;    // op = 0
39   let Inst{24-22} = op2;
40   let Inst{21-0}  = imm22;
41 }
42
43 // Specific F2 classes: SparcV8 manual, page 44
44 //
45 class F2_1<bits<3> op2Val, dag outs, dag ins, string asmstr, list<dag> pattern>
46    : F2<outs, ins, asmstr, pattern> {
47   bits<5>  rd;
48
49   let op2         = op2Val;
50
51   let Inst{29-25} = rd;
52 }
53
54 class F2_2<bits<3> op2Val, bit annul, dag outs, dag ins, string asmstr,
55            list<dag> pattern> : F2<outs, ins, asmstr, pattern> {
56   bits<4>   cond;
57   let op2         = op2Val;
58
59   let Inst{29}    = annul;
60   let Inst{28-25} = cond;
61 }
62
63 class F2_3<bits<3> op2Val, bit annul, bit pred,
64            dag outs, dag ins, string asmstr, list<dag> pattern>
65       : InstSP<outs, ins, asmstr, pattern> {
66   bits<2>  cc;
67   bits<4>  cond;
68   bits<19> imm19;
69
70   let op          = 0;    // op = 0
71
72   let Inst{29}    = annul;
73   let Inst{28-25} = cond;
74   let Inst{24-22} = op2Val;
75   let Inst{21-20} = cc;
76   let Inst{19}    = pred;
77   let Inst{18-0}  = imm19;
78 }
79
80 //===----------------------------------------------------------------------===//
81 // Format #3 instruction classes in the Sparc
82 //===----------------------------------------------------------------------===//
83
84 class F3<dag outs, dag ins, string asmstr, list<dag> pattern>
85     : InstSP<outs, ins, asmstr, pattern> {
86   bits<5> rd;
87   bits<6> op3;
88   bits<5> rs1;
89   let op{1} = 1;   // Op = 2 or 3
90   let Inst{29-25} = rd;
91   let Inst{24-19} = op3;
92   let Inst{18-14} = rs1;
93 }
94
95 // Specific F3 classes: SparcV8 manual, page 44
96 //
97 class F3_1_asi<bits<2> opVal, bits<6> op3val, bits<8> asi, dag outs, dag ins,
98            string asmstr, list<dag> pattern> : F3<outs, ins, asmstr, pattern> {
99   bits<5> rs2;
100
101   let op         = opVal;
102   let op3        = op3val;
103
104   let Inst{13}   = 0;     // i field = 0
105   let Inst{12-5} = asi;   // address space identifier
106   let Inst{4-0}  = rs2;
107 }
108
109 class F3_1<bits<2> opVal, bits<6> op3val, dag outs, dag ins, string asmstr,
110        list<dag> pattern> : F3_1_asi<opVal, op3val, 0, outs, ins,
111                                                      asmstr, pattern>;
112
113 class F3_2<bits<2> opVal, bits<6> op3val, dag outs, dag ins,
114            string asmstr, list<dag> pattern> : F3<outs, ins, asmstr, pattern> {
115   bits<13> simm13;
116
117   let op         = opVal;
118   let op3        = op3val;
119
120   let Inst{13}   = 1;     // i field = 1
121   let Inst{12-0} = simm13;
122 }
123
124 // floating-point
125 class F3_3<bits<2> opVal, bits<6> op3val, bits<9> opfval, dag outs, dag ins,
126            string asmstr, list<dag> pattern> : F3<outs, ins, asmstr, pattern> {
127   bits<5> rs2;
128
129   let op         = opVal;
130   let op3        = op3val;
131
132   let Inst{13-5} = opfval;   // fp opcode
133   let Inst{4-0}  = rs2;
134 }
135
136 // floating-point unary operations.
137 class F3_3u<bits<2> opVal, bits<6> op3val, bits<9> opfval, dag outs, dag ins,
138            string asmstr, list<dag> pattern> : F3<outs, ins, asmstr, pattern> {
139   bits<5> rs2;
140
141   let op         = opVal;
142   let op3        = op3val;
143   let rs1        = 0;
144
145   let Inst{13-5} = opfval;   // fp opcode
146   let Inst{4-0}  = rs2;
147 }
148
149 // floating-point compares.
150 class F3_3c<bits<2> opVal, bits<6> op3val, bits<9> opfval, dag outs, dag ins,
151            string asmstr, list<dag> pattern> : F3<outs, ins, asmstr, pattern> {
152   bits<5> rs2;
153
154   let op         = opVal;
155   let op3        = op3val;
156
157   let Inst{13-5} = opfval;   // fp opcode
158   let Inst{4-0}  = rs2;
159 }
160
161 // Shift by register rs2.
162 class F3_Sr<bits<2> opVal, bits<6> op3val, bit xVal, dag outs, dag ins,
163             string asmstr, list<dag> pattern> : F3<outs, ins, asmstr, pattern> {
164   bit x = xVal;           // 1 for 64-bit shifts.
165   bits<5> rs2;
166
167   let op         = opVal;
168   let op3        = op3val;
169
170   let Inst{13}   = 0;     // i field = 0
171   let Inst{12}   = x;     // extended registers.
172   let Inst{4-0}  = rs2;
173 }
174
175 // Shift by immediate.
176 class F3_Si<bits<2> opVal, bits<6> op3val, bit xVal, dag outs, dag ins,
177             string asmstr, list<dag> pattern> : F3<outs, ins, asmstr, pattern> {
178   bit x = xVal;           // 1 for 64-bit shifts.
179   bits<6> shcnt;          // shcnt32 / shcnt64.
180
181   let op         = opVal;
182   let op3        = op3val;
183
184   let Inst{13}   = 1;     // i field = 1
185   let Inst{12}   = x;     // extended registers.
186   let Inst{5-0}  = shcnt;
187 }
188
189 // Define rr and ri shift instructions with patterns.
190 multiclass F3_S<string OpcStr, bits<6> Op3Val, bit XVal, SDNode OpNode,
191                 ValueType VT, RegisterClass RC> {
192   def rr : F3_Sr<2, Op3Val, XVal, (outs RC:$rd), (ins RC:$rs1, IntRegs:$rs2),
193                  !strconcat(OpcStr, " $rs1, $rs2, $rd"),
194                  [(set VT:$rd, (OpNode VT:$rs1, i32:$rs2))]>;
195   def ri : F3_Si<2, Op3Val, XVal, (outs RC:$rd), (ins RC:$rs1, i32imm:$shcnt),
196                  !strconcat(OpcStr, " $rs1, $shcnt, $rd"),
197                  [(set VT:$rd, (OpNode VT:$rs1, (i32 imm:$shcnt)))]>;
198 }
199
200 class F4<bits<6> op3, dag outs, dag ins, string asmstr, list<dag> pattern>
201       : InstSP<outs, ins, asmstr, pattern> {
202   bits<5> rd;
203
204   let op          = 2;
205   let Inst{29-25} = rd;
206   let Inst{24-19} = op3;
207 }
208
209
210 class F4_1<bits<6> op3, dag outs, dag ins,
211             string asmstr, list<dag> pattern>
212       : F4<op3, outs, ins, asmstr, pattern> {
213
214   bits<3> cc;
215   bits<4> cond;
216   bits<5> rs2;
217
218   let Inst{4-0}   = rs2;
219   let Inst{11}    = cc{0};
220   let Inst{12}    = cc{1};
221   let Inst{13}    = 0;
222   let Inst{17-14} = cond;
223   let Inst{18}    = cc{2};
224
225 }
226
227 class F4_2<bits<6> op3, dag outs, dag ins,
228             string asmstr, list<dag> pattern>
229       : F4<op3, outs, ins, asmstr, pattern> {
230   bits<3>  cc;
231   bits<4>  cond;
232   bits<11> simm11;
233
234   let Inst{10-0}  = simm11;
235   let Inst{11}    = cc{0};
236   let Inst{12}    = cc{1};
237   let Inst{13}    = 1;
238   let Inst{17-14} = cond;
239   let Inst{18}    = cc{2};
240 }
241
242 class F4_3<bits<6> op3, bits<6> opf_low, dag outs, dag ins,
243            string asmstr, list<dag> pattern>
244       : F4<op3, outs, ins, asmstr, pattern> {
245   bits<4> cond;
246   bits<3> opf_cc;
247   bits<5> rs2;
248
249   let Inst{18}     = 0;
250   let Inst{17-14}  = cond;
251   let Inst{13-11}  = opf_cc;
252   let Inst{10-5}   = opf_low;
253   let Inst{4-0}    = rs2;
254 }