diff --git a/src/Air.zig b/src/Air.zig index e86637581c6a41fd4eac9deb0c550e21d01d1552..486656524cb87684419ddc10a5ff1022b319d4b8 100644 --- a/src/Air.zig +++ b/src/Air.zig @@ -1297,15 +1297,15 @@ pub const Inst = struct { }, ty: Type, arg: struct { - ty: Ref, + ty: Type, zir_param_index: u32, }, ty_op: struct { - ty: Ref, + ty: Type, operand: Ref, }, ty_pl: struct { - ty: Ref, + ty: Type, // Index into a different array. payload: u32, }, @@ -1339,7 +1339,7 @@ pub const Inst = struct { operation: std.lang.ReduceOp, }, ty_nav: struct { - ty: InternPool.Index, + ty: Type, nav: InternPool.Nav.Index, }, legalize_compiler_rt_call: struct { @@ -1700,7 +1700,7 @@ pub fn typeOfIndex(air: *const Air, inst: Air.Inst.Index, ip: *const InternPool) .c_va_start, => return datas[@backingInt(inst)].ty, - .arg => return datas[@backingInt(inst)].arg.ty.toType(), + .arg => return datas[@backingInt(inst)].arg.ty, .assembly, .block, @@ -1727,7 +1727,7 @@ pub fn typeOfIndex(air: *const Air, inst: Air.Inst.Index, ip: *const InternPool) .try_ptr_cold, .shuffle_one, .shuffle_two, - => return datas[@backingInt(inst)].ty_pl.ty.toType(), + => return datas[@backingInt(inst)].ty_pl.ty, .not, .bit_cast, @@ -1781,7 +1781,7 @@ pub fn typeOfIndex(air: *const Air, inst: Air.Inst.Index, ip: *const InternPool) .c_va_arg, .c_va_copy, .abs, - => return datas[@backingInt(inst)].ty_op.ty.toType(), + => return datas[@backingInt(inst)].ty_op.ty, .loop, .repeat, @@ -1865,7 +1865,7 @@ pub fn typeOfIndex(air: *const Air, inst: Air.Inst.Index, ip: *const InternPool) return .fromInterned(ip.indexToKey(err_union_ty.ip_index).error_union_type.payload_type); }, - .runtime_nav_ptr => return .fromInterned(datas[@backingInt(inst)].ty_nav.ty), + .runtime_nav_ptr => return datas[@backingInt(inst)].ty_nav.ty, .work_item_id, .work_group_size, @@ -2268,7 +2268,7 @@ pub fn unwrapDbgBlock(air: *const Air, inst_index: Inst.Index) UnwrappedDbgInlin const extra = air.extraData(Air.DbgInlineBlock, payload); return .{ .func = extra.data.func, - .ty = data.ty_pl.ty.toType(), + .ty = data.ty_pl.ty, .body = @ptrCast(air.extra.items[extra.end..][0..extra.data.body_len]), }; } @@ -2287,7 +2287,7 @@ pub fn unwrapBlock(air: *const Air, inst_index: Inst.Index) UnwrappedBlock { }; const extra = air.extraData(Air.Block, payload); return .{ - .ty = data.ty_pl.ty.toType(), + .ty = data.ty_pl.ty, .body = @ptrCast(air.extra.items[extra.end..][0..extra.data.body_len]), }; } @@ -2367,7 +2367,7 @@ pub fn unwrapTry(air: *const Air, inst_index: Inst.Index) UnwrappedTry { } pub const UnwrappedTryPtr = struct { - error_union_payload_ptr_ty: Inst.Ref, + error_union_payload_ptr_ty: Type, error_union_ptr: Inst.Ref, else_body: []const Inst.Index, }; @@ -2482,7 +2482,7 @@ pub fn unwrapShuffleOne(air: *const Air, zcu: *const Zcu, inst_index: Inst.Index .shuffle_one => {}, else => unreachable, // assertion failure } - const result_ty: Type = .fromInterned(inst.data.ty_pl.ty.toInterned().?); + const result_ty: Type = inst.data.ty_pl.ty; const mask_len: u32 = result_ty.vectorLen(zcu); const extra_idx = inst.data.ty_pl.payload; return .{ @@ -2505,7 +2505,7 @@ pub fn unwrapShuffleTwo(air: *const Air, zcu: *const Zcu, inst_index: Inst.Index .shuffle_two => {}, else => unreachable, // assertion failure } - const result_ty: Type = .fromInterned(inst.data.ty_pl.ty.toInterned().?); + const result_ty: Type = inst.data.ty_pl.ty; const mask_len: u32 = result_ty.vectorLen(zcu); const extra_idx = inst.data.ty_pl.payload; return .{ diff --git a/src/Air/Legalize.zig b/src/Air/Legalize.zig index 3c426ec57a195cf211bcbc2a75261030ea563402..9c3f0417d36694202f31850e7389e7809d45c628 100644 --- a/src/Air/Legalize.zig +++ b/src/Air/Legalize.zig @@ -470,7 +470,7 @@ fn legalizeBody(l: *Legalize, body_start: usize, body_len: usize) Error!void { .shl_with_overflow, => |air_tag| if (l.features.has(comptime .scalarize(air_tag))) { const ty_pl = l.air_instructions.items(.data)[@backingInt(inst)].ty_pl; - if (ty_pl.ty.toType().fieldType(0, zcu).isVector(zcu)) { + if (ty_pl.ty.fieldType(0, zcu).isVector(zcu)) { continue :inst l.replaceInst(inst, .block, try l.scalarizeOverflowBlockPayload(inst)); } }, @@ -527,27 +527,27 @@ fn legalizeBody(l: *Legalize, body_start: usize, body_len: usize) Error!void { .trunc, => |air_tag| if (l.features.has(comptime .scalarize(air_tag))) { const ty_op = l.air_instructions.items(.data)[@backingInt(inst)].ty_op; - if (ty_op.ty.toType().isVector(zcu)) { + if (ty_op.ty.isVector(zcu)) { continue :inst l.replaceInst(inst, .block, try l.scalarizeBlockPayload(inst, .ty_op)); } }, .abs => { const ty_op = l.air_instructions.items(.data)[@backingInt(inst)].ty_op; - switch (l.wantScalarizeOrSoftFloat(.abs, ty_op.ty.toType())) { + switch (l.wantScalarizeOrSoftFloat(.abs, ty_op.ty)) { .none => {}, .scalarize => continue :inst l.replaceInst(inst, .block, try l.scalarizeBlockPayload(inst, .ty_op)), .soft_float => continue :inst try l.compilerRtCall( inst, - softFloatFunc(.abs, ty_op.ty.toType(), zcu), + softFloatFunc(.abs, ty_op.ty, zcu), &.{ty_op.operand}, - ty_op.ty.toType(), + ty_op.ty, ), } }, .fptrunc => { const ty_op = l.air_instructions.items(.data)[@backingInt(inst)].ty_op; const src_ty = l.typeOf(ty_op.operand); - const dest_ty = ty_op.ty.toType(); + const dest_ty = ty_op.ty; if (src_ty.zigTypeTag(zcu) == .vector) { if (l.features.has(.scalarize_fptrunc) or l.wantSoftFloatScalar(src_ty.childType(zcu)) or @@ -562,7 +562,7 @@ fn legalizeBody(l: *Legalize, body_start: usize, body_len: usize) Error!void { .fpext => { const ty_op = l.air_instructions.items(.data)[@backingInt(inst)].ty_op; const src_ty = l.typeOf(ty_op.operand); - const dest_ty = ty_op.ty.toType(); + const dest_ty = ty_op.ty; if (src_ty.zigTypeTag(zcu) == .vector) { if (l.features.has(.scalarize_fpext) or l.wantSoftFloatScalar(src_ty.childType(zcu)) or @@ -580,14 +580,14 @@ fn legalizeBody(l: *Legalize, body_start: usize, body_len: usize) Error!void { .none => {}, .scalarize => continue :inst l.replaceInst(inst, .block, try l.scalarizeBlockPayload(inst, .ty_op)), .soft_float => switch (try l.softIntFromFloat(inst)) { - .call => |func| continue :inst try l.compilerRtCall(inst, func, &.{ty_op.operand}, ty_op.ty.toType()), + .call => |func| continue :inst try l.compilerRtCall(inst, func, &.{ty_op.operand}, ty_op.ty), .block_payload => |data| continue :inst l.replaceInst(inst, .block, data), }, } }, .float_from_int => { const ty_op = l.air_instructions.items(.data)[@backingInt(inst)].ty_op; - const dest_ty = ty_op.ty.toType(); + const dest_ty = ty_op.ty; switch (l.wantScalarizeOrSoftFloat(.float_from_int, dest_ty)) { .none => {}, .scalarize => continue :inst l.replaceInst(inst, .block, try l.scalarizeBlockPayload(inst, .ty_op)), @@ -630,7 +630,7 @@ fn legalizeBody(l: *Legalize, body_start: usize, body_len: usize) Error!void { continue :inst l.replaceInst(inst, .int_cast, .{ .ty_op = ty_op }); } else if (l.features.has(.scalarize_int_cast_safe)) { const ty_op = l.air_instructions.items(.data)[@backingInt(inst)].ty_op; - if (ty_op.ty.toType().isVector(zcu)) { + if (ty_op.ty.isVector(zcu)) { continue :inst l.replaceInst(inst, .block, try l.scalarizeBlockPayload(inst, .ty_op)); } }, @@ -875,7 +875,7 @@ fn legalizeBody(l: *Legalize, body_start: usize, body_len: usize) Error!void { switch (vector_ty.vectorLen(zcu)) { 0 => unreachable, 1 => continue :inst l.replaceInst(inst, .bit_cast, .{ .ty_op = .{ - .ty = .fromType(vector_ty.childType(zcu)), + .ty = vector_ty.childType(zcu), .operand = reduce.operand, } }), else => {}, @@ -893,7 +893,7 @@ fn legalizeBody(l: *Legalize, body_start: usize, body_len: usize) Error!void { }, .splat => if (l.features.has(.splat_one_elem_to_bit_cast)) { const ty_op = l.air_instructions.items(.data)[@backingInt(inst)].ty_op; - switch (ty_op.ty.toType().vectorLen(zcu)) { + switch (ty_op.ty.vectorLen(zcu)) { 0 => unreachable, 1 => continue :inst l.replaceInst(inst, .bit_cast, .{ .ty_op = .{ .ty = ty_op.ty, @@ -904,7 +904,7 @@ fn legalizeBody(l: *Legalize, body_start: usize, body_len: usize) Error!void { }, .shuffle_one => { const ty_pl = l.air_instructions.items(.data)[@backingInt(inst)].ty_pl; - switch (l.wantScalarizeOrSoftFloat(.shuffle_one, ty_pl.ty.toType())) { + switch (l.wantScalarizeOrSoftFloat(.shuffle_one, ty_pl.ty)) { .none => {}, .scalarize => continue :inst l.replaceInst(inst, .block, try l.scalarizeShuffleOneBlockPayload(inst)), .soft_float => unreachable, // the operand is not a scalar @@ -912,7 +912,7 @@ fn legalizeBody(l: *Legalize, body_start: usize, body_len: usize) Error!void { }, .shuffle_two => { const ty_pl = l.air_instructions.items(.data)[@backingInt(inst)].ty_pl; - switch (l.wantScalarizeOrSoftFloat(.shuffle_two, ty_pl.ty.toType())) { + switch (l.wantScalarizeOrSoftFloat(.shuffle_two, ty_pl.ty)) { .none => {}, .scalarize => continue :inst l.replaceInst(inst, .block, try l.scalarizeShuffleTwoBlockPayload(inst)), .soft_float => unreachable, // the operand is not a scalar @@ -946,7 +946,7 @@ fn legalizeBody(l: *Legalize, body_start: usize, body_len: usize) Error!void { => {}, .aggregate_init => if (l.features.has(.expand_packed_aggregate_init)) { const ty_pl = l.air_instructions.items(.data)[@backingInt(inst)].ty_pl; - const agg_ty = ty_pl.ty.toType(); + const agg_ty = ty_pl.ty; switch (agg_ty.zigTypeTag(zcu)) { else => {}, .@"union" => unreachable, @@ -962,7 +962,7 @@ fn legalizeBody(l: *Legalize, body_start: usize, body_len: usize) Error!void { if (field_bits == struct_bits) { // Just bitcast this field. continue :inst l.replaceInst(inst, .bit_cast, .{ .ty_op = .{ - .ty = .fromType(agg_ty), + .ty = agg_ty, .operand = @fromBackingInt(@intCast(l.air_extra.items[ty_pl.payload + field_index])), } }); } @@ -1152,7 +1152,7 @@ fn scalarizeBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index, form: Scalariz const elem_block_inst = loop.block.add(l, .{ .tag = .block, .data = .{ .ty_pl = .{ - .ty = .fromType(res_elem_ty), + .ty = res_elem_ty, .payload = undefined, } }, }); @@ -1182,7 +1182,7 @@ fn scalarizeBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index, form: Scalariz const elem_ptr = loop.block.add(l, .{ .tag = .ptr_elem_ptr, .data = .{ .ty_pl = .{ - .ty = .fromType(try pt.singleMutPtrType(res_elem_ty)), + .ty = try pt.singleMutPtrType(res_elem_ty), .payload = try l.addExtra(Air.Bin, .{ .lhs = result_ptr, .rhs = index_val, @@ -1223,7 +1223,7 @@ fn scalarizeBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index, form: Scalariz try loop.finish(l); return .{ .ty_pl = .{ - .ty = .fromType(res_ty), + .ty = res_ty, .payload = try l.addBlockBody(main_block.body()), } }; } @@ -1303,7 +1303,7 @@ fn scalarizeShuffleOneBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Erro main_block.addBr(l, orig_inst, result_val); return .{ .ty_pl = .{ - .ty = .fromType(shuffle.result_ty), + .ty = shuffle.result_ty, .payload = try l.addBlockBody(main_block.body()), } }; } @@ -1409,7 +1409,7 @@ fn scalarizeShuffleTwoBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Erro main_block.addBr(l, orig_inst, result_val); return .{ .ty_pl = .{ - .ty = .fromType(shuffle.result_ty), + .ty = shuffle.result_ty, .payload = try l.addBlockBody(main_block.body()), } }; } @@ -1478,7 +1478,7 @@ fn addScalarizedShuffle( const main_block_inst = parent_block.add(l, .{ .tag = .block, .data = .{ .ty_pl = .{ - .ty = .void_type, + .ty = .void, .payload = undefined, } }, }); @@ -1532,7 +1532,7 @@ fn scalarizeBitcastBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Error!? const ty_op = l.air_instructions.items(.data)[@backingInt(orig_inst)].ty_op; - const dest_ty = ty_op.ty.toType(); + const dest_ty = ty_op.ty; const operand_ty = l.typeOf(ty_op.operand); // We exit this block only if the scalarization is actually necessary. Otherwise we will return @@ -1677,7 +1677,7 @@ fn scalarizeBitcastBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Error!? const uint_block_inst = main_block.add(l, .{ .tag = .block, .data = .{ .ty_pl = .{ - .ty = .fromType(uint_ty), + .ty = uint_ty, .payload = undefined, } }, }); @@ -1746,7 +1746,7 @@ fn scalarizeBitcastBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Error!? .bit_cast_safe => main_block.add(l, .{ .tag = .bit_cast_safe, .data = .{ .ty_op = .{ - .ty = .fromType(dest_ty), + .ty = dest_ty, .operand = uint_val, } }, }).toRef(), @@ -1761,7 +1761,7 @@ fn scalarizeBitcastBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Error!? const result = main_block.add(l, .{ .tag = .aggregate_init, .data = .{ .ty_pl = .{ - .ty = .fromType(dest_ty), + .ty = dest_ty, .payload = @intCast(aggregate_init_payload_start), } }, }).toRef(); @@ -1814,7 +1814,7 @@ fn scalarizeBitcastBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Error!? const elem_ptr = loop.block.add(l, .{ .tag = .ptr_elem_ptr, .data = .{ .ty_pl = .{ - .ty = .fromType(try pt.singleMutPtrType(elem_ty)), + .ty = try pt.singleMutPtrType(elem_ty), .payload = try l.addExtra(Air.Bin, .{ .lhs = result_ptr, .rhs = index_val, @@ -1860,7 +1860,7 @@ fn scalarizeBitcastBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Error!? } return .{ .ty_pl = .{ - .ty = .fromType(dest_ty), + .ty = dest_ty, .payload = try l.addBlockBody(main_block.body()), } }; } @@ -1942,14 +1942,14 @@ fn scalarizeOverflowBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Error! const elem_result = loop.block.add(l, .{ .tag = orig.tag, .data = .{ .ty_pl = .{ - .ty = .fromType(scalar_tuple_ty), + .ty = scalar_tuple_ty, .payload = try l.addExtra(Air.Bin, .{ .lhs = lhs, .rhs = rhs }), } }, }).toRef(); const int_elem = loop.block.add(l, .{ .tag = .agg_field_val, .data = .{ .ty_pl = .{ - .ty = .fromType(scalar_int_ty), + .ty = scalar_int_ty, .payload = try l.addExtra(Air.StructField, .{ .struct_operand = elem_result, .field_index = 0, @@ -1959,7 +1959,7 @@ fn scalarizeOverflowBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Error! const overflow_elem = loop.block.add(l, .{ .tag = .agg_field_val, .data = .{ .ty_pl = .{ - .ty = .u1_type, + .ty = .u1, .payload = try l.addExtra(Air.StructField, .{ .struct_operand = elem_result, .field_index = 1, @@ -2006,7 +2006,7 @@ fn scalarizeOverflowBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Error! try loop.finish(l); return .{ .ty_pl = .{ - .ty = .fromType(vec_tuple_ty), + .ty = vec_tuple_ty, .payload = try l.addBlockBody(main_block.body()), } }; } @@ -2133,7 +2133,7 @@ fn scalarizeReduceBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index, optimize try loop.finish(l); return .{ .ty_pl = .{ - .ty = .fromType(scalar_ty), + .ty = scalar_ty, .payload = try l.addBlockBody(main_block.body()), } }; } @@ -2144,7 +2144,7 @@ fn safeBitcastBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Error!?Air.I const ty_op = l.air_instructions.items(.data)[@backingInt(orig_inst)].ty_op; const operand_ref = ty_op.operand; - const dest_ty = ty_op.ty.toType(); + const dest_ty = ty_op.ty; if (dest_ty.zigTypeTag(zcu) != .@"enum" or dest_ty.isNonexhaustiveEnum(zcu) or @@ -2188,7 +2188,7 @@ fn safeBitcastBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Error!?Air.I try condbr.finish(l); return .{ .ty_pl = .{ - .ty = .fromType(dest_ty), + .ty = dest_ty, .payload = try l.addBlockBody(block.body()), } }; } @@ -2200,7 +2200,7 @@ fn safeIntcastBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Error!?Air.I const operand_ref = ty_op.operand; const operand_ty = l.typeOf(operand_ref); - const dest_ty = ty_op.ty.toType(); + const dest_ty = ty_op.ty; const is_vector = operand_ty.zigTypeTag(zcu) == .vector; const operand_scalar_ty = operand_ty.scalarType(zcu); @@ -2324,7 +2324,7 @@ fn safeIntcastBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Error!?Air.I const cast_inst = cur_block.add(l, .{ .tag = .int_cast, .data = .{ .ty_op = .{ - .ty = Air.internedToRef(dest_ty.toIntern()), + .ty = dest_ty, .operand = operand_ref, } }, }); @@ -2359,7 +2359,7 @@ fn safeIntcastBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Error!?Air.I assert(condbr_idx != 0); // should have already returned `null` for (condbr_buf[0..condbr_idx]) |*condbr| try condbr.finish(l); return .{ .ty_pl = .{ - .ty = Air.internedToRef(dest_ty.toIntern()), + .ty = dest_ty, .payload = try l.addBlockBody(main_block.body()), } }; } @@ -2371,7 +2371,7 @@ fn safeIntFromFloatBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index, optimiz const operand_ref = ty_op.operand; const operand_ty = l.typeOf(operand_ref); - const dest_ty = ty_op.ty.toType(); + const dest_ty = ty_op.ty; const is_vector = operand_ty.zigTypeTag(zcu) == .vector; const dest_scalar_ty = dest_ty.scalarType(zcu); @@ -2453,7 +2453,7 @@ fn safeIntFromFloatBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index, optimiz const cast_inst = condbr.else_block.add(l, .{ .tag = if (optimized) .int_from_float_optimized else .int_from_float, .data = .{ .ty_op = .{ - .ty = Air.internedToRef(dest_ty.toIntern()), + .ty = dest_ty, .operand = operand_ref, } }, }); @@ -2468,7 +2468,7 @@ fn safeIntFromFloatBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index, optimiz try condbr.finish(l); return .{ .ty_pl = .{ - .ty = Air.internedToRef(dest_ty.toIntern()), + .ty = dest_ty, .payload = try l.addBlockBody(main_block.body()), } }; } @@ -2505,7 +2505,7 @@ fn safeArithmeticBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index, overflow_ const overflow_op_inst = main_block.add(l, .{ .tag = overflow_op_tag, .data = .{ .ty_pl = .{ - .ty = Air.internedToRef(overflow_tuple_ty.toIntern()), + .ty = overflow_tuple_ty, .payload = try l.addExtra(Air.Bin, .{ .lhs = bin_op.lhs, .rhs = bin_op.rhs, @@ -2515,7 +2515,7 @@ fn safeArithmeticBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index, overflow_ const overflow_bits_inst = main_block.add(l, .{ .tag = .agg_field_val, .data = .{ .ty_pl = .{ - .ty = Air.internedToRef(overflow_bits_ty.toIntern()), + .ty = overflow_bits_ty, .payload = try l.addExtra(Air.StructField, .{ .struct_operand = overflow_op_inst.toRef(), .field_index = 1, @@ -2539,7 +2539,7 @@ fn safeArithmeticBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index, overflow_ const result_inst = condbr.else_block.add(l, .{ .tag = .agg_field_val, .data = .{ .ty_pl = .{ - .ty = Air.internedToRef(operand_ty.toIntern()), + .ty = operand_ty, .payload = try l.addExtra(Air.StructField, .{ .struct_operand = overflow_op_inst.toRef(), .field_index = 0, @@ -2558,7 +2558,7 @@ fn safeArithmeticBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index, overflow_ try condbr.finish(l); return .{ .ty_pl = .{ - .ty = Air.internedToRef(operand_ty.toIntern()), + .ty = operand_ty, .payload = try l.addBlockBody(main_block.body()), } }; } @@ -2608,7 +2608,7 @@ fn divCeilBlockPayload( _ = main_block.stealRemainingCapacity(); return .{ .ty_pl = .{ - .ty = .fromType(operand_ty), + .ty = operand_ty, .payload = try l.addBlockBody(main_block.body()), } }; }, @@ -2707,7 +2707,7 @@ fn divCeilBlockPayload( _ = main_block.stealRemainingCapacity(); return .{ .ty_pl = .{ - .ty = .fromType(operand_ty), + .ty = operand_ty, .payload = try l.addBlockBody(main_block.body()), } }; }, @@ -2721,7 +2721,7 @@ fn packedLoadBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Error!Air.Ins const zcu = pt.zcu; const orig_ty_op = l.air_instructions.items(.data)[@backingInt(orig_inst)].ty_op; - const res_ty = orig_ty_op.ty.toType(); + const res_ty = orig_ty_op.ty; const res_int_ty = try pt.intType(.unsigned, @intCast(res_ty.bitSize(zcu))); const ptr_ty = l.typeOf(orig_ty_op.operand); const ptr_info = ptr_ty.ptrInfo(zcu); @@ -2740,14 +2740,14 @@ fn packedLoadBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Error!Air.Ins .operand = res_block.addBitCast(l, res_ty, res_block.add(l, .{ .tag = .trunc, .data = .{ .ty_op = .{ - .ty = Air.internedToRef(res_int_ty.toIntern()), + .ty = res_int_ty, .operand = res_block.add(l, .{ .tag = .shr, .data = .{ .bin_op = .{ .lhs = res_block.add(l, .{ .tag = .load, .data = .{ .ty_op = .{ - .ty = Air.internedToRef(load_ty.toIntern()), + .ty = load_ty, .operand = res_block.addPtrCast(l, load_ptr_ty: { var load_ptr_info = ptr_info; load_ptr_info.child = load_ty.toIntern(); @@ -2768,7 +2768,7 @@ fn packedLoadBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Error!Air.Ins } }, }); return .{ .ty_pl = .{ - .ty = Air.internedToRef(res_ty.toIntern()), + .ty = res_ty, .payload = try l.addBlockBody(res_block.body()), } }; } @@ -2811,7 +2811,7 @@ fn packedStoreBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Error!Air.In .lhs = res_block.add(l, .{ .tag = .load, .data = .{ .ty_op = .{ - .ty = Air.internedToRef(load_store_ty.toIntern()), + .ty = load_store_ty, .operand = backing_ptr, } }, }).toRef(), @@ -2843,7 +2843,7 @@ fn packedStoreBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Error!Air.In .lhs = res_block.add(l, .{ .tag = .int_cast, .data = .{ .ty_op = .{ - .ty = Air.internedToRef(load_store_ty.toIntern()), + .ty = load_store_ty, .operand = res_block.addBitCast(l, operand_int_ty, orig_bin_op.rhs), } }, }).toRef(), @@ -2866,7 +2866,7 @@ fn packedStoreBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Error!Air.In }); } return .{ .ty_pl = .{ - .ty = .void_type, + .ty = .void, .payload = try l.addBlockBody(res_block.body()), } }; } @@ -2876,7 +2876,7 @@ fn packedStructFieldValBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Err const orig_ty_pl = l.air_instructions.items(.data)[@backingInt(orig_inst)].ty_pl; const orig_extra = l.extraData(Air.StructField, orig_ty_pl.payload).data; - const field_ty = orig_ty_pl.ty.toType(); + const field_ty = orig_ty_pl.ty; const agg_ty = l.typeOf(orig_extra.struct_operand); const agg_bits: u16 = @intCast(agg_ty.bitSize(zcu)); @@ -2899,7 +2899,7 @@ fn packedStructFieldValBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Err main_block.addBr(l, orig_inst, field_val); return .{ .ty_pl = .{ - .ty = .fromType(field_ty), + .ty = field_ty, .payload = try l.addBlockBody(main_block.body()), } }; } @@ -2909,7 +2909,7 @@ fn packedAggregateInitBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Erro const gpa = zcu.gpa; const orig_ty_pl = l.air_instructions.items(.data)[@backingInt(orig_inst)].ty_pl; - const agg_ty = orig_ty_pl.ty.toType(); + const agg_ty = orig_ty_pl.ty; const agg_field_count = agg_ty.structFieldCount(zcu); var opv_field_count: u32 = 0; for (0..agg_field_count) |field_idx| { @@ -2954,7 +2954,7 @@ fn packedAggregateInitBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Erro main_block.addBr(l, orig_inst, result); return .{ .ty_pl = .{ - .ty = .fromType(agg_ty), + .ty = agg_ty, .payload = try l.addBlockBody(main_block.body()), } }; } @@ -2965,7 +2965,7 @@ fn arrayToVectorBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Error!Air. const gpa = zcu.gpa; const orig_ty_op = l.air_instructions.items(.data)[@backingInt(orig_inst)].ty_op; - const vec_ty = orig_ty_op.ty.toType(); + const vec_ty = orig_ty_op.ty; const len: usize = @intCast(vec_ty.vectorLen(zcu)); var bfa_buf: [64 + 2]Air.Inst.Index = undefined; @@ -2989,14 +2989,14 @@ fn arrayToVectorBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Error!Air. const result = main_block.add(l, .{ .tag = .aggregate_init, .data = .{ .ty_pl = .{ - .ty = .fromType(vec_ty), + .ty = vec_ty, .payload = elems_start, } }, }).toRef(); main_block.addBr(l, orig_inst, result); return .{ .ty_pl = .{ - .ty = .fromType(vec_ty), + .ty = vec_ty, .payload = try l.addBlockBody(main_block.body()), } }; } @@ -3080,7 +3080,7 @@ const Block = struct { return b.add(l, .{ .tag = tag, .data = .{ .ty_op = .{ - .ty = .fromType(ty), + .ty = ty, .operand = operand, } }, }); @@ -3146,7 +3146,7 @@ const Block = struct { return b.add(l, .{ .tag = if (opts.optimized) .cmp_vector_optimized else .cmp_vector, .data = .{ .ty_pl = .{ - .ty = Air.internedToRef(bool_vec_ty.toIntern()), + .ty = bool_vec_ty, .payload = try l.addExtra(Air.VectorCmp, .{ .lhs = lhs, .rhs = rhs, @@ -3194,7 +3194,7 @@ const Block = struct { if (result_ty.toIntern() != operand_ty.toIntern()) return b.add(l, .{ .tag = .bit_cast, .data = .{ .ty_op = .{ - .ty = .fromType(result_ty), + .ty = result_ty, .operand = operand, } }, }).toRef(); @@ -3221,7 +3221,7 @@ const Block = struct { if (result_ty.toIntern() != operand_ty.toIntern()) return b.add(l, .{ .tag = .ptr_cast, .data = .{ .ty_op = .{ - .ty = .fromType(result_ty), + .ty = result_ty, .operand = operand, } }, }).toRef(); @@ -3343,7 +3343,7 @@ const Loop = struct { .inst = parent_block.add(l, .{ .tag = .loop, .data = .{ .ty_pl = .{ - .ty = .noreturn_type, + .ty = .noreturn, .payload = undefined, } }, }), @@ -3466,7 +3466,7 @@ fn compilerRtCall( main_block.addBr(l, orig_inst, casted_result); return l.replaceInst(orig_inst, .block, .{ .ty_pl = .{ - .ty = .fromType(result_ty), + .ty = result_ty, .payload = try l.addBlockBody(main_block.body()), } }); } @@ -3522,7 +3522,7 @@ fn softFloatFromInt(l: *Legalize, orig_inst: Air.Inst.Index) Error!union(enum) { const target = zcu.getTarget(); const ty_op = l.air_instructions.items(.data)[@backingInt(orig_inst)].ty_op; - const dest_ty = ty_op.ty.toType(); + const dest_ty = ty_op.ty; const src_ty = l.typeOf(ty_op.operand); const src_info = src_ty.intInfo(zcu); @@ -3568,7 +3568,7 @@ fn softFloatFromInt(l: *Legalize, orig_inst: Air.Inst.Index) Error!union(enum) { main_block.addBr(l, orig_inst, casted_result); return .{ .block_payload = .{ .ty_pl = .{ - .ty = .fromType(dest_ty), + .ty = dest_ty, .payload = try l.addBlockBody(main_block.body()), } } }; } @@ -3602,7 +3602,7 @@ fn softFloatFromInt(l: *Legalize, orig_inst: Air.Inst.Index) Error!union(enum) { main_block.addBr(l, orig_inst, casted_result); return .{ .block_payload = .{ .ty_pl = .{ - .ty = .fromType(dest_ty), + .ty = dest_ty, .payload = try l.addBlockBody(main_block.body()), } } }; } @@ -3616,7 +3616,7 @@ fn softIntFromFloat(l: *Legalize, orig_inst: Air.Inst.Index) Error!union(enum) { const ty_op = l.air_instructions.items(.data)[@backingInt(orig_inst)].ty_op; const src_ty = l.typeOf(ty_op.operand); - const dest_ty = ty_op.ty.toType(); + const dest_ty = ty_op.ty; const dest_info = dest_ty.intInfo(zcu); const float_off: u32 = switch (src_ty.floatBits(target)) { @@ -3658,7 +3658,7 @@ fn softIntFromFloat(l: *Legalize, orig_inst: Air.Inst.Index) Error!union(enum) { main_block.addBr(l, orig_inst, casted_val); return .{ .block_payload = .{ .ty_pl = .{ - .ty = .fromType(dest_ty), + .ty = dest_ty, .payload = try l.addBlockBody(main_block.body()), } } }; } @@ -3682,7 +3682,7 @@ fn softIntFromFloat(l: *Legalize, orig_inst: Air.Inst.Index) Error!union(enum) { main_block.addBr(l, orig_inst, result_val); return .{ .block_payload = .{ .ty_pl = .{ - .ty = .fromType(dest_ty), + .ty = dest_ty, .payload = try l.addBlockBody(main_block.body()), } } }; } @@ -3767,7 +3767,7 @@ fn softFloatNegBlockPayload( main_block.addBr(l, orig_inst, result); return .{ .ty_pl = .{ - .ty = .fromType(float_ty), + .ty = float_ty, .payload = try l.addBlockBody(main_block.body()), } }; } @@ -3801,7 +3801,7 @@ fn softFloatDivTruncFloorCeilBlockPayload( main_block.addBr(l, orig_inst, casted_result); return .{ .ty_pl = .{ - .ty = .fromType(float_ty), + .ty = float_ty, .payload = try l.addBlockBody(main_block.body()), } }; } @@ -3841,7 +3841,7 @@ fn softFloatModBlockPayload( try condbr.finish(l); return .{ .ty_pl = .{ - .ty = .fromType(float_ty), + .ty = float_ty, .payload = try l.addBlockBody(main_block.body()), } }; } @@ -3864,7 +3864,7 @@ fn softFloatCmpBlockPayload( main_block.addBr(l, orig_inst, result); return .{ .ty_pl = .{ - .ty = .bool_type, + .ty = .bool, .payload = try l.addBlockBody(main_block.body()), } }; } diff --git a/src/Air/Liveness.zig b/src/Air/Liveness.zig index 6089d2c7bc2f5092e9dad7f7dec174a4af1a0b2c..e143e1e41000535b29fcd4112422f11ef13160bb 100644 --- a/src/Air/Liveness.zig +++ b/src/Air/Liveness.zig @@ -661,7 +661,7 @@ fn analyzeInst( }, .aggregate_init => { const ty_pl = inst_datas[@backingInt(inst)].ty_pl; - const aggregate_ty = ty_pl.ty.toType(); + const aggregate_ty = ty_pl.ty; const len = @as(usize, @intCast(aggregate_ty.arrayLenIp(ip))); const elements = @as([]const Air.Inst.Ref, @ptrCast(a.air.extra.items[ty_pl.payload..][0..len])); diff --git a/src/Air/Liveness/Verify.zig b/src/Air/Liveness/Verify.zig index 832728c1c660156cbec6008cf4c369ae6b6f0dc1..54b33389daf176a9407f81737c6f0c3a13435b54 100644 --- a/src/Air/Liveness/Verify.zig +++ b/src/Air/Liveness/Verify.zig @@ -343,7 +343,7 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void { // big tombs .aggregate_init => { const ty_pl = data[@backingInt(inst)].ty_pl; - const aggregate_ty = ty_pl.ty.toType(); + const aggregate_ty = ty_pl.ty; const len = @as(usize, @intCast(aggregate_ty.arrayLenIp(ip))); const elements = @as([]const Air.Inst.Ref, @ptrCast(self.air.extra.items[ty_pl.payload..][0..len])); @@ -453,7 +453,7 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void { }, .block, .dbg_inline_block => |tag| { const ty_pl = data[@backingInt(inst)].ty_pl; - const block_ty = ty_pl.ty.toType(); + const block_ty = ty_pl.ty; const block_body = switch (tag) { .block => self.air.unwrapBlock(inst).body, .dbg_inline_block => self.air.unwrapDbgBlock(inst).body, diff --git a/src/Air/Verify.zig b/src/Air/Verify.zig index 4b6e6a29118187877c621a8a92dcabe09dd5feaa..5979310b1db6a1bce1637e42ee3b7317405d199b 100644 --- a/src/Air/Verify.zig +++ b/src/Air/Verify.zig @@ -121,7 +121,7 @@ fn body(verify: *Verify, body_insts: []const Air.Inst.Index) Error!void { .bit_cast, .bit_cast_safe => { const ty_op = data[@backingInt(inst)].ty_op; const operand_ty = air.typeOf(ty_op.operand, ip); - const result_ty = ty_op.ty.toType(); + const result_ty = ty_op.ty; // Enums are allowed here even if their backing type is implicit. if (!operand_ty.hasBitRepresentation(zcu) and operand_ty.zigTypeTag(zcu) != .@"enum") { return verify.fail("bad operand type"); @@ -136,7 +136,7 @@ fn body(verify: *Verify, body_insts: []const Air.Inst.Index) Error!void { .ptr_cast => { const ty_op = data[@backingInt(inst)].ty_op; const operand_ty = air.typeOf(ty_op.operand, ip); - const result_ty = ty_op.ty.toType(); + const result_ty = ty_op.ty; const operand_scalar_ty = operand_ty.scalarType(zcu); const result_scalar_ty = result_ty.scalarType(zcu); if (operand_ty.isSliceAtRuntime(zcu)) { @@ -154,7 +154,7 @@ fn body(verify: *Verify, body_insts: []const Air.Inst.Index) Error!void { .ptr_from_int => { const ty_op = data[@backingInt(inst)].ty_op; const operand_ty = air.typeOf(ty_op.operand, ip); - const result_ty = ty_op.ty.toType(); + const result_ty = ty_op.ty; const operand_scalar_ty = operand_ty.scalarType(zcu); const result_scalar_ty = result_ty.scalarType(zcu); if (operand_scalar_ty.toIntern() != .usize_type) return verify.fail("bad operand type"); @@ -165,7 +165,7 @@ fn body(verify: *Verify, body_insts: []const Air.Inst.Index) Error!void { .int_from_ptr => { const ty_op = data[@backingInt(inst)].ty_op; const operand_ty = air.typeOf(ty_op.operand, ip); - const result_ty = ty_op.ty.toType(); + const result_ty = ty_op.ty; const operand_scalar_ty = operand_ty.scalarType(zcu); const result_scalar_ty = result_ty.scalarType(zcu); if (!operand_scalar_ty.isPtrAtRuntime(zcu)) return verify.fail("bad operand type"); @@ -176,7 +176,7 @@ fn body(verify: *Verify, body_insts: []const Air.Inst.Index) Error!void { .error_cast => { const ty_op = data[@backingInt(inst)].ty_op; const operand_ty = air.typeOf(ty_op.operand, ip); - const result_ty = ty_op.ty.toType(); + const result_ty = ty_op.ty; switch (operand_ty.zigTypeTag(zcu)) { else => return verify.fail("bad operand type"), .error_union => { @@ -195,7 +195,7 @@ fn body(verify: *Verify, body_insts: []const Air.Inst.Index) Error!void { .error_from_int => { const ty_op = data[@backingInt(inst)].ty_op; const operand_ty = air.typeOf(ty_op.operand, ip); - const result_ty = ty_op.ty.toType(); + const result_ty = ty_op.ty; if (!operand_ty.isUnsignedInt(zcu)) return verify.fail("bad operand type"); if (operand_ty.bitSize(zcu) != zcu.errorSetBits()) return verify.fail("bad operand bit size"); if (result_ty.zigTypeTag(zcu) != .error_set) return verify.fail("bad result type"); @@ -203,7 +203,7 @@ fn body(verify: *Verify, body_insts: []const Air.Inst.Index) Error!void { .int_from_error => { const ty_op = data[@backingInt(inst)].ty_op; const operand_ty = air.typeOf(ty_op.operand, ip); - const result_ty = ty_op.ty.toType(); + const result_ty = ty_op.ty; if (operand_ty.zigTypeTag(zcu) != .error_set) return verify.fail("bad operand type"); if (!result_ty.isUnsignedInt(zcu)) return verify.fail("bad result type"); if (result_ty.bitSize(zcu) != zcu.errorSetBits()) return verify.fail("bad result bit size"); @@ -211,7 +211,7 @@ fn body(verify: *Verify, body_insts: []const Air.Inst.Index) Error!void { .union_from_enum => { const ty_op = data[@backingInt(inst)].ty_op; const operand_ty = air.typeOf(ty_op.operand, ip); - const result_ty = ty_op.ty.toType(); + const result_ty = ty_op.ty; if (operand_ty.zigTypeTag(zcu) != .@"enum") return verify.fail("bad operand type"); if (result_ty.zigTypeTag(zcu) != .@"union") return verify.fail("bad result type"); const union_tag_ty = result_ty.unionTagType(zcu) orelse return verify.fail("union type is not tagged"); @@ -222,7 +222,7 @@ fn body(verify: *Verify, body_insts: []const Air.Inst.Index) Error!void { const ty_pl = data[@backingInt(inst)].ty_pl; const bin_op = air.extraData(Air.Bin, ty_pl.payload).data; const ptr_ty = air.typeOf(bin_op.lhs, ip); - const result_ty = ty_pl.ty.toType(); + const result_ty = ty_pl.ty; if (ptr_ty.zigTypeTag(zcu) != .pointer) return verify.fail("bad pointer type"); if (result_ty.zigTypeTag(zcu) != .pointer) return verify.fail("bad result type"); const ptr_info = ptr_ty.ptrInfo(zcu); diff --git a/src/Air/print.zig b/src/Air/print.zig index d8fe54ed7f33e0d9190a1b23bcfda9b7420b93bb..18d207355f70491b92572e68ca7598791368aef5 100644 --- a/src/Air/print.zig +++ b/src/Air/print.zig @@ -387,20 +387,20 @@ const Writer = struct { fn writeArg(w: *Writer, s: *std.Io.Writer, inst: Air.Inst.Index) Error!void { const arg = w.air.instructions.items(.data)[@backingInt(inst)].arg; - try w.writeType(s, arg.ty.toType()); + try w.writeType(s, arg.ty); try s.print(", {d}", .{arg.zir_param_index}); } fn writeTyOp(w: *Writer, s: *std.Io.Writer, inst: Air.Inst.Index) Error!void { const ty_op = w.air.instructions.items(.data)[@backingInt(inst)].ty_op; - try w.writeType(s, ty_op.ty.toType()); + try w.writeType(s, ty_op.ty); try s.writeAll(", "); try w.writeOperand(s, inst, 0, ty_op.operand); } fn writeBlock(w: *Writer, s: *std.Io.Writer, tag: Air.Inst.Tag, inst: Air.Inst.Index) Error!void { const ty_pl = w.air.instructions.items(.data)[@backingInt(inst)].ty_pl; - try w.writeType(s, ty_pl.ty.toType()); + try w.writeType(s, ty_pl.ty); const body = switch (tag) { .block => w.air.unwrapBlock(inst).body, @@ -448,7 +448,7 @@ const Writer = struct { fn writeAggregateInit(w: *Writer, s: *std.Io.Writer, inst: Air.Inst.Index) Error!void { const zcu = w.pt.zcu; const ty_pl = w.air.instructions.items(.data)[@backingInt(inst)].ty_pl; - const vector_ty = ty_pl.ty.toType(); + const vector_ty = ty_pl.ty; const len = @as(usize, @intCast(vector_ty.arrayLen(zcu))); const elements = @as([]const Air.Inst.Ref, @ptrCast(w.air.extra.items[ty_pl.payload..][0..len])); @@ -482,7 +482,7 @@ const Writer = struct { const ty_pl = data[@backingInt(inst)].ty_pl; const extra = w.air.extraData(Air.Bin, ty_pl.payload).data; - const inst_ty = data[@backingInt(inst)].ty_pl.ty.toType(); + const inst_ty = data[@backingInt(inst)].ty_pl.ty; try w.writeType(s, inst_ty); try s.writeAll(", "); try w.writeOperand(s, inst, 0, extra.lhs); @@ -608,7 +608,7 @@ const Writer = struct { fn writeRuntimeNavPtr(w: *Writer, s: *std.Io.Writer, inst: Air.Inst.Index) Error!void { const ip = &w.pt.zcu.intern_pool; const ty_nav = w.air.instructions.items(.data)[@backingInt(inst)].ty_nav; - try w.writeType(s, .fromInterned(ty_nav.ty)); + try w.writeType(s, ty_nav.ty); try s.print(", '{f}'", .{ip.getNav(ty_nav.nav).fqn.fmt(ip)}); } @@ -799,7 +799,7 @@ const Writer = struct { try w.writeOperand(s, inst, 0, unwrapped_try.error_union_ptr); try s.writeAll(", "); - try w.writeType(s, unwrapped_try.error_union_payload_ptr_ty.toType()); + try w.writeType(s, unwrapped_try.error_union_payload_ptr_ty); if (w.skip_body) return s.writeAll(", ..."); try s.writeAll(", {\n"); const old_indent = w.indent; diff --git a/src/Sema.zig b/src/Sema.zig index 64a76bf84fe8f69051eae384dc35025863a224b4..3bef560c7a1bab9caf91761bae10526c178aaa49 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -577,7 +577,7 @@ pub const Block = struct { return block.addInst(.{ .tag = tag, .data = .{ .ty_op = .{ - .ty = Air.internedToRef(ty.toIntern()), + .ty = ty, .operand = operand, } }, }); @@ -636,7 +636,6 @@ pub const Block = struct { field_index: u32, ptr_field_ty: Type, ) !Air.Inst.Ref { - const ty = Air.internedToRef(ptr_field_ty.toIntern()); const tag: Air.Inst.Tag = switch (field_index) { 0 => .struct_field_ptr_index_0, 1 => .struct_field_ptr_index_1, @@ -646,7 +645,7 @@ pub const Block = struct { return block.addInst(.{ .tag = .struct_field_ptr, .data = .{ .ty_pl = .{ - .ty = ty, + .ty = ptr_field_ty, .payload = try block.sema.addExtra(Air.StructField{ .struct_operand = struct_ptr, .field_index = field_index, @@ -658,7 +657,7 @@ pub const Block = struct { return block.addInst(.{ .tag = tag, .data = .{ .ty_op = .{ - .ty = ty, + .ty = ptr_field_ty, .operand = struct_ptr, } }, }); @@ -673,7 +672,7 @@ pub const Block = struct { return block.addInst(.{ .tag = .agg_field_val, .data = .{ .ty_pl = .{ - .ty = Air.internedToRef(field_ty.toIntern()), + .ty = field_ty, .payload = try block.sema.addExtra(Air.StructField{ .struct_operand = struct_val, .field_index = field_index, @@ -691,7 +690,7 @@ pub const Block = struct { return block.addInst(.{ .tag = .slice_elem_ptr, .data = .{ .ty_pl = .{ - .ty = Air.internedToRef(elem_ptr_ty.toIntern()), + .ty = elem_ptr_ty, .payload = try block.sema.addExtra(Air.Bin{ .lhs = slice, .rhs = elem_index, @@ -705,16 +704,6 @@ pub const Block = struct { array_ptr: Air.Inst.Ref, elem_index: Air.Inst.Ref, elem_ptr_ty: Type, - ) !Air.Inst.Ref { - const ty_ref = Air.internedToRef(elem_ptr_ty.toIntern()); - return block.addPtrElemPtrTypeRef(array_ptr, elem_index, ty_ref); - } - - fn addPtrElemPtrTypeRef( - block: *Block, - array_ptr: Air.Inst.Ref, - elem_index: Air.Inst.Ref, - elem_ptr_ty: Air.Inst.Ref, ) !Air.Inst.Ref { return block.addInst(.{ .tag = .ptr_elem_ptr, @@ -735,10 +724,10 @@ pub const Block = struct { return block.addInst(.{ .tag = if (block.float_mode == .optimized) .cmp_vector_optimized else .cmp_vector, .data = .{ .ty_pl = .{ - .ty = Air.internedToRef((try pt.vectorType(.{ + .ty = (try pt.vectorType(.{ .len = sema.typeOf(lhs).vectorLen(zcu), .child = .bool_type, - })).toIntern()), + })), .payload = try sema.addExtra(Air.VectorCmp{ .lhs = lhs, .rhs = rhs, @@ -771,7 +760,6 @@ pub const Block = struct { elements: []const Air.Inst.Ref, ) !Air.Inst.Ref { const sema = block.sema; - const ty_ref = Air.internedToRef(aggregate_ty.toIntern()); try sema.air_extra.ensureUnusedCapacity(sema.gpa, elements.len); const extra_index: u32 = @intCast(sema.air_extra.items.len); sema.appendRefsAssumeCapacity(elements); @@ -779,7 +767,7 @@ pub const Block = struct { return block.addInst(.{ .tag = .aggregate_init, .data = .{ .ty_pl = .{ - .ty = ty_ref, + .ty = aggregate_ty, .payload = extra_index, } }, }); @@ -794,7 +782,7 @@ pub const Block = struct { return block.addInst(.{ .tag = .union_init, .data = .{ .ty_pl = .{ - .ty = Air.internedToRef(union_ty.toIntern()), + .ty = union_ty, .payload = try block.sema.addExtra(Air.UnionInit{ .field_index = field_index, .init = init, @@ -3761,7 +3749,7 @@ fn finishResolveComptimeKnownAllocPtr( // this one to drop the side effect. We also need to rewrite the stores; we'll turn them to this // too because it doesn't really matter what they become. const nop_inst: Air.Inst = .{ .tag = .ptr_from_int, .data = .{ .ty_op = .{ - .ty = .fromIntern(alloc_ty.toIntern()), + .ty = alloc_ty, .operand = .zero_usize, } } }; @@ -4037,7 +4025,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com sema.air_instructions.set(@backingInt(placeholder_inst), .{ .tag = .block, .data = .{ .ty_pl = .{ - .ty = .void_type, + .ty = .void, .payload = sema.addExtraAssumeCapacity(Air.Block{ .body_len = @intCast(replacement_block.instructions.items.len), }), @@ -5191,7 +5179,7 @@ fn zirLoop(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError sema.air_instructions.appendAssumeCapacity(.{ .tag = .loop, .data = .{ .ty_pl = .{ - .ty = .noreturn_type, + .ty = .noreturn, .payload = undefined, } }, }); @@ -5349,7 +5337,7 @@ fn resolveBlockBody( try sema.air_extra.ensureUnusedCapacity(sema.gpa, @typeInfo(Air.Block).@"struct".field_names.len + child_block.instructions.items.len); sema.air_instructions.items(.data)[@backingInt(merges.block_inst)] = .{ .ty_pl = .{ - .ty = Air.internedToRef(operand_ty.toIntern()), + .ty = operand_ty, .payload = sema.addExtraAssumeCapacity(Air.Block{ .body_len = @intCast(child_block.instructions.items.len), }), @@ -5431,7 +5419,7 @@ fn resolveAnalyzedBlock( try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.DbgInlineBlock).@"struct".field_names.len + child_block.instructions.items.len); sema.air_instructions.items(.data)[@backingInt(merges.block_inst)] = .{ .ty_pl = .{ - .ty = .noreturn_type, + .ty = .noreturn, .payload = sema.addExtraAssumeCapacity(Air.DbgInlineBlock{ .func = child_block.inlining.?.func, .body_len = @intCast(child_block.instructions.items.len), @@ -5469,7 +5457,7 @@ fn resolveAnalyzedBlock( try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).@"struct".field_names.len + child_block.instructions.items.len); sema.air_instructions.items(.data)[@backingInt(merges.block_inst)] = .{ .ty_pl = .{ - .ty = .void_type, + .ty = .void, .payload = sema.addExtraAssumeCapacity(Air.Block{ .body_len = @intCast(child_block.instructions.items.len), }), @@ -5479,7 +5467,7 @@ fn resolveAnalyzedBlock( try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.DbgInlineBlock).@"struct".field_names.len + child_block.instructions.items.len); sema.air_instructions.items(.data)[@backingInt(merges.block_inst)] = .{ .ty_pl = .{ - .ty = .void_type, + .ty = .void, .payload = sema.addExtraAssumeCapacity(Air.DbgInlineBlock{ .func = child_block.inlining.?.func, .body_len = @intCast(child_block.instructions.items.len), @@ -5528,13 +5516,12 @@ fn resolveAnalyzedBlock( try sema.checkMergeAllowed(child_block, type_src, resolved_ty); - const ty_inst = Air.internedToRef(resolved_ty.toIntern()); switch (block_tag) { .block => { try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).@"struct".field_names.len + child_block.instructions.items.len); sema.air_instructions.items(.data)[@backingInt(merges.block_inst)] = .{ .ty_pl = .{ - .ty = ty_inst, + .ty = resolved_ty, .payload = sema.addExtraAssumeCapacity(Air.Block{ .body_len = @intCast(child_block.instructions.items.len), }), @@ -5544,7 +5531,7 @@ fn resolveAnalyzedBlock( try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.DbgInlineBlock).@"struct".field_names.len + child_block.instructions.items.len); sema.air_instructions.items(.data)[@backingInt(merges.block_inst)] = .{ .ty_pl = .{ - .ty = ty_inst, + .ty = resolved_ty, .payload = sema.addExtraAssumeCapacity(Air.DbgInlineBlock{ .func = child_block.inlining.?.func, .body_len = @intCast(child_block.instructions.items.len), @@ -5585,7 +5572,7 @@ fn resolveAnalyzedBlock( sema.air_instructions.items(.tag)[@backingInt(br)] = .block; sema.air_instructions.items(.data)[@backingInt(br)] = .{ .ty_pl = .{ - .ty = .noreturn_type, + .ty = .noreturn, .payload = sema.addExtraAssumeCapacity(Air.Block{ .body_len = sub_block_len, }), @@ -6093,7 +6080,7 @@ pub fn analyzeSaveErrRetIndex(sema: *Sema, block: *Block) SemaError!Air.Inst.Ref return try block.addInst(.{ .tag = .save_err_return_trace_index, .data = .{ .ty_pl = .{ - .ty = Air.internedToRef(stack_trace_ty.toIntern()), + .ty = stack_trace_ty, .payload = @intCast(field_index), } }, }); @@ -6140,7 +6127,7 @@ fn popErrorReturnTrace( .tag = .block, .data = .{ .ty_pl = .{ - .ty = .void_type, + .ty = .void, .payload = undefined, // updated below }, }, @@ -6294,7 +6281,7 @@ fn zirCall( const save_inst = try block.insertInst(block_index, .{ .tag = .save_err_return_trace_index, .data = .{ .ty_pl = .{ - .ty = Air.internedToRef(stack_trace_ty.toIntern()), + .ty = stack_trace_ty, .payload = @intCast(field_index), } }, }); @@ -10364,7 +10351,7 @@ fn analyzeSwitchBlock( const air_ref = try child_block.addInst(.{ .tag = air_tag, .data = .{ .ty_pl = .{ - .ty = .noreturn_type, + .ty = .noreturn, .payload = payload_index, } }, }); @@ -10446,7 +10433,7 @@ fn analyzeSwitchBlock( sema.air_instructions.set(@backingInt(placeholder_inst), .{ .tag = .block, .data = .{ .ty_pl = .{ - .ty = .noreturn_type, + .ty = .noreturn, .payload = sema.addExtraAssumeCapacity(Air.Block{ .body_len = @intCast(replacement_block.instructions.items.len), }), @@ -12401,7 +12388,7 @@ fn analyzeSwitchPayloadCaptureTaggedUnion( .tag = .block, .data = .{ .ty_pl = .{ - .ty = .fromType(capture_ty), + .ty = capture_ty, .payload = undefined, // updated below }, }, @@ -12492,7 +12479,7 @@ fn analyzeSwitchPayloadCaptureTaggedUnion( try sema.air_instructions.append(sema.gpa, .{ .tag = .get_union_tag, .data = .{ .ty_op = .{ - .ty = .fromIntern(union_obj.enum_tag_type), + .ty = .fromInterned(union_obj.enum_tag_type), .operand = loaded_operand, } }, }); @@ -13140,7 +13127,7 @@ fn zirShl( const op_ov = try block.addInst(.{ .tag = .shl_with_overflow, .data = .{ .ty_pl = .{ - .ty = .fromIntern(op_ov_tuple_ty.toIntern()), + .ty = op_ov_tuple_ty, .payload = try sema.addExtra(Air.Bin{ .lhs = lhs, .rhs = rhs, @@ -13673,7 +13660,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai const lhs_dest_slice = try block.addInst(.{ .tag = .slice, .data = .{ .ty_pl = .{ - .ty = .fromType(slice_ty), + .ty = slice_ty, .payload = try sema.addExtra(Air.Bin{ .lhs = many_alloc, .rhs = try pt.intRef(.usize, lhs_len), @@ -13688,7 +13675,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai const rhs_dest_offset = try block.addInst(.{ .tag = .ptr_add, .data = .{ .ty_pl = .{ - .ty = Air.internedToRef(many_ty.toIntern()), + .ty = many_ty, .payload = try sema.addExtra(Air.Bin{ .lhs = many_alloc, .rhs = try pt.intRef(.usize, lhs_len), @@ -13698,7 +13685,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai const rhs_dest_slice = try block.addInst(.{ .tag = .slice, .data = .{ .ty_pl = .{ - .ty = .fromType(slice_ty), + .ty = slice_ty, .payload = try sema.addExtra(Air.Bin{ .lhs = rhs_dest_offset, .rhs = try pt.intRef(.usize, rhs_len), @@ -14970,7 +14957,7 @@ fn zirOverflowArithmetic( return block.addInst(.{ .tag = air_tag, .data = .{ .ty_pl = .{ - .ty = Air.internedToRef(tuple_ty.toIntern()), + .ty = tuple_ty, .payload = try block.sema.addExtra(Air.Bin{ .lhs = lhs, .rhs = rhs, @@ -15267,7 +15254,7 @@ fn analyzePtrArithmetic( return block.addInst(.{ .tag = air_tag, .data = .{ .ty_pl = .{ - .ty = .fromType(new_ptr_ty), + .ty = new_ptr_ty, .payload = try sema.addExtra(Air.Bin{ .lhs = ptr, .rhs = offset, @@ -15330,7 +15317,7 @@ fn zirAsm( const ConstraintName = struct { c: []const u8, n: []const u8 }; const out_args = try sema.arena.alloc(Air.Inst.Ref, outputs_len); const outputs = try sema.arena.alloc(ConstraintName, outputs_len); - var expr_ty = Air.Inst.Ref.void_type; + var expr_ty: Type = .void; for (out_args, 0..) |*arg, out_i| { const output = sema.code.extraData(Zir.Inst.Asm.Output, extra_i); @@ -15352,7 +15339,7 @@ fn zirAsm( const out_ty = try sema.resolveType(block, ret_ty_src, output.data.operand); try sema.ensureLayoutResolved(out_ty, ret_ty_src, .asm_out_type); - expr_ty = .fromType(out_ty); + expr_ty = out_ty; break :out_ty out_ty; } else { const inst = sema.resolveInst(output.data.operand); @@ -15547,7 +15534,7 @@ fn zirAsm( buffer[input.c.len + 1 + input.n.len] = 0; sema.air_extra.items.len += (input.c.len + input.n.len + (2 + 3)) / 4; } - if (try expr_ty.toType().onePossibleValue(pt)) |opv| return .fromValue(opv); + if (try expr_ty.onePossibleValue(pt)) |opv| return .fromValue(opv); return asm_air; } @@ -17459,7 +17446,7 @@ fn zirBoolBr( try sema.air_instructions.append(gpa, .{ .tag = .block, .data = .{ .ty_pl = .{ - .ty = .bool_type, + .ty = .bool, .payload = undefined, } }, }); @@ -17879,13 +17866,12 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr new.child = err_union_ty.errorUnionPayload(zcu).toIntern(); break :info new; }); - const res_ty_ref = Air.internedToRef(res_ty.toIntern()); try sema.air_extra.ensureUnusedCapacity(sema.gpa, @typeInfo(Air.TryPtr).@"struct".field_names.len + sub_block.instructions.items.len); const try_inst = try parent_block.addInst(.{ .tag = if (is_cold) .try_ptr_cold else .try_ptr, .data = .{ .ty_pl = .{ - .ty = res_ty_ref, + .ty = res_ty, .payload = sema.addExtraAssumeCapacity(Air.TryPtr{ .ptr = operand, .body_len = @intCast(sub_block.instructions.items.len), @@ -18137,7 +18123,7 @@ fn maybePushErrorTrace( sema.air_instructions.appendAssumeCapacity(.{ .tag = .block, .data = .{ .ty_pl = .{ - .ty = .void_type, + .ty = .void, .payload = block_payload, } }, }); @@ -19333,10 +19319,9 @@ fn zirArrayInit( .child = array_ty.fieldType(i, zcu).toIntern(), .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, }); - const elem_ptr_ty_ref = Air.internedToRef(elem_ptr_ty.toIntern()); const index = try pt.intRef(.usize, i); - const elem_ptr = try block.addPtrElemPtrTypeRef(base_ptr, index, elem_ptr_ty_ref); + const elem_ptr = try block.addPtrElemPtr(base_ptr, index, elem_ptr_ty); _ = try block.addBinOp(.store, elem_ptr, arg); } return sema.makePtrConst(block, alloc); @@ -19346,11 +19331,10 @@ fn zirArrayInit( .child = array_ty.childType(zcu).toIntern(), .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, }); - const elem_ptr_ty_ref = Air.internedToRef(elem_ptr_ty.toIntern()); for (resolved_args, 0..) |arg, i| { const index = try pt.intRef(.usize, i); - const elem_ptr = try block.addPtrElemPtrTypeRef(base_ptr, index, elem_ptr_ty_ref); + const elem_ptr = try block.addPtrElemPtr(base_ptr, index, elem_ptr_ty); _ = try block.addBinOp(.store, elem_ptr, arg); } return sema.makePtrConst(block, alloc); @@ -22239,7 +22223,7 @@ fn ptrCastFull( break :ptr try block.addInst(.{ .tag = .addrspace_cast, .data = .{ .ty_op = .{ - .ty = Air.internedToRef(intermediate_ty.toIntern()), + .ty = intermediate_ty, .operand = pre_addrspace_cast, } }, }); @@ -22364,7 +22348,7 @@ fn ptrCastFull( return block.addInst(.{ .tag = .slice, .data = .{ .ty_pl = .{ - .ty = Air.internedToRef(dest_ty.toIntern()), + .ty = dest_ty, .payload = try sema.addExtra(Air.Bin{ .lhs = coerced_ptr, .rhs = result_len, @@ -23233,7 +23217,7 @@ fn zirCmpxchg( return block.addInst(.{ .tag = air_tag, .data = .{ .ty_pl = .{ - .ty = Air.internedToRef(result_ty.toIntern()), + .ty = result_ty, .payload = try sema.addExtra(Air.Cmpxchg{ .ptr = ptr, .expected_value = expected_value, @@ -23498,7 +23482,7 @@ fn analyzeShuffle( return block.addInst(.{ .tag = .shuffle_two, .data = .{ .ty_pl = .{ - .ty = Air.internedToRef(result_ty.toIntern()), + .ty = result_ty, .payload = air_extra_idx, } }, }); @@ -23517,7 +23501,7 @@ fn analyzeShuffle( return block.addInst(.{ .tag = .shuffle_one, .data = .{ .ty_pl = .{ - .ty = Air.internedToRef(result_ty.toIntern()), + .ty = result_ty, .payload = air_extra_idx, } }, }); @@ -23536,7 +23520,7 @@ fn analyzeShuffle( return block.addInst(.{ .tag = .shuffle_one, .data = .{ .ty_pl = .{ - .ty = Air.internedToRef(result_ty.toIntern()), + .ty = result_ty, .payload = air_extra_idx, } }, }); @@ -24083,7 +24067,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins break :result try block.addInst(.{ .tag = .field_parent_ptr, .data = .{ .ty_pl = .{ - .ty = .fromType(unaligned_parent_ptr_ty), + .ty = unaligned_parent_ptr_ty, .payload = try block.sema.addExtra(Air.FieldParentPtr{ .field_ptr = casted_field_ptr, .field_index = @intCast(field_index), @@ -25939,7 +25923,7 @@ fn addSafetyCheckExtra( sema.air_instructions.appendAssumeCapacity(.{ .tag = .block, .data = .{ .ty_pl = .{ - .ty = .void_type, + .ty = .void, .payload = sema.addExtraAssumeCapacity(Air.Block{ .body_len = 1, }), @@ -26485,7 +26469,7 @@ fn analyzeSpirvRuntimeArrayLen( return block.addInst(.{ .tag = .spirv_runtime_array_len, .data = .{ .ty_pl = .{ - .ty = .u32_type, + .ty = .u32, .payload = try sema.addExtra(Air.StructField{ .struct_operand = struct_operand, .field_index = field_index, @@ -30935,7 +30919,7 @@ fn analyzeNavRefInner(sema: *Sema, block: *Block, src: LazySrcLoc, orig_nav_inde return block.addInst(.{ .tag = .runtime_nav_ptr, .data = .{ .ty_nav = .{ - .ty = ptr_ty.toIntern(), + .ty = ptr_ty, .nav = nav_index, } }, }); @@ -31898,7 +31882,7 @@ fn analyzeSlice( const result = try block.addInst(.{ .tag = .slice, .data = .{ .ty_pl = .{ - .ty = Air.internedToRef(return_ty.toIntern()), + .ty = return_ty, .payload = try sema.addExtra(Air.Bin{ .lhs = new_ptr, .rhs = new_len, diff --git a/src/Zcu/PerThread.zig b/src/Zcu/PerThread.zig index 7de477dff17bbef9e24ac088df9f61f7c2ef1c2d..56de07bed5a44a25590f77de9ed10b2ae420d8b0 100644 --- a/src/Zcu/PerThread.zig +++ b/src/Zcu/PerThread.zig @@ -3378,7 +3378,7 @@ fn analyzeFuncBodyInner( sema.air_instructions.appendAssumeCapacity(.{ .tag = .arg, .data = .{ .arg = .{ - .ty = .fromIntern(param_ty.toIntern()), + .ty = param_ty, .zir_param_index = @intCast(zir_param_index), } }, }); diff --git a/src/codegen/aarch64.zig b/src/codegen/aarch64.zig index 0b53fdb79a1cb1e53848725991521601f2fa3647..3c9b683b9a2e908c21612d447308f98b34404690 100644 --- a/src/codegen/aarch64.zig +++ b/src/codegen/aarch64.zig @@ -75,7 +75,7 @@ pub fn generate( const air_args = for (air_main_body, 0..) |air_inst_index, body_index| { if (air.instructions.items(.tag)[@backingInt(air_inst_index)] != .arg) break air_main_body[0..body_index]; const arg = air.instructions.items(.data)[@backingInt(air_inst_index)].arg; - const param_ty = arg.ty.toType(); + const param_ty = arg.ty; const param_vi = param_vi: { if (arg.zir_param_index >= named_params_len) { assert(func_type.is_var_args); diff --git a/src/codegen/aarch64/Select.zig b/src/codegen/aarch64/Select.zig index e5bbeb4f5fed1256e23b30ea73e19a994ba504a8..3b8765e23a9f6ed943bbd73a95c812da364b2af1 100644 --- a/src/codegen/aarch64/Select.zig +++ b/src/codegen/aarch64/Select.zig @@ -279,7 +279,7 @@ pub fn analyze(isel: *Select, air_body: []const Air.Inst.Index) !void { const unwrapped_asm = isel.air.unwrapAsm(air_inst_index); for (unwrapped_asm.outputs) |operand| if (operand != .none) try isel.analyzeUse(operand); - if (ty_pl.ty != .void_type) try isel.def_order.putNoClobber(gpa, air_inst_index, {}); + if (ty_pl.ty.ip_index != .void_type) try isel.def_order.putNoClobber(gpa, air_inst_index, {}); air_body_index += 1; air_inst_index = air_body[air_body_index]; @@ -348,7 +348,7 @@ pub fn analyze(isel: *Select, air_body: []const Air.Inst.Index) !void { => { const ty_op = air_data[@backingInt(air_inst_index)].ty_op; maybe_noop: { - if (ty_op.ty.toInterned().? != isel.air.typeOf(ty_op.operand, ip).toIntern()) break :maybe_noop; + if (ty_op.ty.ip_index != isel.air.typeOf(ty_op.operand, ip).toIntern()) break :maybe_noop; if (true) break :maybe_noop; if (ty_op.operand.toIndex()) |src_air_inst_index| { if (isel.hints.get(src_air_inst_index)) |hint_vpsi| { @@ -792,7 +792,7 @@ pub fn analyze(isel: *Select, air_body: []const Air.Inst.Index) !void { }, .aggregate_init => { const ty_pl = air_data[@backingInt(air_inst_index)].ty_pl; - const elements: []const Air.Inst.Ref = @ptrCast(isel.air.extra.items[ty_pl.payload..][0..@intCast(ty_pl.ty.toType().arrayLen(zcu))]); + const elements: []const Air.Inst.Ref = @ptrCast(isel.air.extra.items[ty_pl.payload..][0..@intCast(ty_pl.ty.arrayLen(zcu))]); for (elements) |element| try isel.analyzeUse(element); try isel.def_order.putNoClobber(gpa, air_inst_index, {}); @@ -2475,10 +2475,10 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, const ty_pl = air.data(air.inst_index).ty_pl; const bin_op = isel.air.extraData(Air.Bin, ty_pl.payload).data; - const elem_size = ty_pl.ty.toType().childType(zcu).abiSize(zcu); + const elem_size = ty_pl.ty.childType(zcu).abiSize(zcu); const base_vi = try isel.use(bin_op.lhs); - var base_part_it = base_vi.field(ty_pl.ty.toType(), 0, 8); + var base_part_it = base_vi.field(ty_pl.ty, 0, 8); const base_part_vi = try base_part_it.only(isel); const base_part_mat = try base_part_vi.?.matReg(isel); const index_vi = try isel.use(bin_op.rhs); @@ -2656,9 +2656,9 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, const lhs_vi = try isel.use(bin_op.lhs); const rhs_vi = try isel.use(bin_op.rhs); const ty_size = lhs_vi.size(isel); - var overflow_it = res_vi.value.field(ty_pl.ty.toType(), ty_size, 1); + var overflow_it = res_vi.value.field(ty_pl.ty, ty_size, 1); const overflow_vi = try overflow_it.only(isel); - var wrapped_it = res_vi.value.field(ty_pl.ty.toType(), 0, ty_size); + var wrapped_it = res_vi.value.field(ty_pl.ty, 0, ty_size); const wrapped_vi = try wrapped_it.only(isel); try wrapped_vi.?.addOrSubtract(isel, ty, lhs_vi, switch (air_tag) { else => unreachable, @@ -2731,11 +2731,11 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, if (!std.mem.eql(u8, name, "_")) { const operand_gop = try as.operands.getOrPut(gpa, name); if (operand_gop.found_existing) return isel.fail("duplicate output name: '{s}'", .{name}); - operand_gop.value_ptr.* = .{ .register = switch (ty_pl.ty.toType().abiSize(zcu)) { + operand_gop.value_ptr.* = .{ .register = switch (ty_pl.ty.abiSize(zcu)) { 0 => unreachable, 1...4 => output_ra.w(), 5...8 => output_ra.x(), - else => return isel.fail("too big output type: '{f}'", .{isel.fmtType(ty_pl.ty.toType())}), + else => return isel.fail("too big output type: '{f}'", .{isel.fmtType(ty_pl.ty)}), } }; } } else if (std.mem.eql(u8, constraint, "=r")) { @@ -2746,11 +2746,11 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, if (!std.mem.eql(u8, name, "_")) { const operand_gop = try as.operands.getOrPut(gpa, name); if (operand_gop.found_existing) return isel.fail("duplicate output name: '{s}'", .{name}); - operand_gop.value_ptr.* = .{ .register = switch (ty_pl.ty.toType().abiSize(zcu)) { + operand_gop.value_ptr.* = .{ .register = switch (ty_pl.ty.abiSize(zcu)) { 0 => unreachable, 1...4 => output_ra.w(), 5...8 => output_ra.x(), - else => return isel.fail("too big output type: '{f}'", .{isel.fmtType(ty_pl.ty.toType())}), + else => return isel.fail("too big output type: '{f}'", .{isel.fmtType(ty_pl.ty)}), } }; } } else return isel.fail("invalid constraint: '{s}'", .{constraint}), @@ -3156,9 +3156,9 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, defer res_vi.value.deref(isel); const ty_op = air.data(air.inst_index).ty_op; - const ty = ty_op.ty.toType(); + const ty = ty_op.ty; const int_info: std.lang.Type.Int = int_info: { - if (ty_op.ty == .bool_type) break :int_info .{ .signedness = .unsigned, .bits = 1 }; + if (ty_op.ty.ip_index == .bool_type) break :int_info .{ .signedness = .unsigned, .bits = 1 }; if (!ty.isAbiInt(zcu)) return isel.fail("bad {t} {f}", .{ air_tag, isel.fmtType(ty) }); break :int_info ty.intInfo(zcu); }; @@ -3215,7 +3215,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, if (isel.live_values.fetchRemove(air.inst_index)) |dst_vi| unused: { defer dst_vi.value.deref(isel); const ty_op = air.data(air.inst_index).ty_op; - const dst_ty = ty_op.ty.toType(); + const dst_ty = ty_op.ty; const dst_tag = dst_ty.zigTypeTag(zcu); const src_ty = isel.air.typeOf(ty_op.operand, ip); const src_tag = src_ty.zigTypeTag(zcu); @@ -3869,7 +3869,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, defer res_vi.value.deref(isel); const ty_op = air.data(air.inst_index).ty_op; - const ty = ty_op.ty.toType(); + const ty = ty_op.ty; if (!ty.isAbiInt(zcu)) return isel.fail("bad {t} {f}", .{ air_tag, isel.fmtType(ty) }); const int_info = ty.intInfo(zcu); if (int_info.bits > 64) return isel.fail("too big {t} {f}", .{ air_tag, isel.fmtType(ty) }); @@ -3933,7 +3933,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, defer res_vi.value.deref(isel); const ty_op = air.data(air.inst_index).ty_op; - const ty = ty_op.ty.toType(); + const ty = ty_op.ty; if (!ty.isAbiInt(zcu)) return isel.fail("bad {t} {f}", .{ air_tag, isel.fmtType(ty) }); const int_info = ty.intInfo(zcu); if (int_info.bits > 64) return isel.fail("too big {t} {f}", .{ air_tag, isel.fmtType(ty) }); @@ -4235,7 +4235,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, defer res_vi.value.deref(isel); const ty_op = air.data(air.inst_index).ty_op; - const ty = ty_op.ty.toType(); + const ty = ty_op.ty; if (!ty.isRuntimeFloat()) { if (!ty.isAbiInt(zcu)) return isel.fail("bad {t} {f}", .{ air_tag, isel.fmtType(ty) }); switch (ty.intInfo(zcu).bits) { @@ -4860,7 +4860,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, const error_union_ptr_mat = try error_union_ptr_vi.matReg(isel); if (isel.live_values.fetchRemove(air.inst_index)) |payload_ptr_vi| unused: { defer payload_ptr_vi.value.deref(isel); - switch (codegen.errUnionPayloadOffset(unwrapped_try.error_union_payload_ptr_ty.toType().childType(zcu), zcu)) { + switch (codegen.errUnionPayloadOffset(unwrapped_try.error_union_payload_ptr_ty.childType(zcu), zcu)) { 0 => try payload_ptr_vi.value.move(isel, unwrapped_try.error_union_ptr), else => |payload_offset| { const payload_ptr_ra = try payload_ptr_vi.value.defReg(isel) orelse break :unused; @@ -4989,7 +4989,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, if (size <= Value.max_parts and ip.zigTypeTag(ptr_info.child) != .@"union") { const ptr_vi = try isel.use(ty_op.operand); const ptr_mat = try ptr_vi.matReg(isel); - _ = try dst_vi.value.load(isel, ty_op.ty.toType(), ptr_mat.ra, .{ + _ = try dst_vi.value.load(isel, ty_op.ty, ptr_mat.ra, .{ .@"volatile" = ptr_info.flags.is_volatile, }); try ptr_mat.finish(isel); @@ -5137,7 +5137,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, defer dst_vi.value.deref(isel); const ty_op = air.data(air.inst_index).ty_op; - const dst_ty = ty_op.ty.toType(); + const dst_ty = ty_op.ty; const dst_bits = dst_ty.floatBits(isel.target); const src_ty = isel.air.typeOf(ty_op.operand, ip); const src_bits = src_ty.floatBits(isel.target); @@ -5247,7 +5247,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, defer dst_vi.value.deref(isel); const ty_op = air.data(air.inst_index).ty_op; - const dst_ty = ty_op.ty.toType(); + const dst_ty = ty_op.ty; const dst_int_info = dst_ty.intInfo(zcu); const src_ty = isel.air.typeOf(ty_op.operand, ip); const src_int_info = src_ty.intInfo(zcu); @@ -5338,7 +5338,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, defer dst_vi.value.deref(isel); const ty_op = air.data(air.inst_index).ty_op; - const dst_ty = ty_op.ty.toType(); + const dst_ty = ty_op.ty; const dst_int_info = dst_ty.intInfo(zcu); const src_ty = isel.air.typeOf(ty_op.operand, ip); const src_int_info = src_ty.intInfo(zcu); @@ -5440,7 +5440,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, defer dst_vi.value.deref(isel); const ty_op = air.data(air.inst_index).ty_op; - const dst_ty = ty_op.ty.toType(); + const dst_ty = ty_op.ty; const src_ty = isel.air.typeOf(ty_op.operand, ip); if (!dst_ty.isAbiInt(zcu) or !src_ty.isAbiInt(zcu)) return isel.fail("bad {t} {f} {f}", .{ air_tag, isel.fmtType(dst_ty), isel.fmtType(src_ty) }); const dst_int_info = dst_ty.intInfo(zcu); @@ -5536,7 +5536,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, const opt_vi = try isel.use(ty_op.operand); var payload_part_it = opt_vi.field(opt_ty, 0, payload_vi.value.size(isel)); const payload_part_vi = try payload_part_it.only(isel); - try payload_vi.value.copy(isel, ty_op.ty.toType(), payload_part_vi.?); + try payload_vi.value.copy(isel, ty_op.ty, payload_part_vi.?); } if (air.next()) |next_air_tag| continue :air_tag next_air_tag; }, @@ -5576,16 +5576,16 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, defer opt_vi.value.deref(isel); const ty_op = air.data(air.inst_index).ty_op; - if (ty_op.ty.toType().optionalReprIsPayload(zcu)) { + if (ty_op.ty.optionalReprIsPayload(zcu)) { try opt_vi.value.move(isel, ty_op.operand); break :unused; } const payload_size = isel.air.typeOf(ty_op.operand, ip).abiSize(zcu); - var payload_part_it = opt_vi.value.field(ty_op.ty.toType(), 0, payload_size); + var payload_part_it = opt_vi.value.field(ty_op.ty, 0, payload_size); const payload_part_vi = try payload_part_it.only(isel); try payload_part_vi.?.move(isel, ty_op.operand); - var has_value_part_it = opt_vi.value.field(ty_op.ty.toType(), payload_size, 1); + var has_value_part_it = opt_vi.value.field(ty_op.ty, payload_size, 1); const has_value_part_vi = try has_value_part_it.only(isel); const has_value_part_ra = try has_value_part_vi.?.defReg(isel) orelse break :unused; try isel.emit(.movz(has_value_part_ra.w(), 1, .{ .lsl = .@"0" })); @@ -5602,11 +5602,11 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, const error_union_vi = try isel.use(ty_op.operand); var payload_part_it = error_union_vi.field( error_union_ty, - codegen.errUnionPayloadOffset(ty_op.ty.toType(), zcu), + codegen.errUnionPayloadOffset(ty_op.ty, zcu), payload_vi.value.size(isel), ); const payload_part_vi = try payload_part_it.only(isel); - try payload_vi.value.copy(isel, ty_op.ty.toType(), payload_part_vi.?); + try payload_vi.value.copy(isel, ty_op.ty, payload_part_vi.?); } if (air.next()) |next_air_tag| continue :air_tag next_air_tag; }, @@ -5624,7 +5624,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, error_set_vi.value.size(isel), ); const error_set_part_vi = try error_set_part_it.only(isel); - try error_set_vi.value.copy(isel, ty_op.ty.toType(), error_set_part_vi.?); + try error_set_vi.value.copy(isel, ty_op.ty, error_set_part_vi.?); } if (air.next()) |next_air_tag| continue :air_tag next_air_tag; }, @@ -5632,7 +5632,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, if (isel.live_values.fetchRemove(air.inst_index)) |payload_ptr_vi| unused: { defer payload_ptr_vi.value.deref(isel); const ty_op = air.data(air.inst_index).ty_op; - switch (codegen.errUnionPayloadOffset(ty_op.ty.toType().childType(zcu), zcu)) { + switch (codegen.errUnionPayloadOffset(ty_op.ty.childType(zcu), zcu)) { 0 => try payload_ptr_vi.value.move(isel, ty_op.operand), else => |payload_offset| { const payload_ptr_ra = try payload_ptr_vi.value.defReg(isel) orelse break :unused; @@ -5660,7 +5660,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, const error_union_ptr_info = error_union_ptr_ty.ptrInfo(zcu); const error_union_ptr_vi = try isel.use(ty_op.operand); const error_union_ptr_mat = try error_union_ptr_vi.matReg(isel); - _ = try error_vi.value.load(isel, ty_op.ty.toType(), error_union_ptr_mat.ra, .{ + _ = try error_vi.value.load(isel, ty_op.ty, error_union_ptr_mat.ra, .{ .offset = codegen.errUnionErrorOffset( ZigType.fromInterned(error_union_ptr_info.child).errorUnionPayload(zcu), zcu, @@ -5675,7 +5675,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, if (isel.live_values.fetchRemove(air.inst_index)) |payload_ptr_vi| unused: { defer payload_ptr_vi.value.deref(isel); const ty_op = air.data(air.inst_index).ty_op; - const payload_ty = ty_op.ty.toType().childType(zcu); + const payload_ty = ty_op.ty.childType(zcu); const error_union_ty = isel.air.typeOf(ty_op.operand, ip).childType(zcu); const error_set_size = error_union_ty.errorUnionSet(zcu).abiSize(zcu); const error_union_ptr_vi = try isel.use(ty_op.operand); @@ -5712,7 +5712,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, defer error_union_vi.value.deref(isel); const ty_op = air.data(air.inst_index).ty_op; - const error_union_ty = ty_op.ty.toType(); + const error_union_ty = ty_op.ty; const error_union_info = ip.indexToKey(error_union_ty.toIntern()).error_union_type; const error_set_ty: ZigType = .fromInterned(error_union_info.error_set_type); const payload_ty: ZigType = .fromInterned(error_union_info.payload_type); @@ -5739,7 +5739,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, defer error_union_vi.value.deref(isel); const ty_op = air.data(air.inst_index).ty_op; - const error_union_ty = ty_op.ty.toType(); + const error_union_ty = ty_op.ty; const error_union_info = ip.indexToKey(error_union_ty.toIntern()).error_union_type; const error_set_ty: ZigType = .fromInterned(error_union_info.error_set_type); const payload_ty: ZigType = .fromInterned(error_union_info.payload_type); @@ -5766,7 +5766,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, const extra = isel.air.extraData(Air.StructField, ty_pl.payload).data; switch (codegen.fieldOffset( isel.air.typeOf(extra.struct_operand, ip), - ty_pl.ty.toType(), + ty_pl.ty, extra.field_index, zcu, )) { @@ -5799,7 +5799,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, const ty_op = air.data(air.inst_index).ty_op; switch (codegen.fieldOffset( isel.air.typeOf(ty_op.operand, ip), - ty_op.ty.toType(), + ty_op.ty, switch (air_tag) { else => unreachable, .struct_field_ptr_index_0 => 0, @@ -5835,7 +5835,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, const ty_pl = air.data(air.inst_index).ty_pl; const extra = isel.air.extraData(Air.StructField, ty_pl.payload).data; const agg_ty = isel.air.typeOf(extra.struct_operand, ip); - const field_ty = ty_pl.ty.toType(); + const field_ty = ty_pl.ty; const field_bit_offset, const field_bit_size, const is_packed = switch (agg_ty.containerLayout(zcu)) { .auto, .@"extern" => .{ 8 * agg_ty.structFieldOffset(extra.field_index, zcu), @@ -5861,7 +5861,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, .@"struct" => { var agg_part_it = agg_vi.field(agg_ty, @divExact(field_bit_offset, 8), @divExact(field_bit_size, 8)); while (try agg_part_it.next(isel)) |agg_part| { - var field_part_it = field_vi.value.field(ty_pl.ty.toType(), agg_part.offset, agg_part.vi.size(isel)); + var field_part_it = field_vi.value.field(ty_pl.ty, agg_part.offset, agg_part.vi.size(isel)); const field_part_vi = try field_part_it.only(isel); if (field_part_vi.? == agg_part.vi) continue; var field_subpart_it = field_part_vi.?.parts(isel); @@ -5931,7 +5931,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, const union_vi = try isel.use(ty_op.operand); var tag_part_it = union_vi.field(union_ty, union_layout.tagOffset(), union_layout.tag_size); const tag_part_vi = try tag_part_it.only(isel); - try tag_vi.value.copy(isel, ty_op.ty.toType(), tag_part_vi.?); + try tag_vi.value.copy(isel, ty_op.ty, tag_part_vi.?); } if (air.next()) |next_air_tag| continue :air_tag next_air_tag; }, @@ -5940,10 +5940,10 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, defer slice_vi.value.deref(isel); const ty_pl = air.data(air.inst_index).ty_pl; const bin_op = isel.air.extraData(Air.Bin, ty_pl.payload).data; - var ptr_part_it = slice_vi.value.field(ty_pl.ty.toType(), 0, 8); + var ptr_part_it = slice_vi.value.field(ty_pl.ty, 0, 8); const ptr_part_vi = try ptr_part_it.only(isel); try ptr_part_vi.?.move(isel, bin_op.lhs); - var len_part_it = slice_vi.value.field(ty_pl.ty.toType(), 8, 8); + var len_part_it = slice_vi.value.field(ty_pl.ty, 8, 8); const len_part_vi = try len_part_it.only(isel); try len_part_vi.?.move(isel, bin_op.rhs); } @@ -5956,7 +5956,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, const slice_vi = try isel.use(ty_op.operand); var len_part_it = slice_vi.field(isel.air.typeOf(ty_op.operand, ip), 8, 8); const len_part_vi = try len_part_it.only(isel); - try len_vi.value.copy(isel, ty_op.ty.toType(), len_part_vi.?); + try len_vi.value.copy(isel, ty_op.ty, len_part_vi.?); } if (air.next()) |next_air_tag| continue :air_tag next_air_tag; }, @@ -5967,7 +5967,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, const slice_vi = try isel.use(ty_op.operand); var ptr_part_it = slice_vi.field(isel.air.typeOf(ty_op.operand, ip), 0, 8); const ptr_part_vi = try ptr_part_it.only(isel); - try ptr_vi.value.copy(isel, ty_op.ty.toType(), ptr_part_vi.?); + try ptr_vi.value.copy(isel, ty_op.ty, ptr_part_vi.?); } if (air.next()) |next_air_tag| continue :air_tag next_air_tag; }, @@ -6180,7 +6180,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, const ty_pl = air.data(air.inst_index).ty_pl; const bin_op = isel.air.extraData(Air.Bin, ty_pl.payload).data; - const elem_size = ty_pl.ty.toType().childType(zcu).abiSize(zcu); + const elem_size = ty_pl.ty.childType(zcu).abiSize(zcu); const slice_vi = try isel.use(bin_op.lhs); var ptr_part_it = slice_vi.field(isel.air.typeOf(bin_op.lhs, ip), 0, 8); @@ -6286,7 +6286,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, const ty_pl = air.data(air.inst_index).ty_pl; const bin_op = isel.air.extraData(Air.Bin, ty_pl.payload).data; - const elem_size = ty_pl.ty.toType().childType(zcu).abiSize(zcu); + const elem_size = ty_pl.ty.childType(zcu).abiSize(zcu); const base_vi = try isel.use(bin_op.lhs); const base_mat = try base_vi.matReg(isel); @@ -6301,10 +6301,10 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, if (isel.live_values.fetchRemove(air.inst_index)) |slice_vi| { defer slice_vi.value.deref(isel); const ty_op = air.data(air.inst_index).ty_op; - var ptr_part_it = slice_vi.value.field(ty_op.ty.toType(), 0, 8); + var ptr_part_it = slice_vi.value.field(ty_op.ty, 0, 8); const ptr_part_vi = try ptr_part_it.only(isel); try ptr_part_vi.?.move(isel, ty_op.operand); - var len_part_it = slice_vi.value.field(ty_op.ty.toType(), 8, 8); + var len_part_it = slice_vi.value.field(ty_op.ty, 8, 8); const len_part_vi = try len_part_it.only(isel); if (try len_part_vi.?.defReg(isel)) |len_ra| try isel.movImmediate( len_ra.x(), @@ -6318,7 +6318,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, defer dst_vi.value.deref(isel); const ty_op = air.data(air.inst_index).ty_op; - const dst_ty = ty_op.ty.toType(); + const dst_ty = ty_op.ty; const src_ty = isel.air.typeOf(ty_op.operand, ip); if (!dst_ty.isAbiInt(zcu)) return isel.fail("bad {t} {f} {f}", .{ air_tag, isel.fmtType(dst_ty), isel.fmtType(src_ty) }); const dst_int_info = dst_ty.intInfo(zcu); @@ -6460,7 +6460,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, defer dst_vi.value.deref(isel); const ty_op = air.data(air.inst_index).ty_op; - const dst_ty = ty_op.ty.toType(); + const dst_ty = ty_op.ty; const src_ty = isel.air.typeOf(ty_op.operand, ip); const dst_bits = dst_ty.floatBits(isel.target); if (!src_ty.isAbiInt(zcu)) return isel.fail("bad {t} {f} {f}", .{ air_tag, isel.fmtType(dst_ty), isel.fmtType(src_ty) }); @@ -6884,7 +6884,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, defer agg_vi.value.deref(isel); const ty_pl = air.data(air.inst_index).ty_pl; - const agg_ty = ty_pl.ty.toType(); + const agg_ty = ty_pl.ty; switch (ip.indexToKey(agg_ty.toIntern())) { .array_type => |array_type| { const elems: []const Air.Inst.Ref = @@ -6959,7 +6959,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, const ty_pl = air.data(air.inst_index).ty_pl; const extra = isel.air.extraData(Air.UnionInit, ty_pl.payload).data; - const union_ty = ty_pl.ty.toType(); + const union_ty = ty_pl.ty; const loaded_union = ip.loadUnionType(union_ty.toIntern()); const union_layout = ZigType.getUnionLayout(loaded_union, zcu); @@ -7171,7 +7171,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, const ty_pl = air.data(air.inst_index).ty_pl; const extra = isel.air.extraData(Air.FieldParentPtr, ty_pl.payload).data; switch (codegen.fieldOffset( - ty_pl.ty.toType(), + ty_pl.ty, isel.air.typeOf(extra.field_ptr, ip), extra.field_index, zcu, @@ -7259,7 +7259,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, const maybe_arg_vi = isel.live_values.fetchRemove(air.inst_index); defer if (maybe_arg_vi) |arg_vi| arg_vi.value.deref(isel); const ty_op = air.data(air.inst_index).ty_op; - const ty = ty_op.ty.toType(); + const ty = ty_op.ty; var param_it: CallAbiIterator = .init; const param_vi = try param_it.param(isel, ty); defer param_vi.?.deref(isel); @@ -7459,7 +7459,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, const ty_op = air.data(air.inst_index).ty_op; const va_list_ptr_vi = try isel.use(ty_op.operand); const va_list_ptr_mat = try va_list_ptr_vi.matReg(isel); - _ = try va_list_vi.value.load(isel, ty_op.ty.toType(), va_list_ptr_mat.ra, .{}); + _ = try va_list_vi.value.load(isel, ty_op.ty, va_list_ptr_mat.ra, .{}); try va_list_ptr_mat.finish(isel); } if (air.next()) |next_air_tag| continue :air_tag next_air_tag; diff --git a/src/codegen/c.zig b/src/codegen/c.zig index 977295ad3013414ebee2739b251da717e735a358..e040445c15c506adf466bfd29ead358ad79cbdb1 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -3413,7 +3413,7 @@ fn airIntCast(f: *Function, inst: Air.Inst.Index, operation: []const u8, info: B const zcu = pt.zcu; const ty_op = f.air.instructions.items(.data)[@backingInt(inst)].ty_op; - const inst_ty = ty_op.ty.toType(); + const inst_ty = ty_op.ty; const inst_scalar_ty = inst_ty.scalarType(zcu); const operand_ty = f.typeOf(ty_op.operand); const operand_scalar_ty = operand_ty.scalarType(zcu); @@ -7219,7 +7219,7 @@ fn airMulAdd(f: *Function, inst: Air.Inst.Index) !CValue { fn airRuntimeNavPtr(f: *Function, inst: Air.Inst.Index) !CValue { const ty_nav = f.air.instructions.items(.data)[@backingInt(inst)].ty_nav; const w = &f.code.writer; - const local = try f.allocLocal(inst, .fromInterned(ty_nav.ty)); + const local = try f.allocLocal(inst, ty_nav.ty); try f.writeCValue(w, local, .other); try w.writeAll(" = "); try f.dg.renderNav(w, ty_nav.nav, .other); @@ -7261,7 +7261,7 @@ fn airCVaArg(f: *Function, inst: Air.Inst.Index) !CValue { try w.writeAll(" = va_arg(*(va_list *)"); try f.writeCValue(w, va_list, .other); try w.writeAll(", "); - try f.renderType(w, ty_op.ty.toType()); + try f.renderType(w, ty_op.ty); try w.writeAll(");"); try f.newline(); return local; diff --git a/src/codegen/llvm/FuncGen.zig b/src/codegen/llvm/FuncGen.zig index 3efb14d1b3118828adc2b316c8e1f920d51336e2..d65a23146f081f5bbc1f7c40980db2faadb0db63 100644 --- a/src/codegen/llvm/FuncGen.zig +++ b/src/codegen/llvm/FuncGen.zig @@ -1164,7 +1164,7 @@ fn airRetLoad(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!void { fn airCVaArg(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value { const ty_op = self.air.instructions.items(.data)[@backingInt(inst)].ty_op; const list = try self.resolveInst(ty_op.operand); - const arg_ty = ty_op.ty.toType(); + const arg_ty = ty_op.ty; const llvm_arg_ty = try self.object.lowerType(arg_ty, .as_value); return self.wip.vaArg(list, llvm_arg_ty, ""); @@ -1175,7 +1175,7 @@ fn airCVaCopy(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Valu const zcu = o.zcu; const ty_op = self.air.instructions.items(.data)[@backingInt(inst)].ty_op; const src_list = try self.resolveInst(ty_op.operand); - const va_list_ty = ty_op.ty.toType(); + const va_list_ty = ty_op.ty; const dest_list = try self.buildZigAlloca(va_list_ty, .none); @@ -2393,11 +2393,11 @@ fn airFieldParentPtr(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Build const field_ptr = try self.resolveInst(extra.field_ptr); - const parent_ty = ty_pl.ty.toType().childType(zcu); + const parent_ty = ty_pl.ty.childType(zcu); const field_offset = parent_ty.structFieldOffset(extra.field_index, zcu); if (field_offset == 0) return field_ptr; - const res_ty = try o.lowerType(ty_pl.ty.toType(), .as_value); + const res_ty = try o.lowerType(ty_pl.ty, .as_value); const llvm_usize = try o.lowerType(.usize, .as_value); const field_ptr_int = try self.wip.cast(.ptrtoint, field_ptr, llvm_usize, ""); @@ -3191,7 +3191,7 @@ fn airSaveErrReturnTraceIndex(self: *FuncGen, inst: Air.Inst.Index) Allocator.Er const zcu = self.object.zcu; const ty_pl = self.air.instructions.items(.data)[@backingInt(inst)].ty_pl; - const struct_ty = ty_pl.ty.toType(); + const struct_ty = ty_pl.ty; const field_index = ty_pl.payload; assert(self.err_ret_trace != .none); @@ -5902,7 +5902,7 @@ fn airErrorSetHasValue(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Bui const ip = &zcu.intern_pool; const ty_op = self.air.instructions.items(.data)[@backingInt(inst)].ty_op; const operand = try self.resolveInst(ty_op.operand); - const error_set_ty = ty_op.ty.toType(); + const error_set_ty = ty_op.ty; const names = error_set_ty.errorSetNames(zcu); const valid_block = try self.wip.block(@intCast(names.len), "Valid"); diff --git a/src/codegen/riscv64/CodeGen.zig b/src/codegen/riscv64/CodeGen.zig index 17561ce3a902510c50446d4a202724cd156039e5..106640f519a47de8a43a420bc539a716f47f711f 100644 --- a/src/codegen/riscv64/CodeGen.zig +++ b/src/codegen/riscv64/CodeGen.zig @@ -3536,7 +3536,7 @@ fn airWrapErrUnionPayload(func: *Func, inst: Air.Inst.Index) !void { const zcu = pt.zcu; const ty_op = func.air.instructions.items(.data)[@backingInt(inst)].ty_op; - const eu_ty = ty_op.ty.toType(); + const eu_ty = ty_op.ty; const pl_ty = eu_ty.errorUnionPayload(zcu); const err_ty = eu_ty.errorUnionSet(zcu); const operand = try func.resolveInst(ty_op.operand); @@ -3561,7 +3561,7 @@ fn airWrapErrUnionErr(func: *Func, inst: Air.Inst.Index) !void { const zcu = pt.zcu; const ty_op = func.air.instructions.items(.data)[@backingInt(inst)].ty_op; - const eu_ty = ty_op.ty.toType(); + const eu_ty = ty_op.ty; const pl_ty = eu_ty.errorUnionPayload(zcu); const err_ty = eu_ty.errorUnionSet(zcu); @@ -3583,7 +3583,7 @@ fn airRuntimeNavPtr(func: *Func, inst: Air.Inst.Index) !void { const zcu = func.pt.zcu; const ip = &zcu.intern_pool; const ty_nav = func.air.instructions.items(.data)[@backingInt(inst)].ty_nav; - const ptr_ty: Type = .fromInterned(ty_nav.ty); + const ptr_ty: Type = ty_nav.ty; const nav = ip.getNav(ty_nav.nav); const tlv_sym_index = if (func.bin_file.cast(.elf)) |elf_file| sym: { @@ -7295,7 +7295,7 @@ fn airFloatFromInt(func: *Func, inst: Air.Inst.Index) !void { const operand = try func.resolveInst(ty_op.operand); const src_ty = func.typeOf(ty_op.operand); - const dst_ty = ty_op.ty.toType(); + const dst_ty = ty_op.ty; const src_reg, const src_lock = try func.promoteReg(src_ty, operand); defer if (src_lock) |lock| func.register_manager.unlockReg(lock); @@ -7358,7 +7358,7 @@ fn airIntFromFloat(func: *Func, inst: Air.Inst.Index) !void { const operand = try func.resolveInst(ty_op.operand); const src_ty = func.typeOf(ty_op.operand); - const dst_ty = ty_op.ty.toType(); + const dst_ty = ty_op.ty; const is_unsigned = dst_ty.isUnsignedInt(zcu); const src_bits = src_ty.bitSize(zcu); diff --git a/src/codegen/sparc64/CodeGen.zig b/src/codegen/sparc64/CodeGen.zig index c0ccd968fe60f3ee0fd2a8bd3f637d521734e418..e354976c91628f88e6d4c71180ab8cf4351fc538 100644 --- a/src/codegen/sparc64/CodeGen.zig +++ b/src/codegen/sparc64/CodeGen.zig @@ -2650,7 +2650,7 @@ fn airWrapErrUnionErr(self: *Self, inst: Air.Inst.Index) !void { const zcu = pt.zcu; const ty_op = self.air.instructions.items(.data)[@backingInt(inst)].ty_op; const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: { - const error_union_ty = ty_op.ty.toType(); + const error_union_ty = ty_op.ty; const payload_ty = error_union_ty.errorUnionPayload(zcu); const mcv = try self.resolveInst(ty_op.operand); if (!payload_ty.hasRuntimeBits(zcu)) break :result mcv; diff --git a/src/codegen/spirv/CodeGen.zig b/src/codegen/spirv/CodeGen.zig index f89fbdb4e40e957e6f180f053d2d19524c174824..ffaa71766afb2b5ae9f329b9d9ee14812231cf8b 100644 --- a/src/codegen/spirv/CodeGen.zig +++ b/src/codegen/spirv/CodeGen.zig @@ -7064,7 +7064,7 @@ fn airFieldParentPtr(cg: *CodeGen, inst: Air.Inst.Index) !?Id { const ty_pl = cg.air.instructions.items(.data)[@backingInt(inst)].ty_pl; const extra = cg.air.extraData(Air.FieldParentPtr, ty_pl.payload).data; - const parent_ptr_ty = ty_pl.ty.toType(); + const parent_ptr_ty = ty_pl.ty; const parent_ty = parent_ptr_ty.childType(zcu); const result_ty_id = try cg.resolveType(parent_ptr_ty, .indirect); diff --git a/src/codegen/wasm/CodeGen.zig b/src/codegen/wasm/CodeGen.zig index 7c6733259b4b2f8f591534836ffadbe18868fe31..993cf26ad66ffae0467a097097c50398751caee9 100644 --- a/src/codegen/wasm/CodeGen.zig +++ b/src/codegen/wasm/CodeGen.zig @@ -1591,7 +1591,7 @@ fn genInst(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { .int_cast => { const ty_op = cg.air.instructions.items(.data)[@backingInt(inst)].ty_op; - const dest_ty = ty_op.ty.toType(); + const dest_ty = ty_op.ty; const operand = try cg.resolveInst(ty_op.operand); const src_ty = cg.typeOf(ty_op.operand); @@ -1620,7 +1620,7 @@ fn genInst(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { const ty_op = cg.air.instructions.items(.data)[@backingInt(inst)].ty_op; const operand = try cg.resolveInst(ty_op.operand); - const dest_ty = ty_op.ty.toType(); + const dest_ty = ty_op.ty; const src_ty = cg.typeOf(ty_op.operand); if (dest_ty.zigTypeTag(zcu) == .vector or src_ty.zigTypeTag(zcu) == .vector) { @@ -2385,7 +2385,7 @@ fn airLoad(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { const zcu = pt.zcu; const ty_op = cg.air.instructions.items(.data)[@backingInt(inst)].ty_op; const operand = try cg.resolveInst(ty_op.operand); - const elem_ty = ty_op.ty.toType(); + const elem_ty = ty_op.ty; const ptr_ty = cg.typeOf(ty_op.operand); const ptr_info = ptr_ty.ptrInfo(zcu); @@ -6176,7 +6176,7 @@ fn airWrapErrUnionErr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { const ty_op = cg.air.instructions.items(.data)[@backingInt(inst)].ty_op; const operand = try cg.resolveInst(ty_op.operand); - const err_ty = ty_op.ty.toType(); + const err_ty = ty_op.ty; const pl_ty = err_ty.errorUnionPayload(zcu); const result = result: { @@ -6402,7 +6402,7 @@ fn airSliceElemPtr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { const ty_pl = cg.air.instructions.items(.data)[@backingInt(inst)].ty_pl; const bin_op = cg.air.extraData(Air.Bin, ty_pl.payload).data; - const elem_ty = ty_pl.ty.toType().childType(zcu); + const elem_ty = ty_pl.ty.childType(zcu); const elem_size = elem_ty.abiSize(zcu); const slice = try cg.resolveInst(bin_op.lhs); @@ -6441,7 +6441,7 @@ fn airArrayToSlice(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { const operand = try cg.resolveInst(ty_op.operand); const array_ty = cg.typeOf(ty_op.operand).childType(zcu); - const slice_ty = ty_op.ty.toType(); + const slice_ty = ty_op.ty; // create a slice on the stack const slice_local = try cg.allocStack(slice_ty); @@ -6489,7 +6489,7 @@ fn airPtrElemPtr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { const bin_op = cg.air.extraData(Air.Bin, ty_pl.payload).data; const ptr_ty = cg.typeOf(bin_op.lhs); - const elem_ty = ty_pl.ty.toType().childType(zcu); + const elem_ty = ty_pl.ty.childType(zcu); const elem_size = elem_ty.abiSize(zcu); const ptr = try cg.resolveInst(bin_op.lhs); @@ -7499,7 +7499,7 @@ fn airErrorSetHasValue(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { const ty_op = cg.air.instructions.items(.data)[@backingInt(inst)].ty_op; const operand = try cg.resolveInst(ty_op.operand); - const error_set_ty = ty_op.ty.toType(); + const error_set_ty = ty_op.ty; const result = try cg.allocLocal(Type.bool); const names = error_set_ty.errorSetNames(zcu); diff --git a/src/codegen/x86_64/CodeGen.zig b/src/codegen/x86_64/CodeGen.zig index b073b4923ca63483a352a383ac33996f7aac882b..0eccc1e5f7fd462a77e65b411cf88bbe6e7c68a8 100644 --- a/src/codegen/x86_64/CodeGen.zig +++ b/src/codegen/x86_64/CodeGen.zig @@ -43354,7 +43354,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { var ops = try cg.tempsFromOperands(inst, .{ bin_op.lhs, bin_op.rhs }); try ops[0].toSlicePtr(cg); var res: [1]Temp = undefined; - if (!hack_around_sema_opv_bugs or ty_pl.ty.toType().childType(zcu).hasRuntimeBits(zcu)) cg.select(&res, &.{ty_pl.ty.toType()}, &ops, comptime &.{ .{ + if (!hack_around_sema_opv_bugs or ty_pl.ty.childType(zcu).hasRuntimeBits(zcu)) cg.select(&res, &.{ty_pl.ty}, &ops, comptime &.{ .{ .patterns = &.{ .{ .src = .{ .to_gpr, .simm32, .none } }, }, @@ -43468,7 +43468,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { var ops = try cg.tempsFromOperands(inst, .{ bin_op.lhs, bin_op.rhs }); try ops[0].toSlicePtr(cg); var res: [1]Temp = undefined; - if (!hack_around_sema_opv_bugs or ty_pl.ty.toType().childType(zcu).hasRuntimeBits(zcu)) cg.select(&res, &.{ty_pl.ty.toType()}, &ops, comptime &.{ .{ + if (!hack_around_sema_opv_bugs or ty_pl.ty.childType(zcu).hasRuntimeBits(zcu)) cg.select(&res, &.{ty_pl.ty}, &ops, comptime &.{ .{ .patterns = &.{ .{ .src = .{ .to_gpr, .simm32, .none } }, }, @@ -52208,7 +52208,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { const bin_op = cg.air.extraData(Air.Bin, ty_pl.payload).data; var ops = try cg.tempsFromOperands(inst, .{ bin_op.lhs, bin_op.rhs }); var res: [2]Temp = undefined; - cg.select(&res, &.{ ty_pl.ty.toType(), .u1 }, &ops, comptime &.{ .{ + cg.select(&res, &.{ ty_pl.ty, .u1 }, &ops, comptime &.{ .{ .src_constraints = .{ .{ .exact_signed_int = 8 }, .{ .exact_signed_int = 8 }, .any }, .patterns = &.{ .{ .src = .{ .to_mut_gpr, .imm8, .none } }, @@ -53044,7 +53044,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { } }) catch |err| switch (err) { error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ @tagName(air_tag), - ty_pl.ty.toType().fmt(pt), + ty_pl.ty.fmt(pt), ops[0].tracking(cg), ops[1].tracking(cg), }), @@ -53058,7 +53058,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { const bin_op = cg.air.extraData(Air.Bin, ty_pl.payload).data; var ops = try cg.tempsFromOperands(inst, .{ bin_op.lhs, bin_op.rhs }); var res: [2]Temp = undefined; - cg.select(&res, &.{ ty_pl.ty.toType(), .u1 }, &ops, comptime &.{ .{ + cg.select(&res, &.{ ty_pl.ty, .u1 }, &ops, comptime &.{ .{ .src_constraints = .{ .{ .exact_signed_int = 8 }, .{ .exact_signed_int = 8 }, .any }, .patterns = &.{ .{ .src = .{ .to_mut_gpr, .imm8, .none } }, @@ -53949,7 +53949,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { } }) catch |err| switch (err) { error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ @tagName(air_tag), - ty_pl.ty.toType().fmt(pt), + ty_pl.ty.fmt(pt), ops[0].tracking(cg), ops[1].tracking(cg), }), @@ -53963,7 +53963,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { const bin_op = cg.air.extraData(Air.Bin, ty_pl.payload).data; var ops = try cg.tempsFromOperands(inst, .{ bin_op.lhs, bin_op.rhs }); var res: [2]Temp = undefined; - cg.select(&res, &.{ ty_pl.ty.toType(), .u1 }, &ops, comptime &.{ .{ + cg.select(&res, &.{ ty_pl.ty, .u1 }, &ops, comptime &.{ .{ .src_constraints = .{ .{ .exact_signed_int = 8 }, .{ .exact_signed_int = 8 }, .any }, .patterns = &.{ .{ .src = .{ .{ .to_reg = .al }, .mem, .none } }, @@ -57546,7 +57546,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { } }) catch |err| switch (err) { error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ @tagName(air_tag), - ty_pl.ty.toType().fmt(pt), + ty_pl.ty.fmt(pt), ops[0].tracking(cg), ops[1].tracking(cg), }), @@ -57560,7 +57560,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { const bin_op = cg.air.extraData(Air.Bin, ty_pl.payload).data; var ops = try cg.tempsFromOperands(inst, .{ bin_op.lhs, bin_op.rhs }); var res: [2]Temp = undefined; - cg.select(&res, &.{ ty_pl.ty.toType(), .u1 }, &ops, comptime &.{ .{ + cg.select(&res, &.{ ty_pl.ty, .u1 }, &ops, comptime &.{ .{ .src_constraints = .{ .{ .exact_signed_int = 8 }, .{ .unsigned_int = .byte }, .any }, .patterns = &.{ .{ .src = .{ .mut_mem, .{ .imm = 1 }, .none } }, @@ -60891,7 +60891,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { } }) catch |err| switch (err) { error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ @tagName(air_tag), - ty_pl.ty.toType().fmt(pt), + ty_pl.ty.fmt(pt), ops[0].tracking(cg), ops[1].tracking(cg), }), @@ -65659,7 +65659,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { const ty_op = air_datas[@backingInt(inst)].ty_op; var ops = try cg.tempsFromOperands(inst, .{ty_op.operand}); var res: [1]Temp = undefined; - cg.select(&res, &.{ty_op.ty.toType()}, &ops, comptime &.{ .{ + cg.select(&res, &.{ty_op.ty}, &ops, comptime &.{ .{ .src_constraints = .{ .{ .bool_vec = .byte }, .any, .any }, .patterns = &.{ .{ .src = .{ .mut_mem, .none, .none } }, @@ -67432,7 +67432,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { } }) catch |err| switch (err) { error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ @tagName(air_tag), - ty_op.ty.toType().fmt(pt), + ty_op.ty.fmt(pt), ops[0].tracking(cg), }), else => |e| return e, @@ -67499,7 +67499,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { const ty_op = air_datas[@backingInt(inst)].ty_op; var ops = try cg.tempsFromOperands(inst, .{ty_op.operand}); var res: [1]Temp = undefined; - cg.select(&res, &.{ty_op.ty.toType()}, &ops, comptime &.{ .{ + cg.select(&res, &.{ty_op.ty}, &ops, comptime &.{ .{ .required_features = .{ .slow_incdec, null, null, null }, .src_constraints = .{ .{ .exact_signed_int = 1 }, .any, .any }, .patterns = &.{ @@ -70604,7 +70604,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { const ty_op = air_datas[@backingInt(inst)].ty_op; var ops = try cg.tempsFromOperands(inst, .{ty_op.operand}); var res: [1]Temp = undefined; - cg.select(&res, &.{ty_op.ty.toType()}, &ops, comptime &.{ .{ + cg.select(&res, &.{ty_op.ty}, &ops, comptime &.{ .{ .required_features = .{ .slow_incdec, null, null, null }, .src_constraints = .{ .{ .exact_signed_int = 1 }, .any, .any }, .patterns = &.{ @@ -71001,7 +71001,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { const ty_op = air_datas[@backingInt(inst)].ty_op; var ops = try cg.tempsFromOperands(inst, .{ty_op.operand}); var res: [1]Temp = undefined; - cg.select(&res, &.{ty_op.ty.toType()}, &ops, comptime &.{ .{ + cg.select(&res, &.{ty_op.ty}, &ops, comptime &.{ .{ .src_constraints = .{ .{ .exact_signed_int = 1 }, .any, .any }, .patterns = &.{ .{ .src = .{ .mut_mem, .none, .none } }, @@ -71889,7 +71889,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { const ty_op = air_datas[@backingInt(inst)].ty_op; var ops = try cg.tempsFromOperands(inst, .{ty_op.operand}); var res: [1]Temp = undefined; - cg.select(&res, &.{ty_op.ty.toType()}, &ops, comptime &.{ .{ + cg.select(&res, &.{ty_op.ty}, &ops, comptime &.{ .{ .src_constraints = .{ .{ .exact_int = 8 }, .any, .any }, .patterns = &.{ .{ .src = .{ .mut_mem, .none, .none } }, @@ -72527,7 +72527,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { } }) catch |err| switch (err) { error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ @tagName(air_tag), - ty_op.ty.toType().fmt(pt), + ty_op.ty.fmt(pt), ops[0].tracking(cg), }), else => |e| return e, @@ -72538,7 +72538,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { const ty_op = air_datas[@backingInt(inst)].ty_op; var ops = try cg.tempsFromOperands(inst, .{ty_op.operand}); var res: [1]Temp = undefined; - cg.select(&res, &.{ty_op.ty.toType()}, &ops, comptime &.{ .{ + cg.select(&res, &.{ty_op.ty}, &ops, comptime &.{ .{ .src_constraints = .{ .{ .exact_int = 1 }, .any, .any }, .patterns = &.{ .{ .src = .{ .mut_mem, .none, .none } }, @@ -75629,7 +75629,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { } }) catch |err| switch (err) { error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ @tagName(air_tag), - ty_op.ty.toType().fmt(pt), + ty_op.ty.fmt(pt), ops[0].tracking(cg), }), else => |e| return e, @@ -77552,7 +77552,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { const ty_op = air_datas[@backingInt(inst)].ty_op; var ops = try cg.tempsFromOperands(inst, .{ty_op.operand}); var res: [1]Temp = undefined; - cg.select(&res, &.{ty_op.ty.toType()}, &ops, comptime &.{ .{ + cg.select(&res, &.{ty_op.ty}, &ops, comptime &.{ .{ .required_features = .{ .cmov, null, null, null }, .src_constraints = .{ .{ .int = .byte }, .any, .any }, .patterns = &.{ @@ -82071,7 +82071,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { .lt, .lte => {}, .gt, .gte => std.mem.swap(Temp, &ops[0], &ops[1]), } - break :err cg.select(&res, &.{ty_pl.ty.toType()}, &ops, switch (@as(Condition, switch (cmp_op) { + break :err cg.select(&res, &.{ty_pl.ty}, &ops, switch (@as(Condition, switch (cmp_op) { else => unreachable, .lt, .gt => .l, .lte, .gte => .le, @@ -84587,7 +84587,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { } }, }); }, - .eq, .neq => |cmp_op| cg.select(&res, &.{ty_pl.ty.toType()}, &ops, switch (@as(Condition, switch (cmp_op) { + .eq, .neq => |cmp_op| cg.select(&res, &.{ty_pl.ty}, &ops, switch (@as(Condition, switch (cmp_op) { else => unreachable, .eq => .e, .neq => .ne, @@ -89364,7 +89364,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { }, .load => { const ty_op = air_datas[@backingInt(inst)].ty_op; - const val_ty = ty_op.ty.toType(); + const val_ty = ty_op.ty; var ops = try cg.tempsFromOperands(inst, .{ty_op.operand}); var res: [1]Temp = undefined; cg.select(&res, &.{val_ty}, &ops, comptime &.{ .{ @@ -89693,7 +89693,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { const ty_op = air_datas[@backingInt(inst)].ty_op; var ops = try cg.tempsFromOperands(inst, .{ty_op.operand}); var res: [1]Temp = undefined; - cg.select(&res, &.{ty_op.ty.toType()}, &ops, comptime &.{ .{ + cg.select(&res, &.{ty_op.ty}, &ops, comptime &.{ .{ .required_features = .{ .f16c, null, null, null }, .src_constraints = .{ .{ .scalar_float = .{ .of = .dword, .is = .dword } }, .any, .any }, .dst_constraints = .{ .{ .scalar_float = .{ .of = .word, .is = .word } }, .any }, @@ -91706,7 +91706,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { } }) catch |err| switch (err) { error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ @tagName(air_tag), - ty_op.ty.toType().fmt(pt), + ty_op.ty.fmt(pt), cg.typeOf(ty_op.operand).fmt(pt), ops[0].tracking(cg), }), @@ -91718,7 +91718,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { const ty_op = air_datas[@backingInt(inst)].ty_op; var ops = try cg.tempsFromOperands(inst, .{ty_op.operand}); var res: [1]Temp = undefined; - cg.select(&res, &.{ty_op.ty.toType()}, &ops, comptime &.{ .{ + cg.select(&res, &.{ty_op.ty}, &ops, comptime &.{ .{ .required_features = .{ .f16c, null, null, null }, .src_constraints = .{ .{ .scalar_float = .{ .of = .word, .is = .word } }, .any, .any }, .dst_constraints = .{ .{ .scalar_float = .{ .of = .dword, .is = .dword } }, .any }, @@ -93381,7 +93381,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { } }) catch |err| switch (err) { error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ @tagName(air_tag), - ty_op.ty.toType().fmt(pt), + ty_op.ty.fmt(pt), cg.typeOf(ty_op.operand).fmt(pt), ops[0].tracking(cg), }), @@ -93391,7 +93391,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { }, .int_cast => |air_tag| { const ty_op = air_datas[@backingInt(inst)].ty_op; - const dst_ty = ty_op.ty.toType(); + const dst_ty = ty_op.ty; const src_ty = cg.typeOf(ty_op.operand); var ops = try cg.tempsFromOperands(inst, .{ty_op.operand}); var res: [1]Temp = undefined; @@ -98152,7 +98152,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { const ty_op = air_datas[@backingInt(inst)].ty_op; var ops = try cg.tempsFromOperands(inst, .{ty_op.operand}); var res: [1]Temp = undefined; - cg.select(&res, &.{ty_op.ty.toType()}, &ops, comptime &.{ .{ + cg.select(&res, &.{ty_op.ty}, &ops, comptime &.{ .{ .src_constraints = .{ .{ .signed_int = .gpr }, .any, .any }, .dst_constraints = .{ .{ .exact_signed_int = 1 }, .any }, .patterns = &.{ @@ -103805,7 +103805,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { } }) catch |err| switch (err) { error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ @tagName(air_tag), - ty_op.ty.toType().fmt(pt), + ty_op.ty.fmt(pt), cg.typeOf(ty_op.operand).fmt(pt), ops[0].tracking(cg), }), @@ -103816,10 +103816,10 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { .optional_payload => { const ty_op = air_datas[@backingInt(inst)].ty_op; var ops = try cg.tempsFromOperands(inst, .{ty_op.operand}); - const pl = if (!hack_around_sema_opv_bugs or ty_op.ty.toType().hasRuntimeBits(zcu)) - try ops[0].read(ty_op.ty.toType(), .{}, cg) + const pl = if (!hack_around_sema_opv_bugs or ty_op.ty.hasRuntimeBits(zcu)) + try ops[0].read(ty_op.ty, .{}, cg) else - try cg.tempInit(ty_op.ty.toType(), .none); + try cg.tempInit(ty_op.ty, .none); try pl.finish(inst, &.{ty_op.operand}, &ops, cg); }, .optional_payload_ptr => { @@ -103844,7 +103844,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { }, .wrap_optional => { const ty_op = air_datas[@backingInt(inst)].ty_op; - const opt_ty = ty_op.ty.toType(); + const opt_ty = ty_op.ty; const opt_pl_ty = cg.typeOf(ty_op.operand); const opt_pl_abi_size: u31 = @intCast(opt_pl_ty.abiSize(zcu)); var ops = try cg.tempsFromOperands(inst, .{ty_op.operand}); @@ -103859,7 +103859,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { }, .unwrap_errunion_payload => { const ty_op = air_datas[@backingInt(inst)].ty_op; - const eu_pl_ty = ty_op.ty.toType(); + const eu_pl_ty = ty_op.ty; const eu_pl_off: i32 = @intCast(codegen.errUnionPayloadOffset(eu_pl_ty, zcu)); var ops = try cg.tempsFromOperands(inst, .{ty_op.operand}); const pl = if (!hack_around_sema_opv_bugs or eu_pl_ty.hasRuntimeBits(zcu)) @@ -103871,7 +103871,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { .unwrap_errunion_err => { const ty_op = air_datas[@backingInt(inst)].ty_op; const eu_ty = cg.typeOf(ty_op.operand); - const eu_err_ty = ty_op.ty.toType(); + const eu_err_ty = ty_op.ty; const eu_pl_ty = eu_ty.errorUnionPayload(zcu); const eu_err_off: i32 = @intCast(codegen.errUnionErrorOffset(eu_pl_ty, zcu)); var ops = try cg.tempsFromOperands(inst, .{ty_op.operand}); @@ -103890,7 +103890,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { .unwrap_errunion_err_ptr => { const ty_op = air_datas[@backingInt(inst)].ty_op; const eu_ty = cg.typeOf(ty_op.operand).childType(zcu); - const eu_err_ty = ty_op.ty.toType(); + const eu_err_ty = ty_op.ty; const eu_pl_ty = eu_ty.errorUnionPayload(zcu); const eu_err_off: i32 = @intCast(codegen.errUnionErrorOffset(eu_pl_ty, zcu)); var ops = try cg.tempsFromOperands(inst, .{ty_op.operand}); @@ -103915,7 +103915,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { }, .wrap_errunion_payload => { const ty_op = air_datas[@backingInt(inst)].ty_op; - const eu_ty = ty_op.ty.toType(); + const eu_ty = ty_op.ty; const eu_err_ty = eu_ty.errorUnionSet(zcu); const eu_pl_ty = cg.typeOf(ty_op.operand); const eu_err_off: u31 = @intCast(codegen.errUnionErrorOffset(eu_pl_ty, zcu)); @@ -103930,7 +103930,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { }, .wrap_errunion_err => { const ty_op = air_datas[@backingInt(inst)].ty_op; - const eu_ty = ty_op.ty.toType(); + const eu_ty = ty_op.ty; const eu_pl_ty = eu_ty.errorUnionPayload(zcu); const eu_err_off: u31 = @intCast(codegen.errUnionErrorOffset(eu_pl_ty, zcu)); var ops = try cg.tempsFromOperands(inst, .{ty_op.operand}); @@ -103944,7 +103944,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { var ops = try cg.tempsFromOperands(inst, .{struct_field.struct_operand}); try ops[0].toOffset(@intCast(codegen.fieldOffset( cg.typeOf(struct_field.struct_operand), - ty_pl.ty.toType(), + ty_pl.ty, struct_field.field_index, zcu, )), cg); @@ -103959,7 +103959,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { var ops = try cg.tempsFromOperands(inst, .{ty_op.operand}); try ops[0].toOffset(@intCast(codegen.fieldOffset( cg.typeOf(ty_op.operand), - ty_op.ty.toType(), + ty_op.ty, switch (air_tag) { else => unreachable, .struct_field_ptr_index_0 => 0, @@ -103975,7 +103975,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { const ty_pl = air_datas[@backingInt(inst)].ty_pl; const struct_field = cg.air.extraData(Air.StructField, ty_pl.payload).data; const agg_ty = cg.typeOf(struct_field.struct_operand); - const field_ty = ty_pl.ty.toType(); + const field_ty = ty_pl.ty; const field_off: u31 = switch (agg_ty.containerLayout(zcu)) { .auto, .@"extern" => @intCast(agg_ty.structFieldOffset(struct_field.field_index, zcu)), .@"packed" => unreachable, @@ -104004,7 +104004,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { var ops = try cg.tempsFromOperands(inst, .{ty_op.operand}); const union_layout = union_ty.unionGetLayout(zcu); assert(union_layout.tag_size > 0); - const res = try ops[0].read(ty_op.ty.toType(), .{ + const res = try ops[0].read(ty_op.ty, .{ .disp = @intCast(union_layout.tagOffset()), }, cg); try res.finish(inst, &.{ty_op.operand}, &ops, cg); @@ -104364,7 +104364,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { const bin_op = cg.air.extraData(Air.Bin, ty_pl.payload).data; var ops = try cg.tempsFromOperands(inst, .{ bin_op.lhs, bin_op.rhs }); try ops[0].toSlicePtr(cg); - const dst_ty = ty_pl.ty.toType(); + const dst_ty = ty_pl.ty; zero_offset: { const elem_size = dst_ty.childType(zcu).abiSize(zcu); if (hack_around_sema_opv_bugs and elem_size == 0) break :zero_offset; @@ -104420,7 +104420,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { const ty_op = air_datas[@backingInt(inst)].ty_op; var ops = try cg.tempsFromOperands(inst, .{ty_op.operand}); var res: [1]Temp = undefined; - cg.select(&res, &.{ty_op.ty.toType()}, &ops, comptime &.{ .{ + cg.select(&res, &.{ty_op.ty}, &ops, comptime &.{ .{ .required_features = .{ .f16c, null, null, null }, .src_constraints = .{ .{ .float = .word }, .any, .any }, .dst_constraints = .{ .{ .int = .dword }, .any }, @@ -115175,7 +115175,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { } }) catch |err| switch (err) { error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ @tagName(air_tag), - ty_op.ty.toType().fmt(pt), + ty_op.ty.fmt(pt), cg.typeOf(ty_op.operand).fmt(pt), ops[0].tracking(cg), }), @@ -115189,7 +115189,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { const ty_op = air_datas[@backingInt(inst)].ty_op; var ops = try cg.tempsFromOperands(inst, .{ty_op.operand}); var res: [1]Temp = undefined; - cg.select(&res, &.{ty_op.ty.toType()}, &ops, comptime &.{ .{ + cg.select(&res, &.{ty_op.ty}, &ops, comptime &.{ .{ .required_features = .{ .f16c, null, null, null }, .src_constraints = .{ .{ .signed_int = .byte }, .any, .any }, .dst_constraints = .{ .{ .float = .word }, .any }, @@ -127066,7 +127066,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { } }) catch |err| switch (err) { error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ @tagName(air_tag), - ty_op.ty.toType().fmt(pt), + ty_op.ty.fmt(pt), cg.typeOf(ty_op.operand).fmt(pt), ops[0].tracking(cg), }), @@ -168982,7 +168982,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { const ty_op = air_datas[@backingInt(inst)].ty_op; var ops = try cg.tempsFromOperands(inst, .{ty_op.operand}); var res: [1]Temp = undefined; - cg.select(&res, &.{ty_op.ty.toType()}, &ops, comptime &.{ .{ + cg.select(&res, &.{ty_op.ty}, &ops, comptime &.{ .{ .dst_constraints = .{ .{ .bool_vec = .qword }, .any }, .src_constraints = .{ .bool, .any, .any }, .patterns = &.{ @@ -170811,7 +170811,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { } }) catch |err| switch (err) { error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ @tagName(air_tag), - ty_op.ty.toType().fmt(pt), + ty_op.ty.fmt(pt), ops[0].tracking(cg), }), else => |e| return e, @@ -171333,7 +171333,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { }, .error_set_has_value => |air_tag| { const ty_op = air_datas[@backingInt(inst)].ty_op; - var ops = try cg.tempsFromOperands(inst, .{ty_op.operand}) ++ .{try cg.tempInit(ty_op.ty.toType(), .none)}; + var ops = try cg.tempsFromOperands(inst, .{ty_op.operand}) ++ .{try cg.tempInit(ty_op.ty, .none)}; var res: [1]Temp = undefined; cg.select(&res, &.{.bool}, &ops, comptime &.{ .{ .required_features = .{ .avx, null, null, null }, @@ -171415,7 +171415,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { } }) catch |err| switch (err) { error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ @tagName(air_tag), - ty_op.ty.toType().fmt(pt), + ty_op.ty.fmt(pt), ops[0].tracking(cg), }), else => |e| return e, @@ -171425,7 +171425,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { }, .aggregate_init => |air_tag| fallback: { const ty_pl = air_datas[@backingInt(inst)].ty_pl; - const agg_ty = ty_pl.ty.toType(); + const agg_ty = ty_pl.ty; if (agg_ty.isVector(zcu) and agg_ty.childType(zcu).toIntern() == .bool_type) { break :fallback try cg.airAggregateInitBoolVec(inst); } @@ -171496,7 +171496,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { .union_init => { const ty_pl = air_datas[@backingInt(inst)].ty_pl; const union_init = cg.air.extraData(Air.UnionInit, ty_pl.payload).data; - const union_ty = ty_pl.ty.toType(); + const union_ty = ty_pl.ty; var ops = try cg.tempsFromOperands(inst, .{union_init.init}); var res = try cg.tempAllocMem(union_ty); const union_layout = union_ty.unionGetLayout(zcu); @@ -172948,7 +172948,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { const field_parent_ptr = cg.air.extraData(Air.FieldParentPtr, ty_pl.payload).data; var ops = try cg.tempsFromOperands(inst, .{field_parent_ptr.field_ptr}); try ops[0].toOffset(-@as(i32, @intCast(codegen.fieldOffset( - ty_pl.ty.toType(), + ty_pl.ty, cg.typeOf(field_parent_ptr.field_ptr), field_parent_ptr.field_index, zcu, @@ -173071,7 +173071,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { }, .save_err_return_trace_index => { const ty_pl = air_datas[@backingInt(inst)].ty_pl; - const agg_ty = ty_pl.ty.toType(); + const agg_ty = ty_pl.ty; assert(agg_ty.containerLayout(zcu) != .@"packed"); var ert: Temp = .{ .index = err_ret_trace_index }; var res = try ert.load(.usize, .{ .disp = @intCast(agg_ty.structFieldOffset(ty_pl.payload, zcu)) }, cg); @@ -173115,7 +173115,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { else => unreachable, }; - var res = try cg.tempInit(.fromInterned(ty_nav.ty), .{ .lea_nav = ty_nav.nav }); + var res = try cg.tempInit(ty_nav.ty, .{ .lea_nav = ty_nav.nav }); if (is_threadlocal) while (try res.toRegClass(true, .general_purpose, cg)) {}; try res.finish(inst, &.{}, &.{}, cg); },