Commit 495162b9 by Olli Etuaho Committed by Commit Bot

Don't create temporary ids ahead of time

Now temporary ids are always only created for a specific temporary variable. BUG=angleproject:2267 TEST=angle_unittests Change-Id: Icbd369695abc166ef399bed9ae11a3669f1e7228 Reviewed-on: https://chromium-review.googlesource.com/816951Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 9db70de8
...@@ -54,7 +54,6 @@ Traverser::Traverser(TSymbolTable *symbolTable) : TIntermTraverser(true, false, ...@@ -54,7 +54,6 @@ Traverser::Traverser(TSymbolTable *symbolTable) : TIntermTraverser(true, false,
void Traverser::nextIteration() void Traverser::nextIteration()
{ {
mFound = false; mFound = false;
nextTemporaryId();
} }
bool Traverser::visitAggregate(Visit visit, TIntermAggregate *node) bool Traverser::visitAggregate(Visit visit, TIntermAggregate *node)
......
...@@ -136,6 +136,8 @@ void RecordConstantPrecisionTraverser::visitConstantUnion(TIntermConstantUnion * ...@@ -136,6 +136,8 @@ void RecordConstantPrecisionTraverser::visitConstantUnion(TIntermConstantUnion *
// Make the constant a precision-qualified named variable to make sure it affects the precision // Make the constant a precision-qualified named variable to make sure it affects the precision
// of the consuming expression. // of the consuming expression.
nextTemporaryId();
TIntermSequence insertions; TIntermSequence insertions;
insertions.push_back(createTempInitDeclaration(node, EvqConst)); insertions.push_back(createTempInitDeclaration(node, EvqConst));
insertStatementsInParentBlock(insertions); insertStatementsInParentBlock(insertions);
...@@ -145,7 +147,6 @@ void RecordConstantPrecisionTraverser::visitConstantUnion(TIntermConstantUnion * ...@@ -145,7 +147,6 @@ void RecordConstantPrecisionTraverser::visitConstantUnion(TIntermConstantUnion *
void RecordConstantPrecisionTraverser::nextIteration() void RecordConstantPrecisionTraverser::nextIteration()
{ {
nextTemporaryId();
mFoundHigherPrecisionConstant = false; mFoundHigherPrecisionConstant = false;
} }
......
...@@ -394,6 +394,7 @@ bool RemoveDynamicIndexingTraverser::visitBinary(Visit visit, TIntermBinary *nod ...@@ -394,6 +394,7 @@ bool RemoveDynamicIndexingTraverser::visitBinary(Visit visit, TIntermBinary *nod
// to this: // to this:
// int s0 = index_expr; v_expr[s0]; // int s0 = index_expr; v_expr[s0];
// Now v_expr[s0] can be safely executed several times without unintended side effects. // Now v_expr[s0] can be safely executed several times without unintended side effects.
nextTemporaryId();
// Init the temp variable holding the index // Init the temp variable holding the index
TIntermDeclaration *initIndex = createTempInitDeclaration(node->getRight()); TIntermDeclaration *initIndex = createTempInitDeclaration(node->getRight());
...@@ -478,6 +479,7 @@ bool RemoveDynamicIndexingTraverser::visitBinary(Visit visit, TIntermBinary *nod ...@@ -478,6 +479,7 @@ bool RemoveDynamicIndexingTraverser::visitBinary(Visit visit, TIntermBinary *nod
TIntermSequence insertionsAfter; TIntermSequence insertionsAfter;
// Store the index in a temporary signed int variable. // Store the index in a temporary signed int variable.
nextTemporaryId();
TIntermTyped *indexInitializer = EnsureSignedInt(node->getRight()); TIntermTyped *indexInitializer = EnsureSignedInt(node->getRight());
TIntermDeclaration *initIndex = createTempInitDeclaration(indexInitializer); TIntermDeclaration *initIndex = createTempInitDeclaration(indexInitializer);
initIndex->setLine(node->getLine()); initIndex->setLine(node->getLine());
...@@ -522,7 +524,6 @@ void RemoveDynamicIndexingTraverser::nextIteration() ...@@ -522,7 +524,6 @@ void RemoveDynamicIndexingTraverser::nextIteration()
{ {
mUsedTreeInsertion = false; mUsedTreeInsertion = false;
mRemoveIndexSideEffectsInSubtree = false; mRemoveIndexSideEffectsInSubtree = false;
nextTemporaryId();
} }
} // namespace } // namespace
......
...@@ -73,6 +73,7 @@ bool SeparateExpressionsTraverser::visitBinary(Visit visit, TIntermBinary *node) ...@@ -73,6 +73,7 @@ bool SeparateExpressionsTraverser::visitBinary(Visit visit, TIntermBinary *node)
// TODO(oetuaho): In some cases it would be more optimal to not add the temporary node, but just // TODO(oetuaho): In some cases it would be more optimal to not add the temporary node, but just
// use the original target of the assignment. Care must be taken so that this doesn't happen // use the original target of the assignment. Care must be taken so that this doesn't happen
// when the same array symbol is a target of assignment more than once in one expression. // when the same array symbol is a target of assignment more than once in one expression.
nextTemporaryId();
insertions.push_back(createTempInitDeclaration(node->getLeft())); insertions.push_back(createTempInitDeclaration(node->getLeft()));
insertStatementsInParentBlock(insertions); insertStatementsInParentBlock(insertions);
...@@ -93,6 +94,8 @@ bool SeparateExpressionsTraverser::visitAggregate(Visit visit, TIntermAggregate ...@@ -93,6 +94,8 @@ bool SeparateExpressionsTraverser::visitAggregate(Visit visit, TIntermAggregate
mFoundArrayExpression = true; mFoundArrayExpression = true;
nextTemporaryId();
TIntermSequence insertions; TIntermSequence insertions;
insertions.push_back(createTempInitDeclaration(node->shallowCopy())); insertions.push_back(createTempInitDeclaration(node->shallowCopy()));
insertStatementsInParentBlock(insertions); insertStatementsInParentBlock(insertions);
...@@ -105,7 +108,6 @@ bool SeparateExpressionsTraverser::visitAggregate(Visit visit, TIntermAggregate ...@@ -105,7 +108,6 @@ bool SeparateExpressionsTraverser::visitAggregate(Visit visit, TIntermAggregate
void SeparateExpressionsTraverser::nextIteration() void SeparateExpressionsTraverser::nextIteration()
{ {
mFoundArrayExpression = false; mFoundArrayExpression = false;
nextTemporaryId();
} }
} // namespace } // namespace
......
...@@ -58,7 +58,6 @@ void SplitSequenceOperatorTraverser::nextIteration() ...@@ -58,7 +58,6 @@ void SplitSequenceOperatorTraverser::nextIteration()
{ {
mFoundExpressionToSplit = false; mFoundExpressionToSplit = false;
mInsideSequenceOperator = 0; mInsideSequenceOperator = 0;
nextTemporaryId();
} }
bool SplitSequenceOperatorTraverser::visitAggregate(Visit visit, TIntermAggregate *node) bool SplitSequenceOperatorTraverser::visitAggregate(Visit visit, TIntermAggregate *node)
......
...@@ -75,6 +75,7 @@ bool UnfoldShortCircuitTraverser::visitBinary(Visit visit, TIntermBinary *node) ...@@ -75,6 +75,7 @@ bool UnfoldShortCircuitTraverser::visitBinary(Visit visit, TIntermBinary *node)
TIntermSequence insertions; TIntermSequence insertions;
TType boolType(EbtBool, EbpUndefined, EvqTemporary); TType boolType(EbtBool, EbpUndefined, EvqTemporary);
nextTemporaryId();
ASSERT(node->getLeft()->getType() == boolType); ASSERT(node->getLeft()->getType() == boolType);
insertions.push_back(createTempInitDeclaration(node->getLeft())); insertions.push_back(createTempInitDeclaration(node->getLeft()));
...@@ -100,6 +101,7 @@ bool UnfoldShortCircuitTraverser::visitBinary(Visit visit, TIntermBinary *node) ...@@ -100,6 +101,7 @@ bool UnfoldShortCircuitTraverser::visitBinary(Visit visit, TIntermBinary *node)
// and then further simplifies down to "bool s = x; if(s) s = y;". // and then further simplifies down to "bool s = x; if(s) s = y;".
TIntermSequence insertions; TIntermSequence insertions;
TType boolType(EbtBool, EbpUndefined, EvqTemporary); TType boolType(EbtBool, EbpUndefined, EvqTemporary);
nextTemporaryId();
ASSERT(node->getLeft()->getType() == boolType); ASSERT(node->getLeft()->getType() == boolType);
insertions.push_back(createTempInitDeclaration(node->getLeft())); insertions.push_back(createTempInitDeclaration(node->getLeft()));
...@@ -138,6 +140,7 @@ bool UnfoldShortCircuitTraverser::visitTernary(Visit visit, TIntermTernary *node ...@@ -138,6 +140,7 @@ bool UnfoldShortCircuitTraverser::visitTernary(Visit visit, TIntermTernary *node
// Unfold "b ? x : y" into "type s; if(b) s = x; else s = y;" // Unfold "b ? x : y" into "type s; if(b) s = x; else s = y;"
TIntermSequence insertions; TIntermSequence insertions;
nextTemporaryId();
TIntermDeclaration *tempDeclaration = createTempDeclaration(node->getType()); TIntermDeclaration *tempDeclaration = createTempDeclaration(node->getType());
insertions.push_back(tempDeclaration); insertions.push_back(tempDeclaration);
...@@ -165,7 +168,6 @@ bool UnfoldShortCircuitTraverser::visitTernary(Visit visit, TIntermTernary *node ...@@ -165,7 +168,6 @@ bool UnfoldShortCircuitTraverser::visitTernary(Visit visit, TIntermTernary *node
void UnfoldShortCircuitTraverser::nextIteration() void UnfoldShortCircuitTraverser::nextIteration()
{ {
mFoundShortCircuit = false; mFoundShortCircuit = false;
nextTemporaryId();
} }
} // namespace } // namespace
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment