Adding the MicroBlaze backend.
[oota-llvm.git] / lib / Target / MBlaze / MBlazeInstrFormats.td
1 //===- MBlazeInstrFormats.td - MB Instruction defs --------------*- C++ -*-===//
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 //  Describe MBlaze instructions format
12 //
13 //  CPU INSTRUCTION FORMATS
14 //
15 //  opcode  - operation code.
16 //  rd      - dst reg.
17 //  ra      - first src. reg.
18 //  rb      - second src. reg.
19 //  imm16   - 16-bit immediate value.
20 //
21 //===----------------------------------------------------------------------===//
22
23 // Generic MBlaze Format
24 class MBlazeInst<dag outs, dag ins, string asmstr, list<dag> pattern, 
25                InstrItinClass itin> : Instruction 
26 {
27   field bits<32> Inst;
28
29   let Namespace = "MBlaze";
30
31   bits<6> opcode;
32
33   // Top 6 bits are the 'opcode' field
34   let Inst{0-5} = opcode;   
35   
36   dag OutOperandList = outs;
37   dag InOperandList  = ins;
38
39   let AsmString   = asmstr;
40   let Pattern     = pattern;
41   let Itinerary   = itin;
42 }
43
44 //===----------------------------------------------------------------------===//
45 // Pseudo instruction class
46 //===----------------------------------------------------------------------===//
47 class MBlazePseudo<dag outs, dag ins, string asmstr, list<dag> pattern>:
48       MBlazeInst<outs, ins, asmstr, pattern, IIPseudo>;
49
50 //===----------------------------------------------------------------------===//
51 // Type A instruction class in MBlaze : <|opcode|rd|ra|rb|flags|>
52 //===----------------------------------------------------------------------===//
53
54 class TA<bits<6> op, bits<11> flags, dag outs, dag ins, string asmstr,
55          list<dag> pattern, InstrItinClass itin> : 
56          MBlazeInst<outs, ins, asmstr, pattern, itin> 
57 {
58   bits<5> rd;
59   bits<5> ra;
60   bits<5> rb;
61
62   let opcode = op;
63
64   let Inst{6-10}  = rd;
65   let Inst{11-15} = ra; 
66   let Inst{16-20} = rb;
67   let Inst{21-31} = flags;
68 }
69
70 class TAI<bits<6> op, dag outs, dag ins, string asmstr,
71           list<dag> pattern, InstrItinClass itin> :
72           MBlazeInst<outs, ins, asmstr, pattern, itin>
73 {
74   bits<5> rd;
75   bits<5> ra;
76   bits<16> imm16;
77
78   let opcode = op;
79
80   let Inst{6-10}  = rd;
81   let Inst{11-15} = ra; 
82   let Inst{16-31} = imm16;
83 }
84
85 class TIMM<bits<6> op, dag outs, dag ins, string asmstr,
86            list<dag> pattern, InstrItinClass itin> :
87            MBlazeInst<outs, ins, asmstr, pattern, itin>
88 {
89   bits<5> ra;
90   bits<16> imm16;
91
92   let opcode = op;
93
94   let Inst{6-15}  = 0;
95   let Inst{16-31} = imm16;
96 }
97
98 class TADDR<bits<6> op, dag outs, dag ins, string asmstr,
99             list<dag> pattern, InstrItinClass itin> :
100             MBlazeInst<outs, ins, asmstr, pattern, itin>
101 {
102   bits<26> addr;
103
104   let opcode = op;
105
106   let Inst{6-31} = addr;
107 }
108
109 //===----------------------------------------------------------------------===//
110 // Type B instruction class in MBlaze : <|opcode|rd|ra|immediate|>
111 //===----------------------------------------------------------------------===//
112
113 class TB<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern,
114          InstrItinClass itin> : 
115          MBlazeInst<outs, ins, asmstr, pattern, itin> 
116 {
117   bits<5>  rd;
118   bits<5>  ra;
119   bits<16> imm16;
120
121   let opcode = op;
122
123   let Inst{6-10}  = rd;
124   let Inst{11-15} = ra; 
125   let Inst{16-31} = imm16;
126 }
127
128 //===----------------------------------------------------------------------===//
129 // Float instruction class in MBlaze : <|opcode|rd|ra|flags|>
130 //===----------------------------------------------------------------------===//
131
132 class TF<bits<6> op, bits<11> flags, dag outs, dag ins, string asmstr,
133          list<dag> pattern, InstrItinClass itin> : 
134          MBlazeInst<outs, ins, asmstr, pattern, itin> 
135 {
136   bits<5>  rd;
137   bits<5>  ra;
138
139   let opcode = op;
140
141   let Inst{6-10}  = rd;
142   let Inst{11-15} = ra; 
143   let Inst{16-20} = 0;
144   let Inst{21-31} = flags;
145 }
146
147 //===----------------------------------------------------------------------===//
148 // Branch instruction class in MBlaze : <|opcode|rd|br|ra|flags|>
149 //===----------------------------------------------------------------------===//
150
151 class TBR<bits<6> op, bits<5> br, bits<11> flags, dag outs, dag ins,
152           string asmstr, list<dag> pattern, InstrItinClass itin> :
153           MBlazeInst<outs, ins, asmstr, pattern, itin>
154 {
155   bits<5> ra;
156
157   let opcode = op;
158
159   let Inst{6-10}  = 0;
160   let Inst{11-15} = br; 
161   let Inst{16-20} = ra;
162   let Inst{21-31} = flags;
163 }
164
165 class TBRC<bits<6> op, bits<5> br, bits<11> flags, dag outs, dag ins,
166            string asmstr, list<dag> pattern, InstrItinClass itin> :
167            MBlazeInst<outs, ins, asmstr, pattern, itin>
168 {
169   bits<5> ra;
170   bits<5> rb;
171
172   let opcode = op;
173
174   let Inst{6-10}  = br;
175   let Inst{11-15} = ra; 
176   let Inst{16-20} = rb;
177   let Inst{21-31} = flags;
178 }
179
180 class TBRL<bits<6> op, bits<5> br, bits<11> flags, dag outs, dag ins,
181            string asmstr, list<dag> pattern, InstrItinClass itin> :
182            MBlazeInst<outs, ins, asmstr, pattern, itin>
183 {
184   bits<5> ra;
185
186   let opcode = op;
187
188   let Inst{6-10}  = 0xF;
189   let Inst{11-15} = br; 
190   let Inst{16-20} = ra;
191   let Inst{21-31} = flags;
192 }
193
194 class TBRI<bits<6> op, bits<5> br, dag outs, dag ins,
195            string asmstr, list<dag> pattern, InstrItinClass itin> :
196            MBlazeInst<outs, ins, asmstr, pattern, itin>
197 {
198   bits<16> imm16;
199
200   let opcode = op;
201
202   let Inst{6-10}  = 0;
203   let Inst{11-15} = br; 
204   let Inst{16-31} = imm16;
205 }
206
207 class TBRLI<bits<6> op, bits<5> br, dag outs, dag ins,
208             string asmstr, list<dag> pattern, InstrItinClass itin> :
209             MBlazeInst<outs, ins, asmstr, pattern, itin>
210 {
211   bits<16> imm16;
212
213   let opcode = op;
214
215   let Inst{6-10}  = 0xF;
216   let Inst{11-15} = br; 
217   let Inst{16-31} = imm16;
218 }
219
220 class TBRCI<bits<6> op, bits<5> br, dag outs, dag ins,
221             string asmstr, list<dag> pattern, InstrItinClass itin> :
222             MBlazeInst<outs, ins, asmstr, pattern, itin>
223 {
224   bits<5> ra;
225   bits<16> imm16;
226
227   let opcode = op;
228
229   let Inst{6-10}  = br;
230   let Inst{11-15} = ra; 
231   let Inst{16-31} = imm16;
232 }
233
234 class TRET<bits<6> op, dag outs, dag ins,
235             string asmstr, list<dag> pattern, InstrItinClass itin> :
236             MBlazeInst<outs, ins, asmstr, pattern, itin>
237 {
238   bits<5>  ra;
239   bits<16> imm16;
240
241   let opcode = op;
242
243   let Inst{6-10}  = 0x10;
244   let Inst{11-15} = ra; 
245   let Inst{16-31} = imm16;
246 }