summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler/frontend
diff options
context:
space:
mode:
authorlat9nq <22451773+lat9nq@users.noreply.github.com>2021-05-16 23:06:13 +0200
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:31 +0200
commitf7a2340205b4fa2db32403f20d7b7afe32b15f33 (patch)
tree22059632c5f3bf068e686997d833368f6c22f6ec /src/shader_recompiler/frontend
parentglasm: Implement rest of shared mem (diff)
downloadyuzu-f7a2340205b4fa2db32403f20d7b7afe32b15f33.tar
yuzu-f7a2340205b4fa2db32403f20d7b7afe32b15f33.tar.gz
yuzu-f7a2340205b4fa2db32403f20d7b7afe32b15f33.tar.bz2
yuzu-f7a2340205b4fa2db32403f20d7b7afe32b15f33.tar.lz
yuzu-f7a2340205b4fa2db32403f20d7b7afe32b15f33.tar.xz
yuzu-f7a2340205b4fa2db32403f20d7b7afe32b15f33.tar.zst
yuzu-f7a2340205b4fa2db32403f20d7b7afe32b15f33.zip
Diffstat (limited to 'src/shader_recompiler/frontend')
-rw-r--r--src/shader_recompiler/frontend/ir/abstract_syntax_list.h11
-rw-r--r--src/shader_recompiler/frontend/ir/post_order.cpp2
-rw-r--r--src/shader_recompiler/frontend/maxwell/program.cpp2
-rw-r--r--src/shader_recompiler/frontend/maxwell/structured_control_flow.cpp48
4 files changed, 30 insertions, 33 deletions
diff --git a/src/shader_recompiler/frontend/ir/abstract_syntax_list.h b/src/shader_recompiler/frontend/ir/abstract_syntax_list.h
index e9afb4d92..b61773487 100644
--- a/src/shader_recompiler/frontend/ir/abstract_syntax_list.h
+++ b/src/shader_recompiler/frontend/ir/abstract_syntax_list.h
@@ -13,10 +13,6 @@ namespace Shader::IR {
class Block;
struct AbstractSyntaxNode {
- struct NonTrivialDummy {
- NonTrivialDummy() {}
- };
-
enum class Type {
Block,
If,
@@ -27,9 +23,7 @@ struct AbstractSyntaxNode {
Return,
Unreachable,
};
- Type type{};
- union {
- NonTrivialDummy dummy{};
+ union Data {
Block* block;
struct {
U1 cond;
@@ -55,6 +49,9 @@ struct AbstractSyntaxNode {
Block* skip;
} break_node;
};
+
+ Data data{};
+ Type type{};
};
using AbstractSyntaxList = std::vector<AbstractSyntaxNode>;
diff --git a/src/shader_recompiler/frontend/ir/post_order.cpp b/src/shader_recompiler/frontend/ir/post_order.cpp
index 1a28df7fb..16bc44101 100644
--- a/src/shader_recompiler/frontend/ir/post_order.cpp
+++ b/src/shader_recompiler/frontend/ir/post_order.cpp
@@ -20,7 +20,7 @@ BlockList PostOrder(const AbstractSyntaxNode& root) {
if (root.type != AbstractSyntaxNode::Type::Block) {
throw LogicError("First node in abstract syntax list root is not a block");
}
- Block* const first_block{root.block};
+ Block* const first_block{root.data.block};
visited.insert(first_block);
block_stack.push_back(first_block);
diff --git a/src/shader_recompiler/frontend/maxwell/program.cpp b/src/shader_recompiler/frontend/maxwell/program.cpp
index 017c4b8fd..ccdab1dad 100644
--- a/src/shader_recompiler/frontend/maxwell/program.cpp
+++ b/src/shader_recompiler/frontend/maxwell/program.cpp
@@ -22,7 +22,7 @@ IR::BlockList GenerateBlocks(const IR::AbstractSyntaxList& syntax_list) {
})};
IR::BlockList blocks(std::ranges::distance(syntax_blocks));
std::ranges::transform(syntax_blocks, blocks.begin(),
- [](const IR::AbstractSyntaxNode& node) { return node.block; });
+ [](const IR::AbstractSyntaxNode& node) { return node.data.block; });
return blocks;
}
diff --git a/src/shader_recompiler/frontend/maxwell/structured_control_flow.cpp b/src/shader_recompiler/frontend/maxwell/structured_control_flow.cpp
index 836d4b8aa..83554a953 100644
--- a/src/shader_recompiler/frontend/maxwell/structured_control_flow.cpp
+++ b/src/shader_recompiler/frontend/maxwell/structured_control_flow.cpp
@@ -655,8 +655,8 @@ public:
syntax_list{syntax_list_} {
Visit(root_stmt, nullptr, nullptr);
- IR::Block& first_block{*syntax_list.front().block};
- IR::IREmitter ir{first_block, first_block.begin()};
+ IR::Block& first_block{*syntax_list.front().data.block};
+ IR::IREmitter ir = IR::IREmitter(first_block, first_block.begin());
ir.Prologue();
}
@@ -670,7 +670,7 @@ private:
current_block = block_pool.Create(inst_pool);
auto& node{syntax_list.emplace_back()};
node.type = IR::AbstractSyntaxNode::Type::Block;
- node.block = current_block;
+ node.data.block = current_block;
}};
Tree& tree{parent.children};
for (auto it = tree.begin(); it != tree.end(); ++it) {
@@ -713,24 +713,24 @@ private:
const size_t then_block_index{syntax_list.size()};
Visit(stmt, break_block, merge_block);
- IR::Block* const then_block{syntax_list.at(then_block_index).block};
+ IR::Block* const then_block{syntax_list.at(then_block_index).data.block};
current_block->AddBranch(then_block);
current_block->AddBranch(merge_block);
current_block = merge_block;
auto& if_node{syntax_list[if_node_index]};
if_node.type = IR::AbstractSyntaxNode::Type::If;
- if_node.if_node.cond = cond;
- if_node.if_node.body = then_block;
- if_node.if_node.merge = merge_block;
+ if_node.data.if_node.cond = cond;
+ if_node.data.if_node.body = then_block;
+ if_node.data.if_node.merge = merge_block;
auto& endif_node{syntax_list.emplace_back()};
endif_node.type = IR::AbstractSyntaxNode::Type::EndIf;
- endif_node.end_if.merge = merge_block;
+ endif_node.data.end_if.merge = merge_block;
auto& merge{syntax_list.emplace_back()};
merge.type = IR::AbstractSyntaxNode::Type::Block;
- merge.block = merge_block;
+ merge.data.block = merge_block;
break;
}
case StatementType::Loop: {
@@ -740,7 +740,7 @@ private:
}
auto& header_node{syntax_list.emplace_back()};
header_node.type = IR::AbstractSyntaxNode::Type::Block;
- header_node.block = loop_header_block;
+ header_node.data.block = loop_header_block;
IR::Block* const continue_block{block_pool.Create(inst_pool)};
IR::Block* const merge_block{MergeBlock(parent, stmt)};
@@ -757,7 +757,7 @@ private:
const IR::U1 cond{VisitExpr(ir, *stmt.cond)};
ir.DummyReference(cond);
- IR::Block* const body_block{syntax_list.at(body_block_index).block};
+ IR::Block* const body_block{syntax_list.at(body_block_index).data.block};
loop_header_block->AddBranch(body_block);
continue_block->AddBranch(loop_header_block);
@@ -767,23 +767,23 @@ private:
auto& loop{syntax_list[loop_node_index]};
loop.type = IR::AbstractSyntaxNode::Type::Loop;
- loop.loop.body = body_block;
- loop.loop.continue_block = continue_block;
- loop.loop.merge = merge_block;
+ loop.data.loop.body = body_block;
+ loop.data.loop.continue_block = continue_block;
+ loop.data.loop.merge = merge_block;
auto& continue_block_node{syntax_list.emplace_back()};
continue_block_node.type = IR::AbstractSyntaxNode::Type::Block;
- continue_block_node.block = continue_block;
+ continue_block_node.data.block = continue_block;
auto& repeat{syntax_list.emplace_back()};
repeat.type = IR::AbstractSyntaxNode::Type::Repeat;
- repeat.repeat.cond = cond;
- repeat.repeat.loop_header = loop_header_block;
- repeat.repeat.merge = merge_block;
+ repeat.data.repeat.cond = cond;
+ repeat.data.repeat.loop_header = loop_header_block;
+ repeat.data.repeat.merge = merge_block;
auto& merge{syntax_list.emplace_back()};
merge.type = IR::AbstractSyntaxNode::Type::Block;
- merge.block = merge_block;
+ merge.data.block = merge_block;
break;
}
case StatementType::Break: {
@@ -799,13 +799,13 @@ private:
auto& break_node{syntax_list.emplace_back()};
break_node.type = IR::AbstractSyntaxNode::Type::Break;
- break_node.break_node.cond = cond;
- break_node.break_node.merge = break_block;
- break_node.break_node.skip = skip_block;
+ break_node.data.break_node.cond = cond;
+ break_node.data.break_node.merge = break_block;
+ break_node.data.break_node.skip = skip_block;
auto& merge{syntax_list.emplace_back()};
merge.type = IR::AbstractSyntaxNode::Type::Block;
- merge.block = skip_block;
+ merge.data.block = skip_block;
break;
}
case StatementType::Return: {
@@ -824,7 +824,7 @@ private:
auto& merge{syntax_list.emplace_back()};
merge.type = IR::AbstractSyntaxNode::Type::Block;
- merge.block = demote_block;
+ merge.data.block = demote_block;
break;
}
case StatementType::Unreachable: {