1 #ifndef __PERF_BLOCK_RANGE_H 2 #define __PERF_BLOCK_RANGE_H 3 4 #include "symbol.h" 5 6 /* 7 * struct block_range - non-overlapping parts of basic blocks 8 * @node: treenode 9 * @start: inclusive start of range 10 * @end: inclusive end of range 11 * @is_target: @start is a jump target 12 * @is_branch: @end is a branch instruction 13 * @coverage: number of blocks that cover this range 14 * @taken: number of times the branch is taken (requires @is_branch) 15 * @pred: number of times the taken branch was predicted 16 */ 17 struct block_range { 18 struct rb_node node; 19 20 struct symbol *sym; 21 22 u64 start; 23 u64 end; 24 25 int is_target, is_branch; 26 27 u64 coverage; 28 u64 entry; 29 u64 taken; 30 u64 pred; 31 }; 32 33 static inline struct block_range *block_range__next(struct block_range *br) 34 { 35 struct rb_node *n = rb_next(&br->node); 36 if (!n) 37 return NULL; 38 return rb_entry(n, struct block_range, node); 39 } 40 41 struct block_range_iter { 42 struct block_range *start; 43 struct block_range *end; 44 }; 45 46 static inline struct block_range *block_range_iter(struct block_range_iter *iter) 47 { 48 return iter->start; 49 } 50 51 static inline bool block_range_iter__next(struct block_range_iter *iter) 52 { 53 if (iter->start == iter->end) 54 return false; 55 56 iter->start = block_range__next(iter->start); 57 return true; 58 } 59 60 static inline bool block_range_iter__valid(struct block_range_iter *iter) 61 { 62 if (!iter->start || !iter->end) 63 return false; 64 return true; 65 } 66 67 extern struct block_range *block_range__find(u64 addr); 68 extern struct block_range_iter block_range__create(u64 start, u64 end); 69 extern double block_range__coverage(struct block_range *br); 70 71 #endif /* __PERF_BLOCK_RANGE_H */ 72