summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/frontend/maxwell/control_flow.cpp
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2021-04-04 20:00:34 -0300
committerGravatar ameerj2021-07-22 21:51:26 -0400
commit9e6fe430bdc615ae5f7cc4fbc32d7e2baccd7ceb (patch)
tree3eb68f4872e39642f6f6c483765174ee77a793f1 /src/shader_recompiler/frontend/maxwell/control_flow.cpp
parentshader: Eliminate orphan blocks more efficiently (diff)
downloadyuzu-9e6fe430bdc615ae5f7cc4fbc32d7e2baccd7ceb.tar.gz
yuzu-9e6fe430bdc615ae5f7cc4fbc32d7e2baccd7ceb.tar.xz
yuzu-9e6fe430bdc615ae5f7cc4fbc32d7e2baccd7ceb.zip
shader: Fix splits on blocks using indirect branches
Diffstat (limited to 'src/shader_recompiler/frontend/maxwell/control_flow.cpp')
-rw-r--r--src/shader_recompiler/frontend/maxwell/control_flow.cpp35
1 files changed, 30 insertions, 5 deletions
diff --git a/src/shader_recompiler/frontend/maxwell/control_flow.cpp b/src/shader_recompiler/frontend/maxwell/control_flow.cpp
index ac8707847..eb0f7c8d1 100644
--- a/src/shader_recompiler/frontend/maxwell/control_flow.cpp
+++ b/src/shader_recompiler/frontend/maxwell/control_flow.cpp
@@ -45,19 +45,29 @@ void Split(Block* old_block, Block* new_block, Location pc) {
45 .begin{pc}, 45 .begin{pc},
46 .end{old_block->end}, 46 .end{old_block->end},
47 .end_class{old_block->end_class}, 47 .end_class{old_block->end_class},
48 .stack{old_block->stack},
49 .cond{old_block->cond}, 48 .cond{old_block->cond},
49 .stack{old_block->stack},
50 .branch_true{old_block->branch_true}, 50 .branch_true{old_block->branch_true},
51 .branch_false{old_block->branch_false}, 51 .branch_false{old_block->branch_false},
52 .function_call{old_block->function_call},
53 .return_block{old_block->return_block},
54 .branch_reg{old_block->branch_reg},
55 .branch_offset{old_block->branch_offset},
56 .indirect_branches{std::move(old_block->indirect_branches)},
52 }; 57 };
53 *old_block = Block{ 58 *old_block = Block{
54 .begin{old_block->begin}, 59 .begin{old_block->begin},
55 .end{pc}, 60 .end{pc},
56 .end_class{EndClass::Branch}, 61 .end_class{EndClass::Branch},
57 .stack{std::move(old_block->stack)},
58 .cond{true}, 62 .cond{true},
63 .stack{std::move(old_block->stack)},
59 .branch_true{new_block}, 64 .branch_true{new_block},
60 .branch_false{nullptr}, 65 .branch_false{nullptr},
66 .function_call{},
67 .return_block{},
68 .branch_reg{},
69 .branch_offset{},
70 .indirect_branches{},
61 }; 71 };
62} 72}
63 73
@@ -173,10 +183,15 @@ Function::Function(ObjectPool<Block>& block_pool, Location start_address)
173 .begin{start_address}, 183 .begin{start_address},
174 .end{start_address}, 184 .end{start_address},
175 .end_class{EndClass::Branch}, 185 .end_class{EndClass::Branch},
176 .stack{},
177 .cond{true}, 186 .cond{true},
187 .stack{},
178 .branch_true{nullptr}, 188 .branch_true{nullptr},
179 .branch_false{nullptr}, 189 .branch_false{nullptr},
190 .function_call{},
191 .return_block{},
192 .branch_reg{},
193 .branch_offset{},
194 .indirect_branches{},
180 })}, 195 })},
181 .stack{}, 196 .stack{},
182 }} {} 197 }} {}
@@ -351,10 +366,15 @@ void CFG::AnalyzeCondInst(Block* block, FunctionId function_id, Location pc,
351 .begin{block->begin.Virtual()}, 366 .begin{block->begin.Virtual()},
352 .end{block->begin.Virtual()}, 367 .end{block->begin.Virtual()},
353 .end_class{EndClass::Branch}, 368 .end_class{EndClass::Branch},
354 .stack{block->stack},
355 .cond{cond}, 369 .cond{cond},
370 .stack{block->stack},
356 .branch_true{conditional_block}, 371 .branch_true{conditional_block},
357 .branch_false{nullptr}, 372 .branch_false{nullptr},
373 .function_call{},
374 .return_block{},
375 .branch_reg{},
376 .branch_offset{},
377 .indirect_branches{},
358 }; 378 };
359 // Save the contents of the visited block in the conditional block 379 // Save the contents of the visited block in the conditional block
360 *conditional_block = std::move(*block); 380 *conditional_block = std::move(*block);
@@ -502,10 +522,15 @@ Block* CFG::AddLabel(Block* block, Stack stack, Location pc, FunctionId function
502 .begin{pc}, 522 .begin{pc},
503 .end{pc}, 523 .end{pc},
504 .end_class{EndClass::Branch}, 524 .end_class{EndClass::Branch},
505 .stack{stack},
506 .cond{true}, 525 .cond{true},
526 .stack{stack},
507 .branch_true{nullptr}, 527 .branch_true{nullptr},
508 .branch_false{nullptr}, 528 .branch_false{nullptr},
529 .function_call{},
530 .return_block{},
531 .branch_reg{},
532 .branch_offset{},
533 .indirect_branches{},
509 })}; 534 })};
510 function.labels.push_back(Label{ 535 function.labels.push_back(Label{
511 .address{pc}, 536 .address{pc},