| ... | @@ -269,7 +269,7 @@ pub const InstMap = struct { | ... | @@ -269,7 +269,7 @@ pub const InstMap = struct { |
| 269 | while (true) { | 269 | while (true) { |
| 270 | const extra_capacity = better_capacity / 2 + 16; | 270 | const extra_capacity = better_capacity / 2 + 16; |
| 271 | better_capacity += extra_capacity; | 271 | better_capacity += extra_capacity; |
| 272 | better_start -|= @as(Zir.Inst.Index, @intCast(extra_capacity / 2)); | 272 | better_start -|= @intCast(extra_capacity / 2); |
| 273 | if (better_start <= start and end < better_capacity + better_start) | 273 | if (better_start <= start and end < better_capacity + better_start) |
| 274 | break; | 274 | break; |
| 275 | } | 275 | } |
| ... | @@ -282,7 +282,7 @@ pub const InstMap = struct { | ... | @@ -282,7 +282,7 @@ pub const InstMap = struct { |
| 282 | | 282 | |
| 283 | allocator.free(map.items); | 283 | allocator.free(map.items); |
| 284 | map.items = new_items; | 284 | map.items = new_items; |
| 285 | map.start = @as(Zir.Inst.Index, @intCast(better_start)); | 285 | map.start = @intCast(better_start); |
| 286 | } | 286 | } |
| 287 | }; | 287 | }; |
| 288 | | 288 | |
| ... | @@ -681,7 +681,7 @@ pub const Block = struct { | ... | @@ -681,7 +681,7 @@ pub const Block = struct { |
| 681 | const sema = block.sema; | 681 | const sema = block.sema; |
| 682 | const ty_ref = Air.internedToRef(aggregate_ty.toIntern()); | 682 | const ty_ref = Air.internedToRef(aggregate_ty.toIntern()); |
| 683 | try sema.air_extra.ensureUnusedCapacity(sema.gpa, elements.len); | 683 | try sema.air_extra.ensureUnusedCapacity(sema.gpa, elements.len); |
| 684 | const extra_index = @as(u32, @intCast(sema.air_extra.items.len)); | 684 | const extra_index: u32 = @intCast(sema.air_extra.items.len); |
| 685 | sema.appendRefsAssumeCapacity(elements); | 685 | sema.appendRefsAssumeCapacity(elements); |
| 686 | | 686 | |
| 687 | return block.addInst(.{ | 687 | return block.addInst(.{ |
| ... | @@ -722,7 +722,7 @@ pub const Block = struct { | ... | @@ -722,7 +722,7 @@ pub const Block = struct { |
| 722 | try sema.air_instructions.ensureUnusedCapacity(gpa, 1); | 722 | try sema.air_instructions.ensureUnusedCapacity(gpa, 1); |
| 723 | try block.instructions.ensureUnusedCapacity(gpa, 1); | 723 | try block.instructions.ensureUnusedCapacity(gpa, 1); |
| 724 | | 724 | |
| 725 | const result_index = @as(Air.Inst.Index, @intCast(sema.air_instructions.len)); | 725 | const result_index: Air.Inst.Index = @intCast(sema.air_instructions.len); |
| 726 | sema.air_instructions.appendAssumeCapacity(inst); | 726 | sema.air_instructions.appendAssumeCapacity(inst); |
| 727 | block.instructions.appendAssumeCapacity(result_index); | 727 | block.instructions.appendAssumeCapacity(result_index); |
| 728 | return result_index; | 728 | return result_index; |
| ... | @@ -740,7 +740,7 @@ pub const Block = struct { | ... | @@ -740,7 +740,7 @@ pub const Block = struct { |
| 740 | | 740 | |
| 741 | try sema.air_instructions.ensureUnusedCapacity(gpa, 1); | 741 | try sema.air_instructions.ensureUnusedCapacity(gpa, 1); |
| 742 | | 742 | |
| 743 | const result_index = @as(Air.Inst.Index, @intCast(sema.air_instructions.len)); | 743 | const result_index: Air.Inst.Index = @intCast(sema.air_instructions.len); |
| 744 | sema.air_instructions.appendAssumeCapacity(inst); | 744 | sema.air_instructions.appendAssumeCapacity(inst); |
| 745 | | 745 | |
| 746 | try block.instructions.insert(gpa, index, result_index); | 746 | try block.instructions.insert(gpa, index, result_index); |
| ... | @@ -1819,7 +1819,7 @@ pub fn resolveInst(sema: *Sema, zir_ref: Zir.Inst.Ref) !Air.Inst.Ref { | ... | @@ -1819,7 +1819,7 @@ pub fn resolveInst(sema: *Sema, zir_ref: Zir.Inst.Ref) !Air.Inst.Ref { |
| 1819 | const i = @intFromEnum(zir_ref); | 1819 | const i = @intFromEnum(zir_ref); |
| 1820 | // First section of indexes correspond to a set number of constant values. | 1820 | // First section of indexes correspond to a set number of constant values. |
| 1821 | // We intentionally map the same indexes to the same values between ZIR and AIR. | 1821 | // We intentionally map the same indexes to the same values between ZIR and AIR. |
| 1822 | if (i < InternPool.static_len) return @as(Air.Inst.Ref, @enumFromInt(i)); | 1822 | if (i < InternPool.static_len) return @enumFromInt(i); |
| 1823 | // The last section of indexes refers to the map of ZIR => AIR. | 1823 | // The last section of indexes refers to the map of ZIR => AIR. |
| 1824 | const inst = sema.inst_map.get(i - InternPool.static_len).?; | 1824 | const inst = sema.inst_map.get(i - InternPool.static_len).?; |
| 1825 | if (inst == .generic_poison) return error.GenericPoison; | 1825 | if (inst == .generic_poison) return error.GenericPoison; |
| ... | @@ -2508,7 +2508,7 @@ fn analyzeAsAlign( | ... | @@ -2508,7 +2508,7 @@ fn analyzeAsAlign( |
| 2508 | air_ref: Air.Inst.Ref, | 2508 | air_ref: Air.Inst.Ref, |
| 2509 | ) !Alignment { | 2509 | ) !Alignment { |
| 2510 | const alignment_big = try sema.analyzeAsInt(block, src, air_ref, align_ty, "alignment must be comptime-known"); | 2510 | const alignment_big = try sema.analyzeAsInt(block, src, air_ref, align_ty, "alignment must be comptime-known"); |
| 2511 | const alignment = @as(u32, @intCast(alignment_big)); // We coerce to u29 in the prev line. | 2511 | const alignment: u32 = @intCast(alignment_big); // We coerce to u29 in the prev line. |
| 2512 | try sema.validateAlign(block, src, alignment); | 2512 | try sema.validateAlign(block, src, alignment); |
| 2513 | return Alignment.fromNonzeroByteUnits(alignment); | 2513 | return Alignment.fromNonzeroByteUnits(alignment); |
| 2514 | } | 2514 | } |
| ... | @@ -2815,7 +2815,7 @@ pub fn analyzeStructDecl( | ... | @@ -2815,7 +2815,7 @@ pub fn analyzeStructDecl( |
| 2815 | const struct_obj = mod.structPtr(struct_index); | 2815 | const struct_obj = mod.structPtr(struct_index); |
| 2816 | const extended = sema.code.instructions.items(.data)[inst].extended; | 2816 | const extended = sema.code.instructions.items(.data)[inst].extended; |
| 2817 | assert(extended.opcode == .struct_decl); | 2817 | assert(extended.opcode == .struct_decl); |
| 2818 | const small = @as(Zir.Inst.StructDecl.Small, @bitCast(extended.small)); | 2818 | const small: Zir.Inst.StructDecl.Small = @bitCast(extended.small); |
| 2819 | | 2819 | |
| 2820 | struct_obj.known_non_opv = small.known_non_opv; | 2820 | struct_obj.known_non_opv = small.known_non_opv; |
| 2821 | if (small.known_comptime_only) { | 2821 | if (small.known_comptime_only) { |
| ... | @@ -2852,9 +2852,9 @@ fn zirStructDecl( | ... | @@ -2852,9 +2852,9 @@ fn zirStructDecl( |
| 2852 | ) CompileError!Air.Inst.Ref { | 2852 | ) CompileError!Air.Inst.Ref { |
| 2853 | const mod = sema.mod; | 2853 | const mod = sema.mod; |
| 2854 | const gpa = sema.gpa; | 2854 | const gpa = sema.gpa; |
| 2855 | const small = @as(Zir.Inst.StructDecl.Small, @bitCast(extended.small)); | 2855 | const small: Zir.Inst.StructDecl.Small = @bitCast(extended.small); |
| 2856 | const src: LazySrcLoc = if (small.has_src_node) blk: { | 2856 | const src: LazySrcLoc = if (small.has_src_node) blk: { |
| 2857 | const node_offset = @as(i32, @bitCast(sema.code.extra[extended.operand])); | 2857 | const node_offset: i32 = @bitCast(sema.code.extra[extended.operand]); |
| 2858 | break :blk LazySrcLoc.nodeOffset(node_offset); | 2858 | break :blk LazySrcLoc.nodeOffset(node_offset); |
| 2859 | } else sema.src; | 2859 | } else sema.src; |
| 2860 | | 2860 | |
| ... | @@ -3218,7 +3218,7 @@ fn zirEnumDecl( | ... | @@ -3218,7 +3218,7 @@ fn zirEnumDecl( |
| 3218 | } | 3218 | } |
| 3219 | | 3219 | |
| 3220 | const tag_overflow = if (has_tag_value) overflow: { | 3220 | const tag_overflow = if (has_tag_value) overflow: { |
| 3221 | const tag_val_ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index])); | 3221 | const tag_val_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]); |
| 3222 | extra_index += 1; | 3222 | extra_index += 1; |
| 3223 | const tag_inst = try sema.resolveInst(tag_val_ref); | 3223 | const tag_inst = try sema.resolveInst(tag_val_ref); |
| 3224 | last_tag_val = sema.resolveConstValue(block, .unneeded, tag_inst, "") catch |err| switch (err) { | 3224 | last_tag_val = sema.resolveConstValue(block, .unneeded, tag_inst, "") catch |err| switch (err) { |
| ... | @@ -3300,11 +3300,11 @@ fn zirUnionDecl( | ... | @@ -3300,11 +3300,11 @@ fn zirUnionDecl( |
| 3300 | | 3300 | |
| 3301 | const mod = sema.mod; | 3301 | const mod = sema.mod; |
| 3302 | const gpa = sema.gpa; | 3302 | const gpa = sema.gpa; |
| 3303 | const small = @as(Zir.Inst.UnionDecl.Small, @bitCast(extended.small)); | 3303 | const small: Zir.Inst.UnionDecl.Small = @bitCast(extended.small); |
| 3304 | var extra_index: usize = extended.operand; | 3304 | var extra_index: usize = extended.operand; |
| 3305 | | 3305 | |
| 3306 | const src: LazySrcLoc = if (small.has_src_node) blk: { | 3306 | const src: LazySrcLoc = if (small.has_src_node) blk: { |
| 3307 | const node_offset = @as(i32, @bitCast(sema.code.extra[extra_index])); | 3307 | const node_offset: i32 = @bitCast(sema.code.extra[extra_index]); |
| 3308 | extra_index += 1; | 3308 | extra_index += 1; |
| 3309 | break :blk LazySrcLoc.nodeOffset(node_offset); | 3309 | break :blk LazySrcLoc.nodeOffset(node_offset); |
| 3310 | } else sema.src; | 3310 | } else sema.src; |
| ... | @@ -3398,11 +3398,11 @@ fn zirOpaqueDecl( | ... | @@ -3398,11 +3398,11 @@ fn zirOpaqueDecl( |
| 3398 | defer tracy.end(); | 3398 | defer tracy.end(); |
| 3399 | | 3399 | |
| 3400 | const mod = sema.mod; | 3400 | const mod = sema.mod; |
| 3401 | const small = @as(Zir.Inst.OpaqueDecl.Small, @bitCast(extended.small)); | 3401 | const small: Zir.Inst.OpaqueDecl.Small = @bitCast(extended.small); |
| 3402 | var extra_index: usize = extended.operand; | 3402 | var extra_index: usize = extended.operand; |
| 3403 | | 3403 | |
| 3404 | const src: LazySrcLoc = if (small.has_src_node) blk: { | 3404 | const src: LazySrcLoc = if (small.has_src_node) blk: { |
| 3405 | const node_offset = @as(i32, @bitCast(sema.code.extra[extra_index])); | 3405 | const node_offset: i32 = @bitCast(sema.code.extra[extra_index]); |
| 3406 | extra_index += 1; | 3406 | extra_index += 1; |
| 3407 | break :blk LazySrcLoc.nodeOffset(node_offset); | 3407 | break :blk LazySrcLoc.nodeOffset(node_offset); |
| 3408 | } else sema.src; | 3408 | } else sema.src; |
| ... | @@ -3469,7 +3469,7 @@ fn zirErrorSetDecl( | ... | @@ -3469,7 +3469,7 @@ fn zirErrorSetDecl( |
| 3469 | var names: InferredErrorSet.NameMap = .{}; | 3469 | var names: InferredErrorSet.NameMap = .{}; |
| 3470 | try names.ensureUnusedCapacity(sema.arena, extra.data.fields_len); | 3470 | try names.ensureUnusedCapacity(sema.arena, extra.data.fields_len); |
| 3471 | | 3471 | |
| 3472 | var extra_index = @as(u32, @intCast(extra.end)); | 3472 | var extra_index: u32 = @intCast(extra.end); |
| 3473 | const extra_index_end = extra_index + (extra.data.fields_len * 2); | 3473 | const extra_index_end = extra_index + (extra.data.fields_len * 2); |
| 3474 | while (extra_index < extra_index_end) : (extra_index += 2) { // +2 to skip over doc_string | 3474 | while (extra_index < extra_index_end) : (extra_index += 2) { // +2 to skip over doc_string |
| 3475 | const str_index = sema.code.extra[extra_index]; | 3475 | const str_index = sema.code.extra[extra_index]; |
| ... | @@ -3669,18 +3669,18 @@ fn zirAllocExtended( | ... | @@ -3669,18 +3669,18 @@ fn zirAllocExtended( |
| 3669 | const extra = sema.code.extraData(Zir.Inst.AllocExtended, extended.operand); | 3669 | const extra = sema.code.extraData(Zir.Inst.AllocExtended, extended.operand); |
| 3670 | const ty_src: LazySrcLoc = .{ .node_offset_var_decl_ty = extra.data.src_node }; | 3670 | const ty_src: LazySrcLoc = .{ .node_offset_var_decl_ty = extra.data.src_node }; |
| 3671 | const align_src: LazySrcLoc = .{ .node_offset_var_decl_align = extra.data.src_node }; | 3671 | const align_src: LazySrcLoc = .{ .node_offset_var_decl_align = extra.data.src_node }; |
| 3672 | const small = @as(Zir.Inst.AllocExtended.Small, @bitCast(extended.small)); | 3672 | const small: Zir.Inst.AllocExtended.Small = @bitCast(extended.small); |
| 3673 | | 3673 | |
| 3674 | var extra_index: usize = extra.end; | 3674 | var extra_index: usize = extra.end; |
| 3675 | | 3675 | |
| 3676 | const var_ty: Type = if (small.has_type) blk: { | 3676 | const var_ty: Type = if (small.has_type) blk: { |
| 3677 | const type_ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index])); | 3677 | const type_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]); |
| 3678 | extra_index += 1; | 3678 | extra_index += 1; |
| 3679 | break :blk try sema.resolveType(block, ty_src, type_ref); | 3679 | break :blk try sema.resolveType(block, ty_src, type_ref); |
| 3680 | } else undefined; | 3680 | } else undefined; |
| 3681 | | 3681 | |
| 3682 | const alignment = if (small.has_align) blk: { | 3682 | const alignment = if (small.has_align) blk: { |
| 3683 | const align_ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index])); | 3683 | const align_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]); |
| 3684 | extra_index += 1; | 3684 | extra_index += 1; |
| 3685 | const alignment = try sema.resolveAlign(block, align_src, align_ref); | 3685 | const alignment = try sema.resolveAlign(block, align_src, align_ref); |
| 3686 | break :blk alignment; | 3686 | break :blk alignment; |
| ... | @@ -3698,7 +3698,7 @@ fn zirAllocExtended( | ... | @@ -3698,7 +3698,7 @@ fn zirAllocExtended( |
| 3698 | .is_const = small.is_const, | 3698 | .is_const = small.is_const, |
| 3699 | } }, | 3699 | } }, |
| 3700 | }); | 3700 | }); |
| 3701 | return Air.indexToRef(@as(u32, @intCast(sema.air_instructions.len - 1))); | 3701 | return Air.indexToRef(@intCast(sema.air_instructions.len - 1)); |
| 3702 | } | 3702 | } |
| 3703 | } | 3703 | } |
| 3704 | | 3704 | |
| ... | @@ -3830,7 +3830,7 @@ fn zirAllocInferredComptime( | ... | @@ -3830,7 +3830,7 @@ fn zirAllocInferredComptime( |
| 3830 | .is_const = is_const, | 3830 | .is_const = is_const, |
| 3831 | } }, | 3831 | } }, |
| 3832 | }); | 3832 | }); |
| 3833 | return Air.indexToRef(@as(u32, @intCast(sema.air_instructions.len - 1))); | 3833 | return Air.indexToRef(@intCast(sema.air_instructions.len - 1)); |
| 3834 | } | 3834 | } |
| 3835 | | 3835 | |
| 3836 | fn zirAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 3836 | fn zirAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| ... | @@ -3895,7 +3895,7 @@ fn zirAllocInferred( | ... | @@ -3895,7 +3895,7 @@ fn zirAllocInferred( |
| 3895 | .is_const = is_const, | 3895 | .is_const = is_const, |
| 3896 | } }, | 3896 | } }, |
| 3897 | }); | 3897 | }); |
| 3898 | return Air.indexToRef(@as(u32, @intCast(sema.air_instructions.len - 1))); | 3898 | return Air.indexToRef(@intCast(sema.air_instructions.len - 1)); |
| 3899 | } | 3899 | } |
| 3900 | | 3900 | |
| 3901 | const result_index = try block.addInstAsIndex(.{ | 3901 | const result_index = try block.addInstAsIndex(.{ |
| ... | @@ -4147,7 +4147,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com | ... | @@ -4147,7 +4147,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com |
| 4147 | .data = .{ .ty_pl = .{ | 4147 | .data = .{ .ty_pl = .{ |
| 4148 | .ty = ty_inst, | 4148 | .ty = ty_inst, |
| 4149 | .payload = sema.addExtraAssumeCapacity(Air.Block{ | 4149 | .payload = sema.addExtraAssumeCapacity(Air.Block{ |
| 4150 | .body_len = @as(u32, @intCast(replacement_block.instructions.items.len)), | 4150 | .body_len = @intCast(replacement_block.instructions.items.len), |
| 4151 | }), | 4151 | }), |
| 4152 | } }, | 4152 | } }, |
| 4153 | }); | 4153 | }); |
| ... | @@ -4231,7 +4231,7 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -4231,7 +4231,7 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 4231 | | 4231 | |
| 4232 | // First pass to look for comptime values. | 4232 | // First pass to look for comptime values. |
| 4233 | for (args, 0..) |zir_arg, i_usize| { | 4233 | for (args, 0..) |zir_arg, i_usize| { |
| 4234 | const i = @as(u32, @intCast(i_usize)); | 4234 | const i: u32 = @intCast(i_usize); |
| 4235 | runtime_arg_lens[i] = .none; | 4235 | runtime_arg_lens[i] = .none; |
| 4236 | if (zir_arg == .none) continue; | 4236 | if (zir_arg == .none) continue; |
| 4237 | const object = try sema.resolveInst(zir_arg); | 4237 | const object = try sema.resolveInst(zir_arg); |
| ... | @@ -4302,7 +4302,7 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -4302,7 +4302,7 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 4302 | const msg = try sema.errMsg(block, src, "unbounded for loop", .{}); | 4302 | const msg = try sema.errMsg(block, src, "unbounded for loop", .{}); |
| 4303 | errdefer msg.destroy(gpa); | 4303 | errdefer msg.destroy(gpa); |
| 4304 | for (args, 0..) |zir_arg, i_usize| { | 4304 | for (args, 0..) |zir_arg, i_usize| { |
| 4305 | const i = @as(u32, @intCast(i_usize)); | 4305 | const i: u32 = @intCast(i_usize); |
| 4306 | if (zir_arg == .none) continue; | 4306 | if (zir_arg == .none) continue; |
| 4307 | const object = try sema.resolveInst(zir_arg); | 4307 | const object = try sema.resolveInst(zir_arg); |
| 4308 | const object_ty = sema.typeOf(object); | 4308 | const object_ty = sema.typeOf(object); |
| ... | @@ -4705,9 +4705,9 @@ fn validateStructInit( | ... | @@ -4705,9 +4705,9 @@ fn validateStructInit( |
| 4705 | | 4705 | |
| 4706 | const field_src = init_src; // TODO better source location | 4706 | const field_src = init_src; // TODO better source location |
| 4707 | const default_field_ptr = if (struct_ty.isTuple(mod)) | 4707 | const default_field_ptr = if (struct_ty.isTuple(mod)) |
| 4708 | try sema.tupleFieldPtr(block, init_src, struct_ptr, field_src, @as(u32, @intCast(i)), true) | 4708 | try sema.tupleFieldPtr(block, init_src, struct_ptr, field_src, @intCast(i), true) |
| 4709 | else | 4709 | else |
| 4710 | try sema.structFieldPtrByIndex(block, init_src, struct_ptr, @as(u32, @intCast(i)), field_src, struct_ty, true); | 4710 | try sema.structFieldPtrByIndex(block, init_src, struct_ptr, @intCast(i), field_src, struct_ty, true); |
| 4711 | const init = Air.internedToRef(default_val.toIntern()); | 4711 | const init = Air.internedToRef(default_val.toIntern()); |
| 4712 | try sema.storePtr2(block, init_src, default_field_ptr, init_src, init, field_src, .store); | 4712 | try sema.storePtr2(block, init_src, default_field_ptr, init_src, init, field_src, .store); |
| 4713 | } | 4713 | } |
| ... | @@ -4911,9 +4911,9 @@ fn validateStructInit( | ... | @@ -4911,9 +4911,9 @@ fn validateStructInit( |
| 4911 | | 4911 | |
| 4912 | const field_src = init_src; // TODO better source location | 4912 | const field_src = init_src; // TODO better source location |
| 4913 | const default_field_ptr = if (struct_ty.isTuple(mod)) | 4913 | const default_field_ptr = if (struct_ty.isTuple(mod)) |
| 4914 | try sema.tupleFieldPtr(block, init_src, struct_ptr, field_src, @as(u32, @intCast(i)), true) | 4914 | try sema.tupleFieldPtr(block, init_src, struct_ptr, field_src, @intCast(i), true) |
| 4915 | else | 4915 | else |
| 4916 | try sema.structFieldPtrByIndex(block, init_src, struct_ptr, @as(u32, @intCast(i)), field_src, struct_ty, true); | 4916 | try sema.structFieldPtrByIndex(block, init_src, struct_ptr, @intCast(i), field_src, struct_ty, true); |
| 4917 | const init = Air.internedToRef(field_values[i]); | 4917 | const init = Air.internedToRef(field_values[i]); |
| 4918 | try sema.storePtr2(block, init_src, default_field_ptr, init_src, init, field_src, .store); | 4918 | try sema.storePtr2(block, init_src, default_field_ptr, init_src, init, field_src, .store); |
| 4919 | } | 4919 | } |
| ... | @@ -5337,7 +5337,7 @@ fn storeToInferredAllocComptime( | ... | @@ -5337,7 +5337,7 @@ fn storeToInferredAllocComptime( |
| 5337 | fn zirSetEvalBranchQuota(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { | 5337 | fn zirSetEvalBranchQuota(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 5338 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5338 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5339 | const src = inst_data.src(); | 5339 | const src = inst_data.src(); |
| 5340 | const quota = @as(u32, @intCast(try sema.resolveInt(block, src, inst_data.operand, Type.u32, "eval branch quota must be comptime-known"))); | 5340 | const quota: u32 = @intCast(try sema.resolveInt(block, src, inst_data.operand, Type.u32, "eval branch quota must be comptime-known")); |
| 5341 | sema.branch_quota = @max(sema.branch_quota, quota); | 5341 | sema.branch_quota = @max(sema.branch_quota, quota); |
| 5342 | } | 5342 | } |
| 5343 | | 5343 | |
| ... | @@ -5558,7 +5558,7 @@ fn zirLoop(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -5558,7 +5558,7 @@ fn zirLoop(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError |
| 5558 | // Reserve space for a Loop instruction so that generated Break instructions can | 5558 | // Reserve space for a Loop instruction so that generated Break instructions can |
| 5559 | // point to it, even if it doesn't end up getting used because the code ends up being | 5559 | // point to it, even if it doesn't end up getting used because the code ends up being |
| 5560 | // comptime evaluated. | 5560 | // comptime evaluated. |
| 5561 | const block_inst = @as(Air.Inst.Index, @intCast(sema.air_instructions.len)); | 5561 | const block_inst: Air.Inst.Index = @intCast(sema.air_instructions.len); |
| 5562 | const loop_inst = block_inst + 1; | 5562 | const loop_inst = block_inst + 1; |
| 5563 | try sema.air_instructions.ensureUnusedCapacity(gpa, 2); | 5563 | try sema.air_instructions.ensureUnusedCapacity(gpa, 2); |
| 5564 | sema.air_instructions.appendAssumeCapacity(.{ | 5564 | sema.air_instructions.appendAssumeCapacity(.{ |
| ... | @@ -5606,7 +5606,7 @@ fn zirLoop(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -5606,7 +5606,7 @@ fn zirLoop(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError |
| 5606 | | 5606 | |
| 5607 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).Struct.fields.len + loop_block_len); | 5607 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).Struct.fields.len + loop_block_len); |
| 5608 | sema.air_instructions.items(.data)[loop_inst].ty_pl.payload = sema.addExtraAssumeCapacity( | 5608 | sema.air_instructions.items(.data)[loop_inst].ty_pl.payload = sema.addExtraAssumeCapacity( |
| 5609 | Air.Block{ .body_len = @as(u32, @intCast(loop_block_len)) }, | 5609 | Air.Block{ .body_len = @intCast(loop_block_len) }, |
| 5610 | ); | 5610 | ); |
| 5611 | sema.air_extra.appendSliceAssumeCapacity(loop_block.instructions.items); | 5611 | sema.air_extra.appendSliceAssumeCapacity(loop_block.instructions.items); |
| 5612 | } | 5612 | } |
| ... | @@ -5756,7 +5756,7 @@ fn zirBlock(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index, force_compt | ... | @@ -5756,7 +5756,7 @@ fn zirBlock(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index, force_compt |
| 5756 | // Reserve space for a Block instruction so that generated Break instructions can | 5756 | // Reserve space for a Block instruction so that generated Break instructions can |
| 5757 | // point to it, even if it doesn't end up getting used because the code ends up being | 5757 | // point to it, even if it doesn't end up getting used because the code ends up being |
| 5758 | // comptime evaluated or is an unlabeled block. | 5758 | // comptime evaluated or is an unlabeled block. |
| 5759 | const block_inst = @as(Air.Inst.Index, @intCast(sema.air_instructions.len)); | 5759 | const block_inst: Air.Inst.Index = @intCast(sema.air_instructions.len); |
| 5760 | try sema.air_instructions.append(gpa, .{ | 5760 | try sema.air_instructions.append(gpa, .{ |
| 5761 | .tag = .block, | 5761 | .tag = .block, |
| 5762 | .data = undefined, | 5762 | .data = undefined, |
| ... | @@ -5902,7 +5902,7 @@ fn analyzeBlockBody( | ... | @@ -5902,7 +5902,7 @@ fn analyzeBlockBody( |
| 5902 | sema.air_instructions.items(.data)[merges.block_inst] = .{ .ty_pl = .{ | 5902 | sema.air_instructions.items(.data)[merges.block_inst] = .{ .ty_pl = .{ |
| 5903 | .ty = ty_inst, | 5903 | .ty = ty_inst, |
| 5904 | .payload = sema.addExtraAssumeCapacity(Air.Block{ | 5904 | .payload = sema.addExtraAssumeCapacity(Air.Block{ |
| 5905 | .body_len = @as(u32, @intCast(child_block.instructions.items.len)), | 5905 | .body_len = @intCast(child_block.instructions.items.len), |
| 5906 | }), | 5906 | }), |
| 5907 | } }; | 5907 | } }; |
| 5908 | sema.air_extra.appendSliceAssumeCapacity(child_block.instructions.items); | 5908 | sema.air_extra.appendSliceAssumeCapacity(child_block.instructions.items); |
| ... | @@ -5929,11 +5929,11 @@ fn analyzeBlockBody( | ... | @@ -5929,11 +5929,11 @@ fn analyzeBlockBody( |
| 5929 | | 5929 | |
| 5930 | // Convert the br instruction to a block instruction that has the coercion | 5930 | // Convert the br instruction to a block instruction that has the coercion |
| 5931 | // and then a new br inside that returns the coerced instruction. | 5931 | // and then a new br inside that returns the coerced instruction. |
| 5932 | const sub_block_len = @as(u32, @intCast(coerce_block.instructions.items.len + 1)); | 5932 | const sub_block_len: u32 = @intCast(coerce_block.instructions.items.len + 1); |
| 5933 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).Struct.fields.len + | 5933 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).Struct.fields.len + |
| 5934 | sub_block_len); | 5934 | sub_block_len); |
| 5935 | try sema.air_instructions.ensureUnusedCapacity(gpa, 1); | 5935 | try sema.air_instructions.ensureUnusedCapacity(gpa, 1); |
| 5936 | const sub_br_inst = @as(Air.Inst.Index, @intCast(sema.air_instructions.len)); | 5936 | const sub_br_inst: Air.Inst.Index = @intCast(sema.air_instructions.len); |
| 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 = .{ |
| ... | @@ -6291,7 +6291,7 @@ fn addDbgVar( | ... | @@ -6291,7 +6291,7 @@ fn addDbgVar( |
| 6291 | try sema.queueFullTypeResolution(operand_ty); | 6291 | try sema.queueFullTypeResolution(operand_ty); |
| 6292 | | 6292 | |
| 6293 | // Add the name to the AIR. | 6293 | // Add the name to the AIR. |
| 6294 | const name_extra_index = @as(u32, @intCast(sema.air_extra.items.len)); | 6294 | const name_extra_index: u32 = @intCast(sema.air_extra.items.len); |
| 6295 | const elements_used = name.len / 4 + 1; | 6295 | const elements_used = name.len / 4 + 1; |
| 6296 | try sema.air_extra.ensureUnusedCapacity(sema.gpa, elements_used); | 6296 | try sema.air_extra.ensureUnusedCapacity(sema.gpa, elements_used); |
| 6297 | const buffer = mem.sliceAsBytes(sema.air_extra.unusedCapacitySlice()); | 6297 | const buffer = mem.sliceAsBytes(sema.air_extra.unusedCapacitySlice()); |
| ... | @@ -6491,7 +6491,7 @@ pub fn analyzeSaveErrRetIndex(sema: *Sema, block: *Block) SemaError!Air.Inst.Ref | ... | @@ -6491,7 +6491,7 @@ pub fn analyzeSaveErrRetIndex(sema: *Sema, block: *Block) SemaError!Air.Inst.Ref |
| 6491 | .tag = .save_err_return_trace_index, | 6491 | .tag = .save_err_return_trace_index, |
| 6492 | .data = .{ .ty_pl = .{ | 6492 | .data = .{ .ty_pl = .{ |
| 6493 | .ty = Air.internedToRef(stack_trace_ty.toIntern()), | 6493 | .ty = Air.internedToRef(stack_trace_ty.toIntern()), |
| 6494 | .payload = @as(u32, @intCast(field_index)), | 6494 | .payload = @intCast(field_index), |
| 6495 | } }, | 6495 | } }, |
| 6496 | }); | 6496 | }); |
| 6497 | } | 6497 | } |
| ... | @@ -6563,12 +6563,12 @@ fn popErrorReturnTrace( | ... | @@ -6563,12 +6563,12 @@ fn popErrorReturnTrace( |
| 6563 | then_block.instructions.items.len + else_block.instructions.items.len + | 6563 | then_block.instructions.items.len + else_block.instructions.items.len + |
| 6564 | @typeInfo(Air.Block).Struct.fields.len + 1); // +1 for the sole .cond_br instruction in the .block | 6564 | @typeInfo(Air.Block).Struct.fields.len + 1); // +1 for the sole .cond_br instruction in the .block |
| 6565 | | 6565 | |
| 6566 | const cond_br_inst = @as(Air.Inst.Index, @intCast(sema.air_instructions.len)); | 6566 | const cond_br_inst: Air.Inst.Index = @intCast(sema.air_instructions.len); |
| 6567 | try sema.air_instructions.append(gpa, .{ .tag = .cond_br, .data = .{ .pl_op = .{ | 6567 | try sema.air_instructions.append(gpa, .{ .tag = .cond_br, .data = .{ .pl_op = .{ |
| 6568 | .operand = is_non_error_inst, | 6568 | .operand = is_non_error_inst, |
| 6569 | .payload = sema.addExtraAssumeCapacity(Air.CondBr{ | 6569 | .payload = sema.addExtraAssumeCapacity(Air.CondBr{ |
| 6570 | .then_body_len = @as(u32, @intCast(then_block.instructions.items.len)), | 6570 | .then_body_len = @intCast(then_block.instructions.items.len), |
| 6571 | .else_body_len = @as(u32, @intCast(else_block.instructions.items.len)), | 6571 | .else_body_len = @intCast(else_block.instructions.items.len), |
| 6572 | }), | 6572 | }), |
| 6573 | } } }); | 6573 | } } }); |
| 6574 | sema.air_extra.appendSliceAssumeCapacity(then_block.instructions.items); | 6574 | sema.air_extra.appendSliceAssumeCapacity(then_block.instructions.items); |
| ... | @@ -6599,7 +6599,7 @@ fn zirCall( | ... | @@ -6599,7 +6599,7 @@ fn zirCall( |
| 6599 | const extra = sema.code.extraData(ExtraType, inst_data.payload_index); | 6599 | const extra = sema.code.extraData(ExtraType, inst_data.payload_index); |
| 6600 | const args_len = extra.data.flags.args_len; | 6600 | const args_len = extra.data.flags.args_len; |
| 6601 | | 6601 | |
| 6602 | const modifier = @as(std.builtin.CallModifier, @enumFromInt(extra.data.flags.packed_modifier)); | 6602 | const modifier: std.builtin.CallModifier = @enumFromInt(extra.data.flags.packed_modifier); |
| 6603 | const ensure_result_used = extra.data.flags.ensure_result_used; | 6603 | const ensure_result_used = extra.data.flags.ensure_result_used; |
| 6604 | const pop_error_return_trace = extra.data.flags.pop_error_return_trace; | 6604 | const pop_error_return_trace = extra.data.flags.pop_error_return_trace; |
| 6605 | | 6605 | |
| ... | @@ -6678,7 +6678,7 @@ fn zirCall( | ... | @@ -6678,7 +6678,7 @@ fn zirCall( |
| 6678 | .tag = .save_err_return_trace_index, | 6678 | .tag = .save_err_return_trace_index, |
| 6679 | .data = .{ .ty_pl = .{ | 6679 | .data = .{ .ty_pl = .{ |
| 6680 | .ty = Air.internedToRef(stack_trace_ty.toIntern()), | 6680 | .ty = Air.internedToRef(stack_trace_ty.toIntern()), |
| 6681 | .payload = @as(u32, @intCast(field_index)), | 6681 | .payload = @intCast(field_index), |
| 6682 | } }, | 6682 | } }, |
| 6683 | }); | 6683 | }); |
| 6684 | | 6684 | |
| ... | @@ -7225,7 +7225,7 @@ fn analyzeCall( | ... | @@ -7225,7 +7225,7 @@ fn analyzeCall( |
| 7225 | // set to in the `Block`. | 7225 | // set to in the `Block`. |
| 7226 | // This block instruction will be used to capture the return value from the | 7226 | // This block instruction will be used to capture the return value from the |
| 7227 | // inlined function. | 7227 | // inlined function. |
| 7228 | const block_inst = @as(Air.Inst.Index, @intCast(sema.air_instructions.len)); | 7228 | const block_inst: Air.Inst.Index = @intCast(sema.air_instructions.len); |
| 7229 | try sema.air_instructions.append(gpa, .{ | 7229 | try sema.air_instructions.append(gpa, .{ |
| 7230 | .tag = .block, | 7230 | .tag = .block, |
| 7231 | .data = undefined, | 7231 | .data = undefined, |
| ... | @@ -7523,7 +7523,7 @@ fn analyzeCall( | ... | @@ -7523,7 +7523,7 @@ fn analyzeCall( |
| 7523 | .data = .{ .pl_op = .{ | 7523 | .data = .{ .pl_op = .{ |
| 7524 | .operand = func, | 7524 | .operand = func, |
| 7525 | .payload = sema.addExtraAssumeCapacity(Air.Call{ | 7525 | .payload = sema.addExtraAssumeCapacity(Air.Call{ |
| 7526 | .args_len = @as(u32, @intCast(args.len)), | 7526 | .args_len = @intCast(args.len), |
| 7527 | }), | 7527 | }), |
| 7528 | } }, | 7528 | } }, |
| 7529 | }); | 7529 | }); |
| ... | @@ -8146,7 +8146,7 @@ fn zirVectorType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -8146,7 +8146,7 @@ fn zirVectorType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 8146 | const elem_type_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 8146 | const elem_type_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 8147 | const len_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; | 8147 | const len_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 8148 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 8148 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 8149 | const len = @as(u32, @intCast(try sema.resolveInt(block, len_src, extra.lhs, Type.u32, "vector length must be comptime-known"))); | 8149 | const len: u32 = @intCast(try sema.resolveInt(block, len_src, extra.lhs, Type.u32, "vector length must be comptime-known")); |
| 8150 | const elem_type = try sema.resolveType(block, elem_type_src, extra.rhs); | 8150 | const elem_type = try sema.resolveType(block, elem_type_src, extra.rhs); |
| 8151 | try sema.checkVectorElemType(block, elem_type_src, elem_type); | 8151 | try sema.checkVectorElemType(block, elem_type_src, elem_type); |
| 8152 | const vector_type = try mod.vectorType(.{ | 8152 | const vector_type = try mod.vectorType(.{ |
| ... | @@ -8891,7 +8891,7 @@ fn zirFunc( | ... | @@ -8891,7 +8891,7 @@ fn zirFunc( |
| 8891 | const ret_ty: Type = switch (extra.data.ret_body_len) { | 8891 | const ret_ty: Type = switch (extra.data.ret_body_len) { |
| 8892 | 0 => Type.void, | 8892 | 0 => Type.void, |
| 8893 | 1 => blk: { | 8893 | 1 => blk: { |
| 8894 | const ret_ty_ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index])); | 8894 | const ret_ty_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]); |
| 8895 | extra_index += 1; | 8895 | extra_index += 1; |
| 8896 | if (sema.resolveType(block, ret_ty_src, ret_ty_ref)) |ret_ty| { | 8896 | if (sema.resolveType(block, ret_ty_src, ret_ty_ref)) |ret_ty| { |
| 8897 | break :blk ret_ty; | 8897 | break :blk ret_ty; |
| ... | @@ -9538,37 +9538,37 @@ fn finishFunc( | ... | @@ -9538,37 +9538,37 @@ fn finishFunc( |
| 9538 | } | 9538 | } |
| 9539 | | 9539 | |
| 9540 | const arch = target.cpu.arch; | 9540 | const arch = target.cpu.arch; |
| 9541 | if (switch (cc_resolved) { | 9541 | if (@as(?[]const u8, switch (cc_resolved) { |
| 9542 | .Unspecified, .C, .Naked, .Async, .Inline => null, | 9542 | .Unspecified, .C, .Naked, .Async, .Inline => null, |
| 9543 | .Interrupt => switch (arch) { | 9543 | .Interrupt => switch (arch) { |
| 9544 | .x86, .x86_64, .avr, .msp430 => null, | 9544 | .x86, .x86_64, .avr, .msp430 => null, |
| 9545 | else => @as([]const u8, "x86, x86_64, AVR, and MSP430"), | 9545 | else => "x86, x86_64, AVR, and MSP430", |
| 9546 | }, | 9546 | }, |
| 9547 | .Signal => switch (arch) { | 9547 | .Signal => switch (arch) { |
| 9548 | .avr => null, | 9548 | .avr => null, |
| 9549 | else => @as([]const u8, "AVR"), | 9549 | else => "AVR", |
| 9550 | }, | 9550 | }, |
| 9551 | .Stdcall, .Fastcall, .Thiscall => switch (arch) { | 9551 | .Stdcall, .Fastcall, .Thiscall => switch (arch) { |
| 9552 | .x86 => null, | 9552 | .x86 => null, |
| 9553 | else => @as([]const u8, "x86"), | 9553 | else => "x86", |
| 9554 | }, | 9554 | }, |
| 9555 | .Vectorcall => switch (arch) { | 9555 | .Vectorcall => switch (arch) { |
| 9556 | .x86, .aarch64, .aarch64_be, .aarch64_32 => null, | 9556 | .x86, .aarch64, .aarch64_be, .aarch64_32 => null, |
| 9557 | else => @as([]const u8, "x86 and AArch64"), | 9557 | else => "x86 and AArch64", |
| 9558 | }, | 9558 | }, |
| 9559 | .APCS, .AAPCS, .AAPCSVFP => switch (arch) { | 9559 | .APCS, .AAPCS, .AAPCSVFP => switch (arch) { |
| 9560 | .arm, .armeb, .aarch64, .aarch64_be, .aarch64_32, .thumb, .thumbeb => null, | 9560 | .arm, .armeb, .aarch64, .aarch64_be, .aarch64_32, .thumb, .thumbeb => null, |
| 9561 | else => @as([]const u8, "ARM"), | 9561 | else => "ARM", |
| 9562 | }, | 9562 | }, |
| 9563 | .SysV, .Win64 => switch (arch) { | 9563 | .SysV, .Win64 => switch (arch) { |
| 9564 | .x86_64 => null, | 9564 | .x86_64 => null, |
| 9565 | else => @as([]const u8, "x86_64"), | 9565 | else => "x86_64", |
| 9566 | }, | 9566 | }, |
| 9567 | .Kernel => switch (arch) { | 9567 | .Kernel => switch (arch) { |
| 9568 | .nvptx, .nvptx64, .amdgcn, .spirv32, .spirv64 => null, | 9568 | .nvptx, .nvptx64, .amdgcn, .spirv32, .spirv64 => null, |
| 9569 | else => @as([]const u8, "nvptx, amdgcn and SPIR-V"), | 9569 | else => "nvptx, amdgcn and SPIR-V", |
| 9570 | }, | 9570 | }, |
| 9571 | }) |allowed_platform| { | 9571 | })) |allowed_platform| { |
| 9572 | return sema.fail(block, cc_src, "callconv '{s}' is only available on {s}, not {s}", .{ | 9572 | return sema.fail(block, cc_src, "callconv '{s}' is only available on {s}, not {s}", .{ |
| 9573 | @tagName(cc_resolved), | 9573 | @tagName(cc_resolved), |
| 9574 | allowed_platform, | 9574 | allowed_platform, |
| ... | @@ -10684,7 +10684,7 @@ const SwitchProngAnalysis = struct { | ... | @@ -10684,7 +10684,7 @@ const SwitchProngAnalysis = struct { |
| 10684 | const multi_idx = raw_capture_src.multi_capture; | 10684 | const multi_idx = raw_capture_src.multi_capture; |
| 10685 | const src_decl_ptr = sema.mod.declPtr(block.src_decl); | 10685 | const src_decl_ptr = sema.mod.declPtr(block.src_decl); |
| 10686 | for (case_srcs, 0..) |*case_src, i| { | 10686 | for (case_srcs, 0..) |*case_src, i| { |
| 10687 | const raw_case_src: Module.SwitchProngSrc = .{ .multi = .{ .prong = multi_idx, .item = @as(u32, @intCast(i)) } }; | 10687 | const raw_case_src: Module.SwitchProngSrc = .{ .multi = .{ .prong = multi_idx, .item = @intCast(i) } }; |
| 10688 | case_src.* = raw_case_src.resolve(mod, src_decl_ptr, switch_node_offset, .none); | 10688 | case_src.* = raw_case_src.resolve(mod, src_decl_ptr, switch_node_offset, .none); |
| 10689 | } | 10689 | } |
| 10690 | const capture_src = raw_capture_src.resolve(mod, src_decl_ptr, switch_node_offset, .none); | 10690 | const capture_src = raw_capture_src.resolve(mod, src_decl_ptr, switch_node_offset, .none); |
| ... | @@ -10732,7 +10732,7 @@ const SwitchProngAnalysis = struct { | ... | @@ -10732,7 +10732,7 @@ const SwitchProngAnalysis = struct { |
| 10732 | const multi_idx = raw_capture_src.multi_capture; | 10732 | const multi_idx = raw_capture_src.multi_capture; |
| 10733 | const src_decl_ptr = sema.mod.declPtr(block.src_decl); | 10733 | const src_decl_ptr = sema.mod.declPtr(block.src_decl); |
| 10734 | const capture_src = raw_capture_src.resolve(mod, src_decl_ptr, switch_node_offset, .none); | 10734 | const capture_src = raw_capture_src.resolve(mod, src_decl_ptr, switch_node_offset, .none); |
| 10735 | const raw_case_src: Module.SwitchProngSrc = .{ .multi = .{ .prong = multi_idx, .item = @as(u32, @intCast(i)) } }; | 10735 | const raw_case_src: Module.SwitchProngSrc = .{ .multi = .{ .prong = multi_idx, .item = @intCast(i) } }; |
| 10736 | const case_src = raw_case_src.resolve(mod, src_decl_ptr, switch_node_offset, .none); | 10736 | const case_src = raw_case_src.resolve(mod, src_decl_ptr, switch_node_offset, .none); |
| 10737 | const msg = msg: { | 10737 | const msg = msg: { |
| 10738 | const msg = try sema.errMsg(block, capture_src, "capture group with incompatible types", .{}); | 10738 | const msg = try sema.errMsg(block, capture_src, "capture group with incompatible types", .{}); |
| ... | @@ -10833,12 +10833,12 @@ const SwitchProngAnalysis = struct { | ... | @@ -10833,12 +10833,12 @@ const SwitchProngAnalysis = struct { |
| 10833 | var coerce_block = block.makeSubBlock(); | 10833 | var coerce_block = block.makeSubBlock(); |
| 10834 | defer coerce_block.instructions.deinit(sema.gpa); | 10834 | defer coerce_block.instructions.deinit(sema.gpa); |
| 10835 | | 10835 | |
| 10836 | const uncoerced = try coerce_block.addStructFieldVal(spa.operand, @as(u32, @intCast(idx)), field_tys[idx]); | 10836 | const uncoerced = try coerce_block.addStructFieldVal(spa.operand, @intCast(idx), field_tys[idx]); |
| 10837 | const coerced = sema.coerce(&coerce_block, capture_ty, uncoerced, .unneeded) catch |err| switch (err) { | 10837 | const coerced = sema.coerce(&coerce_block, capture_ty, uncoerced, .unneeded) catch |err| switch (err) { |
| 10838 | error.NeededSourceLocation => { | 10838 | error.NeededSourceLocation => { |
| 10839 | const multi_idx = raw_capture_src.multi_capture; | 10839 | const multi_idx = raw_capture_src.multi_capture; |
| 10840 | const src_decl_ptr = sema.mod.declPtr(block.src_decl); | 10840 | const src_decl_ptr = sema.mod.declPtr(block.src_decl); |
| 10841 | const raw_case_src: Module.SwitchProngSrc = .{ .multi = .{ .prong = multi_idx, .item = @as(u32, @intCast(idx)) } }; | 10841 | const raw_case_src: Module.SwitchProngSrc = .{ .multi = .{ .prong = multi_idx, .item = @intCast(idx) } }; |
| 10842 | const case_src = raw_case_src.resolve(mod, src_decl_ptr, switch_node_offset, .none); | 10842 | const case_src = raw_case_src.resolve(mod, src_decl_ptr, switch_node_offset, .none); |
| 10843 | _ = try sema.coerce(&coerce_block, capture_ty, uncoerced, case_src); | 10843 | _ = try sema.coerce(&coerce_block, capture_ty, uncoerced, case_src); |
| 10844 | unreachable; | 10844 | unreachable; |
| ... | @@ -10849,7 +10849,7 @@ const SwitchProngAnalysis = struct { | ... | @@ -10849,7 +10849,7 @@ const SwitchProngAnalysis = struct { |
| 10849 | | 10849 | |
| 10850 | try cases_extra.ensureUnusedCapacity(3 + coerce_block.instructions.items.len); | 10850 | try cases_extra.ensureUnusedCapacity(3 + coerce_block.instructions.items.len); |
| 10851 | cases_extra.appendAssumeCapacity(1); // items_len | 10851 | cases_extra.appendAssumeCapacity(1); // items_len |
| 10852 | cases_extra.appendAssumeCapacity(@as(u32, @intCast(coerce_block.instructions.items.len))); // body_len | 10852 | cases_extra.appendAssumeCapacity(@intCast(coerce_block.instructions.items.len)); // body_len |
| 10853 | cases_extra.appendAssumeCapacity(@intFromEnum(case_vals[idx])); // item | 10853 | cases_extra.appendAssumeCapacity(@intFromEnum(case_vals[idx])); // item |
| 10854 | cases_extra.appendSliceAssumeCapacity(coerce_block.instructions.items); // body | 10854 | cases_extra.appendSliceAssumeCapacity(coerce_block.instructions.items); // body |
| 10855 | } | 10855 | } |
| ... | @@ -10860,7 +10860,7 @@ const SwitchProngAnalysis = struct { | ... | @@ -10860,7 +10860,7 @@ const SwitchProngAnalysis = struct { |
| 10860 | defer coerce_block.instructions.deinit(sema.gpa); | 10860 | defer coerce_block.instructions.deinit(sema.gpa); |
| 10861 | | 10861 | |
| 10862 | const first_imc = in_mem_coercible.findFirstSet().?; | 10862 | const first_imc = in_mem_coercible.findFirstSet().?; |
| 10863 | const uncoerced = try coerce_block.addStructFieldVal(spa.operand, @as(u32, @intCast(first_imc)), field_tys[first_imc]); | 10863 | const uncoerced = try coerce_block.addStructFieldVal(spa.operand, @intCast(first_imc), field_tys[first_imc]); |
| 10864 | const coerced = try coerce_block.addBitCast(capture_ty, uncoerced); | 10864 | const coerced = try coerce_block.addBitCast(capture_ty, uncoerced); |
| 10865 | _ = try coerce_block.addBr(capture_block_inst, coerced); | 10865 | _ = try coerce_block.addBr(capture_block_inst, coerced); |
| 10866 | | 10866 | |
| ... | @@ -10873,14 +10873,14 @@ const SwitchProngAnalysis = struct { | ... | @@ -10873,14 +10873,14 @@ const SwitchProngAnalysis = struct { |
| 10873 | @typeInfo(Air.Block).Struct.fields.len + | 10873 | @typeInfo(Air.Block).Struct.fields.len + |
| 10874 | 1); | 10874 | 1); |
| 10875 | | 10875 | |
| 10876 | const switch_br_inst = @as(u32, @intCast(sema.air_instructions.len)); | 10876 | const switch_br_inst: u32 = @intCast(sema.air_instructions.len); |
| 10877 | try sema.air_instructions.append(sema.gpa, .{ | 10877 | try sema.air_instructions.append(sema.gpa, .{ |
| 10878 | .tag = .switch_br, | 10878 | .tag = .switch_br, |
| 10879 | .data = .{ .pl_op = .{ | 10879 | .data = .{ .pl_op = .{ |
| 10880 | .operand = spa.cond, | 10880 | .operand = spa.cond, |
| 10881 | .payload = sema.addExtraAssumeCapacity(Air.SwitchBr{ | 10881 | .payload = sema.addExtraAssumeCapacity(Air.SwitchBr{ |
| 10882 | .cases_len = @as(u32, @intCast(prong_count)), | 10882 | .cases_len = @intCast(prong_count), |
| 10883 | .else_body_len = @as(u32, @intCast(else_body_len)), | 10883 | .else_body_len = @intCast(else_body_len), |
| 10884 | }), | 10884 | }), |
| 10885 | } }, | 10885 | } }, |
| 10886 | }); | 10886 | }); |
| ... | @@ -11067,7 +11067,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11067,7 +11067,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11067 | .has_tag_capture = false, | 11067 | .has_tag_capture = false, |
| 11068 | }, | 11068 | }, |
| 11069 | .under, .@"else" => blk: { | 11069 | .under, .@"else" => blk: { |
| 11070 | const info = @as(Zir.Inst.SwitchBlock.ProngInfo, @bitCast(sema.code.extra[header_extra_index])); | 11070 | const info: Zir.Inst.SwitchBlock.ProngInfo = @bitCast(sema.code.extra[header_extra_index]); |
| 11071 | const extra_body_start = header_extra_index + 1; | 11071 | const extra_body_start = header_extra_index + 1; |
| 11072 | break :blk .{ | 11072 | break :blk .{ |
| 11073 | .body = sema.code.extra[extra_body_start..][0..info.body_len], | 11073 | .body = sema.code.extra[extra_body_start..][0..info.body_len], |
| ... | @@ -11144,9 +11144,9 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11144,9 +11144,9 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11144 | { | 11144 | { |
| 11145 | var scalar_i: u32 = 0; | 11145 | var scalar_i: u32 = 0; |
| 11146 | while (scalar_i < scalar_cases_len) : (scalar_i += 1) { | 11146 | while (scalar_i < scalar_cases_len) : (scalar_i += 1) { |
| 11147 | const item_ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index])); | 11147 | const item_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]); |
| 11148 | extra_index += 1; | 11148 | extra_index += 1; |
| 11149 | const info = @as(Zir.Inst.SwitchBlock.ProngInfo, @bitCast(sema.code.extra[extra_index])); | 11149 | const info: Zir.Inst.SwitchBlock.ProngInfo = @bitCast(sema.code.extra[extra_index]); |
| 11150 | extra_index += 1 + info.body_len; | 11150 | extra_index += 1 + info.body_len; |
| 11151 | | 11151 | |
| 11152 | case_vals.appendAssumeCapacity(try sema.validateSwitchItemEnum( | 11152 | case_vals.appendAssumeCapacity(try sema.validateSwitchItemEnum( |
| ... | @@ -11167,7 +11167,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11167,7 +11167,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11167 | extra_index += 1; | 11167 | extra_index += 1; |
| 11168 | const ranges_len = sema.code.extra[extra_index]; | 11168 | const ranges_len = sema.code.extra[extra_index]; |
| 11169 | extra_index += 1; | 11169 | extra_index += 1; |
| 11170 | const info = @as(Zir.Inst.SwitchBlock.ProngInfo, @bitCast(sema.code.extra[extra_index])); | 11170 | const info: Zir.Inst.SwitchBlock.ProngInfo = @bitCast(sema.code.extra[extra_index]); |
| 11171 | extra_index += 1; | 11171 | extra_index += 1; |
| 11172 | const items = sema.code.refSlice(extra_index, items_len); | 11172 | const items = sema.code.refSlice(extra_index, items_len); |
| 11173 | extra_index += items_len + info.body_len; | 11173 | extra_index += items_len + info.body_len; |
| ... | @@ -11181,7 +11181,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11181,7 +11181,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11181 | item_ref, | 11181 | item_ref, |
| 11182 | operand_ty, | 11182 | operand_ty, |
| 11183 | src_node_offset, | 11183 | src_node_offset, |
| 11184 | .{ .multi = .{ .prong = multi_i, .item = @as(u32, @intCast(item_i)) } }, | 11184 | .{ .multi = .{ .prong = multi_i, .item = @intCast(item_i) } }, |
| 11185 | )); | 11185 | )); |
| 11186 | } | 11186 | } |
| 11187 | | 11187 | |
| ... | @@ -11243,9 +11243,9 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11243,9 +11243,9 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11243 | { | 11243 | { |
| 11244 | var scalar_i: u32 = 0; | 11244 | var scalar_i: u32 = 0; |
| 11245 | while (scalar_i < scalar_cases_len) : (scalar_i += 1) { | 11245 | while (scalar_i < scalar_cases_len) : (scalar_i += 1) { |
| 11246 | const item_ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index])); | 11246 | const item_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]); |
| 11247 | extra_index += 1; | 11247 | extra_index += 1; |
| 11248 | const info = @as(Zir.Inst.SwitchBlock.ProngInfo, @bitCast(sema.code.extra[extra_index])); | 11248 | const info: Zir.Inst.SwitchBlock.ProngInfo = @bitCast(sema.code.extra[extra_index]); |
| 11249 | extra_index += 1 + info.body_len; | 11249 | extra_index += 1 + info.body_len; |
| 11250 | | 11250 | |
| 11251 | case_vals.appendAssumeCapacity(try sema.validateSwitchItemError( | 11251 | case_vals.appendAssumeCapacity(try sema.validateSwitchItemError( |
| ... | @@ -11265,7 +11265,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11265,7 +11265,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11265 | extra_index += 1; | 11265 | extra_index += 1; |
| 11266 | const ranges_len = sema.code.extra[extra_index]; | 11266 | const ranges_len = sema.code.extra[extra_index]; |
| 11267 | extra_index += 1; | 11267 | extra_index += 1; |
| 11268 | const info = @as(Zir.Inst.SwitchBlock.ProngInfo, @bitCast(sema.code.extra[extra_index])); | 11268 | const info: Zir.Inst.SwitchBlock.ProngInfo = @bitCast(sema.code.extra[extra_index]); |
| 11269 | extra_index += 1; | 11269 | extra_index += 1; |
| 11270 | const items = sema.code.refSlice(extra_index, items_len); | 11270 | const items = sema.code.refSlice(extra_index, items_len); |
| 11271 | extra_index += items_len + info.body_len; | 11271 | extra_index += items_len + info.body_len; |
| ... | @@ -11278,7 +11278,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11278,7 +11278,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11278 | item_ref, | 11278 | item_ref, |
| 11279 | operand_ty, | 11279 | operand_ty, |
| 11280 | src_node_offset, | 11280 | src_node_offset, |
| 11281 | .{ .multi = .{ .prong = multi_i, .item = @as(u32, @intCast(item_i)) } }, | 11281 | .{ .multi = .{ .prong = multi_i, .item = @intCast(item_i) } }, |
| 11282 | )); | 11282 | )); |
| 11283 | } | 11283 | } |
| 11284 | | 11284 | |
| ... | @@ -11387,9 +11387,9 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11387,9 +11387,9 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11387 | { | 11387 | { |
| 11388 | var scalar_i: u32 = 0; | 11388 | var scalar_i: u32 = 0; |
| 11389 | while (scalar_i < scalar_cases_len) : (scalar_i += 1) { | 11389 | while (scalar_i < scalar_cases_len) : (scalar_i += 1) { |
| 11390 | const item_ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index])); | 11390 | const item_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]); |
| 11391 | extra_index += 1; | 11391 | extra_index += 1; |
| 11392 | const info = @as(Zir.Inst.SwitchBlock.ProngInfo, @bitCast(sema.code.extra[extra_index])); | 11392 | const info: Zir.Inst.SwitchBlock.ProngInfo = @bitCast(sema.code.extra[extra_index]); |
| 11393 | extra_index += 1 + info.body_len; | 11393 | extra_index += 1 + info.body_len; |
| 11394 | | 11394 | |
| 11395 | case_vals.appendAssumeCapacity(try sema.validateSwitchItemInt( | 11395 | case_vals.appendAssumeCapacity(try sema.validateSwitchItemInt( |
| ... | @@ -11409,7 +11409,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11409,7 +11409,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11409 | extra_index += 1; | 11409 | extra_index += 1; |
| 11410 | const ranges_len = sema.code.extra[extra_index]; | 11410 | const ranges_len = sema.code.extra[extra_index]; |
| 11411 | extra_index += 1; | 11411 | extra_index += 1; |
| 11412 | const info = @as(Zir.Inst.SwitchBlock.ProngInfo, @bitCast(sema.code.extra[extra_index])); | 11412 | const info: Zir.Inst.SwitchBlock.ProngInfo = @bitCast(sema.code.extra[extra_index]); |
| 11413 | extra_index += 1; | 11413 | extra_index += 1; |
| 11414 | const items = sema.code.refSlice(extra_index, items_len); | 11414 | const items = sema.code.refSlice(extra_index, items_len); |
| 11415 | extra_index += items_len; | 11415 | extra_index += items_len; |
| ... | @@ -11422,16 +11422,16 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11422,16 +11422,16 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11422 | item_ref, | 11422 | item_ref, |
| 11423 | operand_ty, | 11423 | operand_ty, |
| 11424 | src_node_offset, | 11424 | src_node_offset, |
| 11425 | .{ .multi = .{ .prong = multi_i, .item = @as(u32, @intCast(item_i)) } }, | 11425 | .{ .multi = .{ .prong = multi_i, .item = @intCast(item_i) } }, |
| 11426 | )); | 11426 | )); |
| 11427 | } | 11427 | } |
| 11428 | | 11428 | |
| 11429 | try case_vals.ensureUnusedCapacity(gpa, 2 * ranges_len); | 11429 | try case_vals.ensureUnusedCapacity(gpa, 2 * ranges_len); |
| 11430 | var range_i: u32 = 0; | 11430 | var range_i: u32 = 0; |
| 11431 | while (range_i < ranges_len) : (range_i += 1) { | 11431 | while (range_i < ranges_len) : (range_i += 1) { |
| 11432 | const item_first = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index])); | 11432 | const item_first: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]); |
| 11433 | extra_index += 1; | 11433 | extra_index += 1; |
| 11434 | const item_last = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index])); | 11434 | const item_last: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]); |
| 11435 | extra_index += 1; | 11435 | extra_index += 1; |
| 11436 | | 11436 | |
| 11437 | const vals = try sema.validateSwitchRange( | 11437 | const vals = try sema.validateSwitchRange( |
| ... | @@ -11482,9 +11482,9 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11482,9 +11482,9 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11482 | { | 11482 | { |
| 11483 | var scalar_i: u32 = 0; | 11483 | var scalar_i: u32 = 0; |
| 11484 | while (scalar_i < scalar_cases_len) : (scalar_i += 1) { | 11484 | while (scalar_i < scalar_cases_len) : (scalar_i += 1) { |
| 11485 | const item_ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index])); | 11485 | const item_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]); |
| 11486 | extra_index += 1; | 11486 | extra_index += 1; |
| 11487 | const info = @as(Zir.Inst.SwitchBlock.ProngInfo, @bitCast(sema.code.extra[extra_index])); | 11487 | const info: Zir.Inst.SwitchBlock.ProngInfo = @bitCast(sema.code.extra[extra_index]); |
| 11488 | extra_index += 1 + info.body_len; | 11488 | extra_index += 1 + info.body_len; |
| 11489 | | 11489 | |
| 11490 | case_vals.appendAssumeCapacity(try sema.validateSwitchItemBool( | 11490 | case_vals.appendAssumeCapacity(try sema.validateSwitchItemBool( |
| ... | @@ -11504,7 +11504,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11504,7 +11504,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11504 | extra_index += 1; | 11504 | extra_index += 1; |
| 11505 | const ranges_len = sema.code.extra[extra_index]; | 11505 | const ranges_len = sema.code.extra[extra_index]; |
| 11506 | extra_index += 1; | 11506 | extra_index += 1; |
| 11507 | const info = @as(Zir.Inst.SwitchBlock.ProngInfo, @bitCast(sema.code.extra[extra_index])); | 11507 | const info: Zir.Inst.SwitchBlock.ProngInfo = @bitCast(sema.code.extra[extra_index]); |
| 11508 | extra_index += 1; | 11508 | extra_index += 1; |
| 11509 | const items = sema.code.refSlice(extra_index, items_len); | 11509 | const items = sema.code.refSlice(extra_index, items_len); |
| 11510 | extra_index += items_len + info.body_len; | 11510 | extra_index += items_len + info.body_len; |
| ... | @@ -11517,7 +11517,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11517,7 +11517,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11517 | &false_count, | 11517 | &false_count, |
| 11518 | item_ref, | 11518 | item_ref, |
| 11519 | src_node_offset, | 11519 | src_node_offset, |
| 11520 | .{ .multi = .{ .prong = multi_i, .item = @as(u32, @intCast(item_i)) } }, | 11520 | .{ .multi = .{ .prong = multi_i, .item = @intCast(item_i) } }, |
| 11521 | )); | 11521 | )); |
| 11522 | } | 11522 | } |
| 11523 | | 11523 | |
| ... | @@ -11564,9 +11564,9 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11564,9 +11564,9 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11564 | { | 11564 | { |
| 11565 | var scalar_i: u32 = 0; | 11565 | var scalar_i: u32 = 0; |
| 11566 | while (scalar_i < scalar_cases_len) : (scalar_i += 1) { | 11566 | while (scalar_i < scalar_cases_len) : (scalar_i += 1) { |
| 11567 | const item_ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index])); | 11567 | const item_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]); |
| 11568 | extra_index += 1; | 11568 | extra_index += 1; |
| 11569 | const info = @as(Zir.Inst.SwitchBlock.ProngInfo, @bitCast(sema.code.extra[extra_index])); | 11569 | const info: Zir.Inst.SwitchBlock.ProngInfo = @bitCast(sema.code.extra[extra_index]); |
| 11570 | extra_index += 1; | 11570 | extra_index += 1; |
| 11571 | extra_index += info.body_len; | 11571 | extra_index += info.body_len; |
| 11572 | | 11572 | |
| ... | @@ -11587,7 +11587,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11587,7 +11587,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11587 | extra_index += 1; | 11587 | extra_index += 1; |
| 11588 | const ranges_len = sema.code.extra[extra_index]; | 11588 | const ranges_len = sema.code.extra[extra_index]; |
| 11589 | extra_index += 1; | 11589 | extra_index += 1; |
| 11590 | const info = @as(Zir.Inst.SwitchBlock.ProngInfo, @bitCast(sema.code.extra[extra_index])); | 11590 | const info: Zir.Inst.SwitchBlock.ProngInfo = @bitCast(sema.code.extra[extra_index]); |
| 11591 | extra_index += 1; | 11591 | extra_index += 1; |
| 11592 | const items = sema.code.refSlice(extra_index, items_len); | 11592 | const items = sema.code.refSlice(extra_index, items_len); |
| 11593 | extra_index += items_len + info.body_len; | 11593 | extra_index += items_len + info.body_len; |
| ... | @@ -11600,7 +11600,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11600,7 +11600,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11600 | item_ref, | 11600 | item_ref, |
| 11601 | operand_ty, | 11601 | operand_ty, |
| 11602 | src_node_offset, | 11602 | src_node_offset, |
| 11603 | .{ .multi = .{ .prong = multi_i, .item = @as(u32, @intCast(item_i)) } }, | 11603 | .{ .multi = .{ .prong = multi_i, .item = @intCast(item_i) } }, |
| 11604 | )); | 11604 | )); |
| 11605 | } | 11605 | } |
| 11606 | | 11606 | |
| ... | @@ -11638,7 +11638,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11638,7 +11638,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11638 | .tag_capture_inst = tag_capture_inst, | 11638 | .tag_capture_inst = tag_capture_inst, |
| 11639 | }; | 11639 | }; |
| 11640 | | 11640 | |
| 11641 | const block_inst = @as(Air.Inst.Index, @intCast(sema.air_instructions.len)); | 11641 | const block_inst: Air.Inst.Index = @intCast(sema.air_instructions.len); |
| 11642 | try sema.air_instructions.append(gpa, .{ | 11642 | try sema.air_instructions.append(gpa, .{ |
| 11643 | .tag = .block, | 11643 | .tag = .block, |
| 11644 | .data = undefined, | 11644 | .data = undefined, |
| ... | @@ -11682,7 +11682,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11682,7 +11682,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11682 | var scalar_i: usize = 0; | 11682 | var scalar_i: usize = 0; |
| 11683 | while (scalar_i < scalar_cases_len) : (scalar_i += 1) { | 11683 | while (scalar_i < scalar_cases_len) : (scalar_i += 1) { |
| 11684 | extra_index += 1; | 11684 | extra_index += 1; |
| 11685 | const info = @as(Zir.Inst.SwitchBlock.ProngInfo, @bitCast(sema.code.extra[extra_index])); | 11685 | const info: Zir.Inst.SwitchBlock.ProngInfo = @bitCast(sema.code.extra[extra_index]); |
| 11686 | extra_index += 1; | 11686 | extra_index += 1; |
| 11687 | const body = sema.code.extra[extra_index..][0..info.body_len]; | 11687 | const body = sema.code.extra[extra_index..][0..info.body_len]; |
| 11688 | extra_index += info.body_len; | 11688 | extra_index += info.body_len; |
| ... | @@ -11696,7 +11696,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11696,7 +11696,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11696 | .normal, | 11696 | .normal, |
| 11697 | body, | 11697 | body, |
| 11698 | info.capture, | 11698 | info.capture, |
| 11699 | .{ .scalar_capture = @as(u32, @intCast(scalar_i)) }, | 11699 | .{ .scalar_capture = @intCast(scalar_i) }, |
| 11700 | &.{item}, | 11700 | &.{item}, |
| 11701 | if (info.is_inline) operand else .none, | 11701 | if (info.is_inline) operand else .none, |
| 11702 | info.has_tag_capture, | 11702 | info.has_tag_capture, |
| ... | @@ -11713,7 +11713,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11713,7 +11713,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11713 | extra_index += 1; | 11713 | extra_index += 1; |
| 11714 | const ranges_len = sema.code.extra[extra_index]; | 11714 | const ranges_len = sema.code.extra[extra_index]; |
| 11715 | extra_index += 1; | 11715 | extra_index += 1; |
| 11716 | const info = @as(Zir.Inst.SwitchBlock.ProngInfo, @bitCast(sema.code.extra[extra_index])); | 11716 | const info: Zir.Inst.SwitchBlock.ProngInfo = @bitCast(sema.code.extra[extra_index]); |
| 11717 | extra_index += 1 + items_len; | 11717 | extra_index += 1 + items_len; |
| 11718 | const body = sema.code.extra[extra_index + 2 * ranges_len ..][0..info.body_len]; | 11718 | const body = sema.code.extra[extra_index + 2 * ranges_len ..][0..info.body_len]; |
| 11719 | | 11719 | |
| ... | @@ -11730,7 +11730,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11730,7 +11730,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11730 | .normal, | 11730 | .normal, |
| 11731 | body, | 11731 | body, |
| 11732 | info.capture, | 11732 | info.capture, |
| 11733 | .{ .multi_capture = @as(u32, @intCast(multi_i)) }, | 11733 | .{ .multi_capture = @intCast(multi_i) }, |
| 11734 | items, | 11734 | items, |
| 11735 | if (info.is_inline) operand else .none, | 11735 | if (info.is_inline) operand else .none, |
| 11736 | info.has_tag_capture, | 11736 | info.has_tag_capture, |
| ... | @@ -11757,7 +11757,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11757,7 +11757,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11757 | .normal, | 11757 | .normal, |
| 11758 | body, | 11758 | body, |
| 11759 | info.capture, | 11759 | info.capture, |
| 11760 | .{ .multi_capture = @as(u32, @intCast(multi_i)) }, | 11760 | .{ .multi_capture = @intCast(multi_i) }, |
| 11761 | undefined, // case_vals may be undefined for ranges | 11761 | undefined, // case_vals may be undefined for ranges |
| 11762 | if (info.is_inline) operand else .none, | 11762 | if (info.is_inline) operand else .none, |
| 11763 | info.has_tag_capture, | 11763 | info.has_tag_capture, |
| ... | @@ -11842,7 +11842,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11842,7 +11842,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11842 | var scalar_i: usize = 0; | 11842 | var scalar_i: usize = 0; |
| 11843 | while (scalar_i < scalar_cases_len) : (scalar_i += 1) { | 11843 | while (scalar_i < scalar_cases_len) : (scalar_i += 1) { |
| 11844 | extra_index += 1; | 11844 | extra_index += 1; |
| 11845 | const info = @as(Zir.Inst.SwitchBlock.ProngInfo, @bitCast(sema.code.extra[extra_index])); | 11845 | const info: Zir.Inst.SwitchBlock.ProngInfo = @bitCast(sema.code.extra[extra_index]); |
| 11846 | extra_index += 1; | 11846 | extra_index += 1; |
| 11847 | const body = sema.code.extra[extra_index..][0..info.body_len]; | 11847 | const body = sema.code.extra[extra_index..][0..info.body_len]; |
| 11848 | extra_index += info.body_len; | 11848 | extra_index += info.body_len; |
| ... | @@ -11870,7 +11870,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11870,7 +11870,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11870 | .normal, | 11870 | .normal, |
| 11871 | body, | 11871 | body, |
| 11872 | info.capture, | 11872 | info.capture, |
| 11873 | .{ .scalar_capture = @as(u32, @intCast(scalar_i)) }, | 11873 | .{ .scalar_capture = @intCast(scalar_i) }, |
| 11874 | &.{item}, | 11874 | &.{item}, |
| 11875 | if (info.is_inline) item else .none, | 11875 | if (info.is_inline) item else .none, |
| 11876 | info.has_tag_capture, | 11876 | info.has_tag_capture, |
| ... | @@ -11883,7 +11883,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11883,7 +11883,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11883 | | 11883 | |
| 11884 | try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len); | 11884 | try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len); |
| 11885 | cases_extra.appendAssumeCapacity(1); // items_len | 11885 | cases_extra.appendAssumeCapacity(1); // items_len |
| 11886 | cases_extra.appendAssumeCapacity(@as(u32, @intCast(case_block.instructions.items.len))); | 11886 | cases_extra.appendAssumeCapacity(@intCast(case_block.instructions.items.len)); |
| 11887 | cases_extra.appendAssumeCapacity(@intFromEnum(item)); | 11887 | cases_extra.appendAssumeCapacity(@intFromEnum(item)); |
| 11888 | cases_extra.appendSliceAssumeCapacity(case_block.instructions.items); | 11888 | cases_extra.appendSliceAssumeCapacity(case_block.instructions.items); |
| 11889 | } | 11889 | } |
| ... | @@ -11903,7 +11903,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11903,7 +11903,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11903 | extra_index += 1; | 11903 | extra_index += 1; |
| 11904 | const ranges_len = sema.code.extra[extra_index]; | 11904 | const ranges_len = sema.code.extra[extra_index]; |
| 11905 | extra_index += 1; | 11905 | extra_index += 1; |
| 11906 | const info = @as(Zir.Inst.SwitchBlock.ProngInfo, @bitCast(sema.code.extra[extra_index])); | 11906 | const info: Zir.Inst.SwitchBlock.ProngInfo = @bitCast(sema.code.extra[extra_index]); |
| 11907 | extra_index += 1 + items_len; | 11907 | extra_index += 1 + items_len; |
| 11908 | | 11908 | |
| 11909 | const items = case_vals.items[case_val_idx..][0..items_len]; | 11909 | const items = case_vals.items[case_val_idx..][0..items_len]; |
| ... | @@ -11946,7 +11946,9 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11946,7 +11946,9 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11946 | | 11946 | |
| 11947 | if (emit_bb) sema.emitBackwardBranch(block, .unneeded) catch |err| switch (err) { | 11947 | if (emit_bb) sema.emitBackwardBranch(block, .unneeded) catch |err| switch (err) { |
| 11948 | error.NeededSourceLocation => { | 11948 | error.NeededSourceLocation => { |
| 11949 | const case_src = Module.SwitchProngSrc{ .range = .{ .prong = multi_i, .item = range_i } }; | 11949 | const case_src = Module.SwitchProngSrc{ |
| | 11950 | .range = .{ .prong = multi_i, .item = range_i }, |
| | 11951 | }; |
| 11950 | const decl = mod.declPtr(case_block.src_decl); | 11952 | const decl = mod.declPtr(case_block.src_decl); |
| 11951 | try sema.emitBackwardBranch(block, case_src.resolve(mod, decl, src_node_offset, .none)); | 11953 | try sema.emitBackwardBranch(block, case_src.resolve(mod, decl, src_node_offset, .none)); |
| 11952 | unreachable; | 11954 | unreachable; |
| ... | @@ -11968,7 +11970,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11968,7 +11970,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11968 | | 11970 | |
| 11969 | try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len); | 11971 | try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len); |
| 11970 | cases_extra.appendAssumeCapacity(1); // items_len | 11972 | cases_extra.appendAssumeCapacity(1); // items_len |
| 11971 | cases_extra.appendAssumeCapacity(@as(u32, @intCast(case_block.instructions.items.len))); | 11973 | cases_extra.appendAssumeCapacity(@intCast(case_block.instructions.items.len)); |
| 11972 | cases_extra.appendAssumeCapacity(@intFromEnum(item_ref)); | 11974 | cases_extra.appendAssumeCapacity(@intFromEnum(item_ref)); |
| 11973 | cases_extra.appendSliceAssumeCapacity(case_block.instructions.items); | 11975 | cases_extra.appendSliceAssumeCapacity(case_block.instructions.items); |
| 11974 | | 11976 | |
| ... | @@ -11990,7 +11992,9 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11990,7 +11992,9 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11990 | | 11992 | |
| 11991 | if (emit_bb) sema.emitBackwardBranch(block, .unneeded) catch |err| switch (err) { | 11993 | if (emit_bb) sema.emitBackwardBranch(block, .unneeded) catch |err| switch (err) { |
| 11992 | error.NeededSourceLocation => { | 11994 | error.NeededSourceLocation => { |
| 11993 | const case_src = Module.SwitchProngSrc{ .multi = .{ .prong = multi_i, .item = @as(u32, @intCast(item_i)) } }; | 11995 | const case_src = Module.SwitchProngSrc{ |
| | 11996 | .multi = .{ .prong = multi_i, .item = @intCast(item_i) }, |
| | 11997 | }; |
| 11994 | const decl = mod.declPtr(case_block.src_decl); | 11998 | const decl = mod.declPtr(case_block.src_decl); |
| 11995 | try sema.emitBackwardBranch(block, case_src.resolve(mod, decl, src_node_offset, .none)); | 11999 | try sema.emitBackwardBranch(block, case_src.resolve(mod, decl, src_node_offset, .none)); |
| 11996 | unreachable; | 12000 | unreachable; |
| ... | @@ -12016,7 +12020,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -12016,7 +12020,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 12016 | | 12020 | |
| 12017 | try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len); | 12021 | try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len); |
| 12018 | cases_extra.appendAssumeCapacity(1); // items_len | 12022 | cases_extra.appendAssumeCapacity(1); // items_len |
| 12019 | cases_extra.appendAssumeCapacity(@as(u32, @intCast(case_block.instructions.items.len))); | 12023 | cases_extra.appendAssumeCapacity(@intCast(case_block.instructions.items.len)); |
| 12020 | cases_extra.appendAssumeCapacity(@intFromEnum(item)); | 12024 | cases_extra.appendAssumeCapacity(@intFromEnum(item)); |
| 12021 | cases_extra.appendSliceAssumeCapacity(case_block.instructions.items); | 12025 | cases_extra.appendSliceAssumeCapacity(case_block.instructions.items); |
| 12022 | } | 12026 | } |
| ... | @@ -12064,8 +12068,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -12064,8 +12068,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 12064 | try cases_extra.ensureUnusedCapacity(gpa, 2 + items.len + | 12068 | try cases_extra.ensureUnusedCapacity(gpa, 2 + items.len + |
| 12065 | case_block.instructions.items.len); | 12069 | case_block.instructions.items.len); |
| 12066 | | 12070 | |
| 12067 | cases_extra.appendAssumeCapacity(@as(u32, @intCast(items.len))); | 12071 | cases_extra.appendAssumeCapacity(@intCast(items.len)); |
| 12068 | cases_extra.appendAssumeCapacity(@as(u32, @intCast(case_block.instructions.items.len))); | 12072 | cases_extra.appendAssumeCapacity(@intCast(case_block.instructions.items.len)); |
| 12069 | | 12073 | |
| 12070 | for (items) |item| { | 12074 | for (items) |item| { |
| 12071 | cases_extra.appendAssumeCapacity(@intFromEnum(item)); | 12075 | cases_extra.appendAssumeCapacity(@intFromEnum(item)); |
| ... | @@ -12160,8 +12164,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -12160,8 +12164,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 12160 | | 12164 | |
| 12161 | sema.air_instructions.items(.data)[prev_cond_br].pl_op.payload = | 12165 | sema.air_instructions.items(.data)[prev_cond_br].pl_op.payload = |
| 12162 | sema.addExtraAssumeCapacity(Air.CondBr{ | 12166 | sema.addExtraAssumeCapacity(Air.CondBr{ |
| 12163 | .then_body_len = @as(u32, @intCast(prev_then_body.len)), | 12167 | .then_body_len = @intCast(prev_then_body.len), |
| 12164 | .else_body_len = @as(u32, @intCast(cond_body.len)), | 12168 | .else_body_len = @intCast(cond_body.len), |
| 12165 | }); | 12169 | }); |
| 12166 | sema.air_extra.appendSliceAssumeCapacity(prev_then_body); | 12170 | sema.air_extra.appendSliceAssumeCapacity(prev_then_body); |
| 12167 | sema.air_extra.appendSliceAssumeCapacity(cond_body); | 12171 | sema.air_extra.appendSliceAssumeCapacity(cond_body); |
| ... | @@ -12186,7 +12190,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -12186,7 +12190,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 12186 | if (f != null) continue; | 12190 | if (f != null) continue; |
| 12187 | cases_len += 1; | 12191 | cases_len += 1; |
| 12188 | | 12192 | |
| 12189 | const item_val = try mod.enumValueFieldIndex(operand_ty, @as(u32, @intCast(i))); | 12193 | const item_val = try mod.enumValueFieldIndex(operand_ty, @intCast(i)); |
| 12190 | const item_ref = Air.internedToRef(item_val.toIntern()); | 12194 | const item_ref = Air.internedToRef(item_val.toIntern()); |
| 12191 | | 12195 | |
| 12192 | case_block.instructions.shrinkRetainingCapacity(0); | 12196 | case_block.instructions.shrinkRetainingCapacity(0); |
| ... | @@ -12217,7 +12221,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -12217,7 +12221,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 12217 | | 12221 | |
| 12218 | try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len); | 12222 | try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len); |
| 12219 | cases_extra.appendAssumeCapacity(1); // items_len | 12223 | cases_extra.appendAssumeCapacity(1); // items_len |
| 12220 | cases_extra.appendAssumeCapacity(@as(u32, @intCast(case_block.instructions.items.len))); | 12224 | cases_extra.appendAssumeCapacity(@intCast(case_block.instructions.items.len)); |
| 12221 | cases_extra.appendAssumeCapacity(@intFromEnum(item_ref)); | 12225 | cases_extra.appendAssumeCapacity(@intFromEnum(item_ref)); |
| 12222 | cases_extra.appendSliceAssumeCapacity(case_block.instructions.items); | 12226 | cases_extra.appendSliceAssumeCapacity(case_block.instructions.items); |
| 12223 | } | 12227 | } |
| ... | @@ -12258,7 +12262,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -12258,7 +12262,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 12258 | | 12262 | |
| 12259 | try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len); | 12263 | try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len); |
| 12260 | cases_extra.appendAssumeCapacity(1); // items_len | 12264 | cases_extra.appendAssumeCapacity(1); // items_len |
| 12261 | cases_extra.appendAssumeCapacity(@as(u32, @intCast(case_block.instructions.items.len))); | 12265 | cases_extra.appendAssumeCapacity(@intCast(case_block.instructions.items.len)); |
| 12262 | cases_extra.appendAssumeCapacity(@intFromEnum(item_ref)); | 12266 | cases_extra.appendAssumeCapacity(@intFromEnum(item_ref)); |
| 12263 | cases_extra.appendSliceAssumeCapacity(case_block.instructions.items); | 12267 | cases_extra.appendSliceAssumeCapacity(case_block.instructions.items); |
| 12264 | } | 12268 | } |
| ... | @@ -12289,7 +12293,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -12289,7 +12293,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 12289 | | 12293 | |
| 12290 | try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len); | 12294 | try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len); |
| 12291 | cases_extra.appendAssumeCapacity(1); // items_len | 12295 | cases_extra.appendAssumeCapacity(1); // items_len |
| 12292 | cases_extra.appendAssumeCapacity(@as(u32, @intCast(case_block.instructions.items.len))); | 12296 | cases_extra.appendAssumeCapacity(@intCast(case_block.instructions.items.len)); |
| 12293 | cases_extra.appendAssumeCapacity(@intFromEnum(item_ref)); | 12297 | cases_extra.appendAssumeCapacity(@intFromEnum(item_ref)); |
| 12294 | cases_extra.appendSliceAssumeCapacity(case_block.instructions.items); | 12298 | cases_extra.appendSliceAssumeCapacity(case_block.instructions.items); |
| 12295 | } | 12299 | } |
| ... | @@ -12317,7 +12321,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -12317,7 +12321,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 12317 | | 12321 | |
| 12318 | try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len); | 12322 | try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len); |
| 12319 | cases_extra.appendAssumeCapacity(1); // items_len | 12323 | cases_extra.appendAssumeCapacity(1); // items_len |
| 12320 | cases_extra.appendAssumeCapacity(@as(u32, @intCast(case_block.instructions.items.len))); | 12324 | cases_extra.appendAssumeCapacity(@intCast(case_block.instructions.items.len)); |
| 12321 | cases_extra.appendAssumeCapacity(@intFromEnum(Air.Inst.Ref.bool_true)); | 12325 | cases_extra.appendAssumeCapacity(@intFromEnum(Air.Inst.Ref.bool_true)); |
| 12322 | cases_extra.appendSliceAssumeCapacity(case_block.instructions.items); | 12326 | cases_extra.appendSliceAssumeCapacity(case_block.instructions.items); |
| 12323 | } | 12327 | } |
| ... | @@ -12343,7 +12347,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -12343,7 +12347,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 12343 | | 12347 | |
| 12344 | try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len); | 12348 | try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len); |
| 12345 | cases_extra.appendAssumeCapacity(1); // items_len | 12349 | cases_extra.appendAssumeCapacity(1); // items_len |
| 12346 | cases_extra.appendAssumeCapacity(@as(u32, @intCast(case_block.instructions.items.len))); | 12350 | cases_extra.appendAssumeCapacity(@intCast(case_block.instructions.items.len)); |
| 12347 | cases_extra.appendAssumeCapacity(@intFromEnum(Air.Inst.Ref.bool_false)); | 12351 | cases_extra.appendAssumeCapacity(@intFromEnum(Air.Inst.Ref.bool_false)); |
| 12348 | cases_extra.appendSliceAssumeCapacity(case_block.instructions.items); | 12352 | cases_extra.appendSliceAssumeCapacity(case_block.instructions.items); |
| 12349 | } | 12353 | } |
| ... | @@ -12412,8 +12416,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -12412,8 +12416,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 12412 | | 12416 | |
| 12413 | sema.air_instructions.items(.data)[prev_cond_br].pl_op.payload = | 12417 | sema.air_instructions.items(.data)[prev_cond_br].pl_op.payload = |
| 12414 | sema.addExtraAssumeCapacity(Air.CondBr{ | 12418 | sema.addExtraAssumeCapacity(Air.CondBr{ |
| 12415 | .then_body_len = @as(u32, @intCast(prev_then_body.len)), | 12419 | .then_body_len = @intCast(prev_then_body.len), |
| 12416 | .else_body_len = @as(u32, @intCast(case_block.instructions.items.len)), | 12420 | .else_body_len = @intCast(case_block.instructions.items.len), |
| 12417 | }); | 12421 | }); |
| 12418 | sema.air_extra.appendSliceAssumeCapacity(prev_then_body); | 12422 | sema.air_extra.appendSliceAssumeCapacity(prev_then_body); |
| 12419 | sema.air_extra.appendSliceAssumeCapacity(case_block.instructions.items); | 12423 | sema.air_extra.appendSliceAssumeCapacity(case_block.instructions.items); |
| ... | @@ -12427,8 +12431,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -12427,8 +12431,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 12427 | _ = try child_block.addInst(.{ .tag = .switch_br, .data = .{ .pl_op = .{ | 12431 | _ = try child_block.addInst(.{ .tag = .switch_br, .data = .{ .pl_op = .{ |
| 12428 | .operand = operand, | 12432 | .operand = operand, |
| 12429 | .payload = sema.addExtraAssumeCapacity(Air.SwitchBr{ | 12433 | .payload = sema.addExtraAssumeCapacity(Air.SwitchBr{ |
| 12430 | .cases_len = @as(u32, @intCast(cases_len)), | 12434 | .cases_len = @intCast(cases_len), |
| 12431 | .else_body_len = @as(u32, @intCast(final_else_body.len)), | 12435 | .else_body_len = @intCast(final_else_body.len), |
| 12432 | }), | 12436 | }), |
| 12433 | } } }); | 12437 | } } }); |
| 12434 | sema.air_extra.appendSliceAssumeCapacity(cases_extra.items); | 12438 | sema.air_extra.appendSliceAssumeCapacity(cases_extra.items); |
| ... | @@ -13842,7 +13846,7 @@ fn analyzeTupleMul( | ... | @@ -13842,7 +13846,7 @@ fn analyzeTupleMul( |
| 13842 | var i: u32 = 0; | 13846 | var i: u32 = 0; |
| 13843 | while (i < tuple_len) : (i += 1) { | 13847 | while (i < tuple_len) : (i += 1) { |
| 13844 | const operand_src = lhs_src; // TODO better source location | 13848 | const operand_src = lhs_src; // TODO better source location |
| 13845 | element_refs[i] = try sema.tupleFieldValByIndex(block, operand_src, operand, @as(u32, @intCast(i)), operand_ty); | 13849 | element_refs[i] = try sema.tupleFieldValByIndex(block, operand_src, operand, @intCast(i), operand_ty); |
| 13846 | } | 13850 | } |
| 13847 | i = 1; | 13851 | i = 1; |
| 13848 | while (i < factor) : (i += 1) { | 13852 | while (i < factor) : (i += 1) { |
| ... | @@ -15886,10 +15890,10 @@ fn analyzePtrArithmetic( | ... | @@ -15886,10 +15890,10 @@ fn analyzePtrArithmetic( |
| 15886 | // The resulting pointer is aligned to the lcd between the offset (an | 15890 | // The resulting pointer is aligned to the lcd between the offset (an |
| 15887 | // arbitrary number) and the alignment factor (always a power of two, | 15891 | // arbitrary number) and the alignment factor (always a power of two, |
| 15888 | // non zero). | 15892 | // non zero). |
| 15889 | const new_align = @as(Alignment, @enumFromInt(@min( | 15893 | const new_align: Alignment = @enumFromInt(@min( |
| 15890 | @ctz(addend), | 15894 | @ctz(addend), |
| 15891 | @intFromEnum(ptr_info.flags.alignment), | 15895 | @intFromEnum(ptr_info.flags.alignment), |
| 15892 | ))); | 15896 | )); |
| 15893 | assert(new_align != .none); | 15897 | assert(new_align != .none); |
| 15894 | | 15898 | |
| 15895 | break :t try mod.ptrType(.{ | 15899 | break :t try mod.ptrType(.{ |
| ... | @@ -15968,14 +15972,14 @@ fn zirAsm( | ... | @@ -15968,14 +15972,14 @@ fn zirAsm( |
| 15968 | const extra = sema.code.extraData(Zir.Inst.Asm, extended.operand); | 15972 | const extra = sema.code.extraData(Zir.Inst.Asm, extended.operand); |
| 15969 | const src = LazySrcLoc.nodeOffset(extra.data.src_node); | 15973 | const src = LazySrcLoc.nodeOffset(extra.data.src_node); |
| 15970 | const ret_ty_src: LazySrcLoc = .{ .node_offset_asm_ret_ty = extra.data.src_node }; | 15974 | const ret_ty_src: LazySrcLoc = .{ .node_offset_asm_ret_ty = extra.data.src_node }; |
| 15971 | const outputs_len = @as(u5, @truncate(extended.small)); | 15975 | const outputs_len: u5 = @truncate(extended.small); |
| 15972 | const inputs_len = @as(u5, @truncate(extended.small >> 5)); | 15976 | const inputs_len: u5 = @truncate(extended.small >> 5); |
| 15973 | const clobbers_len = @as(u5, @truncate(extended.small >> 10)); | 15977 | const clobbers_len: u5 = @truncate(extended.small >> 10); |
| 15974 | const is_volatile = @as(u1, @truncate(extended.small >> 15)) != 0; | 15978 | const is_volatile = @as(u1, @truncate(extended.small >> 15)) != 0; |
| 15975 | const is_global_assembly = sema.func_index == .none; | 15979 | const is_global_assembly = sema.func_index == .none; |
| 15976 | | 15980 | |
| 15977 | const asm_source: []const u8 = if (tmpl_is_expr) blk: { | 15981 | const asm_source: []const u8 = if (tmpl_is_expr) blk: { |
| 15978 | const tmpl = @as(Zir.Inst.Ref, @enumFromInt(extra.data.asm_source)); | 15982 | const tmpl: Zir.Inst.Ref = @enumFromInt(extra.data.asm_source); |
| 15979 | const s: []const u8 = try sema.resolveConstString(block, src, tmpl, "assembly code must be comptime-known"); | 15983 | const s: []const u8 = try sema.resolveConstString(block, src, tmpl, "assembly code must be comptime-known"); |
| 15980 | break :blk s; | 15984 | break :blk s; |
| 15981 | } else sema.code.nullTerminatedString(extra.data.asm_source); | 15985 | } else sema.code.nullTerminatedString(extra.data.asm_source); |
| ... | @@ -16076,9 +16080,9 @@ fn zirAsm( | ... | @@ -16076,9 +16080,9 @@ fn zirAsm( |
| 16076 | .data = .{ .ty_pl = .{ | 16080 | .data = .{ .ty_pl = .{ |
| 16077 | .ty = expr_ty, | 16081 | .ty = expr_ty, |
| 16078 | .payload = sema.addExtraAssumeCapacity(Air.Asm{ | 16082 | .payload = sema.addExtraAssumeCapacity(Air.Asm{ |
| 16079 | .source_len = @as(u32, @intCast(asm_source.len)), | 16083 | .source_len = @intCast(asm_source.len), |
| 16080 | .outputs_len = outputs_len, | 16084 | .outputs_len = outputs_len, |
| 16081 | .inputs_len = @as(u32, @intCast(args.len)), | 16085 | .inputs_len = @intCast(args.len), |
| 16082 | .flags = (@as(u32, @intFromBool(is_volatile)) << 31) | @as(u32, @intCast(clobbers.len)), | 16086 | .flags = (@as(u32, @intFromBool(is_volatile)) << 31) | @as(u32, @intCast(clobbers.len)), |
| 16083 | }), | 16087 | }), |
| 16084 | } }, | 16088 | } }, |
| ... | @@ -16486,7 +16490,7 @@ fn zirThis( | ... | @@ -16486,7 +16490,7 @@ fn zirThis( |
| 16486 | ) CompileError!Air.Inst.Ref { | 16490 | ) CompileError!Air.Inst.Ref { |
| 16487 | const mod = sema.mod; | 16491 | const mod = sema.mod; |
| 16488 | const this_decl_index = mod.namespaceDeclIndex(block.namespace); | 16492 | const this_decl_index = mod.namespaceDeclIndex(block.namespace); |
| 16489 | const src = LazySrcLoc.nodeOffset(@as(i32, @bitCast(extended.operand))); | 16493 | const src = LazySrcLoc.nodeOffset(@bitCast(extended.operand)); |
| 16490 | return sema.analyzeDeclVal(block, src, this_decl_index); | 16494 | return sema.analyzeDeclVal(block, src, this_decl_index); |
| 16491 | } | 16495 | } |
| 16492 | | 16496 | |
| ... | @@ -16624,7 +16628,7 @@ fn zirFrameAddress( | ... | @@ -16624,7 +16628,7 @@ fn zirFrameAddress( |
| 16624 | block: *Block, | 16628 | block: *Block, |
| 16625 | extended: Zir.Inst.Extended.InstData, | 16629 | extended: Zir.Inst.Extended.InstData, |
| 16626 | ) CompileError!Air.Inst.Ref { | 16630 | ) CompileError!Air.Inst.Ref { |
| 16627 | const src = LazySrcLoc.nodeOffset(@as(i32, @bitCast(extended.operand))); | 16631 | const src = LazySrcLoc.nodeOffset(@bitCast(extended.operand)); |
| 16628 | try sema.requireRuntimeBlock(block, src, null); | 16632 | try sema.requireRuntimeBlock(block, src, null); |
| 16629 | return try block.addNoOp(.frame_addr); | 16633 | return try block.addNoOp(.frame_addr); |
| 16630 | } | 16634 | } |
| ... | @@ -17223,7 +17227,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17223,7 +17227,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17223 | else | 17227 | else |
| 17224 | try mod.intern(.{ .int = .{ | 17228 | try mod.intern(.{ .int = .{ |
| 17225 | .ty = .comptime_int_type, | 17229 | .ty = .comptime_int_type, |
| 17226 | .storage = .{ .u64 = @as(u64, @intCast(i)) }, | 17230 | .storage = .{ .u64 = @intCast(i) }, |
| 17227 | } }); | 17231 | } }); |
| 17228 | // TODO: write something like getCoercedInts to avoid needing to dupe | 17232 | // TODO: write something like getCoercedInts to avoid needing to dupe |
| 17229 | const name = try sema.arena.dupe(u8, ip.stringToSlice(enum_type.names.get(ip)[i])); | 17233 | const name = try sema.arena.dupe(u8, ip.stringToSlice(enum_type.names.get(ip)[i])); |
| ... | @@ -18035,7 +18039,7 @@ fn zirBoolBr( | ... | @@ -18035,7 +18039,7 @@ fn zirBoolBr( |
| 18035 | return sema.resolveBody(parent_block, body, inst); | 18039 | return sema.resolveBody(parent_block, body, inst); |
| 18036 | } | 18040 | } |
| 18037 | | 18041 | |
| 18038 | const block_inst = @as(Air.Inst.Index, @intCast(sema.air_instructions.len)); | 18042 | const block_inst: Air.Inst.Index = @intCast(sema.air_instructions.len); |
| 18039 | try sema.air_instructions.append(gpa, .{ | 18043 | try sema.air_instructions.append(gpa, .{ |
| 18040 | .tag = .block, | 18044 | .tag = .block, |
| 18041 | .data = .{ .ty_pl = .{ | 18045 | .data = .{ .ty_pl = .{ |
| ... | @@ -18097,8 +18101,8 @@ fn finishCondBr( | ... | @@ -18097,8 +18101,8 @@ fn finishCondBr( |
| 18097 | @typeInfo(Air.Block).Struct.fields.len + child_block.instructions.items.len + 1); | 18101 | @typeInfo(Air.Block).Struct.fields.len + child_block.instructions.items.len + 1); |
| 18098 | | 18102 | |
| 18099 | const cond_br_payload = sema.addExtraAssumeCapacity(Air.CondBr{ | 18103 | const cond_br_payload = sema.addExtraAssumeCapacity(Air.CondBr{ |
| 18100 | .then_body_len = @as(u32, @intCast(then_block.instructions.items.len)), | 18104 | .then_body_len = @intCast(then_block.instructions.items.len), |
| 18101 | .else_body_len = @as(u32, @intCast(else_block.instructions.items.len)), | 18105 | .else_body_len = @intCast(else_block.instructions.items.len), |
| 18102 | }); | 18106 | }); |
| 18103 | sema.air_extra.appendSliceAssumeCapacity(then_block.instructions.items); | 18107 | sema.air_extra.appendSliceAssumeCapacity(then_block.instructions.items); |
| 18104 | sema.air_extra.appendSliceAssumeCapacity(else_block.instructions.items); | 18108 | sema.air_extra.appendSliceAssumeCapacity(else_block.instructions.items); |
| ... | @@ -18109,7 +18113,7 @@ fn finishCondBr( | ... | @@ -18109,7 +18113,7 @@ fn finishCondBr( |
| 18109 | } } }); | 18113 | } } }); |
| 18110 | | 18114 | |
| 18111 | sema.air_instructions.items(.data)[block_inst].ty_pl.payload = sema.addExtraAssumeCapacity( | 18115 | sema.air_instructions.items(.data)[block_inst].ty_pl.payload = sema.addExtraAssumeCapacity( |
| 18112 | Air.Block{ .body_len = @as(u32, @intCast(child_block.instructions.items.len)) }, | 18116 | Air.Block{ .body_len = @intCast(child_block.instructions.items.len) }, |
| 18113 | ); | 18117 | ); |
| 18114 | sema.air_extra.appendSliceAssumeCapacity(child_block.instructions.items); | 18118 | sema.air_extra.appendSliceAssumeCapacity(child_block.instructions.items); |
| 18115 | | 18119 | |
| ... | @@ -18272,8 +18276,8 @@ fn zirCondbr( | ... | @@ -18272,8 +18276,8 @@ fn zirCondbr( |
| 18272 | .data = .{ .pl_op = .{ | 18276 | .data = .{ .pl_op = .{ |
| 18273 | .operand = cond, | 18277 | .operand = cond, |
| 18274 | .payload = sema.addExtraAssumeCapacity(Air.CondBr{ | 18278 | .payload = sema.addExtraAssumeCapacity(Air.CondBr{ |
| 18275 | .then_body_len = @as(u32, @intCast(true_instructions.len)), | 18279 | .then_body_len = @intCast(true_instructions.len), |
| 18276 | .else_body_len = @as(u32, @intCast(sub_block.instructions.items.len)), | 18280 | .else_body_len = @intCast(sub_block.instructions.items.len), |
| 18277 | }), | 18281 | }), |
| 18278 | } }, | 18282 | } }, |
| 18279 | }); | 18283 | }); |
| ... | @@ -18320,7 +18324,7 @@ fn zirTry(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -18320,7 +18324,7 @@ fn zirTry(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError! |
| 18320 | .data = .{ .pl_op = .{ | 18324 | .data = .{ .pl_op = .{ |
| 18321 | .operand = err_union, | 18325 | .operand = err_union, |
| 18322 | .payload = sema.addExtraAssumeCapacity(Air.Try{ | 18326 | .payload = sema.addExtraAssumeCapacity(Air.Try{ |
| 18323 | .body_len = @as(u32, @intCast(sub_block.instructions.items.len)), | 18327 | .body_len = @intCast(sub_block.instructions.items.len), |
| 18324 | }), | 18328 | }), |
| 18325 | } }, | 18329 | } }, |
| 18326 | }); | 18330 | }); |
| ... | @@ -18380,7 +18384,7 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr | ... | @@ -18380,7 +18384,7 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr |
| 18380 | .ty = res_ty_ref, | 18384 | .ty = res_ty_ref, |
| 18381 | .payload = sema.addExtraAssumeCapacity(Air.TryPtr{ | 18385 | .payload = sema.addExtraAssumeCapacity(Air.TryPtr{ |
| 18382 | .ptr = operand, | 18386 | .ptr = operand, |
| 18383 | .body_len = @as(u32, @intCast(sub_block.instructions.items.len)), | 18387 | .body_len = @intCast(sub_block.instructions.items.len), |
| 18384 | }), | 18388 | }), |
| 18385 | } }, | 18389 | } }, |
| 18386 | }); | 18390 | }); |
| ... | @@ -18396,7 +18400,7 @@ fn addRuntimeBreak(sema: *Sema, child_block: *Block, break_data: BreakData) !voi | ... | @@ -18396,7 +18400,7 @@ fn addRuntimeBreak(sema: *Sema, child_block: *Block, break_data: BreakData) !voi |
| 18396 | const labeled_block = if (!gop.found_existing) blk: { | 18400 | const labeled_block = if (!gop.found_existing) blk: { |
| 18397 | try sema.post_hoc_blocks.ensureUnusedCapacity(sema.gpa, 1); | 18401 | try sema.post_hoc_blocks.ensureUnusedCapacity(sema.gpa, 1); |
| 18398 | | 18402 | |
| 18399 | const new_block_inst = @as(Air.Inst.Index, @intCast(sema.air_instructions.len)); | 18403 | const new_block_inst: Air.Inst.Index = @intCast(sema.air_instructions.len); |
| 18400 | gop.value_ptr.* = Air.indexToRef(new_block_inst); | 18404 | gop.value_ptr.* = Air.indexToRef(new_block_inst); |
| 18401 | try sema.air_instructions.append(sema.gpa, .{ | 18405 | try sema.air_instructions.append(sema.gpa, .{ |
| 18402 | .tag = .block, | 18406 | .tag = .block, |
| ... | @@ -18611,8 +18615,8 @@ fn retWithErrTracing( | ... | @@ -18611,8 +18615,8 @@ fn retWithErrTracing( |
| 18611 | @typeInfo(Air.Block).Struct.fields.len + 1); | 18615 | @typeInfo(Air.Block).Struct.fields.len + 1); |
| 18612 | | 18616 | |
| 18613 | const cond_br_payload = sema.addExtraAssumeCapacity(Air.CondBr{ | 18617 | const cond_br_payload = sema.addExtraAssumeCapacity(Air.CondBr{ |
| 18614 | .then_body_len = @as(u32, @intCast(then_block.instructions.items.len)), | 18618 | .then_body_len = @intCast(then_block.instructions.items.len), |
| 18615 | .else_body_len = @as(u32, @intCast(else_block.instructions.items.len)), | 18619 | .else_body_len = @intCast(else_block.instructions.items.len), |
| 18616 | }); | 18620 | }); |
| 18617 | sema.air_extra.appendSliceAssumeCapacity(then_block.instructions.items); | 18621 | sema.air_extra.appendSliceAssumeCapacity(then_block.instructions.items); |
| 18618 | sema.air_extra.appendSliceAssumeCapacity(else_block.instructions.items); | 18622 | sema.air_extra.appendSliceAssumeCapacity(else_block.instructions.items); |
| ... | @@ -18826,7 +18830,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -18826,7 +18830,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 18826 | var extra_i = extra.end; | 18830 | var extra_i = extra.end; |
| 18827 | | 18831 | |
| 18828 | const sentinel = if (inst_data.flags.has_sentinel) blk: { | 18832 | const sentinel = if (inst_data.flags.has_sentinel) blk: { |
| 18829 | const ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_i])); | 18833 | const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]); |
| 18830 | extra_i += 1; | 18834 | extra_i += 1; |
| 18831 | const coerced = try sema.coerce(block, elem_ty, try sema.resolveInst(ref), sentinel_src); | 18835 | const coerced = try sema.coerce(block, elem_ty, try sema.resolveInst(ref), sentinel_src); |
| 18832 | const val = try sema.resolveConstValue(block, sentinel_src, coerced, "pointer sentinel value must be comptime-known"); | 18836 | const val = try sema.resolveConstValue(block, sentinel_src, coerced, "pointer sentinel value must be comptime-known"); |
| ... | @@ -18834,7 +18838,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -18834,7 +18838,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 18834 | } else .none; | 18838 | } else .none; |
| 18835 | | 18839 | |
| 18836 | const abi_align: Alignment = if (inst_data.flags.has_align) blk: { | 18840 | const abi_align: Alignment = if (inst_data.flags.has_align) blk: { |
| 18837 | const ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_i])); | 18841 | const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]); |
| 18838 | extra_i += 1; | 18842 | extra_i += 1; |
| 18839 | const coerced = try sema.coerce(block, Type.u32, try sema.resolveInst(ref), align_src); | 18843 | const coerced = try sema.coerce(block, Type.u32, try sema.resolveInst(ref), align_src); |
| 18840 | const val = try sema.resolveConstValue(block, align_src, coerced, "pointer alignment must be comptime-known"); | 18844 | const val = try sema.resolveConstValue(block, align_src, coerced, "pointer alignment must be comptime-known"); |
| ... | @@ -18847,29 +18851,29 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -18847,29 +18851,29 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 18847 | }, | 18851 | }, |
| 18848 | else => {}, | 18852 | else => {}, |
| 18849 | } | 18853 | } |
| 18850 | const abi_align = @as(u32, @intCast((try val.getUnsignedIntAdvanced(mod, sema)).?)); | 18854 | const abi_align: u32 = @intCast((try val.getUnsignedIntAdvanced(mod, sema)).?); |
| 18851 | try sema.validateAlign(block, align_src, abi_align); | 18855 | try sema.validateAlign(block, align_src, abi_align); |
| 18852 | break :blk Alignment.fromByteUnits(abi_align); | 18856 | break :blk Alignment.fromByteUnits(abi_align); |
| 18853 | } else .none; | 18857 | } else .none; |
| 18854 | | 18858 | |
| 18855 | const address_space: std.builtin.AddressSpace = if (inst_data.flags.has_addrspace) blk: { | 18859 | const address_space: std.builtin.AddressSpace = if (inst_data.flags.has_addrspace) blk: { |
| 18856 | const ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_i])); | 18860 | const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]); |
| 18857 | extra_i += 1; | 18861 | extra_i += 1; |
| 18858 | break :blk try sema.analyzeAddressSpace(block, addrspace_src, ref, .pointer); | 18862 | break :blk try sema.analyzeAddressSpace(block, addrspace_src, ref, .pointer); |
| 18859 | } else if (elem_ty.zigTypeTag(mod) == .Fn and target.cpu.arch == .avr) .flash else .generic; | 18863 | } else if (elem_ty.zigTypeTag(mod) == .Fn and target.cpu.arch == .avr) .flash else .generic; |
| 18860 | | 18864 | |
| 18861 | const bit_offset = if (inst_data.flags.has_bit_range) blk: { | 18865 | const bit_offset: u16 = if (inst_data.flags.has_bit_range) blk: { |
| 18862 | const ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_i])); | 18866 | const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]); |
| 18863 | extra_i += 1; | 18867 | extra_i += 1; |
| 18864 | const bit_offset = try sema.resolveInt(block, bitoffset_src, ref, Type.u16, "pointer bit-offset must be comptime-known"); | 18868 | const bit_offset = try sema.resolveInt(block, bitoffset_src, ref, Type.u16, "pointer bit-offset must be comptime-known"); |
| 18865 | break :blk @as(u16, @intCast(bit_offset)); | 18869 | break :blk @intCast(bit_offset); |
| 18866 | } else 0; | 18870 | } else 0; |
| 18867 | | 18871 | |
| 18868 | const host_size: u16 = if (inst_data.flags.has_bit_range) blk: { | 18872 | const host_size: u16 = if (inst_data.flags.has_bit_range) blk: { |
| 18869 | const ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_i])); | 18873 | const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]); |
| 18870 | extra_i += 1; | 18874 | extra_i += 1; |
| 18871 | const host_size = try sema.resolveInt(block, hostsize_src, ref, Type.u16, "pointer host size must be comptime-known"); | 18875 | const host_size = try sema.resolveInt(block, hostsize_src, ref, Type.u16, "pointer host size must be comptime-known"); |
| 18872 | break :blk @as(u16, @intCast(host_size)); | 18876 | break :blk @intCast(host_size); |
| 18873 | } else 0; | 18877 | } else 0; |
| 18874 | | 18878 | |
| 18875 | if (host_size != 0 and bit_offset >= host_size * 8) { | 18879 | if (host_size != 0 and bit_offset >= host_size * 8) { |
| ... | @@ -19270,7 +19274,7 @@ fn finishStructInit( | ... | @@ -19270,7 +19274,7 @@ fn finishStructInit( |
| 19270 | }); | 19274 | }); |
| 19271 | const alloc = try block.addTy(.alloc, alloc_ty); | 19275 | const alloc = try block.addTy(.alloc, alloc_ty); |
| 19272 | for (field_inits, 0..) |field_init, i_usize| { | 19276 | for (field_inits, 0..) |field_init, i_usize| { |
| 19273 | const i = @as(u32, @intCast(i_usize)); | 19277 | const i: u32 = @intCast(i_usize); |
| 19274 | const field_src = dest_src; | 19278 | const field_src = dest_src; |
| 19275 | const field_ptr = try sema.structFieldPtrByIndex(block, dest_src, alloc, i, field_src, struct_ty, true); | 19279 | const field_ptr = try sema.structFieldPtrByIndex(block, dest_src, alloc, i, field_src, struct_ty, true); |
| 19276 | try sema.storePtr(block, dest_src, field_ptr, field_init); | 19280 | try sema.storePtr(block, dest_src, field_ptr, field_init); |
| ... | @@ -19423,7 +19427,7 @@ fn structInitAnon( | ... | @@ -19423,7 +19427,7 @@ fn structInitAnon( |
| 19423 | const alloc = try block.addTy(.alloc, alloc_ty); | 19427 | const alloc = try block.addTy(.alloc, alloc_ty); |
| 19424 | var extra_index = extra_end; | 19428 | var extra_index = extra_end; |
| 19425 | for (types, 0..) |field_ty, i_usize| { | 19429 | for (types, 0..) |field_ty, i_usize| { |
| 19426 | const i = @as(u32, @intCast(i_usize)); | 19430 | const i: u32 = @intCast(i_usize); |
| 19427 | const item = switch (kind) { | 19431 | const item = switch (kind) { |
| 19428 | .anon_init => sema.code.extraData(Zir.Inst.StructInitAnon.Item, extra_index), | 19432 | .anon_init => sema.code.extraData(Zir.Inst.StructInitAnon.Item, extra_index), |
| 19429 | .typed_init => sema.code.extraData(Zir.Inst.StructInit.Item, extra_index), | 19433 | .typed_init => sema.code.extraData(Zir.Inst.StructInit.Item, extra_index), |
| ... | @@ -19520,7 +19524,7 @@ fn zirArrayInit( | ... | @@ -19520,7 +19524,7 @@ fn zirArrayInit( |
| 19520 | | 19524 | |
| 19521 | const opt_runtime_index: ?u32 = for (resolved_args, 0..) |arg, i| { | 19525 | const opt_runtime_index: ?u32 = for (resolved_args, 0..) |arg, i| { |
| 19522 | const comptime_known = try sema.isComptimeKnown(arg); | 19526 | const comptime_known = try sema.isComptimeKnown(arg); |
| 19523 | if (!comptime_known) break @as(u32, @intCast(i)); | 19527 | if (!comptime_known) break @intCast(i); |
| 19524 | } else null; | 19528 | } else null; |
| 19525 | | 19529 | |
| 19526 | const runtime_index = opt_runtime_index orelse { | 19530 | const runtime_index = opt_runtime_index orelse { |
| ... | @@ -19665,7 +19669,7 @@ fn arrayInitAnon( | ... | @@ -19665,7 +19669,7 @@ fn arrayInitAnon( |
| 19665 | }); | 19669 | }); |
| 19666 | const alloc = try block.addTy(.alloc, alloc_ty); | 19670 | const alloc = try block.addTy(.alloc, alloc_ty); |
| 19667 | for (operands, 0..) |operand, i_usize| { | 19671 | for (operands, 0..) |operand, i_usize| { |
| 19668 | const i = @as(u32, @intCast(i_usize)); | 19672 | const i: u32 = @intCast(i_usize); |
| 19669 | const field_ptr_ty = try mod.ptrType(.{ | 19673 | const field_ptr_ty = try mod.ptrType(.{ |
| 19670 | .child = types[i], | 19674 | .child = types[i], |
| 19671 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, | 19675 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, |
| ... | @@ -19818,7 +19822,7 @@ fn zirFrame( | ... | @@ -19818,7 +19822,7 @@ fn zirFrame( |
| 19818 | block: *Block, | 19822 | block: *Block, |
| 19819 | extended: Zir.Inst.Extended.InstData, | 19823 | extended: Zir.Inst.Extended.InstData, |
| 19820 | ) CompileError!Air.Inst.Ref { | 19824 | ) CompileError!Air.Inst.Ref { |
| 19821 | const src = LazySrcLoc.nodeOffset(@as(i32, @bitCast(extended.operand))); | 19825 | const src = LazySrcLoc.nodeOffset(@bitCast(extended.operand)); |
| 19822 | return sema.failWithUseOfAsync(block, src); | 19826 | return sema.failWithUseOfAsync(block, src); |
| 19823 | } | 19827 | } |
| 19824 | | 19828 | |
| ... | @@ -20049,7 +20053,7 @@ fn zirReify( | ... | @@ -20049,7 +20053,7 @@ fn zirReify( |
| 20049 | const mod = sema.mod; | 20053 | const mod = sema.mod; |
| 20050 | const gpa = sema.gpa; | 20054 | const gpa = sema.gpa; |
| 20051 | const ip = &mod.intern_pool; | 20055 | const ip = &mod.intern_pool; |
| 20052 | const name_strategy = @as(Zir.Inst.NameStrategy, @enumFromInt(extended.small)); | 20056 | const name_strategy: Zir.Inst.NameStrategy = @enumFromInt(extended.small); |
| 20053 | const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data; | 20057 | const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data; |
| 20054 | const src = LazySrcLoc.nodeOffset(extra.node); | 20058 | const src = LazySrcLoc.nodeOffset(extra.node); |
| 20055 | const type_info_ty = try sema.getBuiltinType("Type"); | 20059 | const type_info_ty = try sema.getBuiltinType("Type"); |
| ... | @@ -20084,7 +20088,7 @@ fn zirReify( | ... | @@ -20084,7 +20088,7 @@ fn zirReify( |
| 20084 | ); | 20088 | ); |
| 20085 | | 20089 | |
| 20086 | const signedness = mod.toEnum(std.builtin.Signedness, signedness_val); | 20090 | const signedness = mod.toEnum(std.builtin.Signedness, signedness_val); |
| 20087 | const bits = @as(u16, @intCast(bits_val.toUnsignedInt(mod))); | 20091 | const bits: u16 = @intCast(bits_val.toUnsignedInt(mod)); |
| 20088 | const ty = try mod.intType(signedness, bits); | 20092 | const ty = try mod.intType(signedness, bits); |
| 20089 | return Air.internedToRef(ty.toIntern()); | 20093 | return Air.internedToRef(ty.toIntern()); |
| 20090 | }, | 20094 | }, |
| ... | @@ -20097,7 +20101,7 @@ fn zirReify( | ... | @@ -20097,7 +20101,7 @@ fn zirReify( |
| 20097 | try ip.getOrPutString(gpa, "child"), | 20101 | try ip.getOrPutString(gpa, "child"), |
| 20098 | ).?); | 20102 | ).?); |
| 20099 | | 20103 | |
| 20100 | const len = @as(u32, @intCast(len_val.toUnsignedInt(mod))); | 20104 | const len: u32 = @intCast(len_val.toUnsignedInt(mod)); |
| 20101 | const child_ty = child_val.toType(); | 20105 | const child_ty = child_val.toType(); |
| 20102 | | 20106 | |
| 20103 | try sema.checkVectorElemType(block, src, child_ty); | 20107 | try sema.checkVectorElemType(block, src, child_ty); |
| ... | @@ -20114,7 +20118,7 @@ fn zirReify( | ... | @@ -20114,7 +20118,7 @@ fn zirReify( |
| 20114 | try ip.getOrPutString(gpa, "bits"), | 20118 | try ip.getOrPutString(gpa, "bits"), |
| 20115 | ).?); | 20119 | ).?); |
| 20116 | | 20120 | |
| 20117 | const bits = @as(u16, @intCast(bits_val.toUnsignedInt(mod))); | 20121 | const bits: u16 = @intCast(bits_val.toUnsignedInt(mod)); |
| 20118 | const ty = switch (bits) { | 20122 | const ty = switch (bits) { |
| 20119 | 16 => Type.f16, | 20123 | 16 => Type.f16, |
| 20120 | 32 => Type.f32, | 20124 | 32 => Type.f32, |
| ... | @@ -20382,7 +20386,7 @@ fn zirReify( | ... | @@ -20382,7 +20386,7 @@ fn zirReify( |
| 20382 | } | 20386 | } |
| 20383 | | 20387 | |
| 20384 | // Define our empty enum decl | 20388 | // Define our empty enum decl |
| 20385 | const fields_len = @as(u32, @intCast(try sema.usizeCast(block, src, fields_val.sliceLen(mod)))); | 20389 | const fields_len: u32 = @intCast(try sema.usizeCast(block, src, fields_val.sliceLen(mod))); |
| 20386 | const incomplete_enum = try ip.getIncompleteEnum(gpa, .{ | 20390 | const incomplete_enum = try ip.getIncompleteEnum(gpa, .{ |
| 20387 | .decl = new_decl_index, | 20391 | .decl = new_decl_index, |
| 20388 | .namespace = .none, | 20392 | .namespace = .none, |
| ... | @@ -20753,7 +20757,7 @@ fn zirReify( | ... | @@ -20753,7 +20757,7 @@ fn zirReify( |
| 20753 | if (!try sema.intFitsInType(alignment_val, Type.u32, null)) { | 20757 | if (!try sema.intFitsInType(alignment_val, Type.u32, null)) { |
| 20754 | return sema.fail(block, src, "alignment must fit in 'u32'", .{}); | 20758 | return sema.fail(block, src, "alignment must fit in 'u32'", .{}); |
| 20755 | } | 20759 | } |
| 20756 | const alignment = @as(u29, @intCast(alignment_val.toUnsignedInt(mod))); | 20760 | const alignment: u29 = @intCast(alignment_val.toUnsignedInt(mod)); |
| 20757 | if (alignment == target_util.defaultFunctionAlignment(target)) { | 20761 | if (alignment == target_util.defaultFunctionAlignment(target)) { |
| 20758 | break :alignment .none; | 20762 | break :alignment .none; |
| 20759 | } else { | 20763 | } else { |
| ... | @@ -21034,7 +21038,7 @@ fn reifyStruct( | ... | @@ -21034,7 +21038,7 @@ fn reifyStruct( |
| 21034 | try sema.checkBackingIntType(block, src, backing_int_ty, fields_bit_sum); | 21038 | try sema.checkBackingIntType(block, src, backing_int_ty, fields_bit_sum); |
| 21035 | struct_obj.backing_int_ty = backing_int_ty; | 21039 | struct_obj.backing_int_ty = backing_int_ty; |
| 21036 | } else { | 21040 | } else { |
| 21037 | struct_obj.backing_int_ty = try mod.intType(.unsigned, @as(u16, @intCast(fields_bit_sum))); | 21041 | struct_obj.backing_int_ty = try mod.intType(.unsigned, @intCast(fields_bit_sum)); |
| 21038 | } | 21042 | } |
| 21039 | | 21043 | |
| 21040 | struct_obj.status = .have_layout; | 21044 | struct_obj.status = .have_layout; |
| ... | @@ -21105,7 +21109,7 @@ fn zirCVaEnd(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) C | ... | @@ -21105,7 +21109,7 @@ fn zirCVaEnd(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) C |
| 21105 | } | 21109 | } |
| 21106 | | 21110 | |
| 21107 | fn zirCVaStart(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref { | 21111 | fn zirCVaStart(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref { |
| 21108 | const src = LazySrcLoc.nodeOffset(@as(i32, @bitCast(extended.operand))); | 21112 | const src = LazySrcLoc.nodeOffset(@bitCast(extended.operand)); |
| 21109 | | 21113 | |
| 21110 | const va_list_ty = try sema.getBuiltinType("VaList"); | 21114 | const va_list_ty = try sema.getBuiltinType("VaList"); |
| 21111 | try sema.requireRuntimeBlock(block, src, null); | 21115 | try sema.requireRuntimeBlock(block, src, null); |
| ... | @@ -21482,7 +21486,10 @@ fn zirErrSetCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDat | ... | @@ -21482,7 +21486,10 @@ fn zirErrSetCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDat |
| 21482 | } | 21486 | } |
| 21483 | | 21487 | |
| 21484 | fn zirPtrCastFull(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref { | 21488 | fn zirPtrCastFull(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref { |
| 21485 | const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as(u5, @truncate(extended.small))); | 21489 | const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as( |
| | 21490 | @typeInfo(Zir.Inst.FullPtrCastFlags).Struct.backing_integer.?, |
| | 21491 | @truncate(extended.small), |
| | 21492 | )); |
| 21486 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; | 21493 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; |
| 21487 | const src = LazySrcLoc.nodeOffset(extra.node); | 21494 | const src = LazySrcLoc.nodeOffset(extra.node); |
| 21488 | const operand_src: LazySrcLoc = .{ .node_offset_ptrcast_operand = extra.node }; | 21495 | const operand_src: LazySrcLoc = .{ .node_offset_ptrcast_operand = extra.node }; |
| ... | @@ -21885,7 +21892,10 @@ fn ptrCastFull( | ... | @@ -21885,7 +21892,10 @@ fn ptrCastFull( |
| 21885 | | 21892 | |
| 21886 | fn zirPtrCastNoDest(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref { | 21893 | fn zirPtrCastNoDest(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref { |
| 21887 | const mod = sema.mod; | 21894 | const mod = sema.mod; |
| 21888 | const flags = @as(Zir.Inst.FullPtrCastFlags, @bitCast(@as(u5, @truncate(extended.small)))); | 21895 | const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as( |
| | 21896 | @typeInfo(Zir.Inst.FullPtrCastFlags).Struct.backing_integer.?, |
| | 21897 | @truncate(extended.small), |
| | 21898 | )); |
| 21889 | const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data; | 21899 | const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data; |
| 21890 | const src = LazySrcLoc.nodeOffset(extra.node); | 21900 | const src = LazySrcLoc.nodeOffset(extra.node); |
| 21891 | const operand_src: LazySrcLoc = .{ .node_offset_ptrcast_operand = extra.node }; | 21901 | const operand_src: LazySrcLoc = .{ .node_offset_ptrcast_operand = extra.node }; |
| ... | @@ -22950,12 +22960,12 @@ fn zirShuffle(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -22950,12 +22960,12 @@ fn zirShuffle(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 22950 | else => return sema.fail(block, mask_src, "expected vector or array, found '{}'", .{sema.typeOf(mask).fmt(sema.mod)}), | 22960 | else => return sema.fail(block, mask_src, "expected vector or array, found '{}'", .{sema.typeOf(mask).fmt(sema.mod)}), |
| 22951 | }; | 22961 | }; |
| 22952 | mask_ty = try mod.vectorType(.{ | 22962 | mask_ty = try mod.vectorType(.{ |
| 22953 | .len = @as(u32, @intCast(mask_len)), | 22963 | .len = @intCast(mask_len), |
| 22954 | .child = .i32_type, | 22964 | .child = .i32_type, |
| 22955 | }); | 22965 | }); |
| 22956 | mask = try sema.coerce(block, mask_ty, mask, mask_src); | 22966 | mask = try sema.coerce(block, mask_ty, mask, mask_src); |
| 22957 | const mask_val = try sema.resolveConstMaybeUndefVal(block, mask_src, mask, "shuffle mask must be comptime-known"); | 22967 | const mask_val = try sema.resolveConstMaybeUndefVal(block, mask_src, mask, "shuffle mask must be comptime-known"); |
| 22958 | return sema.analyzeShuffle(block, inst_data.src_node, elem_ty, a, b, mask_val, @as(u32, @intCast(mask_len))); | 22968 | return sema.analyzeShuffle(block, inst_data.src_node, elem_ty, a, b, mask_val, @intCast(mask_len)); |
| 22959 | } | 22969 | } |
| 22960 | | 22970 | |
| 22961 | fn analyzeShuffle( | 22971 | fn analyzeShuffle( |
| ... | @@ -22999,8 +23009,8 @@ fn analyzeShuffle( | ... | @@ -22999,8 +23009,8 @@ fn analyzeShuffle( |
| 22999 | if (maybe_a_len == null and maybe_b_len == null) { | 23009 | if (maybe_a_len == null and maybe_b_len == null) { |
| 23000 | return mod.undefRef(res_ty); | 23010 | return mod.undefRef(res_ty); |
| 23001 | } | 23011 | } |
| 23002 | const a_len = @as(u32, @intCast(maybe_a_len orelse maybe_b_len.?)); | 23012 | const a_len: u32 = @intCast(maybe_a_len orelse maybe_b_len.?); |
| 23003 | const b_len = @as(u32, @intCast(maybe_b_len orelse a_len)); | 23013 | const b_len: u32 = @intCast(maybe_b_len orelse a_len); |
| 23004 | | 23014 | |
| 23005 | const a_ty = try mod.vectorType(.{ | 23015 | const a_ty = try mod.vectorType(.{ |
| 23006 | .len = a_len, | 23016 | .len = a_len, |
| ... | @@ -23019,17 +23029,17 @@ fn analyzeShuffle( | ... | @@ -23019,17 +23029,17 @@ fn analyzeShuffle( |
| 23019 | .{ b_len, b_src, b_ty }, | 23029 | .{ b_len, b_src, b_ty }, |
| 23020 | }; | 23030 | }; |
| 23021 | | 23031 | |
| 23022 | for (0..@as(usize, @intCast(mask_len))) |i| { | 23032 | for (0..@intCast(mask_len)) |i| { |
| 23023 | const elem = try mask.elemValue(sema.mod, i); | 23033 | const elem = try mask.elemValue(sema.mod, i); |
| 23024 | if (elem.isUndef(mod)) continue; | 23034 | if (elem.isUndef(mod)) continue; |
| 23025 | const int = elem.toSignedInt(mod); | 23035 | const int = elem.toSignedInt(mod); |
| 23026 | var unsigned: u32 = undefined; | 23036 | var unsigned: u32 = undefined; |
| 23027 | var chosen: u32 = undefined; | 23037 | var chosen: u32 = undefined; |
| 23028 | if (int >= 0) { | 23038 | if (int >= 0) { |
| 23029 | unsigned = @as(u32, @intCast(int)); | 23039 | unsigned = @intCast(int); |
| 23030 | chosen = 0; | 23040 | chosen = 0; |
| 23031 | } else { | 23041 | } else { |
| 23032 | unsigned = @as(u32, @intCast(~int)); | 23042 | unsigned = @intCast(~int); |
| 23033 | chosen = 1; | 23043 | chosen = 1; |
| 23034 | } | 23044 | } |
| 23035 | if (unsigned >= operand_info[chosen][0]) { | 23045 | if (unsigned >= operand_info[chosen][0]) { |
| ... | @@ -23062,7 +23072,7 @@ fn analyzeShuffle( | ... | @@ -23062,7 +23072,7 @@ fn analyzeShuffle( |
| 23062 | continue; | 23072 | continue; |
| 23063 | } | 23073 | } |
| 23064 | const int = mask_elem_val.toSignedInt(mod); | 23074 | const int = mask_elem_val.toSignedInt(mod); |
| 23065 | const unsigned = if (int >= 0) @as(u32, @intCast(int)) else @as(u32, @intCast(~int)); | 23075 | const unsigned: u32 = @intCast(if (int >= 0) int else ~int); |
| 23066 | values[i] = try (try (if (int >= 0) a_val else b_val).elemValue(mod, unsigned)).intern(elem_ty, mod); | 23076 | values[i] = try (try (if (int >= 0) a_val else b_val).elemValue(mod, unsigned)).intern(elem_ty, mod); |
| 23067 | } | 23077 | } |
| 23068 | return Air.internedToRef((try mod.intern(.{ .aggregate = .{ | 23078 | return Air.internedToRef((try mod.intern(.{ .aggregate = .{ |
| ... | @@ -23083,23 +23093,23 @@ fn analyzeShuffle( | ... | @@ -23083,23 +23093,23 @@ fn analyzeShuffle( |
| 23083 | const max_len = try sema.usizeCast(block, max_src, @max(a_len, b_len)); | 23093 | const max_len = try sema.usizeCast(block, max_src, @max(a_len, b_len)); |
| 23084 | | 23094 | |
| 23085 | const expand_mask_values = try sema.arena.alloc(InternPool.Index, max_len); | 23095 | const expand_mask_values = try sema.arena.alloc(InternPool.Index, max_len); |
| 23086 | for (@as(usize, @intCast(0))..@as(usize, @intCast(min_len))) |i| { | 23096 | for (@intCast(0)..@intCast(min_len)) |i| { |
| 23087 | expand_mask_values[i] = (try mod.intValue(Type.comptime_int, i)).toIntern(); | 23097 | expand_mask_values[i] = (try mod.intValue(Type.comptime_int, i)).toIntern(); |
| 23088 | } | 23098 | } |
| 23089 | for (@as(usize, @intCast(min_len))..@as(usize, @intCast(max_len))) |i| { | 23099 | for (@intCast(min_len)..@intCast(max_len)) |i| { |
| 23090 | expand_mask_values[i] = (try mod.intValue(Type.comptime_int, -1)).toIntern(); | 23100 | expand_mask_values[i] = (try mod.intValue(Type.comptime_int, -1)).toIntern(); |
| 23091 | } | 23101 | } |
| 23092 | const expand_mask = try mod.intern(.{ .aggregate = .{ | 23102 | const expand_mask = try mod.intern(.{ .aggregate = .{ |
| 23093 | .ty = (try mod.vectorType(.{ .len = @as(u32, @intCast(max_len)), .child = .comptime_int_type })).toIntern(), | 23103 | .ty = (try mod.vectorType(.{ .len = @intCast(max_len), .child = .comptime_int_type })).toIntern(), |
| 23094 | .storage = .{ .elems = expand_mask_values }, | 23104 | .storage = .{ .elems = expand_mask_values }, |
| 23095 | } }); | 23105 | } }); |
| 23096 | | 23106 | |
| 23097 | if (a_len < b_len) { | 23107 | if (a_len < b_len) { |
| 23098 | const undef = try mod.undefRef(a_ty); | 23108 | const undef = try mod.undefRef(a_ty); |
| 23099 | a = try sema.analyzeShuffle(block, src_node, elem_ty, a, undef, expand_mask.toValue(), @as(u32, @intCast(max_len))); | 23109 | a = try sema.analyzeShuffle(block, src_node, elem_ty, a, undef, expand_mask.toValue(), @intCast(max_len)); |
| 23100 | } else { | 23110 | } else { |
| 23101 | const undef = try mod.undefRef(b_ty); | 23111 | const undef = try mod.undefRef(b_ty); |
| 23102 | b = try sema.analyzeShuffle(block, src_node, elem_ty, b, undef, expand_mask.toValue(), @as(u32, @intCast(max_len))); | 23112 | b = try sema.analyzeShuffle(block, src_node, elem_ty, b, undef, expand_mask.toValue(), @intCast(max_len)); |
| 23103 | } | 23113 | } |
| 23104 | } | 23114 | } |
| 23105 | | 23115 | |
| ... | @@ -23136,7 +23146,7 @@ fn zirSelect(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) C | ... | @@ -23136,7 +23146,7 @@ fn zirSelect(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) C |
| 23136 | .Vector, .Array => pred_ty.arrayLen(mod), | 23146 | .Vector, .Array => pred_ty.arrayLen(mod), |
| 23137 | else => return sema.fail(block, pred_src, "expected vector or array, found '{}'", .{pred_ty.fmt(mod)}), | 23147 | else => return sema.fail(block, pred_src, "expected vector or array, found '{}'", .{pred_ty.fmt(mod)}), |
| 23138 | }; | 23148 | }; |
| 23139 | const vec_len = @as(u32, @intCast(try sema.usizeCast(block, pred_src, vec_len_u64))); | 23149 | const vec_len: u32 = @intCast(try sema.usizeCast(block, pred_src, vec_len_u64)); |
| 23140 | | 23150 | |
| 23141 | const bool_vec_ty = try mod.vectorType(.{ | 23151 | const bool_vec_ty = try mod.vectorType(.{ |
| 23142 | .len = vec_len, | 23152 | .len = vec_len, |
| ... | @@ -23504,7 +23514,7 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -23504,7 +23514,7 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 23504 | | 23514 | |
| 23505 | var resolved_args: []Air.Inst.Ref = try sema.arena.alloc(Air.Inst.Ref, args_ty.structFieldCount(mod)); | 23515 | var resolved_args: []Air.Inst.Ref = try sema.arena.alloc(Air.Inst.Ref, args_ty.structFieldCount(mod)); |
| 23506 | for (resolved_args, 0..) |*resolved, i| { | 23516 | for (resolved_args, 0..) |*resolved, i| { |
| 23507 | resolved.* = try sema.tupleFieldValByIndex(block, args_src, args, @as(u32, @intCast(i)), args_ty); | 23517 | resolved.* = try sema.tupleFieldValByIndex(block, args_src, args, @intCast(i), args_ty); |
| 23508 | } | 23518 | } |
| 23509 | | 23519 | |
| 23510 | const callee_ty = sema.typeOf(func); | 23520 | const callee_ty = sema.typeOf(func); |
| ... | @@ -23636,7 +23646,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr | ... | @@ -23636,7 +23646,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr |
| 23636 | .ty = Air.internedToRef(result_ptr.toIntern()), | 23646 | .ty = Air.internedToRef(result_ptr.toIntern()), |
| 23637 | .payload = try block.sema.addExtra(Air.FieldParentPtr{ | 23647 | .payload = try block.sema.addExtra(Air.FieldParentPtr{ |
| 23638 | .field_ptr = casted_field_ptr, | 23648 | .field_ptr = casted_field_ptr, |
| 23639 | .field_index = @as(u32, @intCast(field_index)), | 23649 | .field_index = @intCast(field_index), |
| 23640 | }), | 23650 | }), |
| 23641 | } }, | 23651 | } }, |
| 23642 | }); | 23652 | }); |
| ... | @@ -24295,7 +24305,7 @@ fn zirVarExtended( | ... | @@ -24295,7 +24305,7 @@ fn zirVarExtended( |
| 24295 | const extra = sema.code.extraData(Zir.Inst.ExtendedVar, extended.operand); | 24305 | const extra = sema.code.extraData(Zir.Inst.ExtendedVar, extended.operand); |
| 24296 | const ty_src: LazySrcLoc = .{ .node_offset_var_decl_ty = 0 }; | 24306 | const ty_src: LazySrcLoc = .{ .node_offset_var_decl_ty = 0 }; |
| 24297 | const init_src: LazySrcLoc = .{ .node_offset_var_decl_init = 0 }; | 24307 | const init_src: LazySrcLoc = .{ .node_offset_var_decl_init = 0 }; |
| 24298 | const small = @as(Zir.Inst.ExtendedVar.Small, @bitCast(extended.small)); | 24308 | const small: Zir.Inst.ExtendedVar.Small = @bitCast(extended.small); |
| 24299 | | 24309 | |
| 24300 | var extra_index: usize = extra.end; | 24310 | var extra_index: usize = extra.end; |
| 24301 | | 24311 | |
| ... | @@ -24310,7 +24320,7 @@ fn zirVarExtended( | ... | @@ -24310,7 +24320,7 @@ fn zirVarExtended( |
| 24310 | assert(!small.has_align); | 24320 | assert(!small.has_align); |
| 24311 | | 24321 | |
| 24312 | const uncasted_init: Air.Inst.Ref = if (small.has_init) blk: { | 24322 | const uncasted_init: Air.Inst.Ref = if (small.has_init) blk: { |
| 24313 | const init_ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index])); | 24323 | const init_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]); |
| 24314 | extra_index += 1; | 24324 | extra_index += 1; |
| 24315 | break :blk try sema.resolveInst(init_ref); | 24325 | break :blk try sema.resolveInst(init_ref); |
| 24316 | } else .none; | 24326 | } else .none; |
| ... | @@ -24387,7 +24397,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -24387,7 +24397,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 24387 | if (val.isGenericPoison()) { | 24397 | if (val.isGenericPoison()) { |
| 24388 | break :blk null; | 24398 | break :blk null; |
| 24389 | } | 24399 | } |
| 24390 | const alignment = @as(u32, @intCast(val.toUnsignedInt(mod))); | 24400 | const alignment: u32 = @intCast(val.toUnsignedInt(mod)); |
| 24391 | try sema.validateAlign(block, align_src, alignment); | 24401 | try sema.validateAlign(block, align_src, alignment); |
| 24392 | if (alignment == target_util.defaultFunctionAlignment(target)) { | 24402 | if (alignment == target_util.defaultFunctionAlignment(target)) { |
| 24393 | break :blk .none; | 24403 | break :blk .none; |
| ... | @@ -24395,7 +24405,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -24395,7 +24405,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 24395 | break :blk Alignment.fromNonzeroByteUnits(alignment); | 24405 | break :blk Alignment.fromNonzeroByteUnits(alignment); |
| 24396 | } | 24406 | } |
| 24397 | } else if (extra.data.bits.has_align_ref) blk: { | 24407 | } else if (extra.data.bits.has_align_ref) blk: { |
| 24398 | const align_ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index])); | 24408 | const align_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]); |
| 24399 | extra_index += 1; | 24409 | extra_index += 1; |
| 24400 | const align_tv = sema.resolveInstConst(block, align_src, align_ref, "alignment must be comptime-known") catch |err| switch (err) { | 24410 | const align_tv = sema.resolveInstConst(block, align_src, align_ref, "alignment must be comptime-known") catch |err| switch (err) { |
| 24401 | error.GenericPoison => { | 24411 | error.GenericPoison => { |
| ... | @@ -24403,7 +24413,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -24403,7 +24413,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 24403 | }, | 24413 | }, |
| 24404 | else => |e| return e, | 24414 | else => |e| return e, |
| 24405 | }; | 24415 | }; |
| 24406 | const alignment = @as(u32, @intCast(align_tv.val.toUnsignedInt(mod))); | 24416 | const alignment: u32 = @intCast(align_tv.val.toUnsignedInt(mod)); |
| 24407 | try sema.validateAlign(block, align_src, alignment); | 24417 | try sema.validateAlign(block, align_src, alignment); |
| 24408 | if (alignment == target_util.defaultFunctionAlignment(target)) { | 24418 | if (alignment == target_util.defaultFunctionAlignment(target)) { |
| 24409 | break :blk .none; | 24419 | break :blk .none; |
| ... | @@ -24425,7 +24435,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -24425,7 +24435,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 24425 | } | 24435 | } |
| 24426 | break :blk mod.toEnum(std.builtin.AddressSpace, val); | 24436 | break :blk mod.toEnum(std.builtin.AddressSpace, val); |
| 24427 | } else if (extra.data.bits.has_addrspace_ref) blk: { | 24437 | } else if (extra.data.bits.has_addrspace_ref) blk: { |
| 24428 | const addrspace_ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index])); | 24438 | const addrspace_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]); |
| 24429 | extra_index += 1; | 24439 | extra_index += 1; |
| 24430 | const addrspace_tv = sema.resolveInstConst(block, addrspace_src, addrspace_ref, "addrespace must be comptime-known") catch |err| switch (err) { | 24440 | const addrspace_tv = sema.resolveInstConst(block, addrspace_src, addrspace_ref, "addrespace must be comptime-known") catch |err| switch (err) { |
| 24431 | error.GenericPoison => { | 24441 | error.GenericPoison => { |
| ... | @@ -24449,7 +24459,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -24449,7 +24459,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 24449 | } | 24459 | } |
| 24450 | break :blk .{ .explicit = try val.toIpString(ty, mod) }; | 24460 | break :blk .{ .explicit = try val.toIpString(ty, mod) }; |
| 24451 | } else if (extra.data.bits.has_section_ref) blk: { | 24461 | } else if (extra.data.bits.has_section_ref) blk: { |
| 24452 | const section_ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index])); | 24462 | const section_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]); |
| 24453 | extra_index += 1; | 24463 | extra_index += 1; |
| 24454 | const section_name = sema.resolveConstStringIntern(block, section_src, section_ref, "linksection must be comptime-known") catch |err| switch (err) { | 24464 | const section_name = sema.resolveConstStringIntern(block, section_src, section_ref, "linksection must be comptime-known") catch |err| switch (err) { |
| 24455 | error.GenericPoison => { | 24465 | error.GenericPoison => { |
| ... | @@ -24473,7 +24483,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -24473,7 +24483,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 24473 | } | 24483 | } |
| 24474 | break :blk mod.toEnum(std.builtin.CallingConvention, val); | 24484 | break :blk mod.toEnum(std.builtin.CallingConvention, val); |
| 24475 | } else if (extra.data.bits.has_cc_ref) blk: { | 24485 | } else if (extra.data.bits.has_cc_ref) blk: { |
| 24476 | const cc_ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index])); | 24486 | const cc_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]); |
| 24477 | extra_index += 1; | 24487 | extra_index += 1; |
| 24478 | const cc_tv = sema.resolveInstConst(block, cc_src, cc_ref, "calling convention must be comptime-known") catch |err| switch (err) { | 24488 | const cc_tv = sema.resolveInstConst(block, cc_src, cc_ref, "calling convention must be comptime-known") catch |err| switch (err) { |
| 24479 | error.GenericPoison => { | 24489 | error.GenericPoison => { |
| ... | @@ -24497,7 +24507,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -24497,7 +24507,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 24497 | const ty = val.toType(); | 24507 | const ty = val.toType(); |
| 24498 | break :blk ty; | 24508 | break :blk ty; |
| 24499 | } else if (extra.data.bits.has_ret_ty_ref) blk: { | 24509 | } else if (extra.data.bits.has_ret_ty_ref) blk: { |
| 24500 | const ret_ty_ref = @as(Zir.Inst.Ref, @enumFromInt(sema.code.extra[extra_index])); | 24510 | const ret_ty_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]); |
| 24501 | extra_index += 1; | 24511 | extra_index += 1; |
| 24502 | const ret_ty_tv = sema.resolveInstConst(block, ret_src, ret_ty_ref, "return type must be comptime-known") catch |err| switch (err) { | 24512 | const ret_ty_tv = sema.resolveInstConst(block, ret_src, ret_ty_ref, "return type must be comptime-known") catch |err| switch (err) { |
| 24503 | error.GenericPoison => { | 24513 | error.GenericPoison => { |
| ... | @@ -24606,7 +24616,7 @@ fn zirWasmMemorySize( | ... | @@ -24606,7 +24616,7 @@ fn zirWasmMemorySize( |
| 24606 | return sema.fail(block, builtin_src, "builtin @wasmMemorySize is available when targeting WebAssembly; targeted CPU architecture is {s}", .{@tagName(target.cpu.arch)}); | 24616 | return sema.fail(block, builtin_src, "builtin @wasmMemorySize is available when targeting WebAssembly; targeted CPU architecture is {s}", .{@tagName(target.cpu.arch)}); |
| 24607 | } | 24617 | } |
| 24608 | | 24618 | |
| 24609 | const index = @as(u32, @intCast(try sema.resolveInt(block, index_src, extra.operand, Type.u32, "wasm memory size index must be comptime-known"))); | 24619 | const index: u32 = @intCast(try sema.resolveInt(block, index_src, extra.operand, Type.u32, "wasm memory size index must be comptime-known")); |
| 24610 | try sema.requireRuntimeBlock(block, builtin_src, null); | 24620 | try sema.requireRuntimeBlock(block, builtin_src, null); |
| 24611 | return block.addInst(.{ | 24621 | return block.addInst(.{ |
| 24612 | .tag = .wasm_memory_size, | 24622 | .tag = .wasm_memory_size, |
| ... | @@ -24631,7 +24641,7 @@ fn zirWasmMemoryGrow( | ... | @@ -24631,7 +24641,7 @@ fn zirWasmMemoryGrow( |
| 24631 | return sema.fail(block, builtin_src, "builtin @wasmMemoryGrow is available when targeting WebAssembly; targeted CPU architecture is {s}", .{@tagName(target.cpu.arch)}); | 24641 | return sema.fail(block, builtin_src, "builtin @wasmMemoryGrow is available when targeting WebAssembly; targeted CPU architecture is {s}", .{@tagName(target.cpu.arch)}); |
| 24632 | } | 24642 | } |
| 24633 | | 24643 | |
| 24634 | const index = @as(u32, @intCast(try sema.resolveInt(block, index_src, extra.lhs, Type.u32, "wasm memory size index must be comptime-known"))); | 24644 | const index: u32 = @intCast(try sema.resolveInt(block, index_src, extra.lhs, Type.u32, "wasm memory size index must be comptime-known")); |
| 24635 | const delta = try sema.coerce(block, Type.u32, try sema.resolveInst(extra.rhs), delta_src); | 24645 | const delta = try sema.coerce(block, Type.u32, try sema.resolveInst(extra.rhs), delta_src); |
| 24636 | | 24646 | |
| 24637 | try sema.requireRuntimeBlock(block, builtin_src, null); | 24647 | try sema.requireRuntimeBlock(block, builtin_src, null); |
| ... | @@ -24671,7 +24681,7 @@ fn resolvePrefetchOptions( | ... | @@ -24671,7 +24681,7 @@ fn resolvePrefetchOptions( |
| 24671 | | 24681 | |
| 24672 | return std.builtin.PrefetchOptions{ | 24682 | return std.builtin.PrefetchOptions{ |
| 24673 | .rw = mod.toEnum(std.builtin.PrefetchOptions.Rw, rw_val), | 24683 | .rw = mod.toEnum(std.builtin.PrefetchOptions.Rw, rw_val), |
| 24674 | .locality = @as(u2, @intCast(locality_val.toUnsignedInt(mod))), | 24684 | .locality = @intCast(locality_val.toUnsignedInt(mod)), |
| 24675 | .cache = mod.toEnum(std.builtin.PrefetchOptions.Cache, cache_val), | 24685 | .cache = mod.toEnum(std.builtin.PrefetchOptions.Cache, cache_val), |
| 24676 | }; | 24686 | }; |
| 24677 | } | 24687 | } |
| ... | @@ -24870,7 +24880,7 @@ fn zirWorkItem( | ... | @@ -24870,7 +24880,7 @@ fn zirWorkItem( |
| 24870 | }, | 24880 | }, |
| 24871 | } | 24881 | } |
| 24872 | | 24882 | |
| 24873 | const dimension = @as(u32, @intCast(try sema.resolveInt(block, dimension_src, extra.operand, Type.u32, "dimension must be comptime-known"))); | 24883 | const dimension: u32 = @intCast(try sema.resolveInt(block, dimension_src, extra.operand, Type.u32, "dimension must be comptime-known")); |
| 24874 | try sema.requireRuntimeBlock(block, builtin_src, null); | 24884 | try sema.requireRuntimeBlock(block, builtin_src, null); |
| 24875 | | 24885 | |
| 24876 | return block.addInst(.{ | 24886 | return block.addInst(.{ |
| ... | @@ -25412,7 +25422,7 @@ fn addSafetyCheckExtra( | ... | @@ -25412,7 +25422,7 @@ fn addSafetyCheckExtra( |
| 25412 | fail_block.instructions.items.len); | 25422 | fail_block.instructions.items.len); |
| 25413 | | 25423 | |
| 25414 | try sema.air_instructions.ensureUnusedCapacity(gpa, 3); | 25424 | try sema.air_instructions.ensureUnusedCapacity(gpa, 3); |
| 25415 | const block_inst = @as(Air.Inst.Index, @intCast(sema.air_instructions.len)); | 25425 | const block_inst: Air.Inst.Index = @intCast(sema.air_instructions.len); |
| 25416 | const cond_br_inst = block_inst + 1; | 25426 | const cond_br_inst = block_inst + 1; |
| 25417 | const br_inst = cond_br_inst + 1; | 25427 | const br_inst = cond_br_inst + 1; |
| 25418 | sema.air_instructions.appendAssumeCapacity(.{ | 25428 | sema.air_instructions.appendAssumeCapacity(.{ |
| ... | @@ -25432,7 +25442,7 @@ fn addSafetyCheckExtra( | ... | @@ -25432,7 +25442,7 @@ fn addSafetyCheckExtra( |
| 25432 | .operand = ok, | 25442 | .operand = ok, |
| 25433 | .payload = sema.addExtraAssumeCapacity(Air.CondBr{ | 25443 | .payload = sema.addExtraAssumeCapacity(Air.CondBr{ |
| 25434 | .then_body_len = 1, | 25444 | .then_body_len = 1, |
| 25435 | .else_body_len = @as(u32, @intCast(fail_block.instructions.items.len)), | 25445 | .else_body_len = @intCast(fail_block.instructions.items.len), |
| 25436 | }), | 25446 | }), |
| 25437 | } }, | 25447 | } }, |
| 25438 | }); | 25448 | }); |
| ... | @@ -25785,7 +25795,7 @@ fn fieldVal( | ... | @@ -25785,7 +25795,7 @@ fn fieldVal( |
| 25785 | try sema.resolveTypeFields(child_type); | 25795 | try sema.resolveTypeFields(child_type); |
| 25786 | if (child_type.unionTagType(mod)) |enum_ty| { | 25796 | if (child_type.unionTagType(mod)) |enum_ty| { |
| 25787 | if (enum_ty.enumFieldIndex(field_name, mod)) |field_index_usize| { | 25797 | if (enum_ty.enumFieldIndex(field_name, mod)) |field_index_usize| { |
| 25788 | const field_index = @as(u32, @intCast(field_index_usize)); | 25798 | const field_index: u32 = @intCast(field_index_usize); |
| 25789 | return Air.internedToRef((try mod.enumValueFieldIndex(enum_ty, field_index)).toIntern()); | 25799 | return Air.internedToRef((try mod.enumValueFieldIndex(enum_ty, field_index)).toIntern()); |
| 25790 | } | 25800 | } |
| 25791 | } | 25801 | } |
| ... | @@ -25799,7 +25809,7 @@ fn fieldVal( | ... | @@ -25799,7 +25809,7 @@ fn fieldVal( |
| 25799 | } | 25809 | } |
| 25800 | const field_index_usize = child_type.enumFieldIndex(field_name, mod) orelse | 25810 | const field_index_usize = child_type.enumFieldIndex(field_name, mod) orelse |
| 25801 | return sema.failWithBadMemberAccess(block, child_type, field_name_src, field_name); | 25811 | return sema.failWithBadMemberAccess(block, child_type, field_name_src, field_name); |
| 25802 | const field_index = @as(u32, @intCast(field_index_usize)); | 25812 | const field_index: u32 = @intCast(field_index_usize); |
| 25803 | const enum_val = try mod.enumValueFieldIndex(child_type, field_index); | 25813 | const enum_val = try mod.enumValueFieldIndex(child_type, field_index); |
| 25804 | return Air.internedToRef(enum_val.toIntern()); | 25814 | return Air.internedToRef(enum_val.toIntern()); |
| 25805 | }, | 25815 | }, |
| ... | @@ -26011,7 +26021,7 @@ fn fieldPtr( | ... | @@ -26011,7 +26021,7 @@ fn fieldPtr( |
| 26011 | try sema.resolveTypeFields(child_type); | 26021 | try sema.resolveTypeFields(child_type); |
| 26012 | if (child_type.unionTagType(mod)) |enum_ty| { | 26022 | if (child_type.unionTagType(mod)) |enum_ty| { |
| 26013 | if (enum_ty.enumFieldIndex(field_name, mod)) |field_index| { | 26023 | if (enum_ty.enumFieldIndex(field_name, mod)) |field_index| { |
| 26014 | const field_index_u32 = @as(u32, @intCast(field_index)); | 26024 | const field_index_u32: u32 = @intCast(field_index); |
| 26015 | var anon_decl = try block.startAnonDecl(); | 26025 | var anon_decl = try block.startAnonDecl(); |
| 26016 | defer anon_decl.deinit(); | 26026 | defer anon_decl.deinit(); |
| 26017 | return sema.analyzeDeclRef(try anon_decl.finish( | 26027 | return sema.analyzeDeclRef(try anon_decl.finish( |
| ... | @@ -26032,7 +26042,7 @@ fn fieldPtr( | ... | @@ -26032,7 +26042,7 @@ fn fieldPtr( |
| 26032 | const field_index = child_type.enumFieldIndex(field_name, mod) orelse { | 26042 | const field_index = child_type.enumFieldIndex(field_name, mod) orelse { |
| 26033 | return sema.failWithBadMemberAccess(block, child_type, field_name_src, field_name); | 26043 | return sema.failWithBadMemberAccess(block, child_type, field_name_src, field_name); |
| 26034 | }; | 26044 | }; |
| 26035 | const field_index_u32 = @as(u32, @intCast(field_index)); | 26045 | const field_index_u32: u32 = @intCast(field_index); |
| 26036 | var anon_decl = try block.startAnonDecl(); | 26046 | var anon_decl = try block.startAnonDecl(); |
| 26037 | defer anon_decl.deinit(); | 26047 | defer anon_decl.deinit(); |
| 26038 | return sema.analyzeDeclRef(try anon_decl.finish( | 26048 | return sema.analyzeDeclRef(try anon_decl.finish( |
| ... | @@ -26117,7 +26127,7 @@ fn fieldCallBind( | ... | @@ -26117,7 +26127,7 @@ fn fieldCallBind( |
| 26117 | if (mod.typeToStruct(concrete_ty)) |struct_obj| { | 26127 | if (mod.typeToStruct(concrete_ty)) |struct_obj| { |
| 26118 | const field_index_usize = struct_obj.fields.getIndex(field_name) orelse | 26128 | const field_index_usize = struct_obj.fields.getIndex(field_name) orelse |
| 26119 | break :find_field; | 26129 | break :find_field; |
| 26120 | const field_index = @as(u32, @intCast(field_index_usize)); | 26130 | const field_index: u32 = @intCast(field_index_usize); |
| 26121 | const field = struct_obj.fields.values()[field_index]; | 26131 | const field = struct_obj.fields.values()[field_index]; |
| 26122 | | 26132 | |
| 26123 | return sema.finishFieldCallBind(block, src, ptr_ty, field.ty, field_index, object_ptr); | 26133 | return sema.finishFieldCallBind(block, src, ptr_ty, field.ty, field_index, object_ptr); |
| ... | @@ -26132,7 +26142,7 @@ fn fieldCallBind( | ... | @@ -26132,7 +26142,7 @@ fn fieldCallBind( |
| 26132 | } else { | 26142 | } else { |
| 26133 | const max = concrete_ty.structFieldCount(mod); | 26143 | const max = concrete_ty.structFieldCount(mod); |
| 26134 | for (0..max) |i_usize| { | 26144 | for (0..max) |i_usize| { |
| 26135 | const i = @as(u32, @intCast(i_usize)); | 26145 | const i: u32 = @intCast(i_usize); |
| 26136 | if (field_name == concrete_ty.structFieldName(i, mod)) { | 26146 | if (field_name == concrete_ty.structFieldName(i, mod)) { |
| 26137 | return sema.finishFieldCallBind(block, src, ptr_ty, concrete_ty.structFieldType(i, mod), i, object_ptr); | 26147 | return sema.finishFieldCallBind(block, src, ptr_ty, concrete_ty.structFieldType(i, mod), i, object_ptr); |
| 26138 | } | 26148 | } |
| ... | @@ -26364,7 +26374,7 @@ fn structFieldPtr( | ... | @@ -26364,7 +26374,7 @@ fn structFieldPtr( |
| 26364 | | 26374 | |
| 26365 | const field_index_big = struct_obj.fields.getIndex(field_name) orelse | 26375 | const field_index_big = struct_obj.fields.getIndex(field_name) orelse |
| 26366 | return sema.failWithBadStructFieldAccess(block, struct_obj, field_name_src, field_name); | 26376 | return sema.failWithBadStructFieldAccess(block, struct_obj, field_name_src, field_name); |
| 26367 | const field_index = @as(u32, @intCast(field_index_big)); | 26377 | const field_index: u32 = @intCast(field_index_big); |
| 26368 | | 26378 | |
| 26369 | return sema.structFieldPtrByIndex(block, src, struct_ptr, field_index, field_name_src, struct_ty, initializing); | 26379 | return sema.structFieldPtrByIndex(block, src, struct_ptr, field_index, field_name_src, struct_ty, initializing); |
| 26370 | } | 26380 | } |
| ... | @@ -26413,7 +26423,7 @@ fn structFieldPtrByIndex( | ... | @@ -26413,7 +26423,7 @@ fn structFieldPtrByIndex( |
| 26413 | if (i == field_index) { | 26423 | if (i == field_index) { |
| 26414 | ptr_ty_data.packed_offset.bit_offset = running_bits; | 26424 | ptr_ty_data.packed_offset.bit_offset = running_bits; |
| 26415 | } | 26425 | } |
| 26416 | running_bits += @as(u16, @intCast(f.ty.bitSize(mod))); | 26426 | running_bits += @intCast(f.ty.bitSize(mod)); |
| 26417 | } | 26427 | } |
| 26418 | ptr_ty_data.packed_offset.host_size = (running_bits + 7) / 8; | 26428 | ptr_ty_data.packed_offset.host_size = (running_bits + 7) / 8; |
| 26419 | | 26429 | |
| ... | @@ -26441,7 +26451,7 @@ fn structFieldPtrByIndex( | ... | @@ -26441,7 +26451,7 @@ fn structFieldPtrByIndex( |
| 26441 | const elem_size_bits = ptr_ty_data.child.toType().bitSize(mod); | 26451 | const elem_size_bits = ptr_ty_data.child.toType().bitSize(mod); |
| 26442 | if (elem_size_bytes * 8 == elem_size_bits) { | 26452 | if (elem_size_bytes * 8 == elem_size_bits) { |
| 26443 | const byte_offset = ptr_ty_data.packed_offset.bit_offset / 8; | 26453 | const byte_offset = ptr_ty_data.packed_offset.bit_offset / 8; |
| 26444 | const new_align = @as(Alignment, @enumFromInt(@ctz(byte_offset | parent_align))); | 26454 | const new_align: Alignment = @enumFromInt(@ctz(byte_offset | parent_align)); |
| 26445 | assert(new_align != .none); | 26455 | assert(new_align != .none); |
| 26446 | ptr_ty_data.flags.alignment = new_align; | 26456 | ptr_ty_data.flags.alignment = new_align; |
| 26447 | ptr_ty_data.packed_offset = .{ .host_size = 0, .bit_offset = 0 }; | 26457 | ptr_ty_data.packed_offset = .{ .host_size = 0, .bit_offset = 0 }; |
| ... | @@ -26505,7 +26515,7 @@ fn structFieldVal( | ... | @@ -26505,7 +26515,7 @@ fn structFieldVal( |
| 26505 | | 26515 | |
| 26506 | const field_index_usize = struct_obj.fields.getIndex(field_name) orelse | 26516 | const field_index_usize = struct_obj.fields.getIndex(field_name) orelse |
| 26507 | return sema.failWithBadStructFieldAccess(block, struct_obj, field_name_src, field_name); | 26517 | return sema.failWithBadStructFieldAccess(block, struct_obj, field_name_src, field_name); |
| 26508 | const field_index = @as(u32, @intCast(field_index_usize)); | 26518 | const field_index: u32 = @intCast(field_index_usize); |
| 26509 | const field = struct_obj.fields.values()[field_index]; | 26519 | const field = struct_obj.fields.values()[field_index]; |
| 26510 | | 26520 | |
| 26511 | if (field.is_comptime) { | 26521 | if (field.is_comptime) { |
| ... | @@ -26815,7 +26825,7 @@ fn elemPtr( | ... | @@ -26815,7 +26825,7 @@ fn elemPtr( |
| 26815 | .Struct => { | 26825 | .Struct => { |
| 26816 | // Tuple field access. | 26826 | // Tuple field access. |
| 26817 | const index_val = try sema.resolveConstValue(block, elem_index_src, elem_index, "tuple field access index must be comptime-known"); | 26827 | const index_val = try sema.resolveConstValue(block, elem_index_src, elem_index, "tuple field access index must be comptime-known"); |
| 26818 | const index = @as(u32, @intCast(index_val.toUnsignedInt(mod))); | 26828 | const index: u32 = @intCast(index_val.toUnsignedInt(mod)); |
| 26819 | return sema.tupleFieldPtr(block, src, indexable_ptr, elem_index_src, index, init); | 26829 | return sema.tupleFieldPtr(block, src, indexable_ptr, elem_index_src, index, init); |
| 26820 | }, | 26830 | }, |
| 26821 | else => { | 26831 | else => { |
| ... | @@ -26850,7 +26860,7 @@ fn elemPtrOneLayerOnly( | ... | @@ -26850,7 +26860,7 @@ fn elemPtrOneLayerOnly( |
| 26850 | const runtime_src = rs: { | 26860 | const runtime_src = rs: { |
| 26851 | const ptr_val = maybe_ptr_val orelse break :rs indexable_src; | 26861 | const ptr_val = maybe_ptr_val orelse break :rs indexable_src; |
| 26852 | const index_val = maybe_index_val orelse break :rs elem_index_src; | 26862 | const index_val = maybe_index_val orelse break :rs elem_index_src; |
| 26853 | const index = @as(usize, @intCast(index_val.toUnsignedInt(mod))); | 26863 | const index: usize = @intCast(index_val.toUnsignedInt(mod)); |
| 26854 | const result_ty = try sema.elemPtrType(indexable_ty, index); | 26864 | const result_ty = try sema.elemPtrType(indexable_ty, index); |
| 26855 | const elem_ptr = try ptr_val.elemPtr(result_ty, index, mod); | 26865 | const elem_ptr = try ptr_val.elemPtr(result_ty, index, mod); |
| 26856 | return Air.internedToRef(elem_ptr.toIntern()); | 26866 | return Air.internedToRef(elem_ptr.toIntern()); |
| ... | @@ -26869,7 +26879,7 @@ fn elemPtrOneLayerOnly( | ... | @@ -26869,7 +26879,7 @@ fn elemPtrOneLayerOnly( |
| 26869 | .Struct => { | 26879 | .Struct => { |
| 26870 | assert(child_ty.isTuple(mod)); | 26880 | assert(child_ty.isTuple(mod)); |
| 26871 | const index_val = try sema.resolveConstValue(block, elem_index_src, elem_index, "tuple field access index must be comptime-known"); | 26881 | const index_val = try sema.resolveConstValue(block, elem_index_src, elem_index, "tuple field access index must be comptime-known"); |
| 26872 | const index = @as(u32, @intCast(index_val.toUnsignedInt(mod))); | 26882 | const index: u32 = @intCast(index_val.toUnsignedInt(mod)); |
| 26873 | return sema.tupleFieldPtr(block, indexable_src, indexable, elem_index_src, index, false); | 26883 | return sema.tupleFieldPtr(block, indexable_src, indexable, elem_index_src, index, false); |
| 26874 | }, | 26884 | }, |
| 26875 | else => unreachable, // Guaranteed by checkIndexable | 26885 | else => unreachable, // Guaranteed by checkIndexable |
| ... | @@ -26907,7 +26917,7 @@ fn elemVal( | ... | @@ -26907,7 +26917,7 @@ fn elemVal( |
| 26907 | const runtime_src = rs: { | 26917 | const runtime_src = rs: { |
| 26908 | const indexable_val = maybe_indexable_val orelse break :rs indexable_src; | 26918 | const indexable_val = maybe_indexable_val orelse break :rs indexable_src; |
| 26909 | const index_val = maybe_index_val orelse break :rs elem_index_src; | 26919 | const index_val = maybe_index_val orelse break :rs elem_index_src; |
| 26910 | const index = @as(usize, @intCast(index_val.toUnsignedInt(mod))); | 26920 | const index: usize = @intCast(index_val.toUnsignedInt(mod)); |
| 26911 | const elem_ty = indexable_ty.elemType2(mod); | 26921 | const elem_ty = indexable_ty.elemType2(mod); |
| 26912 | const many_ptr_ty = try mod.manyConstPtrType(elem_ty); | 26922 | const many_ptr_ty = try mod.manyConstPtrType(elem_ty); |
| 26913 | const many_ptr_val = try mod.getCoerced(indexable_val, many_ptr_ty); | 26923 | const many_ptr_val = try mod.getCoerced(indexable_val, many_ptr_ty); |
| ... | @@ -26944,7 +26954,7 @@ fn elemVal( | ... | @@ -26944,7 +26954,7 @@ fn elemVal( |
| 26944 | .Struct => { | 26954 | .Struct => { |
| 26945 | // Tuple field access. | 26955 | // Tuple field access. |
| 26946 | const index_val = try sema.resolveConstValue(block, elem_index_src, elem_index, "tuple field access index must be comptime-known"); | 26956 | const index_val = try sema.resolveConstValue(block, elem_index_src, elem_index, "tuple field access index must be comptime-known"); |
| 26947 | const index = @as(u32, @intCast(index_val.toUnsignedInt(mod))); | 26957 | const index: u32 = @intCast(index_val.toUnsignedInt(mod)); |
| 26948 | return sema.tupleField(block, indexable_src, indexable, elem_index_src, index); | 26958 | return sema.tupleField(block, indexable_src, indexable, elem_index_src, index); |
| 26949 | }, | 26959 | }, |
| 26950 | else => unreachable, | 26960 | else => unreachable, |
| ... | @@ -27105,7 +27115,7 @@ fn elemValArray( | ... | @@ -27105,7 +27115,7 @@ fn elemValArray( |
| 27105 | const maybe_index_val = try sema.resolveDefinedValue(block, elem_index_src, elem_index); | 27115 | const maybe_index_val = try sema.resolveDefinedValue(block, elem_index_src, elem_index); |
| 27106 | | 27116 | |
| 27107 | if (maybe_index_val) |index_val| { | 27117 | if (maybe_index_val) |index_val| { |
| 27108 | const index = @as(usize, @intCast(index_val.toUnsignedInt(mod))); | 27118 | const index: usize = @intCast(index_val.toUnsignedInt(mod)); |
| 27109 | if (array_sent) |s| { | 27119 | if (array_sent) |s| { |
| 27110 | if (index == array_len) { | 27120 | if (index == array_len) { |
| 27111 | return Air.internedToRef(s.toIntern()); | 27121 | return Air.internedToRef(s.toIntern()); |
| ... | @@ -27121,7 +27131,7 @@ fn elemValArray( | ... | @@ -27121,7 +27131,7 @@ fn elemValArray( |
| 27121 | return mod.undefRef(elem_ty); | 27131 | return mod.undefRef(elem_ty); |
| 27122 | } | 27132 | } |
| 27123 | if (maybe_index_val) |index_val| { | 27133 | if (maybe_index_val) |index_val| { |
| 27124 | const index = @as(usize, @intCast(index_val.toUnsignedInt(mod))); | 27134 | const index: usize = @intCast(index_val.toUnsignedInt(mod)); |
| 27125 | const elem_val = try array_val.elemValue(mod, index); | 27135 | const elem_val = try array_val.elemValue(mod, index); |
| 27126 | return Air.internedToRef(elem_val.toIntern()); | 27136 | return Air.internedToRef(elem_val.toIntern()); |
| 27127 | } | 27137 | } |
| ... | @@ -27234,7 +27244,7 @@ fn elemValSlice( | ... | @@ -27234,7 +27244,7 @@ fn elemValSlice( |
| 27234 | return sema.fail(block, slice_src, "indexing into empty slice is not allowed", .{}); | 27244 | return sema.fail(block, slice_src, "indexing into empty slice is not allowed", .{}); |
| 27235 | } | 27245 | } |
| 27236 | if (maybe_index_val) |index_val| { | 27246 | if (maybe_index_val) |index_val| { |
| 27237 | const index = @as(usize, @intCast(index_val.toUnsignedInt(mod))); | 27247 | const index: usize = @intCast(index_val.toUnsignedInt(mod)); |
| 27238 | if (index >= slice_len_s) { | 27248 | if (index >= slice_len_s) { |
| 27239 | const sentinel_label: []const u8 = if (slice_sent) " +1 (sentinel)" else ""; | 27249 | const sentinel_label: []const u8 = if (slice_sent) " +1 (sentinel)" else ""; |
| 27240 | return sema.fail(block, elem_index_src, "index {d} outside slice of length {d}{s}", .{ index, slice_len, sentinel_label }); | 27250 | return sema.fail(block, elem_index_src, "index {d} outside slice of length {d}{s}", .{ index, slice_len, sentinel_label }); |
| ... | @@ -27878,7 +27888,7 @@ fn coerceExtra( | ... | @@ -27878,7 +27888,7 @@ fn coerceExtra( |
| 27878 | }; | 27888 | }; |
| 27879 | return sema.failWithOwnedErrorMsg(msg); | 27889 | return sema.failWithOwnedErrorMsg(msg); |
| 27880 | }; | 27890 | }; |
| 27881 | return Air.internedToRef((try mod.enumValueFieldIndex(dest_ty, @as(u32, @intCast(field_index)))).toIntern()); | 27891 | return Air.internedToRef((try mod.enumValueFieldIndex(dest_ty, @intCast(field_index))).toIntern()); |
| 27882 | }, | 27892 | }, |
| 27883 | .Union => blk: { | 27893 | .Union => blk: { |
| 27884 | // union to its own tag type | 27894 | // union to its own tag type |
| ... | @@ -28282,8 +28292,8 @@ const InMemoryCoercionResult = union(enum) { | ... | @@ -28282,8 +28292,8 @@ const InMemoryCoercionResult = union(enum) { |
| 28282 | var index: u6 = 0; | 28292 | var index: u6 = 0; |
| 28283 | var actual_noalias = false; | 28293 | var actual_noalias = false; |
| 28284 | while (true) : (index += 1) { | 28294 | while (true) : (index += 1) { |
| 28285 | const actual = @as(u1, @truncate(param.actual >> index)); | 28295 | const actual: u1 = @truncate(param.actual >> index); |
| 28286 | const wanted = @as(u1, @truncate(param.wanted >> index)); | 28296 | const wanted: u1 = @truncate(param.wanted >> index); |
| 28287 | if (actual != wanted) { | 28297 | if (actual != wanted) { |
| 28288 | actual_noalias = actual == 1; | 28298 | actual_noalias = actual == 1; |
| 28289 | break; | 28299 | break; |
| ... | @@ -29446,7 +29456,7 @@ fn beginComptimePtrMutation( | ... | @@ -29446,7 +29456,7 @@ fn beginComptimePtrMutation( |
| 29446 | // bytes.len may be one greater than dest_len because of the case when | 29456 | // bytes.len may be one greater than dest_len because of the case when |
| 29447 | // assigning `[N:S]T` to `[N]T`. This is allowed; the sentinel is omitted. | 29457 | // assigning `[N:S]T` to `[N]T`. This is allowed; the sentinel is omitted. |
| 29448 | assert(bytes.len >= dest_len); | 29458 | assert(bytes.len >= dest_len); |
| 29449 | const elems = try arena.alloc(Value, @as(usize, @intCast(dest_len))); | 29459 | const elems = try arena.alloc(Value, @intCast(dest_len)); |
| 29450 | for (elems, 0..) |*elem, i| { | 29460 | for (elems, 0..) |*elem, i| { |
| 29451 | elem.* = try mod.intValue(elem_ty, bytes[i]); | 29461 | elem.* = try mod.intValue(elem_ty, bytes[i]); |
| 29452 | } | 29462 | } |
| ... | @@ -29458,7 +29468,7 @@ fn beginComptimePtrMutation( | ... | @@ -29458,7 +29468,7 @@ fn beginComptimePtrMutation( |
| 29458 | block, | 29468 | block, |
| 29459 | src, | 29469 | src, |
| 29460 | elem_ty, | 29470 | elem_ty, |
| 29461 | &elems[@as(usize, @intCast(elem_ptr.index))], | 29471 | &elems[@intCast(elem_ptr.index)], |
| 29462 | ptr_elem_ty, | 29472 | ptr_elem_ty, |
| 29463 | parent.mut_decl, | 29473 | parent.mut_decl, |
| 29464 | ); | 29474 | ); |
| ... | @@ -29486,7 +29496,7 @@ fn beginComptimePtrMutation( | ... | @@ -29486,7 +29496,7 @@ fn beginComptimePtrMutation( |
| 29486 | block, | 29496 | block, |
| 29487 | src, | 29497 | src, |
| 29488 | elem_ty, | 29498 | elem_ty, |
| 29489 | &elems[@as(usize, @intCast(elem_ptr.index))], | 29499 | &elems[@intCast(elem_ptr.index)], |
| 29490 | ptr_elem_ty, | 29500 | ptr_elem_ty, |
| 29491 | parent.mut_decl, | 29501 | parent.mut_decl, |
| 29492 | ); | 29502 | ); |
| ... | @@ -29497,7 +29507,7 @@ fn beginComptimePtrMutation( | ... | @@ -29497,7 +29507,7 @@ fn beginComptimePtrMutation( |
| 29497 | block, | 29507 | block, |
| 29498 | src, | 29508 | src, |
| 29499 | elem_ty, | 29509 | elem_ty, |
| 29500 | &val_ptr.castTag(.aggregate).?.data[@as(usize, @intCast(elem_ptr.index))], | 29510 | &val_ptr.castTag(.aggregate).?.data[@intCast(elem_ptr.index)], |
| 29501 | ptr_elem_ty, | 29511 | ptr_elem_ty, |
| 29502 | parent.mut_decl, | 29512 | parent.mut_decl, |
| 29503 | ), | 29513 | ), |
| ... | @@ -29523,7 +29533,7 @@ fn beginComptimePtrMutation( | ... | @@ -29523,7 +29533,7 @@ fn beginComptimePtrMutation( |
| 29523 | block, | 29533 | block, |
| 29524 | src, | 29534 | src, |
| 29525 | elem_ty, | 29535 | elem_ty, |
| 29526 | &elems[@as(usize, @intCast(elem_ptr.index))], | 29536 | &elems[@intCast(elem_ptr.index)], |
| 29527 | ptr_elem_ty, | 29537 | ptr_elem_ty, |
| 29528 | parent.mut_decl, | 29538 | parent.mut_decl, |
| 29529 | ); | 29539 | ); |
| ... | @@ -29578,7 +29588,7 @@ fn beginComptimePtrMutation( | ... | @@ -29578,7 +29588,7 @@ fn beginComptimePtrMutation( |
| 29578 | }, | 29588 | }, |
| 29579 | .field => |field_ptr| { | 29589 | .field => |field_ptr| { |
| 29580 | const base_child_ty = mod.intern_pool.typeOf(field_ptr.base).toType().childType(mod); | 29590 | const base_child_ty = mod.intern_pool.typeOf(field_ptr.base).toType().childType(mod); |
| 29581 | const field_index = @as(u32, @intCast(field_ptr.index)); | 29591 | const field_index: u32 = @intCast(field_ptr.index); |
| 29582 | | 29592 | |
| 29583 | var parent = try sema.beginComptimePtrMutation(block, src, field_ptr.base.toValue(), base_child_ty); | 29593 | var parent = try sema.beginComptimePtrMutation(block, src, field_ptr.base.toValue(), base_child_ty); |
| 29584 | switch (parent.pointee) { | 29594 | switch (parent.pointee) { |
| ... | @@ -30015,12 +30025,12 @@ fn beginComptimePtrLoad( | ... | @@ -30015,12 +30025,12 @@ fn beginComptimePtrLoad( |
| 30015 | } | 30025 | } |
| 30016 | deref.pointee = TypedValue{ | 30026 | deref.pointee = TypedValue{ |
| 30017 | .ty = elem_ty, | 30027 | .ty = elem_ty, |
| 30018 | .val = try array_tv.val.elemValue(mod, @as(usize, @intCast(elem_ptr.index))), | 30028 | .val = try array_tv.val.elemValue(mod, @intCast(elem_ptr.index)), |
| 30019 | }; | 30029 | }; |
| 30020 | break :blk deref; | 30030 | break :blk deref; |
| 30021 | }, | 30031 | }, |
| 30022 | .field => |field_ptr| blk: { | 30032 | .field => |field_ptr| blk: { |
| 30023 | const field_index = @as(u32, @intCast(field_ptr.index)); | 30033 | const field_index: u32 = @intCast(field_ptr.index); |
| 30024 | const container_ty = mod.intern_pool.typeOf(field_ptr.base).toType().childType(mod); | 30034 | const container_ty = mod.intern_pool.typeOf(field_ptr.base).toType().childType(mod); |
| 30025 | var deref = try sema.beginComptimePtrLoad(block, src, field_ptr.base.toValue(), container_ty); | 30035 | var deref = try sema.beginComptimePtrLoad(block, src, field_ptr.base.toValue(), container_ty); |
| 30026 | | 30036 | |
| ... | @@ -30602,7 +30612,7 @@ fn coerceTupleToArray( | ... | @@ -30602,7 +30612,7 @@ fn coerceTupleToArray( |
| 30602 | | 30612 | |
| 30603 | var runtime_src: ?LazySrcLoc = null; | 30613 | var runtime_src: ?LazySrcLoc = null; |
| 30604 | for (element_vals, element_refs, 0..) |*val, *ref, i_usize| { | 30614 | for (element_vals, element_refs, 0..) |*val, *ref, i_usize| { |
| 30605 | const i = @as(u32, @intCast(i_usize)); | 30615 | const i: u32 = @intCast(i_usize); |
| 30606 | if (i_usize == inst_len) { | 30616 | if (i_usize == inst_len) { |
| 30607 | const sentinel_val = dest_ty.sentinel(mod).?; | 30617 | const sentinel_val = dest_ty.sentinel(mod).?; |
| 30608 | val.* = sentinel_val.toIntern(); | 30618 | val.* = sentinel_val.toIntern(); |
| ... | @@ -30713,7 +30723,7 @@ fn coerceTupleToStruct( | ... | @@ -30713,7 +30723,7 @@ fn coerceTupleToStruct( |
| 30713 | else => unreachable, | 30723 | else => unreachable, |
| 30714 | }; | 30724 | }; |
| 30715 | for (0..field_count) |field_index_usize| { | 30725 | for (0..field_count) |field_index_usize| { |
| 30716 | const field_i = @as(u32, @intCast(field_index_usize)); | 30726 | const field_i: u32 = @intCast(field_index_usize); |
| 30717 | const field_src = inst_src; // TODO better source location | 30727 | const field_src = inst_src; // TODO better source location |
| 30718 | // https://github.com/ziglang/zig/issues/15709 | 30728 | // https://github.com/ziglang/zig/issues/15709 |
| 30719 | const field_name: InternPool.NullTerminatedString = switch (ip.indexToKey(inst_ty.toIntern())) { | 30729 | const field_name: InternPool.NullTerminatedString = switch (ip.indexToKey(inst_ty.toIntern())) { |
| ... | @@ -30829,7 +30839,7 @@ fn coerceTupleToTuple( | ... | @@ -30829,7 +30839,7 @@ fn coerceTupleToTuple( |
| 30829 | | 30839 | |
| 30830 | var runtime_src: ?LazySrcLoc = null; | 30840 | var runtime_src: ?LazySrcLoc = null; |
| 30831 | for (0..dest_field_count) |field_index_usize| { | 30841 | for (0..dest_field_count) |field_index_usize| { |
| 30832 | const field_i = @as(u32, @intCast(field_index_usize)); | 30842 | const field_i: u32 = @intCast(field_index_usize); |
| 30833 | const field_src = inst_src; // TODO better source location | 30843 | const field_src = inst_src; // TODO better source location |
| 30834 | // https://github.com/ziglang/zig/issues/15709 | 30844 | // https://github.com/ziglang/zig/issues/15709 |
| 30835 | const field_name: InternPool.NullTerminatedString = switch (ip.indexToKey(inst_ty.toIntern())) { | 30845 | const field_name: InternPool.NullTerminatedString = switch (ip.indexToKey(inst_ty.toIntern())) { |
| ... | @@ -32185,7 +32195,7 @@ fn compareIntsOnlyPossibleResult( | ... | @@ -32185,7 +32195,7 @@ fn compareIntsOnlyPossibleResult( |
| 32185 | | 32195 | |
| 32186 | const ty = try mod.intType( | 32196 | const ty = try mod.intType( |
| 32187 | if (is_negative) .signed else .unsigned, | 32197 | if (is_negative) .signed else .unsigned, |
| 32188 | @as(u16, @intCast(req_bits)), | 32198 | @intCast(req_bits), |
| 32189 | ); | 32199 | ); |
| 32190 | const pop_count = lhs_val.popCount(ty, mod); | 32200 | const pop_count = lhs_val.popCount(ty, mod); |
| 32191 | | 32201 | |
| ... | @@ -32960,7 +32970,7 @@ fn resolvePeerTypesInner( | ... | @@ -32960,7 +32970,7 @@ fn resolvePeerTypesInner( |
| 32960 | }; | 32970 | }; |
| 32961 | | 32971 | |
| 32962 | return .{ .success = try mod.vectorType(.{ | 32972 | return .{ .success = try mod.vectorType(.{ |
| 32963 | .len = @as(u32, @intCast(len.?)), | 32973 | .len = @intCast(len.?), |
| 32964 | .child = child_ty.toIntern(), | 32974 | .child = child_ty.toIntern(), |
| 32965 | }) }; | 32975 | }) }; |
| 32966 | }, | 32976 | }, |
| ... | @@ -34090,7 +34100,7 @@ fn resolveStructLayout(sema: *Sema, ty: Type) CompileError!void { | ... | @@ -34090,7 +34100,7 @@ fn resolveStructLayout(sema: *Sema, ty: Type) CompileError!void { |
| 34090 | | 34100 | |
| 34091 | for (struct_obj.fields.values(), 0..) |field, i| { | 34101 | for (struct_obj.fields.values(), 0..) |field, i| { |
| 34092 | optimized_order[i] = if (try sema.typeHasRuntimeBits(field.ty)) | 34102 | optimized_order[i] = if (try sema.typeHasRuntimeBits(field.ty)) |
| 34093 | @as(u32, @intCast(i)) | 34103 | @intCast(i) |
| 34094 | else | 34104 | else |
| 34095 | Module.Struct.omitted_field; | 34105 | Module.Struct.omitted_field; |
| 34096 | } | 34106 | } |
| ... | @@ -34131,7 +34141,7 @@ fn semaBackingIntType(mod: *Module, struct_obj: *Module.Struct) CompileError!voi | ... | @@ -34131,7 +34141,7 @@ fn semaBackingIntType(mod: *Module, struct_obj: *Module.Struct) CompileError!voi |
| 34131 | const zir = mod.namespacePtr(struct_obj.namespace).file_scope.zir; | 34141 | const zir = mod.namespacePtr(struct_obj.namespace).file_scope.zir; |
| 34132 | const extended = zir.instructions.items(.data)[struct_obj.zir_index].extended; | 34142 | const extended = zir.instructions.items(.data)[struct_obj.zir_index].extended; |
| 34133 | assert(extended.opcode == .struct_decl); | 34143 | assert(extended.opcode == .struct_decl); |
| 34134 | const small = @as(Zir.Inst.StructDecl.Small, @bitCast(extended.small)); | 34144 | const small: Zir.Inst.StructDecl.Small = @bitCast(extended.small); |
| 34135 | | 34145 | |
| 34136 | if (small.has_backing_int) { | 34146 | if (small.has_backing_int) { |
| 34137 | var extra_index: usize = extended.operand; | 34147 | var extra_index: usize = extended.operand; |
| ... | @@ -34182,7 +34192,7 @@ fn semaBackingIntType(mod: *Module, struct_obj: *Module.Struct) CompileError!voi | ... | @@ -34182,7 +34192,7 @@ fn semaBackingIntType(mod: *Module, struct_obj: *Module.Struct) CompileError!voi |
| 34182 | const backing_int_src: LazySrcLoc = .{ .node_offset_container_tag = 0 }; | 34192 | const backing_int_src: LazySrcLoc = .{ .node_offset_container_tag = 0 }; |
| 34183 | const backing_int_ty = blk: { | 34193 | const backing_int_ty = blk: { |
| 34184 | if (backing_int_body_len == 0) { | 34194 | if (backing_int_body_len == 0) { |
| 34185 | const backing_int_ref = @as(Zir.Inst.Ref, @enumFromInt(zir.extra[extra_index])); | 34195 | const backing_int_ref: Zir.Inst.Ref = @enumFromInt(zir.extra[extra_index]); |
| 34186 | break :blk try sema.resolveType(&block, backing_int_src, backing_int_ref); | 34196 | break :blk try sema.resolveType(&block, backing_int_src, backing_int_ref); |
| 34187 | } else { | 34197 | } else { |
| 34188 | const body = zir.extra[extra_index..][0..backing_int_body_len]; | 34198 | const body = zir.extra[extra_index..][0..backing_int_body_len]; |
| ... | @@ -34228,7 +34238,7 @@ fn semaBackingIntType(mod: *Module, struct_obj: *Module.Struct) CompileError!voi | ... | @@ -34228,7 +34238,7 @@ fn semaBackingIntType(mod: *Module, struct_obj: *Module.Struct) CompileError!voi |
| 34228 | }; | 34238 | }; |
| 34229 | return sema.fail(&block, LazySrcLoc.nodeOffset(0), "size of packed struct '{d}' exceeds maximum bit width of 65535", .{fields_bit_sum}); | 34239 | return sema.fail(&block, LazySrcLoc.nodeOffset(0), "size of packed struct '{d}' exceeds maximum bit width of 65535", .{fields_bit_sum}); |
| 34230 | } | 34240 | } |
| 34231 | struct_obj.backing_int_ty = try mod.intType(.unsigned, @as(u16, @intCast(fields_bit_sum))); | 34241 | struct_obj.backing_int_ty = try mod.intType(.unsigned, @intCast(fields_bit_sum)); |
| 34232 | } | 34242 | } |
| 34233 | } | 34243 | } |
| 34234 | | 34244 | |
| ... | @@ -34789,7 +34799,7 @@ fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void | ... | @@ -34789,7 +34799,7 @@ fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void |
| 34789 | const zir = mod.namespacePtr(struct_obj.namespace).file_scope.zir; | 34799 | const zir = mod.namespacePtr(struct_obj.namespace).file_scope.zir; |
| 34790 | const extended = zir.instructions.items(.data)[struct_obj.zir_index].extended; | 34800 | const extended = zir.instructions.items(.data)[struct_obj.zir_index].extended; |
| 34791 | assert(extended.opcode == .struct_decl); | 34801 | assert(extended.opcode == .struct_decl); |
| 34792 | const small = @as(Zir.Inst.StructDecl.Small, @bitCast(extended.small)); | 34802 | const small: Zir.Inst.StructDecl.Small = @bitCast(extended.small); |
| 34793 | var extra_index: usize = extended.operand; | 34803 | var extra_index: usize = extended.operand; |
| 34794 | | 34804 | |
| 34795 | const src = LazySrcLoc.nodeOffset(0); | 34805 | const src = LazySrcLoc.nodeOffset(0); |
| ... | @@ -34917,7 +34927,7 @@ fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void | ... | @@ -34917,7 +34927,7 @@ fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void |
| 34917 | if (has_type_body) { | 34927 | if (has_type_body) { |
| 34918 | fields[field_i].type_body_len = zir.extra[extra_index]; | 34928 | fields[field_i].type_body_len = zir.extra[extra_index]; |
| 34919 | } else { | 34929 | } else { |
| 34920 | fields[field_i].type_ref = @as(Zir.Inst.Ref, @enumFromInt(zir.extra[extra_index])); | 34930 | fields[field_i].type_ref = @enumFromInt(zir.extra[extra_index]); |
| 34921 | } | 34931 | } |
| 34922 | extra_index += 1; | 34932 | extra_index += 1; |
| 34923 | | 34933 | |
| ... | @@ -36076,13 +36086,12 @@ pub fn addExtra(sema: *Sema, extra: anytype) Allocator.Error!u32 { | ... | @@ -36076,13 +36086,12 @@ pub fn addExtra(sema: *Sema, extra: anytype) Allocator.Error!u32 { |
| 36076 | | 36086 | |
| 36077 | pub fn addExtraAssumeCapacity(sema: *Sema, extra: anytype) u32 { | 36087 | pub fn addExtraAssumeCapacity(sema: *Sema, extra: anytype) u32 { |
| 36078 | const fields = std.meta.fields(@TypeOf(extra)); | 36088 | const fields = std.meta.fields(@TypeOf(extra)); |
| 36079 | const result = @as(u32, @intCast(sema.air_extra.items.len)); | 36089 | const result: u32 = @intCast(sema.air_extra.items.len); |
| 36080 | inline for (fields) |field| { | 36090 | inline for (fields) |field| { |
| 36081 | sema.air_extra.appendAssumeCapacity(switch (field.type) { | 36091 | sema.air_extra.appendAssumeCapacity(switch (field.type) { |
| 36082 | u32 => @field(extra, field.name), | 36092 | u32 => @field(extra, field.name), |
| 36083 | Air.Inst.Ref => @intFromEnum(@field(extra, field.name)), | 36093 | i32 => @bitCast(@field(extra, field.name)), |
| 36084 | i32 => @as(u32, @bitCast(@field(extra, field.name))), | 36094 | Air.Inst.Ref, InternPool.Index => @intFromEnum(@field(extra, field.name)), |
| 36085 | InternPool.Index => @intFromEnum(@field(extra, field.name)), | | |
| 36086 | else => @compileError("bad field type: " ++ @typeName(field.type)), | 36095 | else => @compileError("bad field type: " ++ @typeName(field.type)), |
| 36087 | }); | 36096 | }); |
| 36088 | } | 36097 | } |
| ... | @@ -36090,8 +36099,7 @@ pub fn addExtraAssumeCapacity(sema: *Sema, extra: anytype) u32 { | ... | @@ -36090,8 +36099,7 @@ pub fn addExtraAssumeCapacity(sema: *Sema, extra: anytype) u32 { |
| 36090 | } | 36099 | } |
| 36091 | | 36100 | |
| 36092 | fn appendRefsAssumeCapacity(sema: *Sema, refs: []const Air.Inst.Ref) void { | 36101 | fn appendRefsAssumeCapacity(sema: *Sema, refs: []const Air.Inst.Ref) void { |
| 36093 | const coerced = @as([]const u32, @ptrCast(refs)); | 36102 | sema.air_extra.appendSliceAssumeCapacity(@ptrCast(refs)); |
| 36094 | sema.air_extra.appendSliceAssumeCapacity(coerced); | | |
| 36095 | } | 36103 | } |
| 36096 | | 36104 | |
| 36097 | fn getBreakBlock(sema: *Sema, inst_index: Air.Inst.Index) ?Air.Inst.Index { | 36105 | fn getBreakBlock(sema: *Sema, inst_index: Air.Inst.Index) ?Air.Inst.Index { |
| ... | @@ -36547,7 +36555,7 @@ fn structFieldAlignment(sema: *Sema, field: Module.Struct.Field, layout: std.bui | ... | @@ -36547,7 +36555,7 @@ fn structFieldAlignment(sema: *Sema, field: Module.Struct.Field, layout: std.bui |
| 36547 | const mod = sema.mod; | 36555 | const mod = sema.mod; |
| 36548 | if (field.abi_align.toByteUnitsOptional()) |a| { | 36556 | if (field.abi_align.toByteUnitsOptional()) |a| { |
| 36549 | assert(layout != .Packed); | 36557 | assert(layout != .Packed); |
| 36550 | return @as(u32, @intCast(a)); | 36558 | return @intCast(a); |
| 36551 | } | 36559 | } |
| 36552 | switch (layout) { | 36560 | switch (layout) { |
| 36553 | .Packed => return 0, | 36561 | .Packed => return 0, |
| ... | @@ -36612,7 +36620,7 @@ fn structFieldIndex( | ... | @@ -36612,7 +36620,7 @@ fn structFieldIndex( |
| 36612 | const struct_obj = mod.typeToStruct(struct_ty).?; | 36620 | const struct_obj = mod.typeToStruct(struct_ty).?; |
| 36613 | const field_index_usize = struct_obj.fields.getIndex(field_name) orelse | 36621 | const field_index_usize = struct_obj.fields.getIndex(field_name) orelse |
| 36614 | return sema.failWithBadStructFieldAccess(block, struct_obj, field_src, field_name); | 36622 | return sema.failWithBadStructFieldAccess(block, struct_obj, field_src, field_name); |
| 36615 | return @as(u32, @intCast(field_index_usize)); | 36623 | return @intCast(field_index_usize); |
| 36616 | } | 36624 | } |
| 36617 | } | 36625 | } |
| 36618 | | 36626 | |
| ... | @@ -36626,12 +36634,12 @@ fn anonStructFieldIndex( | ... | @@ -36626,12 +36634,12 @@ fn anonStructFieldIndex( |
| 36626 | const mod = sema.mod; | 36634 | const mod = sema.mod; |
| 36627 | switch (mod.intern_pool.indexToKey(struct_ty.toIntern())) { | 36635 | switch (mod.intern_pool.indexToKey(struct_ty.toIntern())) { |
| 36628 | .anon_struct_type => |anon_struct_type| for (anon_struct_type.names, 0..) |name, i| { | 36636 | .anon_struct_type => |anon_struct_type| for (anon_struct_type.names, 0..) |name, i| { |
| 36629 | if (name == field_name) return @as(u32, @intCast(i)); | 36637 | if (name == field_name) return @intCast(i); |
| 36630 | }, | 36638 | }, |
| 36631 | .struct_type => |struct_type| if (mod.structPtrUnwrap(struct_type.index)) |struct_obj| { | 36639 | .struct_type => |struct_type| if (mod.structPtrUnwrap(struct_type.index)) |struct_obj| { |
| 36632 | for (struct_obj.fields.keys(), 0..) |name, i| { | 36640 | for (struct_obj.fields.keys(), 0..) |name, i| { |
| 36633 | if (name == field_name) { | 36641 | if (name == field_name) { |
| 36634 | return @as(u32, @intCast(i)); | 36642 | return @intCast(i); |
| 36635 | } | 36643 | } |
| 36636 | } | 36644 | } |
| 36637 | }, | 36645 | }, |
| ... | @@ -37229,9 +37237,9 @@ fn elemPtrType(sema: *Sema, ptr_ty: Type, offset: ?usize) !Type { | ... | @@ -37229,9 +37237,9 @@ fn elemPtrType(sema: *Sema, ptr_ty: Type, offset: ?usize) !Type { |
| 37229 | if (!is_packed) break :blk .{}; | 37237 | if (!is_packed) break :blk .{}; |
| 37230 | | 37238 | |
| 37231 | break :blk .{ | 37239 | break :blk .{ |
| 37232 | .host_size = @as(u16, @intCast(parent_ty.arrayLen(mod))), | 37240 | .host_size = @intCast(parent_ty.arrayLen(mod)), |
| 37233 | .alignment = @as(u32, @intCast(parent_ty.abiAlignment(mod))), | 37241 | .alignment = @intCast(parent_ty.abiAlignment(mod)), |
| 37234 | .vector_index = if (offset) |some| @as(VI, @enumFromInt(some)) else .runtime, | 37242 | .vector_index = if (offset) |some| @enumFromInt(some) else .runtime, |
| 37235 | }; | 37243 | }; |
| 37236 | } else .{}; | 37244 | } else .{}; |
| 37237 | | 37245 | |
| ... | @@ -37250,10 +37258,10 @@ fn elemPtrType(sema: *Sema, ptr_ty: Type, offset: ?usize) !Type { | ... | @@ -37250,10 +37258,10 @@ fn elemPtrType(sema: *Sema, ptr_ty: Type, offset: ?usize) !Type { |
| 37250 | // The resulting pointer is aligned to the lcd between the offset (an | 37258 | // The resulting pointer is aligned to the lcd between the offset (an |
| 37251 | // arbitrary number) and the alignment factor (always a power of two, | 37259 | // arbitrary number) and the alignment factor (always a power of two, |
| 37252 | // non zero). | 37260 | // non zero). |
| 37253 | const new_align = @as(Alignment, @enumFromInt(@min( | 37261 | const new_align: Alignment = @enumFromInt(@min( |
| 37254 | @ctz(addend), | 37262 | @ctz(addend), |
| 37255 | @intFromEnum(ptr_info.flags.alignment), | 37263 | @intFromEnum(ptr_info.flags.alignment), |
| 37256 | ))); | 37264 | )); |
| 37257 | assert(new_align != .none); | 37265 | assert(new_align != .none); |
| 37258 | break :a new_align; | 37266 | break :a new_align; |
| 37259 | }; | 37267 | }; |