1 //===-- RegisterContextPOSIX_riscv64.cpp ------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #include "lldb/Target/Process.h"
10 #include "lldb/Target/Target.h"
11 #include "lldb/Target/Thread.h"
12 #include "lldb/Utility/DataBufferHeap.h"
13 #include "lldb/Utility/DataExtractor.h"
14 #include "lldb/Utility/Endian.h"
15 #include "lldb/Utility/RegisterValue.h"
16 #include "lldb/Utility/Scalar.h"
17 #include "llvm/Support/Compiler.h"
19 #include "RegisterContextPOSIX_riscv64.h"
22 using namespace lldb_private
;
24 RegisterContextPOSIX_riscv64::RegisterContextPOSIX_riscv64(
25 lldb_private::Thread
&thread
,
26 std::unique_ptr
<RegisterInfoPOSIX_riscv64
> register_info
)
27 : lldb_private::RegisterContext(thread
, 0),
28 m_register_info_up(std::move(register_info
)) {}
30 RegisterContextPOSIX_riscv64::~RegisterContextPOSIX_riscv64() = default;
32 void RegisterContextPOSIX_riscv64::invalidate() {}
34 void RegisterContextPOSIX_riscv64::InvalidateAllRegisters() {}
36 size_t RegisterContextPOSIX_riscv64::GetRegisterCount() {
37 return m_register_info_up
->GetRegisterCount();
40 size_t RegisterContextPOSIX_riscv64::GetGPRSize() {
41 return m_register_info_up
->GetGPRSize();
44 unsigned RegisterContextPOSIX_riscv64::GetRegisterSize(unsigned int reg
) {
45 return m_register_info_up
->GetRegisterInfo()[reg
].byte_size
;
48 unsigned RegisterContextPOSIX_riscv64::GetRegisterOffset(unsigned int reg
) {
49 return m_register_info_up
->GetRegisterInfo()[reg
].byte_offset
;
52 const lldb_private::RegisterInfo
*
53 RegisterContextPOSIX_riscv64::GetRegisterInfoAtIndex(size_t reg
) {
54 if (reg
< GetRegisterCount())
55 return &GetRegisterInfo()[reg
];
60 size_t RegisterContextPOSIX_riscv64::GetRegisterSetCount() {
61 return m_register_info_up
->GetRegisterCount();
64 const lldb_private::RegisterSet
*
65 RegisterContextPOSIX_riscv64::GetRegisterSet(size_t set
) {
66 return m_register_info_up
->GetRegisterSet(set
);
69 const lldb_private::RegisterInfo
*
70 RegisterContextPOSIX_riscv64::GetRegisterInfo() {
71 return m_register_info_up
->GetRegisterInfo();
74 bool RegisterContextPOSIX_riscv64::IsGPR(unsigned int reg
) {
75 return m_register_info_up
->GetRegisterSetFromRegisterIndex(reg
) ==
76 RegisterInfoPOSIX_riscv64::GPRegSet
;
79 bool RegisterContextPOSIX_riscv64::IsFPR(unsigned int reg
) {
80 return m_register_info_up
->GetRegisterSetFromRegisterIndex(reg
) ==
81 RegisterInfoPOSIX_riscv64::FPRegSet
;