xref: /openbmc/linux/tools/perf/util/perf_regs.h (revision 34af56af)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __PERF_REGS_H
3 #define __PERF_REGS_H
4 
5 #include <linux/types.h>
6 #include <linux/compiler.h>
7 
8 struct regs_dump;
9 
10 struct sample_reg {
11 	const char *name;
12 	uint64_t mask;
13 };
14 
15 #define SMPL_REG_MASK(b) (1ULL << (b))
16 #define SMPL_REG(n, b) { .name = #n, .mask = SMPL_REG_MASK(b) }
17 #define SMPL_REG2_MASK(b) (3ULL << (b))
18 #define SMPL_REG2(n, b) { .name = #n, .mask = SMPL_REG2_MASK(b) }
19 #define SMPL_REG_END { .name = NULL }
20 
21 enum {
22 	SDT_ARG_VALID = 0,
23 	SDT_ARG_SKIP,
24 };
25 
26 int arch_sdt_arg_parse_op(char *old_op, char **new_op);
27 uint64_t arch__intr_reg_mask(void);
28 uint64_t arch__user_reg_mask(void);
29 
30 #ifdef HAVE_PERF_REGS_SUPPORT
31 extern const struct sample_reg sample_reg_masks[];
32 
33 #include <perf_regs.h>
34 
35 const char *perf_reg_name(int id, const char *arch);
36 int perf_reg_value(u64 *valp, struct regs_dump *regs, int id);
37 uint64_t perf_arch_reg_ip(const char *arch);
38 uint64_t perf_arch_reg_sp(const char *arch);
39 const char *__perf_reg_name_arm64(int id);
40 uint64_t __perf_reg_ip_arm64(void);
41 uint64_t __perf_reg_sp_arm64(void);
42 const char *__perf_reg_name_arm(int id);
43 uint64_t __perf_reg_ip_arm(void);
44 uint64_t __perf_reg_sp_arm(void);
45 const char *__perf_reg_name_csky(int id);
46 uint64_t __perf_reg_ip_csky(void);
47 uint64_t __perf_reg_sp_csky(void);
48 const char *__perf_reg_name_loongarch(int id);
49 uint64_t __perf_reg_ip_loongarch(void);
50 uint64_t __perf_reg_sp_loongarch(void);
51 const char *__perf_reg_name_mips(int id);
52 uint64_t __perf_reg_ip_mips(void);
53 uint64_t __perf_reg_sp_mips(void);
54 const char *__perf_reg_name_powerpc(int id);
55 uint64_t __perf_reg_ip_powerpc(void);
56 uint64_t __perf_reg_sp_powerpc(void);
57 const char *__perf_reg_name_riscv(int id);
58 uint64_t __perf_reg_ip_riscv(void);
59 uint64_t __perf_reg_sp_riscv(void);
60 const char *__perf_reg_name_s390(int id);
61 uint64_t __perf_reg_ip_s390(void);
62 uint64_t __perf_reg_sp_s390(void);
63 const char *__perf_reg_name_x86(int id);
64 uint64_t __perf_reg_ip_x86(void);
65 uint64_t __perf_reg_sp_x86(void);
66 
67 static inline uint64_t DWARF_MINIMAL_REGS(const char *arch)
68 {
69 	return (1ULL << perf_arch_reg_ip(arch)) | (1ULL << perf_arch_reg_sp(arch));
70 }
71 
72 #else
73 #define PERF_REGS_MASK	0
74 #define PERF_REGS_MAX	0
75 
76 static inline uint64_t DWARF_MINIMAL_REGS(const char *arch __maybe_unused)
77 {
78 	return PERF_REGS_MASK;
79 }
80 
81 static inline const char *perf_reg_name(int id __maybe_unused, const char *arch __maybe_unused)
82 {
83 	return "unknown";
84 }
85 
86 static inline int perf_reg_value(u64 *valp __maybe_unused,
87 				 struct regs_dump *regs __maybe_unused,
88 				 int id __maybe_unused)
89 {
90 	return 0;
91 }
92 
93 static inline uint64_t perf_arch_reg_ip(const char *arch __maybe_unused)
94 {
95 	return 0;
96 }
97 
98 static inline uint64_t perf_arch_reg_sp(const char *arch __maybe_unused)
99 {
100 	return 0;
101 }
102 
103 #endif /* HAVE_PERF_REGS_SUPPORT */
104 #endif /* __PERF_REGS_H */
105