aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/llvm.zig
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2025-01-05 00:50:58 +0000
committerMatthew Lugg <mlugg@mlugg.co.uk>2025-01-05 05:52:02 +0000
commitb039a8b6155e1eddd9f447ff261d56771c12e038 (patch)
tree0c6c6d44c4e8d6b89a260d61f4472ebc0c9186f5 /src/codegen/llvm.zig
parent136c5a916ed7e421461ac5839cc0e4c289b80f16 (diff)
downloadzig-b039a8b6155e1eddd9f447ff261d56771c12e038.tar.gz
zig-b039a8b6155e1eddd9f447ff261d56771c12e038.zip
compiler: slightly simplify builtin decl memoization
Rather than `Zcu.BuiltinDecl.Memoized` being a struct with fields, it can instead just be an array, indexed by the enum. This allows runtime indexing, avoiding a few now-unnecessary `inline` switch cases.
Diffstat (limited to 'src/codegen/llvm.zig')
-rw-r--r--src/codegen/llvm.zig6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
index 63fc7b7dcc..f14d58459f 100644
--- a/src/codegen/llvm.zig
+++ b/src/codegen/llvm.zig
@@ -5754,9 +5754,7 @@ pub const FuncGen = struct {
const o = fg.ng.object;
const zcu = o.pt.zcu;
const ip = &zcu.intern_pool;
- const panic_msg_val: InternPool.Index = switch (panic_id) {
- inline else => |ct_panic_id| @field(zcu.builtin_decl_values, "Panic.messages." ++ @tagName(ct_panic_id)),
- };
+ const panic_msg_val = zcu.builtin_decl_values.get(panic_id.toBuiltin());
assert(panic_msg_val != .none);
const msg_len = Value.fromInterned(panic_msg_val).typeOf(zcu).childType(zcu).arrayLen(zcu);
const msg_ptr = try o.lowerValue(panic_msg_val);
@@ -5770,7 +5768,7 @@ pub const FuncGen = struct {
// ptr null, ; stack trace
// ptr @2, ; addr (null ?usize)
// )
- const panic_func = zcu.funcInfo(zcu.builtin_decl_values.@"Panic.call");
+ const panic_func = zcu.funcInfo(zcu.builtin_decl_values.get(.@"Panic.call"));
const panic_nav = ip.getNav(panic_func.owner_nav);
const fn_info = zcu.typeToFunc(Type.fromInterned(panic_nav.typeOf(ip))).?;
const panic_global = try o.resolveLlvmFunction(panic_func.owner_nav);