reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    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
  113
  114
  115
  116
  117
  118
  119
  120
  121
  122
  123
  124
  125
  126
  127
  128
  129
  130
  131
  132
  133
  134
  135
  136
  137
  138
  139
  140
  141
  142
  143
  144
  145
  146
  147
  148
  149
  150
  151
  152
  153
  154
  155
  156
  157
  158
  159
  160
  161
  162
  163
  164
  165
  166
  167
  168
  169
  170
  171
  172
  173
  174
  175
  176
  177
  178
  179
  180
  181
  182
  183
  184
  185
  186
  187
  188
  189
  190
  191
  192
  193
  194
  195
  196
  197
  198
  199
  200
  201
  202
  203
  204
  205
  206
  207
  208
  209
  210
  211
  212
  213
  214
  215
  216
  217
  218
  219
  220
  221
  222
  223
  224
  225
  226
  227
  228
//===-- RegisterInfos_powerpc.h ---------------------------------*- 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
//
//===---------------------------------------------------------------------===//

#include <stddef.h>

// Computes the offset of the given GPR in the user data area.
#define GPR_OFFSET(regname) (offsetof(GPR, regname))
#define FPR_OFFSET(regname) (offsetof(FPR, regname))
#define VMX_OFFSET(regname) (offsetof(VMX, regname))
#define GPR_SIZE(regname) (sizeof(((GPR *)NULL)->regname))

#ifdef DECLARE_REGISTER_INFOS_POWERPC_STRUCT

