Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/crossgl/HIR/TypeSemantics.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ bool isNumericScalarTypeName(std::string_view name);
bool isFloatLike(std::string_view name);
bool isVectorType(std::string_view name);
bool isNumericVectorTypeName(std::string_view name);
bool isFloatVectorType(std::string_view name);
bool isFloatVectorType(const HIRType &type);
bool isMatrixType(std::string_view name);
bool isScalarAggregateTypePair(const HIRType &left, const HIRType &right);
bool shouldDiagnoseTypeMismatch(const HIRType &expected, const HIRType &actual);
Expand Down
6 changes: 0 additions & 6 deletions src/HIR/HIR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,12 +659,6 @@ bool isComputeInvocationBuiltinIntConversion(const HIRExpression &expression,
isComputeInvocationBuiltinComponentAccess(expression.children.front());
}

bool isFloatVectorType(const HIRType &type) {
const std::string name = baseTypeName(type);
return !type.arraySize.has_value() &&
(name == "vec2" || name == "vec3" || name == "vec4");
}

std::optional<std::size_t> matrixDimensionFromHIRTypeName(std::string_view name) {
if (name == "mat2" || name == "mat2x2") {
return std::size_t{2};
Expand Down
19 changes: 2 additions & 17 deletions src/HIR/Intrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,6 @@ std::string formatArgumentCount(std::size_t count) {
return std::to_string(count) + (count == 1 ? " argument" : " arguments");
}

bool isFloatVectorType(std::string_view baseName) {
if (!isVectorType(baseName)) {
return false;
}
return isFloatLike(baseTypeName(scalarTypeForVector(baseName)));
}

bool isNumericValueType(const HIRType &type) {
if (type.name.empty() || type.arraySize.has_value()) {
return false;
Expand All @@ -206,7 +199,7 @@ bool isFloatValueType(const HIRType &type) {
return false;
}
const std::string baseName = baseTypeName(type);
return isFloatLike(baseName) || isFloatVectorType(baseName) ||
return isFloatLike(baseName) || isFloatVectorType(std::string_view{baseName}) ||
isMatrixType(baseName);
}

Expand All @@ -229,15 +222,7 @@ bool isFloatScalarOrVectorType(const HIRType &type) {
return false;
}
const std::string baseName = baseTypeName(type);
return isFloatLike(baseName) || isFloatVectorType(baseName);
}

bool isFloatVectorType(const HIRType &type) {
if (type.name.empty() || type.arraySize.has_value()) {
return false;
}
const std::string baseName = baseTypeName(type);
return isFloatVectorType(std::string_view{baseName});
return isFloatLike(baseName) || isFloatVectorType(std::string_view{baseName});
}

bool isFloatVector3Type(const HIRType &type) {
Expand Down
15 changes: 15 additions & 0 deletions src/HIR/TypeSemantics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,21 @@ bool isNumericVectorTypeName(std::string_view name) {
return isVectorType(name) && !name.starts_with("bvec");
}

bool isFloatVectorType(std::string_view name) {
// Vector types whose component type is float-like (vecN); ivecN/uvecN/bvecN
// are excluded.
return isVectorType(name) &&
isFloatLike(baseTypeName(scalarTypeForVector(name)));
}

bool isFloatVectorType(const HIRType &type) {
if (type.arraySize.has_value()) {
return false;
}
const std::string name = baseTypeName(type);
return isFloatVectorType(std::string_view{name});
}

bool isMatrixType(std::string_view name) {
return name == "mat2" || name == "mat3" || name == "mat4" ||
name == "mat2x2" || name == "mat3x3" || name == "mat4x4";
Expand Down
Loading