aboutsummaryrefslogtreecommitdiff
path: root/source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp
blob: 982eefea9ba6ec0e0a7db36fd2a9f5f5e6e6f866 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//===-- RegisterContextLinux_mips.cpp ------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===---------------------------------------------------------------------===//

#include <stddef.h>
#include <vector>

// For eh_frame and DWARF Register numbers
#include "RegisterContextLinux_mips.h"

// Internal codes for mips registers
#include "lldb-mips-linux-register-enums.h"

// For GP and FP buffers
#include "RegisterContext_mips.h"

using namespace lldb_private;
using namespace lldb;

//---------------------------------------------------------------------------
// Include RegisterInfos_mips to declare our g_register_infos_mips structure.
//---------------------------------------------------------------------------
#define DECLARE_REGISTER_INFOS_MIPS_STRUCT
#include "RegisterInfos_mips.h"
#undef DECLARE_REGISTER_INFOS_MIPS_STRUCT

uint32_t GetUserRegisterInfoCount(bool msa_present) {
  if (msa_present)
    return static_cast<uint32_t>(k_num_user_registers_mips);
  return static_cast<uint32_t>(k_num_user_registers_mips -
                               k_num_msa_registers_mips);
}

RegisterContextLinux_mips::RegisterContextLinux_mips(
    const ArchSpec &target_arch, bool msa_present)
    : RegisterInfoInterface(target_arch),
      m_user_register_count(GetUserRegisterInfoCount(msa_present)) {}

size_t RegisterContextLinux_mips::GetGPRSize() const {
  return sizeof(GPR_linux_mips);
}

const RegisterInfo *RegisterContextLinux_mips::GetRegisterInfo() const {
  switch (m_target_arch.GetMachine()) {
  case llvm::Triple::mips:
  case llvm::Triple::mipsel:
    return g_register_infos_mips;
  default:
    assert(false && "Unhandled target architecture.");
    return NULL;
  }
}

uint32_t RegisterContextLinux_mips::GetRegisterCount() const {
  return static_cast<uint32_t>(sizeof(g_register_infos_mips) /
                               sizeof(g_register_infos_mips[0]));
}

uint32_t RegisterContextLinux_mips::GetUserRegisterCount() const {
  return static_cast<uint32_t>(m_user_register_count);
}