diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-05-29 17:54:16 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-05-30 12:03:53 -0700 |
| commit | 9da3a058d82573efeaf12fe61ab6a312649175ec (patch) | |
| tree | b86f6f08761289b95c46e10879e476da455de218 /src/Module.zig | |
| parent | f846dc420fff629572caa1175bfa64e5fcffaeb5 (diff) | |
| download | zig-9da3a058d82573efeaf12fe61ab6a312649175ec.tar.gz zig-9da3a058d82573efeaf12fe61ab6a312649175ec.zip | |
stage2: add missing data to ZIR encoding of functions
The main purpose of this commit is to prepare to implement support for
callconv(), align(), linksection(), and addrspace() annotations on
generic functions where the provided expression depends on comptime
parameters (making the function generic).
It's a rather involved change, so this commit only makes the necessary
changes to AstGen without regressing any behavior, and a follow-up
commit can finish the task by making the enhancements to Sema.
By my quick estimation, the new encoding for functions is a negligible
improvement - along the lines of 0.005% fewer total ZIR bytes on
average. Still, it's nice that this commit, while adding more
data into ZIR, actually ends up reducing the storage size thanks to a
slightly more sophisticated encoding.
Zir.Inst.ExtendedFunc is renamed to Zir.Inst.FuncFancy to eliminate
confusion about it being an extended instruction (it used to be but is
no longer). The encoding for this instruction is completely reworked.
The encoding for Zir.Inst.Func is also changed slightly - when the
return type body length is 1, then only a Zir.Inst.Ref is provided; not
a full body.
linksection() and addrspace() are now communicated via func_fancy ZIR
instruction rather than as part of the corresponding decl. This allows
their expressions to observe comptime parameters.
Diffstat (limited to 'src/Module.zig')
| -rw-r--r-- | src/Module.zig | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/Module.zig b/src/Module.zig index 7c19c4dab6..f8d662ae1f 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -1595,9 +1595,9 @@ pub const Fn = struct { switch (zir_tags[func.zir_body_inst]) { .func => return false, .func_inferred => return true, - .func_extended => { + .func_fancy => { const inst_data = zir.instructions.items(.data)[func.zir_body_inst].pl_node; - const extra = zir.extraData(Zir.Inst.ExtendedFunc, inst_data.payload_index); + const extra = zir.extraData(Zir.Inst.FuncFancy, inst_data.payload_index); return extra.data.bits.is_inferred_error; }, else => unreachable, |
