| 1 | //===-- RegisterContextPOSIX_riscv64.cpp ------------------------*- 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 | #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" |
| 18 | |
| 19 | #include "RegisterContextPOSIX_riscv64.h" |
| 20 | |
| 21 | using namespace lldb; |
| 22 | using namespace lldb_private; |
| 23 | |
| 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)) {} |
| 29 | |
| 30 | RegisterContextPOSIX_riscv64::~RegisterContextPOSIX_riscv64() = default; |
| 31 | |
| 32 | void RegisterContextPOSIX_riscv64::invalidate() {} |
| 33 | |
| 34 | void RegisterContextPOSIX_riscv64::InvalidateAllRegisters() {} |
| 35 | |
| 36 | size_t RegisterContextPOSIX_riscv64::GetRegisterCount() { |
| 37 | return m_register_info_up->GetRegisterCount(); |
| 38 | } |
| 39 | |
| 40 | size_t RegisterContextPOSIX_riscv64::GetGPRSize() { |
| 41 | return m_register_info_up->GetGPRSize(); |
| 42 | } |
| 43 | |
| 44 | unsigned RegisterContextPOSIX_riscv64::GetRegisterSize(unsigned int reg) { |
| 45 | return m_register_info_up->GetRegisterInfo()[reg].byte_size; |
| 46 | } |
| 47 | |
| 48 | unsigned RegisterContextPOSIX_riscv64::GetRegisterOffset(unsigned int reg) { |
| 49 | return m_register_info_up->GetRegisterInfo()[reg].byte_offset; |
| 50 | } |
| 51 | |
| 52 | const lldb_private::RegisterInfo * |
| 53 | RegisterContextPOSIX_riscv64::GetRegisterInfoAtIndex(size_t reg) { |
| 54 | if (reg < GetRegisterCount()) |
| 55 | return &GetRegisterInfo()[reg]; |
| 56 | |
| 57 | return nullptr; |
| 58 | } |
| 59 | |
| 60 | size_t RegisterContextPOSIX_riscv64::GetRegisterSetCount() { |
| 61 | return m_register_info_up->GetRegisterSetCount(); |
| 62 | } |
| 63 | |
| 64 | const lldb_private::RegisterSet * |
| 65 | RegisterContextPOSIX_riscv64::GetRegisterSet(size_t set) { |
| 66 | return m_register_info_up->GetRegisterSet(reg_set: set); |
| 67 | } |
| 68 | |
| 69 | const lldb_private::RegisterInfo * |
| 70 | RegisterContextPOSIX_riscv64::GetRegisterInfo() { |
| 71 | return m_register_info_up->GetRegisterInfo(); |
| 72 | } |
| 73 | |
| 74 | bool RegisterContextPOSIX_riscv64::IsGPR(unsigned int reg) { |
| 75 | return m_register_info_up->GetRegisterSetFromRegisterIndex(reg_index: reg) == |
| 76 | RegisterInfoPOSIX_riscv64::GPRegSet; |
| 77 | } |
| 78 | |
| 79 | bool RegisterContextPOSIX_riscv64::IsFPR(unsigned int reg) { |
| 80 | return m_register_info_up->IsFPReg(reg); |
| 81 | } |
| 82 |
