mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-12-29 18:15:33 +00:00
shader_recompiler: GCC fixes
Fixes members of unnamed union not being accessible, and one function without a declaration.
This commit is contained in:
parent
d4f9c798d6
commit
f7a2340205
|
@ -212,14 +212,14 @@ void EmitCode(EmitContext& ctx, const IR::Program& program) {
|
|||
for (const IR::AbstractSyntaxNode& node : program.syntax_list) {
|
||||
switch (node.type) {
|
||||
case IR::AbstractSyntaxNode::Type::Block:
|
||||
for (IR::Inst& inst : node.block->Instructions()) {
|
||||
for (IR::Inst& inst : node.data.block->Instructions()) {
|
||||
EmitInst(ctx, &inst);
|
||||
}
|
||||
break;
|
||||
case IR::AbstractSyntaxNode::Type::If:
|
||||
ctx.Add("MOV.S.CC RC,{};"
|
||||
"IF NE.x;",
|
||||
eval(node.if_node.cond));
|
||||
eval(node.data.if_node.cond));
|
||||
break;
|
||||
case IR::AbstractSyntaxNode::Type::EndIf:
|
||||
ctx.Add("ENDIF;");
|
||||
|
@ -228,8 +228,8 @@ void EmitCode(EmitContext& ctx, const IR::Program& program) {
|
|||
ctx.Add("REP;");
|
||||
break;
|
||||
case IR::AbstractSyntaxNode::Type::Repeat:
|
||||
if (node.repeat.cond.IsImmediate()) {
|
||||
if (node.repeat.cond.U1()) {
|
||||
if (node.data.repeat.cond.IsImmediate()) {
|
||||
if (node.data.repeat.cond.U1()) {
|
||||
ctx.Add("ENDREP;");
|
||||
} else {
|
||||
ctx.Add("BRK;"
|
||||
|
@ -239,18 +239,18 @@ void EmitCode(EmitContext& ctx, const IR::Program& program) {
|
|||
ctx.Add("MOV.S.CC RC,{};"
|
||||
"BRK (EQ.x);"
|
||||
"ENDREP;",
|
||||
eval(node.repeat.cond));
|
||||
eval(node.data.repeat.cond));
|
||||
}
|
||||
break;
|
||||
case IR::AbstractSyntaxNode::Type::Break:
|
||||
if (node.break_node.cond.IsImmediate()) {
|
||||
if (node.break_node.cond.U1()) {
|
||||
if (node.data.break_node.cond.IsImmediate()) {
|
||||
if (node.data.break_node.cond.U1()) {
|
||||
ctx.Add("BRK;");
|
||||
}
|
||||
} else {
|
||||
ctx.Add("MOV.S.CC RC,{};"
|
||||
"BRK (NE.x);",
|
||||
eval(node.break_node.cond));
|
||||
eval(node.data.break_node.cond));
|
||||
}
|
||||
break;
|
||||
case IR::AbstractSyntaxNode::Type::Return:
|
||||
|
|
|
@ -105,7 +105,7 @@ void EmitBoundImageWrite(EmitContext&) {
|
|||
throw LogicError("Unreachable instruction");
|
||||
}
|
||||
|
||||
std::string Texture([[maybe_unused]] EmitContext& ctx, IR::TextureInstInfo info,
|
||||
static std::string Texture([[maybe_unused]] EmitContext& ctx, IR::TextureInstInfo info,
|
||||
[[maybe_unused]] const IR::Value& index) {
|
||||
// FIXME
|
||||
return fmt::format("texture[{}]", info.descriptor_index);
|
||||
|
|
|
@ -112,48 +112,48 @@ void Traverse(EmitContext& ctx, IR::Program& program) {
|
|||
for (const IR::AbstractSyntaxNode& node : program.syntax_list) {
|
||||
switch (node.type) {
|
||||
case IR::AbstractSyntaxNode::Type::Block: {
|
||||
const Id label{node.block->Definition<Id>()};
|
||||
const Id label{node.data.block->Definition<Id>()};
|
||||
if (current_block) {
|
||||
ctx.OpBranch(label);
|
||||
}
|
||||
current_block = node.block;
|
||||
current_block = node.data.block;
|
||||
ctx.AddLabel(label);
|
||||
for (IR::Inst& inst : node.block->Instructions()) {
|
||||
for (IR::Inst& inst : node.data.block->Instructions()) {
|
||||
EmitInst(ctx, &inst);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IR::AbstractSyntaxNode::Type::If: {
|
||||
const Id if_label{node.if_node.body->Definition<Id>()};
|
||||
const Id endif_label{node.if_node.merge->Definition<Id>()};
|
||||
const Id if_label{node.data.if_node.body->Definition<Id>()};
|
||||
const Id endif_label{node.data.if_node.merge->Definition<Id>()};
|
||||
ctx.OpSelectionMerge(endif_label, spv::SelectionControlMask::MaskNone);
|
||||
ctx.OpBranchConditional(ctx.Def(node.if_node.cond), if_label, endif_label);
|
||||
ctx.OpBranchConditional(ctx.Def(node.data.if_node.cond), if_label, endif_label);
|
||||
break;
|
||||
}
|
||||
case IR::AbstractSyntaxNode::Type::Loop: {
|
||||
const Id body_label{node.loop.body->Definition<Id>()};
|
||||
const Id continue_label{node.loop.continue_block->Definition<Id>()};
|
||||
const Id endloop_label{node.loop.merge->Definition<Id>()};
|
||||
const Id body_label{node.data.loop.body->Definition<Id>()};
|
||||
const Id continue_label{node.data.loop.continue_block->Definition<Id>()};
|
||||
const Id endloop_label{node.data.loop.merge->Definition<Id>()};
|
||||
|
||||
ctx.OpLoopMerge(endloop_label, continue_label, spv::LoopControlMask::MaskNone);
|
||||
ctx.OpBranch(body_label);
|
||||
break;
|
||||
}
|
||||
case IR::AbstractSyntaxNode::Type::Break: {
|
||||
const Id break_label{node.break_node.merge->Definition<Id>()};
|
||||
const Id skip_label{node.break_node.skip->Definition<Id>()};
|
||||
ctx.OpBranchConditional(ctx.Def(node.break_node.cond), break_label, skip_label);
|
||||
const Id break_label{node.data.break_node.merge->Definition<Id>()};
|
||||
const Id skip_label{node.data.break_node.skip->Definition<Id>()};
|
||||
ctx.OpBranchConditional(ctx.Def(node.data.break_node.cond), break_label, skip_label);
|
||||
break;
|
||||
}
|
||||
case IR::AbstractSyntaxNode::Type::EndIf:
|
||||
if (current_block) {
|
||||
ctx.OpBranch(node.end_if.merge->Definition<Id>());
|
||||
ctx.OpBranch(node.data.end_if.merge->Definition<Id>());
|
||||
}
|
||||
break;
|
||||
case IR::AbstractSyntaxNode::Type::Repeat: {
|
||||
const Id loop_header_label{node.repeat.loop_header->Definition<Id>()};
|
||||
const Id merge_label{node.repeat.merge->Definition<Id>()};
|
||||
ctx.OpBranchConditional(ctx.Def(node.repeat.cond), loop_header_label, merge_label);
|
||||
const Id loop_header_label{node.data.repeat.loop_header->Definition<Id>()};
|
||||
const Id merge_label{node.data.repeat.merge->Definition<Id>()};
|
||||
ctx.OpBranchConditional(ctx.Def(node.data.repeat.cond), loop_header_label, merge_label);
|
||||
break;
|
||||
}
|
||||
case IR::AbstractSyntaxNode::Type::Return:
|
||||
|
|
|
@ -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>;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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: {
|
||||
|
|
Loading…
Reference in a new issue