xref: /openbmc/linux/tools/perf/util/perf_regs.h (revision ff382c1c)
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 const char *perf_reg_name(int id, const char *arch);
34 int perf_reg_value(u64 *valp, struct regs_dump *regs, int id);
35 uint64_t perf_arch_reg_ip(const char *arch);
36 uint64_t perf_arch_reg_sp(const char *arch);
37 const char *__perf_reg_name_arm64(int id);
38 uint64_t __perf_reg_ip_arm64(void);
39 uint64_t __perf_reg_sp_arm64(void);
40 const char *__perf_reg_name_arm(int id);
41 uint64_t __perf_reg_ip_arm(void);
42 uint64_t __perf_reg_sp_arm(void);
43 const char *__perf_reg_name_csky(int id);
44 uint64_t __perf_reg_ip_csky(void);
45 uint64_t __perf_reg_sp_csky(void);
46 const char *__perf_reg_name_loongarch(int id);
47 uint64_t __perf_reg_ip_loongarch(void);
48 uint64_t __perf_reg_sp_loongarch(void);
49 const char *__perf_reg_name_mips(int id);
50 uint64_t __perf_reg_ip_mips(void);
51 uint64_t __perf_reg_sp_mips(void);
52 const char *__perf_reg_name_powerpc(int id);
53 uint64_t __perf_reg_ip_powerpc(void);
54 uint64_t __perf_reg_sp_powerpc(void);
55 const char *__perf_reg_name_riscv(int id);
56 uint64_t __perf_reg_ip_riscv(void);
57 uint64_t __perf_reg_sp_riscv(void);
58 const char *__perf_reg_name_s390(int id);
59 uint64_t __perf_reg_ip_s390(void);
60 uint64_t __perf_reg_sp_s390(void);
61 const char *__perf_reg_name_x86(int id);
62 uint64_t __perf_reg_ip_x86(void);
63 uint64_t __perf_reg_sp_x86(void);
64 
DWARF_MINIMAL_REGS(const char * arch)65 static inline uint64_t DWARF_MINIMAL_REGS(const char *arch)
66 {
67 	return (1ULL << perf_arch_reg_ip(arch)) | (1ULL << perf_arch_reg_sp(arch));
68 }
69 
70 #else
71 
DWARF_MINIMAL_REGS(const char * arch __maybe_unused)72 static inline uint64_t DWARF_MINIMAL_REGS(const char *arch __maybe_unused)
73 {
74 	return 0;
75 }
76 
perf_reg_name(int id __maybe_unused,const char * arch __maybe_unused)77 static inline const char *perf_reg_name(int id __maybe_unused, const char *arch __maybe_unused)
78 {
79 	return "unknown";
80 }
81 
perf_reg_value(u64 * valp __maybe_unused,struct regs_dump * regs __maybe_unused,int id __maybe_unused)82 static inline int perf_reg_value(u64 *valp __maybe_unused,
83 				 struct regs_dump *regs __maybe_unused,
84 				 int id __maybe_unused)
85 {
86 	return 0;
87 }
88 
perf_arch_reg_ip(const char * arch __maybe_unused)89 static inline uint64_t perf_arch_reg_ip(const char *arch __maybe_unused)
90 {
91 	return 0;
92 }
93 
perf_arch_reg_sp(const char * arch __maybe_unused)94 static inline uint64_t perf_arch_reg_sp(const char *arch __maybe_unused)
95 {
96 	return 0;
97 }
98 
99 #endif /* HAVE_PERF_REGS_SUPPORT */
100 #endif /* __PERF_REGS_H */
101