Add instruction encodings / disassembly support for u10 / lu10 instructions.
[oota-llvm.git] / lib / Target / XCore / XCoreInstrFormats.td
1 //===-- XCoreInstrFormats.td - XCore 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 //===----------------------------------------------------------------------===//
11 // Instruction format superclass
12 //===----------------------------------------------------------------------===//
13 class InstXCore<int sz, dag outs, dag ins, string asmstr, list<dag> pattern>
14     : Instruction {
15   field bits<32> Inst;
16
17   let Namespace = "XCore";
18   dag OutOperandList = outs;
19   dag InOperandList = ins;
20   let AsmString   = asmstr;
21   let Pattern = pattern;
22   let Size = sz;
23   field bits<32> SoftFail = 0;
24 }
25
26 // XCore pseudo instructions format
27 class PseudoInstXCore<dag outs, dag ins, string asmstr, list<dag> pattern>
28    : InstXCore<0, outs, ins, asmstr, pattern> {
29   let isPseudo = 1;
30 }
31
32 //===----------------------------------------------------------------------===//
33 // Instruction formats
34 //===----------------------------------------------------------------------===//
35
36 class _F3R<bits<5> opc, dag outs, dag ins, string asmstr, list<dag> pattern>
37     : InstXCore<2, outs, ins, asmstr, pattern> {
38   let Inst{15-11} = opc;
39   let DecoderMethod = "Decode3RInstruction";
40 }
41
42 class _FL3R<bits<9> opc, dag outs, dag ins, string asmstr, list<dag> pattern>
43     : InstXCore<4, outs, ins, asmstr, pattern> {
44   let Inst{31-27} = opc{8-4};
45   let Inst{26-20} = 0b1111110;
46   let Inst{19-16} = opc{3-0};
47
48   let Inst{15-11} = 0b11111;
49   let DecoderMethod = "DecodeL3RInstruction";
50 }
51
52 // L3R with first operand as both a source and a destination.
53 class _FL3RSrcDst<bits<9> opc, dag outs, dag ins, string asmstr,
54                   list<dag> pattern> : _FL3R<opc, outs, ins, asmstr, pattern> {
55   let DecoderMethod = "DecodeL3RSrcDstInstruction";
56 }
57
58 class _F2RUS<bits<5> opc, dag outs, dag ins, string asmstr, list<dag> pattern>
59     : InstXCore<2, outs, ins, asmstr, pattern> {
60   let Inst{15-11} = opc;
61   let DecoderMethod = "Decode2RUSInstruction";
62 }
63
64 // 2RUS with bitp operand
65 class _F2RUSBitp<bits<5> opc, dag outs, dag ins, string asmstr,
66                  list<dag> pattern>
67     : _F2RUS<opc, outs, ins, asmstr, pattern> {
68   let DecoderMethod = "Decode2RUSBitpInstruction";
69 }
70
71 class _FL2RUS<bits<9> opc, dag outs, dag ins, string asmstr, list<dag> pattern>
72     : InstXCore<4, outs, ins, asmstr, pattern> {
73   let Inst{31-27} = opc{8-4};
74   let Inst{26-20} = 0b1111110;
75   let Inst{19-16} = opc{3-0};
76
77   let Inst{15-11} = 0b11111;
78   let DecoderMethod = "DecodeL2RUSInstruction";
79 }
80
81 // L2RUS with bitp operand
82 class _FL2RUSBitp<bits<9> opc, dag outs, dag ins, string asmstr,
83                   list<dag> pattern>
84     : _FL2RUS<opc, outs, ins, asmstr, pattern> {
85   let DecoderMethod = "DecodeL2RUSBitpInstruction";
86 }
87
88 class _FRU6<bits<6> opc, dag outs, dag ins, string asmstr, list<dag> pattern>
89     : InstXCore<2, outs, ins, asmstr, pattern> {
90   bits<4> a;
91   bits<6> b;
92
93   let Inst{15-10} = opc;
94   let Inst{9-6} = a;
95   let Inst{5-0} = b;
96 }
97
98 class _FLRU6<bits<6> opc, dag outs, dag ins, string asmstr, list<dag> pattern>
99     : InstXCore<4, outs, ins, asmstr, pattern> {
100   bits<4> a;
101   bits<16> b;
102
103   let Inst{31-26} = opc;
104   let Inst{25-22} = a;
105   let Inst{21-16} = b{5-0};
106   let Inst{15-10} = 0b111100;
107   let Inst{9-0} = b{15-6};
108 }
109
110 class _FU6<bits<10> opc, dag outs, dag ins, string asmstr, list<dag> pattern>
111     : InstXCore<2, outs, ins, asmstr, pattern> {
112   bits<6> a;
113
114   let Inst{15-6} = opc;
115   let Inst{5-0} = a;
116 }
117
118 class _FLU6<bits<10> opc, dag outs, dag ins, string asmstr, list<dag> pattern>
119     : InstXCore<4, outs, ins, asmstr, pattern> {
120   bits<16> a;
121
122   let Inst{31-22} = opc;
123   let Inst{21-16} = a{5-0};
124   let Inst{15-10} = 0b111100;
125   let Inst{9-0} = a{15-6};
126 }
127
128 class _FU10<bits<6> opc, dag outs, dag ins, string asmstr, list<dag> pattern>
129     : InstXCore<2, outs, ins, asmstr, pattern> {
130   bits<10> a;
131
132   let Inst{15-10} = opc;
133   let Inst{9-0} = a;
134 }
135
136 class _FLU10<bits<6> opc, dag outs, dag ins, string asmstr, list<dag> pattern>
137     : InstXCore<4, outs, ins, asmstr, pattern> {
138   bits<20> a;
139
140   let Inst{31-26} = opc;
141   let Inst{25-16} = a{9-0};
142   let Inst{15-10} = 0b111100;
143   let Inst{9-0} = a{19-10};
144 }
145
146 class _F2R<bits<6> opc, dag outs, dag ins, string asmstr, list<dag> pattern>
147     : InstXCore<2, outs, ins, asmstr, pattern> {
148   let Inst{15-11} = opc{5-1};
149   let Inst{4} = opc{0};
150   let DecoderMethod = "Decode2RInstruction";
151 }
152
153 // 2R with first operand as both a source and a destination.
154 class _F2RSrcDst<bits<6> opc, dag outs, dag ins, string asmstr,
155                  list<dag> pattern> : _F2R<opc, outs, ins, asmstr, pattern> {
156   let DecoderMethod = "Decode2RSrcDstInstruction";
157 }
158
159 // Same as 2R with last two operands swapped
160 class _FR2R<bits<6> opc, dag outs, dag ins, string asmstr, list<dag> pattern>
161     : _F2R<opc, outs, ins, asmstr, pattern> {
162   let DecoderMethod = "DecodeR2RInstruction";
163 }
164
165 class _FRUS<bits<6> opc, dag outs, dag ins, string asmstr, list<dag> pattern>
166     : InstXCore<2, outs, ins, asmstr, pattern> {
167   let Inst{15-11} = opc{5-1};
168   let Inst{4} = opc{0};
169   let DecoderMethod = "DecodeRUSInstruction";
170 }
171
172 // RUS with bitp operand
173 class _FRUSBitp<bits<6> opc, dag outs, dag ins, string asmstr,
174                 list<dag> pattern>
175     : _FRUS<opc, outs, ins, asmstr, pattern> {
176   let DecoderMethod = "DecodeRUSBitpInstruction";
177 }
178
179 // RUS with first operand as both a source and a destination and a bitp second
180 // operand
181 class _FRUSSrcDstBitp<bits<6> opc, dag outs, dag ins, string asmstr,
182                       list<dag> pattern>
183     : _FRUS<opc, outs, ins, asmstr, pattern> {
184   let DecoderMethod = "DecodeRUSSrcDstBitpInstruction";
185 }
186
187 class _FL2R<bits<10> opc, dag outs, dag ins, string asmstr, list<dag> pattern>
188     : InstXCore<4, outs, ins, asmstr, pattern> {
189   let Inst{31-27} = opc{9-5};
190   let Inst{26-20} = 0b1111110;
191   let Inst{19-16} = opc{4-1};
192
193   let Inst{15-11} = 0b11111;
194   let Inst{4} = opc{0};
195   let DecoderMethod = "DecodeL2RInstruction";
196 }
197
198 // Same as L2R with last two operands swapped
199 class _FLR2R<bits<10> opc, dag outs, dag ins, string asmstr, list<dag> pattern>
200     : _FL2R<opc, outs, ins, asmstr, pattern> {
201   let DecoderMethod = "DecodeLR2RInstruction";
202 }
203
204 class _F1R<bits<6> opc, dag outs, dag ins, string asmstr, list<dag> pattern>
205     : InstXCore<2, outs, ins, asmstr, pattern> {
206   bits<4> a;
207
208   let Inst{15-11} = opc{5-1};
209   let Inst{10-5} = 0b111111;
210   let Inst{4} = opc{0};
211   let Inst{3-0} = a;
212 }
213
214 class _F0R<bits<10> opc, dag outs, dag ins, string asmstr, list<dag> pattern>
215     : InstXCore<2, outs, ins, asmstr, pattern> {
216   let Inst{15-11} = opc{9-5};
217   let Inst{10-5} = 0b111111;
218   let Inst{4-0} = opc{4-0};
219 }
220
221 class _L4R<dag outs, dag ins, string asmstr, list<dag> pattern>
222     : InstXCore<4, outs, ins, asmstr, pattern> {
223 }
224
225 class _L5R<dag outs, dag ins, string asmstr, list<dag> pattern>
226     : InstXCore<4, outs, ins, asmstr, pattern> {
227 }
228
229 class _L6R<dag outs, dag ins, string asmstr, list<dag> pattern>
230     : InstXCore<4, outs, ins, asmstr, pattern> {
231 }