xref: /freebsd-src/contrib/llvm-project/llvm/lib/Target/PowerPC/PPCRegisterInfoMMA.td (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
181ad6265SDimitry Andric//===-- PPCRegisterInfoMMA.td - The PowerPC Register File --*- tablegen -*-===//
281ad6265SDimitry Andric//
381ad6265SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
481ad6265SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
581ad6265SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
681ad6265SDimitry Andric//
781ad6265SDimitry Andric//===----------------------------------------------------------------------===//
881ad6265SDimitry Andric//
981ad6265SDimitry Andric// Register info for registers related to MMA. These are the ACC and UACC
1081ad6265SDimitry Andric// registers.
1181ad6265SDimitry Andric//
1281ad6265SDimitry Andric//===----------------------------------------------------------------------===//
1381ad6265SDimitry Andric
1481ad6265SDimitry Andriclet Namespace = "PPC" in {
1581ad6265SDimitry Andricdef sub_pair0 : SubRegIndex<256>;
1681ad6265SDimitry Andricdef sub_pair1 : SubRegIndex<256, 256>;
1781ad6265SDimitry Andric}
1881ad6265SDimitry Andric
1981ad6265SDimitry Andric// ACC - One of the 8 512-bit VSX accumulators.
2081ad6265SDimitry Andricclass ACC<bits<3> num, string n, list<Register> subregs> : PPCReg<n> {
2181ad6265SDimitry Andric  let HWEncoding{2-0} = num;
2281ad6265SDimitry Andric  let SubRegs = subregs;
2381ad6265SDimitry Andric}
2481ad6265SDimitry Andric
2581ad6265SDimitry Andric// UACC - One of the 8 512-bit VSX accumulators prior to being primed.
2681ad6265SDimitry Andric// Without using this register class, the register allocator has no way to
2781ad6265SDimitry Andric// differentiate a primed accumulator from an unprimed accumulator.
2881ad6265SDimitry Andric// This may result in invalid copies between primed and unprimed accumulators.
2981ad6265SDimitry Andricclass UACC<bits<3> num, string n, list<Register> subregs> : PPCReg<n> {
3081ad6265SDimitry Andric  let HWEncoding{2-0} = num;
3181ad6265SDimitry Andric  let SubRegs = subregs;
3281ad6265SDimitry Andric}
3381ad6265SDimitry Andric
3481ad6265SDimitry Andric// SPE Accumulator for multiply-accumulate SPE operations.  Never directly
3581ad6265SDimitry Andric// accessed, so there's no real encoding for it.
3681ad6265SDimitry Andricdef SPEACC: DwarfRegNum<[99, 111]>;
3781ad6265SDimitry Andric
3881ad6265SDimitry Andriclet SubRegIndices = [sub_pair0, sub_pair1] in {
3981ad6265SDimitry Andric  def ACC0 : ACC<0, "acc0", [VSRp0, VSRp1]>, DwarfRegNum<[-1, -1]>;
4081ad6265SDimitry Andric  def ACC1 : ACC<1, "acc1", [VSRp2, VSRp3]>, DwarfRegNum<[-1, -1]>;
4181ad6265SDimitry Andric  def ACC2 : ACC<2, "acc2", [VSRp4, VSRp5]>, DwarfRegNum<[-1, -1]>;
4281ad6265SDimitry Andric  def ACC3 : ACC<3, "acc3", [VSRp6, VSRp7]>, DwarfRegNum<[-1, -1]>;
4381ad6265SDimitry Andric  def ACC4 : ACC<4, "acc4", [VSRp8, VSRp9]>, DwarfRegNum<[-1, -1]>;
4481ad6265SDimitry Andric  def ACC5 : ACC<5, "acc5", [VSRp10, VSRp11]>, DwarfRegNum<[-1, -1]>;
4581ad6265SDimitry Andric  def ACC6 : ACC<6, "acc6", [VSRp12, VSRp13]>, DwarfRegNum<[-1, -1]>;
4681ad6265SDimitry Andric  def ACC7 : ACC<7, "acc7", [VSRp14, VSRp15]>, DwarfRegNum<[-1, -1]>;
4781ad6265SDimitry Andric}
4881ad6265SDimitry Andricdef ACCRC : RegisterClass<"PPC", [v512i1], 128, (add ACC0, ACC1, ACC2, ACC3,
4981ad6265SDimitry Andric                                                      ACC4, ACC5, ACC6, ACC7)> {
50*bdd1243dSDimitry Andric  // The AllocationPriority is in the range [0, 31]. Assigned the ACC registers
5181ad6265SDimitry Andric  // the highest possible priority in this range to force the register allocator
5281ad6265SDimitry Andric  // to assign these registers first. This is done because the ACC registers
5381ad6265SDimitry Andric  // must represent 4 advacent vector registers. For example ACC1 must be
54*bdd1243dSDimitry Andric  // VS4 - VS7.
55*bdd1243dSDimitry Andric  let AllocationPriority = 31;
56*bdd1243dSDimitry Andric
57*bdd1243dSDimitry Andric  // We want to allocate these registers even before we allocate
58*bdd1243dSDimitry Andric  // global ranges.
59*bdd1243dSDimitry Andric  let GlobalPriority = true;
6081ad6265SDimitry Andric  let Size = 512;
6181ad6265SDimitry Andric}
6281ad6265SDimitry Andric
6381ad6265SDimitry Andriclet SubRegIndices = [sub_pair0, sub_pair1] in {
6481ad6265SDimitry Andric  def UACC0 : UACC<0, "acc0", [VSRp0, VSRp1]>, DwarfRegNum<[-1, -1]>;
6581ad6265SDimitry Andric  def UACC1 : UACC<1, "acc1", [VSRp2, VSRp3]>, DwarfRegNum<[-1, -1]>;
6681ad6265SDimitry Andric  def UACC2 : UACC<2, "acc2", [VSRp4, VSRp5]>, DwarfRegNum<[-1, -1]>;
6781ad6265SDimitry Andric  def UACC3 : UACC<3, "acc3", [VSRp6, VSRp7]>, DwarfRegNum<[-1, -1]>;
6881ad6265SDimitry Andric  def UACC4 : UACC<4, "acc4", [VSRp8, VSRp9]>, DwarfRegNum<[-1, -1]>;
6981ad6265SDimitry Andric  def UACC5 : UACC<5, "acc5", [VSRp10, VSRp11]>, DwarfRegNum<[-1, -1]>;
7081ad6265SDimitry Andric  def UACC6 : UACC<6, "acc6", [VSRp12, VSRp13]>, DwarfRegNum<[-1, -1]>;
7181ad6265SDimitry Andric  def UACC7 : UACC<7, "acc7", [VSRp14, VSRp15]>, DwarfRegNum<[-1, -1]>;
7281ad6265SDimitry Andric}
7381ad6265SDimitry Andricdef UACCRC : RegisterClass<"PPC", [v512i1], 128,
7481ad6265SDimitry Andric                           (add UACC0, UACC1, UACC2, UACC3,
7581ad6265SDimitry Andric                                UACC4, UACC5, UACC6, UACC7)> {
7681ad6265SDimitry Andric  // The AllocationPriority for the UACC registers is still high and must be at
7781ad6265SDimitry Andric  // least 32 as we want to allocate these registers before we allocate other
7881ad6265SDimitry Andric  // global ranges. The value must be less than the AllocationPriority of the
7981ad6265SDimitry Andric  // ACC registers.
80*bdd1243dSDimitry Andric  let AllocationPriority = 4;
81*bdd1243dSDimitry Andric  let GlobalPriority = true;
8281ad6265SDimitry Andric  let Size = 512;
8381ad6265SDimitry Andric}
8481ad6265SDimitry Andric
8581ad6265SDimitry Andric// FIXME: This allocation order may increase stack frame size when allocating
8681ad6265SDimitry Andric// non-volatile registers.
8781ad6265SDimitry Andric//
8881ad6265SDimitry Andric// Placing Altivec registers first and allocate the rest as underlying VSX
8981ad6265SDimitry Andric// ones, to reduce interference with accumulator registers (lower 32 VSRs).
9081ad6265SDimitry Andric// This reduces copies when loading for accumulators, which is common use for
9181ad6265SDimitry Andric// paired VSX registers.
9281ad6265SDimitry Andricdef VSRpRC :
9381ad6265SDimitry Andric  RegisterClass<"PPC", [v256i1], 128,
9481ad6265SDimitry Andric                (add VSRp17, VSRp18, VSRp16, VSRp19, VSRp20, VSRp21,
9581ad6265SDimitry Andric                     VSRp22, VSRp23, VSRp24, VSRp25, VSRp31, VSRp30,
9681ad6265SDimitry Andric                     VSRp29, VSRp28, VSRp27, VSRp26,
9781ad6265SDimitry Andric                     (sequence "VSRp%u", 0, 6),
9881ad6265SDimitry Andric                     (sequence "VSRp%u", 15, 7))> {
9981ad6265SDimitry Andric  // Give the VSRp registers a non-zero AllocationPriority. The value is less
10081ad6265SDimitry Andric  // than 32 as these registers should not always be allocated before global
10181ad6265SDimitry Andric  // ranges and the value should be less than the AllocationPriority - 32 for
10281ad6265SDimitry Andric  // the UACC registers. Even global VSRp registers should be allocated after
10381ad6265SDimitry Andric  // the UACC registers have been chosen.
10481ad6265SDimitry Andric  let AllocationPriority = 2;
10581ad6265SDimitry Andric  let Size = 256;
10681ad6265SDimitry Andric}
10781ad6265SDimitry Andric
10881ad6265SDimitry Andric
10981ad6265SDimitry Andric
11081ad6265SDimitry Andric
111