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
8struct regs_dump;
9
10struct 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
21enum {
22	SDT_ARG_VALID = 0,
23	SDT_ARG_SKIP,
24};
25
26int arch_sdt_arg_parse_op(char *old_op, char **new_op);
27uint64_t arch__intr_reg_mask(void);
28uint64_t arch__user_reg_mask(void);
29const struct sample_reg *arch__sample_reg_masks(void);
30
31const char *perf_reg_name(int id, const char *arch);
32int perf_reg_value(u64 *valp, struct regs_dump *regs, int id);
33uint64_t perf_arch_reg_ip(const char *arch);
34uint64_t perf_arch_reg_sp(const char *arch);
35const char *__perf_reg_name_arm64(int id);
36uint64_t __perf_reg_ip_arm64(void);
37uint64_t __perf_reg_sp_arm64(void);
38const char *__perf_reg_name_arm(int id);
39uint64_t __perf_reg_ip_arm(void);
40uint64_t __perf_reg_sp_arm(void);
41const char *__perf_reg_name_csky(int id);
42uint64_t __perf_reg_ip_csky(void);
43uint64_t __perf_reg_sp_csky(void);
44const char *__perf_reg_name_loongarch(int id);
45uint64_t __perf_reg_ip_loongarch(void);
46uint64_t __perf_reg_sp_loongarch(void);
47const char *__perf_reg_name_mips(int id);
48uint64_t __perf_reg_ip_mips(void);
49uint64_t __perf_reg_sp_mips(void);
50const char *__perf_reg_name_powerpc(int id);
51uint64_t __perf_reg_ip_powerpc(void);
52uint64_t __perf_reg_sp_powerpc(void);
53const char *__perf_reg_name_riscv(int id);
54uint64_t __perf_reg_ip_riscv(void);
55uint64_t __perf_reg_sp_riscv(void);
56const char *__perf_reg_name_s390(int id);
57uint64_t __perf_reg_ip_s390(void);
58uint64_t __perf_reg_sp_s390(void);
59const char *__perf_reg_name_x86(int id);
60uint64_t __perf_reg_ip_x86(void);
61uint64_t __perf_reg_sp_x86(void);
62
63static inline uint64_t DWARF_MINIMAL_REGS(const char *arch)
64{
65	return (1ULL << perf_arch_reg_ip(arch)) | (1ULL << perf_arch_reg_sp(arch));
66}
67
68#endif /* __PERF_REGS_H */
69