[lldb] Use llvm::MC for register numbers in AArch64 ABIs

Summary:
This is equivalent to previous patches (e.g. 07355c1c0) for the x86 ABIs.

One name fixup is needed -- lldb refers to the floating/vector registers by
their vector name (vN). Llvm does not use this name, so we map it to qN,
representing the register as a single 128 bit value (this choice is fairly
arbitrary -- any other name would also work fine as they all have the same
DWARF number).

Reviewers: JDevlieghere, jasonmolenda, omjavaid

Reviewed By: omjavaid

Subscribers: clayborg, danielkiss, aprantl, kristof.beyls, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D75607
This commit is contained in:
Pavel Labath 2020-05-14 13:25:57 +02:00 committed by Pavel Labath
parent 2045189043
commit 638efe3929
6 changed files with 51 additions and 3254 deletions

View File

@ -1,4 +1,4 @@
//===-- AArch64.h ---------------------------------------------------------===//
//===-- AArch66.h ---------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@ -9,6 +9,7 @@
#include "ABIAArch64.h"
#include "ABIMacOSX_arm64.h"
#include "ABISysV_arm64.h"
#include "Utility/ARM64_DWARF_Registers.h"
#include "lldb/Core/PluginManager.h"
LLDB_PLUGIN_DEFINE(ABIAArch64)
@ -22,3 +23,30 @@ void ABIAArch64::Terminate() {
ABISysV_arm64::Terminate();
ABIMacOSX_arm64::Terminate();
}
std::pair<uint32_t, uint32_t>
ABIAArch64::GetEHAndDWARFNums(llvm::StringRef name) {
if (name == "pc")
return {LLDB_INVALID_REGNUM, arm64_dwarf::pc};
if (name == "cpsr")
return {LLDB_INVALID_REGNUM, arm64_dwarf::cpsr};
return MCBasedABI::GetEHAndDWARFNums(name);
}
uint32_t ABIAArch64::GetGenericNum(llvm::StringRef name) {
return llvm::StringSwitch<uint32_t>(name)
.Case("pc", LLDB_REGNUM_GENERIC_PC)
.Case("lr", LLDB_REGNUM_GENERIC_RA)
.Case("sp", LLDB_REGNUM_GENERIC_SP)
.Case("fp", LLDB_REGNUM_GENERIC_FP)
.Case("cpsr", LLDB_REGNUM_GENERIC_FLAGS)
.Case("x0", LLDB_REGNUM_GENERIC_ARG1)
.Case("x1", LLDB_REGNUM_GENERIC_ARG2)
.Case("x2", LLDB_REGNUM_GENERIC_ARG3)
.Case("x3", LLDB_REGNUM_GENERIC_ARG4)
.Case("x4", LLDB_REGNUM_GENERIC_ARG5)
.Case("x5", LLDB_REGNUM_GENERIC_ARG6)
.Case("x6", LLDB_REGNUM_GENERIC_ARG7)
.Case("x7", LLDB_REGNUM_GENERIC_ARG8)
.Default(LLDB_INVALID_REGNUM);
}

View File

@ -9,9 +9,24 @@
#ifndef LLDB_SOURCE_PLUGINS_ABI_AARCH64_ABIAARCH64_H
#define LLDB_SOURCE_PLUGINS_ABI_AARCH64_ABIAARCH64_H
class ABIAArch64 {
#include "lldb/Target/ABI.h"
class ABIAArch64: public lldb_private::MCBasedABI {
public:
static void Initialize();
static void Terminate();
protected:
std::pair<uint32_t, uint32_t>
GetEHAndDWARFNums(llvm::StringRef name) override;
std::string GetMCName(std::string reg) override {
MapRegisterName(reg, "v", "q");
return reg;
}
uint32_t GetGenericNum(llvm::StringRef name) override;
using lldb_private::MCBasedABI::MCBasedABI;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -9,11 +9,11 @@
#ifndef LLDB_SOURCE_PLUGINS_ABI_AARCH64_ABIMACOSX_ARM64_H
#define LLDB_SOURCE_PLUGINS_ABI_AARCH64_ABIMACOSX_ARM64_H
#include "lldb/Target/ABI.h"
#include "Plugins/ABI/AArch64/ABIAArch64.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/lldb-private.h"
class ABIMacOSX_arm64 : public lldb_private::RegInfoBasedABI {
class ABIMacOSX_arm64 : public ABIAArch64 {
public:
~ABIMacOSX_arm64() override = default;
@ -62,9 +62,6 @@ public:
return true;
}
const lldb_private::RegisterInfo *
GetRegisterInfoArray(uint32_t &count) override;
// Static Functions
static void Initialize();
@ -93,7 +90,7 @@ protected:
lldb_private::CompilerType &ast_type) const override;
private:
using lldb_private::RegInfoBasedABI::RegInfoBasedABI; // Call CreateInstance instead.
using ABIAArch64::ABIAArch64; // Call CreateInstance instead.
};
#endif // LLDB_SOURCE_PLUGINS_ABI_AARCH64_ABIMACOSX_ARM64_H

File diff suppressed because it is too large Load Diff

View File

@ -9,10 +9,10 @@
#ifndef LLDB_SOURCE_PLUGINS_ABI_AARCH64_ABISYSV_ARM64_H
#define LLDB_SOURCE_PLUGINS_ABI_AARCH64_ABISYSV_ARM64_H
#include "lldb/Target/ABI.h"
#include "Plugins/ABI/AArch64/ABIAArch64.h"
#include "lldb/lldb-private.h"
class ABISysV_arm64 : public lldb_private::RegInfoBasedABI {
class ABISysV_arm64 : public ABIAArch64 {
public:
~ABISysV_arm64() override = default;
@ -65,9 +65,6 @@ public:
return true;
}
const lldb_private::RegisterInfo *
GetRegisterInfoArray(uint32_t &count) override;
bool GetPointerReturnRegister(const char *&name) override;
// Static Functions
@ -92,7 +89,7 @@ protected:
lldb_private::CompilerType &ast_type) const override;
private:
using lldb_private::RegInfoBasedABI::RegInfoBasedABI; // Call CreateInstance instead.
using ABIAArch64::ABIAArch64; // Call CreateInstance instead.
};
#endif // LLDB_SOURCE_PLUGINS_ABI_AARCH64_ABISYSV_ARM64_H