[RISCV] Add RVVConstraint to SiFive custom matrix multiply instructions. (#124055)
[llvm-project.git] / lldb / source / Plugins / Process / Linux / NativeRegisterContextLinux_arm64.h
blob16190b5492582b5b1783f692aa39fb334e43e794
1 //===-- NativeRegisterContextLinux_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 //===----------------------------------------------------------------------===//
9 #if defined(__arm64__) || defined(__aarch64__)
11 #ifndef lldb_NativeRegisterContextLinux_arm64_h
12 #define lldb_NativeRegisterContextLinux_arm64_h
14 #include "Plugins/Process/Linux/NativeRegisterContextLinux.h"
15 #include "Plugins/Process/Utility/LinuxPTraceDefines_arm64sve.h"
16 #include "Plugins/Process/Utility/NativeRegisterContextDBReg_arm64.h"
17 #include "Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h"
19 #include <asm/ptrace.h>
21 namespace lldb_private {
22 namespace process_linux {
24 class NativeProcessLinux;
26 class NativeRegisterContextLinux_arm64
27 : public NativeRegisterContextLinux,
28 public NativeRegisterContextDBReg_arm64 {
29 public:
30 NativeRegisterContextLinux_arm64(
31 const ArchSpec &target_arch, NativeThreadProtocol &native_thread,
32 std::unique_ptr<RegisterInfoPOSIX_arm64> register_info_up);
34 uint32_t GetRegisterSetCount() const override;
36 uint32_t GetUserRegisterCount() const override;
38 const RegisterSet *GetRegisterSet(uint32_t set_index) const override;
40 Status ReadRegister(const RegisterInfo *reg_info,
41 RegisterValue &reg_value) override;
43 Status WriteRegister(const RegisterInfo *reg_info,
44 const RegisterValue &reg_value) override;
46 Status ReadAllRegisterValues(lldb::WritableDataBufferSP &data_sp) override;
48 Status WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
50 void InvalidateAllRegisters() override;
52 std::vector<uint32_t>
53 GetExpeditedRegisters(ExpeditedRegs expType) const override;
55 bool RegisterOffsetIsDynamic() const override { return true; }
57 llvm::Expected<MemoryTaggingDetails>
58 GetMemoryTaggingDetails(int32_t type) override;
60 protected:
61 Status ReadGPR() override;
63 Status WriteGPR() override;
65 Status ReadFPR() override;
67 Status WriteFPR() override;
69 void *GetGPRBuffer() override { return &m_gpr_arm64; }
71 // GetGPRBufferSize returns sizeof arm64 GPR ptrace buffer, it is different
72 // from GetGPRSize which returns sizeof RegisterInfoPOSIX_arm64::GPR.
73 size_t GetGPRBufferSize() { return sizeof(m_gpr_arm64); }
75 void *GetFPRBuffer() override { return &m_fpr; }
77 size_t GetFPRSize() override { return sizeof(m_fpr); }
79 lldb::addr_t FixWatchpointHitAddress(lldb::addr_t hit_addr) override;
81 private:
82 bool m_gpr_is_valid;
83 bool m_fpu_is_valid;
84 bool m_sve_buffer_is_valid;
85 bool m_mte_ctrl_is_valid;
86 bool m_zt_buffer_is_valid;
87 bool m_fpmr_is_valid;
89 bool m_sve_header_is_valid;
90 bool m_za_buffer_is_valid;
91 bool m_za_header_is_valid;
92 bool m_pac_mask_is_valid;
93 bool m_tls_is_valid;
94 size_t m_tls_size;
96 struct user_pt_regs m_gpr_arm64; // 64-bit general purpose registers.
98 RegisterInfoPOSIX_arm64::FPU
99 m_fpr; // floating-point registers including extended register sets.
101 SVEState m_sve_state = SVEState::Unknown;
102 struct sve::user_sve_header m_sve_header;
103 std::vector<uint8_t> m_sve_ptrace_payload;
105 sve::user_za_header m_za_header;
106 std::vector<uint8_t> m_za_ptrace_payload;
108 bool m_refresh_hwdebug_info;
110 struct user_pac_mask {
111 uint64_t data_mask;
112 uint64_t insn_mask;
115 struct user_pac_mask m_pac_mask;
117 uint64_t m_mte_ctrl_reg;
119 struct sme_pseudo_regs {
120 uint64_t ctrl_reg;
121 uint64_t svg_reg;
124 struct sme_pseudo_regs m_sme_pseudo_regs;
126 struct tls_regs {
127 uint64_t tpidr_reg;
128 // Only valid when SME is present.
129 uint64_t tpidr2_reg;
132 struct tls_regs m_tls_regs;
134 // SME2's ZT is a 512 bit register.
135 std::array<uint8_t, 64> m_zt_reg;
137 uint64_t m_fpmr_reg;
139 bool IsGPR(unsigned reg) const;
141 bool IsFPR(unsigned reg) const;
143 Status ReadAllSVE();
145 Status WriteAllSVE();
147 Status ReadSVEHeader();
149 Status WriteSVEHeader();
151 Status ReadPAuthMask();
153 Status ReadMTEControl();
155 Status WriteMTEControl();
157 Status ReadTLS();
159 Status WriteTLS();
161 Status ReadSMESVG();
163 Status ReadZAHeader();
165 Status ReadZA();
167 Status WriteZA();
169 // No WriteZAHeader because writing only the header will disable ZA.
170 // Instead use WriteZA and ensure you have the correct ZA buffer size set
171 // beforehand if you wish to disable it.
173 Status ReadZT();
175 Status WriteZT();
177 // SVCR is a pseudo register and we do not allow writes to it.
178 Status ReadSMEControl();
180 Status ReadFPMR();
182 Status WriteFPMR();
184 bool IsSVE(unsigned reg) const;
185 bool IsSME(unsigned reg) const;
186 bool IsPAuth(unsigned reg) const;
187 bool IsMTE(unsigned reg) const;
188 bool IsTLS(unsigned reg) const;
189 bool IsFPMR(unsigned reg) const;
191 uint64_t GetSVERegVG() { return m_sve_header.vl / 8; }
193 void SetSVERegVG(uint64_t vg) { m_sve_header.vl = vg * 8; }
195 void *GetSVEHeader() { return &m_sve_header; }
197 void *GetZAHeader() { return &m_za_header; }
199 size_t GetZAHeaderSize() { return sizeof(m_za_header); }
201 void *GetPACMask() { return &m_pac_mask; }
203 void *GetMTEControl() { return &m_mte_ctrl_reg; }
205 void *GetTLSBuffer() { return &m_tls_regs; }
207 void *GetSMEPseudoBuffer() { return &m_sme_pseudo_regs; }
209 void *GetZTBuffer() { return m_zt_reg.data(); }
211 void *GetSVEBuffer() { return m_sve_ptrace_payload.data(); }
213 void *GetFPMRBuffer() { return &m_fpmr_reg; }
215 size_t GetSVEHeaderSize() { return sizeof(m_sve_header); }
217 size_t GetPACMaskSize() { return sizeof(m_pac_mask); }
219 size_t GetSVEBufferSize() { return m_sve_ptrace_payload.size(); }
221 unsigned GetSVERegSet();
223 void *GetZABuffer() { return m_za_ptrace_payload.data(); };
225 size_t GetZABufferSize() { return m_za_ptrace_payload.size(); }
227 size_t GetMTEControlSize() { return sizeof(m_mte_ctrl_reg); }
229 size_t GetTLSBufferSize() { return m_tls_size; }
231 size_t GetSMEPseudoBufferSize() { return sizeof(m_sme_pseudo_regs); }
233 size_t GetZTBufferSize() { return m_zt_reg.size(); }
235 size_t GetFPMRBufferSize() { return sizeof(m_fpmr_reg); }
237 llvm::Error ReadHardwareDebugInfo() override;
239 llvm::Error WriteHardwareDebugRegs(DREGType hwbType) override;
241 uint32_t CalculateFprOffset(const RegisterInfo *reg_info) const;
243 RegisterInfoPOSIX_arm64 &GetRegisterInfo() const;
245 void ConfigureRegisterContext();
247 uint32_t CalculateSVEOffset(const RegisterInfo *reg_info) const;
249 Status CacheAllRegisters(uint32_t &cached_size);
252 } // namespace process_linux
253 } // namespace lldb_private
255 #endif // #ifndef lldb_NativeRegisterContextLinux_arm64_h
257 #endif // defined (__arm64__) || defined (__aarch64__)