Lines Matching defs:block
32 return vtn_value(b, value_id, vtn_value_type_block)->block;
277 vtn_assert(b->block == NULL);
278 b->block = rzalloc(b, struct vtn_block);
279 b->block->node.type = vtn_cf_node_type_block;
280 b->block->label = w;
281 vtn_push_value(b, w[1], vtn_value_type_block)->block = b->block;
284 /* This is the first block encountered for this function. In this
285 * case, we set the start block and add it to the list of
288 b->func->start_block = b->block;
296 vtn_assert(b->block && b->block->merge == NULL);
297 b->block->merge = w;
310 vtn_assert(b->block && b->block->branch == NULL);
311 b->block->branch = w;
312 b->block = NULL;
366 vtn_block_set_merge_cf_node(struct vtn_builder *b, struct vtn_block *block,
369 vtn_fail_if(block->merge_cf_node != NULL,
370 "The merge block declared by a header block cannot be a "
371 "merge block declared by any other header block.");
373 block->merge_cf_node = cf_node;
411 * fine if the target block is a switch case from an outer switch as
421 /* Because block->switch_case is only set on the entry block for a given
455 * construct and continue iterating at the merge target block (if any).
467 "Branching to the merge block of a selection "
477 "Branching to the merge block of a selection "
530 /* returns the default block */
578 cse->block = case_block;
598 /* Processes a block and returns the next block to process or NULL if we've
606 struct vtn_block *block)
610 * block and then returns the next block to process. For a given
614 * the first block in a construct or a block that vtn_process_block()
616 * that we're processing the first block in the construct and we have to
619 * If cf_list is not empty, then it must be the block returned by the
624 switch (vtn_handle_branch(b, cf_parent, block)) {
646 vtn_fail("A block was used as a merge target from two or more "
651 /* Once a block has been processed, it is placed into and the list link
656 if (block->node.parent != NULL) {
657 vtn_fail_if(vtn_cf_node_find_function(&block->node) !=
659 "A block cannot exist in two functions at the "
665 if (block->merge && (*block->merge & SpvOpCodeMask) == SpvOpLoopMerge &&
666 block->loop == NULL) {
667 vtn_fail_if((*block->branch & SpvOpCodeMask) != SpvOpBranch &&
668 (*block->branch & SpvOpCodeMask) != SpvOpBranchConditional,
678 loop->header_block = block;
679 loop->break_block = vtn_block(b, block->merge[1]);
680 loop->cont_block = vtn_block(b, block->merge[2]);
681 loop->control = block->merge[3];
684 block->loop = loop;
687 * current block as its start block. If we weren't careful, we would
689 * block->loop above and check for it before creating one. This way,
692 * regular block.
699 * - the Continue Target must dominate the back-edge block
700 * - the back-edge block must post dominate the Continue Target
702 * If the header block is the same as the continue target, this
716 /* Add the block to the CF list */
717 block->node.parent = cf_parent;
718 list_addtail(&block->node.link, cf_list);
720 switch (*block->branch & SpvOpCodeMask) {
722 struct vtn_block *branch_block = vtn_block(b, block->branch[1]);
724 block->branch_type = vtn_handle_branch(b, cf_parent, branch_block);
726 if (block->branch_type == vtn_branch_type_none)
734 block->branch_type = vtn_branch_type_return;
738 block->branch_type = vtn_branch_type_discard;
742 block->branch_type = vtn_branch_type_terminate_invocation;
746 block->branch_type = vtn_branch_type_ignore_intersection;
750 block->branch_type = vtn_branch_type_terminate_ray;
754 struct vtn_value *cond_val = vtn_untyped_value(b, block->branch[1]);
764 if_stmt->header_block = block;
770 if (block->merge &&
771 (*block->merge & SpvOpCodeMask) == SpvOpSelectionMerge) {
772 /* We may not always have a merge block and that merge doesn't
773 * technically have to be an OpSelectionMerge. We could have a block
776 if_stmt->merge_block = vtn_block(b, block->merge[1]);
779 if_stmt->control = block->merge[2];
782 struct vtn_block *then_block = vtn_block(b, block->branch[2]);
789 struct vtn_block *else_block = vtn_block(b, block->branch[3]);
806 swtch->selector = block->branch[1];
811 /* We may not always have a merge block */
812 if (block->merge) {
813 vtn_fail_if((*block->merge & SpvOpCodeMask) != SpvOpSelectionMerge,
817 swtch->break_block = vtn_block(b, block->merge[1]);
822 vtn_parse_switch(b, swtch, block->branch, &swtch->cases);
828 cse->type = vtn_handle_branch(b, &swtch->node, cse->block);
832 vtn_fail_if(cse->block->switch_case != NULL,
835 cse->block->switch_case = cse;
837 &cse->body, cse->block);
894 for (struct vtn_block *block = work->start_block; block; ) {
895 block = vtn_process_block(b, &work_list, work->cf_parent,
896 work->cf_list, block);
949 /* It's possible that this phi is in an unreachable block in which case it
961 /* If block does not have end_nop, that is because it is an unreacheable
962 * block, and hence it is not worth to handle it */
1082 vtn_emit_ret_store(struct vtn_builder *b, struct vtn_block *block)
1084 if ((*block->branch & SpvOpCodeMask) != SpvOpReturnValue)
1089 struct vtn_ssa_value *src = vtn_ssa_value(b, block->branch[1]);
1107 struct vtn_block *block = vtn_cf_node_as_block(node);
1109 const uint32_t *block_start = block->label;
1110 const uint32_t *block_end = block->merge ? block->merge :
1111 block->branch;
1118 block->end_nop = nir_nop(&b->nb);
1120 vtn_emit_ret_store(b, block);
1122 if (block->branch_type != vtn_branch_type_none) {
1123 vtn_emit_branch(b, block->branch_type,
1137 /* If both branches are the same, just emit the first block, which is
1243 /* If this case jumps directly to the break block, we don't have
1247 if (cse->block == vtn_switch->break_block)
1289 struct vtn_block *block)
1291 if (!block->block) {
1292 block->block = vtn_new_unstructured_block(b, func);
1293 list_addtail(&block->node.link, work_list);
1304 func->start_block->block = nir_start_block(func->nir_func->impl);
1307 struct vtn_block *block =
1309 list_del(&block->node.link);
1311 vtn_assert(block->block);
1313 const uint32_t *block_start = block->label;
1314 const uint32_t *block_end = block->branch;
1316 b->nb.cursor = nir_after_block(block->block);
1320 block->end_nop = nir_nop(&b->nb);
1325 struct vtn_block *branch_block = vtn_block(b, block->branch[1]);
1327 nir_goto(&b->nb, branch_block->block);
1332 nir_ssa_def *cond = vtn_ssa_value(b, block->branch[1])->def;
1333 struct vtn_block *then_block = vtn_block(b, block->branch[2]);
1334 struct vtn_block *else_block = vtn_block(b, block->branch[3]);
1338 nir_goto(&b->nb, then_block->block);
1341 nir_goto_if(&b->nb, then_block->block, nir_src_for_ssa(cond),
1342 else_block->block);
1351 vtn_parse_switch(b, NULL, block->branch, &cases);
1353 nir_ssa_def *sel = vtn_get_nir_ssa(b, block->branch[1]);
1368 /* block for the next check */
1370 vtn_add_unstructured_block(b, func, &work_list, cse->block);
1373 nir_goto_if(&b->nb, cse->block->block, nir_src_for_ssa(cond), e);
1378 vtn_add_unstructured_block(b, func, &work_list, def->block);
1380 /* now that all cases are handled, branch into the default block */
1381 nir_goto(&b->nb, def->block->block);
1394 vtn_emit_ret_store(b, block);