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) <[email protected]> Signed-off-by: Ian Rogers <[email protected]> Acked-by: Palmer Dabbelt <[email protected]> Cc: Anup Patel <[email protected]> Cc: Yang Jihong <[email protected]> Cc: Palmer Dabbelt <[email protected]> Cc: David S. Miller <[email protected]> Cc: Albert Ou <[email protected]> Cc: Shenlin Liang <[email protected]> Cc: Nick Terrell <[email protected]> Cc: Guilherme Amadio <[email protected]> Cc: Steinar H. Gunderson <[email protected]> Cc: Changbin Du <[email protected]> Cc: Alexander Lobakin <[email protected]> Cc: Przemek Kitszel <[email protected]> Cc: Huacai Chen <[email protected]> Cc: Guo Ren <[email protected]> Cc: Masahiro Yamada <[email protected]> Cc: Will Deacon <[email protected]> Cc: James Clark <[email protected]> Cc: Mike Leach <[email protected]> Cc: Chen Pei <[email protected]> Cc: Leo Yan <[email protected]> Cc: Oliver Upton <[email protected]> Cc: Aditya Gupta <[email protected]> Cc: Kajol Jain <[email protected]> Cc: Athira Rajeev <[email protected]> Cc: [email protected] Cc: [email protected] Cc: Bibo Mao <[email protected]> Cc: John Garry <[email protected]> Cc: Atish Patra <[email protected]> Cc: Dima Kogan <[email protected]> Cc: Paul Walmsley <[email protected]> Cc: Dr. David Alan Gilbert <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]>
1 parent 285b523 commit a90c451

File tree

4 files changed

+12
-30
lines changed

4 files changed

+12
-30
lines changed
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)