| 2347 | } |
| 2348 | |
| 2349 | void emit_if(const location &loc, id, id condition_block, id true_statement_block, id false_statement_block, unsigned int selection_control) override |
| 2350 | { |
| 2351 | spirv_instruction merge_label = _current_block_data->instructions.back(); |
| 2352 | assert(merge_label.op == spv::OpLabel); |
| 2353 | _current_block_data->instructions.pop_back(); |
| 2354 | |
| 2355 | // Add previous block containing the condition value first |
| 2356 | _current_block_data->append(_block_data[condition_block]); |
| 2357 | |
| 2358 | spirv_instruction branch_inst = _current_block_data->instructions.back(); |
| 2359 | assert(branch_inst.op == spv::OpBranchConditional); |
| 2360 | _current_block_data->instructions.pop_back(); |
| 2361 | |
| 2362 | // Add structured control flow instruction |
| 2363 | add_location(loc, *_current_block_data); |
| 2364 | add_instruction_without_result(spv::OpSelectionMerge) |
| 2365 | .add(merge_label) |
| 2366 | .add(selection_control & 0x3); // 'SelectionControl' happens to match the flags produced by the parser |
| 2367 | |
| 2368 | // Append all blocks belonging to the branch |
| 2369 | _current_block_data->instructions.push_back(branch_inst); |
| 2370 | _current_block_data->append(_block_data[true_statement_block]); |
| 2371 | _current_block_data->append(_block_data[false_statement_block]); |
| 2372 | |
| 2373 | _current_block_data->instructions.push_back(merge_label); |
| 2374 | } |
| 2375 | id emit_phi(const location &loc, id, id condition_block, id true_value, id true_statement_block, id false_value, id false_statement_block, const type &res_type) override |
| 2376 | { |
| 2377 | spirv_instruction merge_label = _current_block_data->instructions.back(); |