LLDB  mainline
RegisterContextLinux_mips.cpp
Go to the documentation of this file.
1 //===-- RegisterContextLinux_mips.cpp ------------------------*- C++ -*-===//
2 //
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
6 //
7 //===---------------------------------------------------------------------===//
8 
9 #include <stddef.h>
10 #include <vector>
11 
12 // For eh_frame and DWARF Register numbers
14 
15 // Internal codes for mips registers
17 
18 // For GP and FP buffers
19 #include "RegisterContext_mips.h"
20 
21 using namespace lldb_private;
22 using namespace lldb;
23 
24 // Include RegisterInfos_mips to declare our g_register_infos_mips structure.
25 #define DECLARE_REGISTER_INFOS_MIPS_STRUCT
26 #include "RegisterInfos_mips.h"
27 #undef DECLARE_REGISTER_INFOS_MIPS_STRUCT
28 
29 // mips general purpose registers.
41  LLDB_INVALID_REGNUM // register sets need to end with this flag
42 };
43 
44 static_assert((sizeof(g_gp_regnums_mips) / sizeof(g_gp_regnums_mips[0])) - 1 ==
46  "g_gp_regnums_mips has wrong number of register infos");
47 // mips floating point registers.
58  LLDB_INVALID_REGNUM // register sets need to end with this flag
59 };
60 
61 static_assert((sizeof(g_fp_regnums_mips) / sizeof(g_fp_regnums_mips[0])) - 1 ==
63  "g_fp_regnums_mips has wrong number of register infos");
64 
65 // mips MSA registers.
77  LLDB_INVALID_REGNUM // register sets need to end with this flag
78 };
79 
80 static_assert((sizeof(g_msa_regnums_mips) / sizeof(g_msa_regnums_mips[0])) -
81  1 ==
83  "g_msa_regnums_mips has wrong number of register infos");
84 
85 // Number of register sets provided by this context.
86 constexpr size_t k_num_register_sets = 3;
87 
88 // Register sets for mips.
89 static const RegisterSet g_reg_sets_mips[k_num_register_sets] = {
90  {"General Purpose Registers", "gpr", k_num_gpr_registers_mips,
91  g_gp_regnums_mips},
92  {"Floating Point Registers", "fpu", k_num_fpr_registers_mips,
93  g_fp_regnums_mips},
94  {"MSA Registers", "msa", k_num_msa_registers_mips, g_msa_regnums_mips}};
95 
97  if (msa_present)
98  return static_cast<uint32_t>(k_num_user_registers_mips);
99  return static_cast<uint32_t>(k_num_user_registers_mips -
101 }
102 
104  const ArchSpec &target_arch, bool msa_present)
105  : RegisterInfoInterface(target_arch),
106  m_user_register_count(GetUserRegisterInfoCount(msa_present)) {}
107 
109  return sizeof(GPR_linux_mips);
110 }
111 
112 const RegisterInfo *RegisterContextLinux_mips::GetRegisterInfo() const {
113  switch (m_target_arch.GetMachine()) {
114  case llvm::Triple::mips:
115  case llvm::Triple::mipsel:
116  return g_register_infos_mips;
117  default:
118  assert(false && "Unhandled target architecture.");
119  return NULL;
120  }
121 }
122 
123 const RegisterSet *
125  if (set >= k_num_register_sets)
126  return nullptr;
127  switch (m_target_arch.GetMachine()) {
128  case llvm::Triple::mips:
129  case llvm::Triple::mipsel:
130  return &g_reg_sets_mips[set];
131  default:
132  assert(false && "Unhandled target architecture.");
133  return nullptr;
134  }
135 }
136 
137 size_t
139  return k_num_register_sets;
140 }
141 
143  return static_cast<uint32_t>(sizeof(g_register_infos_mips) /
144  sizeof(g_register_infos_mips[0]));
145 }
146 
148  return static_cast<uint32_t>(m_user_register_count);
149 }
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
const uint32_t g_gp_regnums_mips[]
RegisterInfo interface to patch RegisterInfo structure for archs.
const uint32_t g_msa_regnums_mips[]
An architecture specification class.
Definition: ArchSpec.h:32
RegisterContextLinux_mips(const lldb_private::ArchSpec &target_arch, bool msa_present=true)
static const RegisterSet g_reg_sets_mips[k_num_register_sets]
constexpr size_t k_num_register_sets
const lldb_private::RegisterInfo * GetRegisterInfo() const override
uint32_t GetUserRegisterInfoCount(bool msa_present)
Definition: SBAddress.h:15
uint32_t GetRegisterCount() const override
const lldb_private::RegisterSet * GetRegisterSet(size_t set) const
uint32_t GetUserRegisterCount() const override
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
Definition: ArchSpec.cpp:726
const uint32_t g_fp_regnums_mips[]
#define LLDB_INVALID_REGNUM
Definition: lldb-defines.h:90