Skip to content

Commit

Permalink
[lldb] Use llvm::MC for register numbers in AArch64 ABIs
Browse files Browse the repository at this point in the history
Summary:
This is equivalent to previous patches (e.g. 07355c1) 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
  • Loading branch information
labath committed May 14, 2020
1 parent 2045189 commit 638efe3
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 3,254 deletions.
30 changes: 29 additions & 1 deletion lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
@@ -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.
Expand All @@ -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)
Expand All @@ -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);
}
17 changes: 16 additions & 1 deletion lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
Expand Up @@ -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

0 comments on commit 638efe3

Please sign in to comment.