aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/VE/VEInstrFormats.td
blob: a2d2ae929dbdc238b0319d2d33ae082262e853a0 (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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
//===-- VEInstrFormats.td - VE Instruction Formats ---------*- tablegen -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

// SX-Aurora uses little endian, but instructions are encoded little bit
// different manner.  Therefore, we need to tranlate the address of each
// bitfield described in ISA documentation like below.
//
// ISA   |  InstrFormats.td
// ---------------------------
// 0-7   => 63-56
// 8     => 55
// 32-63 => 31-0

//===----------------------------------------------------------------------===//
// Instruction Format
//===----------------------------------------------------------------------===//

class InstVE<dag outs, dag ins, string asmstr, list<dag> pattern>
   : Instruction {
  field bits<64> Inst;

  let Namespace = "VE";
  let Size = 8;

  bits<8> op;
  let Inst{63-56} = op;

  dag OutOperandList = outs;
  dag InOperandList = ins;
  let AsmString   = asmstr;
  let Pattern = pattern;

  bits<1> VE_Vector = 0;
  bits<1> VE_VLInUse = 0;
  bits<3> VE_VLIndex = 0;
  bits<1> VE_VLWithMask = 0;

  /// These fields correspond to the fields in VEInstrInfo.h.  Any changes to
  /// these must be reflected there!  See comments there for what these are.
  ///
  /// VLIndex is the index of VL register in MI's operands.  The HW instruction
  /// doesn't have that field, but we add is in MI for the ease of optimization.
  /// For example, the index of VL of (VST $sy, $sz, $sx, $vl) is 3 (beginning
  /// from 0), and the index of VL of (VST $sy, $sz, $sx, $vm, $vl) is 4.  We
  /// define vector instructions hierarchically, so use VE_VLIndex which is
  /// defined by the type of instruction and VE_VLWithMask which is defined
  /// whether the insturction use mask or not.
  let TSFlags{0}   = VE_Vector;
  let TSFlags{1}   = VE_VLInUse;
  let TSFlags{4-2} = !add(VE_VLIndex, VE_VLWithMask);

  let DecoderNamespace = "VE";
  field bits<64> SoftFail = 0;
}

//-----------------------------------------------------------------------------
// Section 5.1 RM Type
//
// RM type has sx, sy, sz, and imm32.
// The effective address is generated by sz + sy + imm32.
//-----------------------------------------------------------------------------

class RM<bits<8>opVal, dag outs, dag ins, string asmstr, list<dag> pattern = []>
   : InstVE<outs, ins, asmstr, pattern> {
  bits<1>  cx = 0;
  bits<7>  sx;
  bits<1>  cy = 1;
  bits<7>  sz;      // defines sz prior to sy to assign from sz
  bits<7>  sy;
  bits<1>  cz = 1;
  bits<32> imm32;
  let op = opVal;
  let Inst{55} = cx;
  let Inst{54-48} = sx;
  let Inst{47} = cy;
  let Inst{46-40} = sy;
  let Inst{39} = cz;
  let Inst{38-32} = sz;
  let Inst{31-0}  = imm32;
}

//-----------------------------------------------------------------------------
// Section 5.2 RRM Type
//
// RRM type is identical to RM, but the effective address is generated
// by sz + imm32.  The sy field is used by other purposes.
//-----------------------------------------------------------------------------

class RRM<bits<8>opVal, dag outs, dag ins, string asmstr,
          list<dag> pattern = []>
   : RM<opVal, outs, ins, asmstr, pattern>;

// RRMHM type is to load/store host memory
// It is similar to RRM and not use sy.
class RRMHM<bits<8>opVal, dag outs, dag ins, string asmstr,
            list<dag> pattern = []>
   : RRM<opVal, outs, ins, asmstr, pattern> {
  bits<2> ry = 0;
  let cy = 0;
  let sy{6-2} = 0;
  let sy{1-0} = ry;
}

//-----------------------------------------------------------------------------
// Section 5.3 CF Type
//
// CF type is used for control flow.
//-----------------------------------------------------------------------------

class CF<bits<8>opVal, dag outs, dag ins, string asmstr, list<dag> pattern = []>
   : InstVE<outs, ins, asmstr, pattern> {
  bits<1>  cx = 0;
  bits<1>  cx2 = 0;
  bits<2>  bpf = 0;
  bits<4>  cond;
  bits<1>  cy = 1;
  bits<7>  sy;
  bits<1>  cz = 1;
  bits<7>  sz;
  bits<32> imm32;
  let op = opVal;
  let Inst{55} = cx;
  let Inst{54} = cx2;
  let Inst{53-52} = bpf;
  let Inst{51-48} = cond;
  let Inst{47} = cy;
  let Inst{46-40} = sy;
  let Inst{39} = cz;
  let Inst{38-32} = sz;
  let Inst{31-0}  = imm32;
}

//-----------------------------------------------------------------------------
// Section 5.4 RR Type
//
// RR type is for generic arithmetic instructions.
//-----------------------------------------------------------------------------

class RR<bits<8>opVal, dag outs, dag ins, string asmstr, list<dag> pattern = []>
   : InstVE<outs, ins, asmstr, pattern> {
  bits<1>  cx = 0;
  bits<7>  sx;
  bits<1>  cy = 1;
  bits<7>  sy;
  bits<1>  cz = 1;
  bits<7>  sz;          // m field places at the top sz field
  bits<8>  vx = 0;
  bits<8>  vz = 0;
  bits<1> cw = 0;
  bits<1> cw2 = 0;
  bits<4> cfw = 0;
  let op = opVal;
  let Inst{55} = cx;
  let Inst{54-48} = sx;
  let Inst{47} = cy;
  let Inst{46-40} = sy;
  let Inst{39} = cz;
  let Inst{38-32} = sz;
  let Inst{31-24} = vx;
  let Inst{23-16} = 0;
  let Inst{15-8} = vz;
  let Inst{7} = cw;
  let Inst{6} = cw2;
  let Inst{5-4} = 0;
  let Inst{3-0} = cfw;
}

// RRFENCE type is special RR type for a FENCE instruction.
class RRFENCE<bits<8>opVal, dag outs, dag ins, string asmstr,
              list<dag> pattern = []>
   : InstVE<outs, ins, asmstr, pattern> {
  bits<1> avo = 0;
  bits<1> lf = 0;
  bits<1> sf = 0;
  bits<1> c2 = 0;
  bits<1> c1 = 0;
  bits<1> c0 = 0;
  let op = opVal;
  let Inst{55} = avo;
  let Inst{54-50} = 0;
  let Inst{49} = lf;
  let Inst{48} = sf;
  let Inst{47-43} = 0;
  let Inst{42} = c2;
  let Inst{41} = c1;
  let Inst{40} = c0;
  let Inst{39-0} = 0;
}

//-----------------------------------------------------------------------------
// Section 5.5 RW Type
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// Section 5.6 RVM Type
//
// RVM type is for vector transfer instructions.
//-----------------------------------------------------------------------------

class RVM<bits<8>opVal, dag outs, dag ins, string asmstr,
          list<dag> pattern = []>
   : InstVE<outs, ins, asmstr, pattern> {
  bits<1>  cx = 0;
  bits<1>  vc = 0;
  bits<1>  cs = 0;
  bits<4>  m = 0;
  bits<1>  cy = 1;
  bits<7>  sy;
  bits<1>  cz = 1;
  bits<7>  sz;
  bits<8>  vx;
  bits<8>  vy = 0;
  bits<7>  sw = 0;
  let op = opVal;
  let Inst{55} = cx;
  let Inst{54} = vc;
  let Inst{53} = cs;
  let Inst{52} = 0;
  let Inst{51-48} = m;
  let Inst{47} = cy;
  let Inst{46-40} = sy;
  let Inst{39} = cz;
  let Inst{38-32} = sz;
  let Inst{31-24} = vx;
  let Inst{23-16} = vy;
  let Inst{15-8} = 0;
  let Inst{7} = 0;
  let Inst{6-0} = sw;

  let VE_Vector = 1;
}

//-----------------------------------------------------------------------------
// Section 5.7 RV Type
//
// RV type is for vector instructions.
//-----------------------------------------------------------------------------

class RV<bits<8>opVal, dag outs, dag ins, string asmstr, list<dag> pattern = []>
   : InstVE<outs, ins, asmstr, pattern> {
  bits<1>  cx = 0;
  bits<1>  cx2 = 0;
  bits<1>  cs = 0;
  bits<1>  cs2 = 0;
  bits<4>  m = 0;
  bits<1>  cy = 1;
  bits<7>  sy;
  bits<1>  cz = 0;
  bits<7>  sz = 0;
  bits<8>  vx = 0;
  bits<8>  vy = 0;
  bits<8>  vz = 0;
  bits<8>  vw = 0;
  let op = opVal;
  let Inst{55} = cx;
  let Inst{54} = cx2;
  let Inst{53} = cs;
  let Inst{52} = cs2;
  let Inst{51-48} = m;
  let Inst{47} = cy;
  let Inst{46-40} = sy;
  let Inst{39} = cz;
  let Inst{38-32} = sz;
  let Inst{31-24} = vx;
  let Inst{23-16} = vy;
  let Inst{15-8} = vz;
  let Inst{7-0} = vw;

  let VE_Vector = 1;
}

// Pseudo instructions.
class Pseudo<dag outs, dag ins, string asmstr, list<dag> pattern = []>
   : InstVE<outs, ins, asmstr, pattern> {
  let isCodeGenOnly = 1;
  let isPseudo = 1;
}