From 2f92d1a0264b6827cb67a55726c4c9a082337508 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 14 Mar 2022 21:11:49 -0700 Subject: stage2: fixups for topolarity-comptime-memory-reinterp branch * don't store `has_well_defined_layout` in memory. * remove struct `hasWellDefinedLayout` logic. it's just `layout != .Auto`. This means we only need one implementation, in Type. * fix some of the cases being wrong in `hasWellDefinedLayout`, such as optional pointers. * move `tag_ty_inferred` field into a position that makes it more obvious how the struct layout will be done. Also we don't have a compiler that intelligently moves fields around so this layout is better. * Sema: don't `resolveTypeLayout` in `zirCoerceResultPtr` unless necessary. * Rename `ComptimePtrLoadKit` `target` field to `pointee` to avoid confusion with `target`. --- src/Module.zig | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/Module.zig') diff --git a/src/Module.zig b/src/Module.zig index 7c6c654660..20bf25af03 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -885,7 +885,6 @@ pub const Struct = struct { /// one possible value. known_non_opv: bool, requires_comptime: PropertyBoolean = .unknown, - has_well_defined_layout: PropertyBoolean = .unknown, pub const Fields = std.StringArrayHashMapUnmanaged(Field); @@ -1080,8 +1079,6 @@ pub const EnumFull = struct { /// An integer type which is used for the numerical value of the enum. /// Whether zig chooses this type or the user specifies it, it is stored here. tag_ty: Type, - /// true if zig inferred this tag type, false if user specified it - tag_ty_inferred: bool, /// Set of field names in declaration order. fields: NameMap, /// Maps integer tag value to field index. @@ -1092,6 +1089,8 @@ pub const EnumFull = struct { namespace: Namespace, /// Offset from `owner_decl`, points to the enum decl AST node. node_offset: i32, + /// true if zig inferred this tag type, false if user specified it + tag_ty_inferred: bool, pub const NameMap = std.StringArrayHashMapUnmanaged(void); pub const ValueMap = std.ArrayHashMapUnmanaged(Value, void, Value.ArrayHashContext, false); @@ -1136,7 +1135,6 @@ pub const Union = struct { fully_resolved, }, requires_comptime: PropertyBoolean = .unknown, - has_well_defined_layout: PropertyBoolean = .unknown, pub const Field = struct { /// undefined until `status` is `have_field_types` or `have_layout`. -- cgit v1.2.3