[Sparc] Clean up MOVcc instructions so that TableGen can encode them correctly. No...
[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
16   bits<2> op;
17   let Inst{31-30} = op;               // Top two bits are the 'op' field
18
19   dag OutOperandList = outs;
20   dag InOperandList = ins;
21   let AsmString   = asmstr;
22   let Pattern = pattern;
23 }
24
25 //===----------------------------------------------------------------------===//
26 // Format #2 instruction classes in the Sparc
27 //===----------------------------------------------------------------------===//
28
29 // Format 2 instructions
30 class F2<dag outs, dag ins, string asmstr, list<dag> pattern>
31    : InstSP<outs, ins, asmstr, pattern> {
32   bits<3>  op2;
33   bits<22> imm22;
34   let op          = 0;    // op = 0
35   let Inst{24-22} = op2;
36   let Inst{21-0}  = imm22;
37 }
38
39 // Specific F2 classes: SparcV8 manual, page 44
40 //
41 class F2_1<bits<3> op2Val, dag outs, dag ins, string asmstr, list<dag> pattern>
42    : F2<outs, ins, asmstr, pattern> {
43   bits<5>  rd;
44
45   let op2         = op2Val;
46
47   let Inst{29-25} = rd;
48 }
49
50 class F2_2<bits<3> op2Val, dag outs, dag ins, string asmstr,
51            list<dag> pattern> : F2<outs, ins, asmstr, pattern> {
52   bits<4>   cond;
53   bit       annul = 0;     // currently unused
54
55   let op2         = op2Val;
56
57   let Inst{29}    = annul;
58   let Inst{28-25} = cond;
59 }
60
61 //===----------------------------------------------------------------------===//
62 // Format #3 instruction classes in the Sparc
63 //===----------------------------------------------------------------------===//
64
65 class F3<dag outs, dag ins, string asmstr, list<dag> pattern>
66     : InstSP<outs, ins, asmstr, pattern> {
67   bits<5> rd;
68   bits<6> op3;
69   bits<5> rs1;
70   let op{1} = 1;   // Op = 2 or 3
71   let Inst{29-25} = rd;
72   let Inst{24-19} = op3;
73   let Inst{18-14} = rs1;
74 }
75
76 // Specific F3 classes: SparcV8 manual, page 44
77 //
78 class F3_1<bits<2> opVal, bits<6> op3val, dag outs, dag ins,
79            string asmstr, list<dag> pattern> : F3<outs, ins, asmstr, pattern> {
80   bits<8> asi = 0; // asi not currently used
81   bits<5> rs2;
82
83   let op         = opVal;
84   let op3        = op3val;
85
86   let Inst{13}   = 0;     // i field = 0
87   let Inst{12-5} = asi;   // address space identifier
88   let Inst{4-0}  = rs2;
89 }
90
91 class F3_2<bits<2> opVal, bits<6> op3val, dag outs, dag ins,
92            string asmstr, list<dag> pattern> : F3<outs, ins, asmstr, pattern> {
93   bits<13> simm13;
94
95   let op         = opVal;
96   let op3        = op3val;
97
98   let Inst{13}   = 1;     // i field = 1
99   let Inst{12-0} = simm13;
100 }
101
102 // floating-point
103 class F3_3<bits<2> opVal, bits<6> op3val, bits<9> opfval, dag outs, dag ins,
104            string asmstr, list<dag> pattern> : F3<outs, ins, asmstr, pattern> {
105   bits<5> rs2;
106
107   let op         = opVal;
108   let op3        = op3val;
109
110   let Inst{13-5} = opfval;   // fp opcode
111   let Inst{4-0}  = rs2;
112 }
113
114 // Shift by register rs2.
115 class F3_Sr<bits<2> opVal, bits<6> op3val, bit xVal, dag outs, dag ins,
116             string asmstr, list<dag> pattern> : F3<outs, ins, asmstr, pattern> {
117   bit x = xVal;           // 1 for 64-bit shifts.
118   bits<5> rs2;
119
120   let op         = opVal;
121   let op3        = op3val;
122
123   let Inst{13}   = 0;     // i field = 0
124   let Inst{12}   = x;     // extended registers.
125   let Inst{4-0}  = rs2;
126 }
127
128 // Shift by immediate.
129 class F3_Si<bits<2> opVal, bits<6> op3val, bit xVal, dag outs, dag ins,
130             string asmstr, list<dag> pattern> : F3<outs, ins, asmstr, pattern> {
131   bit x = xVal;           // 1 for 64-bit shifts.
132   bits<6> shcnt;          // shcnt32 / shcnt64.
133
134   let op         = opVal;
135   let op3        = op3val;
136
137   let Inst{13}   = 1;     // i field = 1
138   let Inst{12}   = x;     // extended registers.
139   let Inst{5-0}  = shcnt;
140 }
141
142 // Define rr and ri shift instructions with patterns.
143 multiclass F3_S<string OpcStr, bits<6> Op3Val, bit XVal, SDNode OpNode,
144                 ValueType VT, RegisterClass RC> {
145   def rr : F3_Sr<2, Op3Val, XVal, (outs RC:$rd), (ins RC:$rs, IntRegs:$rs2),
146                  !strconcat(OpcStr, " $rs, $rs2, $rd"),
147                  [(set VT:$rd, (OpNode VT:$rs, i32:$rs2))]>;
148   def ri : F3_Si<2, Op3Val, XVal, (outs RC:$rd), (ins RC:$rs, i32imm:$shcnt),
149                  !strconcat(OpcStr, " $rs, $shcnt, $rd"),
150                  [(set VT:$rd, (OpNode VT:$rs, (i32 imm:$shcnt)))]>;
151 }
152
153 class F4<bits<6> op3, dag outs, dag ins, string asmstr, list<dag> pattern>
154       : InstSP<outs, ins, asmstr, pattern> {
155   bits<5> rd;
156
157   let op          = 2;
158   let Inst{29-25} = rd;
159   let Inst{24-19} = op3;
160 }
161
162
163 class F4_1<bits<6> op3, dag outs, dag ins,
164             string asmstr, list<dag> pattern>
165       : F4<op3, outs, ins, asmstr, pattern> {
166
167   bits<3> cc;
168   bits<4> cond;
169   bits<5> rs2;
170
171   let Inst{4-0}   = rs2;
172   let Inst{11}    = cc{0};
173   let Inst{12}    = cc{1};
174   let Inst{13}    = 0;
175   let Inst{17-14} = cond;
176   let Inst{18}    = cc{2};
177
178 }
179
180 class F4_2<bits<6> op3, dag outs, dag ins,
181             string asmstr, list<dag> pattern>
182       : F4<op3, outs, ins, asmstr, pattern> {
183   bits<3>  cc;
184   bits<4>  cond;
185   bits<11> simm11;
186
187   let Inst{10-0}  = simm11;
188   let Inst{11}    = cc{0};
189   let Inst{12}    = cc{1};
190   let Inst{13}    = 1;
191   let Inst{17-14} = cond;
192   let Inst{18}    = cc{2};
193 }
194
195 class F4_3<bits<6> op3, bits<6> opf_low, dag outs, dag ins,
196            string asmstr, list<dag> pattern>
197       : F4<op3, outs, ins, asmstr, pattern> {
198   bits<4> cond;
199   bits<3> opf_cc;
200   bits<5> rs2;
201
202   let Inst{18}     = 0;
203   let Inst{17-14}  = cond;
204   let Inst{13-11}  = opf_cc;
205   let Inst{10-5}   = opf_low;
206   let Inst{4-0}    = rs2;
207 }