Lines Matching refs:block
67 /* We want to evaluate each block from the position of any other
68 * predecessor block, in order that the flags set are the union of
73 * that we can't simply recursively process each predecessor block
74 * before legalizing the current block.
77 * results converge. If the output state of a given block changes
83 legalize_block(struct ir3_legalize_ctx *ctx, struct ir3_block *block)
85 struct ir3_legalize_block_data *bd = block->data;
100 for (unsigned i = 0; i < block->predecessors_count; i++) {
101 struct ir3_block *predecessor = block->predecessors[i];
116 foreach_instr (n, &block->instr_list) {
124 /* Either inputs are in the first block or we expect inputs to be released
128 block == ir3_start_block(block->shader));
133 list_replace(&block->instr_list, &instr_list);
134 list_inithead(&block->instr_list);
228 nop = ir3_NOP(block);
234 if (list_is_empty(&block->instr_list) && (opc_cat(n->opc) >= 5))
235 ir3_NOP(block);
252 list_addtail(&n->node, &block->instr_list);
264 ir3_NOP(block)->flags |= IR3_INSTR_SS;
318 baryf = ir3_instr_create(block, OPC_BARY_F, 1, 2);
348 baryf = ir3_instr_create(block, OPC_BARY_F, 1, 2);
355 list_add(&baryf->node, &block->instr_list);
367 for (unsigned i = 0; i < ARRAY_SIZE(block->successors); i++) {
368 if (!block->successors[i])
370 struct ir3_legalize_block_data *pbd = block->successors[i]->data;
388 apply_fine_deriv_macro(struct ir3_legalize_ctx *ctx, struct ir3_block *block)
395 list_replace(&block->instr_list, &instr_list);
396 list_inithead(&block->instr_list);
399 list_addtail(&n->node, &block->instr_list);
415 * in the block. We take advantage of this as we resolve the
437 * that the first instruction in the target block is itself
450 resolve_dest_block(struct ir3_block *block)
452 /* special case for last block: */
453 if (!block->successors[0])
454 return block;
457 * in the target block yet, so conditions to resolve
458 * the dest to the dest block's successor are:
461 * (2) (block-is-empty || only-instr-is-jump)
463 if (block->successors[1] == NULL) {
464 if (list_is_empty(&block->instr_list)) {
465 return block->successors[0];
466 } else if (list_length(&block->instr_list) == 1) {
468 list_first_entry(&block->instr_list, struct ir3_instruction, node);
476 if (block->successors[0]->index <= block->index)
477 return block;
478 return block->successors[0];
482 return block;
503 struct ir3_block *cur_block = instr->block;
545 foreach_block (block, &ir->block_list)
546 block->index = index++;
548 foreach_block (block, &ir->block_list) {
549 foreach_instr (instr, &block->instr_list) {
557 /* Exit early if we deleted a block to avoid iterator
565 /* Detect the case where the block ends either with:
566 * - A single unconditional jump to the next block.
568 * them jumps to the next block.
569 * We can remove the one that jumps to the next block in either case.
571 if (list_is_empty(&block->instr_list))
576 list_last_entry(&block->instr_list, struct ir3_instruction, node);
577 if (!list_is_singular(&block->instr_list))
591 if (&tblock->node == block->node.next) {
605 foreach_block (block, &ir->block_list)
606 foreach_instr (instr, &block->instr_list)
616 mark_jp(struct ir3_block *block)
619 list_first_entry(&block->instr_list, struct ir3_instruction, node);
633 foreach_block (block, &ir->block_list) {
634 if (block->predecessors_count > 1) {
635 /* if a block has more than one possible predecessor, then
638 mark_jp(block);
639 } else if (block->predecessors_count == 1) {
640 /* If a block has one predecessor, which has multiple possible
643 for (unsigned i = 0; i < block->predecessors_count; i++) {
644 struct ir3_block *predecessor = block->predecessors[i];
646 mark_jp(block);
655 * block immediately follows the current block (ie. so no jump required),
658 * TODO what ensures that the last write to p0.x in a block is the
664 foreach_block (block, &ir->block_list) {
665 if (block->successors[1]) {
669 if (block->brtype == IR3_BRANCH_GETONE) {
674 debug_assert(!block->condition);
675 br1 = ir3_GETONE(block);
676 br1->cat0.target = block->successors[1];
678 br2 = ir3_JUMP(block);
679 br2->cat0.target = block->successors[0];
681 debug_assert(block->condition);
683 /* create "else" branch first (since "then" block should
686 br1 = ir3_instr_create(block, OPC_B, 0, 1);
688 block->condition->dsts[0];
690 br1->cat0.target = block->successors[1];
693 br2 = ir3_instr_create(block, OPC_B, 0, 1);
695 block->condition->dsts[0];
696 br2->cat0.target = block->successors[0];
698 switch (block->brtype) {
714 } else if (block->successors[0]) {
715 /* otherwise unconditional jump to next block: */
718 jmp = ir3_JUMP(block);
719 jmp->cat0.target = block->successors[0];
734 * block.
744 /* True if we know that this block will always eventually lead to the end
745 * block:
752 foreach_block_rev (block, &ir->block_list) {
753 for (unsigned i = 0; i < 2 && block->successors[i]; i++) {
754 if (block->successors[i]->start_ip <= block->end_ip)
761 foreach_instr_safe (instr, &block->instr_list) {
765 struct ir3_instruction *br = ir3_instr_create(block, OPC_B, 0, 1);
796 foreach_block (block, &ir->block_list) {
803 list_replace(&block->instr_list, &instr_list);
804 list_inithead(&block->instr_list);
807 unsigned delay = ir3_delay_calc_exact(block, instr, so->mergedregs);
832 ir3_NOP(block)->repeat = delay - 1;
835 list_addtail(&instr->node, &block->instr_list);
853 /* allocate per-block data: */
854 foreach_block (block, &ir->block_list) {
862 block->data = bd;
867 /* We may have failed to pull all input loads into the first block.
874 foreach_block (block, &ir->block_list) {
875 foreach_instr (instr, &block->instr_list) {
876 if (is_input(instr) && block != start_block) {
885 /* process each block: */
888 foreach_block (block, &ir->block_list) {
889 progress |= legalize_block(ctx, block);
899 foreach_block (block, &ir->block_list) {
900 progress |= apply_fine_deriv_macro(ctx, block);