Linux 5.1.15
[linux/fpc-iii.git] / tools / perf / util / block-range.h
blobec0fb534bf5684f2983ee8b3c2c3fbb13eaaecb7
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __PERF_BLOCK_RANGE_H
3 #define __PERF_BLOCK_RANGE_H
5 #include <stdbool.h>
6 #include <linux/rbtree.h>
7 #include <linux/types.h>
9 struct symbol;
12 * struct block_range - non-overlapping parts of basic blocks
13 * @node: treenode
14 * @start: inclusive start of range
15 * @end: inclusive end of range
16 * @is_target: @start is a jump target
17 * @is_branch: @end is a branch instruction
18 * @coverage: number of blocks that cover this range
19 * @taken: number of times the branch is taken (requires @is_branch)
20 * @pred: number of times the taken branch was predicted
22 struct block_range {
23 struct rb_node node;
25 struct symbol *sym;
27 u64 start;
28 u64 end;
30 int is_target, is_branch;
32 u64 coverage;
33 u64 entry;
34 u64 taken;
35 u64 pred;
38 static inline struct block_range *block_range__next(struct block_range *br)
40 struct rb_node *n = rb_next(&br->node);
41 if (!n)
42 return NULL;
43 return rb_entry(n, struct block_range, node);
46 struct block_range_iter {
47 struct block_range *start;
48 struct block_range *end;
51 static inline struct block_range *block_range_iter(struct block_range_iter *iter)
53 return iter->start;
56 static inline bool block_range_iter__next(struct block_range_iter *iter)
58 if (iter->start == iter->end)
59 return false;
61 iter->start = block_range__next(iter->start);
62 return true;
65 static inline bool block_range_iter__valid(struct block_range_iter *iter)
67 if (!iter->start || !iter->end)
68 return false;
69 return true;
72 extern struct block_range *block_range__find(u64 addr);
73 extern struct block_range_iter block_range__create(u64 start, u64 end);
74 extern double block_range__coverage(struct block_range *br);
76 #endif /* __PERF_BLOCK_RANGE_H */