committed by
ameerj
12 changed files with 150 additions and 46 deletions
-
2src/shader_recompiler/CMakeLists.txt
-
12src/shader_recompiler/backend/spirv/emit_spirv.h
-
8src/shader_recompiler/backend/spirv/emit_spirv_integer.cpp
-
10src/shader_recompiler/backend/spirv/emit_spirv_undefined.cpp
-
1src/shader_recompiler/frontend/ir/function.h
-
48src/shader_recompiler/frontend/ir/post_order.cpp
-
13src/shader_recompiler/frontend/ir/post_order.h
-
12src/shader_recompiler/frontend/maxwell/program.cpp
-
2src/shader_recompiler/ir_opt/dead_code_elimination_pass.cpp
-
8src/shader_recompiler/ir_opt/passes.h
-
62src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp
-
18src/shader_recompiler/main.cpp
@ -0,0 +1,48 @@ |
|||
// Copyright 2021 yuzu Emulator Project
|
|||
// Licensed under GPLv2 or any later version
|
|||
// Refer to the license.txt file included.
|
|||
|
|||
#include <boost/container/flat_set.hpp>
|
|||
#include <boost/container/small_vector.hpp>
|
|||
|
|||
#include "shader_recompiler/frontend/ir/basic_block.h"
|
|||
#include "shader_recompiler/frontend/ir/post_order.h"
|
|||
|
|||
namespace Shader::IR { |
|||
|
|||
BlockList PostOrder(const BlockList& blocks) { |
|||
boost::container::small_vector<Block*, 16> block_stack; |
|||
boost::container::flat_set<Block*> visited; |
|||
|
|||
BlockList post_order_blocks; |
|||
post_order_blocks.reserve(blocks.size()); |
|||
|
|||
Block* const first_block{blocks.front()}; |
|||
visited.insert(first_block); |
|||
block_stack.push_back(first_block); |
|||
|
|||
const auto visit_branch = [&](Block* block, Block* branch) { |
|||
if (!branch) { |
|||
return false; |
|||
} |
|||
if (!visited.insert(branch).second) { |
|||
return false; |
|||
} |
|||
// Calling push_back twice is faster than insert on msvc
|
|||
block_stack.push_back(block); |
|||
block_stack.push_back(branch); |
|||
return true; |
|||
}; |
|||
while (!block_stack.empty()) { |
|||
Block* const block{block_stack.back()}; |
|||
block_stack.pop_back(); |
|||
|
|||
if (!visit_branch(block, block->TrueBranch()) && |
|||
!visit_branch(block, block->FalseBranch())) { |
|||
post_order_blocks.push_back(block); |
|||
} |
|||
} |
|||
return post_order_blocks; |
|||
} |
|||
|
|||
} // namespace Shader::IR
|
|||
@ -0,0 +1,13 @@ |
|||
// Copyright 2021 yuzu Emulator Project |
|||
// Licensed under GPLv2 or any later version |
|||
// Refer to the license.txt file included. |
|||
|
|||
#pragma once |
|||
|
|||
#include "shader_recompiler/frontend/ir/basic_block.h" |
|||
|
|||
namespace Shader::IR { |
|||
|
|||
BlockList PostOrder(const BlockList& blocks); |
|||
|
|||
} // namespace Shader::IR |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue