summaryrefslogtreecommitdiffstats
path: root/src/compiler/spirv
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2017-12-06 10:09:28 -0800
committerJason Ekstrand <[email protected]>2017-12-11 22:28:34 -0800
commit58cabae8cc8e848cfe39c7a63973c12c92a4ee96 (patch)
treecd5eb6fa30629f78eb440f30b7885f1bc1323acb /src/compiler/spirv
parent5f572ccc95bdfa1445b67511c6d2c9b23bc22208 (diff)
spirv: Restructure the case loop in OpSwitch handling
Instead of calling vtn_add_case for the default case and then looping, add an is_default variable and do everything inside the loop. This will make the next commit easier. Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/compiler/spirv')
-rw-r--r--src/compiler/spirv/vtn_cfg.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/compiler/spirv/vtn_cfg.c b/src/compiler/spirv/vtn_cfg.c
index 25140ffc7dd..28b811fc9a9 100644
--- a/src/compiler/spirv/vtn_cfg.c
+++ b/src/compiler/spirv/vtn_cfg.c
@@ -425,9 +425,17 @@ vtn_cfg_walk_blocks(struct vtn_builder *b, struct list_head *cf_list,
const uint32_t *branch_end =
block->branch + (block->branch[0] >> SpvWordCountShift);
- vtn_add_case(b, swtch, break_block, block->branch[2], 0, true);
- for (const uint32_t *w = block->branch + 3; w < branch_end; w += 2)
- vtn_add_case(b, swtch, break_block, w[1], w[0], false);
+ bool is_default = true;
+ for (const uint32_t *w = block->branch + 2; w < branch_end;) {
+ uint32_t literal = 0;
+ if (!is_default)
+ literal = *(w++);
+
+ uint32_t block_id = *(w++);
+
+ vtn_add_case(b, swtch, break_block, block_id, literal, is_default);
+ is_default = false;
+ }
/* Now, we go through and walk the blocks. While we walk through
* the blocks, we also gather the much-needed fall-through