mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-27 10:34:19 +01:00
shader: Avoid usage of C++20 ranges to build in clang
This commit is contained in:
parent
94af0a00f6
commit
bf2956d77a
@ -2,7 +2,7 @@
|
|||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include <ranges>
|
#include <algorithm>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
@ -196,7 +196,10 @@ void PrecolorInst(IR::Inst& phi) {
|
|||||||
|
|
||||||
void Precolor(const IR::Program& program) {
|
void Precolor(const IR::Program& program) {
|
||||||
for (IR::Block* const block : program.blocks) {
|
for (IR::Block* const block : program.blocks) {
|
||||||
for (IR::Inst& phi : block->Instructions() | std::views::take_while(IR::IsPhi)) {
|
for (IR::Inst& phi : block->Instructions()) {
|
||||||
|
if (!IR::IsPhi(phi)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
PrecolorInst(phi);
|
PrecolorInst(phi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,10 @@
|
|||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include <ranges>
|
#include <algorithm>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <tuple>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
#include "common/div_ceil.h"
|
#include "common/div_ceil.h"
|
||||||
#include "common/settings.h"
|
#include "common/settings.h"
|
||||||
@ -120,7 +122,10 @@ void PrecolorInst(IR::Inst& phi) {
|
|||||||
|
|
||||||
void Precolor(const IR::Program& program) {
|
void Precolor(const IR::Program& program) {
|
||||||
for (IR::Block* const block : program.blocks) {
|
for (IR::Block* const block : program.blocks) {
|
||||||
for (IR::Inst& phi : block->Instructions() | std::views::take_while(IR::IsPhi)) {
|
for (IR::Inst& phi : block->Instructions()) {
|
||||||
|
if (!IR::IsPhi(phi)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
PrecolorInst(phi);
|
PrecolorInst(phi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <ranges>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
@ -151,18 +150,18 @@ std::pair<Location, Stack> Stack::Pop(Token token) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::optional<Location> Stack::Peek(Token token) const {
|
std::optional<Location> Stack::Peek(Token token) const {
|
||||||
const auto reverse_entries{entries | std::views::reverse};
|
const auto it{std::find_if(entries.rbegin(), entries.rend(),
|
||||||
const auto it{std::ranges::find(reverse_entries, token, &StackEntry::token)};
|
[token](const auto& entry) { return entry.token == token; })};
|
||||||
if (it == reverse_entries.end()) {
|
if (it == entries.rend()) {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
return it->target;
|
return it->target;
|
||||||
}
|
}
|
||||||
|
|
||||||
Stack Stack::Remove(Token token) const {
|
Stack Stack::Remove(Token token) const {
|
||||||
const auto reverse_entries{entries | std::views::reverse};
|
const auto it{std::find_if(entries.rbegin(), entries.rend(),
|
||||||
const auto it{std::ranges::find(reverse_entries, token, &StackEntry::token)};
|
[token](const auto& entry) { return entry.token == token; })};
|
||||||
const auto pos{std::distance(reverse_entries.begin(), it)};
|
const auto pos{std::distance(entries.rbegin(), it)};
|
||||||
Stack result;
|
Stack result;
|
||||||
result.entries.insert(result.entries.end(), entries.begin(), entries.end() - pos - 1);
|
result.entries.insert(result.entries.end(), entries.begin(), entries.end() - pos - 1);
|
||||||
return result;
|
return result;
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <ranges>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@ -167,7 +166,7 @@ std::string DumpExpr(const Statement* stmt) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DumpTree(const Tree& tree, u32 indentation = 0) {
|
[[maybe_unused]] std::string DumpTree(const Tree& tree, u32 indentation = 0) {
|
||||||
std::string ret;
|
std::string ret;
|
||||||
std::string indent(indentation, ' ');
|
std::string indent(indentation, ' ');
|
||||||
for (auto stmt = tree.begin(); stmt != tree.end(); ++stmt) {
|
for (auto stmt = tree.begin(); stmt != tree.end(); ++stmt) {
|
||||||
@ -315,8 +314,9 @@ class GotoPass {
|
|||||||
public:
|
public:
|
||||||
explicit GotoPass(Flow::CFG& cfg, ObjectPool<Statement>& stmt_pool) : pool{stmt_pool} {
|
explicit GotoPass(Flow::CFG& cfg, ObjectPool<Statement>& stmt_pool) : pool{stmt_pool} {
|
||||||
std::vector gotos{BuildTree(cfg)};
|
std::vector gotos{BuildTree(cfg)};
|
||||||
for (const Node& goto_stmt : gotos | std::views::reverse) {
|
const auto end{gotos.rend()};
|
||||||
RemoveGoto(goto_stmt);
|
for (auto goto_stmt = gotos.rbegin(); goto_stmt != end; ++goto_stmt) {
|
||||||
|
RemoveGoto(*goto_stmt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <ranges>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "common/settings.h"
|
#include "common/settings.h"
|
||||||
@ -20,12 +19,19 @@
|
|||||||
namespace Shader::Maxwell {
|
namespace Shader::Maxwell {
|
||||||
namespace {
|
namespace {
|
||||||
IR::BlockList GenerateBlocks(const IR::AbstractSyntaxList& syntax_list) {
|
IR::BlockList GenerateBlocks(const IR::AbstractSyntaxList& syntax_list) {
|
||||||
auto syntax_blocks{syntax_list | std::views::filter([](const auto& node) {
|
size_t num_syntax_blocks{};
|
||||||
return node.type == IR::AbstractSyntaxNode::Type::Block;
|
for (const auto& node : syntax_list) {
|
||||||
})};
|
if (node.type == IR::AbstractSyntaxNode::Type::Block) {
|
||||||
IR::BlockList blocks(std::ranges::distance(syntax_blocks));
|
++num_syntax_blocks;
|
||||||
std::ranges::transform(syntax_blocks, blocks.begin(),
|
}
|
||||||
[](const IR::AbstractSyntaxNode& node) { return node.data.block; });
|
}
|
||||||
|
IR::BlockList blocks;
|
||||||
|
blocks.reserve(num_syntax_blocks);
|
||||||
|
for (const auto& node : syntax_list) {
|
||||||
|
if (node.type == IR::AbstractSyntaxNode::Type::Block) {
|
||||||
|
blocks.push_back(node.data.block);
|
||||||
|
}
|
||||||
|
}
|
||||||
return blocks;
|
return blocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <ranges>
|
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
@ -599,7 +598,9 @@ void ConstantPropagation(IR::Block& block, IR::Inst& inst) {
|
|||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
||||||
void ConstantPropagationPass(IR::Program& program) {
|
void ConstantPropagationPass(IR::Program& program) {
|
||||||
for (IR::Block* const block : program.post_order_blocks | std::views::reverse) {
|
const auto end{program.post_order_blocks.rend()};
|
||||||
|
for (auto it = program.post_order_blocks.rbegin(); it != end; ++it) {
|
||||||
|
IR::Block* const block{*it};
|
||||||
for (IR::Inst& inst : block->Instructions()) {
|
for (IR::Inst& inst : block->Instructions()) {
|
||||||
ConstantPropagation(*block, inst);
|
ConstantPropagation(*block, inst);
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include <ranges>
|
|
||||||
|
|
||||||
#include "shader_recompiler/frontend/ir/basic_block.h"
|
#include "shader_recompiler/frontend/ir/basic_block.h"
|
||||||
#include "shader_recompiler/frontend/ir/value.h"
|
#include "shader_recompiler/frontend/ir/value.h"
|
||||||
#include "shader_recompiler/ir_opt/passes.h"
|
#include "shader_recompiler/ir_opt/passes.h"
|
||||||
|
@ -2,12 +2,6 @@
|
|||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <ranges>
|
|
||||||
|
|
||||||
#include "common/bit_cast.h"
|
|
||||||
#include "common/bit_util.h"
|
|
||||||
#include "shader_recompiler/exception.h"
|
|
||||||
#include "shader_recompiler/frontend/ir/ir_emitter.h"
|
#include "shader_recompiler/frontend/ir/ir_emitter.h"
|
||||||
#include "shader_recompiler/ir_opt/passes.h"
|
#include "shader_recompiler/ir_opt/passes.h"
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <compare>
|
#include <compare>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <ranges>
|
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
|
||||||
#include <boost/container/flat_set.hpp>
|
#include <boost/container/flat_set.hpp>
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include <ranges>
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "shader_recompiler/exception.h"
|
#include "shader_recompiler/exception.h"
|
||||||
@ -207,7 +206,9 @@ void Lower(IR::Block& block, IR::Inst& inst) {
|
|||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
||||||
void LowerInt64ToInt32(IR::Program& program) {
|
void LowerInt64ToInt32(IR::Program& program) {
|
||||||
for (IR::Block* const block : program.post_order_blocks | std::views::reverse) {
|
const auto end{program.post_order_blocks.rend()};
|
||||||
|
for (auto it = program.post_order_blocks.rbegin(); it != end; ++it) {
|
||||||
|
IR::Block* const block{*it};
|
||||||
for (IR::Inst& inst : block->Instructions()) {
|
for (IR::Inst& inst : block->Instructions()) {
|
||||||
Lower(*block, inst);
|
Lower(*block, inst);
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
// https://link.springer.com/chapter/10.1007/978-3-642-37051-9_6
|
// https://link.springer.com/chapter/10.1007/978-3-642-37051-9_6
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <ranges>
|
|
||||||
#include <span>
|
#include <span>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -243,7 +242,9 @@ public:
|
|||||||
void SealBlock(IR::Block* block) {
|
void SealBlock(IR::Block* block) {
|
||||||
const auto it{incomplete_phis.find(block)};
|
const auto it{incomplete_phis.find(block)};
|
||||||
if (it != incomplete_phis.end()) {
|
if (it != incomplete_phis.end()) {
|
||||||
for (auto& [variant, phi] : it->second) {
|
for (auto& pair : it->second) {
|
||||||
|
auto& variant{pair.first};
|
||||||
|
auto& phi{pair.second};
|
||||||
std::visit([&](auto& variable) { AddPhiOperands(variable, *phi, block); }, variant);
|
std::visit([&](auto& variable) { AddPhiOperands(variable, *phi, block); }, variant);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -373,8 +374,9 @@ void VisitBlock(Pass& pass, IR::Block* block) {
|
|||||||
|
|
||||||
void SsaRewritePass(IR::Program& program) {
|
void SsaRewritePass(IR::Program& program) {
|
||||||
Pass pass;
|
Pass pass;
|
||||||
for (IR::Block* const block : program.post_order_blocks | std::views::reverse) {
|
const auto end{program.post_order_blocks.rend()};
|
||||||
VisitBlock(pass, block);
|
for (auto block = program.post_order_blocks.rbegin(); block != end; ++block) {
|
||||||
|
VisitBlock(pass, *block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user