Skip to content

Commit a90c451

Browse files
captain5050namhyung
authored andcommitted
perf riscv: Remove dwarf-regs.c and add dwarf-regs-table.h
The file just provides the function get_arch_regstr, however, if in the only caller get_dwarf_regstr EM_HOST is used for the EM_NONE case, and the register table is provided in a header file, the function can never be called. So remove as dead code. Tidy up the EM_NONE cases for riscv in dwarf-regs.c. Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Signed-off-by: Ian Rogers <irogers@google.com> Acked-by: Palmer Dabbelt <palmer@rivosinc.com> Cc: Anup Patel <anup@brainfault.org> Cc: Yang Jihong <yangjihong@bytedance.com> Cc: Palmer Dabbelt <palmer@dabbelt.com> Cc: David S. Miller <davem@davemloft.net> Cc: Albert Ou <aou@eecs.berkeley.edu> Cc: Shenlin Liang <liangshenlin@eswincomputing.com> Cc: Nick Terrell <terrelln@fb.com> Cc: Guilherme Amadio <amadio@gentoo.org> Cc: Steinar H. Gunderson <sesse@google.com> Cc: Changbin Du <changbin.du@huawei.com> Cc: Alexander Lobakin <aleksander.lobakin@intel.com> Cc: Przemek Kitszel <przemyslaw.kitszel@intel.com> Cc: Huacai Chen <chenhuacai@kernel.org> Cc: Guo Ren <guoren@kernel.org> Cc: Masahiro Yamada <masahiroy@kernel.org> Cc: Will Deacon <will@kernel.org> Cc: James Clark <james.clark@linaro.org> Cc: Mike Leach <mike.leach@linaro.org> Cc: Chen Pei <cp0613@linux.alibaba.com> Cc: Leo Yan <leo.yan@linux.dev> Cc: Oliver Upton <oliver.upton@linux.dev> Cc: Aditya Gupta <adityag@linux.ibm.com> Cc: Kajol Jain <kjain@linux.ibm.com> Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com> Cc: linux-arm-kernel@lists.infradead.org Cc: linux-riscv@lists.infradead.org Cc: Bibo Mao <maobibo@loongson.cn> Cc: John Garry <john.g.garry@oracle.com> Cc: Atish Patra <atishp@rivosinc.com> Cc: Dima Kogan <dima@secretsauce.net> Cc: Paul Walmsley <paul.walmsley@sifive.com> Cc: Dr. David Alan Gilbert <linux@treblig.org> Cc: linux-csky@vger.kernel.org Link: https://lore.kernel.org/r/20241108234606.429459-15-irogers@google.com Signed-off-by: Namhyung Kim <namhyung@kernel.org>
1 parent 285b523 commit a90c451

4 files changed

Lines changed: 12 additions & 30 deletions

File tree

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,10 @@
1-
// SPDX-License-Identifier: GPL-2.0
2-
/*
3-
* Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd.
4-
* Mapping of DWARF debug register numbers into register names.
5-
*/
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifdef DEFINE_DWARF_REGSTR_TABLE
3+
/* This is included in perf/util/dwarf-regs.c */
64

7-
#include <stddef.h>
8-
#include <errno.h> /* for EINVAL */
9-
#include <string.h> /* for strcmp */
10-
#include <dwarf-regs.h>
5+
#define REG_DWARFNUM_NAME(reg, idx) [idx] = "%" #reg
116

12-
struct regs_dwarfnum {
13-
const char *name;
14-
unsigned int dwarfnum;
15-
};
16-
17-
#define REG_DWARFNUM_NAME(r, num) {.name = r, .dwarfnum = num}
18-
#define REG_DWARFNUM_END {.name = NULL, .dwarfnum = 0}
19-
20-
struct regs_dwarfnum riscv_dwarf_regs_table[] = {
7+
static const char * const riscv_regstr_tbl[] = {
218
REG_DWARFNUM_NAME("%zero", 0),
229
REG_DWARFNUM_NAME("%ra", 1),
2310
REG_DWARFNUM_NAME("%sp", 2),
@@ -50,13 +37,6 @@ struct regs_dwarfnum riscv_dwarf_regs_table[] = {
5037
REG_DWARFNUM_NAME("%t4", 29),
5138
REG_DWARFNUM_NAME("%t5", 30),
5239
REG_DWARFNUM_NAME("%t6", 31),
53-
REG_DWARFNUM_END,
5440
};
5541

56-
#define RISCV_MAX_REGS ((sizeof(riscv_dwarf_regs_table) / \
57-
sizeof(riscv_dwarf_regs_table[0])) - 1)
58-
59-
const char *get_arch_regstr(unsigned int n)
60-
{
61-
return (n < RISCV_MAX_REGS) ? riscv_dwarf_regs_table[n].name : NULL;
62-
}
42+
#endif

