aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/IntermediateRepresentation/BasicBlock.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.Graphics.Shader/IntermediateRepresentation/BasicBlock.cs')
-rw-r--r--Ryujinx.Graphics.Shader/IntermediateRepresentation/BasicBlock.cs29
1 files changed, 29 insertions, 0 deletions
diff --git a/Ryujinx.Graphics.Shader/IntermediateRepresentation/BasicBlock.cs b/Ryujinx.Graphics.Shader/IntermediateRepresentation/BasicBlock.cs
index 1f7d2b25..2aca118b 100644
--- a/Ryujinx.Graphics.Shader/IntermediateRepresentation/BasicBlock.cs
+++ b/Ryujinx.Graphics.Shader/IntermediateRepresentation/BasicBlock.cs
@@ -58,5 +58,34 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
{
return Operations.Last?.Value;
}
+
+ public void Append(INode node)
+ {
+ INode lastOp = GetLastOp();
+
+ if (lastOp is Operation operation && IsControlFlowInst(operation.Inst))
+ {
+ Operations.AddBefore(Operations.Last, node);
+ }
+ else
+ {
+ Operations.AddLast(node);
+ }
+ }
+
+ private static bool IsControlFlowInst(Instruction inst)
+ {
+ switch (inst)
+ {
+ case Instruction.Branch:
+ case Instruction.BranchIfFalse:
+ case Instruction.BranchIfTrue:
+ case Instruction.Discard:
+ case Instruction.Return:
+ return true;
+ }
+
+ return false;
+ }
}
} \ No newline at end of file