xref: /linux/tools/perf/util/perf_regs.h (revision 5000e7f61a1eb82fed98d5d0c8f19477033f0914)
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 #define DWARF_MINIMAL_REGS ((1ULL << PERF_REG_IP) | (1ULL << PERF_REG_SP))
36 
37 const char *perf_reg_name(int id, const char *arch);
38 int perf_reg_value(u64 *valp, struct regs_dump *regs, int id);
39 const char *__perf_reg_name_arm64(int id);
40 const char *__perf_reg_name_arm(int id);
41 const char *__perf_reg_name_csky(int id);
42 const char *__perf_reg_name_loongarch(int id);
43 const char *__perf_reg_name_mips(int id);
44 const char *__perf_reg_name_powerpc(int id);
45 const char *__perf_reg_name_riscv(int id);
46 const char *__perf_reg_name_s390(int id);
47 const char *__perf_reg_name_x86(int id);
48 
49 #else
50 #define PERF_REGS_MASK	0
51 #define PERF_REGS_MAX	0
52 
53 #define DWARF_MINIMAL_REGS PERF_REGS_MASK
54 
55 static inline const char *perf_reg_name(int id __maybe_unused, const char *arch __maybe_unused)
56 {
57 	return "unknown";
58 }
59 
60 static inline int perf_reg_value(u64 *valp __maybe_unused,
61 				 struct regs_dump *regs __maybe_unused,
62 				 int id __maybe_unused)
63 {
64 	return 0;
65 }
66 #endif /* HAVE_PERF_REGS_SUPPORT */
67 #endif /* __PERF_REGS_H */
68