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