diff options
| author | 2021-07-12 05:22:01 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:40 -0400 | |
| commit | bf2956d77ab0ad06c4b5505cc9906e51e5878274 (patch) | |
| tree | 3aae336c0dc3fe65351d5e6e312a214351e2e2fc /src/shader_recompiler/frontend/maxwell | |
| parent | glsl: Clamp shared mem size to GL_MAX_COMPUTE_SHARED_MEMORY_SIZE (diff) | |
| download | yuzu-bf2956d77ab0ad06c4b5505cc9906e51e5878274.tar.gz yuzu-bf2956d77ab0ad06c4b5505cc9906e51e5878274.tar.xz yuzu-bf2956d77ab0ad06c4b5505cc9906e51e5878274.zip | |
shader: Avoid usage of C++20 ranges to build in clang
Diffstat (limited to 'src/shader_recompiler/frontend/maxwell')
3 files changed, 23 insertions, 18 deletions
diff --git a/src/shader_recompiler/frontend/maxwell/control_flow.cpp b/src/shader_recompiler/frontend/maxwell/control_flow.cpp index e7abea82f..1a954a509 100644 --- a/src/shader_recompiler/frontend/maxwell/control_flow.cpp +++ b/src/shader_recompiler/frontend/maxwell/control_flow.cpp | |||
| @@ -5,7 +5,6 @@ | |||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <array> | 6 | #include <array> |
| 7 | #include <optional> | 7 | #include <optional> |
| 8 | #include <ranges> | ||
| 9 | #include <string> | 8 | #include <string> |
| 10 | #include <utility> | 9 | #include <utility> |
| 11 | 10 | ||
| @@ -151,18 +150,18 @@ std::pair<Location, Stack> Stack::Pop(Token token) const { | |||
| 151 | } | 150 | } |
| 152 | 151 | ||
| 153 | std::optional<Location> Stack::Peek(Token token) const { | 152 | std::optional<Location> Stack::Peek(Token token) const { |
| 154 | const auto reverse_entries{entries | std::views::reverse}; | 153 | const auto it{std::find_if(entries.rbegin(), entries.rend(), |
| 155 | const auto it{std::ranges::find(reverse_entries, token, &StackEntry::token)}; | 154 | [token](const auto& entry) { return entry.token == token; })}; |
| 156 | if (it == reverse_entries.end()) { | 155 | if (it == entries.rend()) { |
| 157 | return std::nullopt; | 156 | return std::nullopt; |
| 158 | } | 157 | } |
| 159 | return it->target; | 158 | return it->target; |
| 160 | } | 159 | } |
| 161 | 160 | ||
| 162 | Stack Stack::Remove(Token token) const { | 161 | Stack Stack::Remove(Token token) const { |
| 163 | const auto reverse_entries{entries | std::views::reverse}; | 162 | const auto it{std::find_if(entries.rbegin(), entries.rend(), |
| 164 | const auto it{std::ranges::find(reverse_entries, token, &StackEntry::token)}; | 163 | [token](const auto& entry) { return entry.token == token; })}; |
| 165 | const auto pos{std::distance(reverse_entries.begin(), it)}; | 164 | const auto pos{std::distance(entries.rbegin(), it)}; |
| 166 | Stack result; | 165 | Stack result; |
| 167 | result.entries.insert(result.entries.end(), entries.begin(), entries.end() - pos - 1); | 166 | result.entries.insert(result.entries.end(), entries.begin(), entries.end() - pos - 1); |
| 168 | return result; | 167 | return result; |
diff --git a/src/shader_recompiler/frontend/maxwell/structured_control_flow.cpp b/src/shader_recompiler/frontend/maxwell/structured_control_flow.cpp index 221454b99..8b3e0a15c 100644 --- a/src/shader_recompiler/frontend/maxwell/structured_control_flow.cpp +++ b/src/shader_recompiler/frontend/maxwell/structured_control_flow.cpp | |||
| @@ -4,7 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <memory> | 6 | #include <memory> |
| 7 | #include <ranges> | ||
| 8 | #include <string> | 7 | #include <string> |
| 9 | #include <unordered_map> | 8 | #include <unordered_map> |
| 10 | #include <utility> | 9 | #include <utility> |
| @@ -167,7 +166,7 @@ std::string DumpExpr(const Statement* stmt) { | |||
| 167 | } | 166 | } |
| 168 | } | 167 | } |
| 169 | 168 | ||
| 170 | std::string DumpTree(const Tree& tree, u32 indentation = 0) { | 169 | [[maybe_unused]] std::string DumpTree(const Tree& tree, u32 indentation = 0) { |
| 171 | std::string ret; | 170 | std::string ret; |
| 172 | std::string indent(indentation, ' '); | 171 | std::string indent(indentation, ' '); |
| 173 | for (auto stmt = tree.begin(); stmt != tree.end(); ++stmt) { | 172 | for (auto stmt = tree.begin(); stmt != tree.end(); ++stmt) { |
| @@ -315,8 +314,9 @@ class GotoPass { | |||
| 315 | public: | 314 | public: |
| 316 | explicit GotoPass(Flow::CFG& cfg, ObjectPool<Statement>& stmt_pool) : pool{stmt_pool} { | 315 | explicit GotoPass(Flow::CFG& cfg, ObjectPool<Statement>& stmt_pool) : pool{stmt_pool} { |
| 317 | std::vector gotos{BuildTree(cfg)}; | 316 | std::vector gotos{BuildTree(cfg)}; |
| 318 | for (const Node& goto_stmt : gotos | std::views::reverse) { | 317 | const auto end{gotos.rend()}; |
| 319 | RemoveGoto(goto_stmt); | 318 | for (auto goto_stmt = gotos.rbegin(); goto_stmt != end; ++goto_stmt) { |
| 319 | RemoveGoto(*goto_stmt); | ||
| 320 | } | 320 | } |
| 321 | } | 321 | } |
| 322 | 322 | ||
diff --git a/src/shader_recompiler/frontend/maxwell/translate_program.cpp b/src/shader_recompiler/frontend/maxwell/translate_program.cpp index 83c77967d..c067d459c 100644 --- a/src/shader_recompiler/frontend/maxwell/translate_program.cpp +++ b/src/shader_recompiler/frontend/maxwell/translate_program.cpp | |||
| @@ -4,7 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <memory> | 6 | #include <memory> |
| 7 | #include <ranges> | ||
| 8 | #include <vector> | 7 | #include <vector> |
| 9 | 8 | ||
| 10 | #include "common/settings.h" | 9 | #include "common/settings.h" |
| @@ -20,12 +19,19 @@ | |||
| 20 | namespace Shader::Maxwell { | 19 | namespace Shader::Maxwell { |
| 21 | namespace { | 20 | namespace { |
| 22 | IR::BlockList GenerateBlocks(const IR::AbstractSyntaxList& syntax_list) { | 21 | IR::BlockList GenerateBlocks(const IR::AbstractSyntaxList& syntax_list) { |
| 23 | auto syntax_blocks{syntax_list | std::views::filter([](const auto& node) { | 22 | size_t num_syntax_blocks{}; |
| 24 | return node.type == IR::AbstractSyntaxNode::Type::Block; | 23 | for (const auto& node : syntax_list) { |
| 25 | })}; | 24 | if (node.type == IR::AbstractSyntaxNode::Type::Block) { |
| 26 | IR::BlockList blocks(std::ranges::distance(syntax_blocks)); | 25 | ++num_syntax_blocks; |
| 27 | std::ranges::transform(syntax_blocks, blocks.begin(), | 26 | } |
| 28 | [](const IR::AbstractSyntaxNode& node) { return node.data.block; }); | 27 | } |
| 28 | IR::BlockList blocks; | ||
| 29 | blocks.reserve(num_syntax_blocks); | ||
| 30 | for (const auto& node : syntax_list) { | ||
| 31 | if (node.type == IR::AbstractSyntaxNode::Type::Block) { | ||
| 32 | blocks.push_back(node.data.block); | ||
| 33 | } | ||
| 34 | } | ||
| 29 | return blocks; | 35 | return blocks; |
| 30 | } | 36 | } |
| 31 | 37 | ||