summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/frontend
diff options
context:
space:
mode:
authorGravatar lat9nq2021-05-16 17:06:13 -0400
committerGravatar ameerj2021-07-22 21:51:31 -0400
commitf7a2340205b4fa2db32403f20d7b7afe32b15f33 (patch)
tree22059632c5f3bf068e686997d833368f6c22f6ec /src/shader_recompiler/frontend
parentglasm: Implement rest of shared mem (diff)
downloadyuzu-f7a2340205b4fa2db32403f20d7b7afe32b15f33.tar.gz
yuzu-f7a2340205b4fa2db32403f20d7b7afe32b15f33.tar.xz
yuzu-f7a2340205b4fa2db32403f20d7b7afe32b15f33.zip
shader_recompiler: GCC fixes
Fixes members of unnamed union not being accessible, and one function without a declaration.
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 {
13class Block; 13class Block;
14 14
15struct AbstractSyntaxNode { 15struct AbstractSyntaxNode {
16 struct NonTrivialDummy {
17 NonTrivialDummy() {}
18 };
19
20 enum class Type { 16 enum class Type {
21 Block, 17 Block,
22 If, 18 If,
@@ -27,9 +23,7 @@ struct AbstractSyntaxNode {
27 Return, 23 Return,
28 Unreachable, 24 Unreachable,
29 }; 25 };
30 Type type{}; 26 union Data {
31 union {
32 NonTrivialDummy dummy{};
33 Block* block; 27 Block* block;
34 struct { 28 struct {
35 U1 cond; 29 U1 cond;
@@ -55,6 +49,9 @@ struct AbstractSyntaxNode {
55 Block* skip; 49 Block* skip;
56 } break_node; 50 } break_node;
57 }; 51 };
52
53 Data data{};
54 Type type{};
58}; 55};
59using AbstractSyntaxList = std::vector<AbstractSyntaxNode>; 56using AbstractSyntaxList = std::vector<AbstractSyntaxNode>;
60 57
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) {
20 if (root.type != AbstractSyntaxNode::Type::Block) { 20 if (root.type != AbstractSyntaxNode::Type::Block) {
21 throw LogicError("First node in abstract syntax list root is not a block"); 21 throw LogicError("First node in abstract syntax list root is not a block");
22 } 22 }
23 Block* const first_block{root.block}; 23 Block* const first_block{root.data.block};
24 visited.insert(first_block); 24 visited.insert(first_block);
25 block_stack.push_back(first_block); 25 block_stack.push_back(first_block);
26 26
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) {
22 })}; 22 })};
23 IR::BlockList blocks(std::ranges::distance(syntax_blocks)); 23 IR::BlockList blocks(std::ranges::distance(syntax_blocks));
24 std::ranges::transform(syntax_blocks, blocks.begin(), 24 std::ranges::transform(syntax_blocks, blocks.begin(),
25 [](const IR::AbstractSyntaxNode& node) { return node.block; }); 25 [](const IR::AbstractSyntaxNode& node) { return node.data.block; });
26 return blocks; 26 return blocks;
27} 27}
28 28
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:
655 syntax_list{syntax_list_} { 655 syntax_list{syntax_list_} {
656 Visit(root_stmt, nullptr, nullptr); 656 Visit(root_stmt, nullptr, nullptr);
657 657
658 IR::Block& first_block{*syntax_list.front().block}; 658 IR::Block& first_block{*syntax_list.front().data.block};
659 IR::IREmitter ir{first_block, first_block.begin()}; 659 IR::IREmitter ir = IR::IREmitter(first_block, first_block.begin());
660 ir.Prologue(); 660 ir.Prologue();
661 } 661 }
662 662
@@ -670,7 +670,7 @@ private:
670 current_block = block_pool.Create(inst_pool); 670 current_block = block_pool.Create(inst_pool);
671 auto& node{syntax_list.emplace_back()}; 671 auto& node{syntax_list.emplace_back()};
672 node.type = IR::AbstractSyntaxNode::Type::Block; 672 node.type = IR::AbstractSyntaxNode::Type::Block;
673 node.block = current_block; 673 node.data.block = current_block;
674 }}; 674 }};
675 Tree& tree{parent.children}; 675 Tree& tree{parent.children};
676 for (auto it = tree.begin(); it != tree.end(); ++it) { 676 for (auto it = tree.begin(); it != tree.end(); ++it) {
@@ -713,24 +713,24 @@ private:
713 const size_t then_block_index{syntax_list.size()}; 713 const size_t then_block_index{syntax_list.size()};
714 Visit(stmt, break_block, merge_block); 714 Visit(stmt, break_block, merge_block);
715 715
716 IR::Block* const then_block{syntax_list.at(then_block_index).block}; 716 IR::Block* const then_block{syntax_list.at(then_block_index).data.block};
717 current_block->AddBranch(then_block); 717 current_block->AddBranch(then_block);
718 current_block->AddBranch(merge_block); 718 current_block->AddBranch(merge_block);
719 current_block = merge_block; 719 current_block = merge_block;
720 720
721 auto& if_node{syntax_list[if_node_index]}; 721 auto& if_node{syntax_list[if_node_index]};
722 if_node.type = IR::AbstractSyntaxNode::Type::If; 722 if_node.type = IR::AbstractSyntaxNode::Type::If;
723 if_node.if_node.cond = cond; 723 if_node.data.if_node.cond = cond;
724 if_node.if_node.body = then_block; 724 if_node.data.if_node.body = then_block;
725 if_node.if_node.merge = merge_block; 725 if_node.data.if_node.merge = merge_block;
726 726
727 auto& endif_node{syntax_list.emplace_back()}; 727 auto& endif_node{syntax_list.emplace_back()};
728 endif_node.type = IR::AbstractSyntaxNode::Type::EndIf; 728 endif_node.type = IR::AbstractSyntaxNode::Type::EndIf;
729 endif_node.end_if.merge = merge_block; 729 endif_node.data.end_if.merge = merge_block;
730 730
731 auto& merge{syntax_list.emplace_back()}; 731 auto& merge{syntax_list.emplace_back()};
732 merge.type = IR::AbstractSyntaxNode::Type::Block; 732 merge.type = IR::AbstractSyntaxNode::Type::Block;
733 merge.block = merge_block; 733 merge.data.block = merge_block;
734 break; 734 break;
735 } 735 }
736 case StatementType::Loop: { 736 case StatementType::Loop: {
@@ -740,7 +740,7 @@ private:
740 } 740 }
741 auto& header_node{syntax_list.emplace_back()}; 741 auto& header_node{syntax_list.emplace_back()};
742 header_node.type = IR::AbstractSyntaxNode::Type::Block; 742 header_node.type = IR::AbstractSyntaxNode::Type::Block;
743 header_node.block = loop_header_block; 743 header_node.data.block = loop_header_block;
744 744
745 IR::Block* const continue_block{block_pool.Create(inst_pool)}; 745 IR::Block* const continue_block{block_pool.Create(inst_pool)};
746 IR::Block* const merge_block{MergeBlock(parent, stmt)}; 746 IR::Block* const merge_block{MergeBlock(parent, stmt)};
@@ -757,7 +757,7 @@ private:
757 const IR::U1 cond{VisitExpr(ir, *stmt.cond)}; 757 const IR::U1 cond{VisitExpr(ir, *stmt.cond)};
758 ir.DummyReference(cond); 758 ir.DummyReference(cond);
759 759
760 IR::Block* const body_block{syntax_list.at(body_block_index).block}; 760 IR::Block* const body_block{syntax_list.at(body_block_index).data.block};
761 loop_header_block->AddBranch(body_block); 761 loop_header_block->AddBranch(body_block);
762 762
763 continue_block->AddBranch(loop_header_block); 763 continue_block->AddBranch(loop_header_block);
@@ -767,23 +767,23 @@ private:
767 767
768 auto& loop{syntax_list[loop_node_index]}; 768 auto& loop{syntax_list[loop_node_index]};
769 loop.type = IR::AbstractSyntaxNode::Type::Loop; 769 loop.type = IR::AbstractSyntaxNode::Type::Loop;
770 loop.loop.body = body_block; 770 loop.data.loop.body = body_block;
771 loop.loop.continue_block = continue_block; 771 loop.data.loop.continue_block = continue_block;
772 loop.loop.merge = merge_block; 772 loop.data.loop.merge = merge_block;
773 773
774 auto& continue_block_node{syntax_list.emplace_back()}; 774 auto& continue_block_node{syntax_list.emplace_back()};
775 continue_block_node.type = IR::AbstractSyntaxNode::Type::Block; 775 continue_block_node.type = IR::AbstractSyntaxNode::Type::Block;
776 continue_block_node.block = continue_block; 776 continue_block_node.data.block = continue_block;
777 777
778 auto& repeat{syntax_list.emplace_back()}; 778 auto& repeat{syntax_list.emplace_back()};
779 repeat.type = IR::AbstractSyntaxNode::Type::Repeat; 779 repeat.type = IR::AbstractSyntaxNode::Type::Repeat;
780 repeat.repeat.cond = cond; 780 repeat.data.repeat.cond = cond;
781 repeat.repeat.loop_header = loop_header_block; 781 repeat.data.repeat.loop_header = loop_header_block;
782 repeat.repeat.merge = merge_block; 782 repeat.data.repeat.merge = merge_block;
783 783
784 auto& merge{syntax_list.emplace_back()}; 784 auto& merge{syntax_list.emplace_back()};
785 merge.type = IR::AbstractSyntaxNode::Type::Block; 785 merge.type = IR::AbstractSyntaxNode::Type::Block;
786 merge.block = merge_block; 786 merge.data.block = merge_block;
787 break; 787 break;
788 } 788 }
789 case StatementType::Break: { 789 case StatementType::Break: {
@@ -799,13 +799,13 @@ private:
799 799
800 auto& break_node{syntax_list.emplace_back()}; 800 auto& break_node{syntax_list.emplace_back()};
801 break_node.type = IR::AbstractSyntaxNode::Type::Break; 801 break_node.type = IR::AbstractSyntaxNode::Type::Break;
802 break_node.break_node.cond = cond; 802 break_node.data.break_node.cond = cond;
803 break_node.break_node.merge = break_block; 803 break_node.data.break_node.merge = break_block;
804 break_node.break_node.skip = skip_block; 804 break_node.data.break_node.skip = skip_block;
805 805
806 auto& merge{syntax_list.emplace_back()}; 806 auto& merge{syntax_list.emplace_back()};
807 merge.type = IR::AbstractSyntaxNode::Type::Block; 807 merge.type = IR::AbstractSyntaxNode::Type::Block;
808 merge.block = skip_block; 808 merge.data.block = skip_block;
809 break; 809 break;
810 } 810 }
811 case StatementType::Return: { 811 case StatementType::Return: {
@@ -824,7 +824,7 @@ private:
824 824
825 auto& merge{syntax_list.emplace_back()}; 825 auto& merge{syntax_list.emplace_back()};
826 merge.type = IR::AbstractSyntaxNode::Type::Block; 826 merge.type = IR::AbstractSyntaxNode::Type::Block;
827 merge.block = demote_block; 827 merge.data.block = demote_block;
828 break; 828 break;
829 } 829 }
830 case StatementType::Unreachable: { 830 case StatementType::Unreachable: {