Lines Matching +full:range +full:- +full:double
1 // SPDX-License-Identifier: GPL-2.0
2 #include "block-range.h"
21 assert(old < entry->start); in block_range__debug()
22 assert(entry->start <= entry->end); /* single instruction block; jump to a jump */ in block_range__debug()
24 old = entry->end; in block_range__debug()
39 if (addr < entry->start) in block_range__find()
40 p = &parent->rb_left; in block_range__find()
41 else if (addr > entry->end) in block_range__find()
42 p = &parent->rb_right; in block_range__find()
52 struct rb_node **p = &node->rb_left; in rb_link_left_of_node()
55 p = &node->rb_right; in rb_link_left_of_node()
62 struct rb_node **p = &node->rb_right; in rb_link_right_of_node()
65 p = &node->rb_left; in rb_link_right_of_node()
75 * Create all the required block ranges to precisely span the given range.
88 if (start < entry->start) in block_range__create()
89 p = &parent->rb_left; in block_range__create()
90 else if (start > entry->end) in block_range__create()
91 p = &parent->rb_right; in block_range__create()
98 * be inside/behind the next range. in block_range__create()
108 if (entry->end < start) { in block_range__create()
115 if (next->start <= end) { /* add head: [start...][n->start...] */ in block_range__create()
122 .end = next->start - 1, in block_range__create()
127 rb_link_left_of_node(&head->node, &next->node); in block_range__create()
128 rb_insert_color(&head->node, &block_ranges.root); in block_range__create()
137 * The whole [start..end] range is non-overlapping. in block_range__create()
150 rb_link_node(&entry->node, parent, p); in block_range__create()
151 rb_insert_color(&entry->node, &block_ranges.root); in block_range__create()
160 * We found a range that overlapped with ours, split if needed. in block_range__create()
162 if (entry->start < start) { /* split: [e->start...][start...] */ in block_range__create()
168 .start = entry->start, in block_range__create()
169 .end = start - 1, in block_range__create()
170 .is_target = entry->is_target, in block_range__create()
173 .coverage = entry->coverage, in block_range__create()
174 .entry = entry->entry, in block_range__create()
177 entry->start = start; in block_range__create()
178 entry->is_target = 1; in block_range__create()
179 entry->entry = 0; in block_range__create()
181 rb_link_left_of_node(&head->node, &entry->node); in block_range__create()
182 rb_insert_color(&head->node, &block_ranges.root); in block_range__create()
185 } else if (entry->start == start) in block_range__create()
186 entry->is_target = 1; in block_range__create()
200 if (end < entry->end) { /* split: [...end][...e->end] */ in block_range__create()
207 .end = entry->end, in block_range__create()
209 .is_branch = entry->is_branch, in block_range__create()
211 .coverage = entry->coverage, in block_range__create()
212 .taken = entry->taken, in block_range__create()
213 .pred = entry->pred, in block_range__create()
216 entry->end = end; in block_range__create()
217 entry->is_branch = 1; in block_range__create()
218 entry->taken = 0; in block_range__create()
219 entry->pred = 0; in block_range__create()
221 rb_link_right_of_node(&tail->node, &entry->node); in block_range__create()
222 rb_insert_color(&tail->node, &block_ranges.root); in block_range__create()
232 if (end == entry->end) { in block_range__create()
233 entry->is_branch = 1; in block_range__create()
245 if (end < next->start) { /* add tail: [...e->end][...end] */ in block_range__create()
253 .start = entry->end + 1, in block_range__create()
259 rb_link_right_of_node(&tail->node, &entry->node); in block_range__create()
260 rb_insert_color(&tail->node, &block_ranges.root); in block_range__create()
270 if (entry->end + 1 != next->start) { in block_range__create()
276 .start = entry->end + 1, in block_range__create()
277 .end = next->start - 1, in block_range__create()
282 rb_link_left_of_node(&hole->node, &next->node); in block_range__create()
283 rb_insert_color(&hole->node, &block_ranges.root); in block_range__create()
291 assert(iter.start->start == start && iter.start->is_target); in block_range__create()
292 assert(iter.end->end == end && iter.end->is_branch); in block_range__create()
303 * br->coverage / br->sym->max_coverage
308 * Returns [0-1] for coverage and -1 if we had no data what so ever or the
311 double block_range__coverage(struct block_range *br) in block_range__coverage()
320 return -1; in block_range__coverage()
323 sym = br->sym; in block_range__coverage()
325 return -1; in block_range__coverage()
327 branch = symbol__annotation(sym)->branch; in block_range__coverage()
329 return -1; in block_range__coverage()
331 return (double)br->coverage / branch->max_coverage; in block_range__coverage()