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