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