aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics/Shader/StructuredIr
diff options
context:
space:
mode:
authorAlex Barney <thealexbarney@gmail.com>2019-07-01 21:39:22 -0500
committerAc_K <Acoustik666@gmail.com>2019-07-02 04:39:22 +0200
commitb2b736abc2569ab5d8199da666aef8d8394844a0 (patch)
tree88bcc2ae4fb0d4161c95df2cd7edb12388de922a /Ryujinx.Graphics/Shader/StructuredIr
parent10c74182babaf8cf6bedaeffd64c3109df4ea816 (diff)
Misc cleanup (#708)
* Fix typos * Remove unneeded using statements * Enforce var style more * Remove redundant qualifiers * Fix some indentation * Disable naming warnings on files with external enum names * Fix build * Mass find & replace for comments with no spacing * Standardize todo capitalization and for/if spacing
Diffstat (limited to 'Ryujinx.Graphics/Shader/StructuredIr')
-rw-r--r--Ryujinx.Graphics/Shader/StructuredIr/AstBlockVisitor.cs6
-rw-r--r--Ryujinx.Graphics/Shader/StructuredIr/GotoElimination.cs48
-rw-r--r--Ryujinx.Graphics/Shader/StructuredIr/StructuredProgram.cs8
-rw-r--r--Ryujinx.Graphics/Shader/StructuredIr/StructuredProgramContext.cs10
4 files changed, 36 insertions, 36 deletions
diff --git a/Ryujinx.Graphics/Shader/StructuredIr/AstBlockVisitor.cs b/Ryujinx.Graphics/Shader/StructuredIr/AstBlockVisitor.cs
index 9397fdb9..10d5dce0 100644
--- a/Ryujinx.Graphics/Shader/StructuredIr/AstBlockVisitor.cs
+++ b/Ryujinx.Graphics/Shader/StructuredIr/AstBlockVisitor.cs
@@ -33,7 +33,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
while (node != null)
{
- //We reached a child block, visit the nodes inside.
+ // We reached a child block, visit the nodes inside.
while (node is AstBlock childBlock)
{
Block = childBlock;
@@ -43,7 +43,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
BlockEntered?.Invoke(this, new BlockVisitationEventArgs(Block));
}
- //Node may be null, if the block is empty.
+ // Node may be null, if the block is empty.
if (node != null)
{
IAstNode next = Next(node);
@@ -53,7 +53,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
node = next;
}
- //We reached the end of the list, go up on tree to the parent blocks.
+ // We reached the end of the list, go up on tree to the parent blocks.
while (node == null && Block.Type != AstBlockType.Main)
{
BlockLeft?.Invoke(this, new BlockVisitationEventArgs(Block));
diff --git a/Ryujinx.Graphics/Shader/StructuredIr/GotoElimination.cs b/Ryujinx.Graphics/Shader/StructuredIr/GotoElimination.cs
index dffc3142..8bcf9d9c 100644
--- a/Ryujinx.Graphics/Shader/StructuredIr/GotoElimination.cs
+++ b/Ryujinx.Graphics/Shader/StructuredIr/GotoElimination.cs
@@ -8,8 +8,8 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
{
static class GotoElimination
{
- //This is a modified version of the algorithm presented on the paper
- //"Taming Control Flow: A Structured Approach to Eliminating Goto Statements".
+ // This is a modified version of the algorithm presented on the paper
+ // "Taming Control Flow: A Structured Approach to Eliminating Goto Statements".
public static void Eliminate(GotoStatement[] gotos)
{
for (int index = gotos.Length - 1; index >= 0; index--)
@@ -43,10 +43,10 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
if (Previous(stmt.Goto) is AstBlock elseBlock && elseBlock.Type == AstBlockType.Else)
{
- //It's possible that the label was enclosed inside an else block,
- //in this case we need to update the block and level.
- //We also need to set the IsLoop for the case when the label is
- //now before the goto, due to the newly introduced else block.
+ // It's possible that the label was enclosed inside an else block,
+ // in this case we need to update the block and level.
+ // We also need to set the IsLoop for the case when the label is
+ // now before the goto, due to the newly introduced else block.
lBlock = ParentBlock(stmt.Label);
lLevel = Level(lBlock);
@@ -97,7 +97,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
private static bool DirectlyRelated(AstBlock lBlock, AstBlock rBlock, int lLevel, int rLevel)
{
- //If the levels are equal, they can be either siblings or indirectly related.
+ // If the levels are equal, they can be either siblings or indirectly related.
if (lLevel == rLevel)
{
return false;
@@ -171,9 +171,9 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
AstBlock block = origin;
- //Check if a loop is enclosing the goto, and the block that is
- //directly related to the label is above the loop block.
- //In that case, we need to introduce a break to get out of the loop.
+ // Check if a loop is enclosing the goto, and the block that is
+ // directly related to the label is above the loop block.
+ // In that case, we need to introduce a break to get out of the loop.
AstBlock loopBlock = origin;
int loopLevel = gLevel;
@@ -199,7 +199,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
}
}
- //Insert ifs to skip the parts that shouldn't be executed due to the goto.
+ // Insert ifs to skip the parts that shouldn't be executed due to the goto.
bool tryInsertElse = stmt.IsUnconditional && origin.Type == AstBlockType.If;
while (gLevel > lLevel)
@@ -210,10 +210,10 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
AstBlock child = block;
- //We can't move the goto in the middle of a if and a else block, in
- //this case we need to move it after the else.
- //IsLoop may need to be updated if the label is inside the else, as
- //introducing a loop is the only way to ensure the else will be executed.
+ // We can't move the goto in the middle of a if and a else block, in
+ // this case we need to move it after the else.
+ // IsLoop may need to be updated if the label is inside the else, as
+ // introducing a loop is the only way to ensure the else will be executed.
if (Next(child) is AstBlock elseBlock && elseBlock.Type == AstBlockType.Else)
{
child = elseBlock;
@@ -256,7 +256,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
if (child.Type == AstBlockType.If)
{
- //Modify the if condition to allow it to be entered by the goto.
+ // Modify the if condition to allow it to be entered by the goto.
if (!ContainsCondComb(child.Condition, Instruction.LogicalOr, stmt.Condition))
{
child.OrCondition(stmt.Condition);
@@ -264,7 +264,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
}
else if (child.Type == AstBlockType.Else)
{
- //Modify the matching if condition to force the else to be entered by the goto.
+ // Modify the matching if condition to force the else to be entered by the goto.
if (!(Previous(child) is AstBlock ifBlock) || ifBlock.Type != AstBlockType.If)
{
throw new InvalidOperationException("Found an else without a matching if.");
@@ -309,14 +309,14 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
{
if (block.Type == AstBlockType.DoWhile && first == block.First)
{
- //We only need to insert the continue if we're not at the end of the loop,
- //or if our condition is different from the loop condition.
+ // We only need to insert the continue if we're not at the end of the loop,
+ // or if our condition is different from the loop condition.
if (Next(stmt.Goto) != null || block.Condition != stmt.Condition)
{
EncloseSingleInst(stmt, Instruction.LoopContinue);
}
- //Modify the do-while condition to allow it to continue.
+ // Modify the do-while condition to allow it to continue.
if (!ContainsCondComb(block.Condition, Instruction.LogicalOr, stmt.Condition))
{
block.OrCondition(stmt.Condition);
@@ -356,10 +356,10 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
cond = InverseCond(cond);
}
- //Do a quick check, if we are enclosing a single block,
- //and the block type/condition matches the one we're going
- //to create, then we don't need a new block, we can just
- //return the old one.
+ // Do a quick check, if we are enclosing a single block,
+ // and the block type/condition matches the one we're going
+ // to create, then we don't need a new block, we can just
+ // return the old one.
bool hasSingleNode = Next(first) == last;
if (hasSingleNode && BlockMatches(first, type, cond))
diff --git a/Ryujinx.Graphics/Shader/StructuredIr/StructuredProgram.cs b/Ryujinx.Graphics/Shader/StructuredIr/StructuredProgram.cs
index f65631be..26faaf36 100644
--- a/Ryujinx.Graphics/Shader/StructuredIr/StructuredProgram.cs
+++ b/Ryujinx.Graphics/Shader/StructuredIr/StructuredProgram.cs
@@ -69,10 +69,10 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
AstAssignment assignment;
- //If all the sources are bool, it's better to use short-circuiting
- //logical operations, rather than forcing a cast to int and doing
- //a bitwise operation with the value, as it is likely to be used as
- //a bool in the end.
+ // If all the sources are bool, it's better to use short-circuiting
+ // logical operations, rather than forcing a cast to int and doing
+ // a bitwise operation with the value, as it is likely to be used as
+ // a bool in the end.
if (IsBitwiseInst(inst) && AreAllSourceTypesEqual(sources, VariableType.Bool))
{
inst = GetLogicalFromBitwiseInst(inst);
diff --git a/Ryujinx.Graphics/Shader/StructuredIr/StructuredProgramContext.cs b/Ryujinx.Graphics/Shader/StructuredIr/StructuredProgramContext.cs
index e1f0503a..5d6ff890 100644
--- a/Ryujinx.Graphics/Shader/StructuredIr/StructuredProgramContext.cs
+++ b/Ryujinx.Graphics/Shader/StructuredIr/StructuredProgramContext.cs
@@ -65,8 +65,8 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
private void LookForDoWhileStatements(BasicBlock block)
{
- //Check if we have any predecessor whose index is greater than the
- //current block, this indicates a loop.
+ // Check if we have any predecessor whose index is greater than the
+ // current block, this indicates a loop.
bool done = false;
foreach (BasicBlock predecessor in block.Predecessors.OrderByDescending(x => x.Index))
@@ -146,9 +146,9 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
{
AddNode(gotoTempAsg);
- //For block 0, we don't need to add the extra "reset" at the beggining,
- //because it is already the first node to be executed on the shader,
- //so it is reset to false by the "local" assignment anyway.
+ // For block 0, we don't need to add the extra "reset" at the beginning,
+ // because it is already the first node to be executed on the shader,
+ // so it is reset to false by the "local" assignment anyway.
if (block.Index != 0)
{
Info.MainBlock.AddFirst(Assign(gotoTempAsg.Destination, Const(IrConsts.False)));