summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/angle/src/compiler/translator/RemovePow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/angle/src/compiler/translator/RemovePow.cpp')
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RemovePow.cpp36
1 files changed, 14 insertions, 22 deletions
diff --git a/src/3rdparty/angle/src/compiler/translator/RemovePow.cpp b/src/3rdparty/angle/src/compiler/translator/RemovePow.cpp
index 6dbb48da9c..b2cdac55f0 100644
--- a/src/3rdparty/angle/src/compiler/translator/RemovePow.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/RemovePow.cpp
@@ -11,7 +11,10 @@
#include "compiler/translator/RemovePow.h"
#include "compiler/translator/InfoSink.h"
-#include "compiler/translator/IntermNode.h"
+#include "compiler/translator/IntermTraverse.h"
+
+namespace sh
+{
namespace
{
@@ -43,8 +46,7 @@ class RemovePowTraverser : public TIntermTraverser
};
RemovePowTraverser::RemovePowTraverser()
- : TIntermTraverser(true, false, false),
- mNeedAnotherIteration(false)
+ : TIntermTraverser(true, false, false), mNeedAnotherIteration(false)
{
}
@@ -52,31 +54,20 @@ bool RemovePowTraverser::visitAggregate(Visit visit, TIntermAggregate *node)
{
if (IsProblematicPow(node))
{
- TInfoSink nullSink;
-
TIntermTyped *x = node->getSequence()->at(0)->getAsTyped();
TIntermTyped *y = node->getSequence()->at(1)->getAsTyped();
- TIntermUnary *log = new TIntermUnary(EOpLog2);
- log->setOperand(x);
+ TIntermUnary *log = new TIntermUnary(EOpLog2, x);
log->setLine(node->getLine());
- log->setType(x->getType());
- TIntermBinary *mul = new TIntermBinary(EOpMul);
- mul->setLeft(y);
- mul->setRight(log);
+ TOperator op = TIntermBinary::GetMulOpBasedOnOperands(y->getType(), log->getType());
+ TIntermBinary *mul = new TIntermBinary(op, y, log);
mul->setLine(node->getLine());
- bool valid = mul->promote(nullSink);
- UNUSED_ASSERTION_VARIABLE(valid);
- ASSERT(valid);
- TIntermUnary *exp = new TIntermUnary(EOpExp2);
- exp->setOperand(mul);
+ TIntermUnary *exp = new TIntermUnary(EOpExp2, mul);
exp->setLine(node->getLine());
- exp->setType(node->getType());
- NodeUpdateEntry replacePow(getParentNode(), node, exp, false);
- mReplacements.push_back(replacePow);
+ queueReplacement(exp, OriginalNode::IS_DROPPED);
// If the x parameter also needs to be replaced, we need to do that in another traversal,
// since it's parent node will change in a way that's not handled correctly by updateTree().
@@ -89,7 +80,7 @@ bool RemovePowTraverser::visitAggregate(Visit visit, TIntermAggregate *node)
return true;
}
-} // namespace
+} // namespace
void RemovePow(TIntermNode *root)
{
@@ -100,6 +91,7 @@ void RemovePow(TIntermNode *root)
traverser.nextIteration();
root->traverse(&traverser);
traverser.updateTree();
- }
- while (traverser.needAnotherIteration());
+ } while (traverser.needAnotherIteration());
}
+
+} // namespace sh