Rename composite constructors to compound constructors.

Change-Id: Ic1f5d28651e8de9d9ecea2a0bcfa73063dd90a9d
Bug: skia:11032
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/393337
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
This commit is contained in:
John Stiles 2021-04-07 12:31:13 -04:00 committed by Skia Commit-Bot
parent 8317d0b775
commit 8cad6374f0
21 changed files with 117 additions and 119 deletions

View File

@ -96,10 +96,10 @@ skia_sksl_sources = [
"$_src/sksl/ir/SkSLConstructor.h",
"$_src/sksl/ir/SkSLConstructorArray.cpp",
"$_src/sksl/ir/SkSLConstructorArray.h",
"$_src/sksl/ir/SkSLConstructorComposite.cpp",
"$_src/sksl/ir/SkSLConstructorComposite.h",
"$_src/sksl/ir/SkSLConstructorCompositeCast.cpp",
"$_src/sksl/ir/SkSLConstructorCompositeCast.h",
"$_src/sksl/ir/SkSLConstructorCompound.cpp",
"$_src/sksl/ir/SkSLConstructorCompound.h",
"$_src/sksl/ir/SkSLConstructorCompoundCast.cpp",
"$_src/sksl/ir/SkSLConstructorCompoundCast.h",
"$_src/sksl/ir/SkSLConstructorDiagonalMatrix.cpp",
"$_src/sksl/ir/SkSLConstructorDiagonalMatrix.h",
"$_src/sksl/ir/SkSLConstructorMatrixResize.cpp",

View File

@ -747,8 +747,8 @@ bool Analysis::IsSameExpressionTree(const Expression& left, const Expression& ri
return left.as<BoolLiteral>().value() == right.as<BoolLiteral>().value();
case Expression::Kind::kConstructorArray:
case Expression::Kind::kConstructorComposite:
case Expression::Kind::kConstructorCompositeCast:
case Expression::Kind::kConstructorCompound:
case Expression::Kind::kConstructorCompoundCast:
case Expression::Kind::kConstructorDiagonalMatrix:
case Expression::Kind::kConstructorMatrixResize:
case Expression::Kind::kConstructorScalarCast:
@ -1026,8 +1026,8 @@ public:
// ... expressions composed of both of the above
case Expression::Kind::kBinary:
case Expression::Kind::kConstructorArray:
case Expression::Kind::kConstructorComposite:
case Expression::Kind::kConstructorCompositeCast:
case Expression::Kind::kConstructorCompound:
case Expression::Kind::kConstructorCompoundCast:
case Expression::Kind::kConstructorDiagonalMatrix:
case Expression::Kind::kConstructorMatrixResize:
case Expression::Kind::kConstructorScalarCast:
@ -1154,8 +1154,8 @@ template <typename T> bool TProgramVisitor<T>::visitExpression(typename T::Expre
(b.right() && this->visitExpressionPtr(b.right()));
}
case Expression::Kind::kConstructorArray:
case Expression::Kind::kConstructorComposite:
case Expression::Kind::kConstructorCompositeCast:
case Expression::Kind::kConstructorCompound:
case Expression::Kind::kConstructorCompoundCast:
case Expression::Kind::kConstructorDiagonalMatrix:
case Expression::Kind::kConstructorMatrixResize:
case Expression::Kind::kConstructorScalarCast:

View File

@ -17,8 +17,8 @@
#include "src/sksl/ir/SkSLBreakStatement.h"
#include "src/sksl/ir/SkSLConstructor.h"
#include "src/sksl/ir/SkSLConstructorArray.h"
#include "src/sksl/ir/SkSLConstructorComposite.h"
#include "src/sksl/ir/SkSLConstructorCompositeCast.h"
#include "src/sksl/ir/SkSLConstructorCompound.h"
#include "src/sksl/ir/SkSLConstructorCompoundCast.h"
#include "src/sksl/ir/SkSLConstructorDiagonalMatrix.h"
#include "src/sksl/ir/SkSLConstructorMatrixResize.h"
#include "src/sksl/ir/SkSLConstructorScalarCast.h"
@ -294,16 +294,16 @@ void Dehydrator::write(const Expression* e) {
this->writeExpressionSpan(e->as<ConstructorArray>().argumentSpan());
break;
case Expression::Kind::kConstructorComposite:
this->writeCommand(Rehydrator::kConstructorComposite_Command);
case Expression::Kind::kConstructorCompound:
this->writeCommand(Rehydrator::kConstructorCompound_Command);
this->write(e->type());
this->writeExpressionSpan(e->as<ConstructorComposite>().argumentSpan());
this->writeExpressionSpan(e->as<ConstructorCompound>().argumentSpan());
break;
case Expression::Kind::kConstructorCompositeCast:
this->writeCommand(Rehydrator::kConstructorCompositeCast_Command);
case Expression::Kind::kConstructorCompoundCast:
this->writeCommand(Rehydrator::kConstructorCompoundCast_Command);
this->write(e->type());
this->writeExpressionSpan(e->as<ConstructorCompositeCast>().argumentSpan());
this->writeExpressionSpan(e->as<ConstructorCompoundCast>().argumentSpan());
break;
case Expression::Kind::kConstructorDiagonalMatrix:

View File

@ -197,14 +197,14 @@ void GLSLCodeGenerator::writeExpression(const Expression& expr, Precedence paren
this->writeBoolLiteral(expr.as<BoolLiteral>());
break;
case Expression::Kind::kConstructorArray:
case Expression::Kind::kConstructorComposite:
case Expression::Kind::kConstructorCompound:
case Expression::Kind::kConstructorDiagonalMatrix:
case Expression::Kind::kConstructorMatrixResize:
case Expression::Kind::kConstructorSplat:
this->writeAnyConstructor(expr.asAnyConstructor(), parentPrecedence);
break;
case Expression::Kind::kConstructorScalarCast:
case Expression::Kind::kConstructorCompositeCast:
case Expression::Kind::kConstructorCompoundCast:
this->writeCastConstructor(expr.asAnyConstructor(), parentPrecedence);
break;
case Expression::Kind::kIntLiteral:

View File

@ -18,8 +18,8 @@
#include "src/sksl/ir/SkSLBreakStatement.h"
#include "src/sksl/ir/SkSLConstructor.h"
#include "src/sksl/ir/SkSLConstructorArray.h"
#include "src/sksl/ir/SkSLConstructorComposite.h"
#include "src/sksl/ir/SkSLConstructorCompositeCast.h"
#include "src/sksl/ir/SkSLConstructorCompound.h"
#include "src/sksl/ir/SkSLConstructorCompoundCast.h"
#include "src/sksl/ir/SkSLConstructorDiagonalMatrix.h"
#include "src/sksl/ir/SkSLConstructorMatrixResize.h"
#include "src/sksl/ir/SkSLConstructorScalarCast.h"
@ -317,15 +317,15 @@ std::unique_ptr<Expression> Inliner::inlineExpression(int offset,
*ctor.type().clone(symbolTableForExpression),
argList(ctor.arguments()));
}
case Expression::Kind::kConstructorComposite: {
const ConstructorComposite& ctor = expression.as<ConstructorComposite>();
return ConstructorComposite::Make(*fContext, offset,
case Expression::Kind::kConstructorCompound: {
const ConstructorCompound& ctor = expression.as<ConstructorCompound>();
return ConstructorCompound::Make(*fContext, offset,
*ctor.type().clone(symbolTableForExpression),
argList(ctor.arguments()));
}
case Expression::Kind::kConstructorCompositeCast: {
const ConstructorCompositeCast& ctor = expression.as<ConstructorCompositeCast>();
return ConstructorCompositeCast::Make(*fContext, offset,
case Expression::Kind::kConstructorCompoundCast: {
const ConstructorCompoundCast& ctor = expression.as<ConstructorCompoundCast>();
return ConstructorCompoundCast::Make(*fContext, offset,
*ctor.type().clone(symbolTableForExpression),
expr(ctor.argument()));
}
@ -948,8 +948,8 @@ public:
break;
}
case Expression::Kind::kConstructorArray:
case Expression::Kind::kConstructorComposite:
case Expression::Kind::kConstructorCompositeCast:
case Expression::Kind::kConstructorCompound:
case Expression::Kind::kConstructorCompoundCast:
case Expression::Kind::kConstructorDiagonalMatrix:
case Expression::Kind::kConstructorMatrixResize:
case Expression::Kind::kConstructorScalarCast:

View File

@ -11,7 +11,7 @@
#include "src/sksl/SkSLCompiler.h"
#include "src/sksl/SkSLMemoryLayout.h"
#include "src/sksl/ir/SkSLConstructorArray.h"
#include "src/sksl/ir/SkSLConstructorCompositeCast.h"
#include "src/sksl/ir/SkSLConstructorCompoundCast.h"
#include "src/sksl/ir/SkSLConstructorDiagonalMatrix.h"
#include "src/sksl/ir/SkSLConstructorMatrixResize.h"
#include "src/sksl/ir/SkSLConstructorSplat.h"
@ -176,8 +176,8 @@ void MetalCodeGenerator::writeExpression(const Expression& expr, Precedence pare
case Expression::Kind::kConstructorArray:
this->writeAnyConstructor(expr.asAnyConstructor(), "{", "}", parentPrecedence);
break;
case Expression::Kind::kConstructorComposite:
this->writeConstructorComposite(expr.as<ConstructorComposite>(), parentPrecedence);
case Expression::Kind::kConstructorCompound:
this->writeConstructorCompound(expr.as<ConstructorCompound>(), parentPrecedence);
break;
case Expression::Kind::kConstructorDiagonalMatrix:
case Expression::Kind::kConstructorSplat:
@ -188,7 +188,7 @@ void MetalCodeGenerator::writeExpression(const Expression& expr, Precedence pare
parentPrecedence);
break;
case Expression::Kind::kConstructorScalarCast:
case Expression::Kind::kConstructorCompositeCast:
case Expression::Kind::kConstructorCompoundCast:
this->writeCastConstructor(expr.asAnyConstructor(), "(", ")", parentPrecedence);
break;
case Expression::Kind::kIntLiteral:
@ -1009,7 +1009,7 @@ bool MetalCodeGenerator::canCoerce(const Type& t1, const Type& t2) {
return t1.isFloat() && t2.isFloat();
}
bool MetalCodeGenerator::matrixConstructHelperIsNeeded(const ConstructorComposite& c) {
bool MetalCodeGenerator::matrixConstructHelperIsNeeded(const ConstructorCompound& c) {
SkASSERT(c.type().isMatrix());
// GLSL is fairly free-form about inputs to its matrix constructors, but Metal is not; it
@ -1063,17 +1063,17 @@ void MetalCodeGenerator::writeConstructorMatrixResize(const ConstructorMatrixRes
this->write(")");
}
void MetalCodeGenerator::writeConstructorComposite(const ConstructorComposite& c,
Precedence parentPrecedence) {
void MetalCodeGenerator::writeConstructorCompound(const ConstructorCompound& c,
Precedence parentPrecedence) {
if (c.type().isMatrix()) {
this->writeConstructorCompositeMatrix(c, parentPrecedence);
this->writeConstructorCompoundMatrix(c, parentPrecedence);
} else {
this->writeAnyConstructor(c, "(", ")", parentPrecedence);
}
}
void MetalCodeGenerator::writeConstructorCompositeMatrix(const ConstructorComposite& c,
Precedence parentPrecedence) {
void MetalCodeGenerator::writeConstructorCompoundMatrix(const ConstructorCompound& c,
Precedence parentPrecedence) {
// Emit and invoke a matrix-constructor helper method if one is necessary.
if (this->matrixConstructHelperIsNeeded(c)) {
this->write(this->getMatrixConstructHelper(c));
@ -2274,8 +2274,8 @@ MetalCodeGenerator::Requirements MetalCodeGenerator::requirements(const Expressi
}
return result;
}
case Expression::Kind::kConstructorComposite:
case Expression::Kind::kConstructorCompositeCast:
case Expression::Kind::kConstructorCompound:
case Expression::Kind::kConstructorCompoundCast:
case Expression::Kind::kConstructorArray:
case Expression::Kind::kConstructorDiagonalMatrix:
case Expression::Kind::kConstructorScalarCast:

View File

@ -22,7 +22,7 @@
#include "src/sksl/ir/SkSLBinaryExpression.h"
#include "src/sksl/ir/SkSLBoolLiteral.h"
#include "src/sksl/ir/SkSLConstructor.h"
#include "src/sksl/ir/SkSLConstructorComposite.h"
#include "src/sksl/ir/SkSLConstructorCompound.h"
#include "src/sksl/ir/SkSLConstructorMatrixResize.h"
#include "src/sksl/ir/SkSLDoStatement.h"
#include "src/sksl/ir/SkSLExtension.h"
@ -208,7 +208,7 @@ protected:
void writeFunctionCall(const FunctionCall& c);
bool matrixConstructHelperIsNeeded(const ConstructorComposite& c);
bool matrixConstructHelperIsNeeded(const ConstructorCompound& c);
String getMatrixConstructHelper(const AnyConstructor& c);
void assembleMatrixFromMatrix(const Type& sourceMatrix, int rows, int columns);
void assembleMatrixFromExpressions(const AnyConstructor& ctor, int rows, int columns);
@ -229,10 +229,9 @@ protected:
bool canCoerce(const Type& t1, const Type& t2);
void writeConstructorComposite(const ConstructorComposite& c, Precedence parentPrecedence);
void writeConstructorCompound(const ConstructorCompound& c, Precedence parentPrecedence);
void writeConstructorCompositeMatrix(const ConstructorComposite& c,
Precedence parentPrecedence);
void writeConstructorCompoundMatrix(const ConstructorCompound& c, Precedence parentPrecedence);
void writeConstructorMatrixResize(const ConstructorMatrixResize& c,
Precedence parentPrecedence);

View File

@ -409,8 +409,8 @@ void PipelineStageCodeGenerator::writeExpression(const Expression& expr,
this->write(expr.description());
break;
case Expression::Kind::kConstructorArray:
case Expression::Kind::kConstructorComposite:
case Expression::Kind::kConstructorCompositeCast:
case Expression::Kind::kConstructorCompound:
case Expression::Kind::kConstructorCompoundCast:
case Expression::Kind::kConstructorDiagonalMatrix:
case Expression::Kind::kConstructorMatrixResize:
case Expression::Kind::kConstructorScalarCast:

View File

@ -17,8 +17,8 @@
#include "src/sksl/ir/SkSLBreakStatement.h"
#include "src/sksl/ir/SkSLConstructor.h"
#include "src/sksl/ir/SkSLConstructorArray.h"
#include "src/sksl/ir/SkSLConstructorComposite.h"
#include "src/sksl/ir/SkSLConstructorCompositeCast.h"
#include "src/sksl/ir/SkSLConstructorCompound.h"
#include "src/sksl/ir/SkSLConstructorCompoundCast.h"
#include "src/sksl/ir/SkSLConstructorDiagonalMatrix.h"
#include "src/sksl/ir/SkSLConstructorMatrixResize.h"
#include "src/sksl/ir/SkSLConstructorScalarCast.h"
@ -461,9 +461,9 @@ std::unique_ptr<Expression> Rehydrator::expression() {
const Type* type = this->type();
return ConstructorArray::Make(fContext, /*offset=*/-1, *type, this->expressionArray());
}
case Rehydrator::kConstructorComposite_Command: {
case Rehydrator::kConstructorCompound_Command: {
const Type* type = this->type();
return ConstructorComposite::Make(fContext, /*offset=*/-1, *type,
return ConstructorCompound::Make(fContext, /*offset=*/-1, *type,
this->expressionArray());
}
case Rehydrator::kConstructorDiagonalMatrix_Command: {
@ -492,12 +492,11 @@ std::unique_ptr<Expression> Rehydrator::expression() {
SkASSERT(args.size() == 1);
return ConstructorSplat::Make(fContext, /*offset=*/-1, *type, std::move(args[0]));
}
case Rehydrator::kConstructorCompositeCast_Command: {
case Rehydrator::kConstructorCompoundCast_Command: {
const Type* type = this->type();
ExpressionArray args = this->expressionArray();
SkASSERT(args.size() == 1);
return ConstructorCompositeCast::Make(fContext, /*offset=*/-1, *type,
std::move(args[0]));
return ConstructorCompoundCast::Make(fContext,/*offset=*/-1, *type, std::move(args[0]));
}
case Rehydrator::kFieldAccess_Command: {
std::unique_ptr<Expression> base = this->expression();

View File

@ -51,8 +51,8 @@ public:
kBuiltinLayout_Command,
// (All constructors) Type type, uint8 argCount, Expression[] arguments
kConstructorArray_Command,
kConstructorComposite_Command,
kConstructorCompositeCast_Command,
kConstructorCompound_Command,
kConstructorCompoundCast_Command,
kConstructorDiagonalMatrix_Command,
kConstructorMatrixResize_Command,
kConstructorScalarCast_Command,

View File

@ -719,10 +719,10 @@ SpvId SPIRVCodeGenerator::writeExpression(const Expression& expr, OutputStream&
return this->writeConstructorScalarCast(expr.as<ConstructorScalarCast>(), out);
case Expression::Kind::kConstructorSplat:
return this->writeConstructorSplat(expr.as<ConstructorSplat>(), out);
case Expression::Kind::kConstructorComposite:
return this->writeConstructorComposite(expr.as<ConstructorComposite>(), out);
case Expression::Kind::kConstructorCompositeCast:
return this->writeConstructorCompositeCast(expr.as<ConstructorCompositeCast>(), out);
case Expression::Kind::kConstructorCompound:
return this->writeConstructorCompound(expr.as<ConstructorCompound>(), out);
case Expression::Kind::kConstructorCompoundCast:
return this->writeConstructorCompoundCast(expr.as<ConstructorCompoundCast>(), out);
case Expression::Kind::kIntLiteral:
return this->writeIntLiteral(expr.as<IntLiteral>());
case Expression::Kind::kFieldAccess:
@ -927,7 +927,7 @@ SpvId SPIRVCodeGenerator::writeSpecialIntrinsic(const FunctionCall& c, SpecialIn
args.reserve_back(2);
args.push_back(IntLiteral::Make(fContext, /*offset=*/-1, /*value=*/0));
args.push_back(IntLiteral::Make(fContext, /*offset=*/-1, /*value=*/0));
ConstructorComposite ctor(/*offset=*/-1, *fContext.fTypes.fInt2, std::move(args));
ConstructorCompound ctor(/*offset=*/-1, *fContext.fTypes.fInt2, std::move(args));
SpvId coords = this->writeConstantVector(ctor);
if (arguments.size() == 1) {
this->writeInstruction(SpvOpImageRead,
@ -1510,7 +1510,7 @@ void SPIRVCodeGenerator::addColumnEntry(SpvId columnType, Precision precision,
}
}
SpvId SPIRVCodeGenerator::writeMatrixConstructor(const ConstructorComposite& c, OutputStream& out) {
SpvId SPIRVCodeGenerator::writeMatrixConstructor(const ConstructorCompound& c, OutputStream& out) {
const Type& type = c.type();
SkASSERT(type.isMatrix());
SkASSERT(!c.arguments().empty());
@ -1584,13 +1584,13 @@ SpvId SPIRVCodeGenerator::writeMatrixConstructor(const ConstructorComposite& c,
return result;
}
SpvId SPIRVCodeGenerator::writeConstructorComposite(const ConstructorComposite& c,
OutputStream& out) {
SpvId SPIRVCodeGenerator::writeConstructorCompound(const ConstructorCompound& c,
OutputStream& out) {
return c.type().isMatrix() ? this->writeMatrixConstructor(c, out)
: this->writeVectorConstructor(c, out);
}
SpvId SPIRVCodeGenerator::writeVectorConstructor(const ConstructorComposite& c, OutputStream& out) {
SpvId SPIRVCodeGenerator::writeVectorConstructor(const ConstructorCompound& c, OutputStream& out) {
const Type& type = c.type();
const Type& componentType = type.componentType();
SkASSERT(type.isVector());
@ -1676,8 +1676,8 @@ SpvId SPIRVCodeGenerator::writeConstructorScalarCast(const ConstructorScalarCast
return this->castScalarToType(expressionId, ctorExpr.type(), type, out);
}
SpvId SPIRVCodeGenerator::writeConstructorCompositeCast(const ConstructorCompositeCast& c,
OutputStream& out) {
SpvId SPIRVCodeGenerator::writeConstructorCompoundCast(const ConstructorCompoundCast& c,
OutputStream& out) {
const Type& ctorType = c.type();
const Type& argType = c.argument()->type();
SkASSERT(ctorType.isVector() || ctorType.isMatrix());

View File

@ -23,8 +23,8 @@
#include "src/sksl/ir/SkSLBoolLiteral.h"
#include "src/sksl/ir/SkSLConstructor.h"
#include "src/sksl/ir/SkSLConstructorArray.h"
#include "src/sksl/ir/SkSLConstructorComposite.h"
#include "src/sksl/ir/SkSLConstructorCompositeCast.h"
#include "src/sksl/ir/SkSLConstructorCompound.h"
#include "src/sksl/ir/SkSLConstructorCompoundCast.h"
#include "src/sksl/ir/SkSLConstructorDiagonalMatrix.h"
#include "src/sksl/ir/SkSLConstructorMatrixResize.h"
#include "src/sksl/ir/SkSLConstructorScalarCast.h"
@ -288,11 +288,11 @@ private:
std::vector<SpvId>* columnIds, int* currentCount, int rows, SpvId entry,
OutputStream& out);
SpvId writeConstructorComposite(const ConstructorComposite& c, OutputStream& out);
SpvId writeConstructorCompound(const ConstructorCompound& c, OutputStream& out);
SpvId writeMatrixConstructor(const ConstructorComposite& c, OutputStream& out);
SpvId writeMatrixConstructor(const ConstructorCompound& c, OutputStream& out);
SpvId writeVectorConstructor(const ConstructorComposite& c, OutputStream& out);
SpvId writeVectorConstructor(const ConstructorCompound& c, OutputStream& out);
SpvId writeArrayConstructor(const ConstructorArray& c, OutputStream& out);
@ -304,7 +304,7 @@ private:
SpvId writeConstructorSplat(const ConstructorSplat& c, OutputStream& out);
SpvId writeConstructorCompositeCast(const ConstructorCompositeCast& c, OutputStream& out);
SpvId writeConstructorCompoundCast(const ConstructorCompoundCast& c, OutputStream& out);
SpvId writeComposite(const std::vector<SpvId>& arguments, const Type& type, OutputStream& out);

View File

@ -1434,14 +1434,14 @@ Value SkVMGenerator::writeExpression(const Expression& e) {
case Expression::Kind::kBoolLiteral:
return fBuilder->splat(e.as<BoolLiteral>().value() ? ~0 : 0);
case Expression::Kind::kConstructorArray:
case Expression::Kind::kConstructorComposite:
case Expression::Kind::kConstructorCompound:
return this->writeAggregationConstructor(e.asAnyConstructor());
case Expression::Kind::kConstructorDiagonalMatrix:
return this->writeConstructorDiagonalMatrix(e.as<ConstructorDiagonalMatrix>());
case Expression::Kind::kConstructorMatrixResize:
return this->writeConstructorMatrixResize(e.as<ConstructorMatrixResize>());
case Expression::Kind::kConstructorScalarCast:
case Expression::Kind::kConstructorCompositeCast:
case Expression::Kind::kConstructorCompoundCast:
return this->writeConstructorCast(e.asAnyConstructor());
case Expression::Kind::kConstructorSplat:
return this->writeConstructorSplat(e.as<ConstructorSplat>());

View File

@ -9,8 +9,8 @@
#include "src/sksl/ir/SkSLBoolLiteral.h"
#include "src/sksl/ir/SkSLConstructorArray.h"
#include "src/sksl/ir/SkSLConstructorComposite.h"
#include "src/sksl/ir/SkSLConstructorCompositeCast.h"
#include "src/sksl/ir/SkSLConstructorCompound.h"
#include "src/sksl/ir/SkSLConstructorCompoundCast.h"
#include "src/sksl/ir/SkSLConstructorDiagonalMatrix.h"
#include "src/sksl/ir/SkSLConstructorMatrixResize.h"
#include "src/sksl/ir/SkSLConstructorScalarCast.h"
@ -47,7 +47,7 @@ static std::unique_ptr<Expression> convert_compound_constructor(const Context& c
// A vector constructor containing a single vector with the same number of columns is a
// cast (e.g. float3 -> int3).
if (type.isVector() && argument->type().columns() == type.columns()) {
return ConstructorCompositeCast::Make(context, offset, type, std::move(argument));
return ConstructorCompoundCast::Make(context, offset, type, std::move(argument));
}
} else if (argument->type().isMatrix()) {
// A matrix constructor containing a single matrix can be a resize, typecast, or both.
@ -60,7 +60,7 @@ static std::unique_ptr<Expression> convert_compound_constructor(const Context& c
context,
argument->type().columns(),
argument->type().rows());
std::unique_ptr<Expression> typecast = ConstructorCompositeCast::Make(
std::unique_ptr<Expression> typecast = ConstructorCompoundCast::Make(
context, offset, typecastType, std::move(argument));
// Next, wrap the typecasted expression in a matrix-resize constructor if the
@ -104,7 +104,7 @@ static std::unique_ptr<Expression> convert_compound_constructor(const Context& c
return nullptr;
}
return ConstructorComposite::Make(context, offset, type, std::move(args));
return ConstructorCompound::Make(context, offset, type, std::move(args));
}
std::unique_ptr<Expression> Constructor::Convert(const Context& context,

View File

@ -166,7 +166,7 @@ namespace Constructor {
// Creates, typechecks and simplifies constructor expressions. Reports errors via the
// ErrorReporter. This can return null on error, so be careful. There are several different
// Constructor expression types; this class chooses the proper one based on context, e.g.
// `ConstructorComposite`, `ConstructorScalarCast`, or `ConstructorMatrixResize`.
// `ConstructorCompound`, `ConstructorScalarCast`, or `ConstructorMatrixResize`.
std::unique_ptr<Expression> Convert(const Context& context,
int offset,
const Type& type,

View File

@ -5,17 +5,17 @@
* found in the LICENSE file.
*/
#include "src/sksl/ir/SkSLConstructorComposite.h"
#include "src/sksl/ir/SkSLConstructorCompound.h"
#include <algorithm>
#include <numeric>
namespace SkSL {
std::unique_ptr<Expression> ConstructorComposite::Make(const Context& context,
int offset,
const Type& type,
ExpressionArray args) {
std::unique_ptr<Expression> ConstructorCompound::Make(const Context& context,
int offset,
const Type& type,
ExpressionArray args) {
// A scalar "composite" type with a single scalar argument is a no-op and can be eliminated.
// (Pedantically, this isn't a composite at all, but it's harmless to allow and simplifies
// call sites which need to narrow a vector and may sometimes end up with a scalar.)
@ -39,7 +39,7 @@ std::unique_ptr<Expression> ConstructorComposite::Make(const Context& context,
}));
if (context.fConfig->fSettings.fOptimize) {
// Find ConstructorComposites embedded inside other ConstructorComposites and flatten them.
// Find ConstructorCompounds embedded inside other ConstructorCompounds and flatten them.
// - float4(float2(1, 2), 3, 4) --> float4(1, 2, 3, 4)
// - float4(w, float3(sin(x), cos(y), tan(z))) --> float4(w, sin(x), cos(y), tan(z))
// - mat2(float2(a, b), float2(c, d)) --> mat2(a, b, c, d)
@ -47,8 +47,8 @@ std::unique_ptr<Expression> ConstructorComposite::Make(const Context& context,
// See how many fields we would have if composite constructors were flattened out.
size_t fields = 0;
for (const std::unique_ptr<Expression>& arg : args) {
fields += arg->is<ConstructorComposite>()
? arg->as<ConstructorComposite>().arguments().size()
fields += arg->is<ConstructorCompound>()
? arg->as<ConstructorCompound>().arguments().size()
: 1;
}
@ -58,13 +58,13 @@ std::unique_ptr<Expression> ConstructorComposite::Make(const Context& context,
ExpressionArray flattened;
flattened.reserve_back(fields);
for (std::unique_ptr<Expression>& arg : args) {
// For non-ConstructorComposite fields, move them over as-is.
if (!arg->is<ConstructorComposite>()) {
// For non-ConstructorCompound fields, move them over as-is.
if (!arg->is<ConstructorCompound>()) {
flattened.push_back(std::move(arg));
continue;
}
// For ConstructorComposite fields, move over their inner arguments individually.
ConstructorComposite& compositeCtor = arg->as<ConstructorComposite>();
// For ConstructorCompound fields, move over their inner arguments individually.
ConstructorCompound& compositeCtor = arg->as<ConstructorCompound>();
for (std::unique_ptr<Expression>& innerArg : compositeCtor.arguments()) {
flattened.push_back(std::move(innerArg));
}
@ -73,7 +73,7 @@ std::unique_ptr<Expression> ConstructorComposite::Make(const Context& context,
}
}
return std::make_unique<ConstructorComposite>(offset, type, std::move(args));
return std::make_unique<ConstructorCompound>(offset, type, std::move(args));
}
} // namespace SkSL

View File

@ -24,11 +24,11 @@ namespace SkSL {
* constructor must always match the type's slot count. (e.g. `pos.xy` consumes two slots.)
* The inner values must have the same component type as the vector/matrix.
*/
class ConstructorComposite final : public MultiArgumentConstructor {
class ConstructorCompound final : public MultiArgumentConstructor {
public:
static constexpr Kind kExpressionKind = Kind::kConstructorComposite;
static constexpr Kind kExpressionKind = Kind::kConstructorCompound;
ConstructorComposite(int offset, const Type& type, ExpressionArray args)
ConstructorCompound(int offset, const Type& type, ExpressionArray args)
: INHERITED(offset, kExpressionKind, &type, std::move(args)) {}
static std::unique_ptr<Expression> Make(const Context& context,
@ -37,7 +37,7 @@ public:
ExpressionArray args);
std::unique_ptr<Expression> clone() const override {
return std::make_unique<ConstructorComposite>(fOffset, this->type(),
return std::make_unique<ConstructorCompound>(fOffset, this->type(),
this->cloneArguments());
}

View File

@ -5,10 +5,10 @@
* found in the LICENSE file.
*/
#include "src/sksl/ir/SkSLConstructorCompositeCast.h"
#include "src/sksl/ir/SkSLConstructorCompoundCast.h"
#include "src/sksl/ir/SkSLConstructor.h"
#include "src/sksl/ir/SkSLConstructorComposite.h"
#include "src/sksl/ir/SkSLConstructorCompound.h"
#include "src/sksl/ir/SkSLConstructorDiagonalMatrix.h"
#include "src/sksl/ir/SkSLConstructorScalarCast.h"
#include "src/sksl/ir/SkSLConstructorSplat.h"
@ -59,14 +59,14 @@ static std::unique_ptr<Expression> cast_constant_composite(const Context& contex
}
}
return ConstructorComposite::Make(context, constCtor->fOffset, destType,
return ConstructorCompound::Make(context, constCtor->fOffset, destType,
std::move(typecastArgs));
}
std::unique_ptr<Expression> ConstructorCompositeCast::Make(const Context& context,
int offset,
const Type& type,
std::unique_ptr<Expression> arg) {
std::unique_ptr<Expression> ConstructorCompoundCast::Make(const Context& context,
int offset,
const Type& type,
std::unique_ptr<Expression> arg) {
// Only vectors or matrices of the same dimensions are allowed.
SkASSERT(type.isVector() || type.isMatrix());
SkASSERT(arg->type().isVector() == type.isVector());
@ -82,7 +82,7 @@ std::unique_ptr<Expression> ConstructorCompositeCast::Make(const Context& contex
if (arg->isCompileTimeConstant()) {
return cast_constant_composite(context, type, std::move(arg));
}
return std::make_unique<ConstructorCompositeCast>(offset, type, std::move(arg));
return std::make_unique<ConstructorCompoundCast>(offset, type, std::move(arg));
}
} // namespace SkSL

View File

@ -22,11 +22,11 @@ namespace SkSL {
*
* These always contain exactly 1 vector or matrix of matching size, and are never constant.
*/
class ConstructorCompositeCast final : public SingleArgumentConstructor {
class ConstructorCompoundCast final : public SingleArgumentConstructor {
public:
static constexpr Kind kExpressionKind = Kind::kConstructorCompositeCast;
static constexpr Kind kExpressionKind = Kind::kConstructorCompoundCast;
ConstructorCompositeCast(int offset, const Type& type, std::unique_ptr<Expression> arg)
ConstructorCompoundCast(int offset, const Type& type, std::unique_ptr<Expression> arg)
: INHERITED(offset, kExpressionKind, &type, std::move(arg)) {}
static std::unique_ptr<Expression> Make(const Context& context,
@ -35,12 +35,12 @@ public:
std::unique_ptr<Expression> arg);
bool isCompileTimeConstant() const override {
// If this were a compile-time constant, we would have made a ConstructorComposite instead.
// If this were a compile-time constant, we would have made a ConstructorCompound instead.
return false;
}
std::unique_ptr<Expression> clone() const override {
return std::make_unique<ConstructorCompositeCast>(fOffset, this->type(),
return std::make_unique<ConstructorCompoundCast>(fOffset, this->type(),
argument()->clone());
}

View File

@ -31,8 +31,8 @@ public:
kBoolLiteral,
kCodeString,
kConstructorArray,
kConstructorComposite,
kConstructorCompositeCast,
kConstructorCompound,
kConstructorCompoundCast,
kConstructorDiagonalMatrix,
kConstructorMatrixResize,
kConstructorScalarCast,

View File

@ -11,7 +11,7 @@
#include "src/sksl/ir/SkSLBoolLiteral.h"
#include "src/sksl/ir/SkSLConstructor.h"
#include "src/sksl/ir/SkSLConstructorArray.h"
#include "src/sksl/ir/SkSLConstructorComposite.h"
#include "src/sksl/ir/SkSLConstructorCompound.h"
#include "src/sksl/ir/SkSLConstructorDiagonalMatrix.h"
#include "src/sksl/ir/SkSLConstructorSplat.h"
#include "src/sksl/ir/SkSLFloatLiteral.h"
@ -76,11 +76,11 @@ static std::unique_ptr<Expression> negate_operand(const Context& context,
}
break;
case Expression::Kind::kConstructorComposite:
case Expression::Kind::kConstructorCompound:
// Convert `-vecN(literal, ...)` into `vecN(-literal, ...)`.
if (context.fConfig->fSettings.fOptimize && value->isCompileTimeConstant()) {
ConstructorComposite& ctor = operand->as<ConstructorComposite>();
return ConstructorComposite::Make(
ConstructorCompound& ctor = operand->as<ConstructorCompound>();
return ConstructorCompound::Make(
context, ctor.fOffset, ctor.type(),
negate_operands(context, std::move(ctor.arguments())));
}