Skip to content

Commit d4a0c4f

Browse files
captain5050namhyung
authored andcommitted
perf dwarf-regs: Move csky dwarf-regs out of arch
Move arch/csky/util/dwarf-regs.c to util/dwarf-regs-csky.c and compile in unconditionally. To avoid get_arch_regstr being duplicated, rename to get_csky_regstr and add to get_dwarf_regstr switch. Update #ifdefs to allow ABI V1 and V2 tables at the same time. Determine the table from the ELF flags. Reviewed-by: Masami Hiramatsu (Google) <[email protected]> Signed-off-by: Ian Rogers <[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 0c0a20e commit d4a0c4f

File tree

5 files changed

+20
-14
lines changed

5 files changed

+20
-14
lines changed

tools/perf/arch/csky/util/Build

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

3-
perf-util-$(CONFIG_LIBDW) += dwarf-regs.o
43
perf-util-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o

tools/perf/util/Build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ endif
204204
perf-util-$(CONFIG_LIBDW) += probe-finder.o
205205
perf-util-$(CONFIG_LIBDW) += dwarf-aux.o
206206
perf-util-$(CONFIG_LIBDW) += dwarf-regs.o
207+
perf-util-$(CONFIG_LIBDW) += dwarf-regs-csky.o
207208
perf-util-$(CONFIG_LIBDW) += dwarf-regs-x86.o
208209
perf-util-$(CONFIG_LIBDW) += debuginfo.o
209210
perf-util-$(CONFIG_LIBDW) += annotate-data.o

tools/perf/arch/csky/util/dwarf-regs.c renamed to tools/perf/util/dwarf-regs-csky.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
#include <stddef.h>
66
#include <dwarf-regs.h>
77

8-
#if defined(__CSKYABIV2__)
9-
#define CSKY_MAX_REGS 73
10-
const char *csky_dwarf_regs_table[CSKY_MAX_REGS] = {
8+
#define CSKY_ABIV2_MAX_REGS 73
9+
const char *csky_dwarf_regs_table_abiv2[CSKY_ABIV2_MAX_REGS] = {
1110
/* r0 ~ r8 */
1211
"%a0", "%a1", "%a2", "%a3", "%regs0", "%regs1", "%regs2", "%regs3",
1312
/* r9 ~ r15 */
@@ -26,9 +25,9 @@ const char *csky_dwarf_regs_table[CSKY_MAX_REGS] = {
2625
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
2726
"%epc",
2827
};
29-
#else
30-
#define CSKY_MAX_REGS 57
31-
const char *csky_dwarf_regs_table[CSKY_MAX_REGS] = {
28+
29+
#define CSKY_ABIV1_MAX_REGS 57
30+
const char *csky_dwarf_regs_table_abiv1[CSKY_ABIV1_MAX_REGS] = {
3231
/* r0 ~ r8 */
3332
"%sp", "%regs9", "%a0", "%a1", "%a2", "%a3", "%regs0", "%regs1",
3433
/* r9 ~ r15 */
@@ -41,9 +40,11 @@ const char *csky_dwarf_regs_table[CSKY_MAX_REGS] = {
4140
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
4241
"%epc",
4342
};
44-
#endif
4543

46-
const char *get_arch_regstr(unsigned int n)
44+
const char *get_csky_regstr(unsigned int n, unsigned int flags)
4745
{
48-
return (n < CSKY_MAX_REGS) ? csky_dwarf_regs_table[n] : NULL;
46+
if (flags & EF_CSKY_ABIV2)
47+
return (n < CSKY_ABIV2_MAX_REGS) ? csky_dwarf_regs_table_abiv2[n] : NULL;
48+
49+
return (n < CSKY_ABIV1_MAX_REGS) ? csky_dwarf_regs_table_abiv1[n] : NULL;
4950
}

tools/perf/util/dwarf-regs.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,18 @@
2929
#define __get_dwarf_regstr(tbl, n) (((n) < ARRAY_SIZE(tbl)) ? (tbl)[(n)] : NULL)
3030

3131
/* Return architecture dependent register string (for kprobe-tracer) */
32-
const char *get_dwarf_regstr(unsigned int n, unsigned int machine,
33-
unsigned int flags __maybe_unused)
32+
const char *get_dwarf_regstr(unsigned int n, unsigned int machine, unsigned int flags)
3433
{
35-
#if EM_HOST == EM_X86_64 || EM_HOST == EM_386 || EM_HOST == EM_AARCH64 || EM_HOST == EM_ARM
34+
#if EM_HOST == EM_X86_64 || EM_HOST == EM_386 || EM_HOST == EM_AARCH64 || EM_HOST == EM_ARM \
35+
|| EM_HOST == EM_CSKY
3636
if (machine == EM_NONE) {
3737
/* Generic arch - use host arch */
3838
machine = EM_HOST;
3939
}
4040
#endif
4141
switch (machine) {
42-
#if EM_HOST != EM_X86_64 && EM_HOST != EM_386 && EM_HOST != EM_AARCH64 && EM_HOST != EM_ARM
42+
#if EM_HOST != EM_X86_64 && EM_HOST != EM_386 && EM_HOST != EM_AARCH64 && EM_HOST != EM_ARM \
43+
&& EM_HOST != EM_CSKY
4344
case EM_NONE: /* Generic arch - use host arch */
4445
return get_arch_regstr(n);
4546
#endif
@@ -51,6 +52,8 @@ const char *get_dwarf_regstr(unsigned int n, unsigned int machine,
5152
return __get_dwarf_regstr(arm_regstr_tbl, n);
5253
case EM_AARCH64:
5354
return __get_dwarf_regstr(aarch64_regstr_tbl, n);
55+
case EM_CSKY:
56+
return get_csky_regstr(n, flags);
5457
case EM_SH:
5558
return __get_dwarf_regstr(sh_regstr_tbl, n);
5659
case EM_S390:

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@
9393
const char *get_arch_regstr(unsigned int n);
9494
#endif
9595

96+
const char *get_csky_regstr(unsigned int n, unsigned int flags);
97+
9698
/**
9799
* get_dwarf_regstr() - Returns ftrace register string from DWARF regnum.
98100
* @n: DWARF register number.

0 commit comments

Comments
 (0)