1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __PERF_BLOCK_RANGE_H
3 #define __PERF_BLOCK_RANGE_H
6 #include <linux/rbtree.h>
7 #include <linux/types.h>
12 * struct block_range - non-overlapping parts of basic blocks
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
30 int is_target
, is_branch
;
38 static inline struct block_range
*block_range__next(struct block_range
*br
)
40 struct rb_node
*n
= rb_next(&br
->node
);
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
)
56 static inline bool block_range_iter__next(struct block_range_iter
*iter
)
58 if (iter
->start
== iter
->end
)
61 iter
->start
= block_range__next(iter
->start
);
65 static inline bool block_range_iter__valid(struct block_range_iter
*iter
)
67 if (!iter
->start
|| !iter
->end
)
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 */