xref: /freebsd/contrib/llvm-project/llvm/lib/Target/VE/VERegisterInfo.td (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
1480093f4SDimitry Andric//===-- VERegisterInfo.td - VE Register defs ---------------*- 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
9480093f4SDimitry Andric//===----------------------------------------------------------------------===//
10480093f4SDimitry Andric//  Declarations that describe the VE register file
11480093f4SDimitry Andric//===----------------------------------------------------------------------===//
12480093f4SDimitry Andric
135ffd83dbSDimitry Andricclass VEReg<bits<7> enc, string n, list<Register> subregs = [],
145ffd83dbSDimitry Andric            list<string> altNames = [], list<Register> aliases = []>
155ffd83dbSDimitry Andric        : Register<n, altNames> {
16480093f4SDimitry Andric  let HWEncoding{15-7} = 0;
175ffd83dbSDimitry Andric  let HWEncoding{6-0} = enc;
18480093f4SDimitry Andric  let Namespace = "VE";
19480093f4SDimitry Andric  let SubRegs = subregs;
20480093f4SDimitry Andric  let Aliases = aliases;
21480093f4SDimitry Andric}
22480093f4SDimitry Andric
235ffd83dbSDimitry Andricclass VEMiscReg<bits<6> enc, string n>: Register<n> {
245ffd83dbSDimitry Andric  let HWEncoding{15-6} = 0;
255ffd83dbSDimitry Andric  let HWEncoding{5-0} = enc;
265ffd83dbSDimitry Andric  let Namespace = "VE";
275ffd83dbSDimitry Andric}
285ffd83dbSDimitry Andric
29e8d8bef9SDimitry Andricclass VEVecReg<bits<8> enc, string n, list<Register> subregs = [],
30e8d8bef9SDimitry Andric               list<string> altNames = [], list<Register> aliases = []>
31e8d8bef9SDimitry Andric        : Register<n, altNames> {
32e8d8bef9SDimitry Andric  let HWEncoding{15-8} = 0;
33e8d8bef9SDimitry Andric  let HWEncoding{7-0} = enc;
34e8d8bef9SDimitry Andric  let Namespace = "VE";
35e8d8bef9SDimitry Andric  let SubRegs = subregs;
36e8d8bef9SDimitry Andric  let Aliases = aliases;
37e8d8bef9SDimitry Andric}
38e8d8bef9SDimitry Andric
39e8d8bef9SDimitry Andricclass VEMaskReg<bits<4> enc, string n, list<Register> subregs = [],
40e8d8bef9SDimitry Andric                list<string> altNames = [], list<Register> aliases = []>
41e8d8bef9SDimitry Andric        : Register<n, altNames> {
42e8d8bef9SDimitry Andric  let HWEncoding{15-4} = 0;
43e8d8bef9SDimitry Andric  let HWEncoding{3-0} = enc;
44e8d8bef9SDimitry Andric  let Namespace = "VE";
45e8d8bef9SDimitry Andric  let SubRegs = subregs;
46e8d8bef9SDimitry Andric  let Aliases = aliases;
47e8d8bef9SDimitry Andric}
48e8d8bef9SDimitry Andric
495ffd83dbSDimitry Andriclet Namespace = "VE" in {
505ffd83dbSDimitry Andric  def sub_i32     : SubRegIndex<32, 32>;        // Low 32 bit (32..63)
515ffd83dbSDimitry Andric  def sub_f32     : SubRegIndex<32>;            // High 32 bit (0..31)
525ffd83dbSDimitry Andric  def sub_even    : SubRegIndex<64>;            // High 64 bit (0..63)
535ffd83dbSDimitry Andric  def sub_odd     : SubRegIndex<64, 64>;        // Low 64 bit (64..127)
54e8d8bef9SDimitry Andric  def sub_vm_even : SubRegIndex<256>;           // High 256 bit (0..255)
55e8d8bef9SDimitry Andric  def sub_vm_odd  : SubRegIndex<256, 256>;      // Low 256 bit (256..511)
565ffd83dbSDimitry Andric  def AsmName     : RegAltNameIndex;
575ffd83dbSDimitry Andric}
585ffd83dbSDimitry Andric
595ffd83dbSDimitry Andric//-----------------------------------------------------------------------------
605ffd83dbSDimitry Andric// Miscellaneous Registers
615ffd83dbSDimitry Andric//-----------------------------------------------------------------------------
625ffd83dbSDimitry Andric
635ffd83dbSDimitry Andricdef USRCC : VEMiscReg<0, "usrcc">;      // User clock counter
645ffd83dbSDimitry Andricdef PSW : VEMiscReg<1, "psw">;          // Program status word
655ffd83dbSDimitry Andricdef SAR : VEMiscReg<2, "sar">;          // Store address register
665ffd83dbSDimitry Andricdef PMMR : VEMiscReg<7, "pmmr">;        // Performance monitor mode register
675ffd83dbSDimitry Andric
685ffd83dbSDimitry Andric// Performance monitor configuration registers
695ffd83dbSDimitry Andricforeach I = 0-3 in
705ffd83dbSDimitry Andric  def PMCR#I : VEMiscReg<!add(8,I), "pmcr"#I>;
715ffd83dbSDimitry Andric
725ffd83dbSDimitry Andric// Performance monitor counter
735ffd83dbSDimitry Andricforeach I = 0-14 in
745ffd83dbSDimitry Andric  def PMC#I : VEMiscReg<!add(16,I), "pmc"#I>;
755ffd83dbSDimitry Andric
765ffd83dbSDimitry Andric// Register classes.
775ffd83dbSDimitry Andricdef MISC : RegisterClass<"VE", [i64], 64,
785ffd83dbSDimitry Andric                         (add USRCC, PSW, SAR, PMMR,
795ffd83dbSDimitry Andric                              (sequence "PMCR%u", 0, 3),
805ffd83dbSDimitry Andric                              (sequence "PMC%u", 0, 14))>;
815ffd83dbSDimitry Andric
825ffd83dbSDimitry Andric//-----------------------------------------------------------------------------
835ffd83dbSDimitry Andric// Instruction Counter Register
845ffd83dbSDimitry Andric//-----------------------------------------------------------------------------
855ffd83dbSDimitry Andric
865ffd83dbSDimitry Andricdef IC : VEMiscReg<62, "ic">;
875ffd83dbSDimitry Andric
885ffd83dbSDimitry Andric//-----------------------------------------------------------------------------
89e8d8bef9SDimitry Andric// Vector Length Register
90e8d8bef9SDimitry Andric//-----------------------------------------------------------------------------
91e8d8bef9SDimitry Andric
92e8d8bef9SDimitry Andricdef VL : VEMiscReg<63, "vl">;
93e8d8bef9SDimitry Andric
94e8d8bef9SDimitry Andric// Register classes.
95e8d8bef9SDimitry Andricdef VLS : RegisterClass<"VE", [i32], 64, (add VL)>;
96e8d8bef9SDimitry Andric
97e8d8bef9SDimitry Andric//-----------------------------------------------------------------------------
98e8d8bef9SDimitry Andric// Generic Registers
995ffd83dbSDimitry Andric//-----------------------------------------------------------------------------
1005ffd83dbSDimitry Andric
1015ffd83dbSDimitry Andriclet RegAltNameIndices = [AsmName] in {
1025ffd83dbSDimitry Andric
1035ffd83dbSDimitry Andric// Generic integer registers - 32 bits wide
1045ffd83dbSDimitry Andricforeach I = 0-63 in
105e8d8bef9SDimitry Andric  def SW#I : VEReg<I, "sw"#I, [], ["s"#I]>, DwarfRegNum<[I]>;
1065ffd83dbSDimitry Andric
1075ffd83dbSDimitry Andric// Generic floating point registers - 32 bits wide
1085ffd83dbSDimitry Andric//   NOTE: Mark SF#I as alias of SW#I temporary to avoid register allocation
1095ffd83dbSDimitry Andric//         problem.
1105ffd83dbSDimitry Andricforeach I = 0-63 in
1115ffd83dbSDimitry Andric  def SF#I : VEReg<I, "sf"#I, [], ["s"#I], [!cast<VEReg>("SW"#I)]>,
1125ffd83dbSDimitry Andric                   DwarfRegNum<[I]>;
1135ffd83dbSDimitry Andric
1145ffd83dbSDimitry Andric// Generic integer registers - 64 bits wide
115e8d8bef9SDimitry Andriclet SubRegIndices = [sub_i32, sub_f32], CoveredBySubRegs = 1 in {
116e8d8bef9SDimitry Andric  // Several registers have specific names, so add them to one of aliases.
117e8d8bef9SDimitry Andric  def SX8 : VEReg<8, "s8", [SW8, SF8], ["s8", "sl"]>, DwarfRegNum<[8]>;
118e8d8bef9SDimitry Andric  def SX9 : VEReg<9, "s9", [SW9, SF9], ["s9", "fp"]>, DwarfRegNum<[9]>;
119e8d8bef9SDimitry Andric  def SX10 : VEReg<10, "s10", [SW10, SF10], ["s10", "lr"]>, DwarfRegNum<[10]>;
120e8d8bef9SDimitry Andric  def SX11 : VEReg<11, "s11", [SW11, SF11], ["s11", "sp"]>, DwarfRegNum<[11]>;
121e8d8bef9SDimitry Andric  def SX14 : VEReg<14, "s14", [SW14, SF14], ["s14", "tp"]>, DwarfRegNum<[14]>;
122e8d8bef9SDimitry Andric  def SX15 : VEReg<15, "s15", [SW15, SF15], ["s15", "got"]>, DwarfRegNum<[15]>;
123e8d8bef9SDimitry Andric  def SX16 : VEReg<16, "s16", [SW16, SF16], ["s16", "plt"]>, DwarfRegNum<[16]>;
124e8d8bef9SDimitry Andric
125e8d8bef9SDimitry Andric  // Other generic registers.
126e8d8bef9SDimitry Andric  foreach I = { 0-7, 12-13, 17-63 } in
1275ffd83dbSDimitry Andric    def SX#I : VEReg<I, "s"#I, [!cast<VEReg>("SW"#I), !cast<VEReg>("SF"#I)],
1285ffd83dbSDimitry Andric                     ["s"#I]>, DwarfRegNum<[I]>;
129e8d8bef9SDimitry Andric}
1305ffd83dbSDimitry Andric
1315ffd83dbSDimitry Andric// Aliases of the S* registers used to hold 128-bit for values (long doubles).
1325ffd83dbSDimitry Andric// Following foreach represents something like:
1335ffd83dbSDimitry Andric//   def Q0 : VEReg<0, "q0", [SX0, SX1], ["s0"]>;
1345ffd83dbSDimitry Andric//   def Q1 : VEReg<2, "q2", [SX2, SX3], ["s2"]>;
1355ffd83dbSDimitry Andric//   ...
1365ffd83dbSDimitry Andriclet SubRegIndices = [sub_even, sub_odd], CoveredBySubRegs = 1 in
1375ffd83dbSDimitry Andricforeach I = 0-31 in
1385ffd83dbSDimitry Andric  def Q#I : VEReg<!shl(I,1), "q"#I,
1395ffd83dbSDimitry Andric                  [!cast<VEReg>("SX"#!shl(I,1)),
1405ffd83dbSDimitry Andric                   !cast<VEReg>("SX"#!add(!shl(I,1),1))],
1415ffd83dbSDimitry Andric                  ["s"#!shl(I,1)]>;
1425ffd83dbSDimitry Andric
143e8d8bef9SDimitry Andric// Vector registers - 64 bits wide 256 elements
144e8d8bef9SDimitry Andricforeach I = 0-63 in
145e8d8bef9SDimitry Andric  def V#I : VEVecReg<I, "v"#I, [], ["v"#I]>, DwarfRegNum<[!add(64,I)]>;
146e8d8bef9SDimitry Andric
147e8d8bef9SDimitry Andric// Vector Index Register
148e8d8bef9SDimitry Andricdef VIX : VEVecReg<255, "vix", [], ["vix"]>;
149e8d8bef9SDimitry Andric
150e8d8bef9SDimitry Andric// Vector mask registers - 256 bits wide
151*bdd1243dSDimitry Andriclet isConstant = true in
152*bdd1243dSDimitry Andricdef VM0 : VEMaskReg<0, "vm0", [], ["vm0"]>, DwarfRegNum<[128]>;
153*bdd1243dSDimitry Andricforeach I = 1-15 in
154e8d8bef9SDimitry Andric  def VM#I : VEMaskReg<I, "vm"#I, [], ["vm"#I]>, DwarfRegNum<[!add(128,I)]>;
155e8d8bef9SDimitry Andric
156e8d8bef9SDimitry Andric// Aliases of VMs to use as a pair of two VM for packed instructions
157*bdd1243dSDimitry Andriclet isConstant = true in
15881ad6265SDimitry Andricdef VMP0 : VEMaskReg<0, "vm0", [], ["vm0"]>;
15981ad6265SDimitry Andric
160e8d8bef9SDimitry Andriclet SubRegIndices = [sub_vm_even, sub_vm_odd], CoveredBySubRegs = 1 in
16181ad6265SDimitry Andricforeach I = 1-7 in
162e8d8bef9SDimitry Andric  def VMP#I : VEMaskReg<!shl(I,1), "vmp"#I,
163e8d8bef9SDimitry Andric                        [!cast<VEMaskReg>("VM"#!shl(I,1)),
164e8d8bef9SDimitry Andric                         !cast<VEMaskReg>("VM"#!add(!shl(I,1),1))],
165e8d8bef9SDimitry Andric                        ["vm"#!shl(I,1)]>;
166e8d8bef9SDimitry Andric
1675ffd83dbSDimitry Andric} // RegAltNameIndices = [AsmName]
1685ffd83dbSDimitry Andric
169480093f4SDimitry Andric// Register classes.
170480093f4SDimitry Andric//
171480093f4SDimitry Andric// The register order is defined in terms of the preferred
172480093f4SDimitry Andric// allocation order.
1735ffd83dbSDimitry Andricdef I32 : RegisterClass<"VE", [i32], 32,
1745ffd83dbSDimitry Andric                        (add (sequence "SW%u", 0, 7),
1755ffd83dbSDimitry Andric                             (sequence "SW%u", 34, 63),
1765ffd83dbSDimitry Andric                             (sequence "SW%u", 8, 33))>;
1775ffd83dbSDimitry Andricdef I64 : RegisterClass<"VE", [i64, f64], 64,
1785ffd83dbSDimitry Andric                        (add (sequence "SX%u", 0, 7),
1795ffd83dbSDimitry Andric                             (sequence "SX%u", 34, 63),
1805ffd83dbSDimitry Andric                             (sequence "SX%u", 8, 33))>;
1815ffd83dbSDimitry Andricdef F32 : RegisterClass<"VE", [f32], 32,
1825ffd83dbSDimitry Andric                        (add (sequence "SF%u", 0, 7),
1835ffd83dbSDimitry Andric                             (sequence "SF%u", 34, 63),
1845ffd83dbSDimitry Andric                             (sequence "SF%u", 8, 33))>;
1855ffd83dbSDimitry Andricdef F128 : RegisterClass<"VE", [f128], 128,
1865ffd83dbSDimitry Andric                        (add (sequence "Q%u", 0, 3),
1875ffd83dbSDimitry Andric                             (sequence "Q%u", 17, 31),
1885ffd83dbSDimitry Andric                             (sequence "Q%u", 4, 16))>;
189e8d8bef9SDimitry Andric
190e8d8bef9SDimitry Andricdef V64 : RegisterClass<"VE",
191e8d8bef9SDimitry Andric                        [v256f64, // default type for vector registers
192e8d8bef9SDimitry Andric                         v512i32, v512f32,
193e8d8bef9SDimitry Andric                         v256i64, v256i32, v256f32, /* v256f64, */], 64,
194e8d8bef9SDimitry Andric                        (add (sequence "V%u", 0, 63),
195e8d8bef9SDimitry Andric                             VIX)>;
196e8d8bef9SDimitry Andric
197e8d8bef9SDimitry Andric// vm0 is reserved for always true
198e8d8bef9SDimitry Andricdef VM : RegisterClass<"VE", [v256i1], 64, (sequence "VM%u", 0, 15)>;
199e8d8bef9SDimitry Andricdef VM512 : RegisterClass<"VE", [v512i1], 64, (sequence "VMP%u", 0, 7)>;
200