1bdd1243dSDimitry Andric //===-- RegisterContextPOSIX_riscv64.cpp ------------------------*- C++ -*-===// 2bdd1243dSDimitry Andric // 3bdd1243dSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4bdd1243dSDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5bdd1243dSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6bdd1243dSDimitry Andric // 7bdd1243dSDimitry Andric //===----------------------------------------------------------------------===// 8bdd1243dSDimitry Andric 9bdd1243dSDimitry Andric #include "lldb/Target/Process.h" 10bdd1243dSDimitry Andric #include "lldb/Target/Target.h" 11bdd1243dSDimitry Andric #include "lldb/Target/Thread.h" 12bdd1243dSDimitry Andric #include "lldb/Utility/DataBufferHeap.h" 13bdd1243dSDimitry Andric #include "lldb/Utility/DataExtractor.h" 14bdd1243dSDimitry Andric #include "lldb/Utility/Endian.h" 15bdd1243dSDimitry Andric #include "lldb/Utility/RegisterValue.h" 16bdd1243dSDimitry Andric #include "lldb/Utility/Scalar.h" 17bdd1243dSDimitry Andric #include "llvm/Support/Compiler.h" 18bdd1243dSDimitry Andric 19bdd1243dSDimitry Andric #include "RegisterContextPOSIX_riscv64.h" 20bdd1243dSDimitry Andric 21bdd1243dSDimitry Andric using namespace lldb; 22bdd1243dSDimitry Andric using namespace lldb_private; 23bdd1243dSDimitry Andric 24bdd1243dSDimitry Andric RegisterContextPOSIX_riscv64::RegisterContextPOSIX_riscv64( 25bdd1243dSDimitry Andric lldb_private::Thread &thread, 26bdd1243dSDimitry Andric std::unique_ptr<RegisterInfoPOSIX_riscv64> register_info) 27bdd1243dSDimitry Andric : lldb_private::RegisterContext(thread, 0), 28bdd1243dSDimitry Andric m_register_info_up(std::move(register_info)) {} 29bdd1243dSDimitry Andric 30bdd1243dSDimitry Andric RegisterContextPOSIX_riscv64::~RegisterContextPOSIX_riscv64() = default; 31bdd1243dSDimitry Andric 32bdd1243dSDimitry Andric void RegisterContextPOSIX_riscv64::invalidate() {} 33bdd1243dSDimitry Andric 34bdd1243dSDimitry Andric void RegisterContextPOSIX_riscv64::InvalidateAllRegisters() {} 35bdd1243dSDimitry Andric 36bdd1243dSDimitry Andric size_t RegisterContextPOSIX_riscv64::GetRegisterCount() { 37bdd1243dSDimitry Andric return m_register_info_up->GetRegisterCount(); 38bdd1243dSDimitry Andric } 39bdd1243dSDimitry Andric 40bdd1243dSDimitry Andric size_t RegisterContextPOSIX_riscv64::GetGPRSize() { 41bdd1243dSDimitry Andric return m_register_info_up->GetGPRSize(); 42bdd1243dSDimitry Andric } 43bdd1243dSDimitry Andric 44bdd1243dSDimitry Andric unsigned RegisterContextPOSIX_riscv64::GetRegisterSize(unsigned int reg) { 45bdd1243dSDimitry Andric return m_register_info_up->GetRegisterInfo()[reg].byte_size; 46bdd1243dSDimitry Andric } 47bdd1243dSDimitry Andric 48bdd1243dSDimitry Andric unsigned RegisterContextPOSIX_riscv64::GetRegisterOffset(unsigned int reg) { 49bdd1243dSDimitry Andric return m_register_info_up->GetRegisterInfo()[reg].byte_offset; 50bdd1243dSDimitry Andric } 51bdd1243dSDimitry Andric 52bdd1243dSDimitry Andric const lldb_private::RegisterInfo * 53bdd1243dSDimitry Andric RegisterContextPOSIX_riscv64::GetRegisterInfoAtIndex(size_t reg) { 54bdd1243dSDimitry Andric if (reg < GetRegisterCount()) 55bdd1243dSDimitry Andric return &GetRegisterInfo()[reg]; 56bdd1243dSDimitry Andric 57bdd1243dSDimitry Andric return nullptr; 58bdd1243dSDimitry Andric } 59bdd1243dSDimitry Andric 60bdd1243dSDimitry Andric size_t RegisterContextPOSIX_riscv64::GetRegisterSetCount() { 61*0fca6ea1SDimitry Andric return m_register_info_up->GetRegisterSetCount(); 62bdd1243dSDimitry Andric } 63bdd1243dSDimitry Andric 64bdd1243dSDimitry Andric const lldb_private::RegisterSet * 65bdd1243dSDimitry Andric RegisterContextPOSIX_riscv64::GetRegisterSet(size_t set) { 66bdd1243dSDimitry Andric return m_register_info_up->GetRegisterSet(set); 67bdd1243dSDimitry Andric } 68bdd1243dSDimitry Andric 69bdd1243dSDimitry Andric const lldb_private::RegisterInfo * 70bdd1243dSDimitry Andric RegisterContextPOSIX_riscv64::GetRegisterInfo() { 71bdd1243dSDimitry Andric return m_register_info_up->GetRegisterInfo(); 72bdd1243dSDimitry Andric } 73bdd1243dSDimitry Andric 74bdd1243dSDimitry Andric bool RegisterContextPOSIX_riscv64::IsGPR(unsigned int reg) { 75bdd1243dSDimitry Andric return m_register_info_up->GetRegisterSetFromRegisterIndex(reg) == 76bdd1243dSDimitry Andric RegisterInfoPOSIX_riscv64::GPRegSet; 77bdd1243dSDimitry Andric } 78bdd1243dSDimitry Andric 79bdd1243dSDimitry Andric bool RegisterContextPOSIX_riscv64::IsFPR(unsigned int reg) { 80bdd1243dSDimitry Andric return m_register_info_up->GetRegisterSetFromRegisterIndex(reg) == 81bdd1243dSDimitry Andric RegisterInfoPOSIX_riscv64::FPRegSet; 82bdd1243dSDimitry Andric } 83