Add instruction encodings / disassembly support 3r 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<dag outs, dag ins, string asmstr, list<dag> pattern>
43     : InstXCore<4, outs, ins, asmstr, pattern> {
44 }
45
46 class _F2RUS<dag outs, dag ins, string asmstr, list<dag> pattern>
47     : InstXCore<2, outs, ins, asmstr, pattern> {
48 }
49
50 class _FL2RUS<dag outs, dag ins, string asmstr, list<dag> pattern>
51     : InstXCore<4, outs, ins, asmstr, pattern> {
52 }
53
54 class _FRU6<dag outs, dag ins, string asmstr, list<dag> pattern>
55     : InstXCore<2, outs, ins, asmstr, pattern> {
56 }
57
58 class _FLRU6<dag outs, dag ins, string asmstr, list<dag> pattern>
59     : InstXCore<4, outs, ins, asmstr, pattern> {
60 }
61
62 class _FU6<dag outs, dag ins, string asmstr, list<dag> pattern>
63     : InstXCore<2, outs, ins, asmstr, pattern> {
64 }
65
66 class _FLU6<dag outs, dag ins, string asmstr, list<dag> pattern>
67     : InstXCore<4, outs, ins, asmstr, pattern> {
68 }
69
70 class _FU10<dag outs, dag ins, string asmstr, list<dag> pattern>
71     : InstXCore<2, outs, ins, asmstr, pattern> {
72 }
73
74 class _FLU10<dag outs, dag ins, string asmstr, list<dag> pattern>
75     : InstXCore<4, outs, ins, asmstr, pattern> {
76 }
77
78 class _F2R<bits<6> opc, dag outs, dag ins, string asmstr, list<dag> pattern>
79     : InstXCore<2, outs, ins, asmstr, pattern> {
80   let Inst{15-11} = opc{5-1};
81   let Inst{4} = opc{0};
82   let DecoderMethod = "Decode2RInstruction";
83 }
84
85 // 2R with first operand as both a source and a destination.
86 class _F2RSrcDst<bits<6> opc, dag outs, dag ins, string asmstr,
87                  list<dag> pattern> : _F2R<opc, outs, ins, asmstr, pattern> {
88   let DecoderMethod = "Decode2RSrcDstInstruction";
89 }
90
91 // Same as 2R with last two operands swapped
92 class _FR2R<bits<6> opc, dag outs, dag ins, string asmstr, list<dag> pattern>
93     : _F2R<opc, outs, ins, asmstr, pattern> {
94   let DecoderMethod = "DecodeR2RInstruction";
95 }
96
97 class _FRUS<bits<6> opc, dag outs, dag ins, string asmstr, list<dag> pattern>
98     : InstXCore<2, outs, ins, asmstr, pattern> {
99   let Inst{15-11} = opc{5-1};
100   let Inst{4} = opc{0};
101   let DecoderMethod = "DecodeRUSInstruction";
102 }
103
104 // RUS with bitp operand
105 class _FRUSBitp<bits<6> opc, dag outs, dag ins, string asmstr,
106                 list<dag> pattern>
107     : _FRUS<opc, outs, ins, asmstr, pattern> {
108   let DecoderMethod = "DecodeRUSBitpInstruction";
109 }
110
111 // RUS with first operand as both a source and a destination and a bitp second
112 // operand
113 class _FRUSSrcDstBitp<bits<6> opc, dag outs, dag ins, string asmstr,
114                       list<dag> pattern>
115     : _FRUS<opc, outs, ins, asmstr, pattern> {
116   let DecoderMethod = "DecodeRUSSrcDstBitpInstruction";
117 }
118
119 class _FL2R<bits<10> opc, dag outs, dag ins, string asmstr, list<dag> pattern>
120     : InstXCore<4, outs, ins, asmstr, pattern> {
121   let Inst{31-27} = opc{9-5};
122   let Inst{26-20} = 0b1111110;
123   let Inst{19-16} = opc{4-1};
124
125   let Inst{15-11} = 0b11111;
126   let Inst{4} = opc{0};
127   let DecoderMethod = "DecodeL2RInstruction";
128 }
129
130 // Same as L2R with last two operands swapped
131 class _FLR2R<bits<10> opc, dag outs, dag ins, string asmstr, list<dag> pattern>
132     : _FL2R<opc, outs, ins, asmstr, pattern> {
133   let DecoderMethod = "DecodeLR2RInstruction";
134 }
135
136 class _F1R<bits<6> opc, dag outs, dag ins, string asmstr, list<dag> pattern>
137     : InstXCore<2, outs, ins, asmstr, pattern> {
138   bits<4> a;
139
140   let Inst{15-11} = opc{5-1};
141   let Inst{10-5} = 0b111111;
142   let Inst{4} = opc{0};
143   let Inst{3-0} = a;
144 }
145
146 class _F0R<bits<10> opc, dag outs, dag ins, string asmstr, list<dag> pattern>
147     : InstXCore<2, outs, ins, asmstr, pattern> {
148   let Inst{15-11} = opc{9-5};
149   let Inst{10-5} = 0b111111;
150   let Inst{4-0} = opc{4-0};
151 }
152
153 class _L4R<dag outs, dag ins, string asmstr, list<dag> pattern>
154     : InstXCore<4, outs, ins, asmstr, pattern> {
155 }
156
157 class _L5R<dag outs, dag ins, string asmstr, list<dag> pattern>
158     : InstXCore<4, outs, ins, asmstr, pattern> {
159 }
160
161 class _L6R<dag outs, dag ins, string asmstr, list<dag> pattern>
162     : InstXCore<4, outs, ins, asmstr, pattern> {
163 }