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