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