Revert "moved SkSL FloatLiteral data into IRNode"

This reverts commit 135e2376563205533c4638a4ef15816b4eb022c1.

No-Tree-Checks: true
Change-Id: I7e9dd2148f7b2a8dee1e49a9a9cc593e0d7ceb6e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/321460
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/src/gpu/effects/generated/GrHSLToRGBFilterEffect.cpp b/src/gpu/effects/generated/GrHSLToRGBFilterEffect.cpp
index a0bbe8f..48100fd 100644
--- a/src/gpu/effects/generated/GrHSLToRGBFilterEffect.cpp
+++ b/src/gpu/effects/generated/GrHSLToRGBFilterEffect.cpp
@@ -29,7 +29,7 @@
                 R"SkSL(half4 inputColor = %s;
 half3 hsl = inputColor.xyz;
 half C = (1.0 - abs(2.0 * hsl.z - 1.0)) * hsl.y;
-half3 p = hsl.xxx + half3(0.0, 0.66666668653488159, 0.3333333432674408);
+half3 p = hsl.xxx + half3(0.0, 0.66666666666666663, 0.33333333333333331);
 half3 q = clamp(abs(fract(p) * 6.0 - 3.0) - 1.0, 0.0, 1.0);
 half3 rgb = (q - 0.5) * C + hsl.z;
 %s = clamp(half4(rgb, inputColor.w), 0.0, 1.0);
diff --git a/src/gpu/effects/generated/GrHighContrastFilterEffect.cpp b/src/gpu/effects/generated/GrHighContrastFilterEffect.cpp
index f00f0ba..cca3d7c 100644
--- a/src/gpu/effects/generated/GrHighContrastFilterEffect.cpp
+++ b/src/gpu/effects/generated/GrHighContrastFilterEffect.cpp
@@ -45,7 +45,7 @@
         fragBuilder->emitFunction(kHalf_GrSLType, "HSLToRGB", 3, HSLToRGB_args,
                                   R"SkSL(if (t < 0.0) t += 1.0;
 if (t > 1.0) t -= 1.0;
-return t < 0.1666666716337204 ? p + ((q - p) * 6.0) * t : (t < 0.5 ? q : (t < 0.66666668653488159 ? p + ((q - p) * (0.66666668653488159 - t)) * 6.0 : p));
+return t < 0.16666666666666666 ? p + ((q - p) * 6.0) * t : (t < 0.5 ? q : (t < 0.66666666666666663 ? p + ((q - p) * (0.66666666666666663 - t)) * 6.0 : p));
 )SkSL",
                                   &HSLToRGB_name);
         SkString _sample896 = this->invokeChild(0, args);
@@ -87,7 +87,7 @@
         } else {
             h = (color.x - color.y) / d + 4.0;
         }
-        h *= 0.1666666716337204;
+        h *= 0.16666666666666666;
     }
     l = 1.0 + l * -0.5;
     if (s == 0.0) {
@@ -95,9 +95,9 @@
     } else {
         half q = l < 0.5 ? l * (1.0 + s) : (l + s) - l * s;
         half p = 2.0 * l - q;
-        color.x = %s(p, q, h + 0.3333333432674408);
+        color.x = %s(p, q, h + 0.33333333333333331);
         color.y = %s(p, q, h);
-        color.z = %s(p, q, h - 0.3333333432674408);
+        color.z = %s(p, q, h - 0.33333333333333331);
     }
 }
 @if (%s) {
diff --git a/src/gpu/effects/generated/GrRGBToHSLFilterEffect.cpp b/src/gpu/effects/generated/GrRGBToHSLFilterEffect.cpp
index 5dbe823..bf18ed2 100644
--- a/src/gpu/effects/generated/GrRGBToHSLFilterEffect.cpp
+++ b/src/gpu/effects/generated/GrRGBToHSLFilterEffect.cpp
@@ -27,7 +27,7 @@
         SkString _sample1173 = this->invokeChild(0, args);
         fragBuilder->codeAppendf(
                 R"SkSL(half4 c = %s;
-half4 p = c.y < c.z ? half4(c.zy, -1.0, 0.66666668653488159) : half4(c.yz, 0.0, -0.3333333432674408);
+half4 p = c.y < c.z ? half4(c.zy, -1.0, 0.66666666666666663) : half4(c.yz, 0.0, -0.33333333333333331);
 half4 q = c.x < p.x ? half4(p.x, c.x, p.yw) : half4(c.x, p.x, p.yz);
 
 half pmV = q.x;
diff --git a/src/sksl/SkSLByteCodeGenerator.cpp b/src/sksl/SkSLByteCodeGenerator.cpp
index 7946c3c..231abf9 100644
--- a/src/sksl/SkSLByteCodeGenerator.cpp
+++ b/src/sksl/SkSLByteCodeGenerator.cpp
@@ -1022,7 +1022,7 @@
 
 void ByteCodeGenerator::writeFloatLiteral(const FloatLiteral& f) {
     this->write(ByteCodeInstruction::kPushImmediate);
-    this->write32(float_to_bits(f.value()));
+    this->write32(float_to_bits(f.fValue));
 }
 
 static bool is_generic_type(const Type* type, const Type* generic) {
diff --git a/src/sksl/SkSLCompiler.cpp b/src/sksl/SkSLCompiler.cpp
index b757c8d..843a581 100644
--- a/src/sksl/SkSLCompiler.cpp
+++ b/src/sksl/SkSLCompiler.cpp
@@ -652,14 +652,14 @@
  * Returns true if the expression is a constant numeric literal with the specified value, or a
  * constant vector with all elements equal to the specified value.
  */
-template <typename T = SKSL_FLOAT>
+template <typename T = double>
 static bool is_constant(const Expression& expr, T value) {
     switch (expr.kind()) {
         case Expression::Kind::kIntLiteral:
             return expr.as<IntLiteral>().value() == value;
 
         case Expression::Kind::kFloatLiteral:
-            return expr.as<FloatLiteral>().value() == value;
+            return expr.as<FloatLiteral>().fValue == value;
 
         case Expression::Kind::kConstructor: {
             const Constructor& constructor = expr.as<Constructor>();
diff --git a/src/sksl/SkSLDehydrator.cpp b/src/sksl/SkSLDehydrator.cpp
index f70dc7e..d035b53 100644
--- a/src/sksl/SkSLDehydrator.cpp
+++ b/src/sksl/SkSLDehydrator.cpp
@@ -298,7 +298,7 @@
                 const FloatLiteral& f = e->as<FloatLiteral>();
                 this->writeU8(Rehydrator::kFloatLiteral_Command);
                 FloatIntUnion u;
-                u.fFloat = f.value();
+                u.fFloat = f.fValue;
                 this->writeS32(u.fInt);
                 break;
             }
diff --git a/src/sksl/SkSLGLSLCodeGenerator.cpp b/src/sksl/SkSLGLSLCodeGenerator.cpp
index 93b3413..2d269f1 100644
--- a/src/sksl/SkSLGLSLCodeGenerator.cpp
+++ b/src/sksl/SkSLGLSLCodeGenerator.cpp
@@ -1025,7 +1025,7 @@
 }
 
 void GLSLCodeGenerator::writeFloatLiteral(const FloatLiteral& f) {
-    this->write(to_string(f.value()));
+    this->write(to_string(f.fValue));
 }
 
 void GLSLCodeGenerator::writeSetting(const Setting& s) {
diff --git a/src/sksl/SkSLIRGenerator.cpp b/src/sksl/SkSLIRGenerator.cpp
index fa798ac..e1c640c 100644
--- a/src/sksl/SkSLIRGenerator.cpp
+++ b/src/sksl/SkSLIRGenerator.cpp
@@ -1828,8 +1828,8 @@
     }
     if (left.kind() == Expression::Kind::kFloatLiteral &&
         right.kind() == Expression::Kind::kFloatLiteral) {
-        SKSL_FLOAT leftVal  = left.as<FloatLiteral>().value();
-        SKSL_FLOAT rightVal = right.as<FloatLiteral>().value();
+        double leftVal  = left.as<FloatLiteral>().fValue;
+        double rightVal = right.as<FloatLiteral>().fValue;
         switch (op) {
             case Token::Kind::TK_PLUS:  return RESULT(Float, +);
             case Token::Kind::TK_MINUS: return RESULT(Float, -);
@@ -1856,8 +1856,8 @@
         std::vector<std::unique_ptr<Expression>> args;
         #define RETURN_VEC_COMPONENTWISE_RESULT(op)                              \
             for (int i = 0; i < leftType.columns(); i++) {                       \
-                SKSL_FLOAT value = left.getFVecComponent(i) op                        \
-                                   right.getFVecComponent(i);                         \
+                float value = left.getFVecComponent(i) op                        \
+                              right.getFVecComponent(i);                         \
                 args.emplace_back(new FloatLiteral(fContext, -1, value));        \
             }                                                                    \
             return std::unique_ptr<Expression>(new Constructor(-1, &leftType,    \
@@ -1879,7 +1879,7 @@
                         fErrors.error(right.fOffset, "division by zero");
                         return nullptr;
                     }
-                    SKSL_FLOAT value = left.getFVecComponent(i) / rvalue;
+                    float value = left.getFVecComponent(i) / rvalue;
                     args.emplace_back(new FloatLiteral(fContext, -1, value));
                 }
                 return std::unique_ptr<Expression>(new Constructor(-1, &leftType,
@@ -2231,12 +2231,12 @@
         return std::move(args[0]);
     }
     if (type.isFloat() && args.size() == 1 && args[0]->is<FloatLiteral>()) {
-        SKSL_FLOAT value = args[0]->as<FloatLiteral>().value();
+        double value = args[0]->as<FloatLiteral>().fValue;
         return std::make_unique<FloatLiteral>(offset, value, &type);
     }
     if (type.isFloat() && args.size() == 1 && args[0]->is<IntLiteral>()) {
         int64_t value = args[0]->as<IntLiteral>().value();
-        return std::make_unique<FloatLiteral>(offset, (float)value, &type);
+        return std::make_unique<FloatLiteral>(offset, (double)value, &type);
     }
     if (args[0]->is<IntLiteral>() && (type == *fContext.fInt_Type ||
                                       type == *fContext.fUInt_Type)) {
@@ -2373,7 +2373,7 @@
             }
             if (base->is<FloatLiteral>()) {
                 return std::make_unique<FloatLiteral>(fContext, base->fOffset,
-                                                      -base->as<FloatLiteral>().value());
+                                                      -base->as<FloatLiteral>().fValue);
             }
             if (!baseType.isNumber() && baseType.typeKind() != Type::TypeKind::kVector) {
                 fErrors.error(expression.fOffset,
diff --git a/src/sksl/SkSLMetalCodeGenerator.cpp b/src/sksl/SkSLMetalCodeGenerator.cpp
index 4542518..aca4ca6 100644
--- a/src/sksl/SkSLMetalCodeGenerator.cpp
+++ b/src/sksl/SkSLMetalCodeGenerator.cpp
@@ -919,7 +919,7 @@
 }
 
 void MetalCodeGenerator::writeFloatLiteral(const FloatLiteral& f) {
-    this->write(to_string(f.value()));
+    this->write(to_string(f.fValue));
 }
 
 void MetalCodeGenerator::writeSetting(const Setting& s) {
diff --git a/src/sksl/SkSLSPIRVCodeGenerator.cpp b/src/sksl/SkSLSPIRVCodeGenerator.cpp
index 81bcb1b..1cf94f4 100644
--- a/src/sksl/SkSLSPIRVCodeGenerator.cpp
+++ b/src/sksl/SkSLSPIRVCodeGenerator.cpp
@@ -2555,8 +2555,8 @@
     } else {
         constantType = ConstantType::kFloat;
     }
-    float value = (float) f.value();
-    std::pair<ConstantValue, ConstantType> key(f.value(), constantType);
+    float value = (float) f.fValue;
+    std::pair<ConstantValue, ConstantType> key(f.fValue, constantType);
     auto entry = fNumberConstants.find(key);
     if (entry == fNumberConstants.end()) {
         SpvId result = this->nextId();
diff --git a/src/sksl/SkSLSPIRVCodeGenerator.h b/src/sksl/SkSLSPIRVCodeGenerator.h
index 7c884eb..9bbc805 100644
--- a/src/sksl/SkSLSPIRVCodeGenerator.h
+++ b/src/sksl/SkSLSPIRVCodeGenerator.h
@@ -47,15 +47,15 @@
     ConstantValue(int64_t i)
         : fInt(i) {}
 
-    ConstantValue(SKSL_FLOAT f)
-        : fFloat(f) {}
+    ConstantValue(double d)
+        : fDouble(d) {}
 
     bool operator==(const ConstantValue& other) const {
         return fInt == other.fInt;
     }
 
     int64_t fInt;
-    SKSL_FLOAT fFloat;
+    double fDouble;
 };
 
 enum class ConstantType {
diff --git a/src/sksl/ir/SkSLExpression.h b/src/sksl/ir/SkSLExpression.h
index c425180..96acf57 100644
--- a/src/sksl/ir/SkSLExpression.h
+++ b/src/sksl/ir/SkSLExpression.h
@@ -64,10 +64,6 @@
         : INHERITED(offset, (int) Kind::kIntLiteral, data) {
     }
 
-    Expression(int offset, FloatLiteralData data)
-        : INHERITED(offset, (int) Kind::kFloatLiteral, data) {
-    }
-
     Expression(int offset, Kind kind, ExternalValueData data)
         : INHERITED(offset, (int) kind, data) {
         SkASSERT(kind >= Kind::kFirst && kind <= Kind::kLast);
@@ -140,7 +136,7 @@
      * For an expression which evaluates to a constant float, returns the value. Otherwise calls
      * ABORT.
      */
-    virtual SKSL_FLOAT getConstantFloat() const {
+    virtual double getConstantFloat() const {
         ABORT("not a constant float");
     }
 
diff --git a/src/sksl/ir/SkSLFloatLiteral.h b/src/sksl/ir/SkSLFloatLiteral.h
index ee68908..1a0ca30 100644
--- a/src/sksl/ir/SkSLFloatLiteral.h
+++ b/src/sksl/ir/SkSLFloatLiteral.h
@@ -19,18 +19,16 @@
 struct FloatLiteral : public Expression {
     static constexpr Kind kExpressionKind = Kind::kFloatLiteral;
 
-    FloatLiteral(const Context& context, int offset, float value)
-    : INHERITED(offset, FloatLiteralData{context.fFloatLiteral_Type.get(), value}) {}
+    FloatLiteral(const Context& context, int offset, double value)
+    : INHERITED(offset, kExpressionKind, context.fFloatLiteral_Type.get())
+    , fValue(value) {}
 
-    FloatLiteral(int offset, float value, const Type* type)
-    : INHERITED(offset, FloatLiteralData{type, value}) {}
-
-    float value() const {
-        return this->floatLiteralData().fValue;
-    }
+    FloatLiteral(int offset, double value, const Type* type)
+    : INHERITED(offset, kExpressionKind, type)
+    , fValue(value) {}
 
     String description() const override {
-        return to_string(this->value());
+        return to_string(fValue);
     }
 
     bool hasProperty(Property property) const override {
@@ -49,18 +47,19 @@
     }
 
     bool compareConstant(const Context& context, const Expression& other) const override {
-        return this->value() == other.as<FloatLiteral>().value();
+        return fValue == other.as<FloatLiteral>().fValue;
     }
 
-    SKSL_FLOAT getConstantFloat() const override {
-        return this->value();
+    double getConstantFloat() const override {
+        return fValue;
     }
 
     std::unique_ptr<Expression> clone() const override {
-        return std::unique_ptr<Expression>(new FloatLiteral(fOffset, this->value(), &this->type()));
+        return std::unique_ptr<Expression>(new FloatLiteral(fOffset, fValue, &this->type()));
     }
 
-private:
+    const double fValue;
+
     using INHERITED = Expression;
 };
 
diff --git a/src/sksl/ir/SkSLIRNode.cpp b/src/sksl/ir/SkSLIRNode.cpp
index 6783681..17b7683 100644
--- a/src/sksl/ir/SkSLIRNode.cpp
+++ b/src/sksl/ir/SkSLIRNode.cpp
@@ -38,11 +38,6 @@
 , fKind(kind)
 , fData(data) {}
 
-IRNode::IRNode(int offset, int kind, const FloatLiteralData& data)
-: fOffset(offset)
-, fKind(kind)
-, fData(data) {}
-
 IRNode::IRNode(int offset, int kind, const String& data)
 : fOffset(offset)
 , fKind(kind)
diff --git a/src/sksl/ir/SkSLIRNode.h b/src/sksl/ir/SkSLIRNode.h
index 9e5e676..2cf5e99 100644
--- a/src/sksl/ir/SkSLIRNode.h
+++ b/src/sksl/ir/SkSLIRNode.h
@@ -57,8 +57,6 @@
                 return *this->externalValueData().fType;
             case NodeData::Kind::kIntLiteral:
                 return *this->intLiteralData().fType;
-            case NodeData::Kind::kFloatLiteral:
-                return *this->floatLiteralData().fType;
             case NodeData::Kind::kType:
                 return *this->typeData();
             case NodeData::Kind::kTypeToken:
@@ -93,11 +91,6 @@
         const ExternalValue* fValue;
     };
 
-    struct FloatLiteralData {
-        const Type* fType;
-        float fValue;
-    };
-
     struct IntLiteralData {
         const Type* fType;
         int64_t fValue;
@@ -114,7 +107,6 @@
             kBoolLiteral,
             kEnum,
             kExternalValue,
-            kFloatLiteral,
             kIntLiteral,
             kString,
             kType,
@@ -127,7 +119,6 @@
             BoolLiteralData fBoolLiteral;
             EnumData fEnum;
             ExternalValueData fExternalValue;
-            FloatLiteralData fFloatLiteral;
             IntLiteralData fIntLiteral;
             String fString;
             const Type* fType;
@@ -158,11 +149,6 @@
             *(new(&fContents) ExternalValueData) = data;
         }
 
-        NodeData(const FloatLiteralData& data)
-            : fKind(Kind::kFloatLiteral) {
-            *(new(&fContents) FloatLiteralData) = data;
-        }
-
         NodeData(IntLiteralData data)
             : fKind(Kind::kIntLiteral) {
             *(new(&fContents) IntLiteralData) = data;
@@ -203,9 +189,6 @@
                 case Kind::kExternalValue:
                     *(new(&fContents) ExternalValueData) = other.fContents.fExternalValue;
                     break;
-                case Kind::kFloatLiteral:
-                    *(new(&fContents) FloatLiteralData) = other.fContents.fFloatLiteral;
-                    break;
                 case Kind::kIntLiteral:
                     *(new(&fContents) IntLiteralData) = other.fContents.fIntLiteral;
                     break;
@@ -241,9 +224,6 @@
                 case Kind::kExternalValue:
                     fContents.fExternalValue.~ExternalValueData();
                     break;
-                case Kind::kFloatLiteral:
-                    fContents.fFloatLiteral.~FloatLiteralData();
-                    break;
                 case Kind::kIntLiteral:
                     fContents.fIntLiteral.~IntLiteralData();
                     break;
@@ -270,8 +250,6 @@
 
     IRNode(int offset, int kind, const IntLiteralData& data);
 
-    IRNode(int offset, int kind, const FloatLiteralData& data);
-
     IRNode(int offset, int kind, const String& data);
 
     IRNode(int offset, int kind, const Type* data = nullptr);
@@ -344,11 +322,6 @@
         return fData.fContents.fExternalValue;
     }
 
-    const FloatLiteralData& floatLiteralData() const {
-        SkASSERT(fData.fKind == NodeData::Kind::kFloatLiteral);
-        return fData.fContents.fFloatLiteral;
-    }
-
     const IntLiteralData& intLiteralData() const {
         SkASSERT(fData.fKind == NodeData::Kind::kIntLiteral);
         return fData.fContents.fIntLiteral;
diff --git a/src/sksl/ir/SkSLPrefixExpression.h b/src/sksl/ir/SkSLPrefixExpression.h
index 383abf5..8bc72b7 100644
--- a/src/sksl/ir/SkSLPrefixExpression.h
+++ b/src/sksl/ir/SkSLPrefixExpression.h
@@ -43,9 +43,9 @@
                                                   const DefinitionMap& definitions) override {
         if (fOperand->kind() == Expression::Kind::kFloatLiteral) {
             return std::unique_ptr<Expression>(new FloatLiteral(
-                                                            irGenerator.fContext,
-                                                            fOffset,
-                                                            -fOperand->as<FloatLiteral>().value()));
+                                                             irGenerator.fContext,
+                                                             fOffset,
+                                                             -fOperand->as<FloatLiteral>().fValue));
 
         }
         return nullptr;
diff --git a/src/sksl/ir/SkSLSwizzle.h b/src/sksl/ir/SkSLSwizzle.h
index a4ff1f1..fc667ea 100644
--- a/src/sksl/ir/SkSLSwizzle.h
+++ b/src/sksl/ir/SkSLSwizzle.h
@@ -45,7 +45,7 @@
                                                         value);
                 } else if (type.isFloat()) {
                     SkASSERT(fComponents.size() == 1);
-                    SKSL_FLOAT value = constructor.getFVecComponent(fComponents[0]);
+                    double value = constructor.getFVecComponent(fComponents[0]);
                     return std::make_unique<FloatLiteral>(irGenerator.fContext, constructor.fOffset,
                                                           value);
                 }