Reland "Revert "moved BinaryExpression's data into IRNode""
This reverts commit 1d3e0e0054b243b7a62029c29090e7e76a19a805.
Reason for revert: possibly causing https://task-scheduler.skia.org/task/F1DoniJAddPuEkH9ETTE
Original change's description:
> Revert "Revert "moved BinaryExpression's data into IRNode""
>
> This reverts commit b61c3a9a01c44840eaa35b28cae0a4b358727f3c.
>
> Change-Id: I4689e1f4977fab3233ff492cee06fbc301b5c689
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/317386
> Reviewed-by: John Stiles <johnstiles@google.com>
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com
# Not skipping CQ checks because this is a reland.
Change-Id: Id0f3f211f09fbf31b626c648ed141fc6154a450c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/317395
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
diff --git a/src/sksl/SkSLSPIRVCodeGenerator.cpp b/src/sksl/SkSLSPIRVCodeGenerator.cpp
index 6e07dfb..ab3d709 100644
--- a/src/sksl/SkSLSPIRVCodeGenerator.cpp
+++ b/src/sksl/SkSLSPIRVCodeGenerator.cpp
@@ -2302,14 +2302,11 @@
}
SpvId SPIRVCodeGenerator::writeBinaryExpression(const BinaryExpression& b, OutputStream& out) {
- const Expression& left = b.left();
- const Expression& right = b.right();
- Token::Kind op = b.getOperator();
// handle cases where we don't necessarily evaluate both LHS and RHS
- switch (op) {
+ switch (b.fOperator) {
case Token::Kind::TK_EQ: {
- SpvId rhs = this->writeExpression(right, out);
- this->getLValue(left, out)->store(rhs, out);
+ SpvId rhs = this->writeExpression(*b.fRight, out);
+ this->getLValue(*b.fLeft, out)->store(rhs, out);
return rhs;
}
case Token::Kind::TK_LOGICALAND:
@@ -2322,16 +2319,17 @@
std::unique_ptr<LValue> lvalue;
SpvId lhs;
- if (Compiler::IsAssignment(op)) {
- lvalue = this->getLValue(left, out);
+ if (Compiler::IsAssignment(b.fOperator)) {
+ lvalue = this->getLValue(*b.fLeft, out);
lhs = lvalue->load(out);
} else {
lvalue = nullptr;
- lhs = this->writeExpression(left, out);
+ lhs = this->writeExpression(*b.fLeft, out);
}
- SpvId rhs = this->writeExpression(right, out);
- SpvId result = this->writeBinaryExpression(left.type(), lhs, Compiler::RemoveAssignment(op),
- right.type(), rhs, b.type(), out);
+ SpvId rhs = this->writeExpression(*b.fRight, out);
+ SpvId result = this->writeBinaryExpression(b.fLeft->type(), lhs,
+ Compiler::RemoveAssignment(b.fOperator),
+ b.fRight->type(), rhs, b.type(), out);
if (lvalue) {
lvalue->store(result, out);
}
@@ -2339,17 +2337,17 @@
}
SpvId SPIRVCodeGenerator::writeLogicalAnd(const BinaryExpression& a, OutputStream& out) {
- SkASSERT(a.getOperator() == Token::Kind::TK_LOGICALAND);
+ SkASSERT(a.fOperator == Token::Kind::TK_LOGICALAND);
BoolLiteral falseLiteral(fContext, -1, false);
SpvId falseConstant = this->writeBoolLiteral(falseLiteral);
- SpvId lhs = this->writeExpression(a.left(), out);
+ SpvId lhs = this->writeExpression(*a.fLeft, out);
SpvId rhsLabel = this->nextId();
SpvId end = this->nextId();
SpvId lhsBlock = fCurrentBlock;
this->writeInstruction(SpvOpSelectionMerge, end, SpvSelectionControlMaskNone, out);
this->writeInstruction(SpvOpBranchConditional, lhs, rhsLabel, end, out);
this->writeLabel(rhsLabel, out);
- SpvId rhs = this->writeExpression(a.right(), out);
+ SpvId rhs = this->writeExpression(*a.fRight, out);
SpvId rhsBlock = fCurrentBlock;
this->writeInstruction(SpvOpBranch, end, out);
this->writeLabel(end, out);
@@ -2360,17 +2358,17 @@
}
SpvId SPIRVCodeGenerator::writeLogicalOr(const BinaryExpression& o, OutputStream& out) {
- SkASSERT(o.getOperator() == Token::Kind::TK_LOGICALOR);
+ SkASSERT(o.fOperator == Token::Kind::TK_LOGICALOR);
BoolLiteral trueLiteral(fContext, -1, true);
SpvId trueConstant = this->writeBoolLiteral(trueLiteral);
- SpvId lhs = this->writeExpression(o.left(), out);
+ SpvId lhs = this->writeExpression(*o.fLeft, out);
SpvId rhsLabel = this->nextId();
SpvId end = this->nextId();
SpvId lhsBlock = fCurrentBlock;
this->writeInstruction(SpvOpSelectionMerge, end, SpvSelectionControlMaskNone, out);
this->writeInstruction(SpvOpBranchConditional, lhs, end, rhsLabel, out);
this->writeLabel(rhsLabel, out);
- SpvId rhs = this->writeExpression(o.right(), out);
+ SpvId rhs = this->writeExpression(*o.fRight, out);
SpvId rhsBlock = fCurrentBlock;
this->writeInstruction(SpvOpBranch, end, out);
this->writeLabel(end, out);