summaryrefslogtreecommitdiff
path: root/src/video_core/shader/ast.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core/shader/ast.cpp')
-rw-r--r--src/video_core/shader/ast.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/video_core/shader/ast.cpp b/src/video_core/shader/ast.cpp
index 54f0240e1..fc440526f 100644
--- a/src/video_core/shader/ast.cpp
+++ b/src/video_core/shader/ast.cpp
@@ -432,6 +432,12 @@ void ASTManager::InsertReturn(Expr condition, bool kills) {
432 program->nodes.PushBack(node); 432 program->nodes.PushBack(node);
433} 433}
434 434
435// The decompile algorithm is based on
436// "Taming control flow: A structured approach to eliminating goto statements"
437// by AM Erosa, LJ Hendren 1994. In general, the idea is to get gotos to be
438// on the same structured level as the label which they jump to. This is done,
439// through outward/inward movements and lifting. Once they are at the same
440// level, you can enclose them in an "if" structure or a "do-while" structure.
435void ASTManager::Decompile() { 441void ASTManager::Decompile() {
436 auto it = gotos.begin(); 442 auto it = gotos.begin();
437 while (it != gotos.end()) { 443 while (it != gotos.end()) {
@@ -656,11 +662,9 @@ void ASTManager::EncloseIfThen(ASTNode goto_node, ASTNode label) {
656 sub_zipper->Init(goto_node, if_node); 662 sub_zipper->Init(goto_node, if_node);
657 zipper.InsertAfter(if_node, prev); 663 zipper.InsertAfter(if_node, prev);
658 sub_zipper->Remove(goto_node); 664 sub_zipper->Remove(goto_node);
659 // ShowCurrentState("After IfThen Enclose");
660} 665}
661 666
662void ASTManager::MoveOutward(ASTNode goto_node) { 667void ASTManager::MoveOutward(ASTNode goto_node) {
663 // ShowCurrentState("Before MoveOutward");
664 ASTZipper& zipper = goto_node->GetManager(); 668 ASTZipper& zipper = goto_node->GetManager();
665 const ASTNode parent = goto_node->GetParent(); 669 const ASTNode parent = goto_node->GetParent();
666 ASTZipper& zipper2 = parent->GetManager(); 670 ASTZipper& zipper2 = parent->GetManager();