diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2024-08-30 20:29:27 +0100 |
|---|---|---|
| committer | mlugg <mlugg@mlugg.co.uk> | 2024-09-01 18:30:31 +0100 |
| commit | 1b000b90c9a7abde3aeacf29cef73a877da237e1 (patch) | |
| tree | 837c7481d97c1bbf8d165f2b74b3ae77fbcd2f09 /src/codegen/spirv/Module.zig | |
| parent | 49ad51b2feacad394e05d7b5c87c5020c3bc0f5e (diff) | |
| download | zig-1b000b90c9a7abde3aeacf29cef73a877da237e1.tar.gz zig-1b000b90c9a7abde3aeacf29cef73a877da237e1.zip | |
Air: direct representation of ranges in switch cases
This commit modifies the representation of the AIR `switch_br`
instruction to represent ranges in cases. Previously, Sema emitted
different AIR in the case of a range, where the `else` branch of the
`switch_br` contained a simple `cond_br` for each such case which did a
simple range check (`x > a and x < b`). Not only does this add
complexity to Sema, which we would like to minimize, but it also gets in
the way of the implementation of #8220. That proposal turns certain
`switch` statements into a looping construct, and for optimization
purposes, we want to lower this to AIR fairly directly (i.e. without
involving a `loop` instruction). That means we would ideally like a
single instruction to represent the entire `switch` statement, so that
we can dispatch back to it with a different operand as in #8220. This is
not really possible to do correctly under the status quo system.
This commit implements lowering of this new `switch_br` usage in the
LLVM and C backends. The C backend just turns any case containing ranges
entirely into conditionals, as before. The LLVM backend is a little
smarter, and puts scalar items into the `switch` instruction, only using
conditionals for the range cases (which direct to the same bb). All
remaining self-hosted backends are temporarily regressed in the presence
of switch range cases. This functionality will be restored for at least
the x86_64 backend before merge.
Diffstat (limited to 'src/codegen/spirv/Module.zig')
0 files changed, 0 insertions, 0 deletions
