aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/MBlaze/MBlazeInstrFormats.td
blob: 7d655433d4e4dab5c03afc6e7d722cfdb065bbef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
//===- MBlazeInstrFormats.td - MB Instruction defs --------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

//===----------------------------------------------------------------------===//
//  Describe MBlaze instructions format
//
//  CPU INSTRUCTION FORMATS
//
//  opcode  - operation code.
//  rd      - dst reg.
//  ra      - first src. reg.
//  rb      - second src. reg.
//  imm16   - 16-bit immediate value.
//
//===----------------------------------------------------------------------===//

// Generic MBlaze Format
class MBlazeInst<dag outs, dag ins, string asmstr, list<dag> pattern, 
               InstrItinClass itin> : Instruction 
{
  field bits<32> Inst;

  let Namespace = "MBlaze";

  bits<6> opcode;

  // Top 6 bits are the 'opcode' field
  let Inst{0-5} = opcode;   
  
  dag OutOperandList = outs;
  dag InOperandList  = ins;

  let AsmString   = asmstr;
  let Pattern     = pattern;
  let Itinerary   = itin;
}

//===----------------------------------------------------------------------===//
// Pseudo instruction class
//===----------------------------------------------------------------------===//
class MBlazePseudo<dag outs, dag ins, string asmstr, list<dag> pattern>:
      MBlazeInst<outs, ins, asmstr, pattern, IIPseudo>;

//===----------------------------------------------------------------------===//
// Type A instruction class in MBlaze : <|opcode|rd|ra|rb|flags|>
//===----------------------------------------------------------------------===//

class TA<bits<6> op, bits<11> flags, dag outs, dag ins, string asmstr,
         list<dag> pattern, InstrItinClass itin> : 
         MBlazeInst<outs, ins, asmstr, pattern, itin> 
{
  bits<5> rd;
  bits<5> ra;
  bits<5> rb;

  let opcode = op;

  let Inst{6-10}  = rd;
  let Inst{11-15} = ra; 
  let Inst{16-20} = rb;
  let Inst{21-31} = flags;
}

class TAI<bits<6> op, dag outs, dag ins, string asmstr,
          list<dag> pattern, InstrItinClass itin> :
          MBlazeInst<outs, ins, asmstr, pattern, itin>
{
  bits<5> rd;
  bits<5> ra;
  bits<16> imm16;

  let opcode = op;

  let Inst{6-10}  = rd;
  let Inst{11-15} = ra; 
  let Inst{16-31} = imm16;
}

class TIMM<bits<6> op, dag outs, dag ins, string asmstr,
           list<dag> pattern, InstrItinClass itin> :
           MBlazeInst<outs, ins, asmstr, pattern, itin>
{
  bits<5> ra;
  bits<16> imm16;

  let opcode = op;

  let Inst{6-15}  = 0;
  let Inst{16-31} = imm16;
}

class TADDR<bits<6> op, dag outs, dag ins, string asmstr,
            list<dag> pattern, InstrItinClass itin> :
            MBlazeInst<outs, ins, asmstr, pattern, itin>
{
  bits<26> addr;

  let opcode = op;

  let Inst{6-31} = addr;
}

//===----------------------------------------------------------------------===//
// Type B instruction class in MBlaze : <|opcode|rd|ra|immediate|>
//===----------------------------------------------------------------------===//

class TB<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern,
         InstrItinClass itin> : 
         MBlazeInst<outs, ins, asmstr, pattern, itin> 
{
  bits<5>  rd;
  bits<5>  ra;
  bits<16> imm16;

  let opcode = op;

  let Inst{6-10}  = rd;
  let Inst{11-15} = ra; 
  let Inst{16-31} = imm16;
}

//===----------------------------------------------------------------------===//
// Float instruction class in MBlaze : <|opcode|rd|ra|flags|>
//===----------------------------------------------------------------------===//

class TF<bits<6> op, bits<11> flags, dag outs, dag ins, string asmstr,
         list<dag> pattern, InstrItinClass itin> : 
         MBlazeInst<outs, ins, asmstr, pattern, itin> 
{
  bits<5>  rd;
  bits<5>  ra;

  let opcode = op;

  let Inst{6-10}  = rd;
  let Inst{11-15} = ra; 
  let Inst{16-20} = 0;
  let Inst{21-31} = flags;
}

//===----------------------------------------------------------------------===//
// Branch instruction class in MBlaze : <|opcode|rd|br|ra|flags|>
//===----------------------------------------------------------------------===//

class TBR<bits<6> op, bits<5> br, bits<11> flags, dag outs, dag ins,
          string asmstr, list<dag> pattern, InstrItinClass itin> :
          MBlazeInst<outs, ins, asmstr, pattern, itin>
{
  bits<5> ra;

  let opcode = op;

  let Inst{6-10}  = 0;
  let Inst{11-15} = br; 
  let Inst{16-20} = ra;
  let Inst{21-31} = flags;
}

class TBRC<bits<6> op, bits<5> br, bits<11> flags, dag outs, dag ins,
           string asmstr, list<dag> pattern, InstrItinClass itin> :
           MBlazeInst<outs, ins, asmstr, pattern, itin>
{
  bits<5> ra;
  bits<5> rb;

  let opcode = op;

  let Inst{6-10}  = br;
  let Inst{11-15} = ra; 
  let Inst{16-20} = rb;
  let Inst{21-31} = flags;
}

class TBRL<bits<6> op, bits<5> br, bits<11> flags, dag outs, dag ins,
           string asmstr, list<dag> pattern, InstrItinClass itin> :
           MBlazeInst<outs, ins, asmstr, pattern, itin>
{
  bits<5> ra;

  let opcode = op;

  let Inst{6-10}  = 0xF;
  let Inst{11-15} = br; 
  let Inst{16-20} = ra;
  let Inst{21-31} = flags;
}

class TBRI<bits<6> op, bits<5> br, dag outs, dag ins,
           string asmstr, list<dag> pattern, InstrItinClass itin> :
           MBlazeInst<outs, ins, asmstr, pattern, itin>
{
  bits<16> imm16;

  let opcode = op;

  let Inst{6-10}  = 0;
  let Inst{11-15} = br; 
  let Inst{16-31} = imm16;
}

class TBRLI<bits<6> op, bits<5> br, dag outs, dag ins,
            string asmstr, list<dag> pattern, InstrItinClass itin> :
            MBlazeInst<outs, ins, asmstr, pattern, itin>
{
  bits<16> imm16;

  let opcode = op;

  let Inst{6-10}  = 0xF;
  let Inst{11-15} = br; 
  let Inst{16-31} = imm16;
}

class TBRCI<bits<6> op, bits<5> br, dag outs, dag ins,
            string asmstr, list<dag> pattern, InstrItinClass itin> :
            MBlazeInst<outs, ins, asmstr, pattern, itin>
{
  bits<5> ra;
  bits<16> imm16;

  let opcode = op;

  let Inst{6-10}  = br;
  let Inst{11-15} = ra; 
  let Inst{16-31} = imm16;
}

class TRET<bits<6> op, dag outs, dag ins,
            string asmstr, list<dag> pattern, InstrItinClass itin> :
            MBlazeInst<outs, ins, asmstr, pattern, itin>
{
  bits<5>  ra;
  bits<16> imm16;

  let opcode = op;

  let Inst{6-10}  = 0x10;
  let Inst{11-15} = ra; 
  let Inst{16-31} = imm16;
}