1 // SPDX-License-Identifier: GPL-2.0
2 
3 #ifdef HAVE_PERF_REGS_SUPPORT
4 
5 #include "../perf_regs.h"
6 #include "../../../arch/loongarch/include/uapi/asm/perf_regs.h"
7 
8 const char *__perf_reg_name_loongarch(int id)
9 {
10 	switch (id) {
11 	case PERF_REG_LOONGARCH_PC:
12 		return "PC";
13 	case PERF_REG_LOONGARCH_R1:
14 		return "%r1";
15 	case PERF_REG_LOONGARCH_R2:
16 		return "%r2";
17 	case PERF_REG_LOONGARCH_R3:
18 		return "%r3";
19 	case PERF_REG_LOONGARCH_R4:
20 		return "%r4";
21 	case PERF_REG_LOONGARCH_R5:
22 		return "%r5";
23 	case PERF_REG_LOONGARCH_R6:
24 		return "%r6";
25 	case PERF_REG_LOONGARCH_R7:
26 		return "%r7";
27 	case PERF_REG_LOONGARCH_R8:
28 		return "%r8";
29 	case PERF_REG_LOONGARCH_R9:
30 		return "%r9";
31 	case PERF_REG_LOONGARCH_R10:
32 		return "%r10";
33 	case PERF_REG_LOONGARCH_R11:
34 		return "%r11";
35 	case PERF_REG_LOONGARCH_R12:
36 		return "%r12";
37 	case PERF_REG_LOONGARCH_R13:
38 		return "%r13";
39 	case PERF_REG_LOONGARCH_R14:
40 		return "%r14";
41 	case PERF_REG_LOONGARCH_R15:
42 		return "%r15";
43 	case PERF_REG_LOONGARCH_R16:
44 		return "%r16";
45 	case PERF_REG_LOONGARCH_R17:
46 		return "%r17";
47 	case PERF_REG_LOONGARCH_R18:
48 		return "%r18";
49 	case PERF_REG_LOONGARCH_R19:
50 		return "%r19";
51 	case PERF_REG_LOONGARCH_R20:
52 		return "%r20";
53 	case PERF_REG_LOONGARCH_R21:
54 		return "%r21";
55 	case PERF_REG_LOONGARCH_R22:
56 		return "%r22";
57 	case PERF_REG_LOONGARCH_R23:
58 		return "%r23";
59 	case PERF_REG_LOONGARCH_R24:
60 		return "%r24";
61 	case PERF_REG_LOONGARCH_R25:
62 		return "%r25";
63 	case PERF_REG_LOONGARCH_R26:
64 		return "%r26";
65 	case PERF_REG_LOONGARCH_R27:
66 		return "%r27";
67 	case PERF_REG_LOONGARCH_R28:
68 		return "%r28";
69 	case PERF_REG_LOONGARCH_R29:
70 		return "%r29";
71 	case PERF_REG_LOONGARCH_R30:
72 		return "%r30";
73 	case PERF_REG_LOONGARCH_R31:
74 		return "%r31";
75 	default:
76 		break;
77 	}
78 	return NULL;
79 }
80 
81 uint64_t __perf_reg_ip_loongarch(void)
82 {
83 	return PERF_REG_LOONGARCH_PC;
84 }
85 
86 uint64_t __perf_reg_sp_loongarch(void)
87 {
88 	return PERF_REG_LOONGARCH_R3;
89 }
90 
91 #endif
92