LLDB mainline
RegisterInfoPOSIX_loongarch64.cpp
Go to the documentation of this file.
1//===-- RegisterInfoPOSIX_loongarch64.cpp --------------------------------===//
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 <cassert>
10#include <lldb/Utility/Flags.h>
11#include <stddef.h>
12
13#include "lldb/lldb-defines.h"
14#include "llvm/Support/Compiler.h"
15
17
18#define GPR_OFFSET(idx) ((idx)*8 + 0)
19#define FPR_OFFSET(idx) ((idx)*8 + sizeof(RegisterInfoPOSIX_loongarch64::GPR))
20#define FCC_OFFSET(idx) ((idx)*1 + 32 * 8 + sizeof(RegisterInfoPOSIX_loongarch64::GPR))
21#define FCSR_OFFSET (8 * 1 + 32 * 8 + sizeof(RegisterInfoPOSIX_loongarch64::GPR))
22
23#define REG_CONTEXT_SIZE \
24 (sizeof(RegisterInfoPOSIX_loongarch64::GPR) + \
25 sizeof(RegisterInfoPOSIX_loongarch64::FPR))
26
27#define DECLARE_REGISTER_INFOS_LOONGARCH64_STRUCT
29#undef DECLARE_REGISTER_INFOS_LOONGARCH64_STRUCT
30
33 const lldb_private::ArchSpec &target_arch) {
34 switch (target_arch.GetMachine()) {
35 case llvm::Triple::loongarch64:
36 return g_register_infos_loongarch64;
37 default:
38 assert(false && "Unhandled target architecture.");
39 return nullptr;
40 }
41}
42
44 const lldb_private::ArchSpec &target_arch) {
45 switch (target_arch.GetMachine()) {
46 case llvm::Triple::loongarch64:
47 return static_cast<uint32_t>(sizeof(g_register_infos_loongarch64) /
48 sizeof(g_register_infos_loongarch64[0]));
49 default:
50 assert(false && "Unhandled target architecture.");
51 return 0;
52 }
53}
54
55// Number of register sets provided by this context.
56enum {
60};
61
62// LoongArch64 general purpose registers.
63static const uint32_t g_gpr_regnums_loongarch64[] = {
80
81static_assert(((sizeof g_gpr_regnums_loongarch64 /
82 sizeof g_gpr_regnums_loongarch64[0]) -
84 "g_gpr_regnums_loongarch64 has wrong number of register infos");
85
86// LoongArch64 floating point registers.
87static const uint32_t g_fpr_regnums_loongarch64[] = {
102
103static_assert(((sizeof g_fpr_regnums_loongarch64 /
104 sizeof g_fpr_regnums_loongarch64[0]) -
106 "g_fpr_regnums_loongarch64 has wrong number of register infos");
107
108// Register sets for LoongArch64.
109static const lldb_private::RegisterSet
111 {"General Purpose Registers", "gpr", k_num_gpr_registers,
113 {"Floating Point Registers", "fpr", k_num_fpr_registers,
115
117 const lldb_private::ArchSpec &target_arch, lldb_private::Flags flags)
118 : lldb_private::RegisterInfoAndSetInterface(target_arch),
119 m_register_info_p(GetRegisterInfoPtr(target_arch)),
120 m_register_info_count(GetRegisterInfoCount(target_arch)) {}
121
124}
125
127 return sizeof(struct RegisterInfoPOSIX_loongarch64::GPR);
128}
129
131 return sizeof(struct RegisterInfoPOSIX_loongarch64::FPR);
132}
133
136 return m_register_info_p;
137}
138
140 return k_num_register_sets;
141}
142
144 uint32_t reg_index) const {
145 // coverity[unsigned_compare]
146 if (reg_index >= gpr_first_loongarch && reg_index <= gpr_last_loongarch)
147 return GPRegSet;
148 if (reg_index >= fpr_first_loongarch && reg_index <= fpr_last_loongarch)
149 return FPRegSet;
150 return LLDB_INVALID_REGNUM;
151}
152
155 if (set_index < GetRegisterSetCount())
156 return &g_reg_sets_loongarch64[set_index];
157 return nullptr;
158}
constexpr size_t k_num_register_sets
static const RegisterInfo * GetRegisterInfoPtr(const ArchSpec &target_arch)
static uint32_t GetRegisterInfoCount(const ArchSpec &target_arch)
static const lldb_private::RegisterSet g_reg_sets_loongarch64[k_num_register_sets]
static const uint32_t g_fpr_regnums_loongarch64[]
static const uint32_t g_gpr_regnums_loongarch64[]
size_t GetRegisterSetFromRegisterIndex(uint32_t reg_index) const override
static const lldb_private::RegisterInfo * GetRegisterInfoPtr(const lldb_private::ArchSpec &target_arch)
const lldb_private::RegisterSet * GetRegisterSet(size_t reg_set) const override
const lldb_private::RegisterInfo * m_register_info_p
static uint32_t GetRegisterInfoCount(const lldb_private::ArchSpec &target_arch)
const lldb_private::RegisterInfo * GetRegisterInfo() const override
RegisterInfoPOSIX_loongarch64(const lldb_private::ArchSpec &target_arch, lldb_private::Flags flags)
An architecture specification class.
Definition: ArchSpec.h:31
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
Definition: ArchSpec.cpp:683
A class to manage flags.
Definition: Flags.h:22
#define LLDB_INVALID_REGNUM
Definition: lldb-defines.h:87
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
Every register is described in detail including its name, alternate name (optional),...
Registers are grouped into register sets.