summaryrefslogtreecommitdiffstats
path: root/gfx/angle/src/compiler/translator/SplitSequenceOperator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/angle/src/compiler/translator/SplitSequenceOperator.cpp')
-rwxr-xr-xgfx/angle/src/compiler/translator/SplitSequenceOperator.cpp34
1 files changed, 18 insertions, 16 deletions
diff --git a/gfx/angle/src/compiler/translator/SplitSequenceOperator.cpp b/gfx/angle/src/compiler/translator/SplitSequenceOperator.cpp
index 4c63b59f7..45fc8dc9b 100755
--- a/gfx/angle/src/compiler/translator/SplitSequenceOperator.cpp
+++ b/gfx/angle/src/compiler/translator/SplitSequenceOperator.cpp
@@ -14,9 +14,6 @@
#include "compiler/translator/IntermNode.h"
#include "compiler/translator/IntermNodePatternMatcher.h"
-namespace sh
-{
-
namespace
{
@@ -29,7 +26,7 @@ class SplitSequenceOperatorTraverser : public TLValueTrackingTraverser
bool visitBinary(Visit visit, TIntermBinary *node) override;
bool visitAggregate(Visit visit, TIntermAggregate *node) override;
- bool visitTernary(Visit visit, TIntermTernary *node) override;
+ bool visitSelection(Visit visit, TIntermSelection *node) override;
void nextIteration();
bool foundExpressionToSplit() const { return mFoundExpressionToSplit; }
@@ -60,7 +57,7 @@ void SplitSequenceOperatorTraverser::nextIteration()
nextTemporaryIndex();
}
-bool SplitSequenceOperatorTraverser::visitAggregate(Visit visit, TIntermAggregate *node)
+bool SplitSequenceOperatorTraverser::visitBinary(Visit visit, TIntermBinary *node)
{
if (mFoundExpressionToSplit)
return false;
@@ -68,14 +65,15 @@ bool SplitSequenceOperatorTraverser::visitAggregate(Visit visit, TIntermAggregat
if (mInsideSequenceOperator > 0 && visit == PreVisit)
{
// Detect expressions that need to be simplified
- mFoundExpressionToSplit = mPatternToSplitMatcher.match(node, getParentNode());
+ mFoundExpressionToSplit =
+ mPatternToSplitMatcher.match(node, getParentNode(), isLValueRequiredHere());
return !mFoundExpressionToSplit;
}
return true;
}
-bool SplitSequenceOperatorTraverser::visitBinary(Visit visit, TIntermBinary *node)
+bool SplitSequenceOperatorTraverser::visitAggregate(Visit visit, TIntermAggregate *node)
{
if (node->getOp() == EOpComma)
{
@@ -93,12 +91,19 @@ bool SplitSequenceOperatorTraverser::visitBinary(Visit visit, TIntermBinary *nod
// execution order.
if (mFoundExpressionToSplit && mInsideSequenceOperator == 1)
{
- // Move the left side operand into a separate statement in the parent block.
+ // Move all operands of the sequence operation except the last one into separate
+ // statements in the parent block.
TIntermSequence insertions;
- insertions.push_back(node->getLeft());
+ for (auto *sequenceChild : *node->getSequence())
+ {
+ if (sequenceChild != node->getSequence()->back())
+ {
+ insertions.push_back(sequenceChild);
+ }
+ }
insertStatementsInParentBlock(insertions);
- // Replace the comma node with its right side operand.
- queueReplacement(node, node->getRight(), OriginalNode::IS_DROPPED);
+ // Replace the sequence with its last operand
+ queueReplacement(node, node->getSequence()->back(), OriginalNode::IS_DROPPED);
}
mInsideSequenceOperator--;
}
@@ -111,15 +116,14 @@ bool SplitSequenceOperatorTraverser::visitBinary(Visit visit, TIntermBinary *nod
if (mInsideSequenceOperator > 0 && visit == PreVisit)
{
// Detect expressions that need to be simplified
- mFoundExpressionToSplit =
- mPatternToSplitMatcher.match(node, getParentNode(), isLValueRequiredHere());
+ mFoundExpressionToSplit = mPatternToSplitMatcher.match(node, getParentNode());
return !mFoundExpressionToSplit;
}
return true;
}
-bool SplitSequenceOperatorTraverser::visitTernary(Visit visit, TIntermTernary *node)
+bool SplitSequenceOperatorTraverser::visitSelection(Visit visit, TIntermSelection *node)
{
if (mFoundExpressionToSplit)
return false;
@@ -154,5 +158,3 @@ void SplitSequenceOperator(TIntermNode *root,
traverser.updateTree();
} while (traverser.foundExpressionToSplit());
}
-
-} // namespace sh