# stage2: implement runtime \`@intToEnum\` · gitcafe/zig

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

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

Visibility: public

Requested revision: cb616cb7972bb2f38ea4527c7ec0ae3cc0d64c7c

Requested commit: cb616cb7972bb2f38ea4527c7ec0ae3cc0d64c7c

Commit: cb616cb7972bb2f38ea4527c7ec0ae3cc0d64c7c

Tree: bb34a640825465b95c7be5c712da5a5a17217192

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
stage2: implement runtime `@intToEnum`

 * Update AIR instruction `intcast` to allow the dest type to be an
   enum.
 * LLVM backend: update `intcast` to support when the bit counts of
   operand and dest type are the same. This was already a requirement of
   the instruction previously.
 * Type: `intInfo` supports the case when the type is an enum, and
   retrieves the info for the integer tag type. This makes it pretty
   easy for backends to implement `intcast` without having to care
   explicitly that the new type is an enum. As a bonus, simple enums
   never have to go through the type system; their signedness and bit
   count are computed directly.

The "int to enum" behavior test case is now passing for stage2 in the
LLVM backend.

```

## Parents

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

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