xref: /openbmc/linux/tools/perf/util/branch.h (revision 8781e5df)
1 #ifndef _PERF_BRANCH_H
2 #define _PERF_BRANCH_H 1
3 /*
4  * The linux/stddef.h isn't need here, but is needed for __always_inline used
5  * in files included from uapi/linux/perf_event.h such as
6  * /usr/include/linux/swab.h and /usr/include/linux/byteorder/little_endian.h,
7  * detected in at least musl libc, used in Alpine Linux. -acme
8  */
9 #include <stdio.h>
10 #include <stdint.h>
11 #include <linux/compiler.h>
12 #include <linux/stddef.h>
13 #include <linux/perf_event.h>
14 #include <linux/types.h>
15 
16 struct branch_flags {
17 	u64 mispred:1;
18 	u64 predicted:1;
19 	u64 in_tx:1;
20 	u64 abort:1;
21 	u64 cycles:16;
22 	u64 type:4;
23 	u64 reserved:40;
24 };
25 
26 struct branch_info {
27 	struct addr_map_symbol from;
28 	struct addr_map_symbol to;
29 	struct branch_flags    flags;
30 	char		       *srcline_from;
31 	char		       *srcline_to;
32 };
33 
34 struct branch_entry {
35 	u64			from;
36 	u64			to;
37 	struct branch_flags	flags;
38 };
39 
40 struct branch_stack {
41 	u64			nr;
42 	struct branch_entry	entries[0];
43 };
44 
45 struct branch_type_stat {
46 	bool	branch_to;
47 	u64	counts[PERF_BR_MAX];
48 	u64	cond_fwd;
49 	u64	cond_bwd;
50 	u64	cross_4k;
51 	u64	cross_2m;
52 };
53 
54 void branch_type_count(struct branch_type_stat *st, struct branch_flags *flags,
55 		       u64 from, u64 to);
56 
57 const char *branch_type_name(int type);
58 void branch_type_stat_display(FILE *fp, struct branch_type_stat *st);
59 int branch_type_str(struct branch_type_stat *st, char *bf, int bfsize);
60 
61 #endif /* _PERF_BRANCH_H */
62