File: PPCGenRegisterBankInfo.def

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.8-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,696 kB
  • sloc: cpp: 7,438,781; ansic: 1,393,871; asm: 1,012,926; python: 241,771; f90: 86,635; objc: 75,411; lisp: 42,144; pascal: 17,286; sh: 8,596; ml: 5,082; perl: 4,730; makefile: 3,591; awk: 3,523; javascript: 2,251; xml: 892; fortran: 672
file content (112 lines) | stat: -rw-r--r-- 4,663 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//===- PPCGenRegisterBankInfo.def -------------------------------*- C++ -*-==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
/// \file
/// This file defines all the static objects used by PPCRegisterBankInfo.
/// \todo This should be generated by TableGen, because the logic here can be
///  derived from register bank definition. Not yet implemented.
//===----------------------------------------------------------------------===//

namespace llvm {
const RegisterBankInfo::PartialMapping PPCGenRegisterBankInfo::PartMappings[]{
    /* StartIdx, Length, RegBank */
    // 0: GPR 32-bit value.
    {0, 32, PPC::GPRRegBank},
    // 1: GPR 64-bit value.
    {0, 64, PPC::GPRRegBank},
    // 2: FPR 32-bit value
    {0, 32, PPC::FPRRegBank},
    // 3: FPR 64-bit value
    {0, 64, PPC::FPRRegBank},
    // 4: 128-bit vector (VSX, Altivec)
    {0, 128, PPC::VECRegBank},
    // 5: CR 4-bit value
    {0, 4, PPC::CRRegBank},
};

// ValueMappings.
// Pointers to the entries in this array are returned by getValueMapping() and
// getCopyMapping().
//
// The array has the following structure:
// - At index 0 is the invalid entry.
// - After that, the mappings for the register types from PartialMappingIdx
//   follow. Each mapping consists of 3 entries, which is needed to cover
//   3-operands instructions.
// - Last, mappings for cross-register bank moves follow. Since COPY has only
//   2 operands, a mapping consists of 2 entries.
const RegisterBankInfo::ValueMapping PPCGenRegisterBankInfo::ValMappings[]{
    /* BreakDown, NumBreakDowns */
    // 0: invalid
    {nullptr, 0},
    // 1: GPR 32-bit value.
    {&PPCGenRegisterBankInfo::PartMappings[PMI_GPR32 - PMI_Min], 1},
    {&PPCGenRegisterBankInfo::PartMappings[PMI_GPR32 - PMI_Min], 1},
    {&PPCGenRegisterBankInfo::PartMappings[PMI_GPR32 - PMI_Min], 1},
    // 4: GPR 64-bit value.
    {&PPCGenRegisterBankInfo::PartMappings[PMI_GPR64 - PMI_Min], 1},
    {&PPCGenRegisterBankInfo::PartMappings[PMI_GPR64 - PMI_Min], 1},
    {&PPCGenRegisterBankInfo::PartMappings[PMI_GPR64 - PMI_Min], 1},
    // 7: FPR 32-bit value.
    {&PPCGenRegisterBankInfo::PartMappings[PMI_FPR32 - PMI_Min], 1},
    {&PPCGenRegisterBankInfo::PartMappings[PMI_FPR32 - PMI_Min], 1},
    {&PPCGenRegisterBankInfo::PartMappings[PMI_FPR32 - PMI_Min], 1},
    // 10: FPR 64-bit value.
    {&PPCGenRegisterBankInfo::PartMappings[PMI_FPR64 - PMI_Min], 1},
    {&PPCGenRegisterBankInfo::PartMappings[PMI_FPR64 - PMI_Min], 1},
    {&PPCGenRegisterBankInfo::PartMappings[PMI_FPR64 - PMI_Min], 1},
    // 13: 128-bit vector.
    {&PPCGenRegisterBankInfo::PartMappings[PMI_VEC128 - PMI_Min], 1},
    {&PPCGenRegisterBankInfo::PartMappings[PMI_VEC128 - PMI_Min], 1},
    {&PPCGenRegisterBankInfo::PartMappings[PMI_VEC128 - PMI_Min], 1},
    // 16: CR 4-bit value.
    {&PPCGenRegisterBankInfo::PartMappings[PMI_CR - PMI_Min], 1},
};

// TODO Too simple!
const RegisterBankInfo::ValueMapping *
PPCGenRegisterBankInfo::getValueMapping(PartialMappingIdx RBIdx) {
  assert(RBIdx != PartialMappingIdx::PMI_None && "No mapping needed for that");

  unsigned ValMappingIdx = RBIdx - PMI_Min;

  return &ValMappings[1 + 3 * ValMappingIdx];
}

const PPCGenRegisterBankInfo::PartialMappingIdx
  PPCGenRegisterBankInfo::BankIDToCopyMapIdx[]{
    PMI_None,
    PMI_FPR64,  // FPR
    PMI_GPR64,  // GPR
    PMI_VEC128, // VEC
};

// TODO Too simple!
const RegisterBankInfo::ValueMapping *
PPCGenRegisterBankInfo::getCopyMapping(unsigned DstBankID, unsigned SrcBankID,
                                       unsigned Size) {
  assert(DstBankID < PPC::NumRegisterBanks && "Invalid bank ID");
  assert(SrcBankID < PPC::NumRegisterBanks && "Invalid bank ID");
  PartialMappingIdx DstRBIdx = BankIDToCopyMapIdx[DstBankID];
  PartialMappingIdx SrcRBIdx = BankIDToCopyMapIdx[SrcBankID];
  assert(DstRBIdx != PMI_None && "No such mapping");
  assert(SrcRBIdx != PMI_None && "No such mapping");

  if (DstRBIdx == SrcRBIdx)
    return getValueMapping(DstRBIdx);

  assert(Size <= 128 && "Can currently handle types up to 128 bits (vectors)!");
  // TODO: This function needs to be updated to handle all cases for
  //       GPRs, FPRs and vectors. It currently only handles bitcasting to
  //       the same type and has only mainly been tested for bitcasting
  //       between different vector types.
  unsigned ValMappingIdx = DstRBIdx - PMI_Min;

  return &ValMappings[1 + 3 * ValMappingIdx];
}

} // namespace llvm