xref: /linux/tools/perf/util/dwarf-regs-csky.c (revision cdd30ebb1b9f36159d66f088b61aee264e649d7a)
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd.
3 // Mapping of DWARF debug register numbers into register names.
4 
5 #include <stddef.h>
6 #include <dwarf-regs.h>
7 
8 #define CSKY_ABIV2_MAX_REGS 73
9 const char *csky_dwarf_regs_table_abiv2[CSKY_ABIV2_MAX_REGS] = {
10 	/* r0 ~ r8 */
11 	"%a0", "%a1", "%a2", "%a3", "%regs0", "%regs1", "%regs2", "%regs3",
12 	/* r9 ~ r15 */
13 	"%regs4", "%regs5", "%regs6", "%regs7", "%regs8", "%regs9", "%sp",
14 	"%lr",
15 	/* r16 ~ r23 */
16 	"%exregs0", "%exregs1", "%exregs2", "%exregs3", "%exregs4",
17 	"%exregs5", "%exregs6", "%exregs7",
18 	/* r24 ~ r31 */
19 	"%exregs8", "%exregs9", "%exregs10", "%exregs11", "%exregs12",
20 	"%exregs13", "%exregs14", "%tls",
21 	"%pc", NULL, NULL, NULL, "%hi", "%lo", NULL, NULL,
22 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
23 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
24 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
25 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
26 	"%epc",
27 };
28 
29 #define CSKY_ABIV1_MAX_REGS 57
30 const char *csky_dwarf_regs_table_abiv1[CSKY_ABIV1_MAX_REGS] = {
31 	/* r0 ~ r8 */
32 	"%sp", "%regs9", "%a0", "%a1", "%a2", "%a3", "%regs0", "%regs1",
33 	/* r9 ~ r15 */
34 	"%regs2", "%regs3", "%regs4", "%regs5", "%regs6", "%regs7", "%regs8",
35 	"%lr",
36 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
37 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
38 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
39 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
40 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
41 	"%epc",
42 };
43 
44 const char *get_csky_regstr(unsigned int n, unsigned int flags)
45 {
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;
50 }
51