Move core intrinsic table_test off ProgramBuilder.
The core intrinsic table tests were using the program builder to get a
type manager and symbol table. Create them directly and remove the
program builder dependency.
Change-Id: I93b25ba0d872ebf7ebdc4aa6ca2d3ca37fbb0af8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/234534
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
diff --git a/src/tint/lang/core/intrinsic/BUILD.bazel b/src/tint/lang/core/intrinsic/BUILD.bazel
index 69d97d8..49ca08f 100644
--- a/src/tint/lang/core/intrinsic/BUILD.bazel
+++ b/src/tint/lang/core/intrinsic/BUILD.bazel
@@ -76,16 +76,11 @@
"table_test.cc",
],
deps = [
- "//src/tint/api/common",
"//src/tint/lang/core",
"//src/tint/lang/core/constant",
"//src/tint/lang/core/intrinsic",
"//src/tint/lang/core/type",
"//src/tint/lang/core/type:test",
- "//src/tint/lang/wgsl",
- "//src/tint/lang/wgsl/ast",
- "//src/tint/lang/wgsl/program",
- "//src/tint/lang/wgsl/sem",
"//src/tint/utils",
"//src/tint/utils/containers",
"//src/tint/utils/diagnostic",
diff --git a/src/tint/lang/core/intrinsic/BUILD.cmake b/src/tint/lang/core/intrinsic/BUILD.cmake
index ec55ac4..09d3cd2 100644
--- a/src/tint/lang/core/intrinsic/BUILD.cmake
+++ b/src/tint/lang/core/intrinsic/BUILD.cmake
@@ -78,16 +78,11 @@
)
tint_target_add_dependencies(tint_lang_core_intrinsic_test test
- tint_api_common
tint_lang_core
tint_lang_core_constant
tint_lang_core_intrinsic
tint_lang_core_type
tint_lang_core_type_test
- tint_lang_wgsl
- tint_lang_wgsl_ast
- tint_lang_wgsl_program
- tint_lang_wgsl_sem
tint_utils
tint_utils_containers
tint_utils_diagnostic
diff --git a/src/tint/lang/core/intrinsic/BUILD.gn b/src/tint/lang/core/intrinsic/BUILD.gn
index 6d28a9f..0f5c583 100644
--- a/src/tint/lang/core/intrinsic/BUILD.gn
+++ b/src/tint/lang/core/intrinsic/BUILD.gn
@@ -77,16 +77,11 @@
deps = [
"${dawn_root}/src/utils:utils",
"${tint_src_dir}:gmock_and_gtest",
- "${tint_src_dir}/api/common",
"${tint_src_dir}/lang/core",
"${tint_src_dir}/lang/core/constant",
"${tint_src_dir}/lang/core/intrinsic",
"${tint_src_dir}/lang/core/type",
"${tint_src_dir}/lang/core/type:unittests",
- "${tint_src_dir}/lang/wgsl",
- "${tint_src_dir}/lang/wgsl/ast",
- "${tint_src_dir}/lang/wgsl/program",
- "${tint_src_dir}/lang/wgsl/sem",
"${tint_src_dir}/utils",
"${tint_src_dir}/utils/containers",
"${tint_src_dir}/utils/diagnostic",
diff --git a/src/tint/lang/core/intrinsic/table_test.cc b/src/tint/lang/core/intrinsic/table_test.cc
index 593dab7..5067acd 100644
--- a/src/tint/lang/core/intrinsic/table_test.cc
+++ b/src/tint/lang/core/intrinsic/table_test.cc
@@ -32,30 +32,45 @@
#include "gmock/gmock.h"
#include "src/tint/lang/core/intrinsic/dialect.h"
#include "src/tint/lang/core/intrinsic/table_data.h"
+#include "src/tint/lang/core/type/array.h"
#include "src/tint/lang/core/type/atomic.h"
+#include "src/tint/lang/core/type/bool.h"
#include "src/tint/lang/core/type/depth_multisampled_texture.h"
#include "src/tint/lang/core/type/depth_texture.h"
#include "src/tint/lang/core/type/external_texture.h"
+#include "src/tint/lang/core/type/f32.h"
#include "src/tint/lang/core/type/helper_test.h"
+#include "src/tint/lang/core/type/i32.h"
+#include "src/tint/lang/core/type/manager.h"
+#include "src/tint/lang/core/type/matrix.h"
#include "src/tint/lang/core/type/multisampled_texture.h"
+#include "src/tint/lang/core/type/pointer.h"
#include "src/tint/lang/core/type/sampled_texture.h"
+#include "src/tint/lang/core/type/sampler.h"
#include "src/tint/lang/core/type/storage_texture.h"
#include "src/tint/lang/core/type/texture_dimension.h"
-#include "src/tint/lang/wgsl/program/program_builder.h"
+#include "src/tint/lang/core/type/u32.h"
+#include "src/tint/lang/core/type/vector.h"
+#include "src/tint/lang/core/type/void.h"
#include "src/tint/utils/containers/vector.h"
+#include "src/tint/utils/symbol/symbol.h"
+#include "src/tint/utils/symbol/symbol_table.h"
namespace tint::core::intrinsic {
namespace {
using ::testing::HasSubstr;
-class CoreIntrinsicTableTest : public testing::Test, public ProgramBuilder {
+class CoreIntrinsicTableTest : public testing::Test {
public:
- Table<Dialect> table{Types(), Symbols()};
+ GenerationID id = GenerationID::New();
+ SymbolTable syms{id};
+ type::Manager ty;
+ Table<Dialect> table{ty, syms};
};
TEST_F(CoreIntrinsicTableTest, MatchF32) {
- auto* f32 = create<type::F32>();
+ auto* f32 = ty.f32();
auto result = table.Lookup(BuiltinFn::kCos, Empty, Vector{f32}, EvaluationStage::kConstant);
ASSERT_EQ(result, Success);
EXPECT_EQ(result->return_type, f32);
@@ -64,16 +79,16 @@
}
TEST_F(CoreIntrinsicTableTest, MismatchF32) {
- auto* i32 = create<type::I32>();
+ auto* i32 = ty.i32();
auto result = table.Lookup(BuiltinFn::kCos, Empty, Vector{i32}, EvaluationStage::kConstant);
ASSERT_NE(result, Success);
ASSERT_THAT(result.Failure().Plain(), HasSubstr("no matching call"));
}
TEST_F(CoreIntrinsicTableTest, MatchU32) {
- auto* f32 = create<type::F32>();
- auto* u32 = create<type::U32>();
- auto* vec2f = create<type::Vector>(f32, 2u);
+ auto* f32 = ty.f32();
+ auto* u32 = ty.u32();
+ auto* vec2f = ty.vec2(f32);
auto result =
table.Lookup(BuiltinFn::kUnpack2X16Float, Empty, Vector{u32}, EvaluationStage::kConstant);
ASSERT_EQ(result, Success);
@@ -83,7 +98,7 @@
}
TEST_F(CoreIntrinsicTableTest, MismatchU32) {
- auto* f32 = create<type::F32>();
+ auto* f32 = ty.f32();
auto result =
table.Lookup(BuiltinFn::kUnpack2X16Float, Empty, Vector{f32}, EvaluationStage::kConstant);
ASSERT_NE(result, Success);
@@ -91,10 +106,10 @@
}
TEST_F(CoreIntrinsicTableTest, MatchI32) {
- auto* f32 = create<type::F32>();
- auto* i32 = create<type::I32>();
- auto* vec4f = create<type::Vector>(f32, 4u);
- auto* tex = create<type::SampledTexture>(type::TextureDimension::k1d, f32);
+ auto* f32 = ty.f32();
+ auto* i32 = ty.i32();
+ auto* vec4f = ty.vec4(ty.f32());
+ auto* tex = ty.sampled_texture(type::TextureDimension::k1d, f32);
auto result = table.Lookup(BuiltinFn::kTextureLoad, Empty, Vector{tex, i32, i32},
EvaluationStage::kConstant);
ASSERT_EQ(result, Success);
@@ -109,8 +124,8 @@
}
TEST_F(CoreIntrinsicTableTest, MismatchI32) {
- auto* f32 = create<type::F32>();
- auto* tex = create<type::SampledTexture>(type::TextureDimension::k1d, f32);
+ auto* f32 = ty.f32();
+ auto* tex = ty.sampled_texture(type::TextureDimension::k1d, f32);
auto result =
table.Lookup(BuiltinFn::kTextureLoad, Empty, Vector{tex, f32}, EvaluationStage::kConstant);
ASSERT_NE(result, Success);
@@ -118,7 +133,7 @@
}
TEST_F(CoreIntrinsicTableTest, MatchIU32AsI32) {
- auto* i32 = create<type::I32>();
+ auto* i32 = ty.i32();
auto result =
table.Lookup(BuiltinFn::kCountOneBits, Empty, Vector{i32}, EvaluationStage::kConstant);
ASSERT_EQ(result, Success);
@@ -128,7 +143,7 @@
}
TEST_F(CoreIntrinsicTableTest, MatchIU32AsU32) {
- auto* u32 = create<type::U32>();
+ auto* u32 = ty.u32();
auto result =
table.Lookup(BuiltinFn::kCountOneBits, Empty, Vector{u32}, EvaluationStage::kConstant);
ASSERT_EQ(result, Success);
@@ -138,7 +153,7 @@
}
TEST_F(CoreIntrinsicTableTest, MismatchIU32) {
- auto* f32 = create<type::F32>();
+ auto* f32 = ty.f32();
auto result =
table.Lookup(BuiltinFn::kCountOneBits, Empty, Vector{f32}, EvaluationStage::kConstant);
ASSERT_NE(result, Success);
@@ -146,7 +161,7 @@
}
TEST_F(CoreIntrinsicTableTest, MatchFIU32AsI32) {
- auto* i32 = create<type::I32>();
+ auto* i32 = ty.i32();
auto result =
table.Lookup(BuiltinFn::kClamp, Empty, Vector{i32, i32, i32}, EvaluationStage::kConstant);
ASSERT_EQ(result, Success);
@@ -158,7 +173,7 @@
}
TEST_F(CoreIntrinsicTableTest, MatchFIU32AsU32) {
- auto* u32 = create<type::U32>();
+ auto* u32 = ty.u32();
auto result =
table.Lookup(BuiltinFn::kClamp, Empty, Vector{u32, u32, u32}, EvaluationStage::kConstant);
ASSERT_EQ(result, Success);
@@ -170,7 +185,7 @@
}
TEST_F(CoreIntrinsicTableTest, MatchFIU32AsF32) {
- auto* f32 = create<type::F32>();
+ auto* f32 = ty.f32();
auto result =
table.Lookup(BuiltinFn::kClamp, Empty, Vector{f32, f32, f32}, EvaluationStage::kConstant);
ASSERT_EQ(result, Success);
@@ -182,7 +197,7 @@
}
TEST_F(CoreIntrinsicTableTest, MismatchFIU32) {
- auto* bool_ = create<type::Bool>();
+ auto* bool_ = ty.bool_();
auto result = table.Lookup(BuiltinFn::kClamp, Empty, Vector{bool_, bool_, bool_},
EvaluationStage::kConstant);
ASSERT_NE(result, Success);
@@ -190,8 +205,8 @@
}
TEST_F(CoreIntrinsicTableTest, MatchBool) {
- auto* f32 = create<type::F32>();
- auto* bool_ = create<type::Bool>();
+ auto* f32 = ty.f32();
+ auto* bool_ = ty.bool_();
auto result = table.Lookup(BuiltinFn::kSelect, Empty, Vector{f32, f32, bool_},
EvaluationStage::kConstant);
ASSERT_EQ(result, Success);
@@ -203,7 +218,7 @@
}
TEST_F(CoreIntrinsicTableTest, MismatchBool) {
- auto* f32 = create<type::F32>();
+ auto* f32 = ty.f32();
auto result =
table.Lookup(BuiltinFn::kSelect, Empty, Vector{f32, f32, f32}, EvaluationStage::kConstant);
ASSERT_NE(result, Success);
@@ -211,9 +226,9 @@
}
TEST_F(CoreIntrinsicTableTest, MatchPointer) {
- auto* i32 = create<type::I32>();
- auto* atomic_i32 = create<type::Atomic>(i32);
- auto* ptr = create<type::Pointer>(AddressSpace::kWorkgroup, atomic_i32, Access::kReadWrite);
+ auto* i32 = ty.i32();
+ auto* atomic_i32 = ty.atomic(i32);
+ auto* ptr = ty.ptr(AddressSpace::kWorkgroup, atomic_i32, Access::kReadWrite);
auto result =
table.Lookup(BuiltinFn::kAtomicLoad, Empty, Vector{ptr}, EvaluationStage::kConstant);
ASSERT_EQ(result, Success);
@@ -223,8 +238,8 @@
}
TEST_F(CoreIntrinsicTableTest, MismatchPointer) {
- auto* i32 = create<type::I32>();
- auto* atomic_i32 = create<type::Atomic>(i32);
+ auto* i32 = ty.i32();
+ auto* atomic_i32 = ty.atomic(i32);
auto result =
table.Lookup(BuiltinFn::kAtomicLoad, Empty, Vector{atomic_i32}, EvaluationStage::kConstant);
ASSERT_NE(result, Success);
@@ -232,9 +247,8 @@
}
TEST_F(CoreIntrinsicTableTest, MatchArray) {
- auto* arr =
- create<type::Array>(create<type::U32>(), create<type::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
- auto* arr_ptr = create<type::Pointer>(AddressSpace::kStorage, arr, Access::kReadWrite);
+ auto* arr = ty.runtime_array(ty.u32());
+ auto* arr_ptr = ty.ptr(AddressSpace::kStorage, arr, Access::kReadWrite);
auto result =
table.Lookup(BuiltinFn::kArrayLength, Empty, Vector{arr_ptr}, EvaluationStage::kConstant);
ASSERT_EQ(result, Success);
@@ -246,7 +260,7 @@
}
TEST_F(CoreIntrinsicTableTest, MismatchArray) {
- auto* f32 = create<type::F32>();
+ auto* f32 = ty.f32();
auto result =
table.Lookup(BuiltinFn::kArrayLength, Empty, Vector{f32}, EvaluationStage::kConstant);
ASSERT_NE(result, Success);
@@ -254,11 +268,11 @@
}
TEST_F(CoreIntrinsicTableTest, MatchSampler) {
- auto* f32 = create<type::F32>();
- auto* vec2f = create<type::Vector>(f32, 2u);
- auto* vec4f = create<type::Vector>(f32, 4u);
- auto* tex = create<type::SampledTexture>(type::TextureDimension::k2d, f32);
- auto* sampler = create<type::Sampler>(type::SamplerKind::kSampler);
+ auto* f32 = ty.f32();
+ auto* vec2f = ty.vec2(f32);
+ auto* vec4f = ty.vec4(f32);
+ auto* tex = ty.sampled_texture(type::TextureDimension::k2d, f32);
+ auto* sampler = ty.sampler();
auto result = table.Lookup(BuiltinFn::kTextureSample, Empty, Vector{tex, sampler, vec2f},
EvaluationStage::kConstant);
ASSERT_EQ(result, Success);
@@ -273,9 +287,9 @@
}
TEST_F(CoreIntrinsicTableTest, MismatchSampler) {
- auto* f32 = create<type::F32>();
- auto* vec2f = create<type::Vector>(f32, 2u);
- auto* tex = create<type::SampledTexture>(type::TextureDimension::k2d, f32);
+ auto* f32 = ty.f32();
+ auto* vec2f = ty.vec2(f32);
+ auto* tex = ty.sampled_texture(type::TextureDimension::k2d, f32);
auto result = table.Lookup(BuiltinFn::kTextureSample, Empty, Vector{tex, f32, vec2f},
EvaluationStage::kConstant);
ASSERT_NE(result, Success);
@@ -283,11 +297,11 @@
}
TEST_F(CoreIntrinsicTableTest, MatchSampledTexture) {
- auto* i32 = create<type::I32>();
- auto* f32 = create<type::F32>();
- auto* vec2i = create<type::Vector>(i32, 2u);
- auto* vec4f = create<type::Vector>(f32, 4u);
- auto* tex = create<type::SampledTexture>(type::TextureDimension::k2d, f32);
+ auto* i32 = ty.i32();
+ auto* f32 = ty.f32();
+ auto* vec2i = ty.vec2(i32);
+ auto* vec4f = ty.vec4(f32);
+ auto* tex = ty.sampled_texture(type::TextureDimension::k2d, f32);
auto result = table.Lookup(BuiltinFn::kTextureLoad, Empty, Vector{tex, vec2i, i32},
EvaluationStage::kConstant);
ASSERT_EQ(result, Success);
@@ -302,11 +316,11 @@
}
TEST_F(CoreIntrinsicTableTest, MatchMultisampledTexture) {
- auto* i32 = create<type::I32>();
- auto* f32 = create<type::F32>();
- auto* vec2i = create<type::Vector>(i32, 2u);
- auto* vec4f = create<type::Vector>(f32, 4u);
- auto* tex = create<type::MultisampledTexture>(type::TextureDimension::k2d, f32);
+ auto* i32 = ty.i32();
+ auto* f32 = ty.f32();
+ auto* vec2i = ty.vec2(i32);
+ auto* vec4f = ty.vec4(f32);
+ auto* tex = ty.multisampled_texture(type::TextureDimension::k2d, f32);
auto result = table.Lookup(BuiltinFn::kTextureLoad, Empty, Vector{tex, vec2i, i32},
EvaluationStage::kConstant);
ASSERT_EQ(result, Success);
@@ -321,10 +335,10 @@
}
TEST_F(CoreIntrinsicTableTest, MatchDepthTexture) {
- auto* f32 = create<type::F32>();
- auto* i32 = create<type::I32>();
- auto* vec2i = create<type::Vector>(i32, 2u);
- auto* tex = create<type::DepthTexture>(type::TextureDimension::k2d);
+ auto* f32 = ty.f32();
+ auto* i32 = ty.i32();
+ auto* vec2i = ty.vec2(i32);
+ auto* tex = ty.depth_texture(type::TextureDimension::k2d);
auto result = table.Lookup(BuiltinFn::kTextureLoad, Empty, Vector{tex, vec2i, i32},
EvaluationStage::kConstant);
ASSERT_EQ(result, Success);
@@ -339,10 +353,10 @@
}
TEST_F(CoreIntrinsicTableTest, MatchDepthMultisampledTexture) {
- auto* f32 = create<type::F32>();
- auto* i32 = create<type::I32>();
- auto* vec2i = create<type::Vector>(i32, 2u);
- auto* tex = create<type::DepthMultisampledTexture>(type::TextureDimension::k2d);
+ auto* f32 = ty.f32();
+ auto* i32 = ty.i32();
+ auto* vec2i = ty.vec2(i32);
+ auto* tex = ty.depth_multisampled_texture(type::TextureDimension::k2d);
auto result = table.Lookup(BuiltinFn::kTextureLoad, Empty, Vector{tex, vec2i, i32},
EvaluationStage::kConstant);
ASSERT_EQ(result, Success);
@@ -357,11 +371,11 @@
}
TEST_F(CoreIntrinsicTableTest, MatchExternalTexture) {
- auto* f32 = create<type::F32>();
- auto* i32 = create<type::I32>();
- auto* vec2i = create<type::Vector>(i32, 2u);
- auto* vec4f = create<type::Vector>(f32, 4u);
- auto* tex = create<type::ExternalTexture>();
+ auto* f32 = ty.f32();
+ auto* i32 = ty.i32();
+ auto* vec2i = ty.vec2(i32);
+ auto* vec4f = ty.vec4(f32);
+ auto* tex = ty.external_texture();
auto result = table.Lookup(BuiltinFn::kTextureLoad, Empty, Vector{tex, vec2i},
EvaluationStage::kConstant);
ASSERT_EQ(result, Success);
@@ -374,13 +388,12 @@
}
TEST_F(CoreIntrinsicTableTest, MatchWOStorageTexture) {
- auto* f32 = create<type::F32>();
- auto* i32 = create<type::I32>();
- auto* vec2i = create<type::Vector>(i32, 2u);
- auto* vec4f = create<type::Vector>(f32, 4u);
- auto* subtype = type::StorageTexture::SubtypeFor(TexelFormat::kR32Float, Types());
- auto* tex = create<type::StorageTexture>(type::TextureDimension::k2d, TexelFormat::kR32Float,
- Access::kWrite, subtype);
+ auto* f32 = ty.f32();
+ auto* i32 = ty.i32();
+ auto* vec2i = ty.vec2(i32);
+ auto* vec4f = ty.vec4(f32);
+ auto* tex =
+ ty.storage_texture(type::TextureDimension::k2d, TexelFormat::kR32Float, Access::kWrite);
auto result = table.Lookup(BuiltinFn::kTextureStore, Empty, Vector{tex, vec2i, vec4f},
EvaluationStage::kConstant);
@@ -396,9 +409,9 @@
}
TEST_F(CoreIntrinsicTableTest, MismatchTexture) {
- auto* f32 = create<type::F32>();
- auto* i32 = create<type::I32>();
- auto* vec2i = create<type::Vector>(i32, 2u);
+ auto* f32 = ty.f32();
+ auto* i32 = ty.i32();
+ auto* vec2i = ty.vec2(i32);
auto result = table.Lookup(BuiltinFn::kTextureLoad, Empty, Vector{f32, vec2i},
EvaluationStage::kConstant);
ASSERT_NE(result, Success);
@@ -406,7 +419,7 @@
}
TEST_F(CoreIntrinsicTableTest, MatchTemplateType) {
- auto* f32 = create<type::F32>();
+ auto* f32 = ty.f32();
auto result =
table.Lookup(BuiltinFn::kClamp, Empty, Vector{f32, f32, f32}, EvaluationStage::kConstant);
ASSERT_EQ(result, Success);
@@ -417,8 +430,8 @@
}
TEST_F(CoreIntrinsicTableTest, MismatchTemplateType) {
- auto* f32 = create<type::F32>();
- auto* u32 = create<type::U32>();
+ auto* f32 = ty.f32();
+ auto* u32 = ty.u32();
auto result =
table.Lookup(BuiltinFn::kClamp, Empty, Vector{f32, u32, f32}, EvaluationStage::kConstant);
ASSERT_NE(result, Success);
@@ -426,8 +439,8 @@
}
TEST_F(CoreIntrinsicTableTest, MatchOpenSizeVector) {
- auto* f32 = create<type::F32>();
- auto* vec2f = create<type::Vector>(f32, 2u);
+ auto* f32 = ty.f32();
+ auto* vec2f = ty.vec2(f32);
auto result = table.Lookup(BuiltinFn::kClamp, Empty, Vector{vec2f, vec2f, vec2f},
EvaluationStage::kConstant);
ASSERT_EQ(result, Success);
@@ -439,9 +452,9 @@
}
TEST_F(CoreIntrinsicTableTest, MismatchOpenSizeVector) {
- auto* f32 = create<type::F32>();
- auto* u32 = create<type::U32>();
- auto* vec2f = create<type::Vector>(f32, 2u);
+ auto* f32 = ty.f32();
+ auto* u32 = ty.u32();
+ auto* vec2f = ty.vec2(f32);
auto result = table.Lookup(BuiltinFn::kClamp, Empty, Vector{vec2f, u32, vec2f},
EvaluationStage::kConstant);
ASSERT_NE(result, Success);
@@ -449,9 +462,8 @@
}
TEST_F(CoreIntrinsicTableTest, MatchOpenSizeMatrix) {
- auto* f32 = create<type::F32>();
- auto* vec3f = create<type::Vector>(f32, 3u);
- auto* mat3x3f = create<type::Matrix>(vec3f, 3u);
+ auto* f32 = ty.f32();
+ auto* mat3x3f = ty.mat3x3(f32);
auto result =
table.Lookup(BuiltinFn::kDeterminant, Empty, Vector{mat3x3f}, EvaluationStage::kConstant);
ASSERT_EQ(result, Success);
@@ -461,9 +473,8 @@
}
TEST_F(CoreIntrinsicTableTest, MismatchOpenSizeMatrix) {
- auto* f32 = create<type::F32>();
- auto* vec2f = create<type::Vector>(f32, 2u);
- auto* mat3x2f = create<type::Matrix>(vec2f, 3u);
+ auto* f32 = ty.f32();
+ auto* mat3x2f = ty.mat3x2(f32);
auto result =
table.Lookup(BuiltinFn::kDeterminant, Empty, Vector{mat3x2f}, EvaluationStage::kConstant);
ASSERT_NE(result, Success);
@@ -471,8 +482,8 @@
}
TEST_F(CoreIntrinsicTableTest, MatchDifferentArgsElementType_Builtin_ConstantEval) {
- auto* f32 = create<type::F32>();
- auto* bool_ = create<type::Bool>();
+ auto* f32 = ty.f32();
+ auto* bool_ = ty.bool_();
auto result = table.Lookup(BuiltinFn::kSelect, Empty, Vector{f32, f32, bool_},
EvaluationStage::kConstant);
ASSERT_EQ(result, Success);
@@ -485,8 +496,8 @@
}
TEST_F(CoreIntrinsicTableTest, MatchDifferentArgsElementType_Builtin_RuntimeEval) {
- auto* f32 = create<type::F32>();
- auto result = table.Lookup(BuiltinFn::kSelect, Empty, Vector{f32, f32, create<type::Bool>()},
+ auto* f32 = ty.f32();
+ auto result = table.Lookup(BuiltinFn::kSelect, Empty, Vector{f32, f32, ty.bool_()},
EvaluationStage::kRuntime);
ASSERT_EQ(result, Success);
EXPECT_NE(result->const_eval_fn, nullptr);
@@ -498,22 +509,22 @@
}
TEST_F(CoreIntrinsicTableTest, MatchDifferentArgsElementType_Binary_ConstantEval) {
- auto* i32 = create<type::I32>();
- auto* u32 = create<type::U32>();
+ auto* i32 = ty.i32();
+ auto* u32 = ty.u32();
auto result = table.Lookup(BinaryOp::kShiftLeft, i32, u32, EvaluationStage::kConstant, false);
ASSERT_EQ(result, Success);
- ASSERT_NE(result->const_eval_fn, nullptr) << Diagnostics();
+ ASSERT_NE(result->const_eval_fn, nullptr);
EXPECT_EQ(result->return_type, i32);
EXPECT_EQ(result->parameters[0].type, i32);
EXPECT_EQ(result->parameters[1].type, u32);
}
TEST_F(CoreIntrinsicTableTest, MatchDifferentArgsElementType_Binary_RuntimeEval) {
- auto* i32 = create<type::I32>();
- auto* u32 = create<type::U32>();
+ auto* i32 = ty.i32();
+ auto* u32 = ty.u32();
auto result = table.Lookup(BinaryOp::kShiftLeft, i32, u32, EvaluationStage::kRuntime, false);
ASSERT_EQ(result, Success);
- ASSERT_NE(result->const_eval_fn, nullptr) << Diagnostics();
+ ASSERT_NE(result->const_eval_fn, nullptr);
EXPECT_TRUE(result->return_type->Is<type::I32>());
EXPECT_TRUE(result->parameters[0].type->Is<type::I32>());
EXPECT_TRUE(result->parameters[1].type->Is<type::U32>());
@@ -522,7 +533,7 @@
TEST_F(CoreIntrinsicTableTest, OverloadOrderByNumberOfParameters) {
// None of the arguments match, so expect the overloads with 2 parameters to
// come first
- auto* bool_ = create<type::Bool>();
+ auto* bool_ = ty.bool_();
auto result = table.Lookup(BuiltinFn::kTextureDimensions, Empty, Vector{bool_, bool_},
EvaluationStage::kConstant);
ASSERT_NE(result, Success);
@@ -584,8 +595,8 @@
}
TEST_F(CoreIntrinsicTableTest, OverloadOrderByMatchingParameter) {
- auto* tex = create<type::DepthTexture>(type::TextureDimension::k2d);
- auto* bool_ = create<type::Bool>();
+ auto* tex = ty.depth_texture(type::TextureDimension::k2d);
+ auto* bool_ = ty.bool_();
auto result = table.Lookup(BuiltinFn::kTextureDimensions, Empty, Vector{tex, bool_},
EvaluationStage::kConstant);
ASSERT_NE(result, Success);
@@ -648,15 +659,15 @@
}
TEST_F(CoreIntrinsicTableTest, MatchUnaryOp) {
- auto* i32 = create<type::I32>();
- auto* vec3i = create<type::Vector>(i32, 3u);
+ auto* i32 = ty.i32();
+ auto* vec3i = ty.vec3(i32);
auto result = table.Lookup(UnaryOp::kNegation, vec3i, EvaluationStage::kConstant);
ASSERT_EQ(result, Success);
EXPECT_EQ(result->return_type, vec3i);
}
TEST_F(CoreIntrinsicTableTest, MismatchUnaryOp) {
- auto* bool_ = create<type::Bool>();
+ auto* bool_ = ty.bool_();
auto result = table.Lookup(UnaryOp::kNegation, bool_, EvaluationStage::kConstant);
ASSERT_NE(result, Success);
EXPECT_EQ(result.Failure().Plain(), R"(no matching overload for 'operator - (bool)'
@@ -670,22 +681,22 @@
}
TEST_F(CoreIntrinsicTableTest, MatchUnaryOp_Constant) {
- auto* i32 = create<type::I32>();
+ auto* i32 = ty.i32();
auto result = table.Lookup(UnaryOp::kNegation, i32, EvaluationStage::kConstant);
ASSERT_EQ(result, Success);
EXPECT_EQ(result->return_type, i32);
}
TEST_F(CoreIntrinsicTableTest, MatchUnaryOp_Runtime) {
- auto* i32 = create<type::I32>();
+ auto* i32 = ty.i32();
auto result = table.Lookup(UnaryOp::kNegation, i32, EvaluationStage::kRuntime);
ASSERT_EQ(result, Success);
EXPECT_EQ(result->return_type, i32);
}
TEST_F(CoreIntrinsicTableTest, MatchBinaryOp) {
- auto* i32 = create<type::I32>();
- auto* vec3i = create<type::Vector>(i32, 3u);
+ auto* i32 = ty.i32();
+ auto* vec3i = ty.vec3(i32);
auto result = table.Lookup(BinaryOp::kMultiply, i32, vec3i, EvaluationStage::kConstant,
/* is_compound */ false);
ASSERT_EQ(result, Success);
@@ -695,8 +706,8 @@
}
TEST_F(CoreIntrinsicTableTest, MismatchBinaryOp) {
- auto* f32 = create<type::F32>();
- auto* bool_ = create<type::Bool>();
+ auto* f32 = ty.f32();
+ auto* bool_ = ty.bool_();
auto result = table.Lookup(BinaryOp::kMultiply, f32, bool_, EvaluationStage::kConstant,
/* is_compound */ false);
ASSERT_NE(result, Success);
@@ -725,8 +736,8 @@
}
TEST_F(CoreIntrinsicTableTest, MatchCompoundOp) {
- auto* i32 = create<type::I32>();
- auto* vec3i = create<type::Vector>(i32, 3u);
+ auto* i32 = ty.i32();
+ auto* vec3i = ty.vec3(i32);
auto result = table.Lookup(BinaryOp::kMultiply, i32, vec3i, EvaluationStage::kConstant,
/* is_compound */ true);
ASSERT_EQ(result, Success);
@@ -736,8 +747,8 @@
}
TEST_F(CoreIntrinsicTableTest, MismatchCompoundOp) {
- auto* f32 = create<type::F32>();
- auto* bool_ = create<type::Bool>();
+ auto* f32 = ty.f32();
+ auto* bool_ = ty.bool_();
auto result = table.Lookup(BinaryOp::kMultiply, f32, bool_, EvaluationStage::kConstant,
/* is_compound */ true);
ASSERT_NE(result, Success);
@@ -766,8 +777,8 @@
}
TEST_F(CoreIntrinsicTableTest, MatchTypeInitializer) {
- auto* i32 = create<type::I32>();
- auto* vec3i = create<type::Vector>(i32, 3u);
+ auto* i32 = ty.i32();
+ auto* vec3i = ty.vec3(i32);
auto result = table.Lookup(CtorConv::kVec3, Vector{i32}, Vector{i32, i32, i32},
EvaluationStage::kConstant);
ASSERT_EQ(result, Success);
@@ -781,8 +792,8 @@
}
TEST_F(CoreIntrinsicTableTest, MismatchTypeInitializer) {
- auto* i32 = create<type::I32>();
- auto* f32 = create<type::F32>();
+ auto* i32 = ty.i32();
+ auto* f32 = ty.f32();
auto result = table.Lookup(CtorConv::kVec3, Vector{i32}, Vector{i32, f32, i32},
EvaluationStage::kConstant);
ASSERT_NE(result, Success);
@@ -825,8 +836,8 @@
}
TEST_F(CoreIntrinsicTableTest, MatchTypeInitializer_ConstantEval) {
- auto* i32 = create<type::I32>();
- auto* vec3i = create<type::Vector>(i32, 3u);
+ auto* i32 = ty.i32();
+ auto* vec3i = ty.vec3(i32);
auto result = table.Lookup(CtorConv::kVec3, Vector{i32}, Vector{i32, i32, i32},
EvaluationStage::kConstant);
ASSERT_EQ(result, Success);
@@ -841,10 +852,10 @@
}
TEST_F(CoreIntrinsicTableTest, MatchTypeInitializer_RuntimeEval) {
- auto* i32 = create<type::I32>();
+ auto* i32 = ty.i32();
auto result = table.Lookup(CtorConv::kVec3, Vector{i32}, Vector{i32, i32, i32},
EvaluationStage::kRuntime);
- auto* vec3i = create<type::Vector>(i32, 3u);
+ auto* vec3i = ty.vec3(i32);
ASSERT_EQ(result, Success);
EXPECT_NE(result->const_eval_fn, nullptr);
EXPECT_EQ(result->return_type, vec3i);
@@ -857,10 +868,10 @@
}
TEST_F(CoreIntrinsicTableTest, MatchTypeConversion) {
- auto* i32 = create<type::I32>();
- auto* vec3i = create<type::Vector>(i32, 3u);
- auto* f32 = create<type::F32>();
- auto* vec3f = create<type::Vector>(f32, 3u);
+ auto* i32 = ty.i32();
+ auto* vec3i = ty.vec3(i32);
+ auto* f32 = ty.f32();
+ auto* vec3f = ty.vec3(f32);
auto result =
table.Lookup(CtorConv::kVec3, Vector{i32}, Vector{vec3f}, EvaluationStage::kConstant);
ASSERT_EQ(result, Success);
@@ -871,9 +882,8 @@
}
TEST_F(CoreIntrinsicTableTest, MismatchTypeConversion) {
- auto* arr =
- create<type::Array>(create<type::U32>(), create<type::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
- auto* f32 = create<type::F32>();
+ auto* arr = ty.runtime_array(ty.u32());
+ auto* f32 = ty.f32();
auto result =
table.Lookup(CtorConv::kVec3, Vector{f32}, Vector{arr}, EvaluationStage::kConstant);
ASSERT_NE(result, Success);
@@ -915,10 +925,10 @@
}
TEST_F(CoreIntrinsicTableTest, MatchTypeConversion_ConstantEval) {
- auto* i32 = create<type::I32>();
- auto* f32 = create<type::F32>();
- auto* vec3i = create<type::Vector>(i32, 3u);
- auto* vec3f = create<type::Vector>(f32, 3u);
+ auto* i32 = ty.i32();
+ auto* f32 = ty.f32();
+ auto* vec3i = ty.vec3(i32);
+ auto* vec3f = ty.vec3(f32);
auto result =
table.Lookup(CtorConv::kVec3, Vector{f32}, Vector{vec3i}, EvaluationStage::kConstant);
ASSERT_EQ(result, Success);
@@ -931,10 +941,10 @@
}
TEST_F(CoreIntrinsicTableTest, MatchTypeConversion_RuntimeEval) {
- auto* i32 = create<type::I32>();
- auto* f32 = create<type::F32>();
- auto* vec3i = create<type::Vector>(i32, 3u);
- auto* vec3f = create<type::Vector>(create<type::F32>(), 3u);
+ auto* i32 = ty.i32();
+ auto* f32 = ty.f32();
+ auto* vec3i = ty.vec3(i32);
+ auto* vec3f = ty.vec3(ty.f32());
auto result =
table.Lookup(CtorConv::kVec3, Vector{f32}, Vector{vec3i}, EvaluationStage::kRuntime);
ASSERT_EQ(result, Success);
@@ -946,7 +956,7 @@
}
TEST_F(CoreIntrinsicTableTest, Err257Arguments) { // crbug.com/1323605
- auto* f32 = create<type::F32>();
+ auto* f32 = ty.f32();
Vector<const type::Type*, 0> arg_tys;
arg_tys.Resize(257, f32);
auto result =
@@ -956,8 +966,7 @@
}
TEST_F(CoreIntrinsicTableTest, MemberFunctionDoesNotMatchNonMemberFunction) {
- auto* arr =
- create<type::Array>(create<type::F32>(), create<type::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
+ auto* arr = ty.runtime_array(ty.f32());
auto result =
table.Lookup(BuiltinFn::kArrayLength, arr, Empty, Empty, EvaluationStage::kConstant);
ASSERT_NE(result, Success);