LLDB mainline
RegisterInfo_arm64.h
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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#ifndef LLDB_SOURCE_REGISTER_COMMON_REGISTERINFO_ARM64_H
10#define LLDB_SOURCE_REGISTER_COMMON_REGISTERINFO_ARM64_H
11
14#include "lldb/Utility/Flags.h"
15#include "lldb/lldb-private.h"
16#include <map>
17
18enum class SVEState : uint8_t {
19 // We have yet to look what features there are.
21 // We know that there is no SVE or streaming SVE (SME).
23 // We are in non-streaming mode but SVE is not active.
25 // We are in non-streaming mode and SVE is active.
27 // We are in streaming mode using streaming SVE.
29 // We are in non-streaming mode, and only have SVE while in streaming mode.
31};
32
34public:
35 enum { GPRegSet = 0, FPRegSet };
36
37 // AArch64 register set mask value
38 enum {
51 };
52
53 // AArch64 Register set FP/SIMD feature configuration
54 enum {
58 };
59
60 // based on RegisterContextDarwin_arm64.h
61 // Pack this so there are no extra bytes, but align its start address to at
62 // least 8 bytes to prevent alignment errors.
63 LLVM_PACKED_START
64 struct alignas(8) GPR {
65 uint64_t x[29]; // x0-x28
66 uint64_t fp; // x29
67 uint64_t lr; // x30
68 uint64_t sp; // x31
69 uint64_t pc; // pc
70 uint32_t cpsr; // cpsr
71 uint32_t pad;
72 };
73 LLVM_PACKED_END
74
75 // based on RegisterContextDarwin_arm64.h
76 struct VReg {
77 uint8_t bytes[16];
78 };
79
80 // based on RegisterContextDarwin_arm64.h
81 struct FPU {
82 VReg v[32];
83 uint32_t fpsr;
84 uint32_t fpcr;
85 };
86
87 // based on RegisterContextDarwin_arm64.h
88 struct EXC {
89 uint64_t far; // Virtual Fault Address
90 uint32_t esr; // Exception syndrome
91 uint32_t exception; // number of arm exception token
92 };
93
94 // based on RegisterContextDarwin_arm64.h
95 struct DBG {
96 uint64_t bvr[16];
97 uint64_t bcr[16];
98 uint64_t wvr[16];
99 uint64_t wcr[16];
100 uint64_t mdscr_el1;
101 };
102
104 lldb_private::Flags opt_regsets);
105
106 static size_t GetGPRSizeStatic();
107 size_t GetGPRSize() const override { return GetGPRSizeStatic(); }
108
109 size_t GetFPRSize() const override;
110
111 const lldb_private::RegisterInfo *GetRegisterInfo() const override;
112
113 uint32_t GetRegisterCount() const override;
114
116 GetRegisterSet(size_t reg_set) const override;
117
118 size_t GetRegisterSetCount() const override;
119
120 size_t GetRegisterSetFromRegisterIndex(uint32_t reg_index) const override;
121
122 void AddRegSetPAuth();
123
124 void AddRegSetMTE();
125
126 void AddRegSetTLS(bool has_tpidr2);
127
128 void AddRegSetSME(bool has_zt);
129
130 void AddRegSetFPMR();
131
132 void AddRegSetGCS();
133
134 void AddRegSetPOE();
135
136 uint32_t ConfigureVectorLengthSVE(uint32_t sve_vq);
137
138 void ConfigureVectorLengthZA(uint32_t za_vq);
139
140 bool VectorSizeIsValid(uint32_t vq) {
141 // coverity[unsigned_compare]
143 return true;
144 return false;
145 }
146
147 bool IsSVEPresent() const { return m_opt_regsets.AnySet(eRegsetMaskSVE); }
148 bool IsSSVEPresent() const { return m_opt_regsets.AnySet(eRegsetMaskSSVE); }
149 bool IsZAPresent() const { return m_opt_regsets.AnySet(eRegsetMaskZA); }
150 bool IsZTPresent() const { return m_opt_regsets.AnySet(eRegsetMaskZT); }
151 bool IsPAuthPresent() const { return m_opt_regsets.AnySet(eRegsetMaskPAuth); }
152 bool IsMTEPresent() const { return m_opt_regsets.AnySet(eRegsetMaskMTE); }
153 bool IsTLSPresent() const { return m_opt_regsets.AnySet(eRegsetMaskTLS); }
154 bool IsFPMRPresent() const { return m_opt_regsets.AnySet(eRegsetMaskFPMR); }
155 bool IsGCSPresent() const { return m_opt_regsets.AnySet(eRegsetMaskGCS); }
156 bool IsPOEPresent() const { return m_opt_regsets.AnySet(eRegsetMaskPOE); }
157
158 bool IsGPR(unsigned reg) const;
159 bool IsFPR(unsigned reg) const;
160 bool IsSVEReg(unsigned reg) const;
161 bool IsSVEZReg(unsigned reg) const;
162 bool IsSVEPReg(unsigned reg) const;
163 bool IsSVERegVG(unsigned reg) const;
164 bool IsSVERegFFR(unsigned reg) const;
165 bool IsPAuthReg(unsigned reg) const;
166 bool IsMTEReg(unsigned reg) const;
167 bool IsTLSReg(unsigned reg) const;
168 bool IsSMEReg(unsigned reg) const;
169 bool IsSMERegZA(unsigned reg) const;
170 bool IsSMERegZT(unsigned reg) const;
171 bool IsFPMRReg(unsigned reg) const;
172 bool IsGCSReg(unsigned reg) const;
173 bool IsPOEReg(unsigned reg) const;
174
175 uint32_t GetRegNumSVEZ0() const;
176 uint32_t GetRegNumSVEFFR() const;
177 uint32_t GetRegNumFPCR() const;
178 uint32_t GetRegNumFPSR() const;
179 uint32_t GetRegNumFPV0() const;
180 uint32_t GetRegNumSVEVG() const;
181 uint32_t GetRegNumSMESVG() const;
182 uint32_t GetPAuthOffset() const;
183 uint32_t GetMTEOffset() const;
184 uint32_t GetTLSOffset() const;
185 uint32_t GetSMEOffset() const;
186 uint32_t GetFPMROffset() const;
187 uint32_t GetGCSOffset() const;
188 uint32_t GetPOEOffset() const;
189
190private:
191 typedef std::map<uint32_t, std::vector<lldb_private::RegisterInfo>>
193
195
198
199 // In normal operation this is const. Only when SVE or SME registers change
200 // size is it either replaced or the content modified.
203
206
207 // Contains pair of [start, end] register numbers of a register set with start
208 // and end included.
209 std::map<uint32_t, std::pair<uint32_t, uint32_t>> m_per_regset_regnum_range;
210
212
213 std::vector<lldb_private::RegisterInfo> m_dynamic_reg_infos;
214 std::vector<lldb_private::RegisterSet> m_dynamic_reg_sets;
215
216 std::vector<uint32_t> pauth_regnum_collection;
217 std::vector<uint32_t> m_mte_regnum_collection;
218 std::vector<uint32_t> m_tls_regnum_collection;
219 std::vector<uint32_t> m_sme_regnum_collection;
220 std::vector<uint32_t> m_fpmr_regnum_collection;
221 std::vector<uint32_t> m_gcs_regnum_collection;
222 std::vector<uint32_t> m_poe_regnum_collection;
223};
224
225#endif
size_t GetRegisterSetFromRegisterIndex(uint32_t reg_index) const override
bool IsPOEReg(unsigned reg) const
bool IsSVEPReg(unsigned reg) const
size_t GetGPRSize() const override
uint32_t GetMTEOffset() const
void ConfigureVectorLengthZA(uint32_t za_vq)
bool IsSVERegVG(unsigned reg) const
void AddRegSetTLS(bool has_tpidr2)
const lldb_private::RegisterInfo * GetRegisterInfo() const override
uint32_t GetRegNumFPSR() const
bool VectorSizeIsValid(uint32_t vq)
std::vector< uint32_t > m_poe_regnum_collection
const lldb_private::RegisterSet * GetRegisterSet(size_t reg_set) const override
std::vector< lldb_private::RegisterInfo > m_dynamic_reg_infos
bool IsSVEReg(unsigned reg) const
bool IsGCSReg(unsigned reg) const
std::vector< uint32_t > pauth_regnum_collection
bool IsFPMRReg(unsigned reg) const
bool IsTLSReg(unsigned reg) const
void AddRegSetSME(bool has_zt)
bool IsFPR(unsigned reg) const
const lldb_private::RegisterInfo * m_register_info_p
uint32_t GetFPMROffset() const
const lldb_private::RegisterSet * m_register_set_p
size_t GetFPRSize() const override
uint32_t GetRegNumSVEVG() const
lldb_private::Flags m_opt_regsets
bool IsSVERegFFR(unsigned reg) const
uint32_t GetRegNumSVEFFR() const
uint32_t GetRegisterCount() const override
size_t GetRegisterSetCount() const override
std::vector< uint32_t > m_gcs_regnum_collection
std::vector< uint32_t > m_tls_regnum_collection
uint32_t GetRegNumSMESVG() const
uint32_t GetTLSOffset() const
uint32_t GetRegNumFPV0() const
uint32_t GetSMEOffset() const
std::map< uint32_t, std::vector< lldb_private::RegisterInfo > > per_vq_register_infos
bool IsMTEReg(unsigned reg) const
uint32_t GetRegNumFPCR() const
uint32_t ConfigureVectorLengthSVE(uint32_t sve_vq)
uint32_t GetPAuthOffset() const
per_vq_register_infos m_per_vq_reg_infos
bool IsGPR(unsigned reg) const
RegisterInfo_arm64(const lldb_private::ArchSpec &target_arch, lldb_private::Flags opt_regsets)
std::map< uint32_t, std::pair< uint32_t, uint32_t > > m_per_regset_regnum_range
bool IsSMERegZA(unsigned reg) const
static size_t GetGPRSizeStatic()
uint32_t GetPOEOffset() const
bool IsPAuthReg(unsigned reg) const
bool IsSMERegZT(unsigned reg) const
std::vector< uint32_t > m_sme_regnum_collection
uint32_t GetRegNumSVEZ0() const
uint32_t GetGCSOffset() const
std::vector< lldb_private::RegisterSet > m_dynamic_reg_sets
bool IsSVEZReg(unsigned reg) const
std::vector< uint32_t > m_mte_regnum_collection
std::vector< uint32_t > m_fpmr_regnum_collection
bool IsSMEReg(unsigned reg) const
An architecture specification class.
Definition ArchSpec.h:32
A class to manage flags.
Definition Flags.h:22
Every register is described in detail including its name, alternate name (optional),...
Registers are grouped into register sets.