# self-hosted: refactor some code out of Module.zig into zir_sema.zig · gitcafe/zig

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

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

Visibility: public

Requested revision: 0965724e31666d156ca96375eee591380f3c9042

Requested commit: 0965724e31666d156ca96375eee591380f3c9042

Commit: 0965724e31666d156ca96375eee591380f3c9042

Tree: 020b1a51091dfdcef21baeb26e83ca6ee503b9c1

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
self-hosted: refactor some code out of Module.zig into zir_sema.zig

This makes sense from an organizational point of view, as explained by
this new doc comment at the top of the new file:

//! Semantic analysis of ZIR instructions.
//! This file operates on a `Module` instance, transforming untyped ZIR
//! instructions into semantically-analyzed IR instructions. It does type
//! checking, comptime control flow, and safety-check generation. This is the
//! the heart of the Zig compiler.
//! When deciding if something goes into this file or into Module, here is a
//! guiding principle: if it has to do with (untyped) ZIR instructions, it goes
//! here. If the analysis operates on typed IR instructions, it goes in Module.

Before:
   4009 src-self-hosted/Module.zig

After:
   2776 src-self-hosted/Module.zig
   1128 src-self-hosted/zir_sema.zig

This should be sufficient to avoid the situation we have in stage1 where
ir.cpp is 32,516 lines.

```

## Parents

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

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