1*0b57cec5SDimitry Andric //===-- RegisterContextLinux_s390x.cpp ------------------------------------===// 2*0b57cec5SDimitry Andric // 3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*0b57cec5SDimitry Andric // 7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 8*0b57cec5SDimitry Andric 9*0b57cec5SDimitry Andric #include "RegisterContextLinux_s390x.h" 10*0b57cec5SDimitry Andric #include "RegisterContextPOSIX_s390x.h" 11*0b57cec5SDimitry Andric 12*0b57cec5SDimitry Andric using namespace lldb_private; 13*0b57cec5SDimitry Andric using namespace lldb; 14*0b57cec5SDimitry Andric 15*0b57cec5SDimitry Andric // Include RegisterInfos_s390x to declare our g_register_infos_s390x structure. 16*0b57cec5SDimitry Andric #define DECLARE_REGISTER_INFOS_S390X_STRUCT 17*0b57cec5SDimitry Andric #include "RegisterInfos_s390x.h" 18*0b57cec5SDimitry Andric #undef DECLARE_REGISTER_INFOS_S390X_STRUCT 19*0b57cec5SDimitry Andric GetRegisterInfoPtr(const ArchSpec & target_arch)20*0b57cec5SDimitry Andricstatic const RegisterInfo *GetRegisterInfoPtr(const ArchSpec &target_arch) { 21*0b57cec5SDimitry Andric switch (target_arch.GetMachine()) { 22*0b57cec5SDimitry Andric case llvm::Triple::systemz: 23*0b57cec5SDimitry Andric return g_register_infos_s390x; 24*0b57cec5SDimitry Andric default: 25*0b57cec5SDimitry Andric assert(false && "Unhandled target architecture."); 26*0b57cec5SDimitry Andric return nullptr; 27*0b57cec5SDimitry Andric } 28*0b57cec5SDimitry Andric } 29*0b57cec5SDimitry Andric GetRegisterInfoCount(const ArchSpec & target_arch)30*0b57cec5SDimitry Andricstatic uint32_t GetRegisterInfoCount(const ArchSpec &target_arch) { 31*0b57cec5SDimitry Andric switch (target_arch.GetMachine()) { 32*0b57cec5SDimitry Andric case llvm::Triple::systemz: 33*0b57cec5SDimitry Andric return k_num_registers_s390x; 34*0b57cec5SDimitry Andric default: 35*0b57cec5SDimitry Andric assert(false && "Unhandled target architecture."); 36*0b57cec5SDimitry Andric return 0; 37*0b57cec5SDimitry Andric } 38*0b57cec5SDimitry Andric } 39*0b57cec5SDimitry Andric GetUserRegisterInfoCount(const ArchSpec & target_arch)40*0b57cec5SDimitry Andricstatic uint32_t GetUserRegisterInfoCount(const ArchSpec &target_arch) { 41*0b57cec5SDimitry Andric switch (target_arch.GetMachine()) { 42*0b57cec5SDimitry Andric case llvm::Triple::systemz: 43*0b57cec5SDimitry Andric return k_num_user_registers_s390x + k_num_linux_registers_s390x; 44*0b57cec5SDimitry Andric default: 45*0b57cec5SDimitry Andric assert(false && "Unhandled target architecture."); 46*0b57cec5SDimitry Andric return 0; 47*0b57cec5SDimitry Andric } 48*0b57cec5SDimitry Andric } 49*0b57cec5SDimitry Andric RegisterContextLinux_s390x(const ArchSpec & target_arch)50*0b57cec5SDimitry AndricRegisterContextLinux_s390x::RegisterContextLinux_s390x( 51*0b57cec5SDimitry Andric const ArchSpec &target_arch) 52*0b57cec5SDimitry Andric : lldb_private::RegisterInfoInterface(target_arch), 53*0b57cec5SDimitry Andric m_register_info_p(GetRegisterInfoPtr(target_arch)), 54*0b57cec5SDimitry Andric m_register_info_count(GetRegisterInfoCount(target_arch)), 55*0b57cec5SDimitry Andric m_user_register_count(GetUserRegisterInfoCount(target_arch)) {} 56*0b57cec5SDimitry Andric 57*0b57cec5SDimitry Andric const std::vector<lldb_private::RegisterInfo> * GetDynamicRegisterInfoP() const58*0b57cec5SDimitry AndricRegisterContextLinux_s390x::GetDynamicRegisterInfoP() const { 59*0b57cec5SDimitry Andric return &d_register_infos; 60*0b57cec5SDimitry Andric } 61*0b57cec5SDimitry Andric GetRegisterInfo() const62*0b57cec5SDimitry Andricconst RegisterInfo *RegisterContextLinux_s390x::GetRegisterInfo() const { 63*0b57cec5SDimitry Andric return m_register_info_p; 64*0b57cec5SDimitry Andric } 65*0b57cec5SDimitry Andric GetRegisterCount() const66*0b57cec5SDimitry Andricuint32_t RegisterContextLinux_s390x::GetRegisterCount() const { 67*0b57cec5SDimitry Andric return m_register_info_count; 68*0b57cec5SDimitry Andric } 69*0b57cec5SDimitry Andric GetUserRegisterCount() const70*0b57cec5SDimitry Andricuint32_t RegisterContextLinux_s390x::GetUserRegisterCount() const { 71*0b57cec5SDimitry Andric return m_user_register_count; 72*0b57cec5SDimitry Andric } 73*0b57cec5SDimitry Andric GetGPRSize() const74*0b57cec5SDimitry Andricsize_t RegisterContextLinux_s390x::GetGPRSize() const { return 0; } 75