diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2024-12-17 00:41:01 +0000 |
|---|---|---|
| committer | mlugg <mlugg@mlugg.co.uk> | 2024-12-23 21:09:17 +0000 |
| commit | 18362ebe13ece2ea7c4f57303ec4687f55d2dba5 (patch) | |
| tree | 22eeda854078b1201eaf10d64bdfba19f916318d /src/codegen | |
| parent | af5e731729592af4a5716edd3b1e03264d66ea46 (diff) | |
| download | zig-18362ebe13ece2ea7c4f57303ec4687f55d2dba5.tar.gz zig-18362ebe13ece2ea7c4f57303ec4687f55d2dba5.zip | |
Zir: refactor `declaration` instruction representation
The new representation is often more compact. It is also more
straightforward to understand: for instance, `extern` is represented on
the `declaration` instruction itself rather than using a special
instruction. The same applies to `var`, making both of these far more
compact.
This commit also separates the type and value bodies of a `declaration`
instruction. This is a prerequisite for #131.
In general, `declaration` now directly encodes details of the syntax
form used, and the embedded ZIR bodies are for actual expressions. The
only exception to this is functions, where ZIR is effectively designed
as if we had #1717. `extern fn` declarations are modeled as
`extern const` with a function type, and normal `fn` definitions are
modeled as `const` with a `func{,_fancy,_inferred}` instruction. This
may change in the future, but improving on this was out of scope for
this commit.
Diffstat (limited to 'src/codegen')
| -rw-r--r-- | src/codegen/llvm.zig | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index b94ea07995..154a7114cf 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -2939,7 +2939,6 @@ pub const Object = struct { const sret = firstParamSRet(fn_info, zcu, target); const is_extern, const lib_name = switch (ip.indexToKey(val.toIntern())) { - .variable => |variable| .{ false, variable.lib_name }, .@"extern" => |@"extern"| .{ true, @"extern".lib_name }, else => .{ false, .none }, }; @@ -4803,7 +4802,7 @@ pub const NavGen = struct { const resolved = nav.status.resolved; const is_extern, const lib_name, const is_threadlocal, const is_weak_linkage, const is_dll_import, const is_const, const init_val, const owner_nav = switch (ip.indexToKey(resolved.val)) { - .variable => |variable| .{ false, variable.lib_name, variable.is_threadlocal, variable.is_weak_linkage, false, false, variable.init, variable.owner_nav }, + .variable => |variable| .{ false, .none, variable.is_threadlocal, variable.is_weak_linkage, false, false, variable.init, variable.owner_nav }, .@"extern" => |@"extern"| .{ true, @"extern".lib_name, @"extern".is_threadlocal, @"extern".is_weak_linkage, @"extern".is_dll_import, @"extern".is_const, .none, @"extern".owner_nav }, else => .{ false, .none, false, false, false, true, resolved.val, nav_index }, }; |
