Add instruction encodings / disassembly support for l2rus 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<dag outs, dag ins, string asmstr, list<dag> pattern>
89     : InstXCore<2, outs, ins, asmstr, pattern> {
90 }
91
92 class _FLRU6<dag outs, dag ins, string asmstr, list<dag> pattern>
93     : InstXCore<4, outs, ins, asmstr, pattern> {
94 }
95
96 class _FU6<dag outs, dag ins, string asmstr, list<dag> pattern>
97     : InstXCore<2, outs, ins, asmstr, pattern> {
98 }
99
100 class _FLU6<dag outs, dag ins, string asmstr, list<dag> pattern>
101     : InstXCore<4, outs, ins, asmstr, pattern> {
102 }
103
104 class _FU10<dag outs, dag ins, string asmstr, list<dag> pattern>
105     : InstXCore<2, outs, ins, asmstr, pattern> {
106 }
107
108 class _FLU10<dag outs, dag ins, string asmstr, list<dag> pattern>
109     : InstXCore<4, outs, ins, asmstr, pattern> {
110 }
111
112 class _F2R<bits<6> opc, dag outs, dag ins, string asmstr, list<dag> pattern>
113     : InstXCore<2, outs, ins, asmstr, pattern> {
114   let Inst{15-11} = opc{5-1};
115   let Inst{4} = opc{0};
116   let DecoderMethod = "Decode2RInstruction";
117 }
118
119 // 2R with first operand as both a source and a destination.
120 class _F2RSrcDst<bits<6> opc, dag outs, dag ins, string asmstr,
121                  list<dag> pattern> : _F2R<opc, outs, ins, asmstr, pattern> {
122   let DecoderMethod = "Decode2RSrcDstInstruction";
123 }
124
125 // Same as 2R with last two operands swapped
126 class _FR2R<bits<6> opc, dag outs, dag ins, string asmstr, list<dag> pattern>
127     : _F2R<opc, outs, ins, asmstr, pattern> {
128   let DecoderMethod = "DecodeR2RInstruction";
129 }
130
131 class _FRUS<bits<6> opc, dag outs, dag ins, string asmstr, list<dag> pattern>
132     : InstXCore<2, outs, ins, asmstr, pattern> {
133   let Inst{15-11} = opc{5-1};
134   let Inst{4} = opc{0};
135   let DecoderMethod = "DecodeRUSInstruction";
136 }
137
138 // RUS with bitp operand
139 class _FRUSBitp<bits<6> opc, dag outs, dag ins, string asmstr,
140                 list<dag> pattern>
141     : _FRUS<opc, outs, ins, asmstr, pattern> {
142   let DecoderMethod = "DecodeRUSBitpInstruction";
143 }
144
145 // RUS with first operand as both a source and a destination and a bitp second
146 // operand
147 class _FRUSSrcDstBitp<bits<6> opc, dag outs, dag ins, string asmstr,
148                       list<dag> pattern>
149     : _FRUS<opc, outs, ins, asmstr, pattern> {
150   let DecoderMethod = "DecodeRUSSrcDstBitpInstruction";
151 }
152
153 class _FL2R<bits<10> opc, dag outs, dag ins, string asmstr, list<dag> pattern>
154     : InstXCore<4, outs, ins, asmstr, pattern> {
155   let Inst{31-27} = opc{9-5};
156   let Inst{26-20} = 0b1111110;
157   let Inst{19-16} = opc{4-1};
158
159   let Inst{15-11} = 0b11111;
160   let Inst{4} = opc{0};
161   let DecoderMethod = "DecodeL2RInstruction";
162 }
163
164 // Same as L2R with last two operands swapped
165 class _FLR2R<bits<10> opc, dag outs, dag ins, string asmstr, list<dag> pattern>
166     : _FL2R<opc, outs, ins, asmstr, pattern> {
167   let DecoderMethod = "DecodeLR2RInstruction";
168 }
169
170 class _F1R<bits<6> opc, dag outs, dag ins, string asmstr, list<dag> pattern>
171     : InstXCore<2, outs, ins, asmstr, pattern> {
172   bits<4> a;
173
174   let Inst{15-11} = opc{5-1};
175   let Inst{10-5} = 0b111111;
176   let Inst{4} = opc{0};
177   let Inst{3-0} = a;
178 }
179
180 class _F0R<bits<10> opc, dag outs, dag ins, string asmstr, list<dag> pattern>
181     : InstXCore<2, outs, ins, asmstr, pattern> {
182   let Inst{15-11} = opc{9-5};
183   let Inst{10-5} = 0b111111;
184   let Inst{4-0} = opc{4-0};
185 }
186
187 class _L4R<dag outs, dag ins, string asmstr, list<dag> pattern>
188     : InstXCore<4, outs, ins, asmstr, pattern> {
189 }
190
191 class _L5R<dag outs, dag ins, string asmstr, list<dag> pattern>
192     : InstXCore<4, outs, ins, asmstr, pattern> {
193 }
194
195 class _L6R<dag outs, dag ins, string asmstr, list<dag> pattern>
196     : InstXCore<4, outs, ins, asmstr, pattern> {
197 }