xref: /freebsd-src/contrib/llvm-project/llvm/lib/Target/VE/VEInstrFormats.td (revision 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e)
1480093f4SDimitry Andric//===-- VEInstrFormats.td - VE Instruction Formats ---------*- tablegen -*-===//
2480093f4SDimitry Andric//
3480093f4SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4480093f4SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
5480093f4SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6480093f4SDimitry Andric//
7480093f4SDimitry Andric//===----------------------------------------------------------------------===//
8480093f4SDimitry Andric
95ffd83dbSDimitry Andric// SX-Aurora uses little endian, but instructions are encoded little bit
105ffd83dbSDimitry Andric// different manner.  Therefore, we need to tranlate the address of each
115ffd83dbSDimitry Andric// bitfield described in ISA documentation like below.
125ffd83dbSDimitry Andric//
135ffd83dbSDimitry Andric// ISA   |  InstrFormats.td
145ffd83dbSDimitry Andric// ---------------------------
155ffd83dbSDimitry Andric// 0-7   => 63-56
165ffd83dbSDimitry Andric// 8     => 55
175ffd83dbSDimitry Andric// 32-63 => 31-0
185ffd83dbSDimitry Andric
195ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
205ffd83dbSDimitry Andric// Instruction Format
215ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
225ffd83dbSDimitry Andric
23480093f4SDimitry Andricclass InstVE<dag outs, dag ins, string asmstr, list<dag> pattern>
24480093f4SDimitry Andric   : Instruction {
25480093f4SDimitry Andric  field bits<64> Inst;
26480093f4SDimitry Andric
27480093f4SDimitry Andric  let Namespace = "VE";
28480093f4SDimitry Andric  let Size = 8;
29480093f4SDimitry Andric
30480093f4SDimitry Andric  bits<8> op;
315ffd83dbSDimitry Andric  let Inst{63-56} = op;
32480093f4SDimitry Andric
33480093f4SDimitry Andric  dag OutOperandList = outs;
34480093f4SDimitry Andric  dag InOperandList = ins;
35480093f4SDimitry Andric  let AsmString   = asmstr;
36480093f4SDimitry Andric  let Pattern = pattern;
37480093f4SDimitry Andric
38e8d8bef9SDimitry Andric  bits<1> VE_Vector = 0;
39e8d8bef9SDimitry Andric  bits<1> VE_VLInUse = 0;
40e8d8bef9SDimitry Andric  bits<3> VE_VLIndex = 0;
41e8d8bef9SDimitry Andric  bits<1> VE_VLWithMask = 0;
42e8d8bef9SDimitry Andric
43e8d8bef9SDimitry Andric  /// These fields correspond to the fields in VEInstrInfo.h.  Any changes to
44e8d8bef9SDimitry Andric  /// these must be reflected there!  See comments there for what these are.
45e8d8bef9SDimitry Andric  ///
46e8d8bef9SDimitry Andric  /// VLIndex is the index of VL register in MI's operands.  The HW instruction
47e8d8bef9SDimitry Andric  /// doesn't have that field, but we add is in MI for the ease of optimization.
48e8d8bef9SDimitry Andric  /// For example, the index of VL of (VST $sy, $sz, $sx, $vl) is 3 (beginning
49e8d8bef9SDimitry Andric  /// from 0), and the index of VL of (VST $sy, $sz, $sx, $vm, $vl) is 4.  We
50e8d8bef9SDimitry Andric  /// define vector instructions hierarchically, so use VE_VLIndex which is
51e8d8bef9SDimitry Andric  /// defined by the type of instruction and VE_VLWithMask which is defined
52e8d8bef9SDimitry Andric  /// whether the insturction use mask or not.
53e8d8bef9SDimitry Andric  let TSFlags{0}   = VE_Vector;
54e8d8bef9SDimitry Andric  let TSFlags{1}   = VE_VLInUse;
55e8d8bef9SDimitry Andric  let TSFlags{4-2} = !add(VE_VLIndex, VE_VLWithMask);
56e8d8bef9SDimitry Andric
57480093f4SDimitry Andric  let DecoderNamespace = "VE";
58480093f4SDimitry Andric  field bits<64> SoftFail = 0;
59480093f4SDimitry Andric}
60480093f4SDimitry Andric
615ffd83dbSDimitry Andric//-----------------------------------------------------------------------------
625ffd83dbSDimitry Andric// Section 5.1 RM Type
635ffd83dbSDimitry Andric//
645ffd83dbSDimitry Andric// RM type has sx, sy, sz, and imm32.
655ffd83dbSDimitry Andric// The effective address is generated by sz + sy + imm32.
665ffd83dbSDimitry Andric//-----------------------------------------------------------------------------
675ffd83dbSDimitry Andric
68480093f4SDimitry Andricclass RM<bits<8>opVal, dag outs, dag ins, string asmstr, list<dag> pattern = []>
69480093f4SDimitry Andric   : InstVE<outs, ins, asmstr, pattern> {
70480093f4SDimitry Andric  bits<1>  cx = 0;
71480093f4SDimitry Andric  bits<7>  sx;
725ffd83dbSDimitry Andric  bits<1>  cy = 1;
735ffd83dbSDimitry Andric  bits<7>  sz;      // defines sz prior to sy to assign from sz
74480093f4SDimitry Andric  bits<7>  sy;
755ffd83dbSDimitry Andric  bits<1>  cz = 1;
765ffd83dbSDimitry Andric  bits<32> imm32;
77480093f4SDimitry Andric  let op = opVal;
785ffd83dbSDimitry Andric  let Inst{55} = cx;
795ffd83dbSDimitry Andric  let Inst{54-48} = sx;
805ffd83dbSDimitry Andric  let Inst{47} = cy;
815ffd83dbSDimitry Andric  let Inst{46-40} = sy;
825ffd83dbSDimitry Andric  let Inst{39} = cz;
835ffd83dbSDimitry Andric  let Inst{38-32} = sz;
845ffd83dbSDimitry Andric  let Inst{31-0}  = imm32;
85480093f4SDimitry Andric}
86480093f4SDimitry Andric
875ffd83dbSDimitry Andric//-----------------------------------------------------------------------------
885ffd83dbSDimitry Andric// Section 5.2 RRM Type
895ffd83dbSDimitry Andric//
905ffd83dbSDimitry Andric// RRM type is identical to RM, but the effective address is generated
915ffd83dbSDimitry Andric// by sz + imm32.  The sy field is used by other purposes.
925ffd83dbSDimitry Andric//-----------------------------------------------------------------------------
935ffd83dbSDimitry Andric
945ffd83dbSDimitry Andricclass RRM<bits<8>opVal, dag outs, dag ins, string asmstr,
955ffd83dbSDimitry Andric          list<dag> pattern = []>
965ffd83dbSDimitry Andric   : RM<opVal, outs, ins, asmstr, pattern>;
975ffd83dbSDimitry Andric
985ffd83dbSDimitry Andric// RRMHM type is to load/store host memory
995ffd83dbSDimitry Andric// It is similar to RRM and not use sy.
1005ffd83dbSDimitry Andricclass RRMHM<bits<8>opVal, dag outs, dag ins, string asmstr,
1015ffd83dbSDimitry Andric            list<dag> pattern = []>
1025ffd83dbSDimitry Andric   : RRM<opVal, outs, ins, asmstr, pattern> {
1035ffd83dbSDimitry Andric  bits<2> ry = 0;
1045ffd83dbSDimitry Andric  let cy = 0;
1055ffd83dbSDimitry Andric  let sy{6-2} = 0;
1065ffd83dbSDimitry Andric  let sy{1-0} = ry;
1075ffd83dbSDimitry Andric}
1085ffd83dbSDimitry Andric
1095ffd83dbSDimitry Andric//-----------------------------------------------------------------------------
1105ffd83dbSDimitry Andric// Section 5.3 CF Type
1115ffd83dbSDimitry Andric//
1125ffd83dbSDimitry Andric// CF type is used for control flow.
1135ffd83dbSDimitry Andric//-----------------------------------------------------------------------------
1145ffd83dbSDimitry Andric
1155ffd83dbSDimitry Andricclass CF<bits<8>opVal, dag outs, dag ins, string asmstr, list<dag> pattern = []>
1165ffd83dbSDimitry Andric   : InstVE<outs, ins, asmstr, pattern> {
1175ffd83dbSDimitry Andric  bits<1>  cx = 0;
1185ffd83dbSDimitry Andric  bits<1>  cx2 = 0;
1195ffd83dbSDimitry Andric  bits<2>  bpf = 0;
120*06c3fb27SDimitry Andric  bits<4>  cond;
1215ffd83dbSDimitry Andric  bits<1>  cy = 1;
1225ffd83dbSDimitry Andric  bits<7>  sy;
1235ffd83dbSDimitry Andric  bits<1>  cz = 1;
1245ffd83dbSDimitry Andric  bits<7>  sz;
1255ffd83dbSDimitry Andric  bits<32> imm32;
1265ffd83dbSDimitry Andric  let op = opVal;
1275ffd83dbSDimitry Andric  let Inst{55} = cx;
1285ffd83dbSDimitry Andric  let Inst{54} = cx2;
1295ffd83dbSDimitry Andric  let Inst{53-52} = bpf;
130*06c3fb27SDimitry Andric  let Inst{51-48} = cond;
1315ffd83dbSDimitry Andric  let Inst{47} = cy;
1325ffd83dbSDimitry Andric  let Inst{46-40} = sy;
1335ffd83dbSDimitry Andric  let Inst{39} = cz;
1345ffd83dbSDimitry Andric  let Inst{38-32} = sz;
1355ffd83dbSDimitry Andric  let Inst{31-0}  = imm32;
1365ffd83dbSDimitry Andric}
1375ffd83dbSDimitry Andric
1385ffd83dbSDimitry Andric//-----------------------------------------------------------------------------
1395ffd83dbSDimitry Andric// Section 5.4 RR Type
1405ffd83dbSDimitry Andric//
1415ffd83dbSDimitry Andric// RR type is for generic arithmetic instructions.
1425ffd83dbSDimitry Andric//-----------------------------------------------------------------------------
1435ffd83dbSDimitry Andric
1445ffd83dbSDimitry Andricclass RR<bits<8>opVal, dag outs, dag ins, string asmstr, list<dag> pattern = []>
1455ffd83dbSDimitry Andric   : InstVE<outs, ins, asmstr, pattern> {
1465ffd83dbSDimitry Andric  bits<1>  cx = 0;
1475ffd83dbSDimitry Andric  bits<7>  sx;
1485ffd83dbSDimitry Andric  bits<1>  cy = 1;
1495ffd83dbSDimitry Andric  bits<7>  sy;
1505ffd83dbSDimitry Andric  bits<1>  cz = 1;
1515ffd83dbSDimitry Andric  bits<7>  sz;          // m field places at the top sz field
1525ffd83dbSDimitry Andric  bits<8>  vx = 0;
1535ffd83dbSDimitry Andric  bits<8>  vz = 0;
154480093f4SDimitry Andric  bits<1> cw = 0;
155480093f4SDimitry Andric  bits<1> cw2 = 0;
156480093f4SDimitry Andric  bits<4> cfw = 0;
1575ffd83dbSDimitry Andric  let op = opVal;
1585ffd83dbSDimitry Andric  let Inst{55} = cx;
1595ffd83dbSDimitry Andric  let Inst{54-48} = sx;
1605ffd83dbSDimitry Andric  let Inst{47} = cy;
1615ffd83dbSDimitry Andric  let Inst{46-40} = sy;
1625ffd83dbSDimitry Andric  let Inst{39} = cz;
1635ffd83dbSDimitry Andric  let Inst{38-32} = sz;
1645ffd83dbSDimitry Andric  let Inst{31-24} = vx;
1655ffd83dbSDimitry Andric  let Inst{23-16} = 0;
1665ffd83dbSDimitry Andric  let Inst{15-8} = vz;
1675ffd83dbSDimitry Andric  let Inst{7} = cw;
1685ffd83dbSDimitry Andric  let Inst{6} = cw2;
1695ffd83dbSDimitry Andric  let Inst{5-4} = 0;
1705ffd83dbSDimitry Andric  let Inst{3-0} = cfw;
171480093f4SDimitry Andric}
172480093f4SDimitry Andric
1735ffd83dbSDimitry Andric// RRFENCE type is special RR type for a FENCE instruction.
1745ffd83dbSDimitry Andricclass RRFENCE<bits<8>opVal, dag outs, dag ins, string asmstr,
1755ffd83dbSDimitry Andric              list<dag> pattern = []>
1765ffd83dbSDimitry Andric   : InstVE<outs, ins, asmstr, pattern> {
1775ffd83dbSDimitry Andric  bits<1> avo = 0;
1785ffd83dbSDimitry Andric  bits<1> lf = 0;
1795ffd83dbSDimitry Andric  bits<1> sf = 0;
1805ffd83dbSDimitry Andric  bits<1> c2 = 0;
1815ffd83dbSDimitry Andric  bits<1> c1 = 0;
1825ffd83dbSDimitry Andric  bits<1> c0 = 0;
1835ffd83dbSDimitry Andric  let op = opVal;
1845ffd83dbSDimitry Andric  let Inst{55} = avo;
1855ffd83dbSDimitry Andric  let Inst{54-50} = 0;
1865ffd83dbSDimitry Andric  let Inst{49} = lf;
1875ffd83dbSDimitry Andric  let Inst{48} = sf;
1885ffd83dbSDimitry Andric  let Inst{47-43} = 0;
1895ffd83dbSDimitry Andric  let Inst{42} = c2;
1905ffd83dbSDimitry Andric  let Inst{41} = c1;
1915ffd83dbSDimitry Andric  let Inst{40} = c0;
1925ffd83dbSDimitry Andric  let Inst{39-0} = 0;
193480093f4SDimitry Andric}
194480093f4SDimitry Andric
1955ffd83dbSDimitry Andric//-----------------------------------------------------------------------------
1965ffd83dbSDimitry Andric// Section 5.5 RW Type
1975ffd83dbSDimitry Andric//-----------------------------------------------------------------------------
1985ffd83dbSDimitry Andric
1995ffd83dbSDimitry Andric//-----------------------------------------------------------------------------
2005ffd83dbSDimitry Andric// Section 5.6 RVM Type
201e8d8bef9SDimitry Andric//
202e8d8bef9SDimitry Andric// RVM type is for vector transfer instructions.
2035ffd83dbSDimitry Andric//-----------------------------------------------------------------------------
2045ffd83dbSDimitry Andric
205e8d8bef9SDimitry Andricclass RVM<bits<8>opVal, dag outs, dag ins, string asmstr,
206e8d8bef9SDimitry Andric          list<dag> pattern = []>
207e8d8bef9SDimitry Andric   : InstVE<outs, ins, asmstr, pattern> {
208e8d8bef9SDimitry Andric  bits<1>  cx = 0;
209e8d8bef9SDimitry Andric  bits<1>  vc = 0;
210e8d8bef9SDimitry Andric  bits<1>  cs = 0;
211e8d8bef9SDimitry Andric  bits<4>  m = 0;
212e8d8bef9SDimitry Andric  bits<1>  cy = 1;
213e8d8bef9SDimitry Andric  bits<7>  sy;
214e8d8bef9SDimitry Andric  bits<1>  cz = 1;
215e8d8bef9SDimitry Andric  bits<7>  sz;
216e8d8bef9SDimitry Andric  bits<8>  vx;
217e8d8bef9SDimitry Andric  bits<8>  vy = 0;
218e8d8bef9SDimitry Andric  bits<7>  sw = 0;
219e8d8bef9SDimitry Andric  let op = opVal;
220e8d8bef9SDimitry Andric  let Inst{55} = cx;
221e8d8bef9SDimitry Andric  let Inst{54} = vc;
222e8d8bef9SDimitry Andric  let Inst{53} = cs;
223e8d8bef9SDimitry Andric  let Inst{52} = 0;
224e8d8bef9SDimitry Andric  let Inst{51-48} = m;
225e8d8bef9SDimitry Andric  let Inst{47} = cy;
226e8d8bef9SDimitry Andric  let Inst{46-40} = sy;
227e8d8bef9SDimitry Andric  let Inst{39} = cz;
228e8d8bef9SDimitry Andric  let Inst{38-32} = sz;
229e8d8bef9SDimitry Andric  let Inst{31-24} = vx;
230e8d8bef9SDimitry Andric  let Inst{23-16} = vy;
231e8d8bef9SDimitry Andric  let Inst{15-8} = 0;
232e8d8bef9SDimitry Andric  let Inst{7} = 0;
233e8d8bef9SDimitry Andric  let Inst{6-0} = sw;
234e8d8bef9SDimitry Andric
235e8d8bef9SDimitry Andric  let VE_Vector = 1;
236e8d8bef9SDimitry Andric}
237e8d8bef9SDimitry Andric
2385ffd83dbSDimitry Andric//-----------------------------------------------------------------------------
2395ffd83dbSDimitry Andric// Section 5.7 RV Type
240e8d8bef9SDimitry Andric//
241e8d8bef9SDimitry Andric// RV type is for vector instructions.
2425ffd83dbSDimitry Andric//-----------------------------------------------------------------------------
2435ffd83dbSDimitry Andric
244e8d8bef9SDimitry Andricclass RV<bits<8>opVal, dag outs, dag ins, string asmstr, list<dag> pattern = []>
245e8d8bef9SDimitry Andric   : InstVE<outs, ins, asmstr, pattern> {
246e8d8bef9SDimitry Andric  bits<1>  cx = 0;
247e8d8bef9SDimitry Andric  bits<1>  cx2 = 0;
248e8d8bef9SDimitry Andric  bits<1>  cs = 0;
249e8d8bef9SDimitry Andric  bits<1>  cs2 = 0;
250e8d8bef9SDimitry Andric  bits<4>  m = 0;
251e8d8bef9SDimitry Andric  bits<1>  cy = 1;
252e8d8bef9SDimitry Andric  bits<7>  sy;
253e8d8bef9SDimitry Andric  bits<1>  cz = 0;
254e8d8bef9SDimitry Andric  bits<7>  sz = 0;
255e8d8bef9SDimitry Andric  bits<8>  vx = 0;
256e8d8bef9SDimitry Andric  bits<8>  vy = 0;
257e8d8bef9SDimitry Andric  bits<8>  vz = 0;
258e8d8bef9SDimitry Andric  bits<8>  vw = 0;
259e8d8bef9SDimitry Andric  let op = opVal;
260e8d8bef9SDimitry Andric  let Inst{55} = cx;
261e8d8bef9SDimitry Andric  let Inst{54} = cx2;
262e8d8bef9SDimitry Andric  let Inst{53} = cs;
263e8d8bef9SDimitry Andric  let Inst{52} = cs2;
264e8d8bef9SDimitry Andric  let Inst{51-48} = m;
265e8d8bef9SDimitry Andric  let Inst{47} = cy;
266e8d8bef9SDimitry Andric  let Inst{46-40} = sy;
267e8d8bef9SDimitry Andric  let Inst{39} = cz;
268e8d8bef9SDimitry Andric  let Inst{38-32} = sz;
269e8d8bef9SDimitry Andric  let Inst{31-24} = vx;
270e8d8bef9SDimitry Andric  let Inst{23-16} = vy;
271e8d8bef9SDimitry Andric  let Inst{15-8} = vz;
272e8d8bef9SDimitry Andric  let Inst{7-0} = vw;
273e8d8bef9SDimitry Andric
274e8d8bef9SDimitry Andric  let VE_Vector = 1;
275e8d8bef9SDimitry Andric}
276e8d8bef9SDimitry Andric
277480093f4SDimitry Andric// Pseudo instructions.
278480093f4SDimitry Andricclass Pseudo<dag outs, dag ins, string asmstr, list<dag> pattern = []>
279480093f4SDimitry Andric   : InstVE<outs, ins, asmstr, pattern> {
280480093f4SDimitry Andric  let isCodeGenOnly = 1;
281480093f4SDimitry Andric  let isPseudo = 1;
282480093f4SDimitry Andric}
283