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