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 <vector>
11 #include <stddef.h>
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
33 GetUserRegisterInfoCount (bool msa_present)
34 {
35     if (msa_present)
36         return static_cast<uint32_t> (k_num_user_registers_mips);
37     return static_cast<uint32_t> (k_num_user_registers_mips - k_num_msa_registers_mips);
38 }
39 
40 RegisterContextLinux_mips::RegisterContextLinux_mips(const ArchSpec &target_arch, bool msa_present) :
41     RegisterInfoInterface(target_arch),
42     m_user_register_count (GetUserRegisterInfoCount (msa_present))
43 {
44 }
45 
46 size_t
47 RegisterContextLinux_mips::GetGPRSize() const
48 {
49     return sizeof(GPR_linux_mips);
50 }
51 
52 const RegisterInfo *
53 RegisterContextLinux_mips::GetRegisterInfo() const
54 {
55     switch (m_target_arch.GetMachine())
56     {
57         case llvm::Triple::mips:
58         case llvm::Triple::mipsel:
59             return g_register_infos_mips;
60         default:
61             assert(false && "Unhandled target architecture.");
62             return NULL;
63     }
64 }
65 
66 uint32_t
67 RegisterContextLinux_mips::GetRegisterCount () const
68 {
69     return static_cast<uint32_t> (sizeof (g_register_infos_mips) / sizeof (g_register_infos_mips [0]));
70 }
71 
72 uint32_t
73 RegisterContextLinux_mips::GetUserRegisterCount () const
74 {
75     return static_cast<uint32_t> (m_user_register_count);
76 }
77