summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/shader_recompiler/frontend/maxwell/control_flow.cpp35
-rw-r--r--src/shader_recompiler/frontend/maxwell/control_flow.h18
-rw-r--r--src/shader_recompiler/frontend/maxwell/program.cpp2
3 files changed, 38 insertions, 17 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},
diff --git a/src/shader_recompiler/frontend/maxwell/control_flow.h b/src/shader_recompiler/frontend/maxwell/control_flow.h
index a8c90d27a..466b14198 100644
--- a/src/shader_recompiler/frontend/maxwell/control_flow.h
+++ b/src/shader_recompiler/frontend/maxwell/control_flow.h
@@ -79,18 +79,14 @@ struct Block : boost::intrusive::set_base_hook<
79 Location begin; 79 Location begin;
80 Location end; 80 Location end;
81 EndClass end_class; 81 EndClass end_class;
82 Stack stack;
83 IR::Condition cond; 82 IR::Condition cond;
84 union { 83 Stack stack;
85 Block* branch_true; 84 Block* branch_true;
86 FunctionId function_call; 85 Block* branch_false;
87 IR::Reg branch_reg; 86 FunctionId function_call;
88 }; 87 Block* return_block;
89 union { 88 IR::Reg branch_reg;
90 Block* branch_false; 89 s32 branch_offset;
91 Block* return_block;
92 s32 branch_offset;
93 };
94 std::vector<IndirectBranch> indirect_branches; 90 std::vector<IndirectBranch> indirect_branches;
95}; 91};
96 92
diff --git a/src/shader_recompiler/frontend/maxwell/program.cpp b/src/shader_recompiler/frontend/maxwell/program.cpp
index 05b7591bc..58caa35a1 100644
--- a/src/shader_recompiler/frontend/maxwell/program.cpp
+++ b/src/shader_recompiler/frontend/maxwell/program.cpp
@@ -21,7 +21,7 @@ void RemoveUnreachableBlocks(IR::Program& program) {
21 if (program.blocks.size() == program.post_order_blocks.size()) { 21 if (program.blocks.size() == program.post_order_blocks.size()) {
22 return; 22 return;
23 } 23 }
24 const auto begin{std::next(program.blocks.begin())}; 24 const auto begin{program.blocks.begin() + 1};
25 const auto end{program.blocks.end()}; 25 const auto end{program.blocks.end()};
26 const auto pred{[](IR::Block* block) { return block->ImmediatePredecessors().empty(); }}; 26 const auto pred{[](IR::Block* block) { return block->ImmediatePredecessors().empty(); }};
27 program.blocks.erase(std::remove_if(begin, end, pred), end); 27 program.blocks.erase(std::remove_if(begin, end, pred), end);