15ffd83dbSDimitry Andric //===-- RegisterInfoPOSIX_ppc64le.cpp -------------------------------------===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===---------------------------------------------------------------------===//
80b57cec5SDimitry Andric 
90b57cec5SDimitry Andric #include <cassert>
10*5f7ddb14SDimitry Andric #include <cstddef>
110b57cec5SDimitry Andric #include <vector>
120b57cec5SDimitry Andric 
130b57cec5SDimitry Andric #include "lldb/lldb-defines.h"
140b57cec5SDimitry Andric #include "llvm/Support/Compiler.h"
150b57cec5SDimitry Andric 
160b57cec5SDimitry Andric #include "RegisterInfoPOSIX_ppc64le.h"
170b57cec5SDimitry Andric 
180b57cec5SDimitry Andric // Include RegisterInfoPOSIX_ppc64le to declare our g_register_infos_ppc64le
190b57cec5SDimitry Andric #define DECLARE_REGISTER_INFOS_PPC64LE_STRUCT
200b57cec5SDimitry Andric #include "RegisterInfos_ppc64le.h"
210b57cec5SDimitry Andric #undef DECLARE_REGISTER_INFOS_PPC64LE_STRUCT
220b57cec5SDimitry Andric 
230b57cec5SDimitry Andric static const lldb_private::RegisterInfo *
GetRegisterInfoPtr(const lldb_private::ArchSpec & target_arch)240b57cec5SDimitry Andric GetRegisterInfoPtr(const lldb_private::ArchSpec &target_arch) {
250b57cec5SDimitry Andric   switch (target_arch.GetMachine()) {
260b57cec5SDimitry Andric   case llvm::Triple::ppc64le:
270b57cec5SDimitry Andric     return g_register_infos_ppc64le;
280b57cec5SDimitry Andric   default:
290b57cec5SDimitry Andric     assert(false && "Unhandled target architecture.");
300b57cec5SDimitry Andric     return nullptr;
310b57cec5SDimitry Andric   }
320b57cec5SDimitry Andric }
330b57cec5SDimitry Andric 
340b57cec5SDimitry Andric static uint32_t
GetRegisterInfoCount(const lldb_private::ArchSpec & target_arch)350b57cec5SDimitry Andric GetRegisterInfoCount(const lldb_private::ArchSpec &target_arch) {
360b57cec5SDimitry Andric   switch (target_arch.GetMachine()) {
370b57cec5SDimitry Andric   case llvm::Triple::ppc64le:
380b57cec5SDimitry Andric     return static_cast<uint32_t>(sizeof(g_register_infos_ppc64le) /
390b57cec5SDimitry Andric                                  sizeof(g_register_infos_ppc64le[0]));
400b57cec5SDimitry Andric   default:
410b57cec5SDimitry Andric     assert(false && "Unhandled target architecture.");
420b57cec5SDimitry Andric     return 0;
430b57cec5SDimitry Andric   }
440b57cec5SDimitry Andric }
450b57cec5SDimitry Andric 
RegisterInfoPOSIX_ppc64le(const lldb_private::ArchSpec & target_arch)460b57cec5SDimitry Andric RegisterInfoPOSIX_ppc64le::RegisterInfoPOSIX_ppc64le(
470b57cec5SDimitry Andric     const lldb_private::ArchSpec &target_arch)
480b57cec5SDimitry Andric     : lldb_private::RegisterInfoInterface(target_arch),
490b57cec5SDimitry Andric       m_register_info_p(GetRegisterInfoPtr(target_arch)),
500b57cec5SDimitry Andric       m_register_info_count(GetRegisterInfoCount(target_arch)) {}
510b57cec5SDimitry Andric 
GetGPRSize() const520b57cec5SDimitry Andric size_t RegisterInfoPOSIX_ppc64le::GetGPRSize() const {
530b57cec5SDimitry Andric   return sizeof(GPR);
540b57cec5SDimitry Andric }
550b57cec5SDimitry Andric 
560b57cec5SDimitry Andric const lldb_private::RegisterInfo *
GetRegisterInfo() const570b57cec5SDimitry Andric RegisterInfoPOSIX_ppc64le::GetRegisterInfo() const {
580b57cec5SDimitry Andric   return m_register_info_p;
590b57cec5SDimitry Andric }
600b57cec5SDimitry Andric 
GetRegisterCount() const610b57cec5SDimitry Andric uint32_t RegisterInfoPOSIX_ppc64le::GetRegisterCount() const {
620b57cec5SDimitry Andric   return m_register_info_count;
630b57cec5SDimitry Andric }
64