]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / source / Plugins / Process / Utility / RegisterContextLinux_mips.cpp
1 //===-- RegisterContextLinux_mips.cpp ------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===---------------------------------------------------------------------===//
9
10 #include <stddef.h>
11 #include <vector>
12
13 // For eh_frame and DWARF Register numbers
14 #include "RegisterContextLinux_mips.h"
15
16 // Internal codes for mips registers
17 #include "lldb-mips-linux-register-enums.h"
18
19 // For GP and FP buffers
20 #include "RegisterContext_mips.h"
21
22 using namespace lldb_private;
23 using namespace lldb;
24
25 //---------------------------------------------------------------------------
26 // Include RegisterInfos_mips to declare our g_register_infos_mips structure.
27 //---------------------------------------------------------------------------
28 #define DECLARE_REGISTER_INFOS_MIPS_STRUCT
29 #include "RegisterInfos_mips.h"
30 #undef DECLARE_REGISTER_INFOS_MIPS_STRUCT
31
32 uint32_t GetUserRegisterInfoCount(bool msa_present) {
33   if (msa_present)
34     return static_cast<uint32_t>(k_num_user_registers_mips);
35   return static_cast<uint32_t>(k_num_user_registers_mips -
36                                k_num_msa_registers_mips);
37 }
38
39 RegisterContextLinux_mips::RegisterContextLinux_mips(
40     const ArchSpec &target_arch, bool msa_present)
41     : RegisterInfoInterface(target_arch),
42       m_user_register_count(GetUserRegisterInfoCount(msa_present)) {}
43
44 size_t RegisterContextLinux_mips::GetGPRSize() const {
45   return sizeof(GPR_linux_mips);
46 }
47
48 const RegisterInfo *RegisterContextLinux_mips::GetRegisterInfo() const {
49   switch (m_target_arch.GetMachine()) {
50   case llvm::Triple::mips:
51   case llvm::Triple::mipsel:
52     return g_register_infos_mips;
53   default:
54     assert(false && "Unhandled target architecture.");
55     return NULL;
56   }
57 }
58
59 uint32_t RegisterContextLinux_mips::GetRegisterCount() const {
60   return static_cast<uint32_t>(sizeof(g_register_infos_mips) /
61                                sizeof(g_register_infos_mips[0]));
62 }
63
64 uint32_t RegisterContextLinux_mips::GetUserRegisterCount() const {
65   return static_cast<uint32_t>(m_user_register_count);
66 }