From 20bb81166f36668413703e0d74b3e283c55ab8ca Mon Sep 17 00:00:00 2001 From: mlugg Date: Tue, 24 Oct 2023 04:36:35 +0100 Subject: InternPool: remove runtime_value representation The main goal of this commit is to remove the `runtime_value` field from `InternPool.Key` (and its associated representation), but there are a few dominos. Specifically, this mostly eliminates the "maybe runtime" concept from value resolution in Sema: so some resolution functions like `resolveMaybeUndefValAllowVariablesMaybeRuntime` are gone. This required a small change to struct/union/array initializers, to no longer use `runtime_value` if a field was a `variable` - I'm not convinced this case was even reachable, as `variable` should only ever exist as the trivial value of a global runtime `var` decl. Now, the only case in which a `Sema.resolveMaybeUndefVal`-esque function can return the `variable` key is `resolveMaybeUndefValAllowVariables`, which is directly called from `Sema.resolveInstValueAllowVariables` (previously `Sema.resolveInstValue`), which is only used for resolving the value of a Decl from `Module.semaDecl`. While changing these functions, I also slightly reordered and restructured some of them, and updated their doc comments. --- src/codegen/spirv.zig | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/codegen/spirv.zig') diff --git a/src/codegen/spirv.zig b/src/codegen/spirv.zig index a7a494cc11..dcb3329c57 100644 --- a/src/codegen/spirv.zig +++ b/src/codegen/spirv.zig @@ -644,11 +644,7 @@ const DeclGen = struct { const result_ty_ref = try self.resolveType(ty, repr); const ip = &mod.intern_pool; - var val = arg_val; - switch (ip.indexToKey(val.toIntern())) { - .runtime_value => |rt| val = rt.val.toValue(), - else => {}, - } + const val = arg_val; log.debug("constant: ty = {}, val = {}", .{ ty.fmt(mod), val.fmtValue(ty, mod) }); if (val.isUndefDeep(mod)) { @@ -674,7 +670,7 @@ const DeclGen = struct { .inferred_error_set_type, => unreachable, // types, not values - .undef, .runtime_value => unreachable, // handled above + .undef => unreachable, // handled above .variable, .extern_func, -- cgit v1.2.3