# self-hosted: working towards conditional branching test case · gitcafe/zig

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

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

Visibility: public

Requested revision: 130c7fd23b9f23aa5afad2eb1744ffab9e193715

Requested commit: 130c7fd23b9f23aa5afad2eb1744ffab9e193715

Commit: 130c7fd23b9f23aa5afad2eb1744ffab9e193715

Tree: b39e5cf093a901c7713009d4c4448e0702d4ead7

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

````
self-hosted: working towards conditional branching test case

New features:
 * Functions can have parameters in semantic analysis. Codegen
   is not implemented yet.
 * Support for i8, i16, i32, i64, u8, u16, u32, u64 primitive
   identifiers.
 * New ZIR instructions: arg, block, and breakvoid

Implementation details:

 * Move Module.Body to ir.Body
 * Scope.Block gains a parent field and an optional Label field
 * Fix bug in integer type equality comparison.

Here's the test case I'm working towards:

```
@void = primitive(void)
@i32 = primitive(i32)
@fnty = fntype([@i32, @i32], @void)

@0 = str("entry")
@1 = export(@0, "entry")

@entry = fn(@fnty, {
  %0 = arg(0)
  %1 = arg(1)
  %2 = add(%0, %1)
  %3 = int(7)
  %4 = block("if", {
    %neq = cmp(%2, neq, %3)
    %5 = condbr(%neq, {
      %6 = unreachable()
    }, {
      %7 = breakvoid("if")
    })
  })
  %11 = returnvoid()
})
```

$ ./zig-cache/bin/zig build-obj test.zir
test.zir:9:12: error: TODO implement function parameters for Arch.x86_64

That's where I left off.

````

## Parents

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

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