summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/frontend/ir/program.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader_recompiler/frontend/ir/program.cpp')
-rw-r--r--src/shader_recompiler/frontend/ir/program.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/shader_recompiler/frontend/ir/program.cpp b/src/shader_recompiler/frontend/ir/program.cpp
new file mode 100644
index 000000000..0ce99ef2a
--- /dev/null
+++ b/src/shader_recompiler/frontend/ir/program.cpp
@@ -0,0 +1,38 @@
1// Copyright 2021 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <map>
8#include <string>
9
10#include <fmt/format.h>
11
12#include "shader_recompiler/frontend/ir/function.h"
13#include "shader_recompiler/frontend/ir/program.h"
14
15namespace Shader::IR {
16
17std::string DumpProgram(const Program& program) {
18 size_t index{0};
19 std::map<const IR::Inst*, size_t> inst_to_index;
20 std::map<const IR::Block*, size_t> block_to_index;
21
22 for (const IR::Function& function : program.functions) {
23 for (const IR::Block* const block : function.blocks) {
24 block_to_index.emplace(block, index);
25 ++index;
26 }
27 }
28 std::string ret;
29 for (const IR::Function& function : program.functions) {
30 ret += fmt::format("Function\n");
31 for (const auto& block : function.blocks) {
32 ret += IR::DumpBlock(*block, block_to_index, inst_to_index, index) + '\n';
33 }
34 }
35 return ret;
36}
37
38} // namespace Shader::IR \ No newline at end of file