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,
void Traverser::nextIteration()
{
mFound = false;
nextTemporaryId();
}
bool Traverser::visitAggregate(Visit visit, TIntermAggregate *node)
......
......@@ -136,6 +136,8 @@ void RecordConstantPrecisionTraverser::visitConstantUnion(TIntermConstantUnion *
// Make the constant a precision-qualified named variable to make sure it affects the precision
// of the consuming expression.
nextTemporaryId();
TIntermSequence insertions;
insertions.push_back(createTempInitDeclaration(node, EvqConst));
insertStatementsInParentBlock(insertions);
......@@ -145,7 +147,6 @@ void RecordConstantPrecisionTraverser::visitConstantUnion(TIntermConstantUnion *
void RecordConstantPrecisionTraverser::nextIteration()
{
nextTemporaryId();
mFoundHigherPrecisionConstant = false;
}
......
......@@ -394,6 +394,7 @@ bool RemoveDynamicIndexingTraverser::visitBinary(Visit visit, TIntermBinary *nod
// to this:
// int s0 = index_expr; v_expr[s0];
// Now v_expr[s0] can be safely executed several times without unintended side effects.
nextTemporaryId();
// Init the temp variable holding the index
TIntermDeclaration *initIndex = createTempInitDeclaration(node->getRight());
......@@ -478,6 +479,7 @@ bool RemoveDynamicIndexingTraverser::visitBinary(Visit visit, TIntermBinary *nod
TIntermSequence insertionsAfter;
// Store the index in a temporary signed int variable.
nextTemporaryId();
TIntermTyped *indexInitializer = EnsureSignedInt(node->getRight());
TIntermDeclaration *initIndex = createTempInitDeclaration(indexInitializer);
initIndex->setLine(node->getLine());
......@@ -522,7 +524,6 @@ void RemoveDynamicIndexingTraverser::nextIteration()
{
mUsedTreeInsertion = false;
mRemoveIndexSideEffectsInSubtree = false;
nextTemporaryId();
}
} // namespace
......
......@@ -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
// 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.
nextTemporaryId();
insertions.push_back(createTempInitDeclaration(node->getLeft()));
insertStatementsInParentBlock(insertions);
......@@ -93,6 +94,8 @@ bool SeparateExpressionsTraverser::visitAggregate(Visit visit, TIntermAggregate
mFoundArrayExpression = true;
nextTemporaryId();
TIntermSequence insertions;
insertions.push_back(createTempInitDeclaration(node->shallowCopy()));
insertStatementsInParentBlock(insertions);
......@@ -105,7 +108,6 @@ bool SeparateExpressionsTraverser::visitAggregate(Visit visit, TIntermAggregate
void SeparateExpressionsTraverser::nextIteration()
{
mFoundArrayExpression = false;
nextTemporaryId();
}
} // namespace
......
......@@ -58,7 +58,6 @@ void SplitSequenceOperatorTraverser::nextIteration()
{
mFoundExpressionToSplit = false;
mInsideSequenceOperator = 0;
nextTemporaryId();
}
bool SplitSequenceOperatorTraverser::visitAggregate(Visit visit, TIntermAggregate *node)
......
......@@ -75,6 +75,7 @@ bool UnfoldShortCircuitTraverser::visitBinary(Visit visit, TIntermBinary *node)
TIntermSequence insertions;
TType boolType(EbtBool, EbpUndefined, EvqTemporary);
nextTemporaryId();
ASSERT(node->getLeft()->getType() == boolType);
insertions.push_back(createTempInitDeclaration(node->getLeft()));
......@@ -100,6 +101,7 @@ bool UnfoldShortCircuitTraverser::visitBinary(Visit visit, TIntermBinary *node)
// and then further simplifies down to "bool s = x; if(s) s = y;".
TIntermSequence insertions;
TType boolType(EbtBool, EbpUndefined, EvqTemporary);
nextTemporaryId();
ASSERT(node->getLeft()->getType() == boolType);
insertions.push_back(createTempInitDeclaration(node->getLeft()));
......@@ -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;"
TIntermSequence insertions;
nextTemporaryId();
TIntermDeclaration *tempDeclaration = createTempDeclaration(node->getType());
insertions.push_back(tempDeclaration);
......@@ -165,7 +168,6 @@ bool UnfoldShortCircuitTraverser::visitTernary(Visit visit, TIntermTernary *node
void UnfoldShortCircuitTraverser::nextIteration()
{
mFoundShortCircuit = false;
nextTemporaryId();
}
} // 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