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/SkSLByteCodeGenerator.cpp b/src/sksl/SkSLByteCodeGenerator.cpp
index 1e9dab0..a213ca4 100644
--- a/src/sksl/SkSLByteCodeGenerator.cpp
+++ b/src/sksl/SkSLByteCodeGenerator.cpp
@@ -681,29 +681,28 @@
}
bool ByteCodeGenerator::writeBinaryExpression(const BinaryExpression& b, bool discard) {
- const Expression& left = b.left();
- const Expression& right = b.right();
- Token::Kind op = b.getOperator();
- if (op == Token::Kind::TK_EQ) {
- std::unique_ptr<LValue> lvalue = this->getLValue(left);
- this->writeExpression(right);
+ if (b.fOperator == Token::Kind::TK_EQ) {
+ std::unique_ptr<LValue> lvalue = this->getLValue(*b.fLeft);
+ this->writeExpression(*b.fRight);
lvalue->store(discard);
discard = false;
return discard;
}
- const Type& lType = left.type();
- const Type& rType = right.type();
+ const Type& lType = b.fLeft->type();
+ const Type& rType = b.fRight->type();
bool lVecOrMtx = (lType.typeKind() == Type::TypeKind::kVector ||
lType.typeKind() == Type::TypeKind::kMatrix);
bool rVecOrMtx = (rType.typeKind() == Type::TypeKind::kVector ||
rType.typeKind() == Type::TypeKind::kMatrix);
+ Token::Kind op;
std::unique_ptr<LValue> lvalue;
- if (Compiler::IsAssignment(op)) {
- lvalue = this->getLValue(left);
+ if (Compiler::IsAssignment(b.fOperator)) {
+ lvalue = this->getLValue(*b.fLeft);
lvalue->load();
- op = Compiler::RemoveAssignment(op);
+ op = Compiler::RemoveAssignment(b.fOperator);
} else {
- this->writeExpression(left);
+ this->writeExpression(*b.fLeft);
+ op = b.fOperator;
if (!lVecOrMtx && rVecOrMtx) {
for (int i = SlotCount(rType); i > 1; --i) {
this->write(ByteCodeInstruction::kDup, 1);
@@ -719,7 +718,7 @@
this->write(ByteCodeInstruction::kMaskPush);
this->write(ByteCodeInstruction::kBranchIfAllFalse);
DeferredLocation falseLocation(this);
- this->writeExpression(right);
+ this->writeExpression(*b.fRight);
this->write(ByteCodeInstruction::kAndB, 1);
falseLocation.set();
this->write(ByteCodeInstruction::kMaskPop);
@@ -732,7 +731,7 @@
this->write(ByteCodeInstruction::kMaskPush);
this->write(ByteCodeInstruction::kBranchIfAllFalse);
DeferredLocation falseLocation(this);
- this->writeExpression(right);
+ this->writeExpression(*b.fRight);
this->write(ByteCodeInstruction::kOrB, 1);
falseLocation.set();
this->write(ByteCodeInstruction::kMaskPop);
@@ -742,13 +741,13 @@
case Token::Kind::TK_SHR: {
SkASSERT(count == 1 && (tc == SkSL::TypeCategory::kSigned ||
tc == SkSL::TypeCategory::kUnsigned));
- if (!right.isCompileTimeConstant()) {
- fErrors.error(right.fOffset, "Shift amounts must be constant");
+ if (!b.fRight->isCompileTimeConstant()) {
+ fErrors.error(b.fRight->fOffset, "Shift amounts must be constant");
return false;
}
- int64_t shift = right.getConstantInt();
+ int64_t shift = b.fRight->getConstantInt();
if (shift < 0 || shift > 31) {
- fErrors.error(right.fOffset, "Shift amount out of range");
+ fErrors.error(b.fRight->fOffset, "Shift amount out of range");
return false;
}
@@ -766,7 +765,7 @@
default:
break;
}
- this->writeExpression(right);
+ this->writeExpression(*b.fRight);
if (lVecOrMtx && !rVecOrMtx) {
for (int i = SlotCount(lType); i > 1; --i) {
this->write(ByteCodeInstruction::kDup, 1);