From f37c0a459382fa033cefc9bb139277436a78b25e Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 25 May 2023 22:28:02 -0700 Subject: Sema: inferred allocations no longer abuse type/value system Previously, there were types and values for inferred allocations and a lot of special-case handling. Now, instead, the special casing is limited to AIR instructions for these use cases. Instead of storing data in Value payloads, the data is now stored in AIR instruction data as well as the previously `void` value type of the `unresolved_inferred_allocs` hash map. --- src/value.zig | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) (limited to 'src/value.zig') diff --git a/src/value.zig b/src/value.zig index 9244e33ad5..498b7d3339 100644 --- a/src/value.zig +++ b/src/value.zig @@ -63,12 +63,6 @@ pub const Value = struct { aggregate, /// An instance of a union. @"union", - /// This is a special value that tracks a set of types that have been stored - /// to an inferred allocation. It does not support any of the normal value queries. - inferred_alloc, - /// Used to coordinate alloc_inferred, store_to_inferred_ptr, and resolve_inferred_alloc - /// instructions for comptime code. - inferred_alloc_comptime, pub const no_payload_count = 0; @@ -82,8 +76,6 @@ pub const Value = struct { .bytes => Payload.Bytes, .aggregate => Payload.Aggregate, .@"union" => Payload.Union, - .inferred_alloc => Payload.InferredAlloc, - .inferred_alloc_comptime => Payload.InferredAllocComptime, }; } @@ -250,8 +242,6 @@ pub const Value = struct { .legacy = .{ .ptr_otherwise = &new_payload.base }, }; }, - .inferred_alloc => unreachable, - .inferred_alloc_comptime => unreachable, } } @@ -308,8 +298,6 @@ pub const Value = struct { val = val.castTag(.repeated).?.data; }, .slice => return out_stream.writeAll("(slice)"), - .inferred_alloc => return out_stream.writeAll("(inferred allocation value)"), - .inferred_alloc_comptime => return out_stream.writeAll("(inferred comptime allocation value)"), }; } @@ -4147,41 +4135,6 @@ pub const Value = struct { val: Value, }; }; - - pub const InferredAlloc = struct { - pub const base_tag = Tag.inferred_alloc; - - base: Payload = .{ .tag = base_tag }, - data: struct { - /// The value stored in the inferred allocation. This will go into - /// peer type resolution. This is stored in a separate list so that - /// the items are contiguous in memory and thus can be passed to - /// `Module.resolvePeerTypes`. - prongs: std.MultiArrayList(struct { - /// The dummy instruction used as a peer to resolve the type. - /// Although this has a redundant type with placeholder, this is - /// needed in addition because it may be a constant value, which - /// affects peer type resolution. - stored_inst: Air.Inst.Ref, - /// The bitcast instruction used as a placeholder when the - /// new result pointer type is not yet known. - placeholder: Air.Inst.Index, - }) = .{}, - /// 0 means ABI-aligned. - alignment: u32, - }, - }; - - pub const InferredAllocComptime = struct { - pub const base_tag = Tag.inferred_alloc_comptime; - - base: Payload = .{ .tag = base_tag }, - data: struct { - decl_index: Module.Decl.Index, - /// 0 means ABI-aligned. - alignment: u32, - }, - }; }; pub const BigIntSpace = InternPool.Key.Int.Storage.BigIntSpace; -- cgit v1.2.3