Remove use of OpSize for populating VEX_PP field. A prefix encoding is now used inste...
[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, dag outs, dag ins, string asmstr,
55            list<dag> pattern> : F2<outs, ins, asmstr, pattern> {
56   bits<4>   cond;
57   bit       annul = 0;     // currently unused
58
59   let op2         = op2Val;
60
61   let Inst{29}    = annul;
62   let Inst{28-25} = cond;
63 }
64
65 class F2_3<bits<3> op2Val, bits<2> ccVal, dag outs, dag ins, string asmstr,
66            list<dag> pattern>
67    : InstSP<outs, ins, asmstr, pattern> {
68   bit      annul;
69   bits<4>  cond;
70   bit      pred;
71   bits<19> imm19;
72
73   let op          = 0;    // op = 0
74
75   bit annul       = 0;    // currently unused
76   let pred        = 1;    // default is predict taken
77
78   let Inst{29}    = annul;
79   let Inst{28-25} = cond;
80   let Inst{24-22} = op2Val;
81   let Inst{21-20} = ccVal;
82   let Inst{19}    = pred;
83   let Inst{18-0}  = imm19;
84 }
85
86 //===----------------------------------------------------------------------===//
87 // Format #3 instruction classes in the Sparc
88 //===----------------------------------------------------------------------===//
89
90 class F3<dag outs, dag ins, string asmstr, list<dag> pattern>
91     : InstSP<outs, ins, asmstr, pattern> {
92   bits<5> rd;
93   bits<6> op3;
94   bits<5> rs1;
95   let op{1} = 1;   // Op = 2 or 3
96   let Inst{29-25} = rd;
97   let Inst{24-19} = op3;
98   let Inst{18-14} = rs1;
99 }
100
101 // Specific F3 classes: SparcV8 manual, page 44
102 //
103 class F3_1<bits<2> opVal, bits<6> op3val, dag outs, dag ins,
104            string asmstr, list<dag> pattern> : F3<outs, ins, asmstr, pattern> {
105   bits<8> asi = 0; // asi not currently used
106   bits<5> rs2;
107
108   let op         = opVal;
109   let op3        = op3val;
110
111   let Inst{13}   = 0;     // i field = 0
112   let Inst{12-5} = asi;   // address space identifier
113   let Inst{4-0}  = rs2;
114 }
115
116 class F3_2<bits<2> opVal, bits<6> op3val, dag outs, dag ins,
117            string asmstr, list<dag> pattern> : F3<outs, ins, asmstr, pattern> {
118   bits<13> simm13;
119
120   let op         = opVal;
121   let op3        = op3val;
122
123   let Inst{13}   = 1;     // i field = 1
124   let Inst{12-0} = simm13;
125 }
126
127 // floating-point
128 class F3_3<bits<2> opVal, bits<6> op3val, bits<9> opfval, dag outs, dag ins,
129            string asmstr, list<dag> pattern> : F3<outs, ins, asmstr, pattern> {
130   bits<5> rs2;
131
132   let op         = opVal;
133   let op3        = op3val;
134
135   let Inst{13-5} = opfval;   // fp opcode
136   let Inst{4-0}  = rs2;
137 }
138
139 // floating-point unary operations.
140 class F3_3u<bits<2> opVal, bits<6> op3val, bits<9> opfval, dag outs, dag ins,
141            string asmstr, list<dag> pattern> : F3<outs, ins, asmstr, pattern> {
142   bits<5> rs2;
143
144   let op         = opVal;
145   let op3        = op3val;
146   let rs1        = 0;
147
148   let Inst{13-5} = opfval;   // fp opcode
149   let Inst{4-0}  = rs2;
150 }
151
152 // floating-point compares.
153 class F3_3c<bits<2> opVal, bits<6> op3val, bits<9> opfval, dag outs, dag ins,
154            string asmstr, list<dag> pattern> : F3<outs, ins, asmstr, pattern> {
155   bits<5> rs2;
156
157   let op         = opVal;
158   let op3        = op3val;
159   let rd         = 0;
160
161   let Inst{13-5} = opfval;   // fp opcode
162   let Inst{4-0}  = rs2;
163 }
164
165 // Shift by register rs2.
166 class F3_Sr<bits<2> opVal, bits<6> op3val, bit xVal, dag outs, dag ins,
167             string asmstr, list<dag> pattern> : F3<outs, ins, asmstr, pattern> {
168   bit x = xVal;           // 1 for 64-bit shifts.
169   bits<5> rs2;
170
171   let op         = opVal;
172   let op3        = op3val;
173
174   let Inst{13}   = 0;     // i field = 0
175   let Inst{12}   = x;     // extended registers.
176   let Inst{4-0}  = rs2;
177 }
178
179 // Shift by immediate.
180 class F3_Si<bits<2> opVal, bits<6> op3val, bit xVal, dag outs, dag ins,
181             string asmstr, list<dag> pattern> : F3<outs, ins, asmstr, pattern> {
182   bit x = xVal;           // 1 for 64-bit shifts.
183   bits<6> shcnt;          // shcnt32 / shcnt64.
184
185   let op         = opVal;
186   let op3        = op3val;
187
188   let Inst{13}   = 1;     // i field = 1
189   let Inst{12}   = x;     // extended registers.
190   let Inst{5-0}  = shcnt;
191 }
192
193 // Define rr and ri shift instructions with patterns.
194 multiclass F3_S<string OpcStr, bits<6> Op3Val, bit XVal, SDNode OpNode,
195                 ValueType VT, RegisterClass RC> {
196   def rr : F3_Sr<2, Op3Val, XVal, (outs RC:$rd), (ins RC:$rs1, IntRegs:$rs2),
197                  !strconcat(OpcStr, " $rs1, $rs2, $rd"),
198                  [(set VT:$rd, (OpNode VT:$rs1, i32:$rs2))]>;
199   def ri : F3_Si<2, Op3Val, XVal, (outs RC:$rd), (ins RC:$rs1, i32imm:$shcnt),
200                  !strconcat(OpcStr, " $rs1, $shcnt, $rd"),
201                  [(set VT:$rd, (OpNode VT:$rs1, (i32 imm:$shcnt)))]>;
202 }
203
204 class F4<bits<6> op3, dag outs, dag ins, string asmstr, list<dag> pattern>
205       : InstSP<outs, ins, asmstr, pattern> {
206   bits<5> rd;
207
208   let op          = 2;
209   let Inst{29-25} = rd;
210   let Inst{24-19} = op3;
211 }
212
213
214 class F4_1<bits<6> op3, dag outs, dag ins,
215             string asmstr, list<dag> pattern>
216       : F4<op3, outs, ins, asmstr, pattern> {
217
218   bits<3> cc;
219   bits<4> cond;
220   bits<5> rs2;
221
222   let Inst{4-0}   = rs2;
223   let Inst{11}    = cc{0};
224   let Inst{12}    = cc{1};
225   let Inst{13}    = 0;
226   let Inst{17-14} = cond;
227   let Inst{18}    = cc{2};
228
229 }
230
231 class F4_2<bits<6> op3, dag outs, dag ins,
232             string asmstr, list<dag> pattern>
233       : F4<op3, outs, ins, asmstr, pattern> {
234   bits<3>  cc;
235   bits<4>  cond;
236   bits<11> simm11;
237
238   let Inst{10-0}  = simm11;
239   let Inst{11}    = cc{0};
240   let Inst{12}    = cc{1};
241   let Inst{13}    = 1;
242   let Inst{17-14} = cond;
243   let Inst{18}    = cc{2};
244 }
245
246 class F4_3<bits<6> op3, bits<6> opf_low, dag outs, dag ins,
247            string asmstr, list<dag> pattern>
248       : F4<op3, outs, ins, asmstr, pattern> {
249   bits<4> cond;
250   bits<3> opf_cc;
251   bits<5> rs2;
252
253   let Inst{18}     = 0;
254   let Inst{17-14}  = cond;
255   let Inst{13-11}  = opf_cc;
256   let Inst{10-5}   = opf_low;
257   let Inst{4-0}    = rs2;
258 }