| ... | @@ -849,7 +849,7 @@ fn resolveBody( | ... | @@ -849,7 +849,7 @@ fn resolveBody( |
| 849 | body_inst: Zir.Inst.Index, | 849 | body_inst: Zir.Inst.Index, |
| 850 | ) CompileError!Air.Inst.Ref { | 850 | ) CompileError!Air.Inst.Ref { |
| 851 | const break_data = (try sema.analyzeBodyBreak(block, body)) orelse | 851 | const break_data = (try sema.analyzeBodyBreak(block, body)) orelse |
| 852 | return Air.Inst.Ref.unreachable_value; | 852 | return .unreachable_value; |
| 853 | // For comptime control flow, we need to detect when `analyzeBody` reports | 853 | // For comptime control flow, we need to detect when `analyzeBody` reports |
| 854 | // that we need to break from an outer block. In such case we | 854 | // that we need to break from an outer block. In such case we |
| 855 | // use Zig's error mechanism to send control flow up the stack until | 855 | // use Zig's error mechanism to send control flow up the stack until |
| ... | @@ -1757,7 +1757,7 @@ fn analyzeBodyInner( | ... | @@ -1757,7 +1757,7 @@ fn analyzeBodyInner( |
| 1757 | else => |e| return e, | 1757 | else => |e| return e, |
| 1758 | }; | 1758 | }; |
| 1759 | if (break_inst != defer_body[defer_body.len - 1]) break always_noreturn; | 1759 | if (break_inst != defer_body[defer_body.len - 1]) break always_noreturn; |
| 1760 | break :blk Air.Inst.Ref.void_value; | 1760 | break :blk .void_value; |
| 1761 | }, | 1761 | }, |
| 1762 | .defer_err_code => blk: { | 1762 | .defer_err_code => blk: { |
| 1763 | const inst_data = sema.code.instructions.items(.data)[inst].defer_err_code; | 1763 | const inst_data = sema.code.instructions.items(.data)[inst].defer_err_code; |
| ... | @@ -1770,7 +1770,7 @@ fn analyzeBodyInner( | ... | @@ -1770,7 +1770,7 @@ fn analyzeBodyInner( |
| 1770 | else => |e| return e, | 1770 | else => |e| return e, |
| 1771 | }; | 1771 | }; |
| 1772 | if (break_inst != defer_body[defer_body.len - 1]) break always_noreturn; | 1772 | if (break_inst != defer_body[defer_body.len - 1]) break always_noreturn; |
| 1773 | break :blk Air.Inst.Ref.void_value; | 1773 | break :blk .void_value; |
| 1774 | }, | 1774 | }, |
| 1775 | }; | 1775 | }; |
| 1776 | if (sema.isNoReturn(air_inst)) { | 1776 | if (sema.isNoReturn(air_inst)) { |
| ... | @@ -2742,7 +2742,7 @@ fn coerceResultPtr( | ... | @@ -2742,7 +2742,7 @@ fn coerceResultPtr( |
| 2742 | if (pointee_ty.eql(Type.null, sema.mod)) { | 2742 | if (pointee_ty.eql(Type.null, sema.mod)) { |
| 2743 | const null_inst = Air.internedToRef(Value.null.toIntern()); | 2743 | const null_inst = Air.internedToRef(Value.null.toIntern()); |
| 2744 | _ = try block.addBinOp(.store, new_ptr, null_inst); | 2744 | _ = try block.addBinOp(.store, new_ptr, null_inst); |
| 2745 | return Air.Inst.Ref.void_value; | 2745 | return .void_value; |
| 2746 | } | 2746 | } |
| 2747 | return sema.bitCast(block, ptr_ty, new_ptr, src, null); | 2747 | return sema.bitCast(block, ptr_ty, new_ptr, src, null); |
| 2748 | } | 2748 | } |
| ... | @@ -5520,7 +5520,7 @@ fn zirCompileLog( | ... | @@ -5520,7 +5520,7 @@ fn zirCompileLog( |
| 5520 | if (!gop.found_existing) { | 5520 | if (!gop.found_existing) { |
| 5521 | gop.value_ptr.* = src_node; | 5521 | gop.value_ptr.* = src_node; |
| 5522 | } | 5522 | } |
| 5523 | return Air.Inst.Ref.void_value; | 5523 | return .void_value; |
| 5524 | } | 5524 | } |
| 5525 | | 5525 | |
| 5526 | fn zirPanic(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index { | 5526 | fn zirPanic(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index { |
| ... | @@ -5937,7 +5937,7 @@ fn analyzeBlockBody( | ... | @@ -5937,7 +5937,7 @@ fn analyzeBlockBody( |
| 5937 | | 5937 | |
| 5938 | sema.air_instructions.items(.tag)[br] = .block; | 5938 | sema.air_instructions.items(.tag)[br] = .block; |
| 5939 | sema.air_instructions.items(.data)[br] = .{ .ty_pl = .{ | 5939 | sema.air_instructions.items(.data)[br] = .{ .ty_pl = .{ |
| 5940 | .ty = Air.Inst.Ref.noreturn_type, | 5940 | .ty = .noreturn_type, |
| 5941 | .payload = sema.addExtraAssumeCapacity(Air.Block{ | 5941 | .payload = sema.addExtraAssumeCapacity(Air.Block{ |
| 5942 | .body_len = sub_block_len, | 5942 | .body_len = sub_block_len, |
| 5943 | }), | 5943 | }), |
| ... | @@ -6535,7 +6535,7 @@ fn popErrorReturnTrace( | ... | @@ -6535,7 +6535,7 @@ fn popErrorReturnTrace( |
| 6535 | .tag = .block, | 6535 | .tag = .block, |
| 6536 | .data = .{ | 6536 | .data = .{ |
| 6537 | .ty_pl = .{ | 6537 | .ty_pl = .{ |
| 6538 | .ty = Air.Inst.Ref.void_type, | 6538 | .ty = .void_type, |
| 6539 | .payload = undefined, // updated below | 6539 | .payload = undefined, // updated below |
| 6540 | }, | 6540 | }, |
| 6541 | }, | 6541 | }, |
| ... | @@ -6552,12 +6552,12 @@ fn popErrorReturnTrace( | ... | @@ -6552,12 +6552,12 @@ fn popErrorReturnTrace( |
| 6552 | const field_name = try mod.intern_pool.getOrPutString(gpa, "index"); | 6552 | const field_name = try mod.intern_pool.getOrPutString(gpa, "index"); |
| 6553 | const field_ptr = try sema.structFieldPtr(&then_block, src, err_return_trace, field_name, src, stack_trace_ty, true); | 6553 | const field_ptr = try sema.structFieldPtr(&then_block, src, err_return_trace, field_name, src, stack_trace_ty, true); |
| 6554 | try sema.storePtr2(&then_block, src, field_ptr, src, saved_error_trace_index, src, .store); | 6554 | try sema.storePtr2(&then_block, src, field_ptr, src, saved_error_trace_index, src, .store); |
| 6555 | _ = try then_block.addBr(cond_block_inst, Air.Inst.Ref.void_value); | 6555 | _ = try then_block.addBr(cond_block_inst, .void_value); |
| 6556 | | 6556 | |
| 6557 | // Otherwise, do nothing | 6557 | // Otherwise, do nothing |
| 6558 | var else_block = block.makeSubBlock(); | 6558 | var else_block = block.makeSubBlock(); |
| 6559 | defer else_block.instructions.deinit(gpa); | 6559 | defer else_block.instructions.deinit(gpa); |
| 6560 | _ = try else_block.addBr(cond_block_inst, Air.Inst.Ref.void_value); | 6560 | _ = try else_block.addBr(cond_block_inst, .void_value); |
| 6561 | | 6561 | |
| 6562 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).Struct.fields.len + | 6562 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).Struct.fields.len + |
| 6563 | then_block.instructions.items.len + else_block.instructions.items.len + | 6563 | then_block.instructions.items.len + else_block.instructions.items.len + |
| ... | @@ -7549,11 +7549,11 @@ fn analyzeCall( | ... | @@ -7549,11 +7549,11 @@ fn analyzeCall( |
| 7549 | } | 7549 | } |
| 7550 | } | 7550 | } |
| 7551 | try sema.safetyPanic(block, call_src, .noreturn_returned); | 7551 | try sema.safetyPanic(block, call_src, .noreturn_returned); |
| 7552 | return Air.Inst.Ref.unreachable_value; | 7552 | return .unreachable_value; |
| 7553 | } | 7553 | } |
| 7554 | if (func_ty_info.return_type == .noreturn_type) { | 7554 | if (func_ty_info.return_type == .noreturn_type) { |
| 7555 | _ = try block.addNoOp(.unreach); | 7555 | _ = try block.addNoOp(.unreach); |
| 7556 | return Air.Inst.Ref.unreachable_value; | 7556 | return .unreachable_value; |
| 7557 | } | 7557 | } |
| 7558 | break :res func_inst; | 7558 | break :res func_inst; |
| 7559 | }; | 7559 | }; |
| ... | @@ -7580,7 +7580,7 @@ fn handleTailCall(sema: *Sema, block: *Block, call_src: LazySrcLoc, func_ty: Typ | ... | @@ -7580,7 +7580,7 @@ fn handleTailCall(sema: *Sema, block: *Block, call_src: LazySrcLoc, func_ty: Typ |
| 7580 | }); | 7580 | }); |
| 7581 | } | 7581 | } |
| 7582 | _ = try block.addUnOp(.ret, result); | 7582 | _ = try block.addUnOp(.ret, result); |
| 7583 | return Air.Inst.Ref.unreachable_value; | 7583 | return .unreachable_value; |
| 7584 | } | 7584 | } |
| 7585 | | 7585 | |
| 7586 | /// Usually, returns null. If an argument was noreturn, returns that ref (which should become the call result). | 7586 | /// Usually, returns null. If an argument was noreturn, returns that ref (which should become the call result). |
| ... | @@ -8010,7 +8010,7 @@ fn instantiateGenericCall( | ... | @@ -8010,7 +8010,7 @@ fn instantiateGenericCall( |
| 8010 | } | 8010 | } |
| 8011 | if (func_ty.fnReturnType(mod).isNoReturn(mod)) { | 8011 | if (func_ty.fnReturnType(mod).isNoReturn(mod)) { |
| 8012 | _ = try block.addNoOp(.unreach); | 8012 | _ = try block.addNoOp(.unreach); |
| 8013 | return Air.Inst.Ref.unreachable_value; | 8013 | return .unreachable_value; |
| 8014 | } | 8014 | } |
| 8015 | return result; | 8015 | return result; |
| 8016 | } | 8016 | } |
| ... | @@ -8347,7 +8347,7 @@ fn zirErrorFromInt(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD | ... | @@ -8347,7 +8347,7 @@ fn zirErrorFromInt(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD |
| 8347 | return block.addInst(.{ | 8347 | return block.addInst(.{ |
| 8348 | .tag = .bitcast, | 8348 | .tag = .bitcast, |
| 8349 | .data = .{ .ty_op = .{ | 8349 | .data = .{ .ty_op = .{ |
| 8350 | .ty = Air.Inst.Ref.anyerror_type, | 8350 | .ty = .anyerror_type, |
| 8351 | .operand = operand, | 8351 | .operand = operand, |
| 8352 | } }, | 8352 | } }, |
| 8353 | }); | 8353 | }); |
| ... | @@ -8384,7 +8384,7 @@ fn zirMergeErrorSets(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr | ... | @@ -8384,7 +8384,7 @@ fn zirMergeErrorSets(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr |
| 8384 | | 8384 | |
| 8385 | // Anything merged with anyerror is anyerror. | 8385 | // Anything merged with anyerror is anyerror. |
| 8386 | if (lhs_ty.toIntern() == .anyerror_type or rhs_ty.toIntern() == .anyerror_type) { | 8386 | if (lhs_ty.toIntern() == .anyerror_type or rhs_ty.toIntern() == .anyerror_type) { |
| 8387 | return Air.Inst.Ref.anyerror_type; | 8387 | return .anyerror_type; |
| 8388 | } | 8388 | } |
| 8389 | | 8389 | |
| 8390 | if (ip.isInferredErrorSetType(lhs_ty.toIntern())) { | 8390 | if (ip.isInferredErrorSetType(lhs_ty.toIntern())) { |
| ... | @@ -10472,7 +10472,7 @@ const SwitchProngAnalysis = struct { | ... | @@ -10472,7 +10472,7 @@ const SwitchProngAnalysis = struct { |
| 10472 | | 10472 | |
| 10473 | if (sema.typeOf(capture_ref).isNoReturn(sema.mod)) { | 10473 | if (sema.typeOf(capture_ref).isNoReturn(sema.mod)) { |
| 10474 | // This prong should be unreachable! | 10474 | // This prong should be unreachable! |
| 10475 | return Air.Inst.Ref.unreachable_value; | 10475 | return .unreachable_value; |
| 10476 | } | 10476 | } |
| 10477 | | 10477 | |
| 10478 | sema.inst_map.putAssumeCapacity(spa.switch_block_inst, capture_ref); | 10478 | sema.inst_map.putAssumeCapacity(spa.switch_block_inst, capture_ref); |
| ... | @@ -10641,7 +10641,7 @@ const SwitchProngAnalysis = struct { | ... | @@ -10641,7 +10641,7 @@ const SwitchProngAnalysis = struct { |
| 10641 | return sema.bitCast(block, ty, spa.operand, operand_src, null); | 10641 | return sema.bitCast(block, ty, spa.operand, operand_src, null); |
| 10642 | } else { | 10642 | } else { |
| 10643 | try block.addUnreachable(operand_src, false); | 10643 | try block.addUnreachable(operand_src, false); |
| 10644 | return Air.Inst.Ref.unreachable_value; | 10644 | return .unreachable_value; |
| 10645 | }, | 10645 | }, |
| 10646 | else => return spa.operand, | 10646 | else => return spa.operand, |
| 10647 | } | 10647 | } |
| ... | @@ -11771,7 +11771,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11771,7 +11771,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11771 | } | 11771 | } |
| 11772 | if (err_set) try sema.maybeErrorUnwrapComptime(&child_block, special.body, operand); | 11772 | if (err_set) try sema.maybeErrorUnwrapComptime(&child_block, special.body, operand); |
| 11773 | if (empty_enum) { | 11773 | if (empty_enum) { |
| 11774 | return Air.Inst.Ref.void_value; | 11774 | return .void_value; |
| 11775 | } | 11775 | } |
| 11776 | | 11776 | |
| 11777 | return spa.resolveProngComptime( | 11777 | return spa.resolveProngComptime( |
| ... | @@ -11789,13 +11789,13 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11789,13 +11789,13 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11789 | | 11789 | |
| 11790 | if (scalar_cases_len + multi_cases_len == 0 and !special.is_inline) { | 11790 | if (scalar_cases_len + multi_cases_len == 0 and !special.is_inline) { |
| 11791 | if (empty_enum) { | 11791 | if (empty_enum) { |
| 11792 | return Air.Inst.Ref.void_value; | 11792 | return .void_value; |
| 11793 | } | 11793 | } |
| 11794 | if (special_prong == .none) { | 11794 | if (special_prong == .none) { |
| 11795 | return sema.fail(block, src, "switch must handle all possibilities", .{}); | 11795 | return sema.fail(block, src, "switch must handle all possibilities", .{}); |
| 11796 | } | 11796 | } |
| 11797 | if (err_set and try sema.maybeErrorUnwrap(block, special.body, operand, operand_src)) { | 11797 | if (err_set and try sema.maybeErrorUnwrap(block, special.body, operand, operand_src)) { |
| 11798 | return Air.Inst.Ref.unreachable_value; | 11798 | return .unreachable_value; |
| 11799 | } | 11799 | } |
| 11800 | if (mod.backendSupportsFeature(.is_named_enum_value) and block.wantSafety() and operand_ty.zigTypeTag(mod) == .Enum and | 11800 | if (mod.backendSupportsFeature(.is_named_enum_value) and block.wantSafety() and operand_ty.zigTypeTag(mod) == .Enum and |
| 11801 | (!operand_ty.isNonexhaustiveEnum(mod) or union_originally)) | 11801 | (!operand_ty.isNonexhaustiveEnum(mod) or union_originally)) |
| ... | @@ -12314,8 +12314,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -12314,8 +12314,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 12314 | special.body, | 12314 | special.body, |
| 12315 | special.capture, | 12315 | special.capture, |
| 12316 | .special_capture, | 12316 | .special_capture, |
| 12317 | &.{Air.Inst.Ref.bool_true}, | 12317 | &.{.bool_true}, |
| 12318 | Air.Inst.Ref.bool_true, | 12318 | .bool_true, |
| 12319 | special.has_tag_capture, | 12319 | special.has_tag_capture, |
| 12320 | ); | 12320 | ); |
| 12321 | | 12321 | |
| ... | @@ -12340,8 +12340,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -12340,8 +12340,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 12340 | special.body, | 12340 | special.body, |
| 12341 | special.capture, | 12341 | special.capture, |
| 12342 | .special_capture, | 12342 | .special_capture, |
| 12343 | &.{Air.Inst.Ref.bool_false}, | 12343 | &.{.bool_false}, |
| 12344 | Air.Inst.Ref.bool_false, | 12344 | .bool_false, |
| 12345 | special.has_tag_capture, | 12345 | special.has_tag_capture, |
| 12346 | ); | 12346 | ); |
| 12347 | | 12347 | |
| ... | @@ -12901,11 +12901,7 @@ fn zirHasField(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -12901,11 +12901,7 @@ fn zirHasField(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 12901 | ty.fmt(mod), | 12901 | ty.fmt(mod), |
| 12902 | }); | 12902 | }); |
| 12903 | }; | 12903 | }; |
| 12904 | if (has_field) { | 12904 | return if (has_field) .bool_true else .bool_false; |
| 12905 | return Air.Inst.Ref.bool_true; | | |
| 12906 | } else { | | |
| 12907 | return Air.Inst.Ref.bool_false; | | |
| 12908 | } | | |
| 12909 | } | 12905 | } |
| 12910 | | 12906 | |
| 12911 | fn zirHasDecl(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 12907 | fn zirHasDecl(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| ... | @@ -12921,14 +12917,14 @@ fn zirHasDecl(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -12921,14 +12917,14 @@ fn zirHasDecl(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 12921 | try sema.checkNamespaceType(block, lhs_src, container_type); | 12917 | try sema.checkNamespaceType(block, lhs_src, container_type); |
| 12922 | | 12918 | |
| 12923 | const namespace = container_type.getNamespaceIndex(mod).unwrap() orelse | 12919 | const namespace = container_type.getNamespaceIndex(mod).unwrap() orelse |
| 12924 | return Air.Inst.Ref.bool_false; | 12920 | return .bool_false; |
| 12925 | if (try sema.lookupInNamespace(block, src, namespace, decl_name, true)) |decl_index| { | 12921 | if (try sema.lookupInNamespace(block, src, namespace, decl_name, true)) |decl_index| { |
| 12926 | const decl = mod.declPtr(decl_index); | 12922 | const decl = mod.declPtr(decl_index); |
| 12927 | if (decl.is_pub or decl.getFileScope(mod) == block.getFileScope(mod)) { | 12923 | if (decl.is_pub or decl.getFileScope(mod) == block.getFileScope(mod)) { |
| 12928 | return Air.Inst.Ref.bool_true; | 12924 | return .bool_true; |
| 12929 | } | 12925 | } |
| 12930 | } | 12926 | } |
| 12931 | return Air.Inst.Ref.bool_false; | 12927 | return .bool_false; |
| 12932 | } | 12928 | } |
| 12933 | | 12929 | |
| 12934 | fn zirImport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 12930 | fn zirImport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| ... | @@ -15998,7 +15994,7 @@ fn zirAsm( | ... | @@ -15998,7 +15994,7 @@ fn zirAsm( |
| 15998 | return sema.fail(block, src, "volatile keyword is redundant on module-level assembly", .{}); | 15994 | return sema.fail(block, src, "volatile keyword is redundant on module-level assembly", .{}); |
| 15999 | } | 15995 | } |
| 16000 | try sema.mod.addGlobalAssembly(sema.owner_decl_index, asm_source); | 15996 | try sema.mod.addGlobalAssembly(sema.owner_decl_index, asm_source); |
| 16001 | return Air.Inst.Ref.void_value; | 15997 | return .void_value; |
| 16002 | } | 15998 | } |
| 16003 | | 15999 | |
| 16004 | if (block.is_comptime) { | 16000 | if (block.is_comptime) { |
| ... | @@ -16145,11 +16141,7 @@ fn zirCmpEq( | ... | @@ -16145,11 +16141,7 @@ fn zirCmpEq( |
| 16145 | const rhs_ty_tag = rhs_ty.zigTypeTag(mod); | 16141 | const rhs_ty_tag = rhs_ty.zigTypeTag(mod); |
| 16146 | if (lhs_ty_tag == .Null and rhs_ty_tag == .Null) { | 16142 | if (lhs_ty_tag == .Null and rhs_ty_tag == .Null) { |
| 16147 | // null == null, null != null | 16143 | // null == null, null != null |
| 16148 | if (op == .eq) { | 16144 | return if (op == .eq) .bool_true else .bool_false; |
| 16149 | return Air.Inst.Ref.bool_true; | | |
| 16150 | } else { | | |
| 16151 | return Air.Inst.Ref.bool_false; | | |
| 16152 | } | | |
| 16153 | } | 16145 | } |
| 16154 | | 16146 | |
| 16155 | // comparing null with optionals | 16147 | // comparing null with optionals |
| ... | @@ -16181,11 +16173,10 @@ fn zirCmpEq( | ... | @@ -16181,11 +16173,10 @@ fn zirCmpEq( |
| 16181 | } | 16173 | } |
| 16182 | const lkey = mod.intern_pool.indexToKey(lval.toIntern()); | 16174 | const lkey = mod.intern_pool.indexToKey(lval.toIntern()); |
| 16183 | const rkey = mod.intern_pool.indexToKey(rval.toIntern()); | 16175 | const rkey = mod.intern_pool.indexToKey(rval.toIntern()); |
| 16184 | if ((lkey.err.name == rkey.err.name) == (op == .eq)) { | 16176 | return if ((lkey.err.name == rkey.err.name) == (op == .eq)) |
| 16185 | return Air.Inst.Ref.bool_true; | 16177 | .bool_true |
| 16186 | } else { | 16178 | else |
| 16187 | return Air.Inst.Ref.bool_false; | 16179 | .bool_false; |
| 16188 | } | | |
| 16189 | } else { | 16180 | } else { |
| 16190 | break :src rhs_src; | 16181 | break :src rhs_src; |
| 16191 | } | 16182 | } |
| ... | @@ -16199,11 +16190,7 @@ fn zirCmpEq( | ... | @@ -16199,11 +16190,7 @@ fn zirCmpEq( |
| 16199 | if (lhs_ty_tag == .Type and rhs_ty_tag == .Type) { | 16190 | if (lhs_ty_tag == .Type and rhs_ty_tag == .Type) { |
| 16200 | const lhs_as_type = try sema.analyzeAsType(block, lhs_src, lhs); | 16191 | const lhs_as_type = try sema.analyzeAsType(block, lhs_src, lhs); |
| 16201 | const rhs_as_type = try sema.analyzeAsType(block, rhs_src, rhs); | 16192 | const rhs_as_type = try sema.analyzeAsType(block, rhs_src, rhs); |
| 16202 | if (lhs_as_type.eql(rhs_as_type, mod) == (op == .eq)) { | 16193 | return if (lhs_as_type.eql(rhs_as_type, mod) == (op == .eq)) .bool_true else .bool_false; |
| 16203 | return Air.Inst.Ref.bool_true; | | |
| 16204 | } else { | | |
| 16205 | return Air.Inst.Ref.bool_false; | | |
| 16206 | } | | |
| 16207 | } | 16194 | } |
| 16208 | return sema.analyzeCmp(block, src, lhs, rhs, op, lhs_src, rhs_src, true); | 16195 | return sema.analyzeCmp(block, src, lhs, rhs, op, lhs_src, rhs_src, true); |
| 16209 | } | 16196 | } |
| ... | @@ -16239,7 +16226,7 @@ fn analyzeCmpUnionTag( | ... | @@ -16239,7 +16226,7 @@ fn analyzeCmpUnionTag( |
| 16239 | if (enum_val.isUndef(mod)) return mod.undefRef(Type.bool); | 16226 | if (enum_val.isUndef(mod)) return mod.undefRef(Type.bool); |
| 16240 | const field_ty = union_ty.unionFieldType(enum_val, mod); | 16227 | const field_ty = union_ty.unionFieldType(enum_val, mod); |
| 16241 | if (field_ty.zigTypeTag(mod) == .NoReturn) { | 16228 | if (field_ty.zigTypeTag(mod) == .NoReturn) { |
| 16242 | return Air.Inst.Ref.bool_false; | 16229 | return .bool_false; |
| 16243 | } | 16230 | } |
| 16244 | } | 16231 | } |
| 16245 | | 16232 | |
| ... | @@ -16347,11 +16334,10 @@ fn cmpSelf( | ... | @@ -16347,11 +16334,10 @@ fn cmpSelf( |
| 16347 | return Air.internedToRef(cmp_val.toIntern()); | 16334 | return Air.internedToRef(cmp_val.toIntern()); |
| 16348 | } | 16335 | } |
| 16349 | | 16336 | |
| 16350 | if (try sema.compareAll(lhs_val, op, rhs_val, resolved_type)) { | 16337 | return if (try sema.compareAll(lhs_val, op, rhs_val, resolved_type)) |
| 16351 | return Air.Inst.Ref.bool_true; | 16338 | .bool_true |
| 16352 | } else { | 16339 | else |
| 16353 | return Air.Inst.Ref.bool_false; | 16340 | .bool_false; |
| 16354 | } | | |
| 16355 | } else { | 16341 | } else { |
| 16356 | if (resolved_type.zigTypeTag(mod) == .Bool) { | 16342 | if (resolved_type.zigTypeTag(mod) == .Bool) { |
| 16357 | // We can lower bool eq/neq more efficiently. | 16343 | // We can lower bool eq/neq more efficiently. |
| ... | @@ -18000,10 +17986,7 @@ fn zirBoolNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -18000,10 +17986,7 @@ fn zirBoolNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 18000 | if (try sema.resolveMaybeUndefVal(operand)) |val| { | 17986 | if (try sema.resolveMaybeUndefVal(operand)) |val| { |
| 18001 | return if (val.isUndef(mod)) | 17987 | return if (val.isUndef(mod)) |
| 18002 | mod.undefRef(Type.bool) | 17988 | mod.undefRef(Type.bool) |
| 18003 | else if (val.toBool()) | 17989 | else if (val.toBool()) .bool_false else .bool_true; |
| 18004 | Air.Inst.Ref.bool_false | | |
| 18005 | else | | |
| 18006 | Air.Inst.Ref.bool_true; | | |
| 18007 | } | 17990 | } |
| 18008 | try sema.requireRuntimeBlock(block, src, null); | 17991 | try sema.requireRuntimeBlock(block, src, null); |
| 18009 | return block.addTyOp(.not, Type.bool, operand); | 17992 | return block.addTyOp(.not, Type.bool, operand); |
| ... | @@ -18029,9 +18012,9 @@ fn zirBoolBr( | ... | @@ -18029,9 +18012,9 @@ fn zirBoolBr( |
| 18029 | | 18012 | |
| 18030 | if (try sema.resolveDefinedValue(parent_block, lhs_src, lhs)) |lhs_val| { | 18013 | if (try sema.resolveDefinedValue(parent_block, lhs_src, lhs)) |lhs_val| { |
| 18031 | if (is_bool_or and lhs_val.toBool()) { | 18014 | if (is_bool_or and lhs_val.toBool()) { |
| 18032 | return Air.Inst.Ref.bool_true; | 18015 | return .bool_true; |
| 18033 | } else if (!is_bool_or and !lhs_val.toBool()) { | 18016 | } else if (!is_bool_or and !lhs_val.toBool()) { |
| 18034 | return Air.Inst.Ref.bool_false; | 18017 | return .bool_false; |
| 18035 | } | 18018 | } |
| 18036 | // comptime-known left-hand side. No need for a block here; the result | 18019 | // comptime-known left-hand side. No need for a block here; the result |
| 18037 | // is simply the rhs expression. Here we rely on there only being 1 | 18020 | // is simply the rhs expression. Here we rely on there only being 1 |
| ... | @@ -18075,9 +18058,9 @@ fn zirBoolBr( | ... | @@ -18075,9 +18058,9 @@ fn zirBoolBr( |
| 18075 | if (!sema.typeOf(rhs_result).isNoReturn(mod)) { | 18058 | if (!sema.typeOf(rhs_result).isNoReturn(mod)) { |
| 18076 | if (try sema.resolveDefinedValue(rhs_block, sema.src, rhs_result)) |rhs_val| { | 18059 | if (try sema.resolveDefinedValue(rhs_block, sema.src, rhs_result)) |rhs_val| { |
| 18077 | if (is_bool_or and rhs_val.toBool()) { | 18060 | if (is_bool_or and rhs_val.toBool()) { |
| 18078 | return Air.Inst.Ref.bool_true; | 18061 | return .bool_true; |
| 18079 | } else if (!is_bool_or and !rhs_val.toBool()) { | 18062 | } else if (!is_bool_or and !rhs_val.toBool()) { |
| 18080 | return Air.Inst.Ref.bool_false; | 18063 | return .bool_false; |
| 18081 | } | 18064 | } |
| 18082 | } | 18065 | } |
| 18083 | } | 18066 | } |
| ... | @@ -19732,7 +19715,7 @@ fn zirFieldType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -19732,7 +19715,7 @@ fn zirFieldType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 19732 | // generic poison should not result in a failed compilation, but the | 19715 | // generic poison should not result in a failed compilation, but the |
| 19733 | // generic poison type. This prevents unnecessary failures when | 19716 | // generic poison type. This prevents unnecessary failures when |
| 19734 | // constructing types at compile-time. | 19717 | // constructing types at compile-time. |
| 19735 | error.GenericPoison => return Air.Inst.Ref.generic_poison_type, | 19718 | error.GenericPoison => return .generic_poison_type, |
| 19736 | else => |e| return e, | 19719 | else => |e| return e, |
| 19737 | }; | 19720 | }; |
| 19738 | const zir_field_name = sema.code.nullTerminatedString(extra.name_start); | 19721 | const zir_field_name = sema.code.nullTerminatedString(extra.name_start); |
| ... | @@ -20066,16 +20049,16 @@ fn zirReify( | ... | @@ -20066,16 +20049,16 @@ fn zirReify( |
| 20066 | if (try union_val.val.toValue().anyUndef(mod)) return sema.failWithUseOfUndef(block, src); | 20049 | if (try union_val.val.toValue().anyUndef(mod)) return sema.failWithUseOfUndef(block, src); |
| 20067 | const tag_index = type_info_ty.unionTagFieldIndex(union_val.tag.toValue(), mod).?; | 20050 | const tag_index = type_info_ty.unionTagFieldIndex(union_val.tag.toValue(), mod).?; |
| 20068 | switch (@as(std.builtin.TypeId, @enumFromInt(tag_index))) { | 20051 | switch (@as(std.builtin.TypeId, @enumFromInt(tag_index))) { |
| 20069 | .Type => return Air.Inst.Ref.type_type, | 20052 | .Type => return .type_type, |
| 20070 | .Void => return Air.Inst.Ref.void_type, | 20053 | .Void => return .void_type, |
| 20071 | .Bool => return Air.Inst.Ref.bool_type, | 20054 | .Bool => return .bool_type, |
| 20072 | .NoReturn => return Air.Inst.Ref.noreturn_type, | 20055 | .NoReturn => return .noreturn_type, |
| 20073 | .ComptimeFloat => return Air.Inst.Ref.comptime_float_type, | 20056 | .ComptimeFloat => return .comptime_float_type, |
| 20074 | .ComptimeInt => return Air.Inst.Ref.comptime_int_type, | 20057 | .ComptimeInt => return .comptime_int_type, |
| 20075 | .Undefined => return Air.Inst.Ref.undefined_type, | 20058 | .Undefined => return .undefined_type, |
| 20076 | .Null => return Air.Inst.Ref.null_type, | 20059 | .Null => return .null_type, |
| 20077 | .AnyFrame => return sema.failWithUseOfAsync(block, src), | 20060 | .AnyFrame => return sema.failWithUseOfAsync(block, src), |
| 20078 | .EnumLiteral => return Air.Inst.Ref.enum_literal_type, | 20061 | .EnumLiteral => return .enum_literal_type, |
| 20079 | .Int => { | 20062 | .Int => { |
| 20080 | const fields = ip.typeOf(union_val.val).toType().structFields(mod); | 20063 | const fields = ip.typeOf(union_val.val).toType().structFields(mod); |
| 20081 | const signedness_val = try union_val.val.toValue().fieldValue( | 20064 | const signedness_val = try union_val.val.toValue().fieldValue( |
| ... | @@ -24566,7 +24549,7 @@ fn zirCUndef( | ... | @@ -24566,7 +24549,7 @@ fn zirCUndef( |
| 24566 | | 24549 | |
| 24567 | const name = try sema.resolveConstString(block, src, extra.operand, "name of macro being undefined must be comptime-known"); | 24550 | const name = try sema.resolveConstString(block, src, extra.operand, "name of macro being undefined must be comptime-known"); |
| 24568 | try block.c_import_buf.?.writer().print("#undef {s}\n", .{name}); | 24551 | try block.c_import_buf.?.writer().print("#undef {s}\n", .{name}); |
| 24569 | return Air.Inst.Ref.void_value; | 24552 | return .void_value; |
| 24570 | } | 24553 | } |
| 24571 | | 24554 | |
| 24572 | fn zirCInclude( | 24555 | fn zirCInclude( |
| ... | @@ -24579,7 +24562,7 @@ fn zirCInclude( | ... | @@ -24579,7 +24562,7 @@ fn zirCInclude( |
| 24579 | | 24562 | |
| 24580 | const name = try sema.resolveConstString(block, src, extra.operand, "path being included must be comptime-known"); | 24563 | const name = try sema.resolveConstString(block, src, extra.operand, "path being included must be comptime-known"); |
| 24581 | try block.c_import_buf.?.writer().print("#include <{s}>\n", .{name}); | 24564 | try block.c_import_buf.?.writer().print("#include <{s}>\n", .{name}); |
| 24582 | return Air.Inst.Ref.void_value; | 24565 | return .void_value; |
| 24583 | } | 24566 | } |
| 24584 | | 24567 | |
| 24585 | fn zirCDefine( | 24568 | fn zirCDefine( |
| ... | @@ -24600,7 +24583,7 @@ fn zirCDefine( | ... | @@ -24600,7 +24583,7 @@ fn zirCDefine( |
| 24600 | } else { | 24583 | } else { |
| 24601 | try block.c_import_buf.?.writer().print("#define {s}\n", .{name}); | 24584 | try block.c_import_buf.?.writer().print("#define {s}\n", .{name}); |
| 24602 | } | 24585 | } |
| 24603 | return Air.Inst.Ref.void_value; | 24586 | return .void_value; |
| 24604 | } | 24587 | } |
| 24605 | | 24588 | |
| 24606 | fn zirWasmMemorySize( | 24589 | fn zirWasmMemorySize( |
| ... | @@ -24717,7 +24700,7 @@ fn zirPrefetch( | ... | @@ -24717,7 +24700,7 @@ fn zirPrefetch( |
| 24717 | }); | 24700 | }); |
| 24718 | } | 24701 | } |
| 24719 | | 24702 | |
| 24720 | return Air.Inst.Ref.void_value; | 24703 | return .void_value; |
| 24721 | } | 24704 | } |
| 24722 | | 24705 | |
| 24723 | fn resolveExternOptions( | 24706 | fn resolveExternOptions( |
| ... | @@ -24902,11 +24885,7 @@ fn zirInComptime( | ... | @@ -24902,11 +24885,7 @@ fn zirInComptime( |
| 24902 | block: *Block, | 24885 | block: *Block, |
| 24903 | ) CompileError!Air.Inst.Ref { | 24886 | ) CompileError!Air.Inst.Ref { |
| 24904 | _ = sema; | 24887 | _ = sema; |
| 24905 | if (block.is_comptime) { | 24888 | return if (block.is_comptime) .bool_true else .bool_false; |
| 24906 | return Air.Inst.Ref.bool_true; | | |
| 24907 | } else { | | |
| 24908 | return Air.Inst.Ref.bool_false; | | |
| 24909 | } | | |
| 24910 | } | 24889 | } |
| 24911 | | 24890 | |
| 24912 | fn requireRuntimeBlock(sema: *Sema, block: *Block, src: LazySrcLoc, runtime_src: ?LazySrcLoc) !void { | 24891 | fn requireRuntimeBlock(sema: *Sema, block: *Block, src: LazySrcLoc, runtime_src: ?LazySrcLoc) !void { |
| ... | @@ -26723,7 +26702,7 @@ fn unionFieldPtr( | ... | @@ -26723,7 +26702,7 @@ fn unionFieldPtr( |
| 26723 | } | 26702 | } |
| 26724 | if (field_ty.zigTypeTag(mod) == .NoReturn) { | 26703 | if (field_ty.zigTypeTag(mod) == .NoReturn) { |
| 26725 | _ = try block.addNoOp(.unreach); | 26704 | _ = try block.addNoOp(.unreach); |
| 26726 | return Air.Inst.Ref.unreachable_value; | 26705 | return .unreachable_value; |
| 26727 | } | 26706 | } |
| 26728 | return block.addStructFieldPtr(union_ptr, field_index, ptr_field_ty); | 26707 | return block.addStructFieldPtr(union_ptr, field_index, ptr_field_ty); |
| 26729 | } | 26708 | } |
| ... | @@ -26795,7 +26774,7 @@ fn unionFieldVal( | ... | @@ -26795,7 +26774,7 @@ fn unionFieldVal( |
| 26795 | } | 26774 | } |
| 26796 | if (field_ty.zigTypeTag(mod) == .NoReturn) { | 26775 | if (field_ty.zigTypeTag(mod) == .NoReturn) { |
| 26797 | _ = try block.addNoOp(.unreach); | 26776 | _ = try block.addNoOp(.unreach); |
| 26798 | return Air.Inst.Ref.unreachable_value; | 26777 | return .unreachable_value; |
| 26799 | } | 26778 | } |
| 26800 | return block.addStructFieldVal(union_byval, field_index, field_ty); | 26779 | return block.addStructFieldVal(union_byval, field_index, field_ty); |
| 26801 | } | 26780 | } |
| ... | @@ -31227,14 +31206,10 @@ fn analyzeIsNull( | ... | @@ -31227,14 +31206,10 @@ fn analyzeIsNull( |
| 31227 | } | 31206 | } |
| 31228 | const is_null = opt_val.isNull(mod); | 31207 | const is_null = opt_val.isNull(mod); |
| 31229 | const bool_value = if (invert_logic) !is_null else is_null; | 31208 | const bool_value = if (invert_logic) !is_null else is_null; |
| 31230 | if (bool_value) { | 31209 | return if (bool_value) .bool_true else .bool_false; |
| 31231 | return Air.Inst.Ref.bool_true; | | |
| 31232 | } else { | | |
| 31233 | return Air.Inst.Ref.bool_false; | | |
| 31234 | } | | |
| 31235 | } | 31210 | } |
| 31236 | | 31211 | |
| 31237 | const inverted_non_null_res = if (invert_logic) Air.Inst.Ref.bool_true else Air.Inst.Ref.bool_false; | 31212 | const inverted_non_null_res: Air.Inst.Ref = if (invert_logic) .bool_true else .bool_false; |
| 31238 | const operand_ty = sema.typeOf(operand); | 31213 | const operand_ty = sema.typeOf(operand); |
| 31239 | if (operand_ty.zigTypeTag(mod) == .Optional and operand_ty.optionalChild(mod).zigTypeTag(mod) == .NoReturn) { | 31214 | if (operand_ty.zigTypeTag(mod) == .Optional and operand_ty.optionalChild(mod).zigTypeTag(mod) == .NoReturn) { |
| 31240 | return inverted_non_null_res; | 31215 | return inverted_non_null_res; |
| ... | @@ -31259,14 +31234,14 @@ fn analyzePtrIsNonErrComptimeOnly( | ... | @@ -31259,14 +31234,14 @@ fn analyzePtrIsNonErrComptimeOnly( |
| 31259 | const child_ty = ptr_ty.childType(mod); | 31234 | const child_ty = ptr_ty.childType(mod); |
| 31260 | | 31235 | |
| 31261 | const child_tag = child_ty.zigTypeTag(mod); | 31236 | const child_tag = child_ty.zigTypeTag(mod); |
| 31262 | if (child_tag != .ErrorSet and child_tag != .ErrorUnion) return Air.Inst.Ref.bool_true; | 31237 | if (child_tag != .ErrorSet and child_tag != .ErrorUnion) return .bool_true; |
| 31263 | if (child_tag == .ErrorSet) return Air.Inst.Ref.bool_false; | 31238 | if (child_tag == .ErrorSet) return .bool_false; |
| 31264 | assert(child_tag == .ErrorUnion); | 31239 | assert(child_tag == .ErrorUnion); |
| 31265 | | 31240 | |
| 31266 | _ = block; | 31241 | _ = block; |
| 31267 | _ = src; | 31242 | _ = src; |
| 31268 | | 31243 | |
| 31269 | return Air.Inst.Ref.none; | 31244 | return .none; |
| 31270 | } | 31245 | } |
| 31271 | | 31246 | |
| 31272 | fn analyzeIsNonErrComptimeOnly( | 31247 | fn analyzeIsNonErrComptimeOnly( |
| ... | @@ -31888,11 +31863,11 @@ fn cmpNumeric( | ... | @@ -31888,11 +31863,11 @@ fn cmpNumeric( |
| 31888 | // Compare ints: const vs. undefined (or vice versa) | 31863 | // Compare ints: const vs. undefined (or vice versa) |
| 31889 | if (!lhs_val.isUndef(mod) and (lhs_ty.isInt(mod) or lhs_ty_tag == .ComptimeInt) and rhs_ty.isInt(mod) and rhs_val.isUndef(mod)) { | 31864 | if (!lhs_val.isUndef(mod) and (lhs_ty.isInt(mod) or lhs_ty_tag == .ComptimeInt) and rhs_ty.isInt(mod) and rhs_val.isUndef(mod)) { |
| 31890 | if (try sema.compareIntsOnlyPossibleResult(try sema.resolveLazyValue(lhs_val), op, rhs_ty)) |res| { | 31865 | if (try sema.compareIntsOnlyPossibleResult(try sema.resolveLazyValue(lhs_val), op, rhs_ty)) |res| { |
| 31891 | return if (res) Air.Inst.Ref.bool_true else Air.Inst.Ref.bool_false; | 31866 | return if (res) .bool_true else .bool_false; |
| 31892 | } | 31867 | } |
| 31893 | } else if (!rhs_val.isUndef(mod) and (rhs_ty.isInt(mod) or rhs_ty_tag == .ComptimeInt) and lhs_ty.isInt(mod) and lhs_val.isUndef(mod)) { | 31868 | } else if (!rhs_val.isUndef(mod) and (rhs_ty.isInt(mod) or rhs_ty_tag == .ComptimeInt) and lhs_ty.isInt(mod) and lhs_val.isUndef(mod)) { |
| 31894 | if (try sema.compareIntsOnlyPossibleResult(try sema.resolveLazyValue(rhs_val), op.reverse(), lhs_ty)) |res| { | 31869 | if (try sema.compareIntsOnlyPossibleResult(try sema.resolveLazyValue(rhs_val), op.reverse(), lhs_ty)) |res| { |
| 31895 | return if (res) Air.Inst.Ref.bool_true else Air.Inst.Ref.bool_false; | 31870 | return if (res) .bool_true else .bool_false; |
| 31896 | } | 31871 | } |
| 31897 | } | 31872 | } |
| 31898 | | 31873 | |
| ... | @@ -31900,22 +31875,17 @@ fn cmpNumeric( | ... | @@ -31900,22 +31875,17 @@ fn cmpNumeric( |
| 31900 | return mod.undefRef(Type.bool); | 31875 | return mod.undefRef(Type.bool); |
| 31901 | } | 31876 | } |
| 31902 | if (lhs_val.isNan(mod) or rhs_val.isNan(mod)) { | 31877 | if (lhs_val.isNan(mod) or rhs_val.isNan(mod)) { |
| 31903 | if (op == std.math.CompareOperator.neq) { | 31878 | return if (op == std.math.CompareOperator.neq) .bool_true else .bool_false; |
| 31904 | return Air.Inst.Ref.bool_true; | | |
| 31905 | } else { | | |
| 31906 | return Air.Inst.Ref.bool_false; | | |
| 31907 | } | | |
| 31908 | } | | |
| 31909 | if (try Value.compareHeteroAdvanced(lhs_val, op, rhs_val, mod, sema)) { | | |
| 31910 | return Air.Inst.Ref.bool_true; | | |
| 31911 | } else { | | |
| 31912 | return Air.Inst.Ref.bool_false; | | |
| 31913 | } | 31879 | } |
| | 31880 | return if (try Value.compareHeteroAdvanced(lhs_val, op, rhs_val, mod, sema)) |
| | 31881 | .bool_true |
| | 31882 | else |
| | 31883 | .bool_false; |
| 31914 | } else { | 31884 | } else { |
| 31915 | if (!lhs_val.isUndef(mod) and (lhs_ty.isInt(mod) or lhs_ty_tag == .ComptimeInt) and rhs_ty.isInt(mod)) { | 31885 | if (!lhs_val.isUndef(mod) and (lhs_ty.isInt(mod) or lhs_ty_tag == .ComptimeInt) and rhs_ty.isInt(mod)) { |
| 31916 | // Compare ints: const vs. var | 31886 | // Compare ints: const vs. var |
| 31917 | if (try sema.compareIntsOnlyPossibleResult(try sema.resolveLazyValue(lhs_val), op, rhs_ty)) |res| { | 31887 | if (try sema.compareIntsOnlyPossibleResult(try sema.resolveLazyValue(lhs_val), op, rhs_ty)) |res| { |
| 31918 | return if (res) Air.Inst.Ref.bool_true else Air.Inst.Ref.bool_false; | 31888 | return if (res) .bool_true else .bool_false; |
| 31919 | } | 31889 | } |
| 31920 | } | 31890 | } |
| 31921 | break :src rhs_src; | 31891 | break :src rhs_src; |
| ... | @@ -31925,7 +31895,7 @@ fn cmpNumeric( | ... | @@ -31925,7 +31895,7 @@ fn cmpNumeric( |
| 31925 | if (!rhs_val.isUndef(mod) and (rhs_ty.isInt(mod) or rhs_ty_tag == .ComptimeInt) and lhs_ty.isInt(mod)) { | 31895 | if (!rhs_val.isUndef(mod) and (rhs_ty.isInt(mod) or rhs_ty_tag == .ComptimeInt) and lhs_ty.isInt(mod)) { |
| 31926 | // Compare ints: var vs. const | 31896 | // Compare ints: var vs. const |
| 31927 | if (try sema.compareIntsOnlyPossibleResult(try sema.resolveLazyValue(rhs_val), op.reverse(), lhs_ty)) |res| { | 31897 | if (try sema.compareIntsOnlyPossibleResult(try sema.resolveLazyValue(rhs_val), op.reverse(), lhs_ty)) |res| { |
| 31928 | return if (res) Air.Inst.Ref.bool_true else Air.Inst.Ref.bool_false; | 31898 | return if (res) .bool_true else .bool_false; |
| 31929 | } | 31899 | } |
| 31930 | } | 31900 | } |
| 31931 | } | 31901 | } |
| ... | @@ -31992,34 +31962,34 @@ fn cmpNumeric( | ... | @@ -31992,34 +31962,34 @@ fn cmpNumeric( |
| 31992 | if (lhs_val.isUndef(mod)) | 31962 | if (lhs_val.isUndef(mod)) |
| 31993 | return mod.undefRef(Type.bool); | 31963 | return mod.undefRef(Type.bool); |
| 31994 | if (lhs_val.isNan(mod)) switch (op) { | 31964 | if (lhs_val.isNan(mod)) switch (op) { |
| 31995 | .neq => return Air.Inst.Ref.bool_true, | 31965 | .neq => return .bool_true, |
| 31996 | else => return Air.Inst.Ref.bool_false, | 31966 | else => return .bool_false, |
| 31997 | }; | 31967 | }; |
| 31998 | if (lhs_val.isInf(mod)) switch (op) { | 31968 | if (lhs_val.isInf(mod)) switch (op) { |
| 31999 | .neq => return Air.Inst.Ref.bool_true, | 31969 | .neq => return .bool_true, |
| 32000 | .eq => return Air.Inst.Ref.bool_false, | 31970 | .eq => return .bool_false, |
| 32001 | .gt, .gte => return if (lhs_val.isNegativeInf(mod)) Air.Inst.Ref.bool_false else Air.Inst.Ref.bool_true, | 31971 | .gt, .gte => return if (lhs_val.isNegativeInf(mod)) .bool_false else .bool_true, |
| 32002 | .lt, .lte => return if (lhs_val.isNegativeInf(mod)) Air.Inst.Ref.bool_true else Air.Inst.Ref.bool_false, | 31972 | .lt, .lte => return if (lhs_val.isNegativeInf(mod)) .bool_true else .bool_false, |
| 32003 | }; | 31973 | }; |
| 32004 | if (!rhs_is_signed) { | 31974 | if (!rhs_is_signed) { |
| 32005 | switch (lhs_val.orderAgainstZero(mod)) { | 31975 | switch (lhs_val.orderAgainstZero(mod)) { |
| 32006 | .gt => {}, | 31976 | .gt => {}, |
| 32007 | .eq => switch (op) { // LHS = 0, RHS is unsigned | 31977 | .eq => switch (op) { // LHS = 0, RHS is unsigned |
| 32008 | .lte => return Air.Inst.Ref.bool_true, | 31978 | .lte => return .bool_true, |
| 32009 | .gt => return Air.Inst.Ref.bool_false, | 31979 | .gt => return .bool_false, |
| 32010 | else => {}, | 31980 | else => {}, |
| 32011 | }, | 31981 | }, |
| 32012 | .lt => switch (op) { // LHS < 0, RHS is unsigned | 31982 | .lt => switch (op) { // LHS < 0, RHS is unsigned |
| 32013 | .neq, .lt, .lte => return Air.Inst.Ref.bool_true, | 31983 | .neq, .lt, .lte => return .bool_true, |
| 32014 | .eq, .gt, .gte => return Air.Inst.Ref.bool_false, | 31984 | .eq, .gt, .gte => return .bool_false, |
| 32015 | }, | 31985 | }, |
| 32016 | } | 31986 | } |
| 32017 | } | 31987 | } |
| 32018 | if (lhs_is_float) { | 31988 | if (lhs_is_float) { |
| 32019 | if (lhs_val.floatHasFraction(mod)) { | 31989 | if (lhs_val.floatHasFraction(mod)) { |
| 32020 | switch (op) { | 31990 | switch (op) { |
| 32021 | .eq => return Air.Inst.Ref.bool_false, | 31991 | .eq => return .bool_false, |
| 32022 | .neq => return Air.Inst.Ref.bool_true, | 31992 | .neq => return .bool_true, |
| 32023 | else => {}, | 31993 | else => {}, |
| 32024 | } | 31994 | } |
| 32025 | } | 31995 | } |
| ... | @@ -32050,34 +32020,34 @@ fn cmpNumeric( | ... | @@ -32050,34 +32020,34 @@ fn cmpNumeric( |
| 32050 | if (rhs_val.isUndef(mod)) | 32020 | if (rhs_val.isUndef(mod)) |
| 32051 | return mod.undefRef(Type.bool); | 32021 | return mod.undefRef(Type.bool); |
| 32052 | if (rhs_val.isNan(mod)) switch (op) { | 32022 | if (rhs_val.isNan(mod)) switch (op) { |
| 32053 | .neq => return Air.Inst.Ref.bool_true, | 32023 | .neq => return .bool_true, |
| 32054 | else => return Air.Inst.Ref.bool_false, | 32024 | else => return .bool_false, |
| 32055 | }; | 32025 | }; |
| 32056 | if (rhs_val.isInf(mod)) switch (op) { | 32026 | if (rhs_val.isInf(mod)) switch (op) { |
| 32057 | .neq => return Air.Inst.Ref.bool_true, | 32027 | .neq => return .bool_true, |
| 32058 | .eq => return Air.Inst.Ref.bool_false, | 32028 | .eq => return .bool_false, |
| 32059 | .gt, .gte => return if (rhs_val.isNegativeInf(mod)) Air.Inst.Ref.bool_true else Air.Inst.Ref.bool_false, | 32029 | .gt, .gte => return if (rhs_val.isNegativeInf(mod)) .bool_true else .bool_false, |
| 32060 | .lt, .lte => return if (rhs_val.isNegativeInf(mod)) Air.Inst.Ref.bool_false else Air.Inst.Ref.bool_true, | 32030 | .lt, .lte => return if (rhs_val.isNegativeInf(mod)) .bool_false else .bool_true, |
| 32061 | }; | 32031 | }; |
| 32062 | if (!lhs_is_signed) { | 32032 | if (!lhs_is_signed) { |
| 32063 | switch (rhs_val.orderAgainstZero(mod)) { | 32033 | switch (rhs_val.orderAgainstZero(mod)) { |
| 32064 | .gt => {}, | 32034 | .gt => {}, |
| 32065 | .eq => switch (op) { // RHS = 0, LHS is unsigned | 32035 | .eq => switch (op) { // RHS = 0, LHS is unsigned |
| 32066 | .gte => return Air.Inst.Ref.bool_true, | 32036 | .gte => return .bool_true, |
| 32067 | .lt => return Air.Inst.Ref.bool_false, | 32037 | .lt => return .bool_false, |
| 32068 | else => {}, | 32038 | else => {}, |
| 32069 | }, | 32039 | }, |
| 32070 | .lt => switch (op) { // RHS < 0, LHS is unsigned | 32040 | .lt => switch (op) { // RHS < 0, LHS is unsigned |
| 32071 | .neq, .gt, .gte => return Air.Inst.Ref.bool_true, | 32041 | .neq, .gt, .gte => return .bool_true, |
| 32072 | .eq, .lt, .lte => return Air.Inst.Ref.bool_false, | 32042 | .eq, .lt, .lte => return .bool_false, |
| 32073 | }, | 32043 | }, |
| 32074 | } | 32044 | } |
| 32075 | } | 32045 | } |
| 32076 | if (rhs_is_float) { | 32046 | if (rhs_is_float) { |
| 32077 | if (rhs_val.floatHasFraction(mod)) { | 32047 | if (rhs_val.floatHasFraction(mod)) { |
| 32078 | switch (op) { | 32048 | switch (op) { |
| 32079 | .eq => return Air.Inst.Ref.bool_false, | 32049 | .eq => return .bool_false, |
| 32080 | .neq => return Air.Inst.Ref.bool_true, | 32050 | .neq => return .bool_true, |
| 32081 | else => {}, | 32051 | else => {}, |
| 32082 | } | 32052 | } |
| 32083 | } | 32053 | } |