# Zir: refactor \`declaration\` instruction representation · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/18362ebe13ece2ea7c4f57303ec4687f55d2dba5)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 18362ebe13ece2ea7c4f57303ec4687f55d2dba5

Requested commit: 18362ebe13ece2ea7c4f57303ec4687f55d2dba5

Commit: 18362ebe13ece2ea7c4f57303ec4687f55d2dba5

Tree: 22eeda854078b1201eaf10d64bdfba19f916318d

Author: mlugg

Committer: mlugg

## Message

```
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.

```

## Parents

- [af5e731729592af4a5716edd3b1e03264d66ea46](https://git.cafe/gitcafe/zig/commit/af5e731729592af4a5716edd3b1e03264d66ea46?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/18362ebe13ece2ea7c4f57303ec4687f55d2dba5?format=markdown)
