| ... | @@ -6672,6 +6672,7 @@ static IrInstruction *ir_gen_cancel(IrBuilder *irb, Scope *scope, AstNode *node) | ... | @@ -6672,6 +6672,7 @@ static IrInstruction *ir_gen_cancel(IrBuilder *irb, Scope *scope, AstNode *node) |
| 6672 | | 6672 | |
| 6673 | IrBasicBlock *done_block = ir_create_basic_block(irb, scope, "CancelDone"); | 6673 | IrBasicBlock *done_block = ir_create_basic_block(irb, scope, "CancelDone"); |
| 6674 | IrBasicBlock *not_canceled_block = ir_create_basic_block(irb, scope, "NotCanceled"); | 6674 | IrBasicBlock *not_canceled_block = ir_create_basic_block(irb, scope, "NotCanceled"); |
| | 6675 | IrBasicBlock *pre_return_block = ir_create_basic_block(irb, scope, "PreReturn"); |
| 6675 | IrBasicBlock *post_return_block = ir_create_basic_block(irb, scope, "PostReturn"); | 6676 | IrBasicBlock *post_return_block = ir_create_basic_block(irb, scope, "PostReturn"); |
| 6676 | IrBasicBlock *do_cancel_block = ir_create_basic_block(irb, scope, "DoCancel"); | 6677 | IrBasicBlock *do_cancel_block = ir_create_basic_block(irb, scope, "DoCancel"); |
| 6677 | | 6678 | |
| ... | @@ -6684,6 +6685,7 @@ static IrInstruction *ir_gen_cancel(IrBuilder *irb, Scope *scope, AstNode *node) | ... | @@ -6684,6 +6685,7 @@ static IrInstruction *ir_gen_cancel(IrBuilder *irb, Scope *scope, AstNode *node) |
| 6684 | IrInstruction *inverted_ptr_mask = ir_build_const_usize(irb, scope, node, 0x7); // 0b111 | 6685 | IrInstruction *inverted_ptr_mask = ir_build_const_usize(irb, scope, node, 0x7); // 0b111 |
| 6685 | IrInstruction *ptr_mask = ir_build_un_op(irb, scope, node, IrUnOpBinNot, inverted_ptr_mask); // 0b111...000 | 6686 | IrInstruction *ptr_mask = ir_build_un_op(irb, scope, node, IrUnOpBinNot, inverted_ptr_mask); // 0b111...000 |
| 6686 | IrInstruction *await_mask = ir_build_const_usize(irb, scope, node, 0x4); // 0b100 | 6687 | IrInstruction *await_mask = ir_build_const_usize(irb, scope, node, 0x4); // 0b100 |
| | 6688 | IrInstruction *is_suspended_mask = ir_build_const_usize(irb, scope, node, 0x2); // 0b010 |
| 6687 | | 6689 | |
| 6688 | // TODO relies on Zig not re-ordering fields | 6690 | // TODO relies on Zig not re-ordering fields |
| 6689 | IrInstruction *casted_target_inst = ir_build_ptr_cast(irb, scope, node, promise_T_type_val, target_inst); | 6691 | IrInstruction *casted_target_inst = ir_build_ptr_cast(irb, scope, node, promise_T_type_val, target_inst); |
| ... | @@ -6704,13 +6706,18 @@ static IrInstruction *ir_gen_cancel(IrBuilder *irb, Scope *scope, AstNode *node) | ... | @@ -6704,13 +6706,18 @@ static IrInstruction *ir_gen_cancel(IrBuilder *irb, Scope *scope, AstNode *node) |
| 6704 | ir_set_cursor_at_end_and_append_block(irb, not_canceled_block); | 6706 | ir_set_cursor_at_end_and_append_block(irb, not_canceled_block); |
| 6705 | IrInstruction *awaiter_addr = ir_build_bin_op(irb, scope, node, IrBinOpBinAnd, prev_atomic_value, ptr_mask, false); | 6707 | IrInstruction *awaiter_addr = ir_build_bin_op(irb, scope, node, IrBinOpBinAnd, prev_atomic_value, ptr_mask, false); |
| 6706 | IrInstruction *is_returned_bool = ir_build_bin_op(irb, scope, node, IrBinOpCmpEq, awaiter_addr, ptr_mask, false); | 6708 | IrInstruction *is_returned_bool = ir_build_bin_op(irb, scope, node, IrBinOpCmpEq, awaiter_addr, ptr_mask, false); |
| 6707 | ir_build_cond_br(irb, scope, node, is_returned_bool, post_return_block, do_cancel_block, is_comptime); | 6709 | ir_build_cond_br(irb, scope, node, is_returned_bool, post_return_block, pre_return_block, is_comptime); |
| 6708 | | 6710 | |
| 6709 | ir_set_cursor_at_end_and_append_block(irb, post_return_block); | 6711 | ir_set_cursor_at_end_and_append_block(irb, post_return_block); |
| 6710 | IrInstruction *is_awaited_value = ir_build_bin_op(irb, scope, node, IrBinOpBinAnd, prev_atomic_value, await_mask, false); | 6712 | IrInstruction *is_awaited_value = ir_build_bin_op(irb, scope, node, IrBinOpBinAnd, prev_atomic_value, await_mask, false); |
| 6711 | IrInstruction *is_awaited_bool = ir_build_bin_op(irb, scope, node, IrBinOpCmpNotEq, is_awaited_value, zero, false); | 6713 | IrInstruction *is_awaited_bool = ir_build_bin_op(irb, scope, node, IrBinOpCmpNotEq, is_awaited_value, zero, false); |
| 6712 | ir_build_cond_br(irb, scope, node, is_awaited_bool, done_block, do_cancel_block, is_comptime); | 6714 | ir_build_cond_br(irb, scope, node, is_awaited_bool, done_block, do_cancel_block, is_comptime); |
| 6713 | | 6715 | |
| | 6716 | ir_set_cursor_at_end_and_append_block(irb, pre_return_block); |
| | 6717 | IrInstruction *is_suspended_value = ir_build_bin_op(irb, scope, node, IrBinOpBinAnd, prev_atomic_value, is_suspended_mask, false); |
| | 6718 | IrInstruction *is_suspended_bool = ir_build_bin_op(irb, scope, node, IrBinOpCmpNotEq, is_suspended_value, zero, false); |
| | 6719 | ir_build_cond_br(irb, scope, node, is_suspended_bool, do_cancel_block, done_block, is_comptime); |
| | 6720 | |
| 6714 | ir_set_cursor_at_end_and_append_block(irb, do_cancel_block); | 6721 | ir_set_cursor_at_end_and_append_block(irb, do_cancel_block); |
| 6715 | ir_build_cancel(irb, scope, node, target_inst); | 6722 | ir_build_cancel(irb, scope, node, target_inst); |
| 6716 | ir_build_br(irb, scope, node, done_block, is_comptime); | 6723 | ir_build_br(irb, scope, node, done_block, is_comptime); |