| author | |
| committer | |
| log | b1d3d48f687a3a73be1d9ab85035cbdc58e2bb1b |
| tree | d81f3d9705ba2bf164ed6468ae18315c7a7ffe89 |
| parent | 9356cb1475606a7afd2e722af60f87ce2b39f9f8 |
| signature |
This eliminates the statically-reachable recursion loop between code
generation backends and Sema. This is beneficial for optimizers
(although I do not measure any performance improvement for this change),
and for profilers.3 files changed, 22 insertions(+), 22 deletions(-)
src/Type.zig+12-12| ... | ... | @@ -478,7 +478,7 @@ pub fn hasRuntimeBitsAdvanced( |
| 478 | 478 | ty: Type, |
| 479 | 479 | pt: Zcu.PerThread, |
| 480 | 480 | ignore_comptime_only: bool, |
| 481 | strat: ResolveStratLazy, | |
| 481 | comptime strat: ResolveStratLazy, | |
| 482 | 482 | ) RuntimeBitsError!bool { |
| 483 | 483 | const mod = pt.zcu; |
| 484 | 484 | const ip = &mod.intern_pool; |
| ... | ... | @@ -792,7 +792,7 @@ pub fn fnHasRuntimeBits(ty: Type, pt: Zcu.PerThread) bool { |
| 792 | 792 | /// Determines whether a function type has runtime bits, i.e. whether a |
| 793 | 793 | /// function with this type can exist at runtime. |
| 794 | 794 | /// Asserts that `ty` is a function type. |
| 795 | pub fn fnHasRuntimeBitsAdvanced(ty: Type, pt: Zcu.PerThread, strat: ResolveStrat) SemaError!bool { | |
| 795 | pub fn fnHasRuntimeBitsAdvanced(ty: Type, pt: Zcu.PerThread, comptime strat: ResolveStrat) SemaError!bool { | |
| 796 | 796 | const fn_info = pt.zcu.typeToFunc(ty).?; |
| 797 | 797 | if (fn_info.is_generic) return false; |
| 798 | 798 | if (fn_info.is_var_args) return true; |
| ... | ... | @@ -824,7 +824,7 @@ pub fn ptrAlignment(ty: Type, pt: Zcu.PerThread) Alignment { |
| 824 | 824 | return ptrAlignmentAdvanced(ty, pt, .normal) catch unreachable; |
| 825 | 825 | } |
| 826 | 826 | |
| 827 | pub fn ptrAlignmentAdvanced(ty: Type, pt: Zcu.PerThread, strat: ResolveStrat) !Alignment { | |
| 827 | pub fn ptrAlignmentAdvanced(ty: Type, pt: Zcu.PerThread, comptime strat: ResolveStrat) !Alignment { | |
| 828 | 828 | return switch (pt.zcu.intern_pool.indexToKey(ty.toIntern())) { |
| 829 | 829 | .ptr_type => |ptr_type| { |
| 830 | 830 | if (ptr_type.flags.alignment != .none) |
| ... | ... | @@ -891,7 +891,7 @@ pub const ResolveStrat = enum { |
| 891 | 891 | /// This should typically be used from semantic analysis. |
| 892 | 892 | sema, |
| 893 | 893 | |
| 894 | pub fn toLazy(strat: ResolveStrat) ResolveStratLazy { | |
| 894 | pub inline fn toLazy(strat: ResolveStrat) ResolveStratLazy { | |
| 895 | 895 | return switch (strat) { |
| 896 | 896 | .normal => .eager, |
| 897 | 897 | .sema => .sema, |
| ... | ... | @@ -908,7 +908,7 @@ pub const ResolveStrat = enum { |
| 908 | 908 | pub fn abiAlignmentAdvanced( |
| 909 | 909 | ty: Type, |
| 910 | 910 | pt: Zcu.PerThread, |
| 911 | strat: ResolveStratLazy, | |
| 911 | comptime strat: ResolveStratLazy, | |
| 912 | 912 | ) SemaError!AbiAlignmentAdvanced { |
| 913 | 913 | const mod = pt.zcu; |
| 914 | 914 | const target = mod.getTarget(); |
| ... | ... | @@ -1130,7 +1130,7 @@ pub fn abiAlignmentAdvanced( |
| 1130 | 1130 | fn abiAlignmentAdvancedErrorUnion( |
| 1131 | 1131 | ty: Type, |
| 1132 | 1132 | pt: Zcu.PerThread, |
| 1133 | strat: ResolveStratLazy, | |
| 1133 | comptime strat: ResolveStratLazy, | |
| 1134 | 1134 | payload_ty: Type, |
| 1135 | 1135 | ) SemaError!AbiAlignmentAdvanced { |
| 1136 | 1136 | // This code needs to be kept in sync with the equivalent switch prong |
| ... | ... | @@ -1167,7 +1167,7 @@ fn abiAlignmentAdvancedErrorUnion( |
| 1167 | 1167 | fn abiAlignmentAdvancedOptional( |
| 1168 | 1168 | ty: Type, |
| 1169 | 1169 | pt: Zcu.PerThread, |
| 1170 | strat: ResolveStratLazy, | |
| 1170 | comptime strat: ResolveStratLazy, | |
| 1171 | 1171 | ) SemaError!AbiAlignmentAdvanced { |
| 1172 | 1172 | const mod = pt.zcu; |
| 1173 | 1173 | const target = mod.getTarget(); |
| ... | ... | @@ -1231,7 +1231,7 @@ const AbiSizeAdvanced = union(enum) { |
| 1231 | 1231 | pub fn abiSizeAdvanced( |
| 1232 | 1232 | ty: Type, |
| 1233 | 1233 | pt: Zcu.PerThread, |
| 1234 | strat: ResolveStratLazy, | |
| 1234 | comptime strat: ResolveStratLazy, | |
| 1235 | 1235 | ) SemaError!AbiSizeAdvanced { |
| 1236 | 1236 | const mod = pt.zcu; |
| 1237 | 1237 | const target = mod.getTarget(); |
| ... | ... | @@ -1505,7 +1505,7 @@ pub fn abiSizeAdvanced( |
| 1505 | 1505 | fn abiSizeAdvancedOptional( |
| 1506 | 1506 | ty: Type, |
| 1507 | 1507 | pt: Zcu.PerThread, |
| 1508 | strat: ResolveStratLazy, | |
| 1508 | comptime strat: ResolveStratLazy, | |
| 1509 | 1509 | ) SemaError!AbiSizeAdvanced { |
| 1510 | 1510 | const mod = pt.zcu; |
| 1511 | 1511 | const child_ty = ty.optionalChild(mod); |
| ... | ... | @@ -1680,7 +1680,7 @@ pub fn bitSize(ty: Type, pt: Zcu.PerThread) u64 { |
| 1680 | 1680 | pub fn bitSizeAdvanced( |
| 1681 | 1681 | ty: Type, |
| 1682 | 1682 | pt: Zcu.PerThread, |
| 1683 | strat: ResolveStrat, | |
| 1683 | comptime strat: ResolveStrat, | |
| 1684 | 1684 | ) SemaError!u64 { |
| 1685 | 1685 | const mod = pt.zcu; |
| 1686 | 1686 | const target = mod.getTarget(); |
| ... | ... | @@ -2739,7 +2739,7 @@ pub fn comptimeOnly(ty: Type, pt: Zcu.PerThread) bool { |
| 2739 | 2739 | |
| 2740 | 2740 | /// `generic_poison` will return false. |
| 2741 | 2741 | /// May return false negatives when structs and unions are having their field types resolved. |
| 2742 | pub fn comptimeOnlyAdvanced(ty: Type, pt: Zcu.PerThread, strat: ResolveStrat) SemaError!bool { | |
| 2742 | pub fn comptimeOnlyAdvanced(ty: Type, pt: Zcu.PerThread, comptime strat: ResolveStrat) SemaError!bool { | |
| 2743 | 2743 | const mod = pt.zcu; |
| 2744 | 2744 | const ip = &mod.intern_pool; |
| 2745 | 2745 | return switch (ty.toIntern()) { |
| ... | ... | @@ -3198,7 +3198,7 @@ pub fn structFieldAlign(ty: Type, index: usize, pt: Zcu.PerThread) Alignment { |
| 3198 | 3198 | return ty.structFieldAlignAdvanced(index, pt, .normal) catch unreachable; |
| 3199 | 3199 | } |
| 3200 | 3200 | |
| 3201 | pub fn structFieldAlignAdvanced(ty: Type, index: usize, pt: Zcu.PerThread, strat: ResolveStrat) !Alignment { | |
| 3201 | pub fn structFieldAlignAdvanced(ty: Type, index: usize, pt: Zcu.PerThread, comptime strat: ResolveStrat) !Alignment { | |
| 3202 | 3202 | const ip = &pt.zcu.intern_pool; |
| 3203 | 3203 | switch (ip.indexToKey(ty.toIntern())) { |
| 3204 | 3204 | .struct_type => { |
src/Value.zig+8-8| ... | ... | @@ -178,7 +178,7 @@ pub fn toBigIntAdvanced( |
| 178 | 178 | val: Value, |
| 179 | 179 | space: *BigIntSpace, |
| 180 | 180 | pt: Zcu.PerThread, |
| 181 | strat: ResolveStrat, | |
| 181 | comptime strat: ResolveStrat, | |
| 182 | 182 | ) Module.CompileError!BigIntConst { |
| 183 | 183 | return switch (val.toIntern()) { |
| 184 | 184 | .bool_false => BigIntMutable.init(&space.limbs, 0).toConst(), |
| ... | ... | @@ -240,7 +240,7 @@ pub fn getUnsignedInt(val: Value, pt: Zcu.PerThread) ?u64 { |
| 240 | 240 | |
| 241 | 241 | /// If the value fits in a u64, return it, otherwise null. |
| 242 | 242 | /// Asserts not undefined. |
| 243 | pub fn getUnsignedIntAdvanced(val: Value, pt: Zcu.PerThread, strat: ResolveStrat) !?u64 { | |
| 243 | pub fn getUnsignedIntAdvanced(val: Value, pt: Zcu.PerThread, comptime strat: ResolveStrat) !?u64 { | |
| 244 | 244 | const mod = pt.zcu; |
| 245 | 245 | return switch (val.toIntern()) { |
| 246 | 246 | .undef => unreachable, |
| ... | ... | @@ -1042,7 +1042,7 @@ pub fn orderAgainstZero(lhs: Value, pt: Zcu.PerThread) std.math.Order { |
| 1042 | 1042 | pub fn orderAgainstZeroAdvanced( |
| 1043 | 1043 | lhs: Value, |
| 1044 | 1044 | pt: Zcu.PerThread, |
| 1045 | strat: ResolveStrat, | |
| 1045 | comptime strat: ResolveStrat, | |
| 1046 | 1046 | ) Module.CompileError!std.math.Order { |
| 1047 | 1047 | return switch (lhs.toIntern()) { |
| 1048 | 1048 | .bool_false => .eq, |
| ... | ... | @@ -1081,7 +1081,7 @@ pub fn order(lhs: Value, rhs: Value, pt: Zcu.PerThread) std.math.Order { |
| 1081 | 1081 | } |
| 1082 | 1082 | |
| 1083 | 1083 | /// Asserts the value is comparable. |
| 1084 | pub fn orderAdvanced(lhs: Value, rhs: Value, pt: Zcu.PerThread, strat: ResolveStrat) !std.math.Order { | |
| 1084 | pub fn orderAdvanced(lhs: Value, rhs: Value, pt: Zcu.PerThread, comptime strat: ResolveStrat) !std.math.Order { | |
| 1085 | 1085 | const lhs_against_zero = try lhs.orderAgainstZeroAdvanced(pt, strat); |
| 1086 | 1086 | const rhs_against_zero = try rhs.orderAgainstZeroAdvanced(pt, strat); |
| 1087 | 1087 | switch (lhs_against_zero) { |
| ... | ... | @@ -1119,7 +1119,7 @@ pub fn compareHeteroAdvanced( |
| 1119 | 1119 | op: std.math.CompareOperator, |
| 1120 | 1120 | rhs: Value, |
| 1121 | 1121 | pt: Zcu.PerThread, |
| 1122 | strat: ResolveStrat, | |
| 1122 | comptime strat: ResolveStrat, | |
| 1123 | 1123 | ) !bool { |
| 1124 | 1124 | if (lhs.pointerDecl(pt.zcu)) |lhs_decl| { |
| 1125 | 1125 | if (rhs.pointerDecl(pt.zcu)) |rhs_decl| { |
| ... | ... | @@ -1199,7 +1199,7 @@ pub fn compareAllWithZeroAdvancedExtra( |
| 1199 | 1199 | lhs: Value, |
| 1200 | 1200 | op: std.math.CompareOperator, |
| 1201 | 1201 | pt: Zcu.PerThread, |
| 1202 | strat: ResolveStrat, | |
| 1202 | comptime strat: ResolveStrat, | |
| 1203 | 1203 | ) Module.CompileError!bool { |
| 1204 | 1204 | const mod = pt.zcu; |
| 1205 | 1205 | if (lhs.isInf(mod)) { |
| ... | ... | @@ -1505,7 +1505,7 @@ pub fn floatFromIntAdvanced( |
| 1505 | 1505 | int_ty: Type, |
| 1506 | 1506 | float_ty: Type, |
| 1507 | 1507 | pt: Zcu.PerThread, |
| 1508 | strat: ResolveStrat, | |
| 1508 | comptime strat: ResolveStrat, | |
| 1509 | 1509 | ) !Value { |
| 1510 | 1510 | const mod = pt.zcu; |
| 1511 | 1511 | if (int_ty.zigTypeTag(mod) == .Vector) { |
| ... | ... | @@ -1523,7 +1523,7 @@ pub fn floatFromIntAdvanced( |
| 1523 | 1523 | return floatFromIntScalar(val, float_ty, pt, strat); |
| 1524 | 1524 | } |
| 1525 | 1525 | |
| 1526 | pub fn floatFromIntScalar(val: Value, float_ty: Type, pt: Zcu.PerThread, strat: ResolveStrat) !Value { | |
| 1526 | pub fn floatFromIntScalar(val: Value, float_ty: Type, pt: Zcu.PerThread, comptime strat: ResolveStrat) !Value { | |
| 1527 | 1527 | const mod = pt.zcu; |
| 1528 | 1528 | return switch (mod.intern_pool.indexToKey(val.toIntern())) { |
| 1529 | 1529 | .undef => try pt.undefValue(float_ty), |
src/Zcu/PerThread.zig+2-2| ... | ... | @@ -3145,7 +3145,7 @@ pub fn unionFieldNormalAlignmentAdvanced( |
| 3145 | 3145 | pt: Zcu.PerThread, |
| 3146 | 3146 | loaded_union: InternPool.LoadedUnionType, |
| 3147 | 3147 | field_index: u32, |
| 3148 | strat: Type.ResolveStrat, | |
| 3148 | comptime strat: Type.ResolveStrat, | |
| 3149 | 3149 | ) Zcu.SemaError!InternPool.Alignment { |
| 3150 | 3150 | const ip = &pt.zcu.intern_pool; |
| 3151 | 3151 | assert(loaded_union.flagsUnordered(ip).layout != .@"packed"); |
| ... | ... | @@ -3173,7 +3173,7 @@ pub fn structFieldAlignmentAdvanced( |
| 3173 | 3173 | explicit_alignment: InternPool.Alignment, |
| 3174 | 3174 | field_ty: Type, |
| 3175 | 3175 | layout: std.builtin.Type.ContainerLayout, |
| 3176 | strat: Type.ResolveStrat, | |
| 3176 | comptime strat: Type.ResolveStrat, | |
| 3177 | 3177 | ) Zcu.SemaError!InternPool.Alignment { |
| 3178 | 3178 | assert(layout != .@"packed"); |
| 3179 | 3179 | if (explicit_alignment != .none) return explicit_alignment; |