// Note that the size and offset will be updated by platform-specific classes.
#define DEFINE_GPR(reg, alt, lldb_kind)                                        \
  {                                                                            \
    #reg, alt, GPR_SIZE(reg), GPR_OFFSET(reg), eEncodingUint, eFormatHex,      \
                                         {dwarf_##reg##_powerpc,               \
                                          dwarf_##reg##_powerpc, lldb_kind,    \
                                          LLDB_INVALID_REGNUM,                 \
                                          gpr_##reg##_powerpc },               \
                                          NULL, NULL, NULL, 0                  \
  }
#define DEFINE_FPR(reg, lldb_kind)                                             \
  {                                                                            \
    #reg, NULL, 8, FPR_OFFSET(reg), eEncodingIEEE754, eFormatFloat,            \
                              {dwarf_##reg##_powerpc, dwarf_##reg##_powerpc,   \
                               lldb_kind, LLDB_INVALID_REGNUM,                 \
                               fpr_##reg##_powerpc },                          \
                               NULL, NULL, NULL, 0                             \
  }
#define DEFINE_VMX(reg, lldb_kind)                                             \
  {                                                                            \
    #reg, NULL, 16, VMX_OFFSET(reg), eEncodingVector, eFormatVectorOfUInt32,   \
                               {dwarf_##reg##_powerpc, dwarf_##reg##_powerpc,  \
                                lldb_kind, LLDB_INVALID_REGNUM,                \
                                vmx_##reg##_powerpc },                         \
                                NULL, NULL, NULL, 0                            \
  }

// General purpose registers.            EH_Frame,                  DWARF,
// Generic,                Process Plugin
#define POWERPC_REGS                                                           \
  DEFINE_GPR(r0, NULL, LLDB_INVALID_REGNUM)                                    \
  , DEFINE_GPR(r1, "sp", LLDB_REGNUM_GENERIC_SP),                              \
      DEFINE_GPR(r2, NULL, LLDB_INVALID_REGNUM),                               \
      DEFINE_GPR(r3, "arg1", LLDB_REGNUM_GENERIC_ARG1),                        \
      DEFINE_GPR(r4, "arg2", LLDB_REGNUM_GENERIC_ARG2),                        \
      DEFINE_GPR(r5, "arg3", LLDB_REGNUM_GENERIC_ARG3),                        \
      DEFINE_GPR(r6, "arg4", LLDB_REGNUM_GENERIC_ARG4),                        \
      DEFINE_GPR(r7, "arg5", LLDB_REGNUM_GENERIC_ARG5),                        \
      DEFINE_GPR(r8, "arg6", LLDB_REGNUM_GENERIC_ARG6),                        \
      DEFINE_GPR(r9, "arg7", LLDB_REGNUM_GENERIC_ARG7),                        \
      DEFINE_GPR(r10, "arg8", LLDB_REGNUM_GENERIC_ARG8),                       \
      DEFINE_GPR(r11, NULL, LLDB_INVALID_REGNUM),                              \
      DEFINE_GPR(r12, NULL, LLDB_INVALID_REGNUM),                              \
      DEFINE_GPR(r13, NULL, LLDB_INVALID_REGNUM),                              \
      DEFINE_GPR(r14, NULL, LLDB_INVALID_REGNUM),                              \
      DEFINE_GPR(r15, NULL, LLDB_INVALID_REGNUM),                              \
      DEFINE_GPR(r16, NULL, LLDB_INVALID_REGNUM),                              \
      DEFINE_GPR(r17, NULL, LLDB_INVALID_REGNUM),                              \
      DEFINE_GPR(r18, NULL, LLDB_INVALID_REGNUM),                              \
      DEFINE_GPR(r19, NULL, LLDB_INVALID_REGNUM),                              \
      DEFINE_GPR(r20, NULL, LLDB_INVALID_REGNUM),                              \
      DEFINE_GPR(r21, NULL, LLDB_INVALID_REGNUM),                              \
      DEFINE_GPR(r22, NULL, LLDB_INVALID_REGNUM),                              \
      DEFINE_GPR(r23, NULL, LLDB_INVALID_REGNUM),                              \
      DEFINE_GPR(r24, NULL, LLDB_INVALID_REGNUM),                              \
      DEFINE_GPR(r25, NULL, LLDB_INVALID_REGNUM),                              \
      DEFINE_GPR(r26, NULL, LLDB_INVALID_REGNUM),                              \
      DEFINE_GPR(r27, NULL, LLDB_INVALID_REGNUM),                              \
      DEFINE_GPR(r28, NULL, LLDB_INVALID_REGNUM),                              \
      DEFINE_GPR(r29, NULL, LLDB_INVALID_REGNUM),                              \
      DEFINE_GPR(r30, NULL, LLDB_INVALID_REGNUM),                              \
      DEFINE_GPR(r31, NULL, LLDB_INVALID_REGNUM),                              \
      DEFINE_GPR(lr, "lr", LLDB_REGNUM_GENERIC_RA),                            \
      DEFINE_GPR(cr, "cr", LLDB_REGNUM_GENERIC_FLAGS),                         \
      DEFINE_GPR(xer, "xer", LLDB_INVALID_REGNUM),                             \
      DEFINE_GPR(ctr, "ctr", LLDB_INVALID_REGNUM),                             \
      DEFINE_GPR(pc, "pc", LLDB_REGNUM_GENERIC_PC),                            \
      DEFINE_FPR(f0, LLDB_INVALID_REGNUM),                                     \
      DEFINE_FPR(f1, LLDB_INVALID_REGNUM),                                     \
      DEFINE_FPR(f2, LLDB_INVALID_REGNUM),                                     \
      DEFINE_FPR(f3, LLDB_INVALID_REGNUM),                                     \
      DEFINE_FPR(f4, LLDB_INVALID_REGNUM),                                     \
      DEFINE_FPR(f5, LLDB_INVALID_REGNUM),                                     \
      DEFINE_FPR(f6, LLDB_INVALID_REGNUM),                                     \
      DEFINE_FPR(f7, LLDB_INVALID_REGNUM),                                     \
      DEFINE_FPR(f8, LLDB_INVALID_REGNUM),                                     \
      DEFINE_FPR(f9, LLDB_INVALID_REGNUM),                                     \
      DEFINE_FPR(f10, LLDB_INVALID_REGNUM),                                    \
      DEFINE_FPR(f11, LLDB_INVALID_REGNUM),                                    \
      DEFINE_FPR(f12, LLDB_INVALID_REGNUM),                                    \
      DEFINE_FPR(f13, LLDB_INVALID_REGNUM),                                    \
      DEFINE_FPR(f14, LLDB_INVALID_REGNUM),                                    \
      DEFINE_FPR(f15, LLDB_INVALID_REGNUM),                                    \
      DEFINE_FPR(f16, LLDB_INVALID_REGNUM),                                    \
      DEFINE_FPR(f17, LLDB_INVALID_REGNUM),                                    \
      DEFINE_FPR(f18, LLDB_INVALID_REGNUM),                                    \
      DEFINE_FPR(f19, LLDB_INVALID_REGNUM),                                    \
      DEFINE_FPR(f20, LLDB_INVALID_REGNUM),                                    \
      DEFINE_FPR(f21, LLDB_INVALID_REGNUM),                                    \
      DEFINE_FPR(f22, LLDB_INVALID_REGNUM),                                    \
      DEFINE_FPR(f23, LLDB_INVALID_REGNUM),                                    \
      DEFINE_FPR(f24, LLDB_INVALID_REGNUM),                                    \
      DEFINE_FPR(f25, LLDB_INVALID_REGNUM),                                    \
      DEFINE_FPR(f26, LLDB_INVALID_REGNUM),                                    \
      DEFINE_FPR(f27, LLDB_INVALID_REGNUM),                                    \
      DEFINE_FPR(f28, LLDB_INVALID_REGNUM),                                    \
      DEFINE_FPR(f29, LLDB_INVALID_REGNUM),                                    \
      DEFINE_FPR(f30, LLDB_INVALID_REGNUM),                                    \
      DEFINE_FPR(f31, LLDB_INVALID_REGNUM),                                    \
      {"fpscr",                                                                \
       NULL,                                                                   \
       8,                                                                      \
       FPR_OFFSET(fpscr),                                                      \
       eEncodingUint,                                                          \
       eFormatHex,                                                             \
       {dwarf_fpscr_powerpc, dwarf_fpscr_powerpc, LLDB_INVALID_REGNUM,         \
        LLDB_INVALID_REGNUM, fpr_fpscr_powerpc},                               \
       NULL,                                                                   \
       NULL,                                                                   \
       NULL,                                                                   \
       0},                                                                     \
      DEFINE_VMX(v0, LLDB_INVALID_REGNUM),                                     \
      DEFINE_VMX(v1, LLDB_INVALID_REGNUM),                                     \
      DEFINE_VMX(v2, LLDB_INVALID_REGNUM),                                     \
      DEFINE_VMX(v3, LLDB_INVALID_REGNUM),                                     \
      DEFINE_VMX(v4, LLDB_INVALID_REGNUM),                                     \
      DEFINE_VMX(v5, LLDB_INVALID_REGNUM),                                     \
      DEFINE_VMX(v6, LLDB_INVALID_REGNUM),                                     \
      DEFINE_VMX(v7, LLDB_INVALID_REGNUM),                                     \
      DEFINE_VMX(v8, LLDB_INVALID_REGNUM),                                     \
      DEFINE_VMX(v9, LLDB_INVALID_REGNUM),                                     \
      DEFINE_VMX(v10, LLDB_INVALID_REGNUM),                                    \
      DEFINE_VMX(v11, LLDB_INVALID_REGNUM),                                    \
      DEFINE_VMX(v12, LLDB_INVALID_REGNUM),                                    \
      DEFINE_VMX(v13, LLDB_INVALID_REGNUM),                                    \
      DEFINE_VMX(v14, LLDB_INVALID_REGNUM),                                    \
      DEFINE_VMX(v15, LLDB_INVALID_REGNUM),                                    \
      DEFINE_VMX(v16, LLDB_INVALID_REGNUM),                                    \
      DEFINE_VMX(v17, LLDB_INVALID_REGNUM),                                    \
      DEFINE_VMX(v18, LLDB_INVALID_REGNUM),                                    \
      DEFINE_VMX(v19, LLDB_INVALID_REGNUM),                                    \
      DEFINE_VMX(v20, LLDB_INVALID_REGNUM),                                    \
      DEFINE_VMX(v21, LLDB_INVALID_REGNUM),                                    \
      DEFINE_VMX(v22, LLDB_INVALID_REGNUM),                                    \
      DEFINE_VMX(v23, LLDB_INVALID_REGNUM),                                    \
      DEFINE_VMX(v24, LLDB_INVALID_REGNUM),                                    \
      DEFINE_VMX(v25, LLDB_INVALID_REGNUM),                                    \
      DEFINE_VMX(v26, LLDB_INVALID_REGNUM),                                    \
      DEFINE_VMX(v27, LLDB_INVALID_REGNUM),                                    \
      DEFINE_VMX(v28, LLDB_INVALID_REGNUM),                                    \
      DEFINE_VMX(v29, LLDB_INVALID_REGNUM),                                    \
      DEFINE_VMX(v30, LLDB_INVALID_REGNUM),                                    \
      DEFINE_VMX(v31, LLDB_INVALID_REGNUM),                                    \
      {"vrsave",                                                               \
       NULL,                                                                   \
       4,                                                                      \
       VMX_OFFSET(vrsave),                                                     \
       eEncodingUint,                                                          \
       eFormatHex,                                                             \
       {dwarf_vrsave_powerpc, dwarf_vrsave_powerpc, LLDB_INVALID_REGNUM,       \
        LLDB_INVALID_REGNUM, vmx_vrsave_powerpc},                              \
       NULL,                                                                   \
       NULL,                                                                   \
       NULL,                                                                   \
       0},                                                                     \
      {"vscr",                                                                 \
       NULL,                                                                   \
       4,                                                                      \
       VMX_OFFSET(vscr),                                                       \
       eEncodingUint,                                                          \
       eFormatHex,                                                             \
       {dwarf_vscr_powerpc, dwarf_vscr_powerpc, LLDB_INVALID_REGNUM,           \
        LLDB_INVALID_REGNUM, vmx_vscr_powerpc},                                \
       NULL,                                                                   \
       NULL,                                                                   \
       NULL,                                                                   \
       0},

static RegisterInfo g_register_infos_powerpc64[] = {
#define GPR GPR64
    POWERPC_REGS
#undef GPR
};

static RegisterInfo g_register_infos_powerpc32[] = {
#define GPR GPR32
    POWERPC_REGS
#undef GPR
};

static RegisterInfo g_register_infos_powerpc64_32[] = {
#define GPR GPR64
#undef GPR_SIZE
#define GPR_SIZE(reg) (sizeof(uint32_t))
#undef GPR_OFFSET
#define GPR_OFFSET(regname)                                                    \
  (offsetof(GPR, regname) + (sizeof(((GPR *)NULL)->regname) - GPR_SIZE(reg)))
    POWERPC_REGS
#undef GPR
};

static_assert((sizeof(g_register_infos_powerpc32) /
               sizeof(g_register_infos_powerpc32[0])) ==
                  k_num_registers_powerpc,
              "g_register_infos_powerpc32 has wrong number of register infos");
static_assert((sizeof(g_register_infos_powerpc64) /
               sizeof(g_register_infos_powerpc64[0])) ==
                  k_num_registers_powerpc,
              "g_register_infos_powerpc64 has wrong number of register infos");
static_assert(sizeof(g_register_infos_powerpc64_32) ==
                  sizeof(g_register_infos_powerpc64),
              "g_register_infos_powerpc64_32 doesn't match size of "
              "g_register_infos_powerpc64");

#undef DEFINE_FPR
#undef DEFINE_GPR

#endif // DECLARE_REGISTER_INFOS_POWERPC_STRUCT

#undef GPR_OFFSET