| 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(); |
| 2378 | assert(merge_label.op == spv::OpLabel); |
| 2379 | _current_block_data->instructions.pop_back(); |
| 2380 | |
| 2381 | // Add previous block containing the condition value first |
| 2382 | _current_block_data->append(_block_data[condition_block]); |
| 2383 | |
| 2384 | if (true_statement_block != condition_block) |
| 2385 | _current_block_data->append(_block_data[true_statement_block]); |
| 2386 | if (false_statement_block != condition_block) |
| 2387 | _current_block_data->append(_block_data[false_statement_block]); |
| 2388 | |
| 2389 | _current_block_data->instructions.push_back(merge_label); |
| 2390 | |
| 2391 | add_location(loc, *_current_block_data); |
| 2392 | |
| 2393 | // https://www.khronos.org/registry/spir-v/specs/unified1/SPIRV.html#OpPhi |
| 2394 | spirv_instruction &inst = add_instruction(spv::OpPhi, convert_type(res_type)) |
| 2395 | .add(true_value) // Variable 0 |
| 2396 | .add(true_statement_block) // Parent 0 |
| 2397 | .add(false_value) // Variable 1 |
| 2398 | .add(false_statement_block); // Parent 1 |
| 2399 | |
| 2400 | return inst; |
| 2401 | } |
| 2402 | void emit_loop(const location &loc, id, id prev_block, id header_block, id condition_block, id loop_block, id continue_block, unsigned int loop_control) override |
| 2403 | { |
| 2404 | spirv_instruction merge_label = _current_block_data->instructions.back(); |