1 //===-- VERegisterInfo.td - VE Register defs ---------------*- tablegen -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 //===----------------------------------------------------------------------===//
10 // Declarations that describe the VE register file
11 //===----------------------------------------------------------------------===//
13 class VEReg<bits<7> enc, string n, list<Register> subregs = [],
14 list<string> altNames = [], list<Register> aliases = []>
15 : Register<n, altNames> {
16 let HWEncoding{15-7} = 0;
17 let HWEncoding{6-0} = enc;
19 let SubRegs = subregs;
20 let Aliases = aliases;
23 class VEMiscReg<bits<6> enc, string n>: Register<n> {
24 let HWEncoding{15-6} = 0;
25 let HWEncoding{5-0} = enc;
29 class VEVecReg<bits<8> enc, string n, list<Register> subregs = [],
30 list<string> altNames = [], list<Register> aliases = []>
31 : Register<n, altNames> {
32 let HWEncoding{15-8} = 0;
33 let HWEncoding{7-0} = enc;
35 let SubRegs = subregs;
36 let Aliases = aliases;
39 class VEMaskReg<bits<4> enc, string n, list<Register> subregs = [],
40 list<string> altNames = [], list<Register> aliases = []>
41 : Register<n, altNames> {
42 let HWEncoding{15-4} = 0;
43 let HWEncoding{3-0} = enc;
45 let SubRegs = subregs;
46 let Aliases = aliases;
49 let Namespace = "VE" in {
50 def sub_i32 : SubRegIndex<32, 32>; // Low 32 bit (32..63)
51 def sub_f32 : SubRegIndex<32>; // High 32 bit (0..31)
52 def sub_even : SubRegIndex<64>; // High 64 bit (0..63)
53 def sub_odd : SubRegIndex<64, 64>; // Low 64 bit (64..127)
54 def sub_vm_even : SubRegIndex<256>; // High 256 bit (0..255)
55 def sub_vm_odd : SubRegIndex<256, 256>; // Low 256 bit (256..511)
56 def AsmName : RegAltNameIndex;
59 //-----------------------------------------------------------------------------
60 // Miscellaneous Registers
61 //-----------------------------------------------------------------------------
63 def USRCC : VEMiscReg<0, "usrcc">; // User clock counter
64 def PSW : VEMiscReg<1, "psw">; // Program status word
65 def SAR : VEMiscReg<2, "sar">; // Store address register
66 def PMMR : VEMiscReg<7, "pmmr">; // Performance monitor mode register
68 // Performance monitor configuration registers
70 def PMCR#I : VEMiscReg<!add(8,I), "pmcr"#I>;
72 // Performance monitor counter
74 def PMC#I : VEMiscReg<!add(16,I), "pmc"#I>;
77 def MISC : RegisterClass<"VE", [i64], 64,
78 (add USRCC, PSW, SAR, PMMR,
79 (sequence "PMCR%u", 0, 3),
80 (sequence "PMC%u", 0, 14))>;
82 //-----------------------------------------------------------------------------
83 // Instruction Counter Register
84 //-----------------------------------------------------------------------------
86 def IC : VEMiscReg<62, "ic">;
88 //-----------------------------------------------------------------------------
89 // Vector Length Register
90 //-----------------------------------------------------------------------------
92 def VL : VEMiscReg<63, "vl">;
95 def VLS : RegisterClass<"VE", [i32], 64, (add VL)>;
97 //-----------------------------------------------------------------------------
99 //-----------------------------------------------------------------------------
101 let RegAltNameIndices = [AsmName] in {
103 // Generic integer registers - 32 bits wide
105 def SW#I : VEReg<I, "sw"#I, [], ["s"#I]>, DwarfRegNum<[I]>;
107 // Generic floating point registers - 32 bits wide
108 // NOTE: Mark SF#I as alias of SW#I temporary to avoid register allocation
111 def SF#I : VEReg<I, "sf"#I, [], ["s"#I], [!cast<VEReg>("SW"#I)]>,
114 // Generic integer registers - 64 bits wide
115 let SubRegIndices = [sub_i32, sub_f32], CoveredBySubRegs = 1 in {
116 // Several registers have specific names, so add them to one of aliases.
117 def SX8 : VEReg<8, "s8", [SW8, SF8], ["s8", "sl"]>, DwarfRegNum<[8]>;
118 def SX9 : VEReg<9, "s9", [SW9, SF9], ["s9", "fp"]>, DwarfRegNum<[9]>;
119 def SX10 : VEReg<10, "s10", [SW10, SF10], ["s10", "lr"]>, DwarfRegNum<[10]>;
120 def SX11 : VEReg<11, "s11", [SW11, SF11], ["s11", "sp"]>, DwarfRegNum<[11]>;
121 def SX14 : VEReg<14, "s14", [SW14, SF14], ["s14", "tp"]>, DwarfRegNum<[14]>;
122 def SX15 : VEReg<15, "s15", [SW15, SF15], ["s15", "got"]>, DwarfRegNum<[15]>;
123 def SX16 : VEReg<16, "s16", [SW16, SF16], ["s16", "plt"]>, DwarfRegNum<[16]>;
125 // Other generic registers.
126 foreach I = { 0-7, 12-13, 17-63 } in
127 def SX#I : VEReg<I, "s"#I, [!cast<VEReg>("SW"#I), !cast<VEReg>("SF"#I)],
128 ["s"#I]>, DwarfRegNum<[I]>;
131 // Aliases of the S* registers used to hold 128-bit for values (long doubles).
132 // Following foreach represents something like:
133 // def Q0 : VEReg<0, "q0", [SX0, SX1], ["s0"]>;
134 // def Q1 : VEReg<2, "q2", [SX2, SX3], ["s2"]>;
136 let SubRegIndices = [sub_even, sub_odd], CoveredBySubRegs = 1 in
138 def Q#I : VEReg<!shl(I,1), "q"#I,
139 [!cast<VEReg>("SX"#!shl(I,1)),
140 !cast<VEReg>("SX"#!add(!shl(I,1),1))],
143 // Vector registers - 64 bits wide 256 elements
145 def V#I : VEVecReg<I, "v"#I, [], ["v"#I]>, DwarfRegNum<[!add(64,I)]>;
147 // Vector Index Register
148 def VIX : VEVecReg<255, "vix", [], ["vix"]>;
150 // Vector mask registers - 256 bits wide
151 let isConstant = true in
152 def VM0 : VEMaskReg<0, "vm0", [], ["vm0"]>, DwarfRegNum<[128]>;
154 def VM#I : VEMaskReg<I, "vm"#I, [], ["vm"#I]>, DwarfRegNum<[!add(128,I)]>;
156 // Aliases of VMs to use as a pair of two VM for packed instructions
157 let isConstant = true in
158 def VMP0 : VEMaskReg<0, "vm0", [], ["vm0"]>;
160 let SubRegIndices = [sub_vm_even, sub_vm_odd], CoveredBySubRegs = 1 in
162 def VMP#I : VEMaskReg<!shl(I,1), "vmp"#I,
163 [!cast<VEMaskReg>("VM"#!shl(I,1)),
164 !cast<VEMaskReg>("VM"#!add(!shl(I,1),1))],
167 } // RegAltNameIndices = [AsmName]
171 // The register order is defined in terms of the preferred
173 def I32 : RegisterClass<"VE", [i32], 32,
174 (add (sequence "SW%u", 0, 7),
175 (sequence "SW%u", 34, 63),
176 (sequence "SW%u", 8, 33))>;
177 def I64 : RegisterClass<"VE", [i64, f64], 64,
178 (add (sequence "SX%u", 0, 7),
179 (sequence "SX%u", 34, 63),
180 (sequence "SX%u", 8, 33))>;
181 def F32 : RegisterClass<"VE", [f32], 32,
182 (add (sequence "SF%u", 0, 7),
183 (sequence "SF%u", 34, 63),
184 (sequence "SF%u", 8, 33))>;
185 def F128 : RegisterClass<"VE", [f128], 128,
186 (add (sequence "Q%u", 0, 3),
187 (sequence "Q%u", 17, 31),
188 (sequence "Q%u", 4, 16))>;
190 def V64 : RegisterClass<"VE",
191 [v256f64, // default type for vector registers
193 v256i64, v256i32, v256f32, /* v256f64, */], 64,
194 (add (sequence "V%u", 0, 63),
197 // vm0 is reserved for always true
198 def VM : RegisterClass<"VE", [v256i1], 64, (sequence "VM%u", 0, 15)>;
199 def VM512 : RegisterClass<"VE", [v512i1], 64, (sequence "VMP%u", 0, 7)>;