]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp
Merge ^/head r285284 through r285340.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / Plugins / Process / Utility / RegisterContextLinux_mips64.cpp
1 //===-- RegisterContextLinux_mips64.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 #if defined (__mips__)
11
12 #include <vector>
13 #include <stddef.h>
14
15 // For GDB, GCC and DWARF Register numbers
16 #include "RegisterContextLinux_mips64.h"
17
18 // Internal codes for all mips64 registers
19 #include "lldb-mips64-register-enums.h"
20 #include "RegisterContext_mips64.h"
21
22 using namespace lldb;
23 using namespace lldb_private;
24
25 // GP registers
26 typedef struct _GPR
27 {
28     uint64_t zero;
29     uint64_t r1;
30     uint64_t r2;
31     uint64_t r3;
32     uint64_t r4;
33     uint64_t r5;
34     uint64_t r6;
35     uint64_t r7;
36     uint64_t r8;
37     uint64_t r9;
38     uint64_t r10;
39     uint64_t r11;
40     uint64_t r12;
41     uint64_t r13;
42     uint64_t r14;
43     uint64_t r15;
44     uint64_t r16;
45     uint64_t r17;
46     uint64_t r18;
47     uint64_t r19;
48     uint64_t r20;
49     uint64_t r21;
50     uint64_t r22;
51     uint64_t r23;
52     uint64_t r24;
53     uint64_t r25;
54     uint64_t r26;
55     uint64_t r27;
56     uint64_t gp;
57     uint64_t sp;
58     uint64_t r30;
59     uint64_t ra;
60     uint64_t mullo;
61     uint64_t mulhi;
62     uint64_t pc;
63     uint64_t badvaddr;
64     uint64_t sr;
65     uint64_t cause;
66     uint64_t ic;
67     uint64_t dummy;
68 } GPR;
69
70 //---------------------------------------------------------------------------
71 // Include RegisterInfos_mips64 to declare our g_register_infos_mips64 structure.
72 //---------------------------------------------------------------------------
73 #define DECLARE_REGISTER_INFOS_MIPS64_STRUCT
74 #include "RegisterInfos_mips64.h"
75 #undef DECLARE_REGISTER_INFOS_MIPS64_STRUCT
76
77 //---------------------------------------------------------------------------
78 // Include RegisterInfos_mips to declare our g_register_infos_mips structure.
79 //---------------------------------------------------------------------------
80 #define DECLARE_REGISTER_INFOS_MIPS_STRUCT
81 #include "RegisterInfos_mips.h"
82 #undef DECLARE_REGISTER_INFOS_MIPS_STRUCT
83
84 static const RegisterInfo *
85 GetRegisterInfoPtr (const ArchSpec &target_arch)
86 {
87     switch (target_arch.GetMachine())
88     {
89         case llvm::Triple::mips64:
90         case llvm::Triple::mips64el:
91             return g_register_infos_mips64;
92         case llvm::Triple::mips:
93         case llvm::Triple::mipsel:
94             return g_register_infos_mips;
95         default:
96             assert(false && "Unhandled target architecture.");
97             return nullptr;
98     }
99 }
100
101 static uint32_t
102 GetRegisterInfoCount (const ArchSpec &target_arch)
103 {
104     switch (target_arch.GetMachine())
105     {
106         case llvm::Triple::mips64:
107         case llvm::Triple::mips64el:
108             return static_cast<uint32_t> (sizeof (g_register_infos_mips64) / sizeof (g_register_infos_mips64 [0]));
109         case llvm::Triple::mips:
110         case llvm::Triple::mipsel:
111             return static_cast<uint32_t> (sizeof (g_register_infos_mips) / sizeof (g_register_infos_mips [0]));
112         default:
113             assert(false && "Unhandled target architecture.");
114             return 0;
115     }
116 }
117
118 RegisterContextLinux_mips64::RegisterContextLinux_mips64(const ArchSpec &target_arch) :
119     lldb_private::RegisterInfoInterface(target_arch),
120     m_register_info_p (GetRegisterInfoPtr (target_arch)),
121     m_register_info_count (GetRegisterInfoCount (target_arch))
122 {
123 }
124
125 size_t
126 RegisterContextLinux_mips64::GetGPRSize() const
127 {
128     return sizeof(GPR);
129 }
130
131 const RegisterInfo *
132 RegisterContextLinux_mips64::GetRegisterInfo() const
133 {
134     return m_register_info_p;
135 }
136
137 uint32_t
138 RegisterContextLinux_mips64::GetRegisterCount () const
139 {
140     return m_register_info_count;
141 }
142
143 #endif