tools/perf/arch/riscv/util/Build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ perf-util-y += perf_regs.o
22
perf-util-y += header.o
33

44
perf-util-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o
5-
perf-util-$(CONFIG_LIBDW) += dwarf-regs.o
65
perf-util-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o

tools/perf/util/dwarf-regs.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "../arch/arm64/include/dwarf-regs-table.h"
2121
#include "../arch/sh/include/dwarf-regs-table.h"
2222
#include "../arch/powerpc/include/dwarf-regs-table.h"
23+
#include "../arch/riscv/include/dwarf-regs-table.h"
2324
#include "../arch/s390/include/dwarf-regs-table.h"
2425
#include "../arch/sparc/include/dwarf-regs-table.h"
2526
#include "../arch/xtensa/include/dwarf-regs-table.h"
@@ -33,7 +34,7 @@ const char *get_dwarf_regstr(unsigned int n, unsigned int machine, unsigned int
3334
{
3435
#if EM_HOST == EM_X86_64 || EM_HOST == EM_386 || EM_HOST == EM_AARCH64 || EM_HOST == EM_ARM \
3536
|| EM_HOST == EM_CSKY || EM_HOST == EM_LOONGARCH || EM_HOST == EM_MIPS || EM_HOST == EM_PPC \
36-
|| EM_HOST == EM_PPC64
37+
|| EM_HOST == EM_PPC64 || EM_HOST == EM_RISCV
3738
if (machine == EM_NONE) {
3839
/* Generic arch - use host arch */
3940
machine = EM_HOST;
@@ -42,7 +43,7 @@ const char *get_dwarf_regstr(unsigned int n, unsigned int machine, unsigned int
4243
switch (machine) {
4344
#if EM_HOST != EM_X86_64 && EM_HOST != EM_386 && EM_HOST != EM_AARCH64 && EM_HOST != EM_ARM \
4445
&& EM_HOST != EM_CSKY && EM_HOST != EM_LOONGARCH && EM_HOST != EM_MIPS && EM_HOST != EM_PPC \
45-
&& EM_HOST != EM_PPC64
46+
&& EM_HOST != EM_PPC64 && EM_HOST != EM_RISCV
4647
case EM_NONE: /* Generic arch - use host arch */
4748
return get_arch_regstr(n);
4849
#endif
@@ -63,6 +64,8 @@ const char *get_dwarf_regstr(unsigned int n, unsigned int machine, unsigned int
6364
case EM_PPC:
6465
case EM_PPC64:
6566
return __get_dwarf_regstr(powerpc_regstr_tbl, n);
67+
case EM_RISCV:
68+
return __get_dwarf_regstr(riscv_regstr_tbl, n);
6669
case EM_SPARC:
6770
case EM_SPARCV9:
6871
return __get_dwarf_regstr(sparc_regstr_tbl, n);

tools/perf/util/include/dwarf-regs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
#ifdef HAVE_LIBDW_SUPPORT
9292
#if !defined(__x86_64__) && !defined(__i386__) && !defined(__aarch64__) && !defined(__arm__) \
9393
&& !defined(__loongarch__) && !defined(__mips__) && !defined(__powerpc__) \
94-
&& !defined(__powerpc64__)
94+
&& !defined(__powerpc64__) && !defined(__riscv__)
9595
const char *get_arch_regstr(unsigned int n);
9696
#endif
9797

0 commit comments

Comments
 (0)