Interpreter: Simplify interface quite a bit.
Slightly sharper, but far easier to hold:
- Remove Value union from interface, everything is a 32-bit
value type, or a collection thereof.
- Collapse to one version of Run (that takes count), and make
it a member on ByteCode.
- Similarly, move disassemble to ByteCodeFunction.
Change-Id: I07c85e65991178b3f52e20e815c25f36bc9c4257
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/220753
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
diff --git a/src/sksl/SkSLByteCodeGenerator.cpp b/src/sksl/SkSLByteCodeGenerator.cpp
index 13ffc9e..9d779f2 100644
--- a/src/sksl/SkSLByteCodeGenerator.cpp
+++ b/src/sksl/SkSLByteCodeGenerator.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "include/private/SkFloatBits.h"
#include "src/sksl/SkSLByteCodeGenerator.h"
-#include "src/sksl/SkSLInterpreter.h"
#include <algorithm>
@@ -591,7 +591,7 @@
void ByteCodeGenerator::writeFloatLiteral(const FloatLiteral& f) {
this->write(ByteCodeInstruction::kPushImmediate);
- this->write32(Interpreter::Value((float) f.fValue).fUnsigned);
+ this->write32(SkFloat2Bits(f.fValue));
}
void ByteCodeGenerator::writeIntrinsicCall(const FunctionCall& c) {
@@ -659,8 +659,7 @@
std::unique_ptr<LValue> lvalue = this->getLValue(*p.fOperand);
lvalue->load();
this->write(ByteCodeInstruction::kPushImmediate);
- this->write32(type_category(p.fType) == TypeCategory::kFloat
- ? Interpreter::Value(1.0f).fUnsigned : 1);
+ this->write32(type_category(p.fType) == TypeCategory::kFloat ? SkFloat2Bits(1.0f) : 1);
if (p.fOperator == Token::Kind::PLUSPLUS) {
this->writeTypedInstruction(p.fType,
ByteCodeInstruction::kAddI,
@@ -704,8 +703,7 @@
this->write(ByteCodeInstruction::kDup);
}
this->write(ByteCodeInstruction::kPushImmediate);
- this->write32(type_category(p.fType) == TypeCategory::kFloat
- ? Interpreter::Value(1.0f).fUnsigned : 1);
+ this->write32(type_category(p.fType) == TypeCategory::kFloat ? SkFloat2Bits(1.0f) : 1);
if (p.fOperator == Token::Kind::PLUSPLUS) {
this->writeTypedInstruction(p.fType,
ByteCodeInstruction::kAddI,