xref: /llvm-project/llvm/lib/Target/PowerPC/PPCRegisterInfoMMA.td (revision 63d1d37d35e513632e9d4fcc1910ed4e9e3525d0)
10625aed2SStefan Pintilie//===-- PPCRegisterInfoMMA.td - The PowerPC Register File --*- tablegen -*-===//
20625aed2SStefan Pintilie//
30625aed2SStefan Pintilie// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40625aed2SStefan Pintilie// See https://llvm.org/LICENSE.txt for license information.
50625aed2SStefan Pintilie// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60625aed2SStefan Pintilie//
70625aed2SStefan Pintilie//===----------------------------------------------------------------------===//
80625aed2SStefan Pintilie//
90625aed2SStefan Pintilie// Register info for registers related to MMA. These are the ACC and UACC
100625aed2SStefan Pintilie// registers.
110625aed2SStefan Pintilie//
120625aed2SStefan Pintilie//===----------------------------------------------------------------------===//
130625aed2SStefan Pintilie
140625aed2SStefan Pintilielet Namespace = "PPC" in {
150625aed2SStefan Pintiliedef sub_pair0 : SubRegIndex<256>;
160625aed2SStefan Pintiliedef sub_pair1 : SubRegIndex<256, 256>;
170625aed2SStefan Pintilie}
180625aed2SStefan Pintilie
190625aed2SStefan Pintilie// ACC - One of the 8 512-bit VSX accumulators.
200625aed2SStefan Pintilieclass ACC<bits<3> num, string n, list<Register> subregs> : PPCReg<n> {
210625aed2SStefan Pintilie  let HWEncoding{2-0} = num;
220625aed2SStefan Pintilie  let SubRegs = subregs;
230625aed2SStefan Pintilie}
240625aed2SStefan Pintilie
250625aed2SStefan Pintilie// UACC - One of the 8 512-bit VSX accumulators prior to being primed.
260625aed2SStefan Pintilie// Without using this register class, the register allocator has no way to
270625aed2SStefan Pintilie// differentiate a primed accumulator from an unprimed accumulator.
280625aed2SStefan Pintilie// This may result in invalid copies between primed and unprimed accumulators.
290625aed2SStefan Pintilieclass UACC<bits<3> num, string n, list<Register> subregs> : PPCReg<n> {
300625aed2SStefan Pintilie  let HWEncoding{2-0} = num;
310625aed2SStefan Pintilie  let SubRegs = subregs;
320625aed2SStefan Pintilie}
330625aed2SStefan Pintilie
340625aed2SStefan Pintilie// SPE Accumulator for multiply-accumulate SPE operations.  Never directly
350625aed2SStefan Pintilie// accessed, so there's no real encoding for it.
360625aed2SStefan Pintiliedef SPEACC: DwarfRegNum<[99, 111]>;
370625aed2SStefan Pintilie
380625aed2SStefan Pintilielet SubRegIndices = [sub_pair0, sub_pair1] in {
390625aed2SStefan Pintilie  def ACC0 : ACC<0, "acc0", [VSRp0, VSRp1]>, DwarfRegNum<[-1, -1]>;
400625aed2SStefan Pintilie  def ACC1 : ACC<1, "acc1", [VSRp2, VSRp3]>, DwarfRegNum<[-1, -1]>;
410625aed2SStefan Pintilie  def ACC2 : ACC<2, "acc2", [VSRp4, VSRp5]>, DwarfRegNum<[-1, -1]>;
420625aed2SStefan Pintilie  def ACC3 : ACC<3, "acc3", [VSRp6, VSRp7]>, DwarfRegNum<[-1, -1]>;
430625aed2SStefan Pintilie  def ACC4 : ACC<4, "acc4", [VSRp8, VSRp9]>, DwarfRegNum<[-1, -1]>;
440625aed2SStefan Pintilie  def ACC5 : ACC<5, "acc5", [VSRp10, VSRp11]>, DwarfRegNum<[-1, -1]>;
450625aed2SStefan Pintilie  def ACC6 : ACC<6, "acc6", [VSRp12, VSRp13]>, DwarfRegNum<[-1, -1]>;
460625aed2SStefan Pintilie  def ACC7 : ACC<7, "acc7", [VSRp14, VSRp15]>, DwarfRegNum<[-1, -1]>;
470625aed2SStefan Pintilie}
480625aed2SStefan Pintiliedef ACCRC : RegisterClass<"PPC", [v512i1], 128, (add ACC0, ACC1, ACC2, ACC3,
490625aed2SStefan Pintilie                                                      ACC4, ACC5, ACC6, ACC7)> {
50*63d1d37dSMatt Arsenault  // The AllocationPriority is in the range [0, 31]. Assigned the ACC registers
510625aed2SStefan Pintilie  // the highest possible priority in this range to force the register allocator
520625aed2SStefan Pintilie  // to assign these registers first. This is done because the ACC registers
530625aed2SStefan Pintilie  // must represent 4 advacent vector registers. For example ACC1 must be
54*63d1d37dSMatt Arsenault  // VS4 - VS7.
55*63d1d37dSMatt Arsenault  let AllocationPriority = 31;
56*63d1d37dSMatt Arsenault
57*63d1d37dSMatt Arsenault  // We want to allocate these registers even before we allocate
58*63d1d37dSMatt Arsenault  // global ranges.
59*63d1d37dSMatt Arsenault  let GlobalPriority = true;
600625aed2SStefan Pintilie  let Size = 512;
610625aed2SStefan Pintilie}
620625aed2SStefan Pintilie
630625aed2SStefan Pintilielet SubRegIndices = [sub_pair0, sub_pair1] in {
640625aed2SStefan Pintilie  def UACC0 : UACC<0, "acc0", [VSRp0, VSRp1]>, DwarfRegNum<[-1, -1]>;
650625aed2SStefan Pintilie  def UACC1 : UACC<1, "acc1", [VSRp2, VSRp3]>, DwarfRegNum<[-1, -1]>;
660625aed2SStefan Pintilie  def UACC2 : UACC<2, "acc2", [VSRp4, VSRp5]>, DwarfRegNum<[-1, -1]>;
670625aed2SStefan Pintilie  def UACC3 : UACC<3, "acc3", [VSRp6, VSRp7]>, DwarfRegNum<[-1, -1]>;
680625aed2SStefan Pintilie  def UACC4 : UACC<4, "acc4", [VSRp8, VSRp9]>, DwarfRegNum<[-1, -1]>;
690625aed2SStefan Pintilie  def UACC5 : UACC<5, "acc5", [VSRp10, VSRp11]>, DwarfRegNum<[-1, -1]>;
700625aed2SStefan Pintilie  def UACC6 : UACC<6, "acc6", [VSRp12, VSRp13]>, DwarfRegNum<[-1, -1]>;
710625aed2SStefan Pintilie  def UACC7 : UACC<7, "acc7", [VSRp14, VSRp15]>, DwarfRegNum<[-1, -1]>;
720625aed2SStefan Pintilie}
730625aed2SStefan Pintiliedef UACCRC : RegisterClass<"PPC", [v512i1], 128,
740625aed2SStefan Pintilie                           (add UACC0, UACC1, UACC2, UACC3,
750625aed2SStefan Pintilie                                UACC4, UACC5, UACC6, UACC7)> {
760625aed2SStefan Pintilie  // The AllocationPriority for the UACC registers is still high and must be at
770625aed2SStefan Pintilie  // least 32 as we want to allocate these registers before we allocate other
780625aed2SStefan Pintilie  // global ranges. The value must be less than the AllocationPriority of the
790625aed2SStefan Pintilie  // ACC registers.
80*63d1d37dSMatt Arsenault  let AllocationPriority = 4;
81*63d1d37dSMatt Arsenault  let GlobalPriority = true;
820625aed2SStefan Pintilie  let Size = 512;
830625aed2SStefan Pintilie}
840625aed2SStefan Pintilie
850625aed2SStefan Pintilie// FIXME: This allocation order may increase stack frame size when allocating
860625aed2SStefan Pintilie// non-volatile registers.
870625aed2SStefan Pintilie//
880625aed2SStefan Pintilie// Placing Altivec registers first and allocate the rest as underlying VSX
890625aed2SStefan Pintilie// ones, to reduce interference with accumulator registers (lower 32 VSRs).
900625aed2SStefan Pintilie// This reduces copies when loading for accumulators, which is common use for
910625aed2SStefan Pintilie// paired VSX registers.
920625aed2SStefan Pintiliedef VSRpRC :
930625aed2SStefan Pintilie  RegisterClass<"PPC", [v256i1], 128,
940625aed2SStefan Pintilie                (add VSRp17, VSRp18, VSRp16, VSRp19, VSRp20, VSRp21,
950625aed2SStefan Pintilie                     VSRp22, VSRp23, VSRp24, VSRp25, VSRp31, VSRp30,
960625aed2SStefan Pintilie                     VSRp29, VSRp28, VSRp27, VSRp26,
970625aed2SStefan Pintilie                     (sequence "VSRp%u", 0, 6),
980625aed2SStefan Pintilie                     (sequence "VSRp%u", 15, 7))> {
990625aed2SStefan Pintilie  // Give the VSRp registers a non-zero AllocationPriority. The value is less
1000625aed2SStefan Pintilie  // than 32 as these registers should not always be allocated before global
1010625aed2SStefan Pintilie  // ranges and the value should be less than the AllocationPriority - 32 for
1020625aed2SStefan Pintilie  // the UACC registers. Even global VSRp registers should be allocated after
1030625aed2SStefan Pintilie  // the UACC registers have been chosen.
1040625aed2SStefan Pintilie  let AllocationPriority = 2;
1050625aed2SStefan Pintilie  let Size = 256;
1060625aed2SStefan Pintilie}
1070625aed2SStefan Pintilie
1080625aed2SStefan Pintilie
1090625aed2SStefan Pintilie
1100625aed2SStefan Pintilie
111