Commit 1212bcac by Corentin Wallez Committed by Commit Bot

translator: separate declarations after rewriting loops

Otherwise when trying to add the declarations back, things might fail because the loop initialization is a sequence and not a block. BUG=668028 Change-Id: I8d84a25c25765e9655c16ce56604ae08f0f8176c Reviewed-on: https://chromium-review.googlesource.com/414305 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarOlli Etuaho <oetuaho@nvidia.com>
parent 00cf8940
......@@ -106,4 +106,13 @@ bool IntermNodePatternMatcher::match(TIntermTernary *node)
return false;
}
bool IntermNodePatternMatcher::match(TIntermDeclaration *node)
{
if ((mMask & kMultiDeclaration) != 0)
{
return node->getSequence()->size() > 1;
}
return false;
}
} // namespace sh
......@@ -18,6 +18,7 @@ class TIntermAggregate;
class TIntermBinary;
class TIntermNode;
class TIntermTernary;
class TIntermDeclaration;
class IntermNodePatternMatcher
{
......@@ -34,7 +35,10 @@ class IntermNodePatternMatcher
kExpressionReturningArray = 0x0002,
// Matches dynamic indexing of vectors or matrices in l-values.
kDynamicIndexingOfVectorOrMatrixInLValue = 0x0004
kDynamicIndexingOfVectorOrMatrixInLValue = 0x0004,
// Matches declarations with more than one declared variables
kMultiDeclaration = 0x0008,
};
IntermNodePatternMatcher(const unsigned int mask);
......@@ -46,6 +50,7 @@ class IntermNodePatternMatcher
bool match(TIntermAggregate *node, TIntermNode *parentNode);
bool match(TIntermTernary *node);
bool match(TIntermDeclaration *node);
private:
const unsigned int mMask;
......
......@@ -39,16 +39,19 @@ void TranslatorHLSL::translate(TIntermNode *root, ShCompileOptions compileOption
sh::AddDefaultReturnStatements(root);
SeparateDeclarations(root);
// Note that SimplifyLoopConditions needs to be run before any other AST transformations that
// may need to generate new statements from loop conditions or loop expressions.
SimplifyLoopConditions(root,
IntermNodePatternMatcher::kExpressionReturningArray |
IntermNodePatternMatcher::kUnfoldedShortCircuitExpression |
IntermNodePatternMatcher::kDynamicIndexingOfVectorOrMatrixInLValue,
IntermNodePatternMatcher::kDynamicIndexingOfVectorOrMatrixInLValue |
IntermNodePatternMatcher::kMultiDeclaration,
getTemporaryIndex(), getSymbolTable(), getShaderVersion());
// Note that separate declarations need to be run before other AST transformations that
// generate new statements from expressions.
SeparateDeclarations(root);
SplitSequenceOperator(root,
IntermNodePatternMatcher::kExpressionReturningArray |
IntermNodePatternMatcher::kUnfoldedShortCircuitExpression |
......
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