diff options
| author | 2021-07-12 05:22:01 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:40 -0400 | |
| commit | bf2956d77ab0ad06c4b5505cc9906e51e5878274 (patch) | |
| tree | 3aae336c0dc3fe65351d5e6e312a214351e2e2fc /src | |
| 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')
11 files changed, 47 insertions, 39 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm.cpp b/src/shader_recompiler/backend/glasm/emit_glasm.cpp index 64787b353..a5e8c9b6e 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm.cpp +++ b/src/shader_recompiler/backend/glasm/emit_glasm.cpp | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <ranges> | 5 | #include <algorithm> |
| 6 | #include <string> | 6 | #include <string> |
| 7 | #include <tuple> | 7 | #include <tuple> |
| 8 | 8 | ||
| @@ -196,7 +196,10 @@ void PrecolorInst(IR::Inst& phi) { | |||
| 196 | 196 | ||
| 197 | void Precolor(const IR::Program& program) { | 197 | void Precolor(const IR::Program& program) { |
| 198 | for (IR::Block* const block : program.blocks) { | 198 | for (IR::Block* const block : program.blocks) { |
| 199 | for (IR::Inst& phi : block->Instructions() | std::views::take_while(IR::IsPhi)) { | 199 | for (IR::Inst& phi : block->Instructions()) { |
| 200 | if (!IR::IsPhi(phi)) { | ||
| 201 | break; | ||
| 202 | } | ||
| 200 | PrecolorInst(phi); | 203 | PrecolorInst(phi); |
| 201 | } | 204 | } |
| 202 | } | 205 | } |
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl.cpp b/src/shader_recompiler/backend/glsl/emit_glsl.cpp index c5e819a0a..8a430d573 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl.cpp | |||
| @@ -2,8 +2,10 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <ranges> | 5 | #include <algorithm> |
| 6 | #include <string> | 6 | #include <string> |
| 7 | #include <tuple> | ||
| 8 | #include <type_traits> | ||
| 7 | 9 | ||
| 8 | #include "common/div_ceil.h" | 10 | #include "common/div_ceil.h" |
| 9 | #include "common/settings.h" | 11 | #include "common/settings.h" |
| @@ -120,7 +122,10 @@ void PrecolorInst(IR::Inst& phi) { | |||
| 120 | 122 | ||
| 121 | void Precolor(const IR::Program& program) { | 123 | void Precolor(const IR::Program& program) { |
| 122 | for (IR::Block* const block : program.blocks) { | 124 | for (IR::Block* const block : program.blocks) { |
| 123 | for (IR::Inst& phi : block->Instructions() | std::views::take_while(IR::IsPhi)) { | 125 | for (IR::Inst& phi : block->Instructions()) { |
| 126 | if (!IR::IsPhi(phi)) { | ||
| 127 | break; | ||
| 128 | } | ||
| 124 | PrecolorInst(phi); | 129 | PrecolorInst(phi); |
| 125 | } | 130 | } |
| 126 | } | 131 | } |
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 | ||
diff --git a/src/shader_recompiler/ir_opt/constant_propagation_pass.cpp b/src/shader_recompiler/ir_opt/constant_propagation_pass.cpp index 3c72203ad..8dd6d6c2c 100644 --- a/src/shader_recompiler/ir_opt/constant_propagation_pass.cpp +++ b/src/shader_recompiler/ir_opt/constant_propagation_pass.cpp | |||
| @@ -3,7 +3,6 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <ranges> | ||
| 7 | #include <tuple> | 6 | #include <tuple> |
| 8 | #include <type_traits> | 7 | #include <type_traits> |
| 9 | 8 | ||
| @@ -599,7 +598,9 @@ void ConstantPropagation(IR::Block& block, IR::Inst& inst) { | |||
| 599 | } // Anonymous namespace | 598 | } // Anonymous namespace |
| 600 | 599 | ||
| 601 | void ConstantPropagationPass(IR::Program& program) { | 600 | void ConstantPropagationPass(IR::Program& program) { |
| 602 | for (IR::Block* const block : program.post_order_blocks | std::views::reverse) { | 601 | const auto end{program.post_order_blocks.rend()}; |
| 602 | for (auto it = program.post_order_blocks.rbegin(); it != end; ++it) { | ||
| 603 | IR::Block* const block{*it}; | ||
| 603 | for (IR::Inst& inst : block->Instructions()) { | 604 | for (IR::Inst& inst : block->Instructions()) { |
| 604 | ConstantPropagation(*block, inst); | 605 | ConstantPropagation(*block, inst); |
| 605 | } | 606 | } |
diff --git a/src/shader_recompiler/ir_opt/dead_code_elimination_pass.cpp b/src/shader_recompiler/ir_opt/dead_code_elimination_pass.cpp index 1e4a3fdae..400836301 100644 --- a/src/shader_recompiler/ir_opt/dead_code_elimination_pass.cpp +++ b/src/shader_recompiler/ir_opt/dead_code_elimination_pass.cpp | |||
| @@ -2,8 +2,6 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <ranges> | ||
| 6 | |||
| 7 | #include "shader_recompiler/frontend/ir/basic_block.h" | 5 | #include "shader_recompiler/frontend/ir/basic_block.h" |
| 8 | #include "shader_recompiler/frontend/ir/value.h" | 6 | #include "shader_recompiler/frontend/ir/value.h" |
| 9 | #include "shader_recompiler/ir_opt/passes.h" | 7 | #include "shader_recompiler/ir_opt/passes.h" |
diff --git a/src/shader_recompiler/ir_opt/dual_vertex_pass.cpp b/src/shader_recompiler/ir_opt/dual_vertex_pass.cpp index 3d2c205c2..055ba9c54 100644 --- a/src/shader_recompiler/ir_opt/dual_vertex_pass.cpp +++ b/src/shader_recompiler/ir_opt/dual_vertex_pass.cpp | |||
| @@ -2,12 +2,6 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <algorithm> | ||
| 6 | #include <ranges> | ||
| 7 | |||
| 8 | #include "common/bit_cast.h" | ||
| 9 | #include "common/bit_util.h" | ||
| 10 | #include "shader_recompiler/exception.h" | ||
| 11 | #include "shader_recompiler/frontend/ir/ir_emitter.h" | 5 | #include "shader_recompiler/frontend/ir/ir_emitter.h" |
| 12 | #include "shader_recompiler/ir_opt/passes.h" | 6 | #include "shader_recompiler/ir_opt/passes.h" |
| 13 | 7 | ||
diff --git a/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp b/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp index f9de17b25..4197b0095 100644 --- a/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp +++ b/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp | |||
| @@ -5,7 +5,6 @@ | |||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <compare> | 6 | #include <compare> |
| 7 | #include <optional> | 7 | #include <optional> |
| 8 | #include <ranges> | ||
| 9 | #include <queue> | 8 | #include <queue> |
| 10 | 9 | ||
| 11 | #include <boost/container/flat_set.hpp> | 10 | #include <boost/container/flat_set.hpp> |
diff --git a/src/shader_recompiler/ir_opt/lower_int64_to_int32.cpp b/src/shader_recompiler/ir_opt/lower_int64_to_int32.cpp index abf7c87c7..e80d3d1d9 100644 --- a/src/shader_recompiler/ir_opt/lower_int64_to_int32.cpp +++ b/src/shader_recompiler/ir_opt/lower_int64_to_int32.cpp | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <ranges> | ||
| 6 | #include <utility> | 5 | #include <utility> |
| 7 | 6 | ||
| 8 | #include "shader_recompiler/exception.h" | 7 | #include "shader_recompiler/exception.h" |
| @@ -207,7 +206,9 @@ void Lower(IR::Block& block, IR::Inst& inst) { | |||
| 207 | } // Anonymous namespace | 206 | } // Anonymous namespace |
| 208 | 207 | ||
| 209 | void LowerInt64ToInt32(IR::Program& program) { | 208 | void LowerInt64ToInt32(IR::Program& program) { |
| 210 | for (IR::Block* const block : program.post_order_blocks | std::views::reverse) { | 209 | const auto end{program.post_order_blocks.rend()}; |
| 210 | for (auto it = program.post_order_blocks.rbegin(); it != end; ++it) { | ||
| 211 | IR::Block* const block{*it}; | ||
| 211 | for (IR::Inst& inst : block->Instructions()) { | 212 | for (IR::Inst& inst : block->Instructions()) { |
| 212 | Lower(*block, inst); | 213 | Lower(*block, inst); |
| 213 | } | 214 | } |
diff --git a/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp b/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp index dcaced83f..53145fb5e 100644 --- a/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp +++ b/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp | |||
| @@ -14,7 +14,6 @@ | |||
| 14 | // https://link.springer.com/chapter/10.1007/978-3-642-37051-9_6 | 14 | // https://link.springer.com/chapter/10.1007/978-3-642-37051-9_6 |
| 15 | // | 15 | // |
| 16 | 16 | ||
| 17 | #include <ranges> | ||
| 18 | #include <span> | 17 | #include <span> |
| 19 | #include <variant> | 18 | #include <variant> |
| 20 | #include <vector> | 19 | #include <vector> |
| @@ -243,7 +242,9 @@ public: | |||
| 243 | void SealBlock(IR::Block* block) { | 242 | void SealBlock(IR::Block* block) { |
| 244 | const auto it{incomplete_phis.find(block)}; | 243 | const auto it{incomplete_phis.find(block)}; |
| 245 | if (it != incomplete_phis.end()) { | 244 | if (it != incomplete_phis.end()) { |
| 246 | for (auto& [variant, phi] : it->second) { | 245 | for (auto& pair : it->second) { |
| 246 | auto& variant{pair.first}; | ||
| 247 | auto& phi{pair.second}; | ||
| 247 | std::visit([&](auto& variable) { AddPhiOperands(variable, *phi, block); }, variant); | 248 | std::visit([&](auto& variable) { AddPhiOperands(variable, *phi, block); }, variant); |
| 248 | } | 249 | } |
| 249 | } | 250 | } |
| @@ -373,8 +374,9 @@ void VisitBlock(Pass& pass, IR::Block* block) { | |||
| 373 | 374 | ||
| 374 | void SsaRewritePass(IR::Program& program) { | 375 | void SsaRewritePass(IR::Program& program) { |
| 375 | Pass pass; | 376 | Pass pass; |
| 376 | for (IR::Block* const block : program.post_order_blocks | std::views::reverse) { | 377 | const auto end{program.post_order_blocks.rend()}; |
| 377 | VisitBlock(pass, block); | 378 | for (auto block = program.post_order_blocks.rbegin(); block != end; ++block) { |
| 379 | VisitBlock(pass, *block); | ||
| 378 | } | 380 | } |
| 379 | } | 381 | } |
| 380 | 382 | ||