1 //===-- AArch66.h ---------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "ABIAArch64.h"
10 #include "ABIMacOSX_arm64.h"
11 #include "ABISysV_arm64.h"
12 #include "Utility/ARM64_DWARF_Registers.h"
13 #include "lldb/Core/PluginManager.h"
14 
LLDB_PLUGIN_DEFINE(ABIAArch64)15 LLDB_PLUGIN_DEFINE(ABIAArch64)
16 
17 void ABIAArch64::Initialize() {
18   ABISysV_arm64::Initialize();
19   ABIMacOSX_arm64::Initialize();
20 }
21 
Terminate()22 void ABIAArch64::Terminate() {
23   ABISysV_arm64::Terminate();
24   ABIMacOSX_arm64::Terminate();
25 }
26 
27 std::pair<uint32_t, uint32_t>
GetEHAndDWARFNums(llvm::StringRef name)28 ABIAArch64::GetEHAndDWARFNums(llvm::StringRef name) {
29   if (name == "pc")
30     return {LLDB_INVALID_REGNUM, arm64_dwarf::pc};
31   if (name == "cpsr")
32     return {LLDB_INVALID_REGNUM, arm64_dwarf::cpsr};
33   return MCBasedABI::GetEHAndDWARFNums(name);
34 }
35 
GetMCName(std::string reg)36 std::string ABIAArch64::GetMCName(std::string reg) {
37   MapRegisterName(reg, "v", "q");
38   MapRegisterName(reg, "x29", "fp");
39   MapRegisterName(reg, "x30", "lr");
40   return reg;
41 }
GetGenericNum(llvm::StringRef name)42 uint32_t ABIAArch64::GetGenericNum(llvm::StringRef name) {
43   return llvm::StringSwitch<uint32_t>(name)
44       .Case("pc", LLDB_REGNUM_GENERIC_PC)
45       .Case("lr", LLDB_REGNUM_GENERIC_RA)
46       .Case("sp", LLDB_REGNUM_GENERIC_SP)
47       .Case("fp", LLDB_REGNUM_GENERIC_FP)
48       .Case("cpsr", LLDB_REGNUM_GENERIC_FLAGS)
49       .Case("x0", LLDB_REGNUM_GENERIC_ARG1)
50       .Case("x1", LLDB_REGNUM_GENERIC_ARG2)
51       .Case("x2", LLDB_REGNUM_GENERIC_ARG3)
52       .Case("x3", LLDB_REGNUM_GENERIC_ARG4)
53       .Case("x4", LLDB_REGNUM_GENERIC_ARG5)
54       .Case("x5", LLDB_REGNUM_GENERIC_ARG6)
55       .Case("x6", LLDB_REGNUM_GENERIC_ARG7)
56       .Case("x7", LLDB_REGNUM_GENERIC_ARG8)
57       .Default(LLDB_INVALID_REGNUM);
58 }
59