summaryrefslogtreecommitdiffstats
path: root/gfx/angle/src/compiler/translator/SimplifyLoopConditions.cpp
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-07-11 18:11:13 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-07-11 18:11:13 +0200
commit4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0 (patch)
treef000dd831240707a03b8c806db292c2a15cde3ce /gfx/angle/src/compiler/translator/SimplifyLoopConditions.cpp
parent3b7ffb477eec078c7036c92c6a51bb5de6de4f28 (diff)
downloadUXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar
UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar.gz
UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar.lz
UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar.xz
UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.zip
Roll back to ANGLE/2845
Diffstat (limited to 'gfx/angle/src/compiler/translator/SimplifyLoopConditions.cpp')
-rwxr-xr-xgfx/angle/src/compiler/translator/SimplifyLoopConditions.cpp32
1 files changed, 13 insertions, 19 deletions
diff --git a/gfx/angle/src/compiler/translator/SimplifyLoopConditions.cpp b/gfx/angle/src/compiler/translator/SimplifyLoopConditions.cpp
index 85c166e59..61a68fc93 100755
--- a/gfx/angle/src/compiler/translator/SimplifyLoopConditions.cpp
+++ b/gfx/angle/src/compiler/translator/SimplifyLoopConditions.cpp
@@ -13,9 +13,6 @@
#include "compiler/translator/IntermNode.h"
#include "compiler/translator/IntermNodePatternMatcher.h"
-namespace sh
-{
-
namespace
{
@@ -39,7 +36,7 @@ class SimplifyLoopConditionsTraverser : 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 foundLoopToChange() const { return mFoundLoopToChange; }
@@ -97,20 +94,20 @@ bool SimplifyLoopConditionsTraverser::visitAggregate(Visit visit, TIntermAggrega
// If we're outside a loop condition, we only need to traverse nodes that may contain loops.
if (!mInsideLoopConditionOrExpression)
- return false;
+ return (node->getOp() == EOpSequence || node->getOp() == EOpFunction);
mFoundLoopToChange = mConditionsToSimplify.match(node, getParentNode());
return !mFoundLoopToChange;
}
-bool SimplifyLoopConditionsTraverser::visitTernary(Visit visit, TIntermTernary *node)
+bool SimplifyLoopConditionsTraverser::visitSelection(Visit visit, TIntermSelection *node)
{
if (mFoundLoopToChange)
return false;
// Don't traverse ternary operators outside loop conditions.
if (!mInsideLoopConditionOrExpression)
- return false;
+ return !node->usesTernaryOperator();
mFoundLoopToChange = mConditionsToSimplify.match(node);
return !mFoundLoopToChange;
@@ -148,9 +145,10 @@ void SimplifyLoopConditionsTraverser::traverseLoop(TIntermLoop *node)
tempInitSeq.push_back(createTempInitDeclaration(node->getCondition()->deepCopy()));
insertStatementsInParentBlock(tempInitSeq);
- TIntermBlock *newBody = new TIntermBlock();
+ TIntermAggregate *newBody = new TIntermAggregate(EOpSequence);
if (node->getBody())
{
+ ASSERT(node->getBody()->getOp() == EOpSequence);
newBody->getSequence()->push_back(node->getBody());
}
newBody->getSequence()->push_back(
@@ -178,9 +176,10 @@ void SimplifyLoopConditionsTraverser::traverseLoop(TIntermLoop *node)
tempInitSeq.push_back(createTempInitDeclaration(CreateBoolConstantNode(true)));
insertStatementsInParentBlock(tempInitSeq);
- TIntermBlock *newBody = new TIntermBlock();
+ TIntermAggregate *newBody = new TIntermAggregate(EOpSequence);
if (node->getBody())
{
+ ASSERT(node->getBody()->getOp() == EOpSequence);
newBody->getSequence()->push_back(node->getBody());
}
newBody->getSequence()->push_back(
@@ -203,7 +202,7 @@ void SimplifyLoopConditionsTraverser::traverseLoop(TIntermLoop *node)
// bool s0 = expr;
// while (s0) { { body; } exprB; s0 = expr; }
// }
- TIntermBlock *loopScope = new TIntermBlock();
+ TIntermAggregate *loopScope = new TIntermAggregate(EOpSequence);
if (node->getInit())
{
loopScope->getSequence()->push_back(node->getInit());
@@ -211,15 +210,12 @@ void SimplifyLoopConditionsTraverser::traverseLoop(TIntermLoop *node)
loopScope->getSequence()->push_back(
createTempInitDeclaration(node->getCondition()->deepCopy()));
- TIntermBlock *whileLoopBody = new TIntermBlock();
+ TIntermAggregate *whileLoopBody = new TIntermAggregate(EOpSequence);
if (node->getBody())
{
whileLoopBody->getSequence()->push_back(node->getBody());
}
- if (node->getExpression())
- {
- whileLoopBody->getSequence()->push_back(node->getExpression());
- }
+ whileLoopBody->getSequence()->push_back(node->getExpression());
whileLoopBody->getSequence()->push_back(
createTempAssignment(node->getCondition()->deepCopy()));
TIntermLoop *whileLoop = new TIntermLoop(
@@ -246,8 +242,8 @@ void SimplifyLoopConditionsTraverser::traverseLoop(TIntermLoop *node)
// for (init; expr; ) { { body; } exprB; }
TIntermTyped *loopExpression = node->getExpression();
node->setExpression(nullptr);
- TIntermBlock *oldBody = node->getBody();
- node->setBody(new TIntermBlock());
+ TIntermAggregate *oldBody = node->getBody();
+ node->setBody(new TIntermAggregate(EOpSequence));
if (oldBody != nullptr)
{
node->getBody()->getSequence()->push_back(oldBody);
@@ -284,5 +280,3 @@ void SimplifyLoopConditions(TIntermNode *root,
traverser.updateTree();
} while (traverser.foundLoopToChange());
}
-
-} // namespace sh