mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-01 15:02:40 +00:00
clang-format
This commit is contained in:
parent
0f6912cf18
commit
068573e9d6
@ -5,20 +5,34 @@
|
||||
|
||||
namespace Shader::IR {
|
||||
|
||||
std::string DumpASLNode(const AbstractSyntaxNode& node, const std::map<const Block*, size_t>& block_to_index, const std::map<const Inst*, size_t>& inst_to_index) {
|
||||
std::string DumpASLNode(const AbstractSyntaxNode& node,
|
||||
const std::map<const Block*, size_t>& block_to_index,
|
||||
const std::map<const Inst*, size_t>& inst_to_index) {
|
||||
switch (node.type) {
|
||||
case AbstractSyntaxNode::Type::Block:
|
||||
return fmt::format("Block: ${}", block_to_index.at(node.data.block));
|
||||
case AbstractSyntaxNode::Type::If:
|
||||
return fmt::format("If: cond = %{}, body = ${}, merge = ${}", inst_to_index.at(node.data.if_node.cond.Inst()), block_to_index.at(node.data.if_node.body), block_to_index.at(node.data.if_node.merge));
|
||||
return fmt::format("If: cond = %{}, body = ${}, merge = ${}",
|
||||
inst_to_index.at(node.data.if_node.cond.Inst()),
|
||||
block_to_index.at(node.data.if_node.body),
|
||||
block_to_index.at(node.data.if_node.merge));
|
||||
case AbstractSyntaxNode::Type::EndIf:
|
||||
return fmt::format("EndIf: merge = ${}", block_to_index.at(node.data.end_if.merge));
|
||||
case AbstractSyntaxNode::Type::Loop:
|
||||
return fmt::format("Loop: body = ${}, continue = ${}, merge = ${}", block_to_index.at(node.data.loop.body), block_to_index.at(node.data.loop.continue_block), block_to_index.at(node.data.loop.merge));
|
||||
return fmt::format("Loop: body = ${}, continue = ${}, merge = ${}",
|
||||
block_to_index.at(node.data.loop.body),
|
||||
block_to_index.at(node.data.loop.continue_block),
|
||||
block_to_index.at(node.data.loop.merge));
|
||||
case AbstractSyntaxNode::Type::Repeat:
|
||||
return fmt::format("Repeat: cond = %{}, header = ${}, merge = ${}", inst_to_index.at(node.data.repeat.cond.Inst()), block_to_index.at(node.data.repeat.loop_header), block_to_index.at(node.data.repeat.merge));
|
||||
return fmt::format("Repeat: cond = %{}, header = ${}, merge = ${}",
|
||||
inst_to_index.at(node.data.repeat.cond.Inst()),
|
||||
block_to_index.at(node.data.repeat.loop_header),
|
||||
block_to_index.at(node.data.repeat.merge));
|
||||
case AbstractSyntaxNode::Type::Break:
|
||||
return fmt::format("Break: cond = %{}, merge = ${}, skip = ${}", inst_to_index.at(node.data.break_node.cond.Inst()), block_to_index.at(node.data.break_node.merge), block_to_index.at(node.data.break_node.skip));
|
||||
return fmt::format("Break: cond = %{}, merge = ${}, skip = ${}",
|
||||
inst_to_index.at(node.data.break_node.cond.Inst()),
|
||||
block_to_index.at(node.data.break_node.merge),
|
||||
block_to_index.at(node.data.break_node.skip));
|
||||
case AbstractSyntaxNode::Type::Return:
|
||||
return "Return";
|
||||
case AbstractSyntaxNode::Type::Unreachable:
|
||||
|
@ -3,8 +3,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include "shader_recompiler/ir/value.h"
|
||||
|
||||
namespace Shader::IR {
|
||||
@ -54,6 +54,8 @@ struct AbstractSyntaxNode {
|
||||
};
|
||||
using AbstractSyntaxList = std::vector<AbstractSyntaxNode>;
|
||||
|
||||
std::string DumpASLNode(const AbstractSyntaxNode& node, const std::map<const Block*, size_t>& block_to_index, const std::map<const Inst*, size_t>& inst_to_index);
|
||||
std::string DumpASLNode(const AbstractSyntaxNode& node,
|
||||
const std::map<const Block*, size_t>& block_to_index,
|
||||
const std::map<const Inst*, size_t>& inst_to_index);
|
||||
|
||||
} // namespace Shader::IR
|
||||
|
@ -1,8 +1,8 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "shader_recompiler/ir/conditional_tree.h"
|
||||
#include "shader_recompiler/ir/basic_block.h"
|
||||
#include "shader_recompiler/ir/conditional_tree.h"
|
||||
|
||||
#include <span>
|
||||
|
||||
@ -12,13 +12,14 @@
|
||||
|
||||
namespace Shader::IR {
|
||||
|
||||
static void AddConditionalTree(std::span<AbstractSyntaxNode> asl_span, Block::ConditionalData* parent) {
|
||||
const auto get_span = [&asl_span](AbstractSyntaxNode& node, Block* merge_block) -> std::span<AbstractSyntaxNode> {
|
||||
static void AddConditionalTree(std::span<AbstractSyntaxNode> asl_span,
|
||||
Block::ConditionalData* parent) {
|
||||
const auto get_span = [&asl_span](AbstractSyntaxNode& node,
|
||||
Block* merge_block) -> std::span<AbstractSyntaxNode> {
|
||||
auto it = std::find_if(asl_span.begin(), asl_span.end(),
|
||||
[&node, &merge_block](const AbstractSyntaxNode& n) {
|
||||
return n.data.block == merge_block;
|
||||
}
|
||||
);
|
||||
[&node, &merge_block](const AbstractSyntaxNode& n) {
|
||||
return n.data.block == merge_block;
|
||||
});
|
||||
ASSERT(it != asl_span.end());
|
||||
std::ptrdiff_t merge_index = std::distance(asl_span.begin(), it);
|
||||
return std::span<AbstractSyntaxNode>(&node + 1, asl_span.data() + merge_index);
|
||||
@ -26,7 +27,8 @@ static void AddConditionalTree(std::span<AbstractSyntaxNode> asl_span, Block::Co
|
||||
const Block::ConditionalData* copied_parent = nullptr;
|
||||
for (auto it = asl_span.begin(); it < asl_span.end(); ++it) {
|
||||
AbstractSyntaxNode& node = *it;
|
||||
if (node.type == AbstractSyntaxNode::Type::If || node.type == AbstractSyntaxNode::Type::Loop) {
|
||||
if (node.type == AbstractSyntaxNode::Type::If ||
|
||||
node.type == AbstractSyntaxNode::Type::Loop) {
|
||||
ASSERT(copied_parent);
|
||||
Block* merge_block;
|
||||
switch (node.type) {
|
||||
|
@ -44,7 +44,8 @@ void DumpProgram(const Program& program, const Info& info) {
|
||||
}
|
||||
|
||||
const auto asl_filename = fmt::format("{}_{:#018x}.asl.txt", info.stage, info.pgm_hash);
|
||||
const auto asl_file = IOFile{dump_dir / asl_filename, FileAccessMode::Write, FileType::TextFile};
|
||||
const auto asl_file =
|
||||
IOFile{dump_dir / asl_filename, FileAccessMode::Write, FileType::TextFile};
|
||||
|
||||
for (const auto& node : program.syntax_list) {
|
||||
std::string s = IR::DumpASLNode(node, block_to_index, inst_to_index) + '\n';
|
||||
|
@ -4,12 +4,13 @@
|
||||
#include <algorithm>
|
||||
#include <boost/container/flat_set.hpp>
|
||||
#include "shader_recompiler/ir/conditional_tree.h"
|
||||
#include "shader_recompiler/ir/subprogram.h"
|
||||
#include "shader_recompiler/ir/post_order.h"
|
||||
#include "shader_recompiler/ir/subprogram.h"
|
||||
|
||||
namespace Shader::IR {
|
||||
|
||||
SubProgram::SubProgram(Program* super_program, Pools& pools) : super_program(super_program), pools(pools) {}
|
||||
SubProgram::SubProgram(Program* super_program, Pools& pools)
|
||||
: super_program(super_program), pools(pools) {}
|
||||
|
||||
Block* SubProgram::AddBlock(Block* orig_block) {
|
||||
auto it = orig_block_to_block.find(orig_block);
|
||||
@ -80,7 +81,9 @@ void SubProgram::AddPhi(Inst* orig_phi, Inst* phi) {
|
||||
const Value& arg1 = orig_phi->Arg(1);
|
||||
AddPhiOperand(phi, block0, arg0);
|
||||
AddPhiOperand(phi, block1, arg1);
|
||||
const auto get_conds = [orig_block0, orig_block1]() -> std::pair<const Block::ConditionalData&, const Block::ConditionalData&> {
|
||||
const auto get_conds =
|
||||
[orig_block0,
|
||||
orig_block1]() -> std::pair<const Block::ConditionalData&, const Block::ConditionalData&> {
|
||||
const Block::ConditionalData& cond0 = orig_block0->CondData();
|
||||
const Block::ConditionalData& cond1 = orig_block1->CondData();
|
||||
if (cond0.depth > cond1.depth) {
|
||||
|
@ -4,9 +4,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <boost/container/flat_map.hpp>
|
||||
#include "shader_recompiler/pools.h"
|
||||
#include "shader_recompiler/ir/basic_block.h"
|
||||
#include "shader_recompiler/ir/program.h"
|
||||
#include "shader_recompiler/pools.h"
|
||||
|
||||
namespace Shader::IR {
|
||||
|
||||
@ -20,6 +20,7 @@ struct SubProgram {
|
||||
Inst* GetInst(Inst* orig_inst);
|
||||
|
||||
Program GetSubProgram();
|
||||
|
||||
private:
|
||||
void AddPhi(Inst* orig_phi, Inst* phi);
|
||||
|
||||
|
@ -2,9 +2,9 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "shader_recompiler/frontend/control_flow_graph.h"
|
||||
#include "shader_recompiler/ir/conditional_tree.h"
|
||||
#include "shader_recompiler/frontend/decode.h"
|
||||
#include "shader_recompiler/frontend/structured_control_flow.h"
|
||||
#include "shader_recompiler/ir/conditional_tree.h"
|
||||
#include "shader_recompiler/ir/passes/ir_passes.h"
|
||||
#include "shader_recompiler/ir/post_order.h"
|
||||
#include "shader_recompiler/recompiler.h"
|
||||
@ -59,7 +59,7 @@ IR::Program TranslateProgram(std::span<const u32> code, Pools& pools, Info& info
|
||||
program.info, runtime_info, profile);
|
||||
program.blocks = GenerateBlocks(program.syntax_list);
|
||||
program.post_order_blocks = Shader::IR::PostOrder(program.syntax_list.front());
|
||||
|
||||
|
||||
Shader::IR::AddConditionalTreeFromASL(program.syntax_list);
|
||||
|
||||
// Run optimization passes
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shader_recompiler/pools.h"
|
||||
#include "shader_recompiler/ir/basic_block.h"
|
||||
#include "shader_recompiler/ir/program.h"
|
||||
#include "shader_recompiler/pools.h"
|
||||
|
||||
namespace Shader {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user