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