1*acac075bSDimitry Andric //===-- RegisterInfoPOSIX_ppc64le.cpp --------------------------*- C++ -*-===// 2*acac075bSDimitry Andric // 3*acac075bSDimitry Andric // The LLVM Compiler Infrastructure 4*acac075bSDimitry Andric // 5*acac075bSDimitry Andric // This file is distributed under the University of Illinois Open Source 6*acac075bSDimitry Andric // License. See LICENSE.TXT for details. 7*acac075bSDimitry Andric // 8*acac075bSDimitry Andric //===---------------------------------------------------------------------===// 9*acac075bSDimitry Andric 10*acac075bSDimitry Andric #include <cassert> 11*acac075bSDimitry Andric #include <stddef.h> 12*acac075bSDimitry Andric #include <vector> 13*acac075bSDimitry Andric 14*acac075bSDimitry Andric #include "lldb/lldb-defines.h" 15*acac075bSDimitry Andric #include "llvm/Support/Compiler.h" 16*acac075bSDimitry Andric 17*acac075bSDimitry Andric #include "RegisterInfoPOSIX_ppc64le.h" 18*acac075bSDimitry Andric 19*acac075bSDimitry Andric //----------------------------------------------------------------------------- 20*acac075bSDimitry Andric // Include RegisterInfoPOSIX_ppc64le to declare our g_register_infos_ppc64le 21*acac075bSDimitry Andric //----------------------------------------------------------------------------- 22*acac075bSDimitry Andric #define DECLARE_REGISTER_INFOS_PPC64LE_STRUCT 23*acac075bSDimitry Andric #include "RegisterInfos_ppc64le.h" 24*acac075bSDimitry Andric #undef DECLARE_REGISTER_INFOS_PPC64LE_STRUCT 25*acac075bSDimitry Andric 26*acac075bSDimitry Andric static const lldb_private::RegisterInfo * GetRegisterInfoPtr(const lldb_private::ArchSpec & target_arch)27*acac075bSDimitry AndricGetRegisterInfoPtr(const lldb_private::ArchSpec &target_arch) { 28*acac075bSDimitry Andric switch (target_arch.GetMachine()) { 29*acac075bSDimitry Andric case llvm::Triple::ppc64le: 30*acac075bSDimitry Andric return g_register_infos_ppc64le; 31*acac075bSDimitry Andric default: 32*acac075bSDimitry Andric assert(false && "Unhandled target architecture."); 33*acac075bSDimitry Andric return NULL; 34*acac075bSDimitry Andric } 35*acac075bSDimitry Andric } 36*acac075bSDimitry Andric 37*acac075bSDimitry Andric static uint32_t GetRegisterInfoCount(const lldb_private::ArchSpec & target_arch)38*acac075bSDimitry AndricGetRegisterInfoCount(const lldb_private::ArchSpec &target_arch) { 39*acac075bSDimitry Andric switch (target_arch.GetMachine()) { 40*acac075bSDimitry Andric case llvm::Triple::ppc64le: 41*acac075bSDimitry Andric return static_cast<uint32_t>(sizeof(g_register_infos_ppc64le) / 42*acac075bSDimitry Andric sizeof(g_register_infos_ppc64le[0])); 43*acac075bSDimitry Andric default: 44*acac075bSDimitry Andric assert(false && "Unhandled target architecture."); 45*acac075bSDimitry Andric return 0; 46*acac075bSDimitry Andric } 47*acac075bSDimitry Andric } 48*acac075bSDimitry Andric RegisterInfoPOSIX_ppc64le(const lldb_private::ArchSpec & target_arch)49*acac075bSDimitry AndricRegisterInfoPOSIX_ppc64le::RegisterInfoPOSIX_ppc64le( 50*acac075bSDimitry Andric const lldb_private::ArchSpec &target_arch) 51*acac075bSDimitry Andric : lldb_private::RegisterInfoInterface(target_arch), 52*acac075bSDimitry Andric m_register_info_p(GetRegisterInfoPtr(target_arch)), 53*acac075bSDimitry Andric m_register_info_count(GetRegisterInfoCount(target_arch)) {} 54*acac075bSDimitry Andric GetGPRSize() const55*acac075bSDimitry Andricsize_t RegisterInfoPOSIX_ppc64le::GetGPRSize() const { 56*acac075bSDimitry Andric return sizeof(GPR); 57*acac075bSDimitry Andric } 58*acac075bSDimitry Andric 59*acac075bSDimitry Andric const lldb_private::RegisterInfo * GetRegisterInfo() const60*acac075bSDimitry AndricRegisterInfoPOSIX_ppc64le::GetRegisterInfo() const { 61*acac075bSDimitry Andric return m_register_info_p; 62*acac075bSDimitry Andric } 63*acac075bSDimitry Andric GetRegisterCount() const64*acac075bSDimitry Andricuint32_t RegisterInfoPOSIX_ppc64le::GetRegisterCount() const { 65*acac075bSDimitry Andric return m_register_info_count; 66*acac075bSDimitry Andric } 67