Move IntrinsicType parsing to semantic/intrinsic.h

Keeps the enum / parse / print code all together.

Change-Id: I78e5e15b6a97d3aec619a94e4390ecc4a77ab478
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/43980
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton 2021-03-04 23:00:46 +00:00 committed by Commit Bot service account
parent dee7d36f8a
commit f25d51977a
8 changed files with 306 additions and 263 deletions

View File

@ -844,6 +844,7 @@ source_set("tint_unittests_core_src") {
"src/intrinsic_table_test.cc",
"src/program_builder_test.cc",
"src/program_test.cc",
"src/semantic/sem_intrinsic_test.cc",
"src/scope_stack_test.cc",
"src/symbol_table_test.cc",
"src/symbol_test.cc",

View File

@ -472,6 +472,7 @@ if(${TINT_BUILD_TESTS})
inspector/inspector_test.cc
intrinsic_table_test.cc
program_test.cc
semantic/sem_intrinsic_test.cc
scope_stack_test.cc
symbol_table_test.cc
symbol_test.cc

View File

@ -16,6 +16,7 @@
#define SRC_SEMANTIC_INTRINSIC_H_
#include <ostream>
#include <string>
#include "src/semantic/call_target.h"
@ -109,6 +110,12 @@ enum class IntrinsicType {
kUnpack2x16Float,
};
/// Matches the IntrisicType by name
/// @param name the intrinsic name to parse
/// @returns the parsed IntrinsicType, or IntrinsicType::kNone if `name` did not
/// match any intrinsic.
IntrinsicType ParseIntrinsicType(const std::string& name);
/// @returns the name of the intrinsic function type. The spelling, including
/// case, matches the name in the WGSL spec.
const char* str(IntrinsicType i);

View File

@ -28,6 +28,175 @@ const char* Intrinsic::str() const {
return semantic::str(type_);
}
IntrinsicType ParseIntrinsicType(const std::string& name) {
if (name == "abs") {
return IntrinsicType::kAbs;
} else if (name == "acos") {
return IntrinsicType::kAcos;
} else if (name == "all") {
return IntrinsicType::kAll;
} else if (name == "any") {
return IntrinsicType::kAny;
} else if (name == "arrayLength") {
return IntrinsicType::kArrayLength;
} else if (name == "asin") {
return IntrinsicType::kAsin;
} else if (name == "atan") {
return IntrinsicType::kAtan;
} else if (name == "atan2") {
return IntrinsicType::kAtan2;
} else if (name == "ceil") {
return IntrinsicType::kCeil;
} else if (name == "clamp") {
return IntrinsicType::kClamp;
} else if (name == "cos") {
return IntrinsicType::kCos;
} else if (name == "cosh") {
return IntrinsicType::kCosh;
} else if (name == "countOneBits") {
return IntrinsicType::kCountOneBits;
} else if (name == "cross") {
return IntrinsicType::kCross;
} else if (name == "determinant") {
return IntrinsicType::kDeterminant;
} else if (name == "distance") {
return IntrinsicType::kDistance;
} else if (name == "dot") {
return IntrinsicType::kDot;
} else if (name == "dpdx") {
return IntrinsicType::kDpdx;
} else if (name == "dpdxCoarse") {
return IntrinsicType::kDpdxCoarse;
} else if (name == "dpdxFine") {
return IntrinsicType::kDpdxFine;
} else if (name == "dpdy") {
return IntrinsicType::kDpdy;
} else if (name == "dpdyCoarse") {
return IntrinsicType::kDpdyCoarse;
} else if (name == "dpdyFine") {
return IntrinsicType::kDpdyFine;
} else if (name == "exp") {
return IntrinsicType::kExp;
} else if (name == "exp2") {
return IntrinsicType::kExp2;
} else if (name == "faceForward") {
return IntrinsicType::kFaceForward;
} else if (name == "floor") {
return IntrinsicType::kFloor;
} else if (name == "fma") {
return IntrinsicType::kFma;
} else if (name == "fract") {
return IntrinsicType::kFract;
} else if (name == "frexp") {
return IntrinsicType::kFrexp;
} else if (name == "fwidth") {
return IntrinsicType::kFwidth;
} else if (name == "fwidthCoarse") {
return IntrinsicType::kFwidthCoarse;
} else if (name == "fwidthFine") {
return IntrinsicType::kFwidthFine;
} else if (name == "inverseSqrt") {
return IntrinsicType::kInverseSqrt;
} else if (name == "isFinite") {
return IntrinsicType::kIsFinite;
} else if (name == "isInf") {
return IntrinsicType::kIsInf;
} else if (name == "isNan") {
return IntrinsicType::kIsNan;
} else if (name == "isNormal") {
return IntrinsicType::kIsNormal;
} else if (name == "ldexp") {
return IntrinsicType::kLdexp;
} else if (name == "length") {
return IntrinsicType::kLength;
} else if (name == "log") {
return IntrinsicType::kLog;
} else if (name == "log2") {
return IntrinsicType::kLog2;
} else if (name == "max") {
return IntrinsicType::kMax;
} else if (name == "min") {
return IntrinsicType::kMin;
} else if (name == "mix") {
return IntrinsicType::kMix;
} else if (name == "modf") {
return IntrinsicType::kModf;
} else if (name == "normalize") {
return IntrinsicType::kNormalize;
} else if (name == "pack4x8snorm") {
return IntrinsicType::kPack4x8Snorm;
} else if (name == "pack4x8unorm") {
return IntrinsicType::kPack4x8Unorm;
} else if (name == "pack2x16snorm") {
return IntrinsicType::kPack2x16Snorm;
} else if (name == "pack2x16unorm") {
return IntrinsicType::kPack2x16Unorm;
} else if (name == "pack2x16float") {
return IntrinsicType::kPack2x16Float;
} else if (name == "pow") {
return IntrinsicType::kPow;
} else if (name == "reflect") {
return IntrinsicType::kReflect;
} else if (name == "reverseBits") {
return IntrinsicType::kReverseBits;
} else if (name == "round") {
return IntrinsicType::kRound;
} else if (name == "select") {
return IntrinsicType::kSelect;
} else if (name == "sign") {
return IntrinsicType::kSign;
} else if (name == "sin") {
return IntrinsicType::kSin;
} else if (name == "sinh") {
return IntrinsicType::kSinh;
} else if (name == "smoothStep") {
return IntrinsicType::kSmoothStep;
} else if (name == "sqrt") {
return IntrinsicType::kSqrt;
} else if (name == "step") {
return IntrinsicType::kStep;
} else if (name == "tan") {
return IntrinsicType::kTan;
} else if (name == "tanh") {
return IntrinsicType::kTanh;
} else if (name == "textureDimensions") {
return IntrinsicType::kTextureDimensions;
} else if (name == "textureNumLayers") {
return IntrinsicType::kTextureNumLayers;
} else if (name == "textureNumLevels") {
return IntrinsicType::kTextureNumLevels;
} else if (name == "textureNumSamples") {
return IntrinsicType::kTextureNumSamples;
} else if (name == "textureLoad") {
return IntrinsicType::kTextureLoad;
} else if (name == "textureStore") {
return IntrinsicType::kTextureStore;
} else if (name == "textureSample") {
return IntrinsicType::kTextureSample;
} else if (name == "textureSampleBias") {
return IntrinsicType::kTextureSampleBias;
} else if (name == "textureSampleCompare") {
return IntrinsicType::kTextureSampleCompare;
} else if (name == "textureSampleGrad") {
return IntrinsicType::kTextureSampleGrad;
} else if (name == "textureSampleLevel") {
return IntrinsicType::kTextureSampleLevel;
} else if (name == "trunc") {
return IntrinsicType::kTrunc;
} else if (name == "unpack4x8snorm") {
return IntrinsicType::kUnpack4x8Snorm;
} else if (name == "unpack4x8unorm") {
return IntrinsicType::kUnpack4x8Unorm;
} else if (name == "unpack2x16snorm") {
return IntrinsicType::kUnpack2x16Snorm;
} else if (name == "unpack2x16unorm") {
return IntrinsicType::kUnpack2x16Unorm;
} else if (name == "unpack2x16float") {
return IntrinsicType::kUnpack2x16Float;
}
return IntrinsicType::kNone;
}
const char* str(IntrinsicType i) {
/// The emitted name matches the spelling in the WGSL spec.
/// including case.

View File

@ -0,0 +1,123 @@
// Copyright 2021 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "src/semantic/intrinsic.h"
#include "gtest/gtest.h"
namespace tint {
namespace semantic {
namespace {
struct IntrinsicData {
const char* name;
IntrinsicType intrinsic;
};
inline std::ostream& operator<<(std::ostream& out, IntrinsicData data) {
out << data.name;
return out;
}
using IntrinsicTypeTest = testing::TestWithParam<IntrinsicData>;
TEST_P(IntrinsicTypeTest, Parse) {
auto param = GetParam();
EXPECT_EQ(ParseIntrinsicType(param.name), param.intrinsic);
}
INSTANTIATE_TEST_SUITE_P(
IntrinsicTypeTest,
IntrinsicTypeTest,
testing::Values(
IntrinsicData{"abs", IntrinsicType::kAbs},
IntrinsicData{"acos", IntrinsicType::kAcos},
IntrinsicData{"all", IntrinsicType::kAll},
IntrinsicData{"any", IntrinsicType::kAny},
IntrinsicData{"arrayLength", IntrinsicType::kArrayLength},
IntrinsicData{"asin", IntrinsicType::kAsin},
IntrinsicData{"atan", IntrinsicType::kAtan},
IntrinsicData{"atan2", IntrinsicType::kAtan2},
IntrinsicData{"ceil", IntrinsicType::kCeil},
IntrinsicData{"clamp", IntrinsicType::kClamp},
IntrinsicData{"cos", IntrinsicType::kCos},
IntrinsicData{"cosh", IntrinsicType::kCosh},
IntrinsicData{"countOneBits", IntrinsicType::kCountOneBits},
IntrinsicData{"cross", IntrinsicType::kCross},
IntrinsicData{"determinant", IntrinsicType::kDeterminant},
IntrinsicData{"distance", IntrinsicType::kDistance},
IntrinsicData{"dot", IntrinsicType::kDot},
IntrinsicData{"dpdx", IntrinsicType::kDpdx},
IntrinsicData{"dpdxCoarse", IntrinsicType::kDpdxCoarse},
IntrinsicData{"dpdxFine", IntrinsicType::kDpdxFine},
IntrinsicData{"dpdy", IntrinsicType::kDpdy},
IntrinsicData{"dpdyCoarse", IntrinsicType::kDpdyCoarse},
IntrinsicData{"dpdyFine", IntrinsicType::kDpdyFine},
IntrinsicData{"exp", IntrinsicType::kExp},
IntrinsicData{"exp2", IntrinsicType::kExp2},
IntrinsicData{"faceForward", IntrinsicType::kFaceForward},
IntrinsicData{"floor", IntrinsicType::kFloor},
IntrinsicData{"fma", IntrinsicType::kFma},
IntrinsicData{"fract", IntrinsicType::kFract},
IntrinsicData{"frexp", IntrinsicType::kFrexp},
IntrinsicData{"fwidth", IntrinsicType::kFwidth},
IntrinsicData{"fwidthCoarse", IntrinsicType::kFwidthCoarse},
IntrinsicData{"fwidthFine", IntrinsicType::kFwidthFine},
IntrinsicData{"inverseSqrt", IntrinsicType::kInverseSqrt},
IntrinsicData{"isFinite", IntrinsicType::kIsFinite},
IntrinsicData{"isInf", IntrinsicType::kIsInf},
IntrinsicData{"isNan", IntrinsicType::kIsNan},
IntrinsicData{"isNormal", IntrinsicType::kIsNormal},
IntrinsicData{"ldexp", IntrinsicType::kLdexp},
IntrinsicData{"length", IntrinsicType::kLength},
IntrinsicData{"log", IntrinsicType::kLog},
IntrinsicData{"log2", IntrinsicType::kLog2},
IntrinsicData{"max", IntrinsicType::kMax},
IntrinsicData{"min", IntrinsicType::kMin},
IntrinsicData{"mix", IntrinsicType::kMix},
IntrinsicData{"modf", IntrinsicType::kModf},
IntrinsicData{"normalize", IntrinsicType::kNormalize},
IntrinsicData{"pow", IntrinsicType::kPow},
IntrinsicData{"reflect", IntrinsicType::kReflect},
IntrinsicData{"reverseBits", IntrinsicType::kReverseBits},
IntrinsicData{"round", IntrinsicType::kRound},
IntrinsicData{"select", IntrinsicType::kSelect},
IntrinsicData{"sign", IntrinsicType::kSign},
IntrinsicData{"sin", IntrinsicType::kSin},
IntrinsicData{"sinh", IntrinsicType::kSinh},
IntrinsicData{"smoothStep", IntrinsicType::kSmoothStep},
IntrinsicData{"sqrt", IntrinsicType::kSqrt},
IntrinsicData{"step", IntrinsicType::kStep},
IntrinsicData{"tan", IntrinsicType::kTan},
IntrinsicData{"tanh", IntrinsicType::kTanh},
IntrinsicData{"textureDimensions", IntrinsicType::kTextureDimensions},
IntrinsicData{"textureLoad", IntrinsicType::kTextureLoad},
IntrinsicData{"textureNumLayers", IntrinsicType::kTextureNumLayers},
IntrinsicData{"textureNumLevels", IntrinsicType::kTextureNumLevels},
IntrinsicData{"textureNumSamples", IntrinsicType::kTextureNumSamples},
IntrinsicData{"textureSample", IntrinsicType::kTextureSample},
IntrinsicData{"textureSampleBias", IntrinsicType::kTextureSampleBias},
IntrinsicData{"textureSampleCompare",
IntrinsicType::kTextureSampleCompare},
IntrinsicData{"textureSampleGrad", IntrinsicType::kTextureSampleGrad},
IntrinsicData{"textureSampleLevel", IntrinsicType::kTextureSampleLevel},
IntrinsicData{"trunc", IntrinsicType::kTrunc}));
TEST_F(IntrinsicTypeTest, ParseNoMatch) {
EXPECT_EQ(ParseIntrinsicType("not_intrinsic"), IntrinsicType::kNone);
}
} // namespace
} // namespace semantic
} // namespace tint

View File

@ -412,7 +412,7 @@ bool TypeDeterminer::DetermineCall(ast::CallExpression* call) {
auto name = builder_->Symbols().NameFor(ident->symbol());
auto intrinsic_type = MatchIntrinsicType(name);
auto intrinsic_type = semantic::ParseIntrinsicType(name);
if (intrinsic_type != IntrinsicType::kNone) {
if (!DetermineIntrinsicCall(call, intrinsic_type)) {
return false;
@ -563,7 +563,7 @@ bool TypeDeterminer::DetermineIdentifier(ast::IdentifierExpression* expr) {
}
std::string name = builder_->Symbols().NameFor(symbol);
if (MatchIntrinsicType(name) != IntrinsicType::kNone) {
if (semantic::ParseIntrinsicType(name) != IntrinsicType::kNone) {
diagnostics_.add_error("missing '(' for intrinsic call",
expr->source().End());
return false;
@ -575,175 +575,6 @@ bool TypeDeterminer::DetermineIdentifier(ast::IdentifierExpression* expr) {
return false;
}
IntrinsicType TypeDeterminer::MatchIntrinsicType(const std::string& name) {
if (name == "abs") {
return IntrinsicType::kAbs;
} else if (name == "acos") {
return IntrinsicType::kAcos;
} else if (name == "all") {
return IntrinsicType::kAll;
} else if (name == "any") {
return IntrinsicType::kAny;
} else if (name == "arrayLength") {
return IntrinsicType::kArrayLength;
} else if (name == "asin") {
return IntrinsicType::kAsin;
} else if (name == "atan") {
return IntrinsicType::kAtan;
} else if (name == "atan2") {
return IntrinsicType::kAtan2;
} else if (name == "ceil") {
return IntrinsicType::kCeil;
} else if (name == "clamp") {
return IntrinsicType::kClamp;
} else if (name == "cos") {
return IntrinsicType::kCos;
} else if (name == "cosh") {
return IntrinsicType::kCosh;
} else if (name == "countOneBits") {
return IntrinsicType::kCountOneBits;
} else if (name == "cross") {
return IntrinsicType::kCross;
} else if (name == "determinant") {
return IntrinsicType::kDeterminant;
} else if (name == "distance") {
return IntrinsicType::kDistance;
} else if (name == "dot") {
return IntrinsicType::kDot;
} else if (name == "dpdx") {
return IntrinsicType::kDpdx;
} else if (name == "dpdxCoarse") {
return IntrinsicType::kDpdxCoarse;
} else if (name == "dpdxFine") {
return IntrinsicType::kDpdxFine;
} else if (name == "dpdy") {
return IntrinsicType::kDpdy;
} else if (name == "dpdyCoarse") {
return IntrinsicType::kDpdyCoarse;
} else if (name == "dpdyFine") {
return IntrinsicType::kDpdyFine;
} else if (name == "exp") {
return IntrinsicType::kExp;
} else if (name == "exp2") {
return IntrinsicType::kExp2;
} else if (name == "faceForward") {
return IntrinsicType::kFaceForward;
} else if (name == "floor") {
return IntrinsicType::kFloor;
} else if (name == "fma") {
return IntrinsicType::kFma;
} else if (name == "fract") {
return IntrinsicType::kFract;
} else if (name == "frexp") {
return IntrinsicType::kFrexp;
} else if (name == "fwidth") {
return IntrinsicType::kFwidth;
} else if (name == "fwidthCoarse") {
return IntrinsicType::kFwidthCoarse;
} else if (name == "fwidthFine") {
return IntrinsicType::kFwidthFine;
} else if (name == "inverseSqrt") {
return IntrinsicType::kInverseSqrt;
} else if (name == "isFinite") {
return IntrinsicType::kIsFinite;
} else if (name == "isInf") {
return IntrinsicType::kIsInf;
} else if (name == "isNan") {
return IntrinsicType::kIsNan;
} else if (name == "isNormal") {
return IntrinsicType::kIsNormal;
} else if (name == "ldexp") {
return IntrinsicType::kLdexp;
} else if (name == "length") {
return IntrinsicType::kLength;
} else if (name == "log") {
return IntrinsicType::kLog;
} else if (name == "log2") {
return IntrinsicType::kLog2;
} else if (name == "max") {
return IntrinsicType::kMax;
} else if (name == "min") {
return IntrinsicType::kMin;
} else if (name == "mix") {
return IntrinsicType::kMix;
} else if (name == "modf") {
return IntrinsicType::kModf;
} else if (name == "normalize") {
return IntrinsicType::kNormalize;
} else if (name == "pack4x8snorm") {
return IntrinsicType::kPack4x8Snorm;
} else if (name == "pack4x8unorm") {
return IntrinsicType::kPack4x8Unorm;
} else if (name == "pack2x16snorm") {
return IntrinsicType::kPack2x16Snorm;
} else if (name == "pack2x16unorm") {
return IntrinsicType::kPack2x16Unorm;
} else if (name == "pack2x16float") {
return IntrinsicType::kPack2x16Float;
} else if (name == "pow") {
return IntrinsicType::kPow;
} else if (name == "reflect") {
return IntrinsicType::kReflect;
} else if (name == "reverseBits") {
return IntrinsicType::kReverseBits;
} else if (name == "round") {
return IntrinsicType::kRound;
} else if (name == "select") {
return IntrinsicType::kSelect;
} else if (name == "sign") {
return IntrinsicType::kSign;
} else if (name == "sin") {
return IntrinsicType::kSin;
} else if (name == "sinh") {
return IntrinsicType::kSinh;
} else if (name == "smoothStep") {
return IntrinsicType::kSmoothStep;
} else if (name == "sqrt") {
return IntrinsicType::kSqrt;
} else if (name == "step") {
return IntrinsicType::kStep;
} else if (name == "tan") {
return IntrinsicType::kTan;
} else if (name == "tanh") {
return IntrinsicType::kTanh;
} else if (name == "textureDimensions") {
return IntrinsicType::kTextureDimensions;
} else if (name == "textureNumLayers") {
return IntrinsicType::kTextureNumLayers;
} else if (name == "textureNumLevels") {
return IntrinsicType::kTextureNumLevels;
} else if (name == "textureNumSamples") {
return IntrinsicType::kTextureNumSamples;
} else if (name == "textureLoad") {
return IntrinsicType::kTextureLoad;
} else if (name == "textureStore") {
return IntrinsicType::kTextureStore;
} else if (name == "textureSample") {
return IntrinsicType::kTextureSample;
} else if (name == "textureSampleBias") {
return IntrinsicType::kTextureSampleBias;
} else if (name == "textureSampleCompare") {
return IntrinsicType::kTextureSampleCompare;
} else if (name == "textureSampleGrad") {
return IntrinsicType::kTextureSampleGrad;
} else if (name == "textureSampleLevel") {
return IntrinsicType::kTextureSampleLevel;
} else if (name == "trunc") {
return IntrinsicType::kTrunc;
} else if (name == "unpack4x8snorm") {
return IntrinsicType::kUnpack4x8Snorm;
} else if (name == "unpack4x8unorm") {
return IntrinsicType::kUnpack4x8Unorm;
} else if (name == "unpack2x16snorm") {
return IntrinsicType::kUnpack2x16Snorm;
} else if (name == "unpack2x16unorm") {
return IntrinsicType::kUnpack2x16Unorm;
} else if (name == "unpack2x16float") {
return IntrinsicType::kUnpack2x16Float;
}
return IntrinsicType::kNone;
}
bool TypeDeterminer::DetermineMemberAccessor(
ast::MemberAccessorExpression* expr) {
if (!DetermineResultType(expr->structure())) {

View File

@ -65,11 +65,6 @@ class TypeDeterminer {
/// @returns true if the type determiner was successful
bool Determine();
/// @param name the function name to try and match as an intrinsic type.
/// @return the semantic::IntrinsicType for the given name. If `name` does not
/// match an intrinsic, returns semantic::Intrinsic::kNone
static semantic::IntrinsicType MatchIntrinsicType(const std::string& name);
private:
/// Structure holding semantic information about a variable.
/// Used to build the semantic::Variable nodes at the end of resolving.

View File

@ -1995,97 +1995,11 @@ struct IntrinsicData {
const char* name;
IntrinsicType intrinsic;
};
inline std::ostream& operator<<(std::ostream& out, IntrinsicData data) {
out << data.name;
return out;
}
using IntrinsicDataTest = TypeDeterminerTestWithParam<IntrinsicData>;
TEST_P(IntrinsicDataTest, Lookup) {
auto param = GetParam();
EXPECT_EQ(TypeDeterminer::MatchIntrinsicType(param.name), param.intrinsic);
}
INSTANTIATE_TEST_SUITE_P(
TypeDeterminerTest,
IntrinsicDataTest,
testing::Values(
IntrinsicData{"abs", IntrinsicType::kAbs},
IntrinsicData{"acos", IntrinsicType::kAcos},
IntrinsicData{"all", IntrinsicType::kAll},
IntrinsicData{"any", IntrinsicType::kAny},
IntrinsicData{"arrayLength", IntrinsicType::kArrayLength},
IntrinsicData{"asin", IntrinsicType::kAsin},
IntrinsicData{"atan", IntrinsicType::kAtan},
IntrinsicData{"atan2", IntrinsicType::kAtan2},
IntrinsicData{"ceil", IntrinsicType::kCeil},
IntrinsicData{"clamp", IntrinsicType::kClamp},
IntrinsicData{"cos", IntrinsicType::kCos},
IntrinsicData{"cosh", IntrinsicType::kCosh},
IntrinsicData{"countOneBits", IntrinsicType::kCountOneBits},
IntrinsicData{"cross", IntrinsicType::kCross},
IntrinsicData{"determinant", IntrinsicType::kDeterminant},
IntrinsicData{"distance", IntrinsicType::kDistance},
IntrinsicData{"dot", IntrinsicType::kDot},
IntrinsicData{"dpdx", IntrinsicType::kDpdx},
IntrinsicData{"dpdxCoarse", IntrinsicType::kDpdxCoarse},
IntrinsicData{"dpdxFine", IntrinsicType::kDpdxFine},
IntrinsicData{"dpdy", IntrinsicType::kDpdy},
IntrinsicData{"dpdyCoarse", IntrinsicType::kDpdyCoarse},
IntrinsicData{"dpdyFine", IntrinsicType::kDpdyFine},
IntrinsicData{"exp", IntrinsicType::kExp},
IntrinsicData{"exp2", IntrinsicType::kExp2},
IntrinsicData{"faceForward", IntrinsicType::kFaceForward},
IntrinsicData{"floor", IntrinsicType::kFloor},
IntrinsicData{"fma", IntrinsicType::kFma},
IntrinsicData{"fract", IntrinsicType::kFract},
IntrinsicData{"frexp", IntrinsicType::kFrexp},
IntrinsicData{"fwidth", IntrinsicType::kFwidth},
IntrinsicData{"fwidthCoarse", IntrinsicType::kFwidthCoarse},
IntrinsicData{"fwidthFine", IntrinsicType::kFwidthFine},
IntrinsicData{"inverseSqrt", IntrinsicType::kInverseSqrt},
IntrinsicData{"isFinite", IntrinsicType::kIsFinite},
IntrinsicData{"isInf", IntrinsicType::kIsInf},
IntrinsicData{"isNan", IntrinsicType::kIsNan},
IntrinsicData{"isNormal", IntrinsicType::kIsNormal},
IntrinsicData{"ldexp", IntrinsicType::kLdexp},
IntrinsicData{"length", IntrinsicType::kLength},
IntrinsicData{"log", IntrinsicType::kLog},
IntrinsicData{"log2", IntrinsicType::kLog2},
IntrinsicData{"max", IntrinsicType::kMax},
IntrinsicData{"min", IntrinsicType::kMin},
IntrinsicData{"mix", IntrinsicType::kMix},
IntrinsicData{"modf", IntrinsicType::kModf},
IntrinsicData{"normalize", IntrinsicType::kNormalize},
IntrinsicData{"pow", IntrinsicType::kPow},
IntrinsicData{"reflect", IntrinsicType::kReflect},
IntrinsicData{"reverseBits", IntrinsicType::kReverseBits},
IntrinsicData{"round", IntrinsicType::kRound},
IntrinsicData{"select", IntrinsicType::kSelect},
IntrinsicData{"sign", IntrinsicType::kSign},
IntrinsicData{"sin", IntrinsicType::kSin},
IntrinsicData{"sinh", IntrinsicType::kSinh},
IntrinsicData{"smoothStep", IntrinsicType::kSmoothStep},
IntrinsicData{"sqrt", IntrinsicType::kSqrt},
IntrinsicData{"step", IntrinsicType::kStep},
IntrinsicData{"tan", IntrinsicType::kTan},
IntrinsicData{"tanh", IntrinsicType::kTanh},
IntrinsicData{"textureDimensions", IntrinsicType::kTextureDimensions},
IntrinsicData{"textureLoad", IntrinsicType::kTextureLoad},
IntrinsicData{"textureNumLayers", IntrinsicType::kTextureNumLayers},
IntrinsicData{"textureNumLevels", IntrinsicType::kTextureNumLevels},
IntrinsicData{"textureNumSamples", IntrinsicType::kTextureNumSamples},
IntrinsicData{"textureSample", IntrinsicType::kTextureSample},
IntrinsicData{"textureSampleBias", IntrinsicType::kTextureSampleBias},
IntrinsicData{"textureSampleCompare",
IntrinsicType::kTextureSampleCompare},
IntrinsicData{"textureSampleGrad", IntrinsicType::kTextureSampleGrad},
IntrinsicData{"textureSampleLevel", IntrinsicType::kTextureSampleLevel},
IntrinsicData{"trunc", IntrinsicType::kTrunc}));
TEST_F(TypeDeterminerTest, MatchIntrinsicNoMatch) {
EXPECT_EQ(TypeDeterminer::MatchIntrinsicType("not_intrinsic"),
IntrinsicType::kNone);
}
using Intrinsic_DataPackingTest = TypeDeterminerTestWithParam<IntrinsicData>;
TEST_P(Intrinsic_DataPackingTest, InferType) {
@ -2270,6 +2184,8 @@ INSTANTIATE_TEST_SUITE_P(
IntrinsicData{"tanh", IntrinsicType::kTanh},
IntrinsicData{"trunc", IntrinsicType::kTrunc}));
using IntrinsicDataTest = TypeDeterminerTest;
TEST_F(IntrinsicDataTest, ArrayLength_Vector) {
Global("arr", ty.array<int>(), ast::StorageClass::kNone);
auto* call = Call("arrayLength", "arr");