PhiFunctions.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using Ryujinx.Graphics.Shader.IntermediateRepresentation;
  2. using System.Collections.Generic;
  3. namespace Ryujinx.Graphics.Shader.StructuredIr
  4. {
  5. static class PhiFunctions
  6. {
  7. public static void Remove(BasicBlock[] blocks)
  8. {
  9. for (int blkIndex = 0; blkIndex < blocks.Length; blkIndex++)
  10. {
  11. BasicBlock block = blocks[blkIndex];
  12. LinkedListNode<INode> node = block.Operations.First;
  13. while (node != null)
  14. {
  15. LinkedListNode<INode> nextNode = node.Next;
  16. if (node.Value is not PhiNode phi)
  17. {
  18. node = nextNode;
  19. continue;
  20. }
  21. for (int index = 0; index < phi.SourcesCount; index++)
  22. {
  23. Operand src = phi.GetSource(index);
  24. BasicBlock srcBlock = phi.GetBlock(index);
  25. Operation copyOp = new Operation(Instruction.Copy, phi.Dest, src);
  26. srcBlock.Append(copyOp);
  27. }
  28. block.Operations.Remove(node);
  29. node = nextNode;
  30. }
  31. }
  32. }
  33. }
  34. }