Commit 5796127e by Olli Etuaho Committed by Commit Bot

Rename TIntermSelection to TIntermIfElse

Now that ternary nodes are not represented by TIntermSelection any more, TIntermIfElse is an easier name to understand for newcomers to the code. BUG=angleproject:1490 TEST=angle_unittests Change-Id: Ia1e04e356ab93409400245092a84533d7dfd129d Reviewed-on: https://chromium-review.googlesource.com/385416Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 28b6528c
...@@ -72,9 +72,9 @@ class PullGradient : public TIntermTraverser ...@@ -72,9 +72,9 @@ class PullGradient : public TIntermTraverser
return true; return true;
} }
bool visitSelection(Visit visit, TIntermSelection *selection) override bool visitIfElse(Visit visit, TIntermIfElse *ifElse) override
{ {
visitControlFlow(visit, selection); visitControlFlow(visit, ifElse);
return true; return true;
} }
...@@ -196,7 +196,7 @@ class PullComputeDiscontinuousAndGradientLoops : public TIntermTraverser ...@@ -196,7 +196,7 @@ class PullComputeDiscontinuousAndGradientLoops : public TIntermTraverser
return true; return true;
} }
bool visitSelection(Visit visit, TIntermSelection *node) override bool visitIfElse(Visit visit, TIntermIfElse *node) override
{ {
if (visit == PreVisit) if (visit == PreVisit)
{ {
...@@ -310,7 +310,7 @@ class PullComputeDiscontinuousAndGradientLoops : public TIntermTraverser ...@@ -310,7 +310,7 @@ class PullComputeDiscontinuousAndGradientLoops : public TIntermTraverser
const CallDAG &mDag; const CallDAG &mDag;
std::vector<TIntermNode*> mLoopsAndSwitches; std::vector<TIntermNode*> mLoopsAndSwitches;
std::vector<TIntermSelection*> mIfs; std::vector<TIntermIfElse *> mIfs;
}; };
// Tags all the functions called in a discontinuous loop // Tags all the functions called in a discontinuous loop
...@@ -385,7 +385,7 @@ bool ASTMetadataHLSL::hasGradientInCallGraph(TIntermLoop *node) ...@@ -385,7 +385,7 @@ bool ASTMetadataHLSL::hasGradientInCallGraph(TIntermLoop *node)
return mControlFlowsContainingGradient.count(node) > 0; return mControlFlowsContainingGradient.count(node) > 0;
} }
bool ASTMetadataHLSL::hasGradientLoop(TIntermSelection *node) bool ASTMetadataHLSL::hasGradientLoop(TIntermIfElse *node)
{ {
return mIfsContainingGradientLoop.count(node) > 0; return mIfsContainingGradientLoop.count(node) > 0;
} }
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
class CallDAG; class CallDAG;
class TIntermNode; class TIntermNode;
class TIntermSelection; class TIntermIfElse;
class TIntermLoop; class TIntermLoop;
struct ASTMetadataHLSL struct ASTMetadataHLSL
...@@ -30,7 +30,7 @@ struct ASTMetadataHLSL ...@@ -30,7 +30,7 @@ struct ASTMetadataHLSL
// Here "something uses a gradient" means here that it either contains a // Here "something uses a gradient" means here that it either contains a
// gradient operation, or a call to a function that uses a gradient. // gradient operation, or a call to a function that uses a gradient.
bool hasGradientInCallGraph(TIntermLoop *node); bool hasGradientInCallGraph(TIntermLoop *node);
bool hasGradientLoop(TIntermSelection *node); bool hasGradientLoop(TIntermIfElse *node);
// Does the function use a gradient. // Does the function use a gradient.
bool mUsesGradient; bool mUsesGradient;
...@@ -44,7 +44,7 @@ struct ASTMetadataHLSL ...@@ -44,7 +44,7 @@ struct ASTMetadataHLSL
bool mCalledInDiscontinuousLoop; bool mCalledInDiscontinuousLoop;
bool mHasGradientLoopInCallGraph; bool mHasGradientLoopInCallGraph;
std::set<TIntermLoop*> mDiscontinuousLoops; std::set<TIntermLoop*> mDiscontinuousLoops;
std::set<TIntermSelection *> mIfsContainingGradientLoop; std::set<TIntermIfElse *> mIfsContainingGradientLoop;
// Will we need to generate a Lod0 version of the function. // Will we need to generate a Lod0 version of the function.
bool mNeedsLod0; bool mNeedsLod0;
......
...@@ -25,7 +25,7 @@ class VariableInitializer : public TIntermTraverser ...@@ -25,7 +25,7 @@ class VariableInitializer : public TIntermTraverser
protected: protected:
bool visitBinary(Visit, TIntermBinary *node) override { return false; } bool visitBinary(Visit, TIntermBinary *node) override { return false; }
bool visitUnary(Visit, TIntermUnary *node) override { return false; } bool visitUnary(Visit, TIntermUnary *node) override { return false; }
bool visitSelection(Visit, TIntermSelection *node) override { return false; } bool visitIfElse(Visit, TIntermIfElse *node) override { return false; }
bool visitLoop(Visit, TIntermLoop *node) override { return false; } bool visitLoop(Visit, TIntermLoop *node) override { return false; }
bool visitBranch(Visit, TIntermBranch *node) override { return false; } bool visitBranch(Visit, TIntermBranch *node) override { return false; }
......
...@@ -300,8 +300,7 @@ bool TIntermTernary::replaceChildNode(TIntermNode *original, TIntermNode *replac ...@@ -300,8 +300,7 @@ bool TIntermTernary::replaceChildNode(TIntermNode *original, TIntermNode *replac
return false; return false;
} }
bool TIntermSelection::replaceChildNode( bool TIntermIfElse::replaceChildNode(TIntermNode *original, TIntermNode *replacement)
TIntermNode *original, TIntermNode *replacement)
{ {
REPLACE_IF_IS(mCondition, TIntermTyped, original, replacement); REPLACE_IF_IS(mCondition, TIntermTyped, original, replacement);
REPLACE_IF_IS(mTrueBlock, TIntermNode, original, replacement); REPLACE_IF_IS(mTrueBlock, TIntermNode, original, replacement);
......
...@@ -35,7 +35,7 @@ class TIntermBinary; ...@@ -35,7 +35,7 @@ class TIntermBinary;
class TIntermUnary; class TIntermUnary;
class TIntermConstantUnion; class TIntermConstantUnion;
class TIntermTernary; class TIntermTernary;
class TIntermSelection; class TIntermIfElse;
class TIntermSwitch; class TIntermSwitch;
class TIntermCase; class TIntermCase;
class TIntermTyped; class TIntermTyped;
...@@ -95,7 +95,7 @@ class TIntermNode : angle::NonCopyable ...@@ -95,7 +95,7 @@ class TIntermNode : angle::NonCopyable
virtual TIntermBinary *getAsBinaryNode() { return 0; } virtual TIntermBinary *getAsBinaryNode() { return 0; }
virtual TIntermUnary *getAsUnaryNode() { return 0; } virtual TIntermUnary *getAsUnaryNode() { return 0; }
virtual TIntermTernary *getAsTernaryNode() { return nullptr; } virtual TIntermTernary *getAsTernaryNode() { return nullptr; }
virtual TIntermSelection *getAsSelectionNode() { return 0; } virtual TIntermIfElse *getAsIfElseNode() { return nullptr; }
virtual TIntermSwitch *getAsSwitchNode() { return 0; } virtual TIntermSwitch *getAsSwitchNode() { return 0; }
virtual TIntermCase *getAsCaseNode() { return 0; } virtual TIntermCase *getAsCaseNode() { return 0; }
virtual TIntermSymbol *getAsSymbolNode() { return 0; } virtual TIntermSymbol *getAsSymbolNode() { return 0; }
...@@ -603,11 +603,10 @@ class TIntermTernary : public TIntermTyped ...@@ -603,11 +603,10 @@ class TIntermTernary : public TIntermTyped
TIntermTyped *mFalseExpression; TIntermTyped *mFalseExpression;
}; };
// For if tests. class TIntermIfElse : public TIntermNode
class TIntermSelection : public TIntermNode
{ {
public: public:
TIntermSelection(TIntermTyped *cond, TIntermNode *trueB, TIntermNode *falseB) TIntermIfElse(TIntermTyped *cond, TIntermNode *trueB, TIntermNode *falseB)
: TIntermNode(), mCondition(cond), mTrueBlock(trueB), mFalseBlock(falseB) : TIntermNode(), mCondition(cond), mTrueBlock(trueB), mFalseBlock(falseB)
{ {
} }
...@@ -618,7 +617,7 @@ class TIntermSelection : public TIntermNode ...@@ -618,7 +617,7 @@ class TIntermSelection : public TIntermNode
TIntermTyped *getCondition() const { return mCondition; } TIntermTyped *getCondition() const { return mCondition; }
TIntermNode *getTrueBlock() const { return mTrueBlock; } TIntermNode *getTrueBlock() const { return mTrueBlock; }
TIntermNode *getFalseBlock() const { return mFalseBlock; } TIntermNode *getFalseBlock() const { return mFalseBlock; }
TIntermSelection *getAsSelectionNode() override { return this; } TIntermIfElse *getAsIfElseNode() override { return this; }
protected: protected:
TIntermTyped *mCondition; TIntermTyped *mCondition;
...@@ -710,7 +709,7 @@ class TIntermTraverser : angle::NonCopyable ...@@ -710,7 +709,7 @@ class TIntermTraverser : angle::NonCopyable
virtual bool visitBinary(Visit visit, TIntermBinary *node) { return true; } virtual bool visitBinary(Visit visit, TIntermBinary *node) { return true; }
virtual bool visitUnary(Visit visit, TIntermUnary *node) { return true; } virtual bool visitUnary(Visit visit, TIntermUnary *node) { return true; }
virtual bool visitTernary(Visit visit, TIntermTernary *node) { return true; } virtual bool visitTernary(Visit visit, TIntermTernary *node) { return true; }
virtual bool visitSelection(Visit visit, TIntermSelection *node) { return true; } virtual bool visitIfElse(Visit visit, TIntermIfElse *node) { return true; }
virtual bool visitSwitch(Visit visit, TIntermSwitch *node) { return true; } virtual bool visitSwitch(Visit visit, TIntermSwitch *node) { return true; }
virtual bool visitCase(Visit visit, TIntermCase *node) { return true; } virtual bool visitCase(Visit visit, TIntermCase *node) { return true; }
virtual bool visitAggregate(Visit visit, TIntermAggregate *node) { return true; } virtual bool visitAggregate(Visit visit, TIntermAggregate *node) { return true; }
...@@ -726,7 +725,7 @@ class TIntermTraverser : angle::NonCopyable ...@@ -726,7 +725,7 @@ class TIntermTraverser : angle::NonCopyable
virtual void traverseBinary(TIntermBinary *node); virtual void traverseBinary(TIntermBinary *node);
virtual void traverseUnary(TIntermUnary *node); virtual void traverseUnary(TIntermUnary *node);
virtual void traverseTernary(TIntermTernary *node); virtual void traverseTernary(TIntermTernary *node);
virtual void traverseSelection(TIntermSelection *node); virtual void traverseIfElse(TIntermIfElse *node);
virtual void traverseSwitch(TIntermSwitch *node); virtual void traverseSwitch(TIntermSwitch *node);
virtual void traverseCase(TIntermCase *node); virtual void traverseCase(TIntermCase *node);
virtual void traverseAggregate(TIntermAggregate *node); virtual void traverseAggregate(TIntermAggregate *node);
...@@ -1014,7 +1013,7 @@ class TMaxDepthTraverser : public TIntermTraverser ...@@ -1014,7 +1013,7 @@ class TMaxDepthTraverser : public TIntermTraverser
bool visitBinary(Visit, TIntermBinary *) override { return depthCheck(); } bool visitBinary(Visit, TIntermBinary *) override { return depthCheck(); }
bool visitUnary(Visit, TIntermUnary *) override { return depthCheck(); } bool visitUnary(Visit, TIntermUnary *) override { return depthCheck(); }
bool visitTernary(Visit, TIntermTernary *) override { return depthCheck(); } bool visitTernary(Visit, TIntermTernary *) override { return depthCheck(); }
bool visitSelection(Visit, TIntermSelection *) override { return depthCheck(); } bool visitIfElse(Visit, TIntermIfElse *) override { return depthCheck(); }
bool visitAggregate(Visit, TIntermAggregate *) override { return depthCheck(); } bool visitAggregate(Visit, TIntermAggregate *) override { return depthCheck(); }
bool visitLoop(Visit, TIntermLoop *) override { return depthCheck(); } bool visitLoop(Visit, TIntermLoop *) override { return depthCheck(); }
bool visitBranch(Visit, TIntermBranch *) override { return depthCheck(); } bool visitBranch(Visit, TIntermBranch *) override { return depthCheck(); }
......
...@@ -38,9 +38,9 @@ void TIntermTernary::traverse(TIntermTraverser *it) ...@@ -38,9 +38,9 @@ void TIntermTernary::traverse(TIntermTraverser *it)
it->traverseTernary(this); it->traverseTernary(this);
} }
void TIntermSelection::traverse(TIntermTraverser *it) void TIntermIfElse::traverse(TIntermTraverser *it)
{ {
it->traverseSelection(this); it->traverseIfElse(this);
} }
void TIntermSwitch::traverse(TIntermTraverser *it) void TIntermSwitch::traverse(TIntermTraverser *it)
...@@ -596,15 +596,13 @@ void TIntermTraverser::traverseTernary(TIntermTernary *node) ...@@ -596,15 +596,13 @@ void TIntermTraverser::traverseTernary(TIntermTernary *node)
visitTernary(PostVisit, node); visitTernary(PostVisit, node);
} }
// // Traverse an if-else node. Same comments in binary node apply here.
// Traverse a selection node. Same comments in binary node apply here. void TIntermTraverser::traverseIfElse(TIntermIfElse *node)
//
void TIntermTraverser::traverseSelection(TIntermSelection *node)
{ {
bool visit = true; bool visit = true;
if (preVisit) if (preVisit)
visit = visitSelection(PreVisit, node); visit = visitIfElse(PreVisit, node);
if (visit) if (visit)
{ {
...@@ -618,7 +616,7 @@ void TIntermTraverser::traverseSelection(TIntermSelection *node) ...@@ -618,7 +616,7 @@ void TIntermTraverser::traverseSelection(TIntermSelection *node)
} }
if (visit && postVisit) if (visit && postVisit)
visitSelection(PostVisit, node); visitIfElse(PostVisit, node);
} }
// //
......
...@@ -172,37 +172,35 @@ TIntermAggregate *TIntermediate::ensureSequence(TIntermNode *node) ...@@ -172,37 +172,35 @@ TIntermAggregate *TIntermediate::ensureSequence(TIntermNode *node)
return aggNode; return aggNode;
} }
//
// For "if" test nodes. There are three children; a condition, // For "if" test nodes. There are three children; a condition,
// a true path, and a false path. The two paths are in the // a true path, and a false path. The two paths are in the
// nodePair. // nodePair.
// //
// Returns the selection node created. // Returns the node created.
// TIntermNode *TIntermediate::addIfElse(TIntermTyped *cond,
TIntermNode *TIntermediate::addSelection( TIntermNodePair nodePair,
TIntermTyped *cond, TIntermNodePair nodePair, const TSourceLoc &line) const TSourceLoc &line)
{ {
// // For compile time constant conditions, prune the code now.
// For compile time constant selections, prune the code and
// test now.
//
if (cond->getAsConstantUnion()) if (cond->getAsConstantUnion())
{ {
if (cond->getAsConstantUnion()->getBConst(0) == true) if (cond->getAsConstantUnion()->getBConst(0) == true)
{ {
return nodePair.node1 ? setAggregateOperator( return nodePair.node1 ? setAggregateOperator(nodePair.node1, EOpSequence,
nodePair.node1, EOpSequence, nodePair.node1->getLine()) : NULL; nodePair.node1->getLine())
: nullptr;
} }
else else
{ {
return nodePair.node2 ? setAggregateOperator( return nodePair.node2 ? setAggregateOperator(nodePair.node2, EOpSequence,
nodePair.node2, EOpSequence, nodePair.node2->getLine()) : NULL; nodePair.node2->getLine())
: nullptr;
} }
} }
TIntermSelection *node = new TIntermSelection( TIntermIfElse *node =
cond, ensureSequence(nodePair.node1), ensureSequence(nodePair.node2)); new TIntermIfElse(cond, ensureSequence(nodePair.node1), ensureSequence(nodePair.node2));
node->setLine(line); node->setLine(line);
return node; return node;
......
...@@ -38,7 +38,7 @@ class TIntermediate ...@@ -38,7 +38,7 @@ class TIntermediate
TIntermAggregate *makeAggregate(TIntermNode *node, const TSourceLoc &); TIntermAggregate *makeAggregate(TIntermNode *node, const TSourceLoc &);
TIntermAggregate *ensureSequence(TIntermNode *node); TIntermAggregate *ensureSequence(TIntermNode *node);
TIntermAggregate *setAggregateOperator(TIntermNode *, TOperator, const TSourceLoc &); TIntermAggregate *setAggregateOperator(TIntermNode *, TOperator, const TSourceLoc &);
TIntermNode *addSelection(TIntermTyped *cond, TIntermNodePair code, const TSourceLoc &line); TIntermNode *addIfElse(TIntermTyped *cond, TIntermNodePair code, const TSourceLoc &line);
static TIntermTyped *AddTernarySelection(TIntermTyped *cond, static TIntermTyped *AddTernarySelection(TIntermTyped *cond,
TIntermTyped *trueExpression, TIntermTyped *trueExpression,
TIntermTyped *falseExpression, TIntermTyped *falseExpression,
......
...@@ -27,7 +27,7 @@ bool isSingleStatement(TIntermNode *node) ...@@ -27,7 +27,7 @@ bool isSingleStatement(TIntermNode *node)
return (aggregate->getOp() != EOpFunction) && return (aggregate->getOp() != EOpFunction) &&
(aggregate->getOp() != EOpSequence); (aggregate->getOp() != EOpSequence);
} }
else if (node->getAsSelectionNode()) else if (node->getAsIfElseNode())
{ {
return false; return false;
} }
...@@ -726,7 +726,7 @@ bool TOutputGLSLBase::visitTernary(Visit visit, TIntermTernary *node) ...@@ -726,7 +726,7 @@ bool TOutputGLSLBase::visitTernary(Visit visit, TIntermTernary *node)
return false; return false;
} }
bool TOutputGLSLBase::visitSelection(Visit visit, TIntermSelection *node) bool TOutputGLSLBase::visitIfElse(Visit visit, TIntermIfElse *node)
{ {
TInfoSinkBase &out = objSink(); TInfoSinkBase &out = objSink();
......
...@@ -45,7 +45,7 @@ class TOutputGLSLBase : public TIntermTraverser ...@@ -45,7 +45,7 @@ class TOutputGLSLBase : public TIntermTraverser
bool visitBinary(Visit visit, TIntermBinary *node) override; bool visitBinary(Visit visit, TIntermBinary *node) override;
bool visitUnary(Visit visit, TIntermUnary *node) override; bool visitUnary(Visit visit, TIntermUnary *node) override;
bool visitTernary(Visit visit, TIntermTernary *node) override; bool visitTernary(Visit visit, TIntermTernary *node) override;
bool visitSelection(Visit visit, TIntermSelection *node) override; bool visitIfElse(Visit visit, TIntermIfElse *node) override;
bool visitSwitch(Visit visit, TIntermSwitch *node) override; bool visitSwitch(Visit visit, TIntermSwitch *node) override;
bool visitCase(Visit visit, TIntermCase *node) override; bool visitCase(Visit visit, TIntermCase *node) override;
bool visitAggregate(Visit visit, TIntermAggregate *node) override; bool visitAggregate(Visit visit, TIntermAggregate *node) override;
......
...@@ -1457,9 +1457,9 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -1457,9 +1457,9 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
// Don't output ; after case labels, they're terminated by : // Don't output ; after case labels, they're terminated by :
// This is needed especially since outputting a ; after a case statement would turn empty // This is needed especially since outputting a ; after a case statement would turn empty
// case statements into non-empty case statements, disallowing fall-through from them. // case statements into non-empty case statements, disallowing fall-through from them.
// Also no need to output ; after selection (if) statements or sequences. This is done just // Also no need to output ; after if statements or sequences. This is done just for
// for code clarity. // code clarity.
if ((*sit)->getAsCaseNode() == nullptr && (*sit)->getAsSelectionNode() == nullptr && if ((*sit)->getAsCaseNode() == nullptr && (*sit)->getAsIfElseNode() == nullptr &&
!IsSequence(*sit)) !IsSequence(*sit))
out << ";\n"; out << ";\n";
} }
...@@ -1929,7 +1929,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -1929,7 +1929,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
return true; return true;
} }
void OutputHLSL::writeSelection(TInfoSinkBase &out, TIntermSelection *node) void OutputHLSL::writeIfElse(TInfoSinkBase &out, TIntermIfElse *node)
{ {
out << "if ("; out << "if (";
...@@ -1967,7 +1967,8 @@ void OutputHLSL::writeSelection(TInfoSinkBase &out, TIntermSelection *node) ...@@ -1967,7 +1967,8 @@ void OutputHLSL::writeSelection(TInfoSinkBase &out, TIntermSelection *node)
outputLineDirective(out, node->getFalseBlock()->getLine().first_line); outputLineDirective(out, node->getFalseBlock()->getLine().first_line);
// Either this is "else if" or the falseBlock child node will output braces. // Either this is "else if" or the falseBlock child node will output braces.
ASSERT(IsSequence(node->getFalseBlock()) || node->getFalseBlock()->getAsSelectionNode() != nullptr); ASSERT(IsSequence(node->getFalseBlock()) ||
node->getFalseBlock()->getAsIfElseNode() != nullptr);
node->getFalseBlock()->traverse(this); node->getFalseBlock()->traverse(this);
...@@ -1992,7 +1993,7 @@ bool OutputHLSL::visitTernary(Visit, TIntermTernary *) ...@@ -1992,7 +1993,7 @@ bool OutputHLSL::visitTernary(Visit, TIntermTernary *)
return false; return false;
} }
bool OutputHLSL::visitSelection(Visit visit, TIntermSelection *node) bool OutputHLSL::visitIfElse(Visit visit, TIntermIfElse *node)
{ {
TInfoSinkBase &out = getInfoSink(); TInfoSinkBase &out = getInfoSink();
...@@ -2004,7 +2005,7 @@ bool OutputHLSL::visitSelection(Visit visit, TIntermSelection *node) ...@@ -2004,7 +2005,7 @@ bool OutputHLSL::visitSelection(Visit visit, TIntermSelection *node)
out << "FLATTEN "; out << "FLATTEN ";
} }
writeSelection(out, node); writeIfElse(out, node);
return false; return false;
} }
......
...@@ -62,7 +62,7 @@ class OutputHLSL : public TIntermTraverser ...@@ -62,7 +62,7 @@ class OutputHLSL : public TIntermTraverser
bool visitBinary(Visit visit, TIntermBinary*); bool visitBinary(Visit visit, TIntermBinary*);
bool visitUnary(Visit visit, TIntermUnary*); bool visitUnary(Visit visit, TIntermUnary*);
bool visitTernary(Visit visit, TIntermTernary *); bool visitTernary(Visit visit, TIntermTernary *);
bool visitSelection(Visit visit, TIntermSelection*); bool visitIfElse(Visit visit, TIntermIfElse *);
bool visitSwitch(Visit visit, TIntermSwitch *); bool visitSwitch(Visit visit, TIntermSwitch *);
bool visitCase(Visit visit, TIntermCase *); bool visitCase(Visit visit, TIntermCase *);
bool visitAggregate(Visit visit, TIntermAggregate*); bool visitAggregate(Visit visit, TIntermAggregate*);
...@@ -105,7 +105,7 @@ class OutputHLSL : public TIntermTraverser ...@@ -105,7 +105,7 @@ class OutputHLSL : public TIntermTraverser
TIntermTyped *expression); TIntermTyped *expression);
void writeDeferredGlobalInitializers(TInfoSinkBase &out); void writeDeferredGlobalInitializers(TInfoSinkBase &out);
void writeSelection(TInfoSinkBase &out, TIntermSelection *node); void writeIfElse(TInfoSinkBase &out, TIntermIfElse *node);
// Returns the function name // Returns the function name
TString addStructEqualityFunction(const TStructure &structure); TString addStructEqualityFunction(const TStructure &structure);
......
...@@ -280,7 +280,7 @@ TIntermAggregate *GetIndexFunctionDefinition(TType type, bool write) ...@@ -280,7 +280,7 @@ TIntermAggregate *GetIndexFunctionDefinition(TType type, bool write)
TIntermBranch *returnLastNode = new TIntermBranch(EOpReturn, indexLastNode); TIntermBranch *returnLastNode = new TIntermBranch(EOpReturn, indexLastNode);
useLastBlock->getSequence()->push_back(returnLastNode); useLastBlock->getSequence()->push_back(returnLastNode);
} }
TIntermSelection *ifNode = new TIntermSelection(cond, useFirstBlock, nullptr); TIntermIfElse *ifNode = new TIntermIfElse(cond, useFirstBlock, nullptr);
bodyNode->getSequence()->push_back(ifNode); bodyNode->getSequence()->push_back(ifNode);
bodyNode->getSequence()->push_back(useLastBlock); bodyNode->getSequence()->push_back(useLastBlock);
......
...@@ -69,7 +69,7 @@ bool RemoveSwitchFallThrough::visitTernary(Visit, TIntermTernary *node) ...@@ -69,7 +69,7 @@ bool RemoveSwitchFallThrough::visitTernary(Visit, TIntermTernary *node)
return false; return false;
} }
bool RemoveSwitchFallThrough::visitSelection(Visit, TIntermSelection *node) bool RemoveSwitchFallThrough::visitIfElse(Visit, TIntermIfElse *node)
{ {
mPreviousCase->getSequence()->push_back(node); mPreviousCase->getSequence()->push_back(node);
mLastStatementWasBreak = false; mLastStatementWasBreak = false;
......
...@@ -24,7 +24,7 @@ class RemoveSwitchFallThrough : public TIntermTraverser ...@@ -24,7 +24,7 @@ class RemoveSwitchFallThrough : public TIntermTraverser
bool visitBinary(Visit, TIntermBinary *node) override; bool visitBinary(Visit, TIntermBinary *node) override;
bool visitUnary(Visit, TIntermUnary *node) override; bool visitUnary(Visit, TIntermUnary *node) override;
bool visitTernary(Visit visit, TIntermTernary *node) override; bool visitTernary(Visit visit, TIntermTernary *node) override;
bool visitSelection(Visit visit, TIntermSelection *node) override; bool visitIfElse(Visit visit, TIntermIfElse *node) override;
bool visitSwitch(Visit, TIntermSwitch *node) override; bool visitSwitch(Visit, TIntermSwitch *node) override;
bool visitCase(Visit, TIntermCase *node) override; bool visitCase(Visit, TIntermCase *node) override;
bool visitAggregate(Visit, TIntermAggregate *node) override; bool visitAggregate(Visit, TIntermAggregate *node) override;
......
...@@ -95,7 +95,7 @@ class DoWhileRewriter : public TIntermTraverser ...@@ -95,7 +95,7 @@ class DoWhileRewriter : public TIntermTraverser
// break; // break;
// } // }
// } // }
TIntermSelection *breakIf = nullptr; TIntermIfElse *breakIf = nullptr;
{ {
TIntermBranch *breakStatement = new TIntermBranch(EOpBreak, nullptr); TIntermBranch *breakStatement = new TIntermBranch(EOpBreak, nullptr);
...@@ -105,13 +105,12 @@ class DoWhileRewriter : public TIntermTraverser ...@@ -105,13 +105,12 @@ class DoWhileRewriter : public TIntermTraverser
TIntermUnary *negatedCondition = TIntermUnary *negatedCondition =
new TIntermUnary(EOpLogicalNot, loop->getCondition()); new TIntermUnary(EOpLogicalNot, loop->getCondition());
TIntermSelection *innerIf = TIntermIfElse *innerIf = new TIntermIfElse(negatedCondition, breakBlock, nullptr);
new TIntermSelection(negatedCondition, breakBlock, nullptr);
TIntermAggregate *innerIfBlock = new TIntermAggregate(EOpSequence); TIntermAggregate *innerIfBlock = new TIntermAggregate(EOpSequence);
innerIfBlock->getSequence()->push_back(innerIf); innerIfBlock->getSequence()->push_back(innerIf);
breakIf = new TIntermSelection(createTempSymbol(boolType), innerIfBlock, nullptr); breakIf = new TIntermIfElse(createTempSymbol(boolType), innerIfBlock, nullptr);
} }
// Assemble the replacement loops, reusing the do-while loop's body and inserting our // Assemble the replacement loops, reusing the do-while loop's body and inserting our
......
...@@ -28,7 +28,7 @@ class ElseBlockRewriter : public TIntermTraverser ...@@ -28,7 +28,7 @@ class ElseBlockRewriter : public TIntermTraverser
private: private:
const TType *mFunctionType; const TType *mFunctionType;
TIntermNode *rewriteSelection(TIntermSelection *selection); TIntermNode *rewriteIfElse(TIntermIfElse *ifElse);
}; };
ElseBlockRewriter::ElseBlockRewriter() ElseBlockRewriter::ElseBlockRewriter()
...@@ -46,19 +46,19 @@ bool ElseBlockRewriter::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -46,19 +46,19 @@ bool ElseBlockRewriter::visitAggregate(Visit visit, TIntermAggregate *node)
for (size_t statementIndex = 0; statementIndex != node->getSequence()->size(); statementIndex++) for (size_t statementIndex = 0; statementIndex != node->getSequence()->size(); statementIndex++)
{ {
TIntermNode *statement = (*node->getSequence())[statementIndex]; TIntermNode *statement = (*node->getSequence())[statementIndex];
TIntermSelection *selection = statement->getAsSelectionNode(); TIntermIfElse *ifElse = statement->getAsIfElseNode();
if (selection && selection->getFalseBlock() != nullptr) if (ifElse && ifElse->getFalseBlock() != nullptr)
{ {
// Check for if / else if // Check for if / else if
TIntermSelection *elseIfBranch = selection->getFalseBlock()->getAsSelectionNode(); TIntermIfElse *elseIfBranch = ifElse->getFalseBlock()->getAsIfElseNode();
if (elseIfBranch) if (elseIfBranch)
{ {
selection->replaceChildNode(elseIfBranch, rewriteSelection(elseIfBranch)); ifElse->replaceChildNode(elseIfBranch, rewriteIfElse(elseIfBranch));
delete elseIfBranch; delete elseIfBranch;
} }
(*node->getSequence())[statementIndex] = rewriteSelection(selection); (*node->getSequence())[statementIndex] = rewriteIfElse(ifElse);
delete selection; delete ifElse;
} }
} }
} }
...@@ -75,20 +75,20 @@ bool ElseBlockRewriter::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -75,20 +75,20 @@ bool ElseBlockRewriter::visitAggregate(Visit visit, TIntermAggregate *node)
return true; return true;
} }
TIntermNode *ElseBlockRewriter::rewriteSelection(TIntermSelection *selection) TIntermNode *ElseBlockRewriter::rewriteIfElse(TIntermIfElse *ifElse)
{ {
ASSERT(selection != nullptr); ASSERT(ifElse != nullptr);
nextTemporaryIndex(); nextTemporaryIndex();
TIntermTyped *typedCondition = selection->getCondition()->getAsTyped(); TIntermTyped *typedCondition = ifElse->getCondition()->getAsTyped();
TIntermAggregate *storeCondition = createTempInitDeclaration(typedCondition); TIntermAggregate *storeCondition = createTempInitDeclaration(typedCondition);
TIntermSelection *falseBlock = nullptr; TIntermIfElse *falseBlock = nullptr;
TType boolType(EbtBool, EbpUndefined, EvqTemporary); TType boolType(EbtBool, EbpUndefined, EvqTemporary);
if (selection->getFalseBlock()) if (ifElse->getFalseBlock())
{ {
TIntermAggregate *negatedElse = nullptr; TIntermAggregate *negatedElse = nullptr;
// crbug.com/346463 // crbug.com/346463
...@@ -107,16 +107,16 @@ TIntermNode *ElseBlockRewriter::rewriteSelection(TIntermSelection *selection) ...@@ -107,16 +107,16 @@ TIntermNode *ElseBlockRewriter::rewriteSelection(TIntermSelection *selection)
TIntermSymbol *conditionSymbolElse = createTempSymbol(boolType); TIntermSymbol *conditionSymbolElse = createTempSymbol(boolType);
TIntermUnary *negatedCondition = new TIntermUnary(EOpLogicalNot, conditionSymbolElse); TIntermUnary *negatedCondition = new TIntermUnary(EOpLogicalNot, conditionSymbolElse);
falseBlock = new TIntermSelection(negatedCondition, falseBlock = new TIntermIfElse(negatedCondition, ifElse->getFalseBlock(), negatedElse);
selection->getFalseBlock(), negatedElse);
} }
TIntermSymbol *conditionSymbolSel = createTempSymbol(boolType); TIntermSymbol *conditionSymbolSel = createTempSymbol(boolType);
TIntermSelection *newSelection = new TIntermSelection(conditionSymbolSel, selection->getTrueBlock(), falseBlock); TIntermIfElse *newIfElse =
new TIntermIfElse(conditionSymbolSel, ifElse->getTrueBlock(), falseBlock);
TIntermAggregate *block = new TIntermAggregate(EOpSequence); TIntermAggregate *block = new TIntermAggregate(EOpSequence);
block->getSequence()->push_back(storeCondition); block->getSequence()->push_back(storeCondition);
block->getSequence()->push_back(newSelection); block->getSequence()->push_back(newIfElse);
return block; return block;
} }
......
...@@ -80,7 +80,7 @@ bool UnfoldShortCircuitTraverser::visitBinary(Visit visit, TIntermBinary *node) ...@@ -80,7 +80,7 @@ bool UnfoldShortCircuitTraverser::visitBinary(Visit visit, TIntermBinary *node)
assignRightBlock->getSequence()->push_back(createTempAssignment(node->getRight())); assignRightBlock->getSequence()->push_back(createTempAssignment(node->getRight()));
TIntermUnary *notTempSymbol = new TIntermUnary(EOpLogicalNot, createTempSymbol(boolType)); TIntermUnary *notTempSymbol = new TIntermUnary(EOpLogicalNot, createTempSymbol(boolType));
TIntermSelection *ifNode = new TIntermSelection(notTempSymbol, assignRightBlock, nullptr); TIntermIfElse *ifNode = new TIntermIfElse(notTempSymbol, assignRightBlock, nullptr);
insertions.push_back(ifNode); insertions.push_back(ifNode);
insertStatementsInParentBlock(insertions); insertStatementsInParentBlock(insertions);
...@@ -103,8 +103,8 @@ bool UnfoldShortCircuitTraverser::visitBinary(Visit visit, TIntermBinary *node) ...@@ -103,8 +103,8 @@ bool UnfoldShortCircuitTraverser::visitBinary(Visit visit, TIntermBinary *node)
ASSERT(node->getRight()->getType() == boolType); ASSERT(node->getRight()->getType() == boolType);
assignRightBlock->getSequence()->push_back(createTempAssignment(node->getRight())); assignRightBlock->getSequence()->push_back(createTempAssignment(node->getRight()));
TIntermSelection *ifNode = TIntermIfElse *ifNode =
new TIntermSelection(createTempSymbol(boolType), assignRightBlock, nullptr); new TIntermIfElse(createTempSymbol(boolType), assignRightBlock, nullptr);
insertions.push_back(ifNode); insertions.push_back(ifNode);
insertStatementsInParentBlock(insertions); insertStatementsInParentBlock(insertions);
...@@ -147,8 +147,8 @@ bool UnfoldShortCircuitTraverser::visitTernary(Visit visit, TIntermTernary *node ...@@ -147,8 +147,8 @@ bool UnfoldShortCircuitTraverser::visitTernary(Visit visit, TIntermTernary *node
TIntermBinary *falseAssignment = createTempAssignment(node->getFalseExpression()); TIntermBinary *falseAssignment = createTempAssignment(node->getFalseExpression());
falseBlock->getSequence()->push_back(falseAssignment); falseBlock->getSequence()->push_back(falseAssignment);
TIntermSelection *ifNode = TIntermIfElse *ifNode =
new TIntermSelection(node->getCondition()->getAsTyped(), trueBlock, falseBlock); new TIntermIfElse(node->getCondition()->getAsTyped(), trueBlock, falseBlock);
insertions.push_back(ifNode); insertions.push_back(ifNode);
insertStatementsInParentBlock(insertions); insertStatementsInParentBlock(insertions);
......
...@@ -71,7 +71,7 @@ bool ValidateSwitch::visitTernary(Visit, TIntermTernary *) ...@@ -71,7 +71,7 @@ bool ValidateSwitch::visitTernary(Visit, TIntermTernary *)
return true; return true;
} }
bool ValidateSwitch::visitSelection(Visit visit, TIntermSelection *) bool ValidateSwitch::visitIfElse(Visit visit, TIntermIfElse *)
{ {
if (visit == PreVisit) if (visit == PreVisit)
++mControlFlowDepth; ++mControlFlowDepth;
......
...@@ -24,7 +24,7 @@ class ValidateSwitch : public TIntermTraverser ...@@ -24,7 +24,7 @@ class ValidateSwitch : public TIntermTraverser
bool visitBinary(Visit, TIntermBinary *) override; bool visitBinary(Visit, TIntermBinary *) override;
bool visitUnary(Visit, TIntermUnary *) override; bool visitUnary(Visit, TIntermUnary *) override;
bool visitTernary(Visit, TIntermTernary *) override; bool visitTernary(Visit, TIntermTernary *) override;
bool visitSelection(Visit visit, TIntermSelection *) override; bool visitIfElse(Visit visit, TIntermIfElse *) override;
bool visitSwitch(Visit, TIntermSwitch *) override; bool visitSwitch(Visit, TIntermSwitch *) override;
bool visitCase(Visit, TIntermCase *node) override; bool visitCase(Visit, TIntermCase *node) override;
bool visitAggregate(Visit, TIntermAggregate *) override; bool visitAggregate(Visit, TIntermAggregate *) override;
......
...@@ -1334,7 +1334,7 @@ expression_statement ...@@ -1334,7 +1334,7 @@ expression_statement
selection_statement selection_statement
: IF LEFT_PAREN expression RIGHT_PAREN selection_rest_statement { : IF LEFT_PAREN expression RIGHT_PAREN selection_rest_statement {
context->checkIsScalarBool(@1, $3); context->checkIsScalarBool(@1, $3);
$$ = context->intermediate.addSelection($3, $5, @1); $$ = context->intermediate.addIfElse($3, $5, @1);
} }
; ;
......
...@@ -4400,7 +4400,7 @@ yyreduce: ...@@ -4400,7 +4400,7 @@ yyreduce:
{ {
context->checkIsScalarBool((yylsp[-4]), (yyvsp[-2].interm.intermTypedNode)); context->checkIsScalarBool((yylsp[-4]), (yyvsp[-2].interm.intermTypedNode));
(yyval.interm.intermNode) = context->intermediate.addSelection((yyvsp[-2].interm.intermTypedNode), (yyvsp[0].interm.nodePair), (yylsp[-4])); (yyval.interm.intermNode) = context->intermediate.addIfElse((yyvsp[-2].interm.intermTypedNode), (yyvsp[0].interm.nodePair), (yylsp[-4]));
} }
break; break;
......
...@@ -45,7 +45,7 @@ class TOutputTraverser : public TIntermTraverser ...@@ -45,7 +45,7 @@ class TOutputTraverser : public TIntermTraverser
bool visitBinary(Visit visit, TIntermBinary *) override; bool visitBinary(Visit visit, TIntermBinary *) override;
bool visitUnary(Visit visit, TIntermUnary *) override; bool visitUnary(Visit visit, TIntermUnary *) override;
bool visitTernary(Visit visit, TIntermTernary *node) override; bool visitTernary(Visit visit, TIntermTernary *node) override;
bool visitSelection(Visit visit, TIntermSelection *) override; bool visitIfElse(Visit visit, TIntermIfElse *node) override;
bool visitAggregate(Visit visit, TIntermAggregate *) override; bool visitAggregate(Visit visit, TIntermAggregate *) override;
bool visitLoop(Visit visit, TIntermLoop *) override; bool visitLoop(Visit visit, TIntermLoop *) override;
bool visitBranch(Visit visit, TIntermBranch *) override; bool visitBranch(Visit visit, TIntermBranch *) override;
...@@ -492,7 +492,7 @@ bool TOutputTraverser::visitTernary(Visit visit, TIntermTernary *node) ...@@ -492,7 +492,7 @@ bool TOutputTraverser::visitTernary(Visit visit, TIntermTernary *node)
return false; return false;
} }
bool TOutputTraverser::visitSelection(Visit visit, TIntermSelection *node) bool TOutputTraverser::visitIfElse(Visit visit, TIntermIfElse *node)
{ {
TInfoSinkBase &out = sink; TInfoSinkBase &out = sink;
......
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