summaryrefslogtreecommitdiffstats
path: root/gfx/angle/src/compiler/translator/IntermTraverse.cpp
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-07-11 23:29:50 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-07-11 23:31:02 +0200
commit70dd5e7c66b1fe3f82e5b4db2406050baba15f05 (patch)
tree3f012200ef3c934f33db1a4ef2b790fae3141860 /gfx/angle/src/compiler/translator/IntermTraverse.cpp
parent3b7ffb477eec078c7036c92c6a51bb5de6de4f28 (diff)
parent8481fa25d246f1968d0a254ee3c6cdd82c60781a (diff)
downloadUXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar
UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar.gz
UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar.lz
UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar.xz
UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.zip
Merge branch 'ANGLE-rollback'
This resolves #624 Note: Cherry-picked some fixes on top of the ANGLE version that we want to keep.
Diffstat (limited to 'gfx/angle/src/compiler/translator/IntermTraverse.cpp')
-rwxr-xr-xgfx/angle/src/compiler/translator/IntermTraverse.cpp271
1 files changed, 66 insertions, 205 deletions
diff --git a/gfx/angle/src/compiler/translator/IntermTraverse.cpp b/gfx/angle/src/compiler/translator/IntermTraverse.cpp
index 7f91595d4..2f66ba7cd 100755
--- a/gfx/angle/src/compiler/translator/IntermTraverse.cpp
+++ b/gfx/angle/src/compiler/translator/IntermTraverse.cpp
@@ -8,9 +8,6 @@
#include "compiler/translator/InfoSink.h"
#include "compiler/translator/SymbolTable.h"
-namespace sh
-{
-
void TIntermSymbol::traverse(TIntermTraverser *it)
{
it->traverseSymbol(this);
@@ -26,11 +23,6 @@ void TIntermConstantUnion::traverse(TIntermTraverser *it)
it->traverseConstantUnion(this);
}
-void TIntermSwizzle::traverse(TIntermTraverser *it)
-{
- it->traverseSwizzle(this);
-}
-
void TIntermBinary::traverse(TIntermTraverser *it)
{
it->traverseBinary(this);
@@ -41,14 +33,9 @@ void TIntermUnary::traverse(TIntermTraverser *it)
it->traverseUnary(this);
}
-void TIntermTernary::traverse(TIntermTraverser *it)
+void TIntermSelection::traverse(TIntermTraverser *it)
{
- it->traverseTernary(this);
-}
-
-void TIntermIfElse::traverse(TIntermTraverser *it)
-{
- it->traverseIfElse(this);
+ it->traverseSelection(this);
}
void TIntermSwitch::traverse(TIntermTraverser *it)
@@ -61,21 +48,6 @@ void TIntermCase::traverse(TIntermTraverser *it)
it->traverseCase(this);
}
-void TIntermFunctionDefinition::traverse(TIntermTraverser *it)
-{
- it->traverseFunctionDefinition(this);
-}
-
-void TIntermBlock::traverse(TIntermTraverser *it)
-{
- it->traverseBlock(this);
-}
-
-void TIntermDeclaration::traverse(TIntermTraverser *it)
-{
- it->traverseDeclaration(this);
-}
-
void TIntermAggregate::traverse(TIntermTraverser *it)
{
it->traverseAggregate(this);
@@ -106,7 +78,7 @@ TIntermTraverser::~TIntermTraverser()
{
}
-void TIntermTraverser::pushParentBlock(TIntermBlock *node)
+void TIntermTraverser::pushParentBlock(TIntermAggregate *node)
{
mParentBlockStack.push_back(ParentBlock(node, 0));
}
@@ -154,11 +126,7 @@ TIntermSymbol *TIntermTraverser::createTempSymbol(const TType &type, TQualifier
TIntermSymbol *node = new TIntermSymbol(0, symbolName, type);
node->setInternal(true);
-
- ASSERT(qualifier == EvqTemporary || qualifier == EvqConst || qualifier == EvqGlobal);
node->getTypePointer()->setQualifier(qualifier);
- // TODO(oetuaho): Might be useful to sanitize layout qualifier etc. on the type of the created
- // symbol. This might need to be done in other places as well.
return node;
}
@@ -167,25 +135,27 @@ TIntermSymbol *TIntermTraverser::createTempSymbol(const TType &type)
return createTempSymbol(type, EvqTemporary);
}
-TIntermDeclaration *TIntermTraverser::createTempDeclaration(const TType &type)
+TIntermAggregate *TIntermTraverser::createTempDeclaration(const TType &type)
{
- TIntermDeclaration *tempDeclaration = new TIntermDeclaration();
- tempDeclaration->appendDeclarator(createTempSymbol(type));
+ TIntermAggregate *tempDeclaration = new TIntermAggregate(EOpDeclaration);
+ tempDeclaration->getSequence()->push_back(createTempSymbol(type));
return tempDeclaration;
}
-TIntermDeclaration *TIntermTraverser::createTempInitDeclaration(TIntermTyped *initializer,
- TQualifier qualifier)
+TIntermAggregate *TIntermTraverser::createTempInitDeclaration(TIntermTyped *initializer, TQualifier qualifier)
{
ASSERT(initializer != nullptr);
TIntermSymbol *tempSymbol = createTempSymbol(initializer->getType(), qualifier);
- TIntermDeclaration *tempDeclaration = new TIntermDeclaration();
- TIntermBinary *tempInit = new TIntermBinary(EOpInitialize, tempSymbol, initializer);
- tempDeclaration->appendDeclarator(tempInit);
+ TIntermAggregate *tempDeclaration = new TIntermAggregate(EOpDeclaration);
+ TIntermBinary *tempInit = new TIntermBinary(EOpInitialize);
+ tempInit->setLeft(tempSymbol);
+ tempInit->setRight(initializer);
+ tempInit->setType(tempSymbol->getType());
+ tempDeclaration->getSequence()->push_back(tempInit);
return tempDeclaration;
}
-TIntermDeclaration *TIntermTraverser::createTempInitDeclaration(TIntermTyped *initializer)
+TIntermAggregate *TIntermTraverser::createTempInitDeclaration(TIntermTyped *initializer)
{
return createTempInitDeclaration(initializer, EvqTemporary);
}
@@ -194,7 +164,10 @@ TIntermBinary *TIntermTraverser::createTempAssignment(TIntermTyped *rightNode)
{
ASSERT(rightNode != nullptr);
TIntermSymbol *tempSymbol = createTempSymbol(rightNode->getType());
- TIntermBinary *assignment = new TIntermBinary(EOpAssign, tempSymbol, rightNode);
+ TIntermBinary *assignment = new TIntermBinary(EOpAssign);
+ assignment->setLeft(tempSymbol);
+ assignment->setRight(rightNode);
+ assignment->setType(tempSymbol->getType());
return assignment;
}
@@ -217,14 +190,13 @@ void TLValueTrackingTraverser::addToFunctionMap(const TName &name, TIntermSequen
bool TLValueTrackingTraverser::isInFunctionMap(const TIntermAggregate *callNode) const
{
ASSERT(callNode->getOp() == EOpFunctionCall);
- return (mFunctionMap.find(callNode->getFunctionSymbolInfo()->getNameObj()) !=
- mFunctionMap.end());
+ return (mFunctionMap.find(callNode->getNameObj()) != mFunctionMap.end());
}
TIntermSequence *TLValueTrackingTraverser::getFunctionParameters(const TIntermAggregate *callNode)
{
ASSERT(isInFunctionMap(callNode));
- return mFunctionMap[callNode->getFunctionSymbolInfo()->getNameObj()];
+ return mFunctionMap[callNode->getNameObj()];
}
void TLValueTrackingTraverser::setInFunctionCallOutParameter(bool inOutParameter)
@@ -261,26 +233,6 @@ void TIntermTraverser::traverseConstantUnion(TIntermConstantUnion *node)
visitConstantUnion(node);
}
-void TIntermTraverser::traverseSwizzle(TIntermSwizzle *node)
-{
- bool visit = true;
-
- if (preVisit)
- visit = visitSwizzle(PreVisit, node);
-
- if (visit)
- {
- incrementDepth(node);
-
- node->getOperand()->traverse(this);
-
- decrementDepth();
- }
-
- if (visit && postVisit)
- visitSwizzle(PostVisit, node);
-}
-
//
// Traverse a binary node.
//
@@ -442,99 +394,9 @@ void TLValueTrackingTraverser::traverseUnary(TIntermUnary *node)
visitUnary(PostVisit, node);
}
-// Traverse a function definition node.
-void TIntermTraverser::traverseFunctionDefinition(TIntermFunctionDefinition *node)
-{
- bool visit = true;
-
- if (preVisit)
- visit = visitFunctionDefinition(PreVisit, node);
-
- if (visit)
- {
- incrementDepth(node);
- mInGlobalScope = false;
-
- node->getFunctionParameters()->traverse(this);
- if (inVisit)
- visit = visitFunctionDefinition(InVisit, node);
- node->getBody()->traverse(this);
-
- mInGlobalScope = true;
- decrementDepth();
- }
-
- if (visit && postVisit)
- visitFunctionDefinition(PostVisit, node);
-}
-
-// Traverse a block node.
-void TIntermTraverser::traverseBlock(TIntermBlock *node)
-{
- bool visit = true;
-
- TIntermSequence *sequence = node->getSequence();
-
- if (preVisit)
- visit = visitBlock(PreVisit, node);
-
- if (visit)
- {
- incrementDepth(node);
- pushParentBlock(node);
-
- for (auto *child : *sequence)
- {
- child->traverse(this);
- if (visit && inVisit)
- {
- if (child != sequence->back())
- visit = visitBlock(InVisit, node);
- }
-
- incrementParentBlockPos();
- }
-
- popParentBlock();
- decrementDepth();
- }
-
- if (visit && postVisit)
- visitBlock(PostVisit, node);
-}
-
-// Traverse a declaration node.
-void TIntermTraverser::traverseDeclaration(TIntermDeclaration *node)
-{
- bool visit = true;
-
- TIntermSequence *sequence = node->getSequence();
-
- if (preVisit)
- visit = visitDeclaration(PreVisit, node);
-
- if (visit)
- {
- incrementDepth(node);
-
- for (auto *child : *sequence)
- {
- child->traverse(this);
- if (visit && inVisit)
- {
- if (child != sequence->back())
- visit = visitDeclaration(InVisit, node);
- }
- }
-
- decrementDepth();
- }
-
- if (visit && postVisit)
- visitDeclaration(PostVisit, node);
-}
-
+//
// Traverse an aggregate node. Same comments in binary node apply here.
+//
void TIntermTraverser::traverseAggregate(TIntermAggregate *node)
{
bool visit = true;
@@ -548,6 +410,11 @@ void TIntermTraverser::traverseAggregate(TIntermAggregate *node)
{
incrementDepth(node);
+ if (node->getOp() == EOpSequence)
+ pushParentBlock(node);
+ else if (node->getOp() == EOpFunction)
+ mInGlobalScope = false;
+
for (auto *child : *sequence)
{
child->traverse(this);
@@ -556,8 +423,16 @@ void TIntermTraverser::traverseAggregate(TIntermAggregate *node)
if (child != sequence->back())
visit = visitAggregate(InVisit, node);
}
+
+ if (node->getOp() == EOpSequence)
+ incrementParentBlockPos();
}
+ if (node->getOp() == EOpSequence)
+ popParentBlock();
+ else if (node->getOp() == EOpFunction)
+ mInGlobalScope = true;
+
decrementDepth();
}
@@ -565,24 +440,26 @@ void TIntermTraverser::traverseAggregate(TIntermAggregate *node)
visitAggregate(PostVisit, node);
}
-void TLValueTrackingTraverser::traverseFunctionDefinition(TIntermFunctionDefinition *node)
-{
- TIntermAggregate *params = node->getFunctionParameters();
- ASSERT(params != nullptr);
- ASSERT(params->getOp() == EOpParameters);
- addToFunctionMap(node->getFunctionSymbolInfo()->getNameObj(), params->getSequence());
-
- TIntermTraverser::traverseFunctionDefinition(node);
-}
-
void TLValueTrackingTraverser::traverseAggregate(TIntermAggregate *node)
{
bool visit = true;
TIntermSequence *sequence = node->getSequence();
- if (node->getOp() == EOpPrototype)
+ switch (node->getOp())
{
- addToFunctionMap(node->getFunctionSymbolInfo()->getNameObj(), sequence);
+ case EOpFunction:
+ {
+ TIntermAggregate *params = sequence->front()->getAsAggregate();
+ ASSERT(params != nullptr);
+ ASSERT(params->getOp() == EOpParameters);
+ addToFunctionMap(node->getNameObj(), params->getSequence());
+ break;
+ }
+ case EOpPrototype:
+ addToFunctionMap(node->getNameObj(), sequence);
+ break;
+ default:
+ break;
}
if (preVisit)
@@ -628,6 +505,11 @@ void TLValueTrackingTraverser::traverseAggregate(TIntermAggregate *node)
}
else
{
+ if (node->getOp() == EOpSequence)
+ pushParentBlock(node);
+ else if (node->getOp() == EOpFunction)
+ mInGlobalScope = false;
+
// Find the built-in function corresponding to this op so that we can determine the
// in/out qualifiers of its parameters.
TFunction *builtInFunc = nullptr;
@@ -669,10 +551,18 @@ void TLValueTrackingTraverser::traverseAggregate(TIntermAggregate *node)
visit = visitAggregate(InVisit, node);
}
+ if (node->getOp() == EOpSequence)
+ incrementParentBlockPos();
+
++paramIndex;
}
setInFunctionCallOutParameter(false);
+
+ if (node->getOp() == EOpSequence)
+ popParentBlock();
+ else if (node->getOp() == EOpFunction)
+ mInGlobalScope = true;
}
decrementDepth();
@@ -683,37 +573,14 @@ void TLValueTrackingTraverser::traverseAggregate(TIntermAggregate *node)
}
//
-// Traverse a ternary node. Same comments in binary node apply here.
+// Traverse a selection node. Same comments in binary node apply here.
//
-void TIntermTraverser::traverseTernary(TIntermTernary *node)
-{
- bool visit = true;
-
- if (preVisit)
- visit = visitTernary(PreVisit, node);
-
- if (visit)
- {
- incrementDepth(node);
- node->getCondition()->traverse(this);
- if (node->getTrueExpression())
- node->getTrueExpression()->traverse(this);
- if (node->getFalseExpression())
- node->getFalseExpression()->traverse(this);
- decrementDepth();
- }
-
- if (visit && postVisit)
- visitTernary(PostVisit, node);
-}
-
-// Traverse an if-else node. Same comments in binary node apply here.
-void TIntermTraverser::traverseIfElse(TIntermIfElse *node)
+void TIntermTraverser::traverseSelection(TIntermSelection *node)
{
bool visit = true;
if (preVisit)
- visit = visitIfElse(PreVisit, node);
+ visit = visitSelection(PreVisit, node);
if (visit)
{
@@ -727,7 +594,7 @@ void TIntermTraverser::traverseIfElse(TIntermIfElse *node)
}
if (visit && postVisit)
- visitIfElse(PostVisit, node);
+ visitSelection(PostVisit, node);
}
//
@@ -766,11 +633,7 @@ void TIntermTraverser::traverseCase(TIntermCase *node)
visit = visitCase(PreVisit, node);
if (visit && node->getCondition())
- {
- incrementDepth(node);
node->getCondition()->traverse(this);
- decrementDepth();
- }
if (visit && postVisit)
visitCase(PostVisit, node);
@@ -834,5 +697,3 @@ void TIntermTraverser::traverseRaw(TIntermRaw *node)
{
visitRaw(node);
}
-
-} // namespace sh