Lines Matching refs:bb
69 ir_block *blocks, *bb; in ir_build_cfg() local
178 bb = blocks + 1; in ir_build_cfg()
193 bb->start = start; in ir_build_cfg()
194 bb->end = end; in ir_build_cfg()
195 bb->successors = count; in ir_build_cfg()
197 bb->successors_count = 0; in ir_build_cfg()
198 bb->predecessors = count; in ir_build_cfg()
199 bb->dom_parent = 0; in ir_build_cfg()
200 bb->dom_depth = 0; in ir_build_cfg()
201 bb->dom_child = 0; in ir_build_cfg()
202 bb->dom_next_child = 0; in ir_build_cfg()
203 bb->loop_header = 0; in ir_build_cfg()
204 bb->loop_depth = 0; in ir_build_cfg()
206 bb->flags = IR_BB_START; in ir_build_cfg()
207 bb->predecessors_count = 0; in ir_build_cfg()
209 bb->flags = bb_init_falgs; in ir_build_cfg()
212 bb->predecessors_count = n; in ir_build_cfg()
217 bb->flags |= IR_BB_ENTRY; in ir_build_cfg()
220 bb->predecessors_count = 1; in ir_build_cfg()
225 bb->predecessors_count = 0; in ir_build_cfg()
229 bb++; in ir_build_cfg()
237 bb = blocks + 1; in ir_build_cfg()
238 for (b = 1; b <= bb_count; b++, bb++) { in ir_build_cfg()
239 insn = &ctx->ir_base[bb->start]; in ir_build_cfg()
240 if (bb->predecessors_count > 1) { in ir_build_cfg()
241 uint32_t *q = edges + bb->predecessors; in ir_build_cfg()
252 } else if (bb->predecessors_count == 1) { in ir_build_cfg()
258 edges[bb->predecessors] = pred_b; in ir_build_cfg()
280 bb = &blocks[b]; in ir_build_cfg()
281 bb->flags &= ~IR_BB_UNREACHABLE; in ir_build_cfg()
282 n = bb->successors_count; in ir_build_cfg()
284 for (p = edges + bb->successors; n > 0; p++, n--) { in ir_build_cfg()
288 ir_worklist_push(&worklist, edges[bb->successors]); in ir_build_cfg()
301 static void ir_remove_predecessor(ir_ctx *ctx, ir_block *bb, uint32_t from) in ir_remove_predecessor() argument
305 p = q = &ctx->cfg_edges[bb->predecessors]; in ir_remove_predecessor()
306 for (i = 0; i < bb->predecessors_count; i++, p++) { in ir_remove_predecessor()
315 IR_ASSERT(n != bb->predecessors_count); in ir_remove_predecessor()
316 bb->predecessors_count = n; in ir_remove_predecessor()
408 ir_block *bb = ctx->cfg_blocks + 1; in ir_remove_unreachable_blocks() local
410 for (b = 1; b <= bb_count; b++, bb++) { in ir_remove_unreachable_blocks()
411 if (bb->flags & IR_BB_UNREACHABLE) { in ir_remove_unreachable_blocks()
415 if (bb->successors_count) { in ir_remove_unreachable_blocks()
416 for (i = 0, p = &ctx->cfg_edges[bb->successors]; i < bb->successors_count; i++, p++) { in ir_remove_unreachable_blocks()
421 ir_remove_merge_input(ctx, succ_bb->start, bb->end); in ir_remove_unreachable_blocks()
425 ir_ref prev, ref = bb->end; in ir_remove_unreachable_blocks()
443 ctx->cfg_map[bb->start] = 0; in ir_remove_unreachable_blocks()
444 ctx->cfg_map[bb->end] = 0; in ir_remove_unreachable_blocks()
454 dst_bb = bb = ctx->cfg_blocks + 1; in ir_remove_unreachable_blocks()
455 for (b = 1; b <= bb_count; b++, bb++) { in ir_remove_unreachable_blocks()
456 if (!(bb->flags & IR_BB_UNREACHABLE)) { in ir_remove_unreachable_blocks()
457 if (dst_bb != bb) { in ir_remove_unreachable_blocks()
458 memcpy(dst_bb, bb, sizeof(ir_block)); in ir_remove_unreachable_blocks()
471 bb = ctx->cfg_blocks + 1; in ir_remove_unreachable_blocks()
472 for (b = 1; b <= bb_count; b++, bb++) { in ir_remove_unreachable_blocks()
473 ir_insn *insn = &ctx->ir_base[bb->start]; in ir_remove_unreachable_blocks()
476 n = bb->predecessors_count; in ir_remove_unreachable_blocks()
478 uint32_t *q = edges + bb->predecessors; in ir_remove_unreachable_blocks()
495 edges[bb->predecessors] = pred_b; in ir_remove_unreachable_blocks()
508 ir_block *bb = &ctx->cfg_blocks[b];
510 if (bb->postnum != 0) {
514 if (bb->successors_count) {
515 bb->postnum = -1; /* Marker for "currently visiting" */
516 p = ctx->cfg_edges + bb->successors;
517 i = bb->successors_count;
523 bb->postnum = (*cur)++;
531 ir_block *blocks, *bb;
548 for (b = 2, bb = &blocks[2]; b <= blocks_count; b++, bb++) {
549 IR_ASSERT(!(bb->flags & IR_BB_UNREACHABLE));
550 if (bb->predecessors_count == 1) {
551 uint32_t pred_b = edges[bb->predecessors];
555 } else if (bb->idom != pred_b) {
556 bb->idom = pred_b;
559 } else if (bb->predecessors_count) {
561 uint32_t k = bb->predecessors_count;
562 uint32_t *p = edges + bb->predecessors;
590 if (bb->idom != idom) {
591 bb->idom = idom;
605 for (b = 2, bb = &blocks[2]; b <= blocks_count; b++, bb++) {
606 IR_ASSERT(!(bb->flags & IR_BB_UNREACHABLE));
607 if (bb->idom > 0) {
608 ir_block *idom_bb = &blocks[bb->idom];
610 bb->dom_depth = idom_bb->dom_depth + 1;
615 bb->dom_next_child = idom_bb->dom_child;
625 bb->dom_next_child = child_bb->dom_next_child;
641 ir_block *blocks, *bb; in ir_build_dominators_tree() local
657 for (b = 2, bb = &blocks[2]; b <= blocks_count; b++, bb++) { in ir_build_dominators_tree()
658 IR_ASSERT(!(bb->flags & IR_BB_UNREACHABLE)); in ir_build_dominators_tree()
659 IR_ASSERT(bb->predecessors_count > 0); in ir_build_dominators_tree()
660 uint32_t k = bb->predecessors_count; in ir_build_dominators_tree()
661 uint32_t *p = edges + bb->predecessors; in ir_build_dominators_tree()
699 IR_ASSERT(bb->predecessors_count > 1); in ir_build_dominators_tree()
703 bb->idom = idom; in ir_build_dominators_tree()
706 bb->dom_depth = idom_bb->dom_depth + 1; in ir_build_dominators_tree()
711 bb->dom_next_child = idom_bb->dom_child; in ir_build_dominators_tree()
721 bb->dom_next_child = child_bb->dom_next_child; in ir_build_dominators_tree()
736 bb = &blocks[b]; in ir_build_dominators_tree()
737 succ_b = ctx->cfg_edges[bb->successors]; in ir_build_dominators_tree()
738 if (bb->successors_count != 1) { in ir_build_dominators_tree()
740 IR_ASSERT(bb->successors_count == 2); in ir_build_dominators_tree()
742 succ_b = ctx->cfg_edges[bb->successors + 1]; in ir_build_dominators_tree()
744 IR_ASSERT(blocks[ctx->cfg_edges[bb->successors + 1]].flags & IR_BB_ENTRY); in ir_build_dominators_tree()
748 while (bb->dom_depth > dom_depth) { in ir_build_dominators_tree()
749 b = bb->dom_parent; in ir_build_dominators_tree()
750 bb = &blocks[b]; in ir_build_dominators_tree()
773 ir_block *blocks, *bb; in ir_build_dominators_tree_iterative() local
782 for (b = 0, bb = &blocks[0]; b <= blocks_count; b++, bb++) { in ir_build_dominators_tree_iterative()
783 bb->dom_depth = 0; in ir_build_dominators_tree_iterative()
784 bb->dom_child = 0; in ir_build_dominators_tree_iterative()
785 bb->dom_next_child = 0; in ir_build_dominators_tree_iterative()
793 for (b = 2, bb = &blocks[2]; b <= blocks_count; b++, bb++) { in ir_build_dominators_tree_iterative()
794 IR_ASSERT(!(bb->flags & IR_BB_UNREACHABLE)); in ir_build_dominators_tree_iterative()
795 IR_ASSERT(bb->predecessors_count > 0); in ir_build_dominators_tree_iterative()
796 uint32_t k = bb->predecessors_count; in ir_build_dominators_tree_iterative()
797 uint32_t *p = edges + bb->predecessors; in ir_build_dominators_tree_iterative()
827 if (bb->idom != idom) { in ir_build_dominators_tree_iterative()
828 bb->idom = idom; in ir_build_dominators_tree_iterative()
837 for (b = 2, bb = &blocks[2]; b <= blocks_count; b++, bb++) { in ir_build_dominators_tree_iterative()
838 uint32_t idom = bb->idom; in ir_build_dominators_tree_iterative()
841 bb->dom_depth = idom_bb->dom_depth + 1; in ir_build_dominators_tree_iterative()
846 bb->dom_next_child = idom_bb->dom_child; in ir_build_dominators_tree_iterative()
856 bb->dom_next_child = child_bb->dom_next_child; in ir_build_dominators_tree_iterative()
900 ir_block *bb; in ir_find_loops() local
910 bb = &blocks[i]; in ir_find_loops()
911 for (child = bb->dom_child; child > 0; child = blocks[child].dom_next_child) { in ir_find_loops()
918 if (bb->successors_count) { in ir_find_loops()
919 uint32_t *p = edges + bb->successors; in ir_find_loops()
920 for (j = 0; j < bb->successors_count; j++,p++) { in ir_find_loops()
953 ir_block *bb = &blocks[i]; in ir_find_loops() local
955 if (bb->predecessors_count > 1) { in ir_find_loops()
957 uint32_t *p = &edges[bb->predecessors]; in ir_find_loops()
959 j = bb->predecessors_count; in ir_find_loops()
965 if (bb->idom != pred) { in ir_find_loops()
987 bb->flags |= IR_BB_IRREDUCIBLE_LOOP; in ir_find_loops()
993 bb->flags |= IR_BB_LOOP_HEADER; in ir_find_loops()
995 bb->loop_depth = 1; in ir_find_loops()
1002 ir_block *bb = &blocks[j]; in ir_find_loops() local
1003 if (bb->idom == 0 && j != 1) { in ir_find_loops()
1007 bb->loop_header = i; in ir_find_loops()
1008 if (bb->predecessors_count) { in ir_find_loops()
1009 uint32_t *p = &edges[bb->predecessors]; in ir_find_loops()
1010 j = bb->predecessors_count; in ir_find_loops()
1025 ir_block *bb = &blocks[i]; in ir_find_loops() local
1026 if (bb->loop_header > 0) { in ir_find_loops()
1027 ir_block *loop = &blocks[bb->loop_header]; in ir_find_loops()
1030 if (bb->flags & IR_BB_LOOP_HEADER) { in ir_find_loops()
1033 bb->loop_depth = loop_depth; in ir_find_loops()
1034 if (bb->flags & (IR_BB_ENTRY|IR_BB_LOOP_WITH_ENTRY)) { in ir_find_loops()
1038 bb = &blocks[loop->loop_header]; in ir_find_loops()
1040 if (bb->flags & IR_BB_LOOP_WITH_ENTRY) { in ir_find_loops()
1043 bb->flags |= IR_BB_LOOP_WITH_ENTRY; in ir_find_loops()
1044 if (bb->loop_depth == 1) { in ir_find_loops()
1047 bb = &blocks[loop->loop_header]; in ir_find_loops()
1064 ir_block *bb = &ctx->cfg_blocks[b]; in _ir_skip_empty_blocks() local
1066 if ((bb->flags & (IR_BB_START|IR_BB_ENTRY|IR_BB_EMPTY)) == IR_BB_EMPTY) { in _ir_skip_empty_blocks()
1067 IR_ASSERT(bb->successors_count == 1); in _ir_skip_empty_blocks()
1068 b = ctx->cfg_edges[bb->successors]; in _ir_skip_empty_blocks()
1180 ir_block *bb; in ir_dump_cfg_freq_graph() local
1198 bb = &ctx->cfg_blocks[b]; in ir_dump_cfg_freq_graph()
1201 is_empty = (bb->flags & (IR_BB_START|IR_BB_ENTRY|IR_BB_EMPTY)) == IR_BB_EMPTY; in ir_dump_cfg_freq_graph()
1204 bb->loop_depth, bb_freq[b], in ir_dump_cfg_freq_graph()
1205 ir_op_name[ctx->ir_base[bb->start].op], ir_op_name[ctx->ir_base[bb->end].op], in ir_dump_cfg_freq_graph()
1211 bb->loop_depth, bb_freq[b], in ir_dump_cfg_freq_graph()
1212 ir_op_name[ctx->ir_base[bb->start].op], ir_op_name[ctx->ir_base[bb->end].op], in ir_dump_cfg_freq_graph()
1263 ir_block *bb; in ir_schedule_blocks_bottom_up() local
1293 bb = &ctx->cfg_blocks[b]; in ir_schedule_blocks_bottom_up()
1294 if (bb->predecessors_count) { in ir_schedule_blocks_bottom_up()
1295 uint32_t n = bb->predecessors_count; in ir_schedule_blocks_bottom_up()
1296 uint32_t *p = ctx->cfg_edges + bb->predecessors; in ir_schedule_blocks_bottom_up()
1318 if ((bb->flags & (IR_BB_START|IR_BB_ENTRY|IR_BB_EMPTY)) == IR_BB_EMPTY) { in ir_schedule_blocks_bottom_up()
1319 uint32_t successor = ctx->cfg_edges[bb->successors]; in ir_schedule_blocks_bottom_up()
1337 loop_depth = bb->loop_depth; in ir_schedule_blocks_bottom_up()
1338 if (bb->flags & IR_BB_LOOP_HEADER) { in ir_schedule_blocks_bottom_up()
1343 if (bb->successors_count) { in ir_schedule_blocks_bottom_up()
1344 uint32_t n = bb->successors_count; in ir_schedule_blocks_bottom_up()
1345 uint32_t *p = ctx->cfg_edges + bb->successors; in ir_schedule_blocks_bottom_up()
1362 } else if (n == 2 && ctx->ir_base[bb->end].op == IR_IF) { in ir_schedule_blocks_bottom_up()
1482 prob = 100 / bb->successors_count; in ir_schedule_blocks_bottom_up()
1487 prob = 100 / bb->successors_count; in ir_schedule_blocks_bottom_up()
1496 prob = 100 / bb->successors_count; in ir_schedule_blocks_bottom_up()
1589 bb = &ctx->cfg_blocks[b]; in ir_schedule_blocks_bottom_up()
1590 if (bb->flags & IR_BB_EMPTY) { in ir_schedule_blocks_bottom_up()
1594 IR_ASSERT(bb->successors_count == 1); in ir_schedule_blocks_bottom_up()
1595 successor = ctx->cfg_edges[bb->successors]; in ir_schedule_blocks_bottom_up()
1596 bb = &ctx->cfg_blocks[successor]; in ir_schedule_blocks_bottom_up()
1597 } while ((bb->flags & (IR_BB_START|IR_BB_ENTRY|IR_BB_EMPTY)) == IR_BB_EMPTY); in ir_schedule_blocks_bottom_up()
1614 bb = &ctx->cfg_blocks[b]; in ir_schedule_blocks_bottom_up()
1615 if (bb->loop_depth) { in ir_schedule_blocks_bottom_up()
1616 if ((bb->flags & IR_BB_LOOP_HEADER) || ir_chain_head(chains, bb->loop_header) == b) { in ir_schedule_blocks_bottom_up()
1617 bb->flags |= IR_BB_ALIGN_LOOP; in ir_schedule_blocks_bottom_up()
1677 ir_block *bb, *best_successor_bb; in ir_schedule_blocks_top_down() local
1692 bb = &ctx->cfg_blocks[b]; in ir_schedule_blocks_top_down()
1696 if (UNEXPECTED(bb->flags & IR_BB_PREV_EMPTY_ENTRY) && ir_bitqueue_in(&blocks, b - 1)) { in ir_schedule_blocks_top_down()
1704 if ((bb->flags & (IR_BB_START|IR_BB_ENTRY|IR_BB_EMPTY)) == IR_BB_EMPTY) { in ir_schedule_blocks_top_down()
1714 if (bb->successors_count == 1) { in ir_schedule_blocks_top_down()
1715 best_successor = ctx->cfg_edges[bb->successors]; in ir_schedule_blocks_top_down()
1719 } else if (bb->successors_count > 1) { in ir_schedule_blocks_top_down()
1724 for (b = 0, p = &ctx->cfg_edges[bb->successors]; b < bb->successors_count; b++, p++) { in ir_schedule_blocks_top_down()
1732 prob = 100 / bb->successors_count; in ir_schedule_blocks_top_down()
1740 prob = 100 / bb->successors_count; in ir_schedule_blocks_top_down()
1745 prob = 100 / bb->successors_count; in ir_schedule_blocks_top_down()
1754 prob = 100 / bb->successors_count; in ir_schedule_blocks_top_down()
1768 if ((bb->flags & IR_BB_EMPTY) && last_non_empty) { in ir_schedule_blocks_top_down()
1769 bb = &ctx->cfg_blocks[last_non_empty]; in ir_schedule_blocks_top_down()
1770 if (bb->successors_count == 2 && ctx->ir_base[bb->end].op == IR_IF) { in ir_schedule_blocks_top_down()
1771 b = ctx->cfg_edges[bb->successors]; in ir_schedule_blocks_top_down()
1774 b = ctx->cfg_edges[bb->successors + 1]; in ir_schedule_blocks_top_down()
1777 bb = &ctx->cfg_blocks[b]; in ir_schedule_blocks_top_down()
1787 bb = best_successor_bb; in ir_schedule_blocks_top_down()
1813 ir_block *bb = &ctx->cfg_blocks[ctx->cfg_map[ref]]; in ir_schedule_blocks() local
1814 uint32_t n = bb->predecessors_count; in ir_schedule_blocks()
1817 ir_insn *start_insn = &ctx->ir_base[bb->start]; in ir_schedule_blocks()
1826 uint32_t *p = &ctx->cfg_edges[bb->predecessors]; in ir_schedule_blocks()
1829 bb = &ctx->cfg_blocks[*p]; in ir_schedule_blocks()
1830 if (bb->predecessors_count == 1) { in ir_schedule_blocks()
1831 ir_insn *start_insn = &ctx->ir_base[bb->start]; in ir_schedule_blocks()
1866 ir_block *bb; in ir_next_block() local
1884 bb = &ctx->cfg_blocks[b]; in ir_next_block()
1886 if ((bb->flags & (IR_BB_START|IR_BB_EMPTY)) == IR_BB_EMPTY) { in ir_next_block()
1897 ir_block *bb; in ir_get_true_false_blocks() local
1902 bb = &ctx->cfg_blocks[b]; in ir_get_true_false_blocks()
1903 IR_ASSERT(ctx->ir_base[bb->end].op == IR_IF); in ir_get_true_false_blocks()
1904 IR_ASSERT(bb->successors_count == 2); in ir_get_true_false_blocks()
1905 p = &ctx->cfg_edges[bb->successors]; in ir_get_true_false_blocks()