1 //===-- RegisterInfoPOSIX_ppc64le.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 <cassert>
10 #include <stddef.h>
11 #include <vector>
12 
13 #include "lldb/lldb-defines.h"
14 #include "llvm/Support/Compiler.h"
15 
16 #include "RegisterInfoPOSIX_ppc64le.h"
17 
18 //-----------------------------------------------------------------------------
19 // Include RegisterInfoPOSIX_ppc64le to declare our g_register_infos_ppc64le
20 //-----------------------------------------------------------------------------
21 #define DECLARE_REGISTER_INFOS_PPC64LE_STRUCT
22 #include "RegisterInfos_ppc64le.h"
23 #undef DECLARE_REGISTER_INFOS_PPC64LE_STRUCT
24 
25 static const lldb_private::RegisterInfo *
26 GetRegisterInfoPtr(const lldb_private::ArchSpec &target_arch) {
27   switch (target_arch.GetMachine()) {
28   case llvm::Triple::ppc64le:
29     return g_register_infos_ppc64le;
30   default:
31     assert(false && "Unhandled target architecture.");
32     return NULL;
33   }
34 }
35 
36 static uint32_t
37 GetRegisterInfoCount(const lldb_private::ArchSpec &target_arch) {
38   switch (target_arch.GetMachine()) {
39   case llvm::Triple::ppc64le:
40     return static_cast<uint32_t>(sizeof(g_register_infos_ppc64le) /
41                                  sizeof(g_register_infos_ppc64le[0]));
42   default:
43     assert(false && "Unhandled target architecture.");
44     return 0;
45   }
46 }
47 
48 RegisterInfoPOSIX_ppc64le::RegisterInfoPOSIX_ppc64le(
49     const lldb_private::ArchSpec &target_arch)
50     : lldb_private::RegisterInfoInterface(target_arch),
51       m_register_info_p(GetRegisterInfoPtr(target_arch)),
52       m_register_info_count(GetRegisterInfoCount(target_arch)) {}
53 
54 size_t RegisterInfoPOSIX_ppc64le::GetGPRSize() const {
55   return sizeof(GPR);
56 }
57 
58 const lldb_private::RegisterInfo *
59 RegisterInfoPOSIX_ppc64le::GetRegisterInfo() const {
60   return m_register_info_p;
61 }
62 
63 uint32_t RegisterInfoPOSIX_ppc64le::GetRegisterCount() const {
64   return m_register_info_count;
65 }
66