diff --git a/src/tint/BUILD.gn b/src/tint/BUILD.gn index 227893caf4..abedec504b 100644 --- a/src/tint/BUILD.gn +++ b/src/tint/BUILD.gn @@ -249,10 +249,10 @@ libtint_source_set("libtint_program_src") { "program_builder.cc", "resolver/const_eval.cc", "resolver/const_eval.h", + "resolver/ctor_conv_intrinsic.cc", + "resolver/ctor_conv_intrinsic.h", "resolver/dependency_graph.cc", "resolver/dependency_graph.h", - "resolver/init_conv_intrinsic.cc", - "resolver/init_conv_intrinsic.h", "resolver/intrinsic_table.cc", "resolver/intrinsic_table.h", "resolver/intrinsic_table.inl", @@ -671,13 +671,13 @@ libtint_source_set("libtint_sem_src") { "sem/struct.h", "sem/switch_statement.cc", "sem/switch_statement.h", - "sem/type_conversion.cc", - "sem/type_conversion.h", "sem/type_expression.cc", "sem/type_expression.h", - "sem/type_initializer.cc", - "sem/type_initializer.h", "sem/type_mappings.h", + "sem/value_constructor.cc", + "sem/value_constructor.h", + "sem/value_conversion.cc", + "sem/value_conversion.h", "sem/value_expression.cc", "sem/value_expression.h", "sem/variable.cc", @@ -1400,12 +1400,12 @@ if (tint_build_unittests) { "resolver/struct_address_space_use_test.cc", "resolver/struct_layout_test.cc", "resolver/struct_pipeline_stage_use_test.cc", - "resolver/type_initializer_validation_test.cc", "resolver/type_validation_test.cc", "resolver/uniformity_test.cc", "resolver/unresolved_identifier_test.cc", "resolver/validation_test.cc", "resolver/validator_is_storeable_test.cc", + "resolver/value_constructor_validation_test.cc", "resolver/variable_test.cc", "resolver/variable_validation_test.cc", ] @@ -1639,6 +1639,7 @@ if (tint_build_unittests) { "writer/spirv/builder_builtin_texture_test.cc", "writer/spirv/builder_call_test.cc", "writer/spirv/builder_const_assert_test.cc", + "writer/spirv/builder_constructor_expression_test.cc", "writer/spirv/builder_discard_test.cc", "writer/spirv/builder_entry_point_test.cc", "writer/spirv/builder_format_conversion_test.cc", @@ -1648,7 +1649,6 @@ if (tint_build_unittests) { "writer/spirv/builder_global_variable_test.cc", "writer/spirv/builder_ident_expression_test.cc", "writer/spirv/builder_if_test.cc", - "writer/spirv/builder_initializer_expression_test.cc", "writer/spirv/builder_literal_test.cc", "writer/spirv/builder_loop_test.cc", "writer/spirv/builder_return_test.cc", @@ -1767,6 +1767,7 @@ if (tint_build_unittests) { "writer/wgsl/generator_impl_case_test.cc", "writer/wgsl/generator_impl_cast_test.cc", "writer/wgsl/generator_impl_const_assert_test.cc", + "writer/wgsl/generator_impl_constructor_test.cc", "writer/wgsl/generator_impl_continue_test.cc", "writer/wgsl/generator_impl_diagnostic_test.cc", "writer/wgsl/generator_impl_discard_test.cc", @@ -1775,7 +1776,6 @@ if (tint_build_unittests) { "writer/wgsl/generator_impl_global_decl_test.cc", "writer/wgsl/generator_impl_identifier_test.cc", "writer/wgsl/generator_impl_if_test.cc", - "writer/wgsl/generator_impl_initializer_test.cc", "writer/wgsl/generator_impl_literal_test.cc", "writer/wgsl/generator_impl_loop_test.cc", "writer/wgsl/generator_impl_member_accessor_test.cc", @@ -1810,13 +1810,13 @@ if (tint_build_unittests) { "writer/msl/generator_impl_case_test.cc", "writer/msl/generator_impl_cast_test.cc", "writer/msl/generator_impl_const_assert_test.cc", + "writer/msl/generator_impl_constructor_test.cc", "writer/msl/generator_impl_continue_test.cc", "writer/msl/generator_impl_discard_test.cc", "writer/msl/generator_impl_function_test.cc", "writer/msl/generator_impl_identifier_test.cc", "writer/msl/generator_impl_if_test.cc", "writer/msl/generator_impl_import_test.cc", - "writer/msl/generator_impl_initializer_test.cc", "writer/msl/generator_impl_loop_test.cc", "writer/msl/generator_impl_member_accessor_test.cc", "writer/msl/generator_impl_module_constant_test.cc", @@ -1850,13 +1850,13 @@ if (tint_build_unittests) { "writer/hlsl/generator_impl_case_test.cc", "writer/hlsl/generator_impl_cast_test.cc", "writer/hlsl/generator_impl_const_assert_test.cc", + "writer/hlsl/generator_impl_constructor_test.cc", "writer/hlsl/generator_impl_continue_test.cc", "writer/hlsl/generator_impl_discard_test.cc", "writer/hlsl/generator_impl_function_test.cc", "writer/hlsl/generator_impl_identifier_test.cc", "writer/hlsl/generator_impl_if_test.cc", "writer/hlsl/generator_impl_import_test.cc", - "writer/hlsl/generator_impl_initializer_test.cc", "writer/hlsl/generator_impl_loop_test.cc", "writer/hlsl/generator_impl_member_accessor_test.cc", "writer/hlsl/generator_impl_module_constant_test.cc", @@ -1891,13 +1891,13 @@ if (tint_build_unittests) { "writer/glsl/generator_impl_call_test.cc", "writer/glsl/generator_impl_case_test.cc", "writer/glsl/generator_impl_cast_test.cc", + "writer/glsl/generator_impl_constructor_test.cc", "writer/glsl/generator_impl_continue_test.cc", "writer/glsl/generator_impl_discard_test.cc", "writer/glsl/generator_impl_function_test.cc", "writer/glsl/generator_impl_identifier_test.cc", "writer/glsl/generator_impl_if_test.cc", "writer/glsl/generator_impl_import_test.cc", - "writer/glsl/generator_impl_initializer_test.cc", "writer/glsl/generator_impl_loop_test.cc", "writer/glsl/generator_impl_member_accessor_test.cc", "writer/glsl/generator_impl_module_constant_test.cc", diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt index b8a803e6f7..dfd9624a64 100644 --- a/src/tint/CMakeLists.txt +++ b/src/tint/CMakeLists.txt @@ -331,12 +331,12 @@ list(APPEND TINT_LIB_SRCS sem/switch_statement.h sem/type_expression.cc sem/type_expression.h - sem/type_initializer.cc - sem/type_initializer.h - sem/type_conversion.cc - sem/type_conversion.h sem/type_mappings.h sem/variable.cc + sem/value_constructor.cc + sem/value_constructor.h + sem/value_conversion.cc + sem/value_conversion.h sem/value_expression.cc sem/value_expression.h sem/while_statement.cc @@ -564,7 +564,7 @@ tint_generated(builtin/interpolation_sampling BENCH TEST) tint_generated(builtin/interpolation_type BENCH TEST) tint_generated(builtin/texel_format BENCH TEST) -tint_generated(resolver/init_conv_intrinsic) +tint_generated(resolver/ctor_conv_intrinsic) tint_generated(sem/builtin_type) tint_generated(sem/parameter_usage) @@ -926,11 +926,11 @@ if(TINT_BUILD_TESTS) resolver/struct_layout_test.cc resolver/struct_pipeline_stage_use_test.cc resolver/struct_address_space_use_test.cc - resolver/type_initializer_validation_test.cc resolver/type_validation_test.cc resolver/unresolved_identifier_test.cc resolver/validation_test.cc resolver/validator_is_storeable_test.cc + resolver/value_constructor_validation_test.cc resolver/variable_test.cc resolver/variable_validation_test.cc scope_stack_test.cc @@ -1140,6 +1140,7 @@ if(TINT_BUILD_TESTS) writer/spirv/builder_builtin_texture_test.cc writer/spirv/builder_call_test.cc writer/spirv/builder_const_assert_test.cc + writer/spirv/builder_constructor_expression_test.cc writer/spirv/builder_discard_test.cc writer/spirv/builder_entry_point_test.cc writer/spirv/builder_format_conversion_test.cc @@ -1149,7 +1150,6 @@ if(TINT_BUILD_TESTS) writer/spirv/builder_global_variable_test.cc writer/spirv/builder_ident_expression_test.cc writer/spirv/builder_if_test.cc - writer/spirv/builder_initializer_expression_test.cc writer/spirv/builder_literal_test.cc writer/spirv/builder_loop_test.cc writer/spirv/builder_return_test.cc @@ -1180,6 +1180,7 @@ if(TINT_BUILD_TESTS) writer/wgsl/generator_impl_case_test.cc writer/wgsl/generator_impl_cast_test.cc writer/wgsl/generator_impl_const_assert_test.cc + writer/wgsl/generator_impl_constructor_test.cc writer/wgsl/generator_impl_continue_test.cc writer/wgsl/generator_impl_diagnostic_test.cc writer/wgsl/generator_impl_discard_test.cc @@ -1188,7 +1189,6 @@ if(TINT_BUILD_TESTS) writer/wgsl/generator_impl_global_decl_test.cc writer/wgsl/generator_impl_identifier_test.cc writer/wgsl/generator_impl_if_test.cc - writer/wgsl/generator_impl_initializer_test.cc writer/wgsl/generator_impl_loop_test.cc writer/wgsl/generator_impl_literal_test.cc writer/wgsl/generator_impl_member_accessor_test.cc @@ -1276,12 +1276,12 @@ if(TINT_BUILD_TESTS) writer/msl/generator_impl_case_test.cc writer/msl/generator_impl_cast_test.cc writer/msl/generator_impl_const_assert_test.cc + writer/msl/generator_impl_constructor_test.cc writer/msl/generator_impl_continue_test.cc writer/msl/generator_impl_discard_test.cc writer/msl/generator_impl_function_test.cc writer/msl/generator_impl_identifier_test.cc writer/msl/generator_impl_if_test.cc - writer/msl/generator_impl_initializer_test.cc writer/msl/generator_impl_import_test.cc writer/msl/generator_impl_loop_test.cc writer/msl/generator_impl_member_accessor_test.cc @@ -1310,7 +1310,7 @@ if(TINT_BUILD_TESTS) writer/glsl/generator_impl_call_test.cc writer/glsl/generator_impl_case_test.cc writer/glsl/generator_impl_cast_test.cc - writer/glsl/generator_impl_initializer_test.cc + writer/glsl/generator_impl_constructor_test.cc writer/glsl/generator_impl_continue_test.cc writer/glsl/generator_impl_discard_test.cc writer/glsl/generator_impl_function_test.cc @@ -1348,12 +1348,12 @@ if(TINT_BUILD_TESTS) writer/hlsl/generator_impl_case_test.cc writer/hlsl/generator_impl_cast_test.cc writer/hlsl/generator_impl_const_assert_test.cc + writer/hlsl/generator_impl_constructor_test.cc writer/hlsl/generator_impl_continue_test.cc writer/hlsl/generator_impl_discard_test.cc writer/hlsl/generator_impl_function_test.cc writer/hlsl/generator_impl_identifier_test.cc writer/hlsl/generator_impl_if_test.cc - writer/hlsl/generator_impl_initializer_test.cc writer/hlsl/generator_impl_import_test.cc writer/hlsl/generator_impl_loop_test.cc writer/hlsl/generator_impl_member_accessor_test.cc diff --git a/src/tint/ast/call_expression.h b/src/tint/ast/call_expression.h index b22ec11f92..5085818ba8 100644 --- a/src/tint/ast/call_expression.h +++ b/src/tint/ast/call_expression.h @@ -27,8 +27,8 @@ namespace tint::ast { /// A call expression - represents either a: /// * sem::Function /// * sem::Builtin -/// * sem::TypeConstructor -/// * sem::TypeConversion +/// * sem::ValueConstructor +/// * sem::ValueConversion class CallExpression final : public Castable { public: /// Constructor diff --git a/src/tint/intrinsics.def b/src/tint/intrinsics.def index 1815d26d46..45b4b040b0 100644 --- a/src/tint/intrinsics.def +++ b/src/tint/intrinsics.def @@ -820,118 +820,118 @@ fn textureStore(texture: texture_storage_3d, coords: ve @stage("fragment", "compute") fn atomicCompareExchangeWeak(ptr, read_write>, T, T) -> __atomic_compare_exchange_result //////////////////////////////////////////////////////////////////////////////// -// Type initializers // +// Value constructors // //////////////////////////////////////////////////////////////////////////////// -// Zero value initializers -@must_use @const("Zero") init i32() -> i32 -@must_use @const("Zero") init u32() -> u32 -@must_use @const("Zero") init f32() -> f32 -@must_use @const("Zero") init f16() -> f16 -@must_use @const("Zero") init bool() -> bool -@must_use @const("Zero") init vec2() -> vec2 -@must_use @const("Zero") init vec3() -> vec3 -@must_use @const("Zero") init vec4() -> vec4 -@must_use @const("Zero") init mat2x2() -> mat2x2 -@must_use @const("Zero") init mat2x3() -> mat2x3 -@must_use @const("Zero") init mat2x4() -> mat2x4 -@must_use @const("Zero") init mat3x2() -> mat3x2 -@must_use @const("Zero") init mat3x3() -> mat3x3 -@must_use @const("Zero") init mat3x4() -> mat3x4 -@must_use @const("Zero") init mat4x2() -> mat4x2 -@must_use @const("Zero") init mat4x3() -> mat4x3 -@must_use @const("Zero") init mat4x4() -> mat4x4 +// Zero value constructors +@must_use @const("Zero") ctor i32() -> i32 +@must_use @const("Zero") ctor u32() -> u32 +@must_use @const("Zero") ctor f32() -> f32 +@must_use @const("Zero") ctor f16() -> f16 +@must_use @const("Zero") ctor bool() -> bool +@must_use @const("Zero") ctor vec2() -> vec2 +@must_use @const("Zero") ctor vec3() -> vec3 +@must_use @const("Zero") ctor vec4() -> vec4 +@must_use @const("Zero") ctor mat2x2() -> mat2x2 +@must_use @const("Zero") ctor mat2x3() -> mat2x3 +@must_use @const("Zero") ctor mat2x4() -> mat2x4 +@must_use @const("Zero") ctor mat3x2() -> mat3x2 +@must_use @const("Zero") ctor mat3x3() -> mat3x3 +@must_use @const("Zero") ctor mat3x4() -> mat3x4 +@must_use @const("Zero") ctor mat4x2() -> mat4x2 +@must_use @const("Zero") ctor mat4x3() -> mat4x3 +@must_use @const("Zero") ctor mat4x4() -> mat4x4 -// Identity initializers -@must_use @const("Identity") init i32(i32) -> i32 -@must_use @const("Identity") init u32(u32) -> u32 -@must_use @const("Identity") init f32(f32) -> f32 -@must_use @const("Identity") init f16(f16) -> f16 -@must_use @const("Identity") init bool(bool) -> bool -@must_use @const("Identity") init vec2(vec2) -> vec2 -@must_use @const("Identity") init vec3(vec3) -> vec3 -@must_use @const("Identity") init vec4(vec4) -> vec4 -@must_use @const("Identity") init mat2x2(mat2x2) -> mat2x2 -@must_use @const("Identity") init mat2x3(mat2x3) -> mat2x3 -@must_use @const("Identity") init mat2x4(mat2x4) -> mat2x4 -@must_use @const("Identity") init mat3x2(mat3x2) -> mat3x2 -@must_use @const("Identity") init mat3x3(mat3x3) -> mat3x3 -@must_use @const("Identity") init mat3x4(mat3x4) -> mat3x4 -@must_use @const("Identity") init mat4x2(mat4x2) -> mat4x2 -@must_use @const("Identity") init mat4x3(mat4x3) -> mat4x3 -@must_use @const("Identity") init mat4x4(mat4x4) -> mat4x4 +// Identity constructors +@must_use @const("Identity") ctor i32(i32) -> i32 +@must_use @const("Identity") ctor u32(u32) -> u32 +@must_use @const("Identity") ctor f32(f32) -> f32 +@must_use @const("Identity") ctor f16(f16) -> f16 +@must_use @const("Identity") ctor bool(bool) -> bool +@must_use @const("Identity") ctor vec2(vec2) -> vec2 +@must_use @const("Identity") ctor vec3(vec3) -> vec3 +@must_use @const("Identity") ctor vec4(vec4) -> vec4 +@must_use @const("Identity") ctor mat2x2(mat2x2) -> mat2x2 +@must_use @const("Identity") ctor mat2x3(mat2x3) -> mat2x3 +@must_use @const("Identity") ctor mat2x4(mat2x4) -> mat2x4 +@must_use @const("Identity") ctor mat3x2(mat3x2) -> mat3x2 +@must_use @const("Identity") ctor mat3x3(mat3x3) -> mat3x3 +@must_use @const("Identity") ctor mat3x4(mat3x4) -> mat3x4 +@must_use @const("Identity") ctor mat4x2(mat4x2) -> mat4x2 +@must_use @const("Identity") ctor mat4x3(mat4x3) -> mat4x3 +@must_use @const("Identity") ctor mat4x4(mat4x4) -> mat4x4 -// Vector initializers (splat) -@must_use @const("VecSplat") init vec2(T) -> vec2 -@must_use @const("VecSplat") init vec3(T) -> vec3 -@must_use @const("VecSplat") init vec4(T) -> vec4 +// Vector constructors (splat) +@must_use @const("VecSplat") ctor vec2(T) -> vec2 +@must_use @const("VecSplat") ctor vec3(T) -> vec3 +@must_use @const("VecSplat") ctor vec4(T) -> vec4 -// Vector initializers (scalar) -@must_use @const("VecInitS") init vec2(x: T, y: T) -> vec2 -@must_use @const("VecInitS") init vec3(x: T, y: T, z: T) -> vec3 -@must_use @const("VecInitS") init vec4(x: T, y: T, z: T, w: T) -> vec4 +// Vector constructors (scalar) +@must_use @const("VecInitS") ctor vec2(x: T, y: T) -> vec2 +@must_use @const("VecInitS") ctor vec3(x: T, y: T, z: T) -> vec3 +@must_use @const("VecInitS") ctor vec4(x: T, y: T, z: T, w: T) -> vec4 -// Vector initializers (mixed) -@must_use @const("VecInitM") init vec3(xy: vec2, z: T) -> vec3 -@must_use @const("VecInitM") init vec3(x: T, yz: vec2) -> vec3 -@must_use @const("VecInitM") init vec4(xy: vec2, z: T, w: T) -> vec4 -@must_use @const("VecInitM") init vec4(x: T, yz: vec2, w: T) -> vec4 -@must_use @const("VecInitM") init vec4(x: T, y: T, zw: vec2) -> vec4 -@must_use @const("VecInitM") init vec4(xy: vec2, zw: vec2) -> vec4 -@must_use @const("VecInitM") init vec4(xyz: vec3, w: T) -> vec4 -@must_use @const("VecInitM") init vec4(x: T, zyw: vec3) -> vec4 +// Vector constructors (mixed) +@must_use @const("VecInitM") ctor vec3(xy: vec2, z: T) -> vec3 +@must_use @const("VecInitM") ctor vec3(x: T, yz: vec2) -> vec3 +@must_use @const("VecInitM") ctor vec4(xy: vec2, z: T, w: T) -> vec4 +@must_use @const("VecInitM") ctor vec4(x: T, yz: vec2, w: T) -> vec4 +@must_use @const("VecInitM") ctor vec4(x: T, y: T, zw: vec2) -> vec4 +@must_use @const("VecInitM") ctor vec4(xy: vec2, zw: vec2) -> vec4 +@must_use @const("VecInitM") ctor vec4(xyz: vec3, w: T) -> vec4 +@must_use @const("VecInitM") ctor vec4(x: T, zyw: vec3) -> vec4 -// Matrix initializers (scalar) +// Matrix constructors (scalar) @must_use @const("MatInitS") -init mat2x2(T, T, +ctor mat2x2(T, T, T, T) -> mat2x2 @must_use @const("MatInitS") -init mat2x3(T, T, T, +ctor mat2x3(T, T, T, T, T, T) -> mat2x3 @must_use @const("MatInitS") -init mat2x4(T, T, T, T, +ctor mat2x4(T, T, T, T, T, T, T, T) -> mat2x4 @must_use @const("MatInitS") -init mat3x2(T, T, +ctor mat3x2(T, T, T, T, T, T) -> mat3x2 @must_use @const("MatInitS") -init mat3x3(T, T, T, +ctor mat3x3(T, T, T, T, T, T, T, T, T) -> mat3x3 @must_use @const("MatInitS") -init mat3x4(T, T, T, T, +ctor mat3x4(T, T, T, T, T, T, T, T, T, T, T, T) -> mat3x4 @must_use @const("MatInitS") -init mat4x2(T, T, +ctor mat4x2(T, T, T, T, T, T, T, T) -> mat4x2 @must_use @const("MatInitS") -init mat4x3(T, T, T, +ctor mat4x3(T, T, T, T, T, T, T, T, T, T, T, T) -> mat4x3 @must_use @const("MatInitS") -init mat4x4(T, T, T, T, +ctor mat4x4(T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) -> mat4x4 -// Matrix initializers (column vectors) -@must_use @const("MatInitV") init mat2x2(vec2, vec2) -> mat2x2 -@must_use @const("MatInitV") init mat2x3(vec3, vec3) -> mat2x3 -@must_use @const("MatInitV") init mat2x4(vec4, vec4) -> mat2x4 -@must_use @const("MatInitV") init mat3x2(vec2, vec2, vec2) -> mat3x2 -@must_use @const("MatInitV") init mat3x3(vec3, vec3, vec3) -> mat3x3 -@must_use @const("MatInitV") init mat3x4(vec4, vec4, vec4) -> mat3x4 -@must_use @const("MatInitV") init mat4x2(vec2, vec2, vec2, vec2) -> mat4x2 -@must_use @const("MatInitV") init mat4x3(vec3, vec3, vec3, vec3) -> mat4x3 -@must_use @const("MatInitV") init mat4x4(vec4, vec4, vec4, vec4) -> mat4x4 +// Matrix constructors (column vectors) +@must_use @const("MatInitV") ctor mat2x2(vec2, vec2) -> mat2x2 +@must_use @const("MatInitV") ctor mat2x3(vec3, vec3) -> mat2x3 +@must_use @const("MatInitV") ctor mat2x4(vec4, vec4) -> mat2x4 +@must_use @const("MatInitV") ctor mat3x2(vec2, vec2, vec2) -> mat3x2 +@must_use @const("MatInitV") ctor mat3x3(vec3, vec3, vec3) -> mat3x3 +@must_use @const("MatInitV") ctor mat3x4(vec4, vec4, vec4) -> mat3x4 +@must_use @const("MatInitV") ctor mat4x2(vec2, vec2, vec2, vec2) -> mat4x2 +@must_use @const("MatInitV") ctor mat4x3(vec3, vec3, vec3, vec3) -> mat4x3 +@must_use @const("MatInitV") ctor mat4x4(vec4, vec4, vec4, vec4) -> mat4x4 //////////////////////////////////////////////////////////////////////////////// -// Type conversions // +// Value conversions // //////////////////////////////////////////////////////////////////////////////// @must_use @const conv f32(T) -> f32 @must_use @const conv f16(T) -> f16 diff --git a/src/tint/program_builder.h b/src/tint/program_builder.h index a1e3eed3e6..c84a6e065e 100644 --- a/src/tint/program_builder.h +++ b/src/tint/program_builder.h @@ -473,7 +473,7 @@ class ProgramBuilder { /// Creates a new ast::Node owned by the ProgramBuilder. When the /// ProgramBuilder is destructed, the ast::Node will also be destructed. /// @param source the Source of the node - /// @param args the arguments to pass to the type constructor + /// @param args the arguments to pass to the constructor /// @returns the node pointer template traits::EnableIfIsType* create(const Source& source, ARGS&&... args) { @@ -498,8 +498,8 @@ class ProgramBuilder { /// constructor. /// When the ProgramBuilder is destructed, the ast::Node will also be /// destructed. - /// @param arg0 the first arguments to pass to the type constructor - /// @param args the remaining arguments to pass to the type constructor + /// @param arg0 the first arguments to pass to the constructor + /// @param args the remaining arguments to pass to the constructor /// @returns the node pointer template traits::EnableIf @@ -1717,7 +1717,7 @@ class ProgramBuilder { /// @param source the source of the call /// @param type the vector type /// @param size the vector size - /// @param args the arguments for the vector initializer + /// @param args the arguments for the vector constructor /// @return an `ast::CallExpression` of a `size`-element vector of /// type `type`, constructed with the values @p args. template @@ -1728,7 +1728,7 @@ class ProgramBuilder { return Call(source, ty.vec(type, size), std::forward(args)...); } - /// @param args the arguments for the vector initializer + /// @param args the arguments for the vector constructor /// @return an `ast::CallExpression` of a 2-element vector of type `T`, constructed with the /// values @p args. template > @@ -1737,7 +1737,7 @@ class ProgramBuilder { } /// @param source the vector source - /// @param args the arguments for the vector initializer + /// @param args the arguments for the vector constructor /// @return an `ast::CallExpression` of a 2-element vector of type `T`, constructed with the /// values @p args. template @@ -1746,7 +1746,7 @@ class ProgramBuilder { } /// @param type the element type of the vector - /// @param args the arguments for the vector initializer + /// @param args the arguments for the vector constructor /// @return an `ast::CallExpression` of a 2-element vector of type @p type, constructed with the /// values @p args. template @@ -1756,7 +1756,7 @@ class ProgramBuilder { /// @param source the vector source /// @param type the element type of the vector - /// @param args the arguments for the vector initializer + /// @param args the arguments for the vector constructor /// @return an `ast::CallExpression` of a 2-element vector of type @p type, constructed with the /// values @p args. template @@ -1764,7 +1764,7 @@ class ProgramBuilder { return Call(source, ty.vec2(type), std::forward(args)...); } - /// @param args the arguments for the vector initializer + /// @param args the arguments for the vector constructor /// @return an `ast::CallExpression` of a 3-element vector of type `T`, constructed with the /// values @p args. template > @@ -1773,7 +1773,7 @@ class ProgramBuilder { } /// @param source the vector source - /// @param args the arguments for the vector initializer + /// @param args the arguments for the vector constructor /// @return an `ast::CallExpression` of a 3-element vector of type `T`, constructed with the /// values @p args. template @@ -1782,7 +1782,7 @@ class ProgramBuilder { } /// @param type the element type of the vector - /// @param args the arguments for the vector initializer + /// @param args the arguments for the vector constructor /// @return an `ast::CallExpression` of a 3-element vector of type @p type, constructed with the /// values @p args. template @@ -1792,7 +1792,7 @@ class ProgramBuilder { /// @param source the vector source /// @param type the element type of the vector - /// @param args the arguments for the vector initializer + /// @param args the arguments for the vector constructor /// @return an `ast::CallExpression` of a 3-element vector of type @p type, constructed with the /// values @p args. template @@ -1800,7 +1800,7 @@ class ProgramBuilder { return Call(source, ty.vec3(type), std::forward(args)...); } - /// @param args the arguments for the vector initializer + /// @param args the arguments for the vector constructor /// @return an `ast::CallExpression` of a 4-element vector of type `T`, constructed with the /// values @p args. template > @@ -1809,7 +1809,7 @@ class ProgramBuilder { } /// @param source the vector source - /// @param args the arguments for the vector initializer + /// @param args the arguments for the vector constructor /// @return an `ast::CallExpression` of a 4-element vector of type `T`, constructed with the /// values @p args. template @@ -1818,7 +1818,7 @@ class ProgramBuilder { } /// @param type the element type of the vector - /// @param args the arguments for the vector initializer + /// @param args the arguments for the vector constructor /// @return an `ast::CallExpression` of a 4-element vector of type @p type, constructed with the /// values @p args. template @@ -1828,7 +1828,7 @@ class ProgramBuilder { /// @param source the vector source /// @param type the element type of the vector - /// @param args the arguments for the vector initializer + /// @param args the arguments for the vector constructor /// @return an `ast::CallExpression` of a 4-element vector of type @p type, constructed with the /// values @p args. template @@ -1836,7 +1836,7 @@ class ProgramBuilder { return Call(source, ty.vec4(type), std::forward(args)...); } - /// @param args the arguments for the matrix initializer + /// @param args the arguments for the matrix constructor /// @return an `ast::CallExpression` of a 2x2 matrix of type /// `T`, constructed with the values @p args. template > @@ -1845,7 +1845,7 @@ class ProgramBuilder { } /// @param source the matrix source - /// @param args the arguments for the matrix initializer + /// @param args the arguments for the matrix constructor /// @return an `ast::CallExpression` of a 2x2 matrix of type /// `T`, constructed with the values @p args. template @@ -1853,7 +1853,7 @@ class ProgramBuilder { return Call(source, ty.mat2x2(), std::forward(args)...); } - /// @param args the arguments for the matrix initializer + /// @param args the arguments for the matrix constructor /// @return an `ast::CallExpression` of a 2x3 matrix of type /// `T`, constructed with the values @p args. template > @@ -1862,7 +1862,7 @@ class ProgramBuilder { } /// @param source the matrix source - /// @param args the arguments for the matrix initializer + /// @param args the arguments for the matrix constructor /// @return an `ast::CallExpression` of a 2x3 matrix of type /// `T`, constructed with the values @p args. template @@ -1870,7 +1870,7 @@ class ProgramBuilder { return Call(source, ty.mat2x3(), std::forward(args)...); } - /// @param args the arguments for the matrix initializer + /// @param args the arguments for the matrix constructor /// @return an `ast::CallExpression` of a 2x4 matrix of type /// `T`, constructed with the values @p args. template > @@ -1879,7 +1879,7 @@ class ProgramBuilder { } /// @param source the matrix source - /// @param args the arguments for the matrix initializer + /// @param args the arguments for the matrix constructor /// @return an `ast::CallExpression` of a 2x4 matrix of type /// `T`, constructed with the values @p args. template @@ -1887,7 +1887,7 @@ class ProgramBuilder { return Call(source, ty.mat2x4(), std::forward(args)...); } - /// @param args the arguments for the matrix initializer + /// @param args the arguments for the matrix constructor /// @return an `ast::CallExpression` of a 3x2 matrix of type /// `T`, constructed with the values @p args. template > @@ -1896,7 +1896,7 @@ class ProgramBuilder { } /// @param source the matrix source - /// @param args the arguments for the matrix initializer + /// @param args the arguments for the matrix constructor /// @return an `ast::CallExpression` of a 3x2 matrix of type /// `T`, constructed with the values @p args. template @@ -1904,7 +1904,7 @@ class ProgramBuilder { return Call(source, ty.mat3x2(), std::forward(args)...); } - /// @param args the arguments for the matrix initializer + /// @param args the arguments for the matrix constructor /// @return an `ast::CallExpression` of a 3x3 matrix of type /// `T`, constructed with the values @p args. template > @@ -1913,7 +1913,7 @@ class ProgramBuilder { } /// @param source the matrix source - /// @param args the arguments for the matrix initializer + /// @param args the arguments for the matrix constructor /// @return an `ast::CallExpression` of a 3x3 matrix of type /// `T`, constructed with the values @p args. template @@ -1921,7 +1921,7 @@ class ProgramBuilder { return Call(source, ty.mat3x3(), std::forward(args)...); } - /// @param args the arguments for the matrix initializer + /// @param args the arguments for the matrix constructor /// @return an `ast::CallExpression` of a 3x4 matrix of type /// `T`, constructed with the values @p args. template > @@ -1930,7 +1930,7 @@ class ProgramBuilder { } /// @param source the matrix source - /// @param args the arguments for the matrix initializer + /// @param args the arguments for the matrix constructor /// @return an `ast::CallExpression` of a 3x4 matrix of type /// `T`, constructed with the values @p args. template @@ -1938,7 +1938,7 @@ class ProgramBuilder { return Call(source, ty.mat3x4(), std::forward(args)...); } - /// @param args the arguments for the matrix initializer + /// @param args the arguments for the matrix constructor /// @return an `ast::CallExpression` of a 4x2 matrix of type /// `T`, constructed with the values @p args. template > @@ -1947,7 +1947,7 @@ class ProgramBuilder { } /// @param source the matrix source - /// @param args the arguments for the matrix initializer + /// @param args the arguments for the matrix constructor /// @return an `ast::CallExpression` of a 4x2 matrix of type /// `T`, constructed with the values @p args. template @@ -1955,7 +1955,7 @@ class ProgramBuilder { return Call(source, ty.mat4x2(), std::forward(args)...); } - /// @param args the arguments for the matrix initializer + /// @param args the arguments for the matrix constructor /// @return an `ast::CallExpression` of a 4x3 matrix of type /// `T`, constructed with the values @p args. template > @@ -1964,7 +1964,7 @@ class ProgramBuilder { } /// @param source the matrix source - /// @param args the arguments for the matrix initializer + /// @param args the arguments for the matrix constructor /// @return an `ast::CallExpression` of a 4x3 matrix of type /// `T`, constructed with the values @p args. template @@ -1972,7 +1972,7 @@ class ProgramBuilder { return Call(source, ty.mat4x3(), std::forward(args)...); } - /// @param args the arguments for the matrix initializer + /// @param args the arguments for the matrix constructor /// @return an `ast::CallExpression` of a 4x4 matrix of type /// `T`, constructed with the values @p args. template > @@ -1981,7 +1981,7 @@ class ProgramBuilder { } /// @param source the matrix source - /// @param args the arguments for the matrix initializer + /// @param args the arguments for the matrix constructor /// @return an `ast::CallExpression` of a 4x4 matrix of type /// `T`, constructed with the values @p args. template @@ -1989,7 +1989,7 @@ class ProgramBuilder { return Call(source, ty.mat4x4(), std::forward(args)...); } - /// @param args the arguments for the array initializer + /// @param args the arguments for the array constructor /// @return an `ast::CallExpression` of an array with element type `T`, constructed with the /// values @p args. template > @@ -1998,7 +1998,7 @@ class ProgramBuilder { } /// @param source the array source - /// @param args the arguments for the array initializer + /// @param args the arguments for the array constructor /// @return an `ast::CallExpression` of an array with element type `T`, constructed with the /// values @p args. template @@ -2006,7 +2006,7 @@ class ProgramBuilder { return Call(source, ty.array(), std::forward(args)...); } - /// @param args the arguments for the array initializer + /// @param args the arguments for the array constructor /// @return an `ast::CallExpression` of an array with element type `T` and size `N`, constructed /// with the values @p args. template > @@ -2015,7 +2015,7 @@ class ProgramBuilder { } /// @param source the array source - /// @param args the arguments for the array initializer + /// @param args the arguments for the array constructor /// @return an `ast::CallExpression` of an array with element type `T` and size `N`, constructed /// with the values @p args. template @@ -2025,7 +2025,7 @@ class ProgramBuilder { /// @param subtype the array element type /// @param n the array size. nullptr represents a runtime-array. - /// @param args the arguments for the array initializer + /// @param args the arguments for the array constructor /// @return an `ast::CallExpression` of an array with element type /// `subtype`, constructed with the values @p args. template @@ -2036,7 +2036,7 @@ class ProgramBuilder { /// @param source the array source /// @param subtype the array element type /// @param n the array size. nullptr represents a runtime-array. - /// @param args the arguments for the array initializer + /// @param args the arguments for the array constructor /// @return an `ast::CallExpression` of an array with element type /// `subtype`, constructed with the values @p args. template @@ -2069,11 +2069,11 @@ class ProgramBuilder { /// @param name the variable name /// @param options the extra options passed to the ast::Var initializer /// Can be any of the following, in any order: - /// * ast::Type - specifies the variable's type + /// * ast::Type - specifies the variable's type /// * builtin::AddressSpace - specifies the variable's address space /// * builtin::Access - specifies the variable's access control - /// * ast::Expression* - specifies the variable's initializer expression - /// * ast::Attribute* - specifies the variable's attributes (repeatable, or vector) + /// * ast::Expression* - specifies the variable's initializer expression + /// * ast::Attribute* - specifies the variable's attributes (repeatable, or vector) /// Note that non-repeatable arguments of the same type will use the last argument's value. /// @returns a `ast::Var` with the given name, type and additional /// options @@ -2086,11 +2086,11 @@ class ProgramBuilder { /// @param name the variable name /// @param options the extra options passed to the ast::Var initializer /// Can be any of the following, in any order: - /// * ast::Type - specifies the variable's type + /// * ast::Type - specifies the variable's type /// * builtin::AddressSpace - specifies the variable's address space /// * builtin::Access - specifies the variable's access control - /// * ast::Expression* - specifies the variable's initializer expression - /// * ast::Attribute* - specifies the variable's attributes (repeatable, or vector) + /// * ast::Expression* - specifies the variable's initializer expression + /// * ast::Attribute* - specifies the variable's attributes (repeatable, or vector) /// Note that non-repeatable arguments of the same type will use the last argument's value. /// @returns a `ast::Var` with the given name, address_space and type template @@ -2390,7 +2390,7 @@ class ProgramBuilder { Expr(std::forward(expr))); } - /// @param args the arguments for the type constructor + /// @param args the arguments for the constructor /// @returns an ast::CallExpression to the type `T`, with the arguments of @p args converted to /// `ast::Expression`s using Expr(). template > @@ -2399,7 +2399,7 @@ class ProgramBuilder { } /// @param source the source of the call - /// @param args the arguments for the type constructor + /// @param args the arguments for the constructor /// @returns an ast::CallExpression to the type `T` with the arguments of @p args converted to /// `ast::Expression`s using Expr(). template diff --git a/src/tint/reader/spirv/function.cc b/src/tint/reader/spirv/function.cc index f94be977d0..49d4e83e18 100644 --- a/src/tint/reader/spirv/function.cc +++ b/src/tint/reader/spirv/function.cc @@ -3950,7 +3950,7 @@ TypedExpression FunctionEmitter::EmitGlslStd450ExtInst(const spvtools::opt::Inst if (ext_opcode == GLSLstd450Ldexp) { // WGSL requires the second argument to be signed. - // Use a type initializer to convert it, which is the same as a bitcast. + // Use a value constructor to convert it, which is the same as a bitcast. // If the value would go from very large positive to negative, then the // original result would have been infinity. And since WGSL // implementations may assume that infinities are not present, then we diff --git a/src/tint/reader/spirv/parser_impl_handle_test.cc b/src/tint/reader/spirv/parser_impl_handle_test.cc index 60994d5379..24133866e8 100644 --- a/src/tint/reader/spirv/parser_impl_handle_test.cc +++ b/src/tint/reader/spirv/parser_impl_handle_test.cc @@ -2937,7 +2937,7 @@ INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P( // When SPIR-V wants the result type to be unsigned, we have to - // insert a type initializer or bitcast for WGSL to do the type + // insert a value constructor or bitcast for WGSL to do the type // coercion. But the algorithm already does that as a matter // of course. ImageQuerySizeLod_NonArrayed_UnsignedResult_SignedLevel, @@ -3002,8 +3002,7 @@ INSTANTIATE_TEST_SUITE_P(ImageQueryLevels_SignedResult, R"(let x_99 : i32 = i32(textureNumLevels(x_20));)"}})); INSTANTIATE_TEST_SUITE_P( - // Spot check that a type conversion is inserted when SPIR-V asks for - // an unsigned int result. + // Spot check that a value conversion is inserted when SPIR-V asks for an unsigned int result. ImageQueryLevels_UnsignedResult, SpvParserHandleTest_SampledImageAccessTest, ::testing::ValuesIn(std::vector{ diff --git a/src/tint/reader/wgsl/parser_impl.h b/src/tint/reader/wgsl/parser_impl.h index 8cd0cdbd9e..34395ed61b 100644 --- a/src/tint/reader/wgsl/parser_impl.h +++ b/src/tint/reader/wgsl/parser_impl.h @@ -838,7 +838,7 @@ class ParserImpl { /// Creates a new `ast::Node` owned by the Module. When the Module is /// destructed, the `ast::Node` will also be destructed. - /// @param args the arguments to pass to the type constructor + /// @param args the arguments to pass to the constructor /// @returns the node pointer template T* create(ARGS&&... args) { diff --git a/src/tint/resolver/builtin_validation_test.cc b/src/tint/resolver/builtin_validation_test.cc index 14d40bca66..967335df41 100644 --- a/src/tint/resolver/builtin_validation_test.cc +++ b/src/tint/resolver/builtin_validation_test.cc @@ -16,7 +16,7 @@ #include "src/tint/ast/builtin_texture_helper_test.h" #include "src/tint/resolver/resolver_test_helper.h" -#include "src/tint/sem/type_initializer.h" +#include "src/tint/sem/value_constructor.h" using namespace tint::number_suffixes; // NOLINT @@ -147,9 +147,9 @@ TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsAliasUsedAsFunction) { WrapInFunction(Call(Source{{56, 78}}, "mix", 1_f, 2_f, 3_f)); EXPECT_FALSE(r()->Resolve()); - EXPECT_EQ(r()->error(), R"(56:78 error: no matching initializer for i32(f32, f32, f32) + EXPECT_EQ(r()->error(), R"(56:78 error: no matching constructor for i32(f32, f32, f32) -2 candidate initializers: +2 candidate constructors: i32(i32) -> i32 i32() -> i32 @@ -177,7 +177,7 @@ TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsStructUsedAsFunction) { EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), - R"(12:34 error: struct initializer has too many inputs: expected 1, found 3)"); + R"(12:34 error: structure constructor has too many inputs: expected 1, found 3)"); } TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsStructUsedAsType) { @@ -309,8 +309,8 @@ TEST_P(BuiltinTextureConstExprArgValidationTest, Immediate) { auto args = overload.args(this); auto*& arg_to_replace = (param.position == Position::kFirst) ? args.Front() : args.Back(); - // BuildTextureVariable() uses a Literal for scalars, and a CallExpression for - // a vector initializer. + // BuildTextureVariable() uses a Literal for scalars, and a CallExpression for a vector + // constructor. bool is_vector = arg_to_replace->Is(); // Make the expression to be replaced, reachable. This keeps the resolver happy. @@ -366,8 +366,8 @@ TEST_P(BuiltinTextureConstExprArgValidationTest, GlobalConst) { auto args = overload.args(this); auto*& arg_to_replace = (param.position == Position::kFirst) ? args.Front() : args.Back(); - // BuildTextureVariable() uses a Literal for scalars, and a CallExpression for - // a vector initializer. + // BuildTextureVariable() uses a Literal for scalars, and a CallExpression for a vector + // constructor. bool is_vector = arg_to_replace->Is(); // Make the expression to be replaced, reachable. This keeps the resolver happy. diff --git a/src/tint/resolver/const_eval.cc b/src/tint/resolver/const_eval.cc index 741c9d84a6..dc59ccd95f 100644 --- a/src/tint/resolver/const_eval.cc +++ b/src/tint/resolver/const_eval.cc @@ -29,7 +29,7 @@ #include "src/tint/number.h" #include "src/tint/program_builder.h" #include "src/tint/sem/member_accessor_expression.h" -#include "src/tint/sem/type_initializer.h" +#include "src/tint/sem/value_constructor.h" #include "src/tint/type/abstract_float.h" #include "src/tint/type/abstract_int.h" #include "src/tint/type/array.h" @@ -1228,18 +1228,18 @@ ConstEval::Result ConstEval::Literal(const type::Type* ty, const ast::LiteralExp }); } -ConstEval::Result ConstEval::ArrayOrStructInit(const type::Type* ty, +ConstEval::Result ConstEval::ArrayOrStructCtor(const type::Type* ty, utils::VectorRef args) { if (args.IsEmpty()) { return ZeroValue(ty); } if (args.Length() == 1 && args[0]->Type() == ty) { - // Identity initializer. + // Identity constructor. return args[0]->ConstantValue(); } - // Multiple arguments. Must be a type initializer. + // Multiple arguments. Must be a value constructor. utils::Vector els; els.Reserve(args.Length()); for (auto* arg : args) { diff --git a/src/tint/resolver/const_eval.h b/src/tint/resolver/const_eval.h index 934924e57c..969cfe7f57 100644 --- a/src/tint/resolver/const_eval.h +++ b/src/tint/resolver/const_eval.h @@ -80,7 +80,7 @@ class ConstEval { /// @param ty the target type - must be an array or initializer /// @param args the input arguments /// @return the constructed value, or null if the value cannot be calculated - Result ArrayOrStructInit(const type::Type* ty, + Result ArrayOrStructCtor(const type::Type* ty, utils::VectorRef args); /// @param ty the target type @@ -127,7 +127,7 @@ class ConstEval { // Constant value evaluation methods, to be indirectly called via the intrinsic table //////////////////////////////////////////////////////////////////////////////////////////////// - /// Type conversion + /// Value conversion /// @param ty the result type /// @param args the input arguments /// @param source the source location @@ -136,7 +136,7 @@ class ConstEval { utils::VectorRef args, const Source& source); - /// Zero value type initializer + /// Zero value constructor /// @param ty the result type /// @param args the input arguments (no arguments provided) /// @param source the source location @@ -145,7 +145,7 @@ class ConstEval { utils::VectorRef args, const Source& source); - /// Identity value type initializer + /// Identity value constructor /// @param ty the result type /// @param args the input arguments /// @param source the source location @@ -154,7 +154,7 @@ class ConstEval { utils::VectorRef args, const Source& source); - /// Vector splat initializer + /// Vector splat constructor /// @param ty the vector type /// @param args the input arguments /// @param source the source location @@ -163,7 +163,7 @@ class ConstEval { utils::VectorRef args, const Source& source); - /// Vector initializer using scalars + /// Vector constructor using scalars /// @param ty the vector type /// @param args the input arguments /// @param source the source location @@ -172,7 +172,7 @@ class ConstEval { utils::VectorRef args, const Source& source); - /// Vector initializer using a mix of scalars and smaller vectors + /// Vector constructor using a mix of scalars and smaller vectors /// @param ty the vector type /// @param args the input arguments /// @param source the source location @@ -181,7 +181,7 @@ class ConstEval { utils::VectorRef args, const Source& source); - /// Matrix initializer using scalar values + /// Matrix constructor using scalar values /// @param ty the matrix type /// @param args the input arguments /// @param source the source location @@ -190,7 +190,7 @@ class ConstEval { utils::VectorRef args, const Source& source); - /// Matrix initializer using column vectors + /// Matrix constructor using column vectors /// @param ty the matrix type /// @param args the input arguments /// @param source the source location diff --git a/src/tint/resolver/const_eval_binary_op_test.cc b/src/tint/resolver/const_eval_binary_op_test.cc index ef7453e6f5..e2dec195a1 100644 --- a/src/tint/resolver/const_eval_binary_op_test.cc +++ b/src/tint/resolver/const_eval_binary_op_test.cc @@ -1876,7 +1876,7 @@ TEST_F(ResolverConstEvalTest, ShortCircuit_Or_Error_Bitcast) { } //////////////////////////////////////////////// -// Short-Circuit Type Init/Convert +// Short-Circuit value construction / conversion //////////////////////////////////////////////// // NOTE: Cannot demonstrate short-circuiting an invalid init/convert as const eval of init/convert @@ -1892,9 +1892,9 @@ TEST_F(ResolverConstEvalTest, ShortCircuit_And_Error_Init) { EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), - R"(12:34 error: no matching initializer for vec2(abstract-float, bool) + R"(12:34 error: no matching constructor for vec2(abstract-float, bool) -4 candidate initializers: +4 candidate constructors: vec2(x: T, y: T) -> vec2 where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool vec2(T) -> vec2 where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool vec2(vec2) -> vec2 where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool @@ -1919,9 +1919,9 @@ TEST_F(ResolverConstEvalTest, ShortCircuit_Or_Error_Init) { EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), - R"(12:34 error: no matching initializer for vec2(abstract-float, bool) + R"(12:34 error: no matching constructor for vec2(abstract-float, bool) -4 candidate initializers: +4 candidate constructors: vec2(x: T, y: T) -> vec2 where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool vec2(T) -> vec2 where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool vec2(vec2) -> vec2 where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool @@ -1958,7 +1958,7 @@ TEST_F(ResolverConstEvalTest, ShortCircuit_And_Error_StructInit) { EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), - "12:34 error: type in struct initializer does not match struct member type: " + "12:34 error: type in structure constructor does not match struct member type: " "expected 'f32', found 'bool'"); } @@ -1977,7 +1977,7 @@ TEST_F(ResolverConstEvalTest, ShortCircuit_Or_Error_StructInit) { EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), - "12:34 error: type in struct initializer does not match struct member type: " + "12:34 error: type in structure constructor does not match struct member type: " "expected 'f32', found 'bool'"); } diff --git a/src/tint/resolver/init_conv_intrinsic.cc b/src/tint/resolver/ctor_conv_intrinsic.cc similarity index 63% rename from src/tint/resolver/init_conv_intrinsic.cc rename to src/tint/resolver/ctor_conv_intrinsic.cc index f9f40bf7d0..3ac3a677f5 100644 --- a/src/tint/resolver/init_conv_intrinsic.cc +++ b/src/tint/resolver/ctor_conv_intrinsic.cc @@ -15,52 +15,52 @@ //////////////////////////////////////////////////////////////////////////////// // File generated by tools/src/cmd/gen // using the template: -// src/tint/resolver/init_conv_intrinsic.cc.tmpl +// src/tint/resolver/ctor_conv_intrinsic.cc.tmpl // // Do not modify this file directly //////////////////////////////////////////////////////////////////////////////// -#include "src/tint/resolver/init_conv_intrinsic.h" +#include "src/tint/resolver/ctor_conv_intrinsic.h" namespace tint::resolver { -const char* str(InitConvIntrinsic i) { +const char* str(CtorConvIntrinsic i) { switch (i) { - case InitConvIntrinsic::kNone: + case CtorConvIntrinsic::kNone: return ""; - case InitConvIntrinsic::kI32: + case CtorConvIntrinsic::kI32: return "i32"; - case InitConvIntrinsic::kU32: + case CtorConvIntrinsic::kU32: return "u32"; - case InitConvIntrinsic::kF32: + case CtorConvIntrinsic::kF32: return "f32"; - case InitConvIntrinsic::kF16: + case CtorConvIntrinsic::kF16: return "f16"; - case InitConvIntrinsic::kBool: + case CtorConvIntrinsic::kBool: return "bool"; - case InitConvIntrinsic::kVec2: + case CtorConvIntrinsic::kVec2: return "vec2"; - case InitConvIntrinsic::kVec3: + case CtorConvIntrinsic::kVec3: return "vec3"; - case InitConvIntrinsic::kVec4: + case CtorConvIntrinsic::kVec4: return "vec4"; - case InitConvIntrinsic::kMat2x2: + case CtorConvIntrinsic::kMat2x2: return "mat2x2"; - case InitConvIntrinsic::kMat2x3: + case CtorConvIntrinsic::kMat2x3: return "mat2x3"; - case InitConvIntrinsic::kMat2x4: + case CtorConvIntrinsic::kMat2x4: return "mat2x4"; - case InitConvIntrinsic::kMat3x2: + case CtorConvIntrinsic::kMat3x2: return "mat3x2"; - case InitConvIntrinsic::kMat3x3: + case CtorConvIntrinsic::kMat3x3: return "mat3x3"; - case InitConvIntrinsic::kMat3x4: + case CtorConvIntrinsic::kMat3x4: return "mat3x4"; - case InitConvIntrinsic::kMat4x2: + case CtorConvIntrinsic::kMat4x2: return "mat4x2"; - case InitConvIntrinsic::kMat4x3: + case CtorConvIntrinsic::kMat4x3: return "mat4x3"; - case InitConvIntrinsic::kMat4x4: + case CtorConvIntrinsic::kMat4x4: return "mat4x4"; } return ""; diff --git a/src/tint/resolver/init_conv_intrinsic.cc.tmpl b/src/tint/resolver/ctor_conv_intrinsic.cc.tmpl similarity index 66% rename from src/tint/resolver/init_conv_intrinsic.cc.tmpl rename to src/tint/resolver/ctor_conv_intrinsic.cc.tmpl index 199cb6181e..00ac21beee 100644 --- a/src/tint/resolver/init_conv_intrinsic.cc.tmpl +++ b/src/tint/resolver/ctor_conv_intrinsic.cc.tmpl @@ -1,6 +1,6 @@ {{- /* -------------------------------------------------------------------------------- -Template file for use with tools/src/cmd/gen to generate init_conv_intrinsic.cc +Template file for use with tools/src/cmd/gen to generate ctor_conv_intrinsic.cc To update the generated file, run: ./tools/run gen @@ -11,16 +11,16 @@ See: -------------------------------------------------------------------------------- */ -}} -#include "src/tint/resolver/init_conv_intrinsic.h" +#include "src/tint/resolver/ctor_conv_intrinsic.h" namespace tint::resolver { -const char* str(InitConvIntrinsic i) { +const char* str(CtorConvIntrinsic i) { switch (i) { - case InitConvIntrinsic::kNone: + case CtorConvIntrinsic::kNone: return ""; -{{- range Sem.InitializersAndConverters }} - case InitConvIntrinsic::k{{Title .Name}}: +{{- range Sem.ConstructorsAndConverters }} + case CtorConvIntrinsic::k{{Title .Name}}: return "{{.Name}}"; {{- end }} } diff --git a/src/tint/resolver/init_conv_intrinsic.h b/src/tint/resolver/ctor_conv_intrinsic.h similarity index 57% rename from src/tint/resolver/init_conv_intrinsic.h rename to src/tint/resolver/ctor_conv_intrinsic.h index 07bb45b28f..4ee1c79e99 100644 --- a/src/tint/resolver/init_conv_intrinsic.h +++ b/src/tint/resolver/ctor_conv_intrinsic.h @@ -15,21 +15,21 @@ //////////////////////////////////////////////////////////////////////////////// // File generated by tools/src/cmd/gen // using the template: -// src/tint/resolver/init_conv_intrinsic.h.tmpl +// src/tint/resolver/ctor_conv_intrinsic.h.tmpl // // Do not modify this file directly //////////////////////////////////////////////////////////////////////////////// -#ifndef SRC_TINT_RESOLVER_INIT_CONV_INTRINSIC_H_ -#define SRC_TINT_RESOLVER_INIT_CONV_INTRINSIC_H_ +#ifndef SRC_TINT_RESOLVER_CTOR_CONV_INTRINSIC_H_ +#define SRC_TINT_RESOLVER_CTOR_CONV_INTRINSIC_H_ #include namespace tint::resolver { -/// InitConvIntrinsic is an enumerator of types that have a initializer or converter overload +/// CtorConvIntrinsic is an enumerator of types that have a constructor or converter overload /// declared in the intrinsic table. -enum class InitConvIntrinsic { +enum class CtorConvIntrinsic { kNone = -1, kI32, kU32, @@ -51,49 +51,49 @@ enum class InitConvIntrinsic { }; /// @returns the name of the type. -const char* str(InitConvIntrinsic i); +const char* str(CtorConvIntrinsic i); /// @param n the width of the vector -/// @return the InitConvIntrinsic for a vector of width `n` -inline InitConvIntrinsic VectorInitConvIntrinsic(uint32_t n) { +/// @return the CtorConvIntrinsic for a vector of width `n` +inline CtorConvIntrinsic VectorCtorConvIntrinsic(uint32_t n) { switch (n) { case 2: - return InitConvIntrinsic::kVec2; + return CtorConvIntrinsic::kVec2; case 3: - return InitConvIntrinsic::kVec3; + return CtorConvIntrinsic::kVec3; case 4: - return InitConvIntrinsic::kVec4; + return CtorConvIntrinsic::kVec4; } - return InitConvIntrinsic::kNone; + return CtorConvIntrinsic::kNone; } /// @param c the number of columns in the matrix /// @param r the number of rows in the matrix -/// @return the InitConvIntrinsic for a matrix with `c` columns and `r` rows -inline InitConvIntrinsic MatrixInitConvIntrinsic(uint32_t c, uint32_t r) { +/// @return the CtorConvIntrinsic for a matrix with `c` columns and `r` rows +inline CtorConvIntrinsic MatrixCtorConvIntrinsic(uint32_t c, uint32_t r) { switch ((c - 2) * 3 + (r - 2)) { case 0: - return InitConvIntrinsic::kMat2x2; + return CtorConvIntrinsic::kMat2x2; case 1: - return InitConvIntrinsic::kMat2x3; + return CtorConvIntrinsic::kMat2x3; case 2: - return InitConvIntrinsic::kMat2x4; + return CtorConvIntrinsic::kMat2x4; case 3: - return InitConvIntrinsic::kMat3x2; + return CtorConvIntrinsic::kMat3x2; case 4: - return InitConvIntrinsic::kMat3x3; + return CtorConvIntrinsic::kMat3x3; case 5: - return InitConvIntrinsic::kMat3x4; + return CtorConvIntrinsic::kMat3x4; case 6: - return InitConvIntrinsic::kMat4x2; + return CtorConvIntrinsic::kMat4x2; case 7: - return InitConvIntrinsic::kMat4x3; + return CtorConvIntrinsic::kMat4x3; case 8: - return InitConvIntrinsic::kMat4x4; + return CtorConvIntrinsic::kMat4x4; } - return InitConvIntrinsic::kNone; + return CtorConvIntrinsic::kNone; } } // namespace tint::resolver -#endif // SRC_TINT_RESOLVER_INIT_CONV_INTRINSIC_H_ +#endif // SRC_TINT_RESOLVER_CTOR_CONV_INTRINSIC_H_ diff --git a/src/tint/resolver/ctor_conv_intrinsic.h.tmpl b/src/tint/resolver/ctor_conv_intrinsic.h.tmpl new file mode 100644 index 0000000000..349f93907e --- /dev/null +++ b/src/tint/resolver/ctor_conv_intrinsic.h.tmpl @@ -0,0 +1,76 @@ +{{- /* +-------------------------------------------------------------------------------- +Template file for use with tools/src/cmd/gen to generate ctor_conv_intrinsic.h + +To update the generated file, run: + ./tools/run gen + +See: +* tools/src/cmd/gen for structures used by this template +* https://golang.org/pkg/text/template/ for documentation on the template syntax +-------------------------------------------------------------------------------- +*/ -}} + +#ifndef SRC_TINT_RESOLVER_CTOR_CONV_INTRINSIC_H_ +#define SRC_TINT_RESOLVER_CTOR_CONV_INTRINSIC_H_ + +#include + +namespace tint::resolver { + +/// CtorConvIntrinsic is an enumerator of types that have a constructor or converter overload +/// declared in the intrinsic table. +enum class CtorConvIntrinsic { + kNone = -1, +{{- range Sem.ConstructorsAndConverters }} + k{{Title .Name}}, +{{- end }} +}; + +/// @returns the name of the type. +const char* str(CtorConvIntrinsic i); + +/// @param n the width of the vector +/// @return the CtorConvIntrinsic for a vector of width `n` +inline CtorConvIntrinsic VectorCtorConvIntrinsic(uint32_t n) { + switch (n) { + case 2: + return CtorConvIntrinsic::kVec2; + case 3: + return CtorConvIntrinsic::kVec3; + case 4: + return CtorConvIntrinsic::kVec4; + } + return CtorConvIntrinsic::kNone; +} + +/// @param c the number of columns in the matrix +/// @param r the number of rows in the matrix +/// @return the CtorConvIntrinsic for a matrix with `c` columns and `r` rows +inline CtorConvIntrinsic MatrixCtorConvIntrinsic(uint32_t c, uint32_t r) { + switch ((c - 2) * 3 + (r - 2)) { + case 0: + return CtorConvIntrinsic::kMat2x2; + case 1: + return CtorConvIntrinsic::kMat2x3; + case 2: + return CtorConvIntrinsic::kMat2x4; + case 3: + return CtorConvIntrinsic::kMat3x2; + case 4: + return CtorConvIntrinsic::kMat3x3; + case 5: + return CtorConvIntrinsic::kMat3x4; + case 6: + return CtorConvIntrinsic::kMat4x2; + case 7: + return CtorConvIntrinsic::kMat4x3; + case 8: + return CtorConvIntrinsic::kMat4x4; + } + return CtorConvIntrinsic::kNone; +} + +} // namespace tint::resolver + +#endif // SRC_TINT_RESOLVER_CTOR_CONV_INTRINSIC_H_ diff --git a/src/tint/resolver/expression_kind_test.cc b/src/tint/resolver/expression_kind_test.cc index fb23e1438a..0b4584d2b1 100644 --- a/src/tint/resolver/expression_kind_test.cc +++ b/src/tint/resolver/expression_kind_test.cc @@ -445,7 +445,7 @@ INSTANTIATE_TEST_SUITE_P( R"(5:6 error: cannot use type 'vec4' as address space)"}, {Def::kBuiltinType, Use::kBinaryOp, R"(5:6 error: cannot use type 'vec4' as value -7:8 note: are you missing '()' for type initializer?)"}, +7:8 note: are you missing '()' for value constructor?)"}, {Def::kBuiltinType, Use::kBuiltinValue, R"(5:6 error: cannot use type 'vec4' as builtin value)"}, {Def::kBuiltinType, Use::kCallExpr, kPass}, @@ -459,11 +459,11 @@ INSTANTIATE_TEST_SUITE_P( R"(5:6 error: cannot use type 'vec4' as texel format)"}, {Def::kBuiltinType, Use::kValueExpression, R"(5:6 error: cannot use type 'vec4' as value -7:8 note: are you missing '()' for type initializer?)"}, +7:8 note: are you missing '()' for value constructor?)"}, {Def::kBuiltinType, Use::kVariableType, kPass}, {Def::kBuiltinType, Use::kUnaryOp, R"(5:6 error: cannot use type 'vec4' as value -7:8 note: are you missing '()' for type initializer?)"}, +7:8 note: are you missing '()' for value constructor?)"}, {Def::kBuiltinValue, Use::kAccess, R"(5:6 error: cannot use builtin value 'position' as access)"}, @@ -602,7 +602,7 @@ INSTANTIATE_TEST_SUITE_P( {Def::kStruct, Use::kAddressSpace, R"(5:6 error: cannot use type 'STRUCT' as address space)"}, {Def::kStruct, Use::kBinaryOp, R"(5:6 error: cannot use type 'STRUCT' as value -7:8 note: are you missing '()' for type initializer? +7:8 note: are you missing '()' for value constructor? 1:2 note: struct 'STRUCT' declared here)"}, {Def::kStruct, Use::kBuiltinValue, R"(5:6 error: cannot use type 'STRUCT' as builtin value)"}, @@ -615,12 +615,12 @@ INSTANTIATE_TEST_SUITE_P( {Def::kStruct, Use::kTexelFormat, R"(5:6 error: cannot use type 'STRUCT' as texel format)"}, {Def::kStruct, Use::kValueExpression, R"(5:6 error: cannot use type 'STRUCT' as value -7:8 note: are you missing '()' for type initializer? +7:8 note: are you missing '()' for value constructor? 1:2 note: struct 'STRUCT' declared here)"}, {Def::kStruct, Use::kVariableType, kPass}, {Def::kStruct, Use::kUnaryOp, R"(5:6 error: cannot use type 'STRUCT' as value -7:8 note: are you missing '()' for type initializer? +7:8 note: are you missing '()' for value constructor? 1:2 note: struct 'STRUCT' declared here)"}, {Def::kTexelFormat, Use::kAccess, @@ -656,7 +656,7 @@ INSTANTIATE_TEST_SUITE_P( R"(5:6 error: cannot use type 'i32' as address space)"}, {Def::kTypeAlias, Use::kBinaryOp, R"(5:6 error: cannot use type 'i32' as value -7:8 note: are you missing '()' for type initializer?)"}, +7:8 note: are you missing '()' for value constructor?)"}, {Def::kTypeAlias, Use::kBuiltinValue, R"(5:6 error: cannot use type 'i32' as builtin value)"}, {Def::kTypeAlias, Use::kCallExpr, kPass}, @@ -669,11 +669,11 @@ INSTANTIATE_TEST_SUITE_P( {Def::kTypeAlias, Use::kTexelFormat, R"(5:6 error: cannot use type 'i32' as texel format)"}, {Def::kTypeAlias, Use::kValueExpression, R"(5:6 error: cannot use type 'i32' as value -7:8 note: are you missing '()' for type initializer?)"}, +7:8 note: are you missing '()' for value constructor?)"}, {Def::kTypeAlias, Use::kVariableType, kPass}, {Def::kTypeAlias, Use::kUnaryOp, R"(5:6 error: cannot use type 'i32' as value -7:8 note: are you missing '()' for type initializer?)"}, +7:8 note: are you missing '()' for value constructor?)"}, {Def::kVariable, Use::kAccess, R"(5:6 error: cannot use const 'VARIABLE' as access 1:2 note: const 'VARIABLE' declared here)"}, diff --git a/src/tint/resolver/init_conv_intrinsic.h.tmpl b/src/tint/resolver/init_conv_intrinsic.h.tmpl deleted file mode 100644 index 5f1281b2b8..0000000000 --- a/src/tint/resolver/init_conv_intrinsic.h.tmpl +++ /dev/null @@ -1,76 +0,0 @@ -{{- /* --------------------------------------------------------------------------------- -Template file for use with tools/src/cmd/gen to generate init_conv_intrinsic.h - -To update the generated file, run: - ./tools/run gen - -See: -* tools/src/cmd/gen for structures used by this template -* https://golang.org/pkg/text/template/ for documentation on the template syntax --------------------------------------------------------------------------------- -*/ -}} - -#ifndef SRC_TINT_RESOLVER_INIT_CONV_INTRINSIC_H_ -#define SRC_TINT_RESOLVER_INIT_CONV_INTRINSIC_H_ - -#include - -namespace tint::resolver { - -/// InitConvIntrinsic is an enumerator of types that have a initializer or converter overload -/// declared in the intrinsic table. -enum class InitConvIntrinsic { - kNone = -1, -{{- range Sem.InitializersAndConverters }} - k{{Title .Name}}, -{{- end }} -}; - -/// @returns the name of the type. -const char* str(InitConvIntrinsic i); - -/// @param n the width of the vector -/// @return the InitConvIntrinsic for a vector of width `n` -inline InitConvIntrinsic VectorInitConvIntrinsic(uint32_t n) { - switch (n) { - case 2: - return InitConvIntrinsic::kVec2; - case 3: - return InitConvIntrinsic::kVec3; - case 4: - return InitConvIntrinsic::kVec4; - } - return InitConvIntrinsic::kNone; -} - -/// @param c the number of columns in the matrix -/// @param r the number of rows in the matrix -/// @return the InitConvIntrinsic for a matrix with `c` columns and `r` rows -inline InitConvIntrinsic MatrixInitConvIntrinsic(uint32_t c, uint32_t r) { - switch ((c - 2) * 3 + (r - 2)) { - case 0: - return InitConvIntrinsic::kMat2x2; - case 1: - return InitConvIntrinsic::kMat2x3; - case 2: - return InitConvIntrinsic::kMat2x4; - case 3: - return InitConvIntrinsic::kMat3x2; - case 4: - return InitConvIntrinsic::kMat3x3; - case 5: - return InitConvIntrinsic::kMat3x4; - case 6: - return InitConvIntrinsic::kMat4x2; - case 7: - return InitConvIntrinsic::kMat4x3; - case 8: - return InitConvIntrinsic::kMat4x4; - } - return InitConvIntrinsic::kNone; -} - -} // namespace tint::resolver - -#endif // SRC_TINT_RESOLVER_INIT_CONV_INTRINSIC_H_ diff --git a/src/tint/resolver/intrinsic_table.cc b/src/tint/resolver/intrinsic_table.cc index 34e4b5aec5..17927dbc32 100644 --- a/src/tint/resolver/intrinsic_table.cc +++ b/src/tint/resolver/intrinsic_table.cc @@ -22,8 +22,8 @@ #include "src/tint/program_builder.h" #include "src/tint/sem/evaluation_stage.h" #include "src/tint/sem/pipeline_stage_set.h" -#include "src/tint/sem/type_conversion.h" -#include "src/tint/sem/type_initializer.h" +#include "src/tint/sem/value_constructor.h" +#include "src/tint/sem/value_conversion.h" #include "src/tint/type/abstract_float.h" #include "src/tint/type/abstract_int.h" #include "src/tint/type/abstract_numeric.h" @@ -338,8 +338,8 @@ using PipelineStage = ast::PipelineStage; enum class OverloadFlag { kIsBuiltin, // The overload is a builtin ('fn') kIsOperator, // The overload is an operator ('op') - kIsInitializer, // The overload is a type initializer ('ctor') - kIsConverter, // The overload is a type converter ('conv') + kIsConstructor, // The overload is a value constructor ('ctor') + kIsConverter, // The overload is a value converter ('conv') kSupportsVertexPipeline, // The overload can be used in vertex shaders kSupportsFragmentPipeline, // The overload can be used in fragment shaders kSupportsComputePipeline, // The overload can be used in compute shaders @@ -1093,7 +1093,7 @@ class Impl : public IntrinsicTable { const Source& source, bool is_compound) override; - InitOrConv Lookup(InitConvIntrinsic type, + CtorOrConv Lookup(CtorConvIntrinsic type, const type::Type* template_arg, utils::VectorRef args, sem::EvaluationStage earliest_eval_stage, @@ -1201,9 +1201,9 @@ class Impl : public IntrinsicTable { ProgramBuilder& builder; Matchers matchers; utils::Hashmap builtins; - utils::Hashmap - initializers; - utils::Hashmap + utils::Hashmap + constructors; + utils::Hashmap converters; }; @@ -1425,7 +1425,7 @@ IntrinsicTable::BinaryOperator Impl::Lookup(ast::BinaryOp op, }; } -IntrinsicTable::InitOrConv Impl::Lookup(InitConvIntrinsic type, +IntrinsicTable::CtorOrConv Impl::Lookup(CtorConvIntrinsic type, const type::Type* template_arg, utils::VectorRef args, sem::EvaluationStage earliest_eval_stage, @@ -1435,11 +1435,11 @@ IntrinsicTable::InitOrConv Impl::Lookup(InitConvIntrinsic type, // Generates an error when no overloads match the provided arguments auto on_no_match = [&](utils::VectorRef candidates) { std::stringstream ss; - ss << "no matching initializer for " << CallSignature(builder, name, args, template_arg) + ss << "no matching constructor for " << CallSignature(builder, name, args, template_arg) << std::endl; Candidates ctor, conv; for (auto candidate : candidates) { - if (candidate.overload->flags.Contains(OverloadFlag::kIsInitializer)) { + if (candidate.overload->flags.Contains(OverloadFlag::kIsConstructor)) { ctor.Push(candidate); } else { conv.Push(candidate); @@ -1447,7 +1447,7 @@ IntrinsicTable::InitOrConv Impl::Lookup(InitConvIntrinsic type, } if (!ctor.IsEmpty()) { ss << std::endl - << ctor.Length() << " candidate initializer" << (ctor.Length() > 1 ? "s:" : ":") + << ctor.Length() << " candidate constructor" << (ctor.Length() > 1 ? "s:" : ":") << std::endl; PrintCandidates(ss, ctor, name); } @@ -1467,14 +1467,14 @@ IntrinsicTable::InitOrConv Impl::Lookup(InitConvIntrinsic type, } // Resolve the intrinsic overload - auto match = MatchIntrinsic(kInitializersAndConverters[static_cast(type)], name, args, + auto match = MatchIntrinsic(kConstructorsAndConverters[static_cast(type)], name, args, earliest_eval_stage, templates, on_no_match); if (!match.overload) { return {}; } - // Was this overload a initializer or conversion? - if (match.overload->flags.Contains(OverloadFlag::kIsInitializer)) { + // Was this overload a constructor or conversion? + if (match.overload->flags.Contains(OverloadFlag::kIsConstructor)) { utils::Vector params; params.Reserve(match.parameters.Length()); for (auto& p : match.parameters) { @@ -1484,11 +1484,11 @@ IntrinsicTable::InitOrConv Impl::Lookup(InitConvIntrinsic type, } auto eval_stage = match.overload->const_eval_fn ? sem::EvaluationStage::kConstant : sem::EvaluationStage::kRuntime; - auto* target = initializers.GetOrCreate(match, [&]() { - return builder.create(match.return_type, std::move(params), - eval_stage); + auto* target = constructors.GetOrCreate(match, [&]() { + return builder.create(match.return_type, std::move(params), + eval_stage); }); - return InitOrConv{target, match.overload->const_eval_fn}; + return CtorOrConv{target, match.overload->const_eval_fn}; } // Conversion. @@ -1498,9 +1498,9 @@ IntrinsicTable::InitOrConv Impl::Lookup(InitConvIntrinsic type, builtin::Access::kUndefined, match.parameters[0].usage); auto eval_stage = match.overload->const_eval_fn ? sem::EvaluationStage::kConstant : sem::EvaluationStage::kRuntime; - return builder.create(match.return_type, param, eval_stage); + return builder.create(match.return_type, param, eval_stage); }); - return InitOrConv{target, match.overload->const_eval_fn}; + return CtorOrConv{target, match.overload->const_eval_fn}; } IntrinsicPrototype Impl::MatchIntrinsic(const IntrinsicInfo& intrinsic, @@ -1753,8 +1753,8 @@ void Impl::PrintOverload(std::ostream& ss, // e.g. vec3(vec3) -> vec3 print_template_type = true; } else if ((overload->num_parameters == 0) && - overload->flags.Contains(OverloadFlag::kIsInitializer)) { - // Print for initializers with no params + overload->flags.Contains(OverloadFlag::kIsConstructor)) { + // Print for constructors with no params // e.g. vec2() -> vec2 print_template_type = true; } diff --git a/src/tint/resolver/intrinsic_table.h b/src/tint/resolver/intrinsic_table.h index c49ed5072f..515e8390ca 100644 --- a/src/tint/resolver/intrinsic_table.h +++ b/src/tint/resolver/intrinsic_table.h @@ -21,7 +21,7 @@ #include "src/tint/ast/binary_expression.h" #include "src/tint/ast/unary_op.h" #include "src/tint/resolver/const_eval.h" -#include "src/tint/resolver/init_conv_intrinsic.h" +#include "src/tint/resolver/ctor_conv_intrinsic.h" #include "src/tint/sem/builtin.h" #include "src/tint/utils/vector.h" @@ -72,9 +72,9 @@ class IntrinsicTable { ConstEval::Function const_eval_fn = nullptr; }; - /// InitOrConv describes a resolved type initializer or type conversion - struct InitOrConv { - /// The result type of the type initializer or type conversion + /// CtorOrConv describes a resolved value constructor or conversion + struct CtorOrConv { + /// The result type of the value constructor or conversion const sem::CallTarget* target = nullptr; /// The constant evaluation function ConstEval::Function const_eval_fn = nullptr; @@ -137,20 +137,20 @@ class IntrinsicTable { const Source& source, bool is_compound) = 0; - /// Lookup looks for the type initializer or conversion overload for the given - /// InitConvIntrinsic. + /// Lookup looks for the value constructor or conversion overload for the given + /// CtorConvIntrinsic. /// @param type the type being constructed or converted /// @param template_arg the optional template argument - /// @param args the argument types passed to the initializer / conversion call + /// @param args the argument types passed to the constructor / conversion call /// @param earliest_eval_stage the the earliest evaluation stage that a call to - /// the initializer or conversion can be made. This can alter the overloads considered. + /// the constructor or conversion can be made. This can alter the overloads considered. /// For example, if the earliest evaluation stage is /// `sem::EvaluationStage::kRuntime`, then only overloads with concrete argument types /// will be considered, as all abstract-numerics will have been materialized /// after shader creation time (sem::EvaluationStage::kConstant). /// @param source the source of the call - /// @return a sem::TypeInitializer, sem::TypeConversion or nullptr if nothing matched - virtual InitOrConv Lookup(InitConvIntrinsic type, + /// @return a sem::ValueConstructor, sem::ValueConversion or nullptr if nothing matched + virtual CtorOrConv Lookup(CtorConvIntrinsic type, const type::Type* template_arg, utils::VectorRef args, sem::EvaluationStage earliest_eval_stage, diff --git a/src/tint/resolver/intrinsic_table.inl b/src/tint/resolver/intrinsic_table.inl index fcda04fe86..3d15e1f133 100644 --- a/src/tint/resolver/intrinsic_table.inl +++ b/src/tint/resolver/intrinsic_table.inl @@ -8881,7 +8881,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[1013], /* return matcher indices */ &kMatcherIndices[134], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Zero, }, { @@ -8893,7 +8893,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[979], /* return matcher indices */ &kMatcherIndices[134], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Identity, }, { @@ -8905,7 +8905,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[980], /* return matcher indices */ &kMatcherIndices[134], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::VecSplat, }, { @@ -8917,7 +8917,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[427], /* return matcher indices */ &kMatcherIndices[134], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::VecInitS, }, { @@ -8929,7 +8929,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[576], /* return matcher indices */ &kMatcherIndices[134], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::VecInitM, }, { @@ -8941,7 +8941,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[579], /* return matcher indices */ &kMatcherIndices[134], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::VecInitM, }, { @@ -8953,7 +8953,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[582], /* return matcher indices */ &kMatcherIndices[134], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::VecInitM, }, { @@ -8965,7 +8965,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[788], /* return matcher indices */ &kMatcherIndices[134], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::VecInitM, }, { @@ -8977,7 +8977,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[790], /* return matcher indices */ &kMatcherIndices[134], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::VecInitM, }, { @@ -8989,7 +8989,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[792], /* return matcher indices */ &kMatcherIndices[134], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::VecInitM, }, { @@ -9517,7 +9517,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[1013], /* return matcher indices */ &kMatcherIndices[106], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Zero, }, { @@ -9529,7 +9529,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[972], /* return matcher indices */ &kMatcherIndices[106], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Identity, }, { @@ -9541,7 +9541,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[973], /* return matcher indices */ &kMatcherIndices[106], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::VecSplat, }, { @@ -9553,7 +9553,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[573], /* return matcher indices */ &kMatcherIndices[106], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::VecInitS, }, { @@ -9565,7 +9565,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[784], /* return matcher indices */ &kMatcherIndices[106], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::VecInitM, }, { @@ -9577,7 +9577,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[786], /* return matcher indices */ &kMatcherIndices[106], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::VecInitM, }, { @@ -9985,7 +9985,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[1013], /* return matcher indices */ &kMatcherIndices[23], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Zero, }, { @@ -9997,7 +9997,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[965], /* return matcher indices */ &kMatcherIndices[23], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Identity, }, { @@ -10009,7 +10009,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[966], /* return matcher indices */ &kMatcherIndices[23], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::VecSplat, }, { @@ -10021,7 +10021,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[782], /* return matcher indices */ &kMatcherIndices[23], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::VecInitS, }, { @@ -10501,7 +10501,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[1013], /* return matcher indices */ &kMatcherIndices[178], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Zero, }, { @@ -10513,7 +10513,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[986], /* return matcher indices */ &kMatcherIndices[178], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Identity, }, { @@ -10525,7 +10525,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[431], /* return matcher indices */ &kMatcherIndices[178], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::MatInitS, }, { @@ -10537,7 +10537,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[794], /* return matcher indices */ &kMatcherIndices[178], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::MatInitV, }, { @@ -10573,7 +10573,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[1013], /* return matcher indices */ &kMatcherIndices[184], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Zero, }, { @@ -10585,7 +10585,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[989], /* return matcher indices */ &kMatcherIndices[184], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Identity, }, { @@ -10597,7 +10597,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[138], /* return matcher indices */ &kMatcherIndices[184], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::MatInitS, }, { @@ -10609,7 +10609,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[796], /* return matcher indices */ &kMatcherIndices[184], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::MatInitV, }, { @@ -10645,7 +10645,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[1013], /* return matcher indices */ &kMatcherIndices[190], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Zero, }, { @@ -10657,7 +10657,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[992], /* return matcher indices */ &kMatcherIndices[190], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Identity, }, { @@ -10669,7 +10669,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[49], /* return matcher indices */ &kMatcherIndices[190], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::MatInitS, }, { @@ -10681,7 +10681,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[798], /* return matcher indices */ &kMatcherIndices[190], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::MatInitV, }, { @@ -10717,7 +10717,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[1013], /* return matcher indices */ &kMatcherIndices[196], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Zero, }, { @@ -10729,7 +10729,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[995], /* return matcher indices */ &kMatcherIndices[196], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Identity, }, { @@ -10741,7 +10741,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[144], /* return matcher indices */ &kMatcherIndices[196], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::MatInitS, }, { @@ -10753,7 +10753,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[585], /* return matcher indices */ &kMatcherIndices[196], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::MatInitV, }, { @@ -10789,7 +10789,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[1013], /* return matcher indices */ &kMatcherIndices[202], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Zero, }, { @@ -10801,7 +10801,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[998], /* return matcher indices */ &kMatcherIndices[202], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Identity, }, { @@ -10813,7 +10813,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[40], /* return matcher indices */ &kMatcherIndices[202], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::MatInitS, }, { @@ -10825,7 +10825,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[588], /* return matcher indices */ &kMatcherIndices[202], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::MatInitV, }, { @@ -10861,7 +10861,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[1013], /* return matcher indices */ &kMatcherIndices[208], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Zero, }, { @@ -10873,7 +10873,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[1001], /* return matcher indices */ &kMatcherIndices[208], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Identity, }, { @@ -10885,7 +10885,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[16], /* return matcher indices */ &kMatcherIndices[208], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::MatInitS, }, { @@ -10897,7 +10897,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[591], /* return matcher indices */ &kMatcherIndices[208], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::MatInitV, }, { @@ -10933,7 +10933,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[1013], /* return matcher indices */ &kMatcherIndices[214], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Zero, }, { @@ -10945,7 +10945,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[1004], /* return matcher indices */ &kMatcherIndices[214], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Identity, }, { @@ -10957,7 +10957,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[57], /* return matcher indices */ &kMatcherIndices[214], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::MatInitS, }, { @@ -10969,7 +10969,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[435], /* return matcher indices */ &kMatcherIndices[214], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::MatInitV, }, { @@ -11005,7 +11005,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[1013], /* return matcher indices */ &kMatcherIndices[220], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Zero, }, { @@ -11017,7 +11017,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[1007], /* return matcher indices */ &kMatcherIndices[220], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Identity, }, { @@ -11029,7 +11029,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[28], /* return matcher indices */ &kMatcherIndices[220], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::MatInitS, }, { @@ -11041,7 +11041,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[439], /* return matcher indices */ &kMatcherIndices[220], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::MatInitV, }, { @@ -11077,7 +11077,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[1013], /* return matcher indices */ &kMatcherIndices[226], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Zero, }, { @@ -11089,7 +11089,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[1010], /* return matcher indices */ &kMatcherIndices[226], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Identity, }, { @@ -11101,7 +11101,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[0], /* return matcher indices */ &kMatcherIndices[226], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::MatInitS, }, { @@ -11113,7 +11113,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[443], /* return matcher indices */ &kMatcherIndices[226], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::MatInitV, }, { @@ -11593,7 +11593,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[1013], /* return matcher indices */ &kMatcherIndices[9], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Zero, }, { @@ -11605,7 +11605,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[955], /* return matcher indices */ &kMatcherIndices[9], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Identity, }, { @@ -11629,7 +11629,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[1013], /* return matcher indices */ &kMatcherIndices[105], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Zero, }, { @@ -11641,7 +11641,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[957], /* return matcher indices */ &kMatcherIndices[105], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Identity, }, { @@ -11665,7 +11665,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[1013], /* return matcher indices */ &kMatcherIndices[42], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Zero, }, { @@ -11677,7 +11677,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[959], /* return matcher indices */ &kMatcherIndices[42], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Identity, }, { @@ -11701,7 +11701,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[1013], /* return matcher indices */ &kMatcherIndices[1], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Zero, }, { @@ -11713,7 +11713,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[961], /* return matcher indices */ &kMatcherIndices[1], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Identity, }, { @@ -11737,7 +11737,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[1013], /* return matcher indices */ &kMatcherIndices[39], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Zero, }, { @@ -11749,7 +11749,7 @@ constexpr OverloadInfo kOverloads[] = { /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[963], /* return matcher indices */ &kMatcherIndices[39], - /* flags */ OverloadFlags(OverloadFlag::kIsInitializer, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), + /* flags */ OverloadFlags(OverloadFlag::kIsConstructor, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline, OverloadFlag::kMustUse), /* const eval */ &ConstEval::Identity, }, { @@ -15094,53 +15094,53 @@ constexpr uint8_t kBinaryOperatorGreaterThanEqual = 15; constexpr uint8_t kBinaryOperatorShiftLeft = 16; constexpr uint8_t kBinaryOperatorShiftRight = 17; -constexpr IntrinsicInfo kInitializersAndConverters[] = { +constexpr IntrinsicInfo kConstructorsAndConverters[] = { { /* [0] */ - /* init i32() -> i32 */ - /* init i32(i32) -> i32 */ + /* ctor i32() -> i32 */ + /* ctor i32(i32) -> i32 */ /* conv i32(T) -> i32 */ /* num overloads */ 3, /* overloads */ &kOverloads[268], }, { /* [1] */ - /* init u32() -> u32 */ - /* init u32(u32) -> u32 */ + /* ctor u32() -> u32 */ + /* ctor u32(u32) -> u32 */ /* conv u32(T) -> u32 */ /* num overloads */ 3, /* overloads */ &kOverloads[271], }, { /* [2] */ - /* init f32() -> f32 */ - /* init f32(f32) -> f32 */ + /* ctor f32() -> f32 */ + /* ctor f32(f32) -> f32 */ /* conv f32(T) -> f32 */ /* num overloads */ 3, /* overloads */ &kOverloads[274], }, { /* [3] */ - /* init f16() -> f16 */ - /* init f16(f16) -> f16 */ + /* ctor f16() -> f16 */ + /* ctor f16(f16) -> f16 */ /* conv f16(T) -> f16 */ /* num overloads */ 3, /* overloads */ &kOverloads[277], }, { /* [4] */ - /* init bool() -> bool */ - /* init bool(bool) -> bool */ + /* ctor bool() -> bool */ + /* ctor bool(bool) -> bool */ /* conv bool(T) -> bool */ /* num overloads */ 3, /* overloads */ &kOverloads[280], }, { /* [5] */ - /* init vec2() -> vec2 */ - /* init vec2(vec2) -> vec2 */ - /* init vec2(T) -> vec2 */ - /* init vec2(x: T, y: T) -> vec2 */ + /* ctor vec2() -> vec2 */ + /* ctor vec2(vec2) -> vec2 */ + /* ctor vec2(T) -> vec2 */ + /* ctor vec2(x: T, y: T) -> vec2 */ /* conv vec2(vec2) -> vec2 */ /* conv vec2(vec2) -> vec2 */ /* conv vec2(vec2) -> vec2 */ @@ -15151,12 +15151,12 @@ constexpr IntrinsicInfo kInitializersAndConverters[] = { }, { /* [6] */ - /* init vec3() -> vec3 */ - /* init vec3(vec3) -> vec3 */ - /* init vec3(T) -> vec3 */ - /* init vec3(x: T, y: T, z: T) -> vec3 */ - /* init vec3(xy: vec2, z: T) -> vec3 */ - /* init vec3(x: T, yz: vec2) -> vec3 */ + /* ctor vec3() -> vec3 */ + /* ctor vec3(vec3) -> vec3 */ + /* ctor vec3(T) -> vec3 */ + /* ctor vec3(x: T, y: T, z: T) -> vec3 */ + /* ctor vec3(xy: vec2, z: T) -> vec3 */ + /* ctor vec3(x: T, yz: vec2) -> vec3 */ /* conv vec3(vec3) -> vec3 */ /* conv vec3(vec3) -> vec3 */ /* conv vec3(vec3) -> vec3 */ @@ -15167,16 +15167,16 @@ constexpr IntrinsicInfo kInitializersAndConverters[] = { }, { /* [7] */ - /* init vec4() -> vec4 */ - /* init vec4(vec4) -> vec4 */ - /* init vec4(T) -> vec4 */ - /* init vec4(x: T, y: T, z: T, w: T) -> vec4 */ - /* init vec4(xy: vec2, z: T, w: T) -> vec4 */ - /* init vec4(x: T, yz: vec2, w: T) -> vec4 */ - /* init vec4(x: T, y: T, zw: vec2) -> vec4 */ - /* init vec4(xy: vec2, zw: vec2) -> vec4 */ - /* init vec4(xyz: vec3, w: T) -> vec4 */ - /* init vec4(x: T, zyw: vec3) -> vec4 */ + /* ctor vec4() -> vec4 */ + /* ctor vec4(vec4) -> vec4 */ + /* ctor vec4(T) -> vec4 */ + /* ctor vec4(x: T, y: T, z: T, w: T) -> vec4 */ + /* ctor vec4(xy: vec2, z: T, w: T) -> vec4 */ + /* ctor vec4(x: T, yz: vec2, w: T) -> vec4 */ + /* ctor vec4(x: T, y: T, zw: vec2) -> vec4 */ + /* ctor vec4(xy: vec2, zw: vec2) -> vec4 */ + /* ctor vec4(xyz: vec3, w: T) -> vec4 */ + /* ctor vec4(x: T, zyw: vec3) -> vec4 */ /* conv vec4(vec4) -> vec4 */ /* conv vec4(vec4) -> vec4 */ /* conv vec4(vec4) -> vec4 */ @@ -15187,10 +15187,10 @@ constexpr IntrinsicInfo kInitializersAndConverters[] = { }, { /* [8] */ - /* init mat2x2() -> mat2x2 */ - /* init mat2x2(mat2x2) -> mat2x2 */ - /* init mat2x2(T, T, T, T) -> mat2x2 */ - /* init mat2x2(vec2, vec2) -> mat2x2 */ + /* ctor mat2x2() -> mat2x2 */ + /* ctor mat2x2(mat2x2) -> mat2x2 */ + /* ctor mat2x2(T, T, T, T) -> mat2x2 */ + /* ctor mat2x2(vec2, vec2) -> mat2x2 */ /* conv mat2x2(mat2x2) -> mat2x2 */ /* conv mat2x2(mat2x2) -> mat2x2 */ /* num overloads */ 6, @@ -15198,10 +15198,10 @@ constexpr IntrinsicInfo kInitializersAndConverters[] = { }, { /* [9] */ - /* init mat2x3() -> mat2x3 */ - /* init mat2x3(mat2x3) -> mat2x3 */ - /* init mat2x3(T, T, T, T, T, T) -> mat2x3 */ - /* init mat2x3(vec3, vec3) -> mat2x3 */ + /* ctor mat2x3() -> mat2x3 */ + /* ctor mat2x3(mat2x3) -> mat2x3 */ + /* ctor mat2x3(T, T, T, T, T, T) -> mat2x3 */ + /* ctor mat2x3(vec3, vec3) -> mat2x3 */ /* conv mat2x3(mat2x3) -> mat2x3 */ /* conv mat2x3(mat2x3) -> mat2x3 */ /* num overloads */ 6, @@ -15209,10 +15209,10 @@ constexpr IntrinsicInfo kInitializersAndConverters[] = { }, { /* [10] */ - /* init mat2x4() -> mat2x4 */ - /* init mat2x4(mat2x4) -> mat2x4 */ - /* init mat2x4(T, T, T, T, T, T, T, T) -> mat2x4 */ - /* init mat2x4(vec4, vec4) -> mat2x4 */ + /* ctor mat2x4() -> mat2x4 */ + /* ctor mat2x4(mat2x4) -> mat2x4 */ + /* ctor mat2x4(T, T, T, T, T, T, T, T) -> mat2x4 */ + /* ctor mat2x4(vec4, vec4) -> mat2x4 */ /* conv mat2x4(mat2x4) -> mat2x4 */ /* conv mat2x4(mat2x4) -> mat2x4 */ /* num overloads */ 6, @@ -15220,10 +15220,10 @@ constexpr IntrinsicInfo kInitializersAndConverters[] = { }, { /* [11] */ - /* init mat3x2() -> mat3x2 */ - /* init mat3x2(mat3x2) -> mat3x2 */ - /* init mat3x2(T, T, T, T, T, T) -> mat3x2 */ - /* init mat3x2(vec2, vec2, vec2) -> mat3x2 */ + /* ctor mat3x2() -> mat3x2 */ + /* ctor mat3x2(mat3x2) -> mat3x2 */ + /* ctor mat3x2(T, T, T, T, T, T) -> mat3x2 */ + /* ctor mat3x2(vec2, vec2, vec2) -> mat3x2 */ /* conv mat3x2(mat3x2) -> mat3x2 */ /* conv mat3x2(mat3x2) -> mat3x2 */ /* num overloads */ 6, @@ -15231,10 +15231,10 @@ constexpr IntrinsicInfo kInitializersAndConverters[] = { }, { /* [12] */ - /* init mat3x3() -> mat3x3 */ - /* init mat3x3(mat3x3) -> mat3x3 */ - /* init mat3x3(T, T, T, T, T, T, T, T, T) -> mat3x3 */ - /* init mat3x3(vec3, vec3, vec3) -> mat3x3 */ + /* ctor mat3x3() -> mat3x3 */ + /* ctor mat3x3(mat3x3) -> mat3x3 */ + /* ctor mat3x3(T, T, T, T, T, T, T, T, T) -> mat3x3 */ + /* ctor mat3x3(vec3, vec3, vec3) -> mat3x3 */ /* conv mat3x3(mat3x3) -> mat3x3 */ /* conv mat3x3(mat3x3) -> mat3x3 */ /* num overloads */ 6, @@ -15242,10 +15242,10 @@ constexpr IntrinsicInfo kInitializersAndConverters[] = { }, { /* [13] */ - /* init mat3x4() -> mat3x4 */ - /* init mat3x4(mat3x4) -> mat3x4 */ - /* init mat3x4(T, T, T, T, T, T, T, T, T, T, T, T) -> mat3x4 */ - /* init mat3x4(vec4, vec4, vec4) -> mat3x4 */ + /* ctor mat3x4() -> mat3x4 */ + /* ctor mat3x4(mat3x4) -> mat3x4 */ + /* ctor mat3x4(T, T, T, T, T, T, T, T, T, T, T, T) -> mat3x4 */ + /* ctor mat3x4(vec4, vec4, vec4) -> mat3x4 */ /* conv mat3x4(mat3x4) -> mat3x4 */ /* conv mat3x4(mat3x4) -> mat3x4 */ /* num overloads */ 6, @@ -15253,10 +15253,10 @@ constexpr IntrinsicInfo kInitializersAndConverters[] = { }, { /* [14] */ - /* init mat4x2() -> mat4x2 */ - /* init mat4x2(mat4x2) -> mat4x2 */ - /* init mat4x2(T, T, T, T, T, T, T, T) -> mat4x2 */ - /* init mat4x2(vec2, vec2, vec2, vec2) -> mat4x2 */ + /* ctor mat4x2() -> mat4x2 */ + /* ctor mat4x2(mat4x2) -> mat4x2 */ + /* ctor mat4x2(T, T, T, T, T, T, T, T) -> mat4x2 */ + /* ctor mat4x2(vec2, vec2, vec2, vec2) -> mat4x2 */ /* conv mat4x2(mat4x2) -> mat4x2 */ /* conv mat4x2(mat4x2) -> mat4x2 */ /* num overloads */ 6, @@ -15264,10 +15264,10 @@ constexpr IntrinsicInfo kInitializersAndConverters[] = { }, { /* [15] */ - /* init mat4x3() -> mat4x3 */ - /* init mat4x3(mat4x3) -> mat4x3 */ - /* init mat4x3(T, T, T, T, T, T, T, T, T, T, T, T) -> mat4x3 */ - /* init mat4x3(vec3, vec3, vec3, vec3) -> mat4x3 */ + /* ctor mat4x3() -> mat4x3 */ + /* ctor mat4x3(mat4x3) -> mat4x3 */ + /* ctor mat4x3(T, T, T, T, T, T, T, T, T, T, T, T) -> mat4x3 */ + /* ctor mat4x3(vec3, vec3, vec3, vec3) -> mat4x3 */ /* conv mat4x3(mat4x3) -> mat4x3 */ /* conv mat4x3(mat4x3) -> mat4x3 */ /* num overloads */ 6, @@ -15275,10 +15275,10 @@ constexpr IntrinsicInfo kInitializersAndConverters[] = { }, { /* [16] */ - /* init mat4x4() -> mat4x4 */ - /* init mat4x4(mat4x4) -> mat4x4 */ - /* init mat4x4(T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) -> mat4x4 */ - /* init mat4x4(vec4, vec4, vec4, vec4) -> mat4x4 */ + /* ctor mat4x4() -> mat4x4 */ + /* ctor mat4x4(mat4x4) -> mat4x4 */ + /* ctor mat4x4(T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) -> mat4x4 */ + /* ctor mat4x4(vec4, vec4, vec4, vec4) -> mat4x4 */ /* conv mat4x4(mat4x4) -> mat4x4 */ /* conv mat4x4(mat4x4) -> mat4x4 */ /* num overloads */ 6, diff --git a/src/tint/resolver/intrinsic_table.inl.tmpl b/src/tint/resolver/intrinsic_table.inl.tmpl index db146a87e7..92e7e31669 100644 --- a/src/tint/resolver/intrinsic_table.inl.tmpl +++ b/src/tint/resolver/intrinsic_table.inl.tmpl @@ -162,8 +162,8 @@ constexpr IntrinsicInfo kBinaryOperators[] = { constexpr uint8_t kBinaryOperator{{ template "ExpandName" $o.Name}} = {{$i}}; {{- end }} -constexpr IntrinsicInfo kInitializersAndConverters[] = { -{{- range $i, $o := .InitializersAndConverters }} +constexpr IntrinsicInfo kConstructorsAndConverters[] = { +{{- range $i, $o := .ConstructorsAndConverters }} { /* [{{$i}}] */ {{- range $o.OverloadDescriptions }} diff --git a/src/tint/resolver/intrinsic_table_test.cc b/src/tint/resolver/intrinsic_table_test.cc index 5aee48056e..7f0399d188 100644 --- a/src/tint/resolver/intrinsic_table_test.cc +++ b/src/tint/resolver/intrinsic_table_test.cc @@ -19,8 +19,8 @@ #include "gmock/gmock.h" #include "src/tint/program_builder.h" #include "src/tint/resolver/resolver_test_helper.h" -#include "src/tint/sem/type_conversion.h" -#include "src/tint/sem/type_initializer.h" +#include "src/tint/sem/value_constructor.h" +#include "src/tint/sem/value_conversion.h" #include "src/tint/type/atomic.h" #include "src/tint/type/depth_multisampled_texture.h" #include "src/tint/type/depth_texture.h" @@ -802,11 +802,11 @@ TEST_F(IntrinsicTableTest, MismatchCompoundOp) { TEST_F(IntrinsicTableTest, MatchTypeInitializerImplicit) { auto* i32 = create(); auto* vec3_i32 = create(i32, 3u); - auto result = table->Lookup(InitConvIntrinsic::kVec3, nullptr, utils::Vector{i32, i32, i32}, + auto result = table->Lookup(CtorConvIntrinsic::kVec3, nullptr, utils::Vector{i32, i32, i32}, sem::EvaluationStage::kConstant, Source{{12, 34}}); ASSERT_NE(result.target, nullptr); EXPECT_EQ(result.target->ReturnType(), vec3_i32); - EXPECT_TRUE(result.target->Is()); + EXPECT_TRUE(result.target->Is()); ASSERT_EQ(result.target->Parameters().Length(), 3u); EXPECT_EQ(result.target->Parameters()[0]->Type(), i32); EXPECT_EQ(result.target->Parameters()[1]->Type(), i32); @@ -817,11 +817,11 @@ TEST_F(IntrinsicTableTest, MatchTypeInitializerImplicit) { TEST_F(IntrinsicTableTest, MatchTypeInitializerExplicit) { auto* i32 = create(); auto* vec3_i32 = create(i32, 3u); - auto result = table->Lookup(InitConvIntrinsic::kVec3, i32, utils::Vector{i32, i32, i32}, + auto result = table->Lookup(CtorConvIntrinsic::kVec3, i32, utils::Vector{i32, i32, i32}, sem::EvaluationStage::kConstant, Source{{12, 34}}); ASSERT_NE(result.target, nullptr); EXPECT_EQ(result.target->ReturnType(), vec3_i32); - EXPECT_TRUE(result.target->Is()); + EXPECT_TRUE(result.target->Is()); ASSERT_EQ(result.target->Parameters().Length(), 3u); EXPECT_EQ(result.target->Parameters()[0]->Type(), i32); EXPECT_EQ(result.target->Parameters()[1]->Type(), i32); @@ -832,13 +832,13 @@ TEST_F(IntrinsicTableTest, MatchTypeInitializerExplicit) { TEST_F(IntrinsicTableTest, MismatchTypeInitializerImplicit) { auto* i32 = create(); auto* f32 = create(); - auto result = table->Lookup(InitConvIntrinsic::kVec3, nullptr, utils::Vector{i32, f32, i32}, + auto result = table->Lookup(CtorConvIntrinsic::kVec3, nullptr, utils::Vector{i32, f32, i32}, sem::EvaluationStage::kConstant, Source{{12, 34}}); ASSERT_EQ(result.target, nullptr); EXPECT_EQ(Diagnostics().str(), - R"(12:34 error: no matching initializer for vec3(i32, f32, i32) + R"(12:34 error: no matching constructor for vec3(i32, f32, i32) -6 candidate initializers: +6 candidate constructors: vec3(x: T, y: T, z: T) -> vec3 where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool vec3(xy: vec2, z: T) -> vec3 where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool vec3(x: T, yz: vec2) -> vec3 where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool @@ -858,13 +858,13 @@ TEST_F(IntrinsicTableTest, MismatchTypeInitializerImplicit) { TEST_F(IntrinsicTableTest, MismatchTypeInitializerExplicit) { auto* i32 = create(); auto* f32 = create(); - auto result = table->Lookup(InitConvIntrinsic::kVec3, i32, utils::Vector{i32, f32, i32}, + auto result = table->Lookup(CtorConvIntrinsic::kVec3, i32, utils::Vector{i32, f32, i32}, sem::EvaluationStage::kConstant, Source{{12, 34}}); ASSERT_EQ(result.target, nullptr); EXPECT_EQ(Diagnostics().str(), - R"(12:34 error: no matching initializer for vec3(i32, f32, i32) + R"(12:34 error: no matching constructor for vec3(i32, f32, i32) -6 candidate initializers: +6 candidate constructors: vec3(x: T, y: T, z: T) -> vec3 where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool vec3(x: T, yz: vec2) -> vec3 where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool vec3(T) -> vec3 where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool @@ -884,11 +884,11 @@ TEST_F(IntrinsicTableTest, MismatchTypeInitializerExplicit) { TEST_F(IntrinsicTableTest, MatchTypeInitializerImplicitVecFromVecAbstract) { auto* ai = create(); auto* vec3_ai = create(ai, 3u); - auto result = table->Lookup(InitConvIntrinsic::kVec3, nullptr, utils::Vector{vec3_ai}, + auto result = table->Lookup(CtorConvIntrinsic::kVec3, nullptr, utils::Vector{vec3_ai}, sem::EvaluationStage::kConstant, Source{{12, 34}}); ASSERT_NE(result.target, nullptr); EXPECT_EQ(result.target->ReturnType(), vec3_ai); - EXPECT_TRUE(result.target->Is()); + EXPECT_TRUE(result.target->Is()); ASSERT_EQ(result.target->Parameters().Length(), 1u); EXPECT_EQ(result.target->Parameters()[0]->Type(), vec3_ai); EXPECT_NE(result.const_eval_fn, nullptr); @@ -900,11 +900,11 @@ TEST_F(IntrinsicTableTest, MatchTypeInitializerImplicitMatFromVec) { auto* vec2_af = create(af, 2u); auto* mat2x2_af = create(vec2_af, 2u); auto result = - table->Lookup(InitConvIntrinsic::kMat2x2, nullptr, utils::Vector{vec2_ai, vec2_ai}, + table->Lookup(CtorConvIntrinsic::kMat2x2, nullptr, utils::Vector{vec2_ai, vec2_ai}, sem::EvaluationStage::kConstant, Source{{12, 34}}); ASSERT_NE(result.target, nullptr); EXPECT_TYPE(result.target->ReturnType(), mat2x2_af); - EXPECT_TRUE(result.target->Is()); + EXPECT_TRUE(result.target->Is()); ASSERT_EQ(result.target->Parameters().Length(), 2u); EXPECT_TYPE(result.target->Parameters()[0]->Type(), vec2_af); EXPECT_TYPE(result.target->Parameters()[1]->Type(), vec2_af); @@ -914,12 +914,12 @@ TEST_F(IntrinsicTableTest, MatchTypeInitializerImplicitMatFromVec) { TEST_F(IntrinsicTableTest, MatchTypeInitializer_ConstantEval) { auto* ai = create(); auto* vec3_ai = create(ai, 3u); - auto result = table->Lookup(InitConvIntrinsic::kVec3, nullptr, utils::Vector{ai, ai, ai}, + auto result = table->Lookup(CtorConvIntrinsic::kVec3, nullptr, utils::Vector{ai, ai, ai}, sem::EvaluationStage::kConstant, Source{{12, 34}}); ASSERT_NE(result.target, nullptr); EXPECT_EQ(result.target->Stage(), sem::EvaluationStage::kConstant); EXPECT_EQ(result.target->ReturnType(), vec3_ai); - EXPECT_TRUE(result.target->Is()); + EXPECT_TRUE(result.target->Is()); ASSERT_EQ(result.target->Parameters().Length(), 3u); EXPECT_EQ(result.target->Parameters()[0]->Type(), ai); EXPECT_EQ(result.target->Parameters()[1]->Type(), ai); @@ -929,14 +929,14 @@ TEST_F(IntrinsicTableTest, MatchTypeInitializer_ConstantEval) { TEST_F(IntrinsicTableTest, MatchTypeInitializer_RuntimeEval) { auto* ai = create(); - auto result = table->Lookup(InitConvIntrinsic::kVec3, nullptr, utils::Vector{ai, ai, ai}, + auto result = table->Lookup(CtorConvIntrinsic::kVec3, nullptr, utils::Vector{ai, ai, ai}, sem::EvaluationStage::kRuntime, Source{{12, 34}}); auto* i32 = create(); auto* vec3_i32 = create(i32, 3u); ASSERT_NE(result.target, nullptr); EXPECT_EQ(result.target->Stage(), sem::EvaluationStage::kConstant); EXPECT_EQ(result.target->ReturnType(), vec3_i32); - EXPECT_TRUE(result.target->Is()); + EXPECT_TRUE(result.target->Is()); ASSERT_EQ(result.target->Parameters().Length(), 3u); EXPECT_EQ(result.target->Parameters()[0]->Type(), i32); EXPECT_EQ(result.target->Parameters()[1]->Type(), i32); @@ -949,11 +949,11 @@ TEST_F(IntrinsicTableTest, MatchTypeConversion) { auto* vec3_i32 = create(i32, 3u); auto* f32 = create(); auto* vec3_f32 = create(f32, 3u); - auto result = table->Lookup(InitConvIntrinsic::kVec3, i32, utils::Vector{vec3_f32}, + auto result = table->Lookup(CtorConvIntrinsic::kVec3, i32, utils::Vector{vec3_f32}, sem::EvaluationStage::kConstant, Source{{12, 34}}); ASSERT_NE(result.target, nullptr); EXPECT_EQ(result.target->ReturnType(), vec3_i32); - EXPECT_TRUE(result.target->Is()); + EXPECT_TRUE(result.target->Is()); ASSERT_EQ(result.target->Parameters().Length(), 1u); EXPECT_EQ(result.target->Parameters()[0]->Type(), vec3_f32); } @@ -962,13 +962,13 @@ TEST_F(IntrinsicTableTest, MismatchTypeConversion) { auto* arr = create(create(), create(), 4u, 4u, 4u, 4u); auto* f32 = create(); - auto result = table->Lookup(InitConvIntrinsic::kVec3, f32, utils::Vector{arr}, + auto result = table->Lookup(CtorConvIntrinsic::kVec3, f32, utils::Vector{arr}, sem::EvaluationStage::kConstant, Source{{12, 34}}); ASSERT_EQ(result.target, nullptr); EXPECT_EQ(Diagnostics().str(), - R"(12:34 error: no matching initializer for vec3(array) + R"(12:34 error: no matching constructor for vec3(array) -6 candidate initializers: +6 candidate constructors: vec3(vec3) -> vec3 where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool vec3(T) -> vec3 where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool vec3() -> vec3 where: T is f32, f16, i32, u32 or bool @@ -991,13 +991,13 @@ TEST_F(IntrinsicTableTest, MatchTypeConversion_ConstantEval) { auto* vec3_ai = create(ai, 3u); auto* f32 = create(); auto* vec3_f32 = create(f32, 3u); - auto result = table->Lookup(InitConvIntrinsic::kVec3, af, utils::Vector{vec3_ai}, + auto result = table->Lookup(CtorConvIntrinsic::kVec3, af, utils::Vector{vec3_ai}, sem::EvaluationStage::kConstant, Source{{12, 34}}); ASSERT_NE(result.target, nullptr); EXPECT_EQ(result.target->Stage(), sem::EvaluationStage::kConstant); // NOTE: Conversions are explicit, so there's no way to have it return abstracts EXPECT_EQ(result.target->ReturnType(), vec3_f32); - EXPECT_TRUE(result.target->Is()); + EXPECT_TRUE(result.target->Is()); ASSERT_EQ(result.target->Parameters().Length(), 1u); EXPECT_EQ(result.target->Parameters()[0]->Type(), vec3_ai); } @@ -1008,12 +1008,12 @@ TEST_F(IntrinsicTableTest, MatchTypeConversion_RuntimeEval) { auto* vec3_ai = create(ai, 3u); auto* vec3_f32 = create(create(), 3u); auto* vec3_i32 = create(create(), 3u); - auto result = table->Lookup(InitConvIntrinsic::kVec3, af, utils::Vector{vec3_ai}, + auto result = table->Lookup(CtorConvIntrinsic::kVec3, af, utils::Vector{vec3_ai}, sem::EvaluationStage::kRuntime, Source{{12, 34}}); ASSERT_NE(result.target, nullptr); EXPECT_EQ(result.target->Stage(), sem::EvaluationStage::kConstant); EXPECT_EQ(result.target->ReturnType(), vec3_f32); - EXPECT_TRUE(result.target->Is()); + EXPECT_TRUE(result.target->Is()); ASSERT_EQ(result.target->Parameters().Length(), 1u); EXPECT_EQ(result.target->Parameters()[0]->Type(), vec3_i32); } @@ -1035,7 +1035,7 @@ TEST_F(IntrinsicTableTest, OverloadResolution) { // The first should win overload resolution. auto* ai = create(); auto* i32 = create(); - auto result = table->Lookup(InitConvIntrinsic::kI32, nullptr, utils::Vector{ai}, + auto result = table->Lookup(CtorConvIntrinsic::kI32, nullptr, utils::Vector{ai}, sem::EvaluationStage::kConstant, Source{}); ASSERT_NE(result.target, nullptr); EXPECT_EQ(result.target->ReturnType(), i32); diff --git a/src/tint/resolver/resolver.cc b/src/tint/resolver/resolver.cc index 27f1881743..7471466cdd 100644 --- a/src/tint/resolver/resolver.cc +++ b/src/tint/resolver/resolver.cc @@ -60,9 +60,9 @@ #include "src/tint/sem/statement.h" #include "src/tint/sem/struct.h" #include "src/tint/sem/switch_statement.h" -#include "src/tint/sem/type_conversion.h" #include "src/tint/sem/type_expression.h" -#include "src/tint/sem/type_initializer.h" +#include "src/tint/sem/value_constructor.h" +#include "src/tint/sem/value_conversion.h" #include "src/tint/sem/variable.h" #include "src/tint/sem/while_statement.h" #include "src/tint/type/abstract_float.h" @@ -1939,8 +1939,8 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) { // A CallExpression can resolve to one of: // * A function call. // * A builtin call. - // * A type initializer. - // * A type conversion. + // * A value constructor. + // * A value conversion. auto* target = expr->target; Mark(target); @@ -1967,42 +1967,41 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) { bool has_side_effects = std::any_of(args.begin(), args.end(), [](auto* e) { return e->HasSideEffects(); }); - // init_or_conv is a helper for building either a sem::TypeInitializer or - // sem::TypeConversion call for a InitConvIntrinsic with an optional template argument type. - auto init_or_conv = [&](InitConvIntrinsic ty, const type::Type* template_arg) -> sem::Call* { + // ctor_or_conv is a helper for building either a sem::ValueConstructor or + // sem::ValueConversion call for a CtorConvIntrinsic with an optional template argument type. + auto ctor_or_conv = [&](CtorConvIntrinsic ty, const type::Type* template_arg) -> sem::Call* { auto arg_tys = utils::Transform(args, [](auto* arg) { return arg->Type(); }); - auto ctor_or_conv = - intrinsic_table_->Lookup(ty, template_arg, arg_tys, args_stage, expr->source); - if (!ctor_or_conv.target) { + auto entry = intrinsic_table_->Lookup(ty, template_arg, arg_tys, args_stage, expr->source); + if (!entry.target) { return nullptr; } - if (!MaybeMaterializeAndLoadArguments(args, ctor_or_conv.target)) { + if (!MaybeMaterializeAndLoadArguments(args, entry.target)) { return nullptr; } const constant::Value* value = nullptr; - auto stage = sem::EarliestStage(ctor_or_conv.target->Stage(), args_stage); + auto stage = sem::EarliestStage(entry.target->Stage(), args_stage); if (stage == sem::EvaluationStage::kConstant && skip_const_eval_.Contains(expr)) { stage = sem::EvaluationStage::kNotEvaluated; } if (stage == sem::EvaluationStage::kConstant) { - auto const_args = ConvertArguments(args, ctor_or_conv.target); + auto const_args = ConvertArguments(args, entry.target); if (!const_args) { return nullptr; } - if (auto r = (const_eval_.*ctor_or_conv.const_eval_fn)( - ctor_or_conv.target->ReturnType(), const_args.Get(), expr->source)) { + if (auto r = (const_eval_.*entry.const_eval_fn)(entry.target->ReturnType(), + const_args.Get(), expr->source)) { value = r.Get(); } else { return nullptr; } } - return builder_->create(expr, ctor_or_conv.target, stage, std::move(args), + return builder_->create(expr, entry.target, stage, std::move(args), current_statement_, value, has_side_effects); }; - // arr_or_str_init is a helper for building a sem::TypeInitializer for an array or structure - // initializer call target. + // arr_or_str_init is a helper for building a sem::ValueConstructor for an array or structure + // constructor call target. auto arr_or_str_init = [&](const type::Type* ty, const sem::CallTarget* call_target) -> sem::Call* { if (!MaybeMaterializeAndLoadArguments(args, call_target)) { @@ -2012,7 +2011,7 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) { auto stage = args_stage; // The evaluation stage of the call const constant::Value* value = nullptr; // The constant value for the call if (stage == sem::EvaluationStage::kConstant) { - if (auto r = const_eval_.ArrayOrStructInit(ty, args)) { + if (auto r = const_eval_.ArrayOrStructCtor(ty, args)) { value = r.Get(); } else { return nullptr; @@ -2021,7 +2020,7 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) { // Constant evaluation failed. // Can happen for expressions that will fail validation (later). // Use the kRuntime EvaluationStage, as kConstant will trigger an assertion in - // the sem::ValueExpression initializer, which checks that kConstant is paired + // the sem::ValueExpression constructor, which checks that kConstant is paired // with a constant value. stage = sem::EvaluationStage::kRuntime; } @@ -2034,25 +2033,25 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) { auto ty_init_or_conv = [&](const type::Type* type) { return Switch( type, // - [&](const type::I32*) { return init_or_conv(InitConvIntrinsic::kI32, nullptr); }, - [&](const type::U32*) { return init_or_conv(InitConvIntrinsic::kU32, nullptr); }, + [&](const type::I32*) { return ctor_or_conv(CtorConvIntrinsic::kI32, nullptr); }, + [&](const type::U32*) { return ctor_or_conv(CtorConvIntrinsic::kU32, nullptr); }, [&](const type::F16*) { return validator_.CheckF16Enabled(expr->source) - ? init_or_conv(InitConvIntrinsic::kF16, nullptr) + ? ctor_or_conv(CtorConvIntrinsic::kF16, nullptr) : nullptr; }, - [&](const type::F32*) { return init_or_conv(InitConvIntrinsic::kF32, nullptr); }, - [&](const type::Bool*) { return init_or_conv(InitConvIntrinsic::kBool, nullptr); }, + [&](const type::F32*) { return ctor_or_conv(CtorConvIntrinsic::kF32, nullptr); }, + [&](const type::Bool*) { return ctor_or_conv(CtorConvIntrinsic::kBool, nullptr); }, [&](const type::Vector* v) { - return init_or_conv(VectorInitConvIntrinsic(v->Width()), v->type()); + return ctor_or_conv(VectorCtorConvIntrinsic(v->Width()), v->type()); }, [&](const type::Matrix* m) { - return init_or_conv(MatrixInitConvIntrinsic(m->columns(), m->rows()), m->type()); + return ctor_or_conv(MatrixCtorConvIntrinsic(m->columns(), m->rows()), m->type()); }, [&](const type::Array* arr) -> sem::Call* { - auto* call_target = array_inits_.GetOrCreate( - ArrayInitializerSig{{arr, args.Length(), args_stage}}, - [&]() -> sem::TypeInitializer* { + auto* call_target = array_ctors_.GetOrCreate( + ArrayConstructorSig{{arr, args.Length(), args_stage}}, + [&]() -> sem::ValueConstructor* { auto params = utils::Transform(args, [&](auto, size_t i) { return builder_->create( nullptr, // declaration @@ -2061,8 +2060,8 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) { builtin::AddressSpace::kUndefined, // address_space builtin::Access::kUndefined); }); - return builder_->create(arr, std::move(params), - args_stage); + return builder_->create(arr, std::move(params), + args_stage); }); auto* call = arr_or_str_init(arr, call_target); @@ -2071,15 +2070,15 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) { } // Validation must occur after argument materialization in arr_or_str_init(). - if (!validator_.ArrayInitializer(expr, arr)) { + if (!validator_.ArrayConstructor(expr, arr)) { return nullptr; } return call; }, [&](const sem::Struct* str) -> sem::Call* { - auto* call_target = struct_inits_.GetOrCreate( - StructInitializerSig{{str, args.Length(), args_stage}}, - [&]() -> sem::TypeInitializer* { + auto* call_target = struct_ctors_.GetOrCreate( + StructConstructorSig{{str, args.Length(), args_stage}}, + [&]() -> sem::ValueConstructor* { utils::Vector params; params.Resize(std::min(args.Length(), str->Members().Length())); for (size_t i = 0, n = params.Length(); i < n; i++) { @@ -2090,8 +2089,8 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) { builtin::AddressSpace::kUndefined, // address_space builtin::Access::kUndefined); // access } - return builder_->create(str, std::move(params), - args_stage); + return builder_->create(str, std::move(params), + args_stage); }); auto* call = arr_or_str_init(str, call_target); @@ -2117,7 +2116,7 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) { auto arg_tys = utils::Transform(args, [](auto* arg) { return arg->Type()->UnwrapRef(); }); auto el_ty = type::Type::Common(arg_tys); if (!el_ty) { - AddError("cannot infer common array element type from initializer arguments", + AddError("cannot infer common array element type from constructor arguments", expr->source); utils::Hashset types; for (size_t i = 0; i < args.Length(); i++) { @@ -2172,29 +2171,29 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) { case builtin::Builtin::kArray: return inferred_array(); case builtin::Builtin::kVec2: - return init_or_conv(InitConvIntrinsic::kVec2, nullptr); + return ctor_or_conv(CtorConvIntrinsic::kVec2, nullptr); case builtin::Builtin::kVec3: - return init_or_conv(InitConvIntrinsic::kVec3, nullptr); + return ctor_or_conv(CtorConvIntrinsic::kVec3, nullptr); case builtin::Builtin::kVec4: - return init_or_conv(InitConvIntrinsic::kVec4, nullptr); + return ctor_or_conv(CtorConvIntrinsic::kVec4, nullptr); case builtin::Builtin::kMat2X2: - return init_or_conv(InitConvIntrinsic::kMat2x2, nullptr); + return ctor_or_conv(CtorConvIntrinsic::kMat2x2, nullptr); case builtin::Builtin::kMat2X3: - return init_or_conv(InitConvIntrinsic::kMat2x3, nullptr); + return ctor_or_conv(CtorConvIntrinsic::kMat2x3, nullptr); case builtin::Builtin::kMat2X4: - return init_or_conv(InitConvIntrinsic::kMat2x4, nullptr); + return ctor_or_conv(CtorConvIntrinsic::kMat2x4, nullptr); case builtin::Builtin::kMat3X2: - return init_or_conv(InitConvIntrinsic::kMat3x2, nullptr); + return ctor_or_conv(CtorConvIntrinsic::kMat3x2, nullptr); case builtin::Builtin::kMat3X3: - return init_or_conv(InitConvIntrinsic::kMat3x3, nullptr); + return ctor_or_conv(CtorConvIntrinsic::kMat3x3, nullptr); case builtin::Builtin::kMat3X4: - return init_or_conv(InitConvIntrinsic::kMat3x4, nullptr); + return ctor_or_conv(CtorConvIntrinsic::kMat3x4, nullptr); case builtin::Builtin::kMat4X2: - return init_or_conv(InitConvIntrinsic::kMat4x2, nullptr); + return ctor_or_conv(CtorConvIntrinsic::kMat4x2, nullptr); case builtin::Builtin::kMat4X3: - return init_or_conv(InitConvIntrinsic::kMat4x3, nullptr); + return ctor_or_conv(CtorConvIntrinsic::kMat4x3, nullptr); case builtin::Builtin::kMat4X4: - return init_or_conv(InitConvIntrinsic::kMat4x4, nullptr); + return ctor_or_conv(CtorConvIntrinsic::kMat4x4, nullptr); default: break; } @@ -2219,7 +2218,7 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) { return nullptr; } - if (call->Target()->IsAnyOf()) { + if (call->Target()->IsAnyOf()) { // The target of the call was a type. // Associate the target identifier expression with the resolved type. auto* ty_expr = diff --git a/src/tint/resolver/resolver.h b/src/tint/resolver/resolver.h index c29a416aca..72f9e8fd76 100644 --- a/src/tint/resolver/resolver.h +++ b/src/tint/resolver/resolver.h @@ -67,7 +67,6 @@ class LoopStatement; class Statement; class StructMember; class SwitchStatement; -class TypeInitializer; class WhileStatement; } // namespace tint::sem namespace tint::type { @@ -497,15 +496,15 @@ class Resolver { /// @note: Will raise an ICE if @p symbol is not a builtin type. type::Type* BuiltinType(builtin::Builtin builtin_ty, const ast::Identifier* ident); - // ArrayInitializerSig represents a unique array initializer signature. + // ArrayConstructorSig represents a unique array constructor signature. // It is a tuple of the array type, number of arguments provided and earliest evaluation stage. - using ArrayInitializerSig = + using ArrayConstructorSig = utils::UnorderedKeyWrapper>; - // StructInitializerSig represents a unique structure initializer signature. + // StructConstructorSig represents a unique structure constructor signature. // It is a tuple of the structure type, number of arguments provided and earliest evaluation // stage. - using StructInitializerSig = + using StructConstructorSig = utils::UnorderedKeyWrapper>; /// ExprEvalStageConstraint describes a constraint on when expressions can be evaluated. @@ -555,8 +554,8 @@ class Resolver { ExprEvalStageConstraint expr_eval_stage_constraint_; std::unordered_map alias_analysis_infos_; utils::Hashmap override_ids_; - utils::Hashmap array_inits_; - utils::Hashmap struct_inits_; + utils::Hashmap array_ctors_; + utils::Hashmap struct_ctors_; sem::Function* current_function_ = nullptr; sem::Statement* current_statement_ = nullptr; sem::CompoundStatement* current_compound_statement_ = nullptr; diff --git a/src/tint/resolver/sem_helper.cc b/src/tint/resolver/sem_helper.cc index 0a9bc1bd1e..d11d790cf7 100644 --- a/src/tint/resolver/sem_helper.cc +++ b/src/tint/resolver/sem_helper.cc @@ -114,7 +114,7 @@ void SemHelper::ErrorExpectedValueExpr(const sem::Expression* expr) const { ErrorUnexpectedExprKind(expr, "value"); if (auto* ty_expr = expr->As()) { if (auto* ident = ty_expr->Declaration()->As()) { - AddNote("are you missing '()' for type initializer?", + AddNote("are you missing '()' for value constructor?", Source{{ident->source.range.end}}); } if (auto* str = ty_expr->Type()->As()) { diff --git a/src/tint/resolver/uniformity.cc b/src/tint/resolver/uniformity.cc index d02be8dc0b..37fba4ce23 100644 --- a/src/tint/resolver/uniformity.cc +++ b/src/tint/resolver/uniformity.cc @@ -34,8 +34,8 @@ #include "src/tint/sem/loop_statement.h" #include "src/tint/sem/statement.h" #include "src/tint/sem/switch_statement.h" -#include "src/tint/sem/type_conversion.h" -#include "src/tint/sem/type_initializer.h" +#include "src/tint/sem/value_constructor.h" +#include "src/tint/sem/value_conversion.h" #include "src/tint/sem/variable.h" #include "src/tint/sem/while_statement.h" #include "src/tint/utils/block_allocator.h" @@ -1541,11 +1541,11 @@ class UniformityGraph { function_tag = info->function_tag; func_info = info; }, - [&](const sem::TypeInitializer*) { + [&](const sem::ValueConstructor*) { callsite_tag = {CallSiteTag::CallSiteNoRestriction}; function_tag = NoRestriction; }, - [&](const sem::TypeConversion*) { + [&](const sem::ValueConversion*) { callsite_tag = {CallSiteTag::CallSiteNoRestriction}; function_tag = NoRestriction; }, @@ -1631,7 +1631,7 @@ class UniformityGraph { current_function_->RequiredToBeUniform(default_severity)->AddEdge(args[i]); } else { // All other builtin function parameters are RequiredToBeUniformForReturnValue, - // as are parameters for type initializers and type conversions. + // as are parameters for value constructors and value conversions. result->AddEdge(args[i]); } } diff --git a/src/tint/resolver/validator.cc b/src/tint/resolver/validator.cc index cedd5bf03d..4875022adc 100644 --- a/src/tint/resolver/validator.cc +++ b/src/tint/resolver/validator.cc @@ -49,8 +49,8 @@ #include "src/tint/sem/statement.h" #include "src/tint/sem/struct.h" #include "src/tint/sem/switch_statement.h" -#include "src/tint/sem/type_conversion.h" -#include "src/tint/sem/type_initializer.h" +#include "src/tint/sem/value_constructor.h" +#include "src/tint/sem/value_conversion.h" #include "src/tint/sem/variable.h" #include "src/tint/sem/while_statement.h" #include "src/tint/type/abstract_numeric.h" @@ -1507,11 +1507,11 @@ bool Validator::Call(const sem::Call* call, sem::Statement* current_statement) c AddError("ignoring return value of builtin '" + utils::ToString(b->Type()) + "'", call->Declaration()->source); }, - [&](const sem::TypeConversion*) { - AddError("type conversion evaluated but not used", call->Declaration()->source); + [&](const sem::ValueConversion*) { + AddError("value conversion evaluated but not used", call->Declaration()->source); }, - [&](const sem::TypeInitializer*) { - AddError("type initializer evaluated but not used", call->Declaration()->source); + [&](const sem::ValueConstructor*) { + AddError("value constructor evaluated but not used", call->Declaration()->source); }, [&](Default) { AddError("return value of call not used", call->Declaration()->source); @@ -1825,14 +1825,14 @@ bool Validator::FunctionCall(const sem::Call* call, sem::Statement* current_stat bool Validator::StructureInitializer(const ast::CallExpression* ctor, const sem::Struct* struct_type) const { if (!struct_type->IsConstructible()) { - AddError("struct initializer has non-constructible type", ctor->source); + AddError("structure constructor has non-constructible type", ctor->source); return false; } if (ctor->args.Length() > 0) { if (ctor->args.Length() != struct_type->Members().Length()) { std::string fm = ctor->args.Length() < struct_type->Members().Length() ? "few" : "many"; - AddError("struct initializer has too " + fm + " inputs: expected " + + AddError("structure constructor has too " + fm + " inputs: expected " + std::to_string(struct_type->Members().Length()) + ", found " + std::to_string(ctor->args.Length()), ctor->source); @@ -1843,7 +1843,7 @@ bool Validator::StructureInitializer(const ast::CallExpression* ctor, auto* value_ty = sem_.TypeOf(value); if (member->Type() != value_ty->UnwrapRef()) { AddError( - "type in struct initializer does not match struct member type: expected '" + + "type in structure constructor does not match struct member type: expected '" + sem_.TypeNameOf(member->Type()) + "', found '" + sem_.TypeNameOf(value_ty) + "'", value->source); @@ -1854,7 +1854,7 @@ bool Validator::StructureInitializer(const ast::CallExpression* ctor, return true; } -bool Validator::ArrayInitializer(const ast::CallExpression* ctor, +bool Validator::ArrayConstructor(const ast::CallExpression* ctor, const type::Array* array_type) const { auto& values = ctor->args; auto* elem_ty = array_type->ElemType(); @@ -1881,7 +1881,7 @@ bool Validator::ArrayInitializer(const ast::CallExpression* ctor, } if (!elem_ty->IsConstructible()) { - AddError("array initializer has non-constructible element type", ctor->source); + AddError("array constructor has non-constructible element type", ctor->source); return false; } @@ -1893,7 +1893,7 @@ bool Validator::ArrayInitializer(const ast::CallExpression* ctor, const auto count = c->As()->value; if (!values.IsEmpty() && (values.Length() != count)) { std::string fm = values.Length() < count ? "few" : "many"; - AddError("array initializer has too " + fm + " elements: expected " + + AddError("array constructor has too " + fm + " elements: expected " + std::to_string(count) + ", found " + std::to_string(values.Length()), ctor->source); return false; diff --git a/src/tint/resolver/validator.h b/src/tint/resolver/validator.h index 3128ae1cee..45c98c8618 100644 --- a/src/tint/resolver/validator.h +++ b/src/tint/resolver/validator.h @@ -61,7 +61,6 @@ class LoopStatement; class Materialize; class Statement; class SwitchStatement; -class TypeInitializer; class WhileStatement; } // namespace tint::sem namespace tint::type { @@ -445,11 +444,11 @@ class Validator { /// @returns true on success, false otherwise bool Vector(const type::Type* el_ty, const Source& source) const; - /// Validates an array initializer + /// Validates an array constructor /// @param ctor the call expresion to validate /// @param arr_type the type of the array /// @returns true on success, false otherwise - bool ArrayInitializer(const ast::CallExpression* ctor, const type::Array* arr_type) const; + bool ArrayConstructor(const ast::CallExpression* ctor, const type::Array* arr_type) const; /// Validates a texture builtin function /// @param call the builtin call to validate diff --git a/src/tint/resolver/type_initializer_validation_test.cc b/src/tint/resolver/value_constructor_validation_test.cc similarity index 81% rename from src/tint/resolver/type_initializer_validation_test.cc rename to src/tint/resolver/value_constructor_validation_test.cc index 10d6ae4f90..8ab1cab6e6 100644 --- a/src/tint/resolver/type_initializer_validation_test.cc +++ b/src/tint/resolver/value_constructor_validation_test.cc @@ -14,8 +14,8 @@ #include "gmock/gmock.h" #include "src/tint/resolver/resolver_test_helper.h" -#include "src/tint/sem/type_conversion.h" -#include "src/tint/sem/type_initializer.h" +#include "src/tint/sem/value_constructor.h" +#include "src/tint/sem/value_conversion.h" #include "src/tint/type/reference.h" using namespace tint::number_suffixes; // NOLINT @@ -42,7 +42,7 @@ using builder::vec2; using builder::vec3; using builder::vec4; -class ResolverTypeInitializerValidationTest : public resolver::TestHelper, public testing::Test {}; +class ResolverValueConstructorValidationTest : public resolver::TestHelper, public testing::Test {}; namespace InferTypeTest { struct Params { @@ -56,7 +56,7 @@ constexpr Params ParamsFor() { return Params{DataType::AST, DataType::ExprFromDouble, DataType::Sem}; } -TEST_F(ResolverTypeInitializerValidationTest, InferTypeTest_Simple) { +TEST_F(ResolverValueConstructorValidationTest, InferTypeTest_Simple) { // var a = 1i; // var b = a; auto* a = Var("a", Expr(1_i)); @@ -77,8 +77,8 @@ TEST_F(ResolverTypeInitializerValidationTest, InferTypeTest_Simple) { builtin::AddressSpace::kFunction); } -using InferTypeTest_FromInitializerExpression = ResolverTestWithParam; -TEST_P(InferTypeTest_FromInitializerExpression, All) { +using InferTypeTest_FromConstructorExpression = ResolverTestWithParam; +TEST_P(InferTypeTest_FromConstructorExpression, All) { // e.g. for vec3 // { // var a = vec3(0.0, 0.0, 0.0) @@ -104,7 +104,7 @@ TEST_P(InferTypeTest_FromInitializerExpression, All) { << "expected: " << FriendlyName(expected) << "\n"; } -static constexpr Params from_initializer_expression_cases[] = { +static constexpr Params from_constructor_expression_cases[] = { ParamsFor(), ParamsFor(), ParamsFor(), @@ -128,9 +128,9 @@ static constexpr Params from_initializer_expression_cases[] = { ParamsFor>>(), ParamsFor>>(), }; -INSTANTIATE_TEST_SUITE_P(ResolverTypeInitializerValidationTest, - InferTypeTest_FromInitializerExpression, - testing::ValuesIn(from_initializer_expression_cases)); +INSTANTIATE_TEST_SUITE_P(ResolverValueConstructorValidationTest, + InferTypeTest_FromConstructorExpression, + testing::ValuesIn(from_constructor_expression_cases)); using InferTypeTest_FromArithmeticExpression = ResolverTestWithParam; TEST_P(InferTypeTest_FromArithmeticExpression, All) { @@ -170,7 +170,7 @@ static constexpr Params from_arithmetic_expression_cases[] = { ParamsFor>>(), ParamsFor>>(), }; -INSTANTIATE_TEST_SUITE_P(ResolverTypeInitializerValidationTest, +INSTANTIATE_TEST_SUITE_P(ResolverValueConstructorValidationTest, InferTypeTest_FromArithmeticExpression, testing::ValuesIn(from_arithmetic_expression_cases)); @@ -231,7 +231,7 @@ static constexpr Params from_call_expression_cases[] = { ParamsFor>>(), ParamsFor>>(), }; -INSTANTIATE_TEST_SUITE_P(ResolverTypeInitializerValidationTest, +INSTANTIATE_TEST_SUITE_P(ResolverValueConstructorValidationTest, InferTypeTest_FromCallExpression, testing::ValuesIn(from_call_expression_cases)); @@ -342,8 +342,8 @@ static constexpr Params valid_cases[] = { ParamsFor, mat3x2>(Kind::Conversion), // }; -using ConversionInitializerValidTest = ResolverTestWithParam; -TEST_P(ConversionInitializerValidTest, All) { +using ConversionConstructorValidTest = ResolverTestWithParam; +TEST_P(ConversionConstructorValidTest, All) { auto& params = GetParam(); Enable(builtin::Extension::kF16); @@ -374,7 +374,7 @@ TEST_P(ConversionInitializerValidTest, All) { ASSERT_NE(call, nullptr); switch (params.kind) { case Kind::Construct: { - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 1u); @@ -382,7 +382,7 @@ TEST_P(ConversionInitializerValidTest, All) { break; } case Kind::Conversion: { - auto* conv = call->Target()->As(); + auto* conv = call->Target()->As(); ASSERT_NE(conv, nullptr); EXPECT_EQ(call->Type(), conv->ReturnType()); ASSERT_EQ(conv->Parameters().Length(), 1u); @@ -391,8 +391,8 @@ TEST_P(ConversionInitializerValidTest, All) { } } } -INSTANTIATE_TEST_SUITE_P(ResolverTypeInitializerValidationTest, - ConversionInitializerValidTest, +INSTANTIATE_TEST_SUITE_P(ResolverValueConstructorValidationTest, + ConversionConstructorValidTest, testing::ValuesIn(valid_cases)); constexpr CreatePtrs all_types[] = { @@ -420,10 +420,10 @@ constexpr CreatePtrs all_types[] = { CreatePtrsFor>(), // }; -using ConversionInitializerInvalidTest = ResolverTestWithParam>; -TEST_P(ConversionInitializerInvalidTest, All) { +TEST_P(ConversionConstructorInvalidTest, All) { auto& params = GetParam(); auto& lhs_params = std::get<0>(params); @@ -463,33 +463,33 @@ TEST_P(ConversionInitializerInvalidTest, All) { ASSERT_FALSE(r()->Resolve()); } -INSTANTIATE_TEST_SUITE_P(ResolverTypeInitializerValidationTest, - ConversionInitializerInvalidTest, +INSTANTIATE_TEST_SUITE_P(ResolverValueConstructorValidationTest, + ConversionConstructorInvalidTest, testing::Combine(testing::ValuesIn(all_types), testing::ValuesIn(all_types))); -TEST_F(ResolverTypeInitializerValidationTest, ConversionInitializerInvalid_TooManyInitializers) { +TEST_F(ResolverValueConstructorValidationTest, ConversionConstructorInvalid_TooManyConstructors) { auto* a = Var("a", ty.f32(), Call(Source{{12, 34}}, ty.f32(), Expr(1_f), Expr(2_f))); WrapInFunction(a); ASSERT_FALSE(r()->Resolve()); - EXPECT_THAT(r()->error(), HasSubstr("12:34 error: no matching initializer for f32(f32, f32)")); + EXPECT_THAT(r()->error(), HasSubstr("12:34 error: no matching constructor for f32(f32, f32)")); } -TEST_F(ResolverTypeInitializerValidationTest, ConversionInitializerInvalid_InvalidInitializer) { +TEST_F(ResolverValueConstructorValidationTest, ConversionConstructorInvalid_InvalidConstructor) { auto* a = Var("a", ty.f32(), Call(Source{{12, 34}}, ty.f32(), Call(ty.array()))); WrapInFunction(a); ASSERT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("12:34 error: no matching initializer for f32(array)")); + HasSubstr("12:34 error: no matching constructor for f32(array)")); } } // namespace ConversionConstructTest -namespace ArrayInitializer { +namespace ArrayConstructor { -TEST_F(ResolverTypeInitializerValidationTest, Array_ZeroValue_Pass) { +TEST_F(ResolverValueConstructorValidationTest, Array_ZeroValue_Pass) { // array(); auto* tc = array(); WrapInFunction(tc); @@ -499,13 +499,13 @@ TEST_F(ResolverTypeInitializerValidationTest, Array_ZeroValue_Pass) { auto* call = Sem().Get(tc); ASSERT_NE(call, nullptr); EXPECT_TRUE(call->Type()->Is()); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 0u); } -TEST_F(ResolverTypeInitializerValidationTest, Array_U32U32U32) { +TEST_F(ResolverValueConstructorValidationTest, Array_U32U32U32) { // array(0u, 10u, 20u); auto* tc = array(0_u, 10_u, 20_u); WrapInFunction(tc); @@ -515,7 +515,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Array_U32U32U32) { auto* call = Sem().Get(tc); ASSERT_NE(call, nullptr); EXPECT_TRUE(call->Type()->Is()); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 3u); @@ -524,7 +524,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Array_U32U32U32) { EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); } -TEST_F(ResolverTypeInitializerValidationTest, InferredArray_U32U32U32) { +TEST_F(ResolverValueConstructorValidationTest, InferredArray_U32U32U32) { // array(0u, 10u, 20u); auto* tc = array(Source{{12, 34}}, 0_u, 10_u, 20_u); WrapInFunction(tc); @@ -534,7 +534,7 @@ TEST_F(ResolverTypeInitializerValidationTest, InferredArray_U32U32U32) { auto* call = Sem().Get(tc); ASSERT_NE(call, nullptr); EXPECT_TRUE(call->Type()->Is()); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 3u); @@ -543,7 +543,7 @@ TEST_F(ResolverTypeInitializerValidationTest, InferredArray_U32U32U32) { EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); } -TEST_F(ResolverTypeInitializerValidationTest, Array_U32AIU32) { +TEST_F(ResolverValueConstructorValidationTest, Array_U32AIU32) { // array(0u, 10, 20u); auto* tc = array(0_u, 10_a, 20_u); WrapInFunction(tc); @@ -553,7 +553,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Array_U32AIU32) { auto* call = Sem().Get(tc); ASSERT_NE(call, nullptr); EXPECT_TRUE(call->Type()->Is()); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 3u); @@ -562,7 +562,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Array_U32AIU32) { EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); } -TEST_F(ResolverTypeInitializerValidationTest, InferredArray_U32AIU32) { +TEST_F(ResolverValueConstructorValidationTest, InferredArray_U32AIU32) { // array(0u, 10u, 20u); auto* tc = array(Source{{12, 34}}, 0_u, 10_a, 20_u); WrapInFunction(tc); @@ -572,7 +572,7 @@ TEST_F(ResolverTypeInitializerValidationTest, InferredArray_U32AIU32) { auto* call = Sem().Get(tc); ASSERT_NE(call, nullptr); EXPECT_TRUE(call->Type()->Is()); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 3u); @@ -581,7 +581,7 @@ TEST_F(ResolverTypeInitializerValidationTest, InferredArray_U32AIU32) { EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); } -TEST_F(ResolverTypeInitializerValidationTest, ArrayU32_AIAIAI) { +TEST_F(ResolverValueConstructorValidationTest, ArrayU32_AIAIAI) { // array(0, 10, 20); auto* tc = array(0_a, 10_a, 20_a); WrapInFunction(tc); @@ -591,7 +591,7 @@ TEST_F(ResolverTypeInitializerValidationTest, ArrayU32_AIAIAI) { auto* call = Sem().Get(tc); ASSERT_NE(call, nullptr); EXPECT_TRUE(call->Type()->Is()); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 3u); @@ -600,7 +600,7 @@ TEST_F(ResolverTypeInitializerValidationTest, ArrayU32_AIAIAI) { EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); } -TEST_F(ResolverTypeInitializerValidationTest, InferredArray_AIAIAI) { +TEST_F(ResolverValueConstructorValidationTest, InferredArray_AIAIAI) { // const c = array(0, 10, 20); auto* tc = array(Source{{12, 34}}, 0_a, 10_a, 20_a); WrapInFunction(Decl(Const("C", tc))); @@ -610,7 +610,7 @@ TEST_F(ResolverTypeInitializerValidationTest, InferredArray_AIAIAI) { auto* call = Sem().Get(tc); ASSERT_NE(call, nullptr); EXPECT_TRUE(call->Type()->Is()); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 3u); @@ -619,7 +619,7 @@ TEST_F(ResolverTypeInitializerValidationTest, InferredArray_AIAIAI) { EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); } -TEST_F(ResolverTypeInitializerValidationTest, InferredArrayU32_VecI32_VecAI) { +TEST_F(ResolverValueConstructorValidationTest, InferredArrayU32_VecI32_VecAI) { // array(vec2(10i), vec2(20)); auto* tc = array(Source{{12, 34}}, // Call(ty.vec(2), 20_i), // @@ -631,7 +631,7 @@ TEST_F(ResolverTypeInitializerValidationTest, InferredArrayU32_VecI32_VecAI) { auto* call = Sem().Get(tc); ASSERT_NE(call, nullptr); EXPECT_TRUE(call->Type()->Is()); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 2u); @@ -641,7 +641,7 @@ TEST_F(ResolverTypeInitializerValidationTest, InferredArrayU32_VecI32_VecAI) { EXPECT_TRUE(ctor->Parameters()[1]->Type()->As()->type()->Is()); } -TEST_F(ResolverTypeInitializerValidationTest, InferredArrayU32_VecAI_VecF32) { +TEST_F(ResolverValueConstructorValidationTest, InferredArrayU32_VecAI_VecF32) { // array(vec2(20), vec2(10f)); auto* tc = array(Source{{12, 34}}, // Call(ty.vec(2), 20_a), // @@ -653,7 +653,7 @@ TEST_F(ResolverTypeInitializerValidationTest, InferredArrayU32_VecAI_VecF32) { auto* call = Sem().Get(tc); ASSERT_NE(call, nullptr); EXPECT_TRUE(call->Type()->Is()); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 2u); @@ -663,7 +663,7 @@ TEST_F(ResolverTypeInitializerValidationTest, InferredArrayU32_VecAI_VecF32) { EXPECT_TRUE(ctor->Parameters()[1]->Type()->As()->type()->Is()); } -TEST_F(ResolverTypeInitializerValidationTest, ArrayArgumentTypeMismatch_U32F32) { +TEST_F(ResolverValueConstructorValidationTest, ArrayArgumentTypeMismatch_U32F32) { // array(0u, 1.0f, 20u); auto* tc = array(0_u, Expr(Source{{12, 34}}, 1_f), 20_u); WrapInFunction(tc); @@ -672,19 +672,19 @@ TEST_F(ResolverTypeInitializerValidationTest, ArrayArgumentTypeMismatch_U32F32) EXPECT_EQ(r()->error(), R"(12:34 error: 'f32' cannot be used to construct an array of 'u32')"); } -TEST_F(ResolverTypeInitializerValidationTest, InferredArrayArgumentTypeMismatch_U32F32) { +TEST_F(ResolverValueConstructorValidationTest, InferredArrayArgumentTypeMismatch_U32F32) { // array(0u, 1.0f, 20u); auto* tc = array(Source{{12, 34}}, 0_u, 1_f, 20_u); WrapInFunction(tc); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), - R"(12:34 error: cannot infer common array element type from initializer arguments + R"(12:34 error: cannot infer common array element type from constructor arguments note: argument 0 is of type 'u32' note: argument 1 is of type 'f32')"); } -TEST_F(ResolverTypeInitializerValidationTest, ArrayArgumentTypeMismatch_F32I32) { +TEST_F(ResolverValueConstructorValidationTest, ArrayArgumentTypeMismatch_F32I32) { // array(1i); auto* tc = array(Expr(Source{{12, 34}}, 1_i)); WrapInFunction(tc); @@ -693,19 +693,19 @@ TEST_F(ResolverTypeInitializerValidationTest, ArrayArgumentTypeMismatch_F32I32) EXPECT_EQ(r()->error(), R"(12:34 error: 'i32' cannot be used to construct an array of 'f32')"); } -TEST_F(ResolverTypeInitializerValidationTest, InferredArrayArgumentTypeMismatch_F32I32) { +TEST_F(ResolverValueConstructorValidationTest, InferredArrayArgumentTypeMismatch_F32I32) { // array(1f, 1i); auto* tc = array(Source{{12, 34}}, 1_f, 1_i); WrapInFunction(tc); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), - R"(12:34 error: cannot infer common array element type from initializer arguments + R"(12:34 error: cannot infer common array element type from constructor arguments note: argument 0 is of type 'f32' note: argument 1 is of type 'i32')"); } -TEST_F(ResolverTypeInitializerValidationTest, ArrayArgumentTypeMismatch_U32I32) { +TEST_F(ResolverValueConstructorValidationTest, ArrayArgumentTypeMismatch_U32I32) { // array(1i, 0u, 0u, 0u, 0u, 0u); auto* tc = array(Expr(Source{{12, 34}}, 1_i), 0_u, 0_u, 0_u, 0_u); WrapInFunction(tc); @@ -714,19 +714,19 @@ TEST_F(ResolverTypeInitializerValidationTest, ArrayArgumentTypeMismatch_U32I32) EXPECT_EQ(r()->error(), R"(12:34 error: 'i32' cannot be used to construct an array of 'u32')"); } -TEST_F(ResolverTypeInitializerValidationTest, InferredArrayArgumentTypeMismatch_U32I32) { +TEST_F(ResolverValueConstructorValidationTest, InferredArrayArgumentTypeMismatch_U32I32) { // array(1i, 0u, 0u, 0u, 0u, 0u); auto* tc = array(Source{{12, 34}}, 1_i, 0_u, 0_u, 0_u, 0_u); WrapInFunction(tc); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), - R"(12:34 error: cannot infer common array element type from initializer arguments + R"(12:34 error: cannot infer common array element type from constructor arguments note: argument 0 is of type 'i32' note: argument 1 is of type 'u32')"); } -TEST_F(ResolverTypeInitializerValidationTest, ArrayArgumentTypeMismatch_I32Vec2) { +TEST_F(ResolverValueConstructorValidationTest, ArrayArgumentTypeMismatch_I32Vec2) { // array(1i, vec2()); auto* tc = array(1_i, vec2(Source{{12, 34}})); WrapInFunction(tc); @@ -735,18 +735,18 @@ TEST_F(ResolverTypeInitializerValidationTest, ArrayArgumentTypeMismatch_I32Vec2) R"(12:34 error: 'vec2' cannot be used to construct an array of 'i32')"); } -TEST_F(ResolverTypeInitializerValidationTest, InferredArrayArgumentTypeMismatch_I32Vec2) { +TEST_F(ResolverValueConstructorValidationTest, InferredArrayArgumentTypeMismatch_I32Vec2) { // array(1i, vec2()); auto* tc = array(Source{{12, 34}}, 1_i, vec2()); WrapInFunction(tc); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), - R"(12:34 error: cannot infer common array element type from initializer arguments + R"(12:34 error: cannot infer common array element type from constructor arguments note: argument 0 is of type 'i32' note: argument 1 is of type 'vec2')"); } -TEST_F(ResolverTypeInitializerValidationTest, ArrayArgumentTypeMismatch_Vec3i32_Vec3u32) { +TEST_F(ResolverValueConstructorValidationTest, ArrayArgumentTypeMismatch_Vec3i32_Vec3u32) { // array, 2u>(vec3(), vec3()); auto* t = array(ty.vec3(), 2_u, vec3(Source{{12, 34}}), vec3()); WrapInFunction(t); @@ -756,31 +756,31 @@ TEST_F(ResolverTypeInitializerValidationTest, ArrayArgumentTypeMismatch_Vec3i32_ R"(12:34 error: 'vec3' cannot be used to construct an array of 'vec3')"); } -TEST_F(ResolverTypeInitializerValidationTest, InferredArrayArgumentTypeMismatch_Vec3i32_Vec3u32) { +TEST_F(ResolverValueConstructorValidationTest, InferredArrayArgumentTypeMismatch_Vec3i32_Vec3u32) { // array(vec3(), vec3()); auto* t = array(Source{{12, 34}}, vec3(), vec3()); WrapInFunction(t); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), - R"(12:34 error: cannot infer common array element type from initializer arguments + R"(12:34 error: cannot infer common array element type from constructor arguments note: argument 0 is of type 'vec3' note: argument 1 is of type 'vec3')"); } -TEST_F(ResolverTypeInitializerValidationTest, InferredArrayArgumentTypeMismatch_Vec3i32_Vec3AF) { +TEST_F(ResolverValueConstructorValidationTest, InferredArrayArgumentTypeMismatch_Vec3i32_Vec3AF) { // array(vec3(), vec3(1.0)); auto* t = array(Source{{12, 34}}, vec3(), Call("vec3", 1._a)); WrapInFunction(t); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), - R"(12:34 error: cannot infer common array element type from initializer arguments + R"(12:34 error: cannot infer common array element type from constructor arguments note: argument 0 is of type 'vec3' note: argument 1 is of type 'vec3')"); } -TEST_F(ResolverTypeInitializerValidationTest, ArrayArgumentTypeMismatch_Vec3i32_Vec3bool) { +TEST_F(ResolverValueConstructorValidationTest, ArrayArgumentTypeMismatch_Vec3i32_Vec3bool) { // array, 2u>(vec3(), vec3()); auto* t = array(ty.vec3(), 2_u, vec3(), vec3()); WrapInFunction(t); @@ -790,19 +790,19 @@ TEST_F(ResolverTypeInitializerValidationTest, ArrayArgumentTypeMismatch_Vec3i32_ R"(error: 'vec3' cannot be used to construct an array of 'vec3')"); } -TEST_F(ResolverTypeInitializerValidationTest, InferredArrayArgumentTypeMismatch_Vec3i32_Vec3bool) { +TEST_F(ResolverValueConstructorValidationTest, InferredArrayArgumentTypeMismatch_Vec3i32_Vec3bool) { // array(vec3(), vec3()); auto* t = array(Source{{12, 34}}, vec3(), vec3()); WrapInFunction(t); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), - R"(12:34 error: cannot infer common array element type from initializer arguments + R"(12:34 error: cannot infer common array element type from constructor arguments note: argument 0 is of type 'vec3' note: argument 1 is of type 'vec3')"); } -TEST_F(ResolverTypeInitializerValidationTest, ArrayOfArray_SubElemSizeMismatch) { +TEST_F(ResolverValueConstructorValidationTest, ArrayOfArray_SubElemSizeMismatch) { // array, 2u>(array(), array()); auto* t = array(Source{{12, 34}}, ty.array(), 2_i, array(), array()); WrapInFunction(t); @@ -812,19 +812,19 @@ TEST_F(ResolverTypeInitializerValidationTest, ArrayOfArray_SubElemSizeMismatch) R"(error: 'array' cannot be used to construct an array of 'array')"); } -TEST_F(ResolverTypeInitializerValidationTest, InferredArrayOfArray_SubElemSizeMismatch) { +TEST_F(ResolverValueConstructorValidationTest, InferredArrayOfArray_SubElemSizeMismatch) { // array, 2u>(array(), array()); auto* t = array(Source{{12, 34}}, array(), array()); WrapInFunction(t); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), - R"(12:34 error: cannot infer common array element type from initializer arguments + R"(12:34 error: cannot infer common array element type from constructor arguments note: argument 0 is of type 'array' note: argument 1 is of type 'array')"); } -TEST_F(ResolverTypeInitializerValidationTest, ArrayOfArray_SubElemTypeMismatch) { +TEST_F(ResolverValueConstructorValidationTest, ArrayOfArray_SubElemTypeMismatch) { // array, 2u>(array(), array()); auto* t = array(Source{{12, 34}}, ty.array(), 2_i, array(), array()); WrapInFunction(t); @@ -834,19 +834,19 @@ TEST_F(ResolverTypeInitializerValidationTest, ArrayOfArray_SubElemTypeMismatch) R"(error: 'array' cannot be used to construct an array of 'array')"); } -TEST_F(ResolverTypeInitializerValidationTest, InferredArrayOfArray_SubElemTypeMismatch) { +TEST_F(ResolverValueConstructorValidationTest, InferredArrayOfArray_SubElemTypeMismatch) { // array, 2u>(array(), array()); auto* t = array(Source{{12, 34}}, array(), array()); WrapInFunction(t); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), - R"(12:34 error: cannot infer common array element type from initializer arguments + R"(12:34 error: cannot infer common array element type from constructor arguments note: argument 0 is of type 'array' note: argument 1 is of type 'array')"); } -TEST_F(ResolverTypeInitializerValidationTest, Array_TooFewElements) { +TEST_F(ResolverValueConstructorValidationTest, Array_TooFewElements) { // array(1i, 2i, 3i); SetSource(Source::Location({12, 34})); auto* tc = array(Expr(1_i), Expr(2_i), Expr(3_i)); @@ -854,10 +854,10 @@ TEST_F(ResolverTypeInitializerValidationTest, Array_TooFewElements) { EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), - "12:34 error: array initializer has too few elements: expected 4, found 3"); + "12:34 error: array constructor has too few elements: expected 4, found 3"); } -TEST_F(ResolverTypeInitializerValidationTest, Array_TooManyElements) { +TEST_F(ResolverValueConstructorValidationTest, Array_TooManyElements) { // array(1i, 2i, 3i, 4i, 5i); SetSource(Source::Location({12, 34})); auto* tc = array(Expr(1_i), Expr(2_i), Expr(3_i), Expr(4_i), Expr(5_i)); @@ -865,12 +865,12 @@ TEST_F(ResolverTypeInitializerValidationTest, Array_TooManyElements) { EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), - "12:34 error: array initializer has too many " + "12:34 error: array constructor has too many " "elements: expected 4, " "found 5"); } -TEST_F(ResolverTypeInitializerValidationTest, Array_Runtime) { +TEST_F(ResolverValueConstructorValidationTest, Array_Runtime) { // array(1i); auto* tc = array(Source{{12, 34}}, Expr(1_i)); WrapInFunction(tc); @@ -879,7 +879,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Array_Runtime) { EXPECT_EQ(r()->error(), "12:34 error: cannot construct a runtime-sized array"); } -TEST_F(ResolverTypeInitializerValidationTest, Array_RuntimeZeroValue) { +TEST_F(ResolverValueConstructorValidationTest, Array_RuntimeZeroValue) { // array(); auto* tc = array(Source{{12, 34}}); WrapInFunction(tc); @@ -888,11 +888,11 @@ TEST_F(ResolverTypeInitializerValidationTest, Array_RuntimeZeroValue) { EXPECT_EQ(r()->error(), "12:34 error: cannot construct a runtime-sized array"); } -} // namespace ArrayInitializer +} // namespace ArrayConstructor -namespace ScalarInitializer { +namespace ScalarConstructor { -TEST_F(ResolverTypeInitializerValidationTest, I32_Success) { +TEST_F(ResolverValueConstructorValidationTest, I32_Success) { auto* expr = Call(Expr(123_i)); WrapInFunction(expr); @@ -903,14 +903,14 @@ TEST_F(ResolverTypeInitializerValidationTest, I32_Success) { auto* call = Sem().Get(expr); ASSERT_NE(call, nullptr); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 1u); EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); } -TEST_F(ResolverTypeInitializerValidationTest, U32_Success) { +TEST_F(ResolverValueConstructorValidationTest, U32_Success) { auto* expr = Call(Expr(123_u)); WrapInFunction(expr); @@ -921,14 +921,14 @@ TEST_F(ResolverTypeInitializerValidationTest, U32_Success) { auto* call = Sem().Get(expr); ASSERT_NE(call, nullptr); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 1u); EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); } -TEST_F(ResolverTypeInitializerValidationTest, F32_Success) { +TEST_F(ResolverValueConstructorValidationTest, F32_Success) { auto* expr = Call(Expr(1.23_f)); WrapInFunction(expr); @@ -939,14 +939,14 @@ TEST_F(ResolverTypeInitializerValidationTest, F32_Success) { auto* call = Sem().Get(expr); ASSERT_NE(call, nullptr); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 1u); EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); } -TEST_F(ResolverTypeInitializerValidationTest, F16_Success) { +TEST_F(ResolverValueConstructorValidationTest, F16_Success) { Enable(builtin::Extension::kF16); auto* expr = Call(Expr(1.5_h)); @@ -959,14 +959,14 @@ TEST_F(ResolverTypeInitializerValidationTest, F16_Success) { auto* call = Sem().Get(expr); ASSERT_NE(call, nullptr); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 1u); EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); } -TEST_F(ResolverTypeInitializerValidationTest, Convert_f32_to_i32_Success) { +TEST_F(ResolverValueConstructorValidationTest, Convert_f32_to_i32_Success) { auto* expr = Call(1.23_f); WrapInFunction(expr); @@ -977,14 +977,14 @@ TEST_F(ResolverTypeInitializerValidationTest, Convert_f32_to_i32_Success) { auto* call = Sem().Get(expr); ASSERT_NE(call, nullptr); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 1u); EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); } -TEST_F(ResolverTypeInitializerValidationTest, Convert_i32_to_u32_Success) { +TEST_F(ResolverValueConstructorValidationTest, Convert_i32_to_u32_Success) { auto* expr = Call(123_i); WrapInFunction(expr); @@ -995,14 +995,14 @@ TEST_F(ResolverTypeInitializerValidationTest, Convert_i32_to_u32_Success) { auto* call = Sem().Get(expr); ASSERT_NE(call, nullptr); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 1u); EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); } -TEST_F(ResolverTypeInitializerValidationTest, Convert_u32_to_f16_Success) { +TEST_F(ResolverValueConstructorValidationTest, Convert_u32_to_f16_Success) { Enable(builtin::Extension::kF16); auto* expr = Call(123_u); @@ -1015,14 +1015,14 @@ TEST_F(ResolverTypeInitializerValidationTest, Convert_u32_to_f16_Success) { auto* call = Sem().Get(expr); ASSERT_NE(call, nullptr); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 1u); EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); } -TEST_F(ResolverTypeInitializerValidationTest, Convert_f16_to_f32_Success) { +TEST_F(ResolverValueConstructorValidationTest, Convert_f16_to_f32_Success) { Enable(builtin::Extension::kF16); auto* expr = Call(123_h); @@ -1035,109 +1035,109 @@ TEST_F(ResolverTypeInitializerValidationTest, Convert_f16_to_f32_Success) { auto* call = Sem().Get(expr); ASSERT_NE(call, nullptr); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 1u); EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); } -} // namespace ScalarInitializer +} // namespace ScalarConstructor -namespace VectorInitializer { +namespace VectorConstructor { -TEST_F(ResolverTypeInitializerValidationTest, Vec2F32_Error_ScalarArgumentTypeMismatch) { +TEST_F(ResolverValueConstructorValidationTest, Vec2F32_Error_ScalarArgumentTypeMismatch) { WrapInFunction(vec2(Source{{12, 34}}, 1_i, 2_f)); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("12:34 error: no matching initializer for vec2(i32, f32)")); + HasSubstr("12:34 error: no matching constructor for vec2(i32, f32)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec2F16_Error_ScalarArgumentTypeMismatch) { +TEST_F(ResolverValueConstructorValidationTest, Vec2F16_Error_ScalarArgumentTypeMismatch) { Enable(builtin::Extension::kF16); WrapInFunction(vec2(Source{{12, 34}}, 1_h, 2_f)); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("12:34 error: no matching initializer for vec2(f16, f32)")); + HasSubstr("12:34 error: no matching constructor for vec2(f16, f32)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec2U32_Error_ScalarArgumentTypeMismatch) { +TEST_F(ResolverValueConstructorValidationTest, Vec2U32_Error_ScalarArgumentTypeMismatch) { WrapInFunction(vec2(Source{{12, 34}}, 1_u, 2_i)); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("12:34 error: no matching initializer for vec2(u32, i32)")); + HasSubstr("12:34 error: no matching constructor for vec2(u32, i32)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec2I32_Error_ScalarArgumentTypeMismatch) { +TEST_F(ResolverValueConstructorValidationTest, Vec2I32_Error_ScalarArgumentTypeMismatch) { WrapInFunction(vec2(Source{{12, 34}}, 1_u, 2_i)); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("12:34 error: no matching initializer for vec2(u32, i32)")); + HasSubstr("12:34 error: no matching constructor for vec2(u32, i32)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec2Bool_Error_ScalarArgumentTypeMismatch) { +TEST_F(ResolverValueConstructorValidationTest, Vec2Bool_Error_ScalarArgumentTypeMismatch) { WrapInFunction(vec2(Source{{12, 34}}, true, 1_i)); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("12:34 error: no matching initializer for vec2(bool, i32)")); + HasSubstr("12:34 error: no matching constructor for vec2(bool, i32)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec2_Error_Vec3ArgumentCardinalityTooLarge) { +TEST_F(ResolverValueConstructorValidationTest, Vec2_Error_Vec3ArgumentCardinalityTooLarge) { WrapInFunction(vec2(Source{{12, 34}}, vec3())); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("12:34 error: no matching initializer for vec2(vec3)")); + HasSubstr("12:34 error: no matching constructor for vec2(vec3)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec2_Error_Vec4ArgumentCardinalityTooLarge) { +TEST_F(ResolverValueConstructorValidationTest, Vec2_Error_Vec4ArgumentCardinalityTooLarge) { WrapInFunction(vec2(Source{{12, 34}}, vec4())); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("12:34 error: no matching initializer for vec2(vec4)")); + HasSubstr("12:34 error: no matching constructor for vec2(vec4)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec2_Error_TooManyArgumentsScalar) { +TEST_F(ResolverValueConstructorValidationTest, Vec2_Error_TooManyArgumentsScalar) { WrapInFunction(vec2(Source{{12, 34}}, 1_f, 2_f, 3_f)); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("12:34 error: no matching initializer for vec2(f32, f32, f32)")); + HasSubstr("12:34 error: no matching constructor for vec2(f32, f32, f32)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec2_Error_TooManyArgumentsVector) { +TEST_F(ResolverValueConstructorValidationTest, Vec2_Error_TooManyArgumentsVector) { WrapInFunction(vec2(Source{{12, 34}}, vec2(), vec2())); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT( r()->error(), - HasSubstr("12:34 error: no matching initializer for vec2(vec2, vec2)")); + HasSubstr("12:34 error: no matching constructor for vec2(vec2, vec2)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec2_Error_TooManyArgumentsVectorAndScalar) { +TEST_F(ResolverValueConstructorValidationTest, Vec2_Error_TooManyArgumentsVectorAndScalar) { WrapInFunction(vec2(Source{{12, 34}}, vec2(), 1_f)); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("12:34 error: no matching initializer for vec2(vec2, f32)")); + HasSubstr("12:34 error: no matching constructor for vec2(vec2, f32)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec2_Error_InvalidArgumentType) { +TEST_F(ResolverValueConstructorValidationTest, Vec2_Error_InvalidArgumentType) { WrapInFunction(vec2(Source{{12, 34}}, mat2x2())); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("12:34 error: no matching initializer for vec2(mat2x2)")); + HasSubstr("12:34 error: no matching constructor for vec2(mat2x2)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec2_Success_ZeroValue) { +TEST_F(ResolverValueConstructorValidationTest, Vec2_Success_ZeroValue) { auto* tc = vec2(); WrapInFunction(tc); @@ -1150,13 +1150,13 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2_Success_ZeroValue) { auto* call = Sem().Get(tc); ASSERT_NE(call, nullptr); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 0u); } -TEST_F(ResolverTypeInitializerValidationTest, Vec2F32_Success_Scalar) { +TEST_F(ResolverValueConstructorValidationTest, Vec2F32_Success_Scalar) { auto* tc = vec2(1_f, 1_f); WrapInFunction(tc); @@ -1169,7 +1169,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2F32_Success_Scalar) { auto* call = Sem().Get(tc); ASSERT_NE(call, nullptr); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 2u); @@ -1177,7 +1177,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2F32_Success_Scalar) { EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); } -TEST_F(ResolverTypeInitializerValidationTest, Vec2F16_Success_Scalar) { +TEST_F(ResolverValueConstructorValidationTest, Vec2F16_Success_Scalar) { Enable(builtin::Extension::kF16); auto* tc = vec2(1_h, 1_h); @@ -1192,7 +1192,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2F16_Success_Scalar) { auto* call = Sem().Get(tc); ASSERT_NE(call, nullptr); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 2u); @@ -1200,7 +1200,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2F16_Success_Scalar) { EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); } -TEST_F(ResolverTypeInitializerValidationTest, Vec2U32_Success_Scalar) { +TEST_F(ResolverValueConstructorValidationTest, Vec2U32_Success_Scalar) { auto* tc = vec2(1_u, 1_u); WrapInFunction(tc); @@ -1213,7 +1213,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2U32_Success_Scalar) { auto* call = Sem().Get(tc); ASSERT_NE(call, nullptr); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 2u); @@ -1221,7 +1221,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2U32_Success_Scalar) { EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); } -TEST_F(ResolverTypeInitializerValidationTest, Vec2I32_Success_Scalar) { +TEST_F(ResolverValueConstructorValidationTest, Vec2I32_Success_Scalar) { auto* tc = vec2(1_i, 1_i); WrapInFunction(tc); @@ -1234,7 +1234,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2I32_Success_Scalar) { auto* call = Sem().Get(tc); ASSERT_NE(call, nullptr); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 2u); @@ -1242,7 +1242,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2I32_Success_Scalar) { EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); } -TEST_F(ResolverTypeInitializerValidationTest, Vec2Bool_Success_Scalar) { +TEST_F(ResolverValueConstructorValidationTest, Vec2Bool_Success_Scalar) { auto* tc = vec2(true, false); WrapInFunction(tc); @@ -1255,7 +1255,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2Bool_Success_Scalar) { auto* call = Sem().Get(tc); ASSERT_NE(call, nullptr); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 2u); @@ -1263,7 +1263,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2Bool_Success_Scalar) { EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); } -TEST_F(ResolverTypeInitializerValidationTest, Vec2_Success_Identity) { +TEST_F(ResolverValueConstructorValidationTest, Vec2_Success_Identity) { auto* tc = vec2(vec2()); WrapInFunction(tc); @@ -1276,14 +1276,14 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2_Success_Identity) { auto* call = Sem().Get(tc); ASSERT_NE(call, nullptr); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 1u); EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); } -TEST_F(ResolverTypeInitializerValidationTest, Vec2_Success_Vec2TypeConversion) { +TEST_F(ResolverValueConstructorValidationTest, Vec2_Success_Vec2TypeConversion) { auto* tc = vec2(vec2()); WrapInFunction(tc); @@ -1296,123 +1296,123 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2_Success_Vec2TypeConversion) { auto* call = Sem().Get(tc); ASSERT_NE(call, nullptr); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 1u); EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); } -TEST_F(ResolverTypeInitializerValidationTest, Vec3F32_Error_ScalarArgumentTypeMismatch) { +TEST_F(ResolverValueConstructorValidationTest, Vec3F32_Error_ScalarArgumentTypeMismatch) { WrapInFunction(vec3(Source{{12, 34}}, 1_f, 2_f, 3_i)); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("12:34 error: no matching initializer for vec3(f32, f32, i32)")); + HasSubstr("12:34 error: no matching constructor for vec3(f32, f32, i32)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec3F16_Error_ScalarArgumentTypeMismatch) { +TEST_F(ResolverValueConstructorValidationTest, Vec3F16_Error_ScalarArgumentTypeMismatch) { Enable(builtin::Extension::kF16); WrapInFunction(vec3(Source{{12, 34}}, 1_h, 2_h, 3_f)); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("12:34 error: no matching initializer for vec3(f16, f16, f32)")); + HasSubstr("12:34 error: no matching constructor for vec3(f16, f16, f32)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec3U32_Error_ScalarArgumentTypeMismatch) { +TEST_F(ResolverValueConstructorValidationTest, Vec3U32_Error_ScalarArgumentTypeMismatch) { WrapInFunction(vec3(Source{{12, 34}}, 1_u, 2_i, 3_u)); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("12:34 error: no matching initializer for vec3(u32, i32, u32)")); + HasSubstr("12:34 error: no matching constructor for vec3(u32, i32, u32)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec3I32_Error_ScalarArgumentTypeMismatch) { +TEST_F(ResolverValueConstructorValidationTest, Vec3I32_Error_ScalarArgumentTypeMismatch) { WrapInFunction(vec3(Source{{12, 34}}, 1_i, 2_u, 3_i)); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("12:34 error: no matching initializer for vec3(i32, u32, i32)")); + HasSubstr("12:34 error: no matching constructor for vec3(i32, u32, i32)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec3Bool_Error_ScalarArgumentTypeMismatch) { +TEST_F(ResolverValueConstructorValidationTest, Vec3Bool_Error_ScalarArgumentTypeMismatch) { WrapInFunction(vec3(Source{{12, 34}}, false, 1_i, true)); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("12:34 error: no matching initializer for vec3(bool, i32, bool)")); + HasSubstr("12:34 error: no matching constructor for vec3(bool, i32, bool)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec3_Error_Vec4ArgumentCardinalityTooLarge) { +TEST_F(ResolverValueConstructorValidationTest, Vec3_Error_Vec4ArgumentCardinalityTooLarge) { WrapInFunction(vec3(Source{{12, 34}}, vec4())); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("12:34 error: no matching initializer for vec3(vec4)")); + HasSubstr("12:34 error: no matching constructor for vec3(vec4)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec3_Error_TooFewArgumentsScalar) { +TEST_F(ResolverValueConstructorValidationTest, Vec3_Error_TooFewArgumentsScalar) { WrapInFunction(vec3(Source{{12, 34}}, 1_f, 2_f)); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("12:34 error: no matching initializer for vec3(f32, f32)")); + HasSubstr("12:34 error: no matching constructor for vec3(f32, f32)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec3_Error_TooManyArgumentsScalar) { +TEST_F(ResolverValueConstructorValidationTest, Vec3_Error_TooManyArgumentsScalar) { WrapInFunction(vec3(Source{{12, 34}}, 1_f, 2_f, 3_f, 4_f)); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT( r()->error(), - HasSubstr("12:34 error: no matching initializer for vec3(f32, f32, f32, f32)")); + HasSubstr("12:34 error: no matching constructor for vec3(f32, f32, f32, f32)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec3_Error_TooFewArgumentsVec2) { +TEST_F(ResolverValueConstructorValidationTest, Vec3_Error_TooFewArgumentsVec2) { WrapInFunction(vec3(Source{{12, 34}}, vec2())); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("12:34 error: no matching initializer for vec3(vec2)")); + HasSubstr("12:34 error: no matching constructor for vec3(vec2)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec3_Error_TooManyArgumentsVec2) { +TEST_F(ResolverValueConstructorValidationTest, Vec3_Error_TooManyArgumentsVec2) { WrapInFunction(vec3(Source{{12, 34}}, vec2(), vec2())); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT( r()->error(), - HasSubstr("12:34 error: no matching initializer for vec3(vec2, vec2)")); + HasSubstr("12:34 error: no matching constructor for vec3(vec2, vec2)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec3_Error_TooManyArgumentsVec2AndScalar) { +TEST_F(ResolverValueConstructorValidationTest, Vec3_Error_TooManyArgumentsVec2AndScalar) { WrapInFunction(vec3(Source{{12, 34}}, vec2(), 1_f, 1_f)); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT( r()->error(), - HasSubstr("12:34 error: no matching initializer for vec3(vec2, f32, f32)")); + HasSubstr("12:34 error: no matching constructor for vec3(vec2, f32, f32)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec3_Error_TooManyArgumentsVec3) { +TEST_F(ResolverValueConstructorValidationTest, Vec3_Error_TooManyArgumentsVec3) { WrapInFunction(vec3(Source{{12, 34}}, vec3(), 1_f)); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("12:34 error: no matching initializer for vec3(vec3, f32)")); + HasSubstr("12:34 error: no matching constructor for vec3(vec3, f32)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec3_Error_InvalidArgumentType) { +TEST_F(ResolverValueConstructorValidationTest, Vec3_Error_InvalidArgumentType) { WrapInFunction(vec3(Source{{12, 34}}, mat2x2())); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("12:34 error: no matching initializer for vec3(mat2x2)")); + HasSubstr("12:34 error: no matching constructor for vec3(mat2x2)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_ZeroValue) { +TEST_F(ResolverValueConstructorValidationTest, Vec3_Success_ZeroValue) { auto* tc = vec3(); WrapInFunction(tc); @@ -1425,13 +1425,13 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_ZeroValue) { auto* call = Sem().Get(tc); ASSERT_NE(call, nullptr); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 0u); } -TEST_F(ResolverTypeInitializerValidationTest, Vec3F32_Success_Scalar) { +TEST_F(ResolverValueConstructorValidationTest, Vec3F32_Success_Scalar) { auto* tc = vec3(1_f, 1_f, 1_f); WrapInFunction(tc); @@ -1444,7 +1444,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3F32_Success_Scalar) { auto* call = Sem().Get(tc); ASSERT_NE(call, nullptr); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 3u); @@ -1453,7 +1453,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3F32_Success_Scalar) { EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); } -TEST_F(ResolverTypeInitializerValidationTest, Vec3F16_Success_Scalar) { +TEST_F(ResolverValueConstructorValidationTest, Vec3F16_Success_Scalar) { Enable(builtin::Extension::kF16); auto* tc = vec3(1_h, 1_h, 1_h); @@ -1468,7 +1468,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3F16_Success_Scalar) { auto* call = Sem().Get(tc); ASSERT_NE(call, nullptr); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 3u); @@ -1477,7 +1477,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3F16_Success_Scalar) { EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); } -TEST_F(ResolverTypeInitializerValidationTest, Vec3U32_Success_Scalar) { +TEST_F(ResolverValueConstructorValidationTest, Vec3U32_Success_Scalar) { auto* tc = vec3(1_u, 1_u, 1_u); WrapInFunction(tc); @@ -1490,7 +1490,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3U32_Success_Scalar) { auto* call = Sem().Get(tc); ASSERT_NE(call, nullptr); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 3u); @@ -1499,7 +1499,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3U32_Success_Scalar) { EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); } -TEST_F(ResolverTypeInitializerValidationTest, Vec3I32_Success_Scalar) { +TEST_F(ResolverValueConstructorValidationTest, Vec3I32_Success_Scalar) { auto* tc = vec3(1_i, 1_i, 1_i); WrapInFunction(tc); @@ -1512,7 +1512,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3I32_Success_Scalar) { auto* call = Sem().Get(tc); ASSERT_NE(call, nullptr); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 3u); @@ -1521,7 +1521,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3I32_Success_Scalar) { EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); } -TEST_F(ResolverTypeInitializerValidationTest, Vec3Bool_Success_Scalar) { +TEST_F(ResolverValueConstructorValidationTest, Vec3Bool_Success_Scalar) { auto* tc = vec3(true, false, true); WrapInFunction(tc); @@ -1534,7 +1534,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3Bool_Success_Scalar) { auto* call = Sem().Get(tc); ASSERT_NE(call, nullptr); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 3u); @@ -1543,7 +1543,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3Bool_Success_Scalar) { EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); } -TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_Vec2AndScalar) { +TEST_F(ResolverValueConstructorValidationTest, Vec3_Success_Vec2AndScalar) { auto* tc = vec3(vec2(), 1_f); WrapInFunction(tc); @@ -1556,7 +1556,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_Vec2AndScalar) { auto* call = Sem().Get(tc); ASSERT_NE(call, nullptr); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 2u); @@ -1564,7 +1564,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_Vec2AndScalar) { EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); } -TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_ScalarAndVec2) { +TEST_F(ResolverValueConstructorValidationTest, Vec3_Success_ScalarAndVec2) { auto* tc = vec3(1_f, vec2()); WrapInFunction(tc); @@ -1577,7 +1577,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_ScalarAndVec2) { auto* call = Sem().Get(tc); ASSERT_NE(call, nullptr); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 2u); @@ -1585,7 +1585,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_ScalarAndVec2) { EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); } -TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_Identity) { +TEST_F(ResolverValueConstructorValidationTest, Vec3_Success_Identity) { auto* tc = vec3(vec3()); WrapInFunction(tc); @@ -1598,14 +1598,14 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_Identity) { auto* call = Sem().Get(tc); ASSERT_NE(call, nullptr); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 1u); EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); } -TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_Vec3TypeConversion) { +TEST_F(ResolverValueConstructorValidationTest, Vec3_Success_Vec3TypeConversion) { auto* tc = vec3(vec3()); WrapInFunction(tc); @@ -1618,23 +1618,23 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_Vec3TypeConversion) { auto* call = Sem().Get(tc); ASSERT_NE(call, nullptr); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 1u); EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); } -TEST_F(ResolverTypeInitializerValidationTest, Vec4F32_Error_ScalarArgumentTypeMismatch) { +TEST_F(ResolverValueConstructorValidationTest, Vec4F32_Error_ScalarArgumentTypeMismatch) { WrapInFunction(vec4(Source{{12, 34}}, 1_f, 1_f, 1_i, 1_f)); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT( r()->error(), - HasSubstr("12:34 error: no matching initializer for vec4(f32, f32, i32, f32)")); + HasSubstr("12:34 error: no matching constructor for vec4(f32, f32, i32, f32)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec4F16_Error_ScalarArgumentTypeMismatch) { +TEST_F(ResolverValueConstructorValidationTest, Vec4F16_Error_ScalarArgumentTypeMismatch) { Enable(builtin::Extension::kF16); WrapInFunction(vec4(Source{{12, 34}}, 1_h, 1_h, 1_f, 1_h)); @@ -1642,142 +1642,142 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4F16_Error_ScalarArgumentTypeMi EXPECT_FALSE(r()->Resolve()); EXPECT_THAT( r()->error(), - HasSubstr("12:34 error: no matching initializer for vec4(f16, f16, f32, f16)")); + HasSubstr("12:34 error: no matching constructor for vec4(f16, f16, f32, f16)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec4U32_Error_ScalarArgumentTypeMismatch) { +TEST_F(ResolverValueConstructorValidationTest, Vec4U32_Error_ScalarArgumentTypeMismatch) { WrapInFunction(vec4(Source{{12, 34}}, 1_u, 1_u, 1_i, 1_u)); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT( r()->error(), - HasSubstr("12:34 error: no matching initializer for vec4(u32, u32, i32, u32)")); + HasSubstr("12:34 error: no matching constructor for vec4(u32, u32, i32, u32)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec4I32_Error_ScalarArgumentTypeMismatch) { +TEST_F(ResolverValueConstructorValidationTest, Vec4I32_Error_ScalarArgumentTypeMismatch) { WrapInFunction(vec4(Source{{12, 34}}, 1_i, 1_i, 1_u, 1_i)); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT( r()->error(), - HasSubstr("12:34 error: no matching initializer for vec4(i32, i32, u32, i32)")); + HasSubstr("12:34 error: no matching constructor for vec4(i32, i32, u32, i32)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec4Bool_Error_ScalarArgumentTypeMismatch) { +TEST_F(ResolverValueConstructorValidationTest, Vec4Bool_Error_ScalarArgumentTypeMismatch) { WrapInFunction(vec4(Source{{12, 34}}, true, false, 1_i, true)); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT( r()->error(), - HasSubstr("12:34 error: no matching initializer for vec4(bool, bool, i32, bool)")); + HasSubstr("12:34 error: no matching constructor for vec4(bool, bool, i32, bool)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec4_Error_TooFewArgumentsScalar) { +TEST_F(ResolverValueConstructorValidationTest, Vec4_Error_TooFewArgumentsScalar) { WrapInFunction(vec4(Source{{12, 34}}, 1_f, 2_f, 3_f)); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("12:34 error: no matching initializer for vec4(f32, f32, f32)")); + HasSubstr("12:34 error: no matching constructor for vec4(f32, f32, f32)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec4_Error_TooManyArgumentsScalar) { +TEST_F(ResolverValueConstructorValidationTest, Vec4_Error_TooManyArgumentsScalar) { WrapInFunction(vec4(Source{{12, 34}}, 1_f, 2_f, 3_f, 4_f, 5_f)); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT( r()->error(), - HasSubstr("12:34 error: no matching initializer for vec4(f32, f32, f32, f32, f32)")); + HasSubstr("12:34 error: no matching constructor for vec4(f32, f32, f32, f32, f32)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec4_Error_TooFewArgumentsVec2AndScalar) { +TEST_F(ResolverValueConstructorValidationTest, Vec4_Error_TooFewArgumentsVec2AndScalar) { WrapInFunction(vec4(Source{{12, 34}}, vec2(), 1_f)); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("12:34 error: no matching initializer for vec4(vec2, f32)")); + HasSubstr("12:34 error: no matching constructor for vec4(vec2, f32)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec4_Error_TooManyArgumentsVec2AndScalars) { +TEST_F(ResolverValueConstructorValidationTest, Vec4_Error_TooManyArgumentsVec2AndScalars) { WrapInFunction(vec4(Source{{12, 34}}, vec2(), 1_f, 2_f, 3_f)); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT( r()->error(), - HasSubstr("12:34 error: no matching initializer for vec4(vec2, f32, f32, f32)")); + HasSubstr("12:34 error: no matching constructor for vec4(vec2, f32, f32, f32)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec4_Error_TooManyArgumentsVec2Vec2Scalar) { +TEST_F(ResolverValueConstructorValidationTest, Vec4_Error_TooManyArgumentsVec2Vec2Scalar) { WrapInFunction(vec4(Source{{12, 34}}, vec2(), vec2(), 1_f)); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT( r()->error(), - HasSubstr("12:34 error: no matching initializer for vec4(vec2, vec2, f32)")); + HasSubstr("12:34 error: no matching constructor for vec4(vec2, vec2, f32)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec4_Error_TooManyArgumentsVec2Vec2Vec2) { +TEST_F(ResolverValueConstructorValidationTest, Vec4_Error_TooManyArgumentsVec2Vec2Vec2) { WrapInFunction(vec4(Source{{12, 34}}, vec2(), vec2(), vec2())); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT( r()->error(), HasSubstr( - "12:34 error: no matching initializer for vec4(vec2, vec2, vec2)")); + "12:34 error: no matching constructor for vec4(vec2, vec2, vec2)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec4_Error_TooFewArgumentsVec3) { +TEST_F(ResolverValueConstructorValidationTest, Vec4_Error_TooFewArgumentsVec3) { WrapInFunction(vec4(Source{{12, 34}}, vec3())); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("12:34 error: no matching initializer for vec4(vec3)")); + HasSubstr("12:34 error: no matching constructor for vec4(vec3)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec4_Error_TooManyArgumentsVec3AndScalars) { +TEST_F(ResolverValueConstructorValidationTest, Vec4_Error_TooManyArgumentsVec3AndScalars) { WrapInFunction(vec4(Source{{12, 34}}, vec3(), 1_f, 2_f)); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT( r()->error(), - HasSubstr("12:34 error: no matching initializer for vec4(vec3, f32, f32)")); + HasSubstr("12:34 error: no matching constructor for vec4(vec3, f32, f32)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec4_Error_TooManyArgumentsVec3AndVec2) { +TEST_F(ResolverValueConstructorValidationTest, Vec4_Error_TooManyArgumentsVec3AndVec2) { WrapInFunction(vec4(Source{{12, 34}}, vec3(), vec2())); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT( r()->error(), - HasSubstr("12:34 error: no matching initializer for vec4(vec3, vec2)")); + HasSubstr("12:34 error: no matching constructor for vec4(vec3, vec2)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec4_Error_TooManyArgumentsVec2AndVec3) { +TEST_F(ResolverValueConstructorValidationTest, Vec4_Error_TooManyArgumentsVec2AndVec3) { WrapInFunction(vec4(Source{{12, 34}}, vec2(), vec3())); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT( r()->error(), - HasSubstr("12:34 error: no matching initializer for vec4(vec2, vec3)")); + HasSubstr("12:34 error: no matching constructor for vec4(vec2, vec3)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec4_Error_TooManyArgumentsVec3AndVec3) { +TEST_F(ResolverValueConstructorValidationTest, Vec4_Error_TooManyArgumentsVec3AndVec3) { WrapInFunction(vec4(Source{{12, 34}}, vec3(), vec3())); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT( r()->error(), - HasSubstr("12:34 error: no matching initializer for vec4(vec3, vec3)")); + HasSubstr("12:34 error: no matching constructor for vec4(vec3, vec3)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec4_Error_InvalidArgumentType) { +TEST_F(ResolverValueConstructorValidationTest, Vec4_Error_InvalidArgumentType) { WrapInFunction(vec4(Source{{12, 34}}, mat2x2())); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("12:34 error: no matching initializer for vec4(mat2x2)")); + HasSubstr("12:34 error: no matching constructor for vec4(mat2x2)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_ZeroValue) { +TEST_F(ResolverValueConstructorValidationTest, Vec4_Success_ZeroValue) { auto* tc = vec4(); WrapInFunction(tc); @@ -1789,7 +1789,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_ZeroValue) { EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } -TEST_F(ResolverTypeInitializerValidationTest, Vec4F32_Success_Scalar) { +TEST_F(ResolverValueConstructorValidationTest, Vec4F32_Success_Scalar) { auto* tc = vec4(1_f, 1_f, 1_f, 1_f); WrapInFunction(tc); @@ -1801,7 +1801,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4F32_Success_Scalar) { EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } -TEST_F(ResolverTypeInitializerValidationTest, Vec4F16_Success_Scalar) { +TEST_F(ResolverValueConstructorValidationTest, Vec4F16_Success_Scalar) { Enable(builtin::Extension::kF16); auto* tc = vec4(1_h, 1_h, 1_h, 1_h); @@ -1815,7 +1815,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4F16_Success_Scalar) { EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } -TEST_F(ResolverTypeInitializerValidationTest, Vec4U32_Success_Scalar) { +TEST_F(ResolverValueConstructorValidationTest, Vec4U32_Success_Scalar) { auto* tc = vec4(1_u, 1_u, 1_u, 1_u); WrapInFunction(tc); @@ -1827,7 +1827,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4U32_Success_Scalar) { EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } -TEST_F(ResolverTypeInitializerValidationTest, Vec4I32_Success_Scalar) { +TEST_F(ResolverValueConstructorValidationTest, Vec4I32_Success_Scalar) { auto* tc = vec4(1_i, 1_i, 1_i, 1_i); WrapInFunction(tc); @@ -1839,7 +1839,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4I32_Success_Scalar) { EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } -TEST_F(ResolverTypeInitializerValidationTest, Vec4Bool_Success_Scalar) { +TEST_F(ResolverValueConstructorValidationTest, Vec4Bool_Success_Scalar) { auto* tc = vec4(true, false, true, false); WrapInFunction(tc); @@ -1851,7 +1851,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4Bool_Success_Scalar) { EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } -TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_Vec2ScalarScalar) { +TEST_F(ResolverValueConstructorValidationTest, Vec4_Success_Vec2ScalarScalar) { auto* tc = vec4(vec2(), 1_f, 1_f); WrapInFunction(tc); @@ -1863,7 +1863,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_Vec2ScalarScalar) { EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } -TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_ScalarVec2Scalar) { +TEST_F(ResolverValueConstructorValidationTest, Vec4_Success_ScalarVec2Scalar) { auto* tc = vec4(1_f, vec2(), 1_f); WrapInFunction(tc); @@ -1875,7 +1875,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_ScalarVec2Scalar) { EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } -TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_ScalarScalarVec2) { +TEST_F(ResolverValueConstructorValidationTest, Vec4_Success_ScalarScalarVec2) { auto* tc = vec4(1_f, 1_f, vec2()); WrapInFunction(tc); @@ -1887,7 +1887,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_ScalarScalarVec2) { EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } -TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_Vec2AndVec2) { +TEST_F(ResolverValueConstructorValidationTest, Vec4_Success_Vec2AndVec2) { auto* tc = vec4(vec2(), vec2()); WrapInFunction(tc); @@ -1899,7 +1899,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_Vec2AndVec2) { EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } -TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_Vec3AndScalar) { +TEST_F(ResolverValueConstructorValidationTest, Vec4_Success_Vec3AndScalar) { auto* tc = vec4(vec3(), 1_f); WrapInFunction(tc); @@ -1911,7 +1911,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_Vec3AndScalar) { EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } -TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_ScalarAndVec3) { +TEST_F(ResolverValueConstructorValidationTest, Vec4_Success_ScalarAndVec3) { auto* tc = vec4(1_f, vec3()); WrapInFunction(tc); @@ -1923,7 +1923,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_ScalarAndVec3) { EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } -TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_Identity) { +TEST_F(ResolverValueConstructorValidationTest, Vec4_Success_Identity) { auto* tc = vec4(vec4()); WrapInFunction(tc); @@ -1935,7 +1935,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_Identity) { EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } -TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_Vec4TypeConversion) { +TEST_F(ResolverValueConstructorValidationTest, Vec4_Success_Vec4TypeConversion) { auto* tc = vec4(vec4()); WrapInFunction(tc); @@ -1947,17 +1947,17 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_Vec4TypeConversion) { EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } -TEST_F(ResolverTypeInitializerValidationTest, NestedVectorInitializers_InnerError) { +TEST_F(ResolverValueConstructorValidationTest, NestedVectorConstructors_InnerError) { WrapInFunction(vec4(vec4(1_f, 1_f, // vec3(Source{{12, 34}}, 1_f, 1_f)), 1_f)); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("12:34 error: no matching initializer for vec3(f32, f32)")); + HasSubstr("12:34 error: no matching constructor for vec3(f32, f32)")); } -TEST_F(ResolverTypeInitializerValidationTest, NestedVectorInitializers_Success) { +TEST_F(ResolverValueConstructorValidationTest, NestedVectorConstructors_Success) { auto* tc = vec4(vec3(vec2(1_f, 1_f), 1_f), 1_f); WrapInFunction(tc); @@ -1969,7 +1969,7 @@ TEST_F(ResolverTypeInitializerValidationTest, NestedVectorInitializers_Success) EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } -TEST_F(ResolverTypeInitializerValidationTest, Vector_Alias_Argument_Error) { +TEST_F(ResolverValueConstructorValidationTest, Vector_Alias_Argument_Error) { auto* alias = Alias("UnsignedInt", ty.u32()); GlobalVar("uint_var", ty.Of(alias), builtin::AddressSpace::kPrivate); @@ -1977,10 +1977,10 @@ TEST_F(ResolverTypeInitializerValidationTest, Vector_Alias_Argument_Error) { WrapInFunction(tc); EXPECT_FALSE(r()->Resolve()); - EXPECT_THAT(r()->error(), HasSubstr("12:34 error: no matching initializer for vec2(u32)")); + EXPECT_THAT(r()->error(), HasSubstr("12:34 error: no matching constructor for vec2(u32)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vector_Alias_Argument_Success) { +TEST_F(ResolverValueConstructorValidationTest, Vector_Alias_Argument_Success) { auto* f32_alias = Alias("Float32", ty.f32()); auto* vec2_alias = Alias("VectorFloat2", ty.vec2()); GlobalVar("my_f32", ty.Of(f32_alias), builtin::AddressSpace::kPrivate); @@ -1991,7 +1991,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vector_Alias_Argument_Success) { ASSERT_TRUE(r()->Resolve()) << r()->error(); } -TEST_F(ResolverTypeInitializerValidationTest, Vector_ElementTypeAlias_Error) { +TEST_F(ResolverValueConstructorValidationTest, Vector_ElementTypeAlias_Error) { auto* f32_alias = Alias("Float32", ty.f32()); // vec2(1.0f, 1u) @@ -2000,10 +2000,10 @@ TEST_F(ResolverTypeInitializerValidationTest, Vector_ElementTypeAlias_Error) { EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("12:34 error: no matching initializer for vec2(f32, u32)")); + HasSubstr("12:34 error: no matching constructor for vec2(f32, u32)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vector_ElementTypeAlias_Success) { +TEST_F(ResolverValueConstructorValidationTest, Vector_ElementTypeAlias_Success) { auto* f32_alias = Alias("Float32", ty.f32()); // vec2(1.0f, 1.0f) @@ -2014,7 +2014,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vector_ElementTypeAlias_Success) { ASSERT_TRUE(r()->Resolve()) << r()->error(); } -TEST_F(ResolverTypeInitializerValidationTest, Vector_ArgumentElementTypeAlias_Error) { +TEST_F(ResolverValueConstructorValidationTest, Vector_ArgumentElementTypeAlias_Error) { auto* f32_alias = Alias("Float32", ty.f32()); // vec3(vec(), 1.0f) @@ -2023,10 +2023,10 @@ TEST_F(ResolverTypeInitializerValidationTest, Vector_ArgumentElementTypeAlias_Er EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("12:34 error: no matching initializer for vec3(vec2, f32)")); + HasSubstr("12:34 error: no matching constructor for vec3(vec2, f32)")); } -TEST_F(ResolverTypeInitializerValidationTest, Vector_ArgumentElementTypeAlias_Success) { +TEST_F(ResolverValueConstructorValidationTest, Vector_ArgumentElementTypeAlias_Success) { auto* f32_alias = Alias("Float32", ty.f32()); // vec3(vec(), 1.0f) @@ -2037,7 +2037,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vector_ArgumentElementTypeAlias_Su ASSERT_TRUE(r()->Resolve()) << r()->error(); } -TEST_F(ResolverTypeInitializerValidationTest, InferVec2ElementTypeFromScalars) { +TEST_F(ResolverValueConstructorValidationTest, InferVec2ElementTypeFromScalars) { Enable(builtin::Extension::kF16); auto* vec2_bool = vec2(true, false); @@ -2066,7 +2066,7 @@ TEST_F(ResolverTypeInitializerValidationTest, InferVec2ElementTypeFromScalars) { EXPECT_EQ(TypeOf(vec2_f16)->As()->Width(), 2u); } -TEST_F(ResolverTypeInitializerValidationTest, InferVec2ElementTypeFromVec2) { +TEST_F(ResolverValueConstructorValidationTest, InferVec2ElementTypeFromVec2) { Enable(builtin::Extension::kF16); auto* vec2_bool = vec2(vec2(true, false)); @@ -2095,7 +2095,7 @@ TEST_F(ResolverTypeInitializerValidationTest, InferVec2ElementTypeFromVec2) { EXPECT_EQ(TypeOf(vec2_f16)->As()->Width(), 2u); } -TEST_F(ResolverTypeInitializerValidationTest, InferVec3ElementTypeFromScalars) { +TEST_F(ResolverValueConstructorValidationTest, InferVec3ElementTypeFromScalars) { Enable(builtin::Extension::kF16); auto* vec3_bool = vec3(Expr(true), Expr(false), Expr(true)); @@ -2124,7 +2124,7 @@ TEST_F(ResolverTypeInitializerValidationTest, InferVec3ElementTypeFromScalars) { EXPECT_EQ(TypeOf(vec3_f16)->As()->Width(), 3u); } -TEST_F(ResolverTypeInitializerValidationTest, InferVec3ElementTypeFromVec3) { +TEST_F(ResolverValueConstructorValidationTest, InferVec3ElementTypeFromVec3) { Enable(builtin::Extension::kF16); auto* vec3_bool = vec3(vec3(true, false, true)); @@ -2153,7 +2153,7 @@ TEST_F(ResolverTypeInitializerValidationTest, InferVec3ElementTypeFromVec3) { EXPECT_EQ(TypeOf(vec3_f16)->As()->Width(), 3u); } -TEST_F(ResolverTypeInitializerValidationTest, InferVec3ElementTypeFromScalarAndVec2) { +TEST_F(ResolverValueConstructorValidationTest, InferVec3ElementTypeFromScalarAndVec2) { Enable(builtin::Extension::kF16); auto* vec3_bool = vec3(Expr(true), vec2(false, true)); @@ -2182,7 +2182,7 @@ TEST_F(ResolverTypeInitializerValidationTest, InferVec3ElementTypeFromScalarAndV EXPECT_EQ(TypeOf(vec3_f16)->As()->Width(), 3u); } -TEST_F(ResolverTypeInitializerValidationTest, InferVec4ElementTypeFromScalars) { +TEST_F(ResolverValueConstructorValidationTest, InferVec4ElementTypeFromScalars) { Enable(builtin::Extension::kF16); auto* vec4_bool = vec4(Expr(true), Expr(false), Expr(true), Expr(false)); @@ -2211,7 +2211,7 @@ TEST_F(ResolverTypeInitializerValidationTest, InferVec4ElementTypeFromScalars) { EXPECT_EQ(TypeOf(vec4_f16)->As()->Width(), 4u); } -TEST_F(ResolverTypeInitializerValidationTest, InferVec4ElementTypeFromVec4) { +TEST_F(ResolverValueConstructorValidationTest, InferVec4ElementTypeFromVec4) { Enable(builtin::Extension::kF16); auto* vec4_bool = vec4(vec4(true, false, true, false)); @@ -2240,7 +2240,7 @@ TEST_F(ResolverTypeInitializerValidationTest, InferVec4ElementTypeFromVec4) { EXPECT_EQ(TypeOf(vec4_f16)->As()->Width(), 4u); } -TEST_F(ResolverTypeInitializerValidationTest, InferVec4ElementTypeFromScalarAndVec3) { +TEST_F(ResolverValueConstructorValidationTest, InferVec4ElementTypeFromScalarAndVec3) { Enable(builtin::Extension::kF16); auto* vec4_bool = vec4(Expr(true), vec3(false, true, false)); @@ -2269,7 +2269,7 @@ TEST_F(ResolverTypeInitializerValidationTest, InferVec4ElementTypeFromScalarAndV EXPECT_EQ(TypeOf(vec4_f16)->As()->Width(), 4u); } -TEST_F(ResolverTypeInitializerValidationTest, InferVec4ElementTypeFromVec2AndVec2) { +TEST_F(ResolverValueConstructorValidationTest, InferVec4ElementTypeFromVec2AndVec2) { Enable(builtin::Extension::kF16); auto* vec4_bool = vec4(vec2(true, false), vec2(true, false)); @@ -2298,23 +2298,23 @@ TEST_F(ResolverTypeInitializerValidationTest, InferVec4ElementTypeFromVec2AndVec EXPECT_EQ(TypeOf(vec4_f16)->As()->Width(), 4u); } -TEST_F(ResolverTypeInitializerValidationTest, CannotInferVectorElementTypeWithoutArgs) { +TEST_F(ResolverValueConstructorValidationTest, CannotInferVectorElementTypeWithoutArgs) { WrapInFunction(Call(Source{{12, 34}}, "vec3")); EXPECT_FALSE(r()->Resolve()); - EXPECT_THAT(r()->error(), HasSubstr("12:34 error: no matching initializer for vec3()")); + EXPECT_THAT(r()->error(), HasSubstr("12:34 error: no matching constructor for vec3()")); } -TEST_F(ResolverTypeInitializerValidationTest, CannotInferVec2ElementTypeFromScalarsMismatch) { +TEST_F(ResolverValueConstructorValidationTest, CannotInferVec2ElementTypeFromScalarsMismatch) { WrapInFunction(Call(Source{{1, 1}}, "vec2", // Expr(Source{{1, 2}}, 1_i), // Expr(Source{{1, 3}}, 2_u))); EXPECT_FALSE(r()->Resolve()); - EXPECT_THAT(r()->error(), HasSubstr("1:1 error: no matching initializer for vec2(i32, u32)")); + EXPECT_THAT(r()->error(), HasSubstr("1:1 error: no matching constructor for vec2(i32, u32)")); } -TEST_F(ResolverTypeInitializerValidationTest, CannotInferVec3ElementTypeFromScalarsMismatch) { +TEST_F(ResolverValueConstructorValidationTest, CannotInferVec3ElementTypeFromScalarsMismatch) { WrapInFunction(Call(Source{{1, 1}}, "vec3", // Expr(Source{{1, 2}}, 1_i), // Expr(Source{{1, 3}}, 2_u), // @@ -2322,20 +2322,21 @@ TEST_F(ResolverTypeInitializerValidationTest, CannotInferVec3ElementTypeFromScal EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("1:1 error: no matching initializer for vec3(i32, u32, i32)")); + HasSubstr("1:1 error: no matching constructor for vec3(i32, u32, i32)")); } -TEST_F(ResolverTypeInitializerValidationTest, CannotInferVec3ElementTypeFromScalarAndVec2Mismatch) { +TEST_F(ResolverValueConstructorValidationTest, + CannotInferVec3ElementTypeFromScalarAndVec2Mismatch) { WrapInFunction(Call(Source{{1, 1}}, "vec3", // Expr(Source{{1, 2}}, 1_i), // Call(Source{{1, 3}}, ty.vec2(), 2_f, 3_f))); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("1:1 error: no matching initializer for vec3(i32, vec2)")); + HasSubstr("1:1 error: no matching constructor for vec3(i32, vec2)")); } -TEST_F(ResolverTypeInitializerValidationTest, CannotInferVec4ElementTypeFromScalarsMismatch) { +TEST_F(ResolverValueConstructorValidationTest, CannotInferVec4ElementTypeFromScalarsMismatch) { WrapInFunction(Call(Source{{1, 1}}, "vec4", // Expr(Source{{1, 2}}, 1_i), // Expr(Source{{1, 3}}, 2_i), // @@ -2344,32 +2345,33 @@ TEST_F(ResolverTypeInitializerValidationTest, CannotInferVec4ElementTypeFromScal EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("1:1 error: no matching initializer for vec4(i32, i32, f32, i32)")); + HasSubstr("1:1 error: no matching constructor for vec4(i32, i32, f32, i32)")); } -TEST_F(ResolverTypeInitializerValidationTest, CannotInferVec4ElementTypeFromScalarAndVec3Mismatch) { +TEST_F(ResolverValueConstructorValidationTest, + CannotInferVec4ElementTypeFromScalarAndVec3Mismatch) { WrapInFunction(Call(Source{{1, 1}}, "vec4", // Expr(Source{{1, 2}}, 1_i), // Call(Source{{1, 3}}, ty.vec3(), 2_u, 3_u, 4_u))); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("1:1 error: no matching initializer for vec4(i32, vec3)")); + HasSubstr("1:1 error: no matching constructor for vec4(i32, vec3)")); } -TEST_F(ResolverTypeInitializerValidationTest, CannotInferVec4ElementTypeFromVec2AndVec2Mismatch) { +TEST_F(ResolverValueConstructorValidationTest, CannotInferVec4ElementTypeFromVec2AndVec2Mismatch) { WrapInFunction(Call(Source{{1, 1}}, "vec4", // Call(Source{{1, 2}}, ty.vec2(), 3_i, 4_i), // Call(Source{{1, 3}}, ty.vec2(), 3_u, 4_u))); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), - HasSubstr("1:1 error: no matching initializer for vec4(vec2, vec2)")); + HasSubstr("1:1 error: no matching constructor for vec4(vec2, vec2)")); } -} // namespace VectorInitializer +} // namespace VectorConstructor -namespace MatrixInitializer { +namespace MatrixConstructor { struct MatrixParams { using name_func_ptr = std::string (*)(); @@ -2401,9 +2403,9 @@ static std::string MatrixStr(const MatrixParams& param) { param.get_element_type_name() + ">"; } -using MatrixInitializerTest = ResolverTestWithParam; +using MatrixConstructorTest = ResolverTestWithParam; -TEST_P(MatrixInitializerTest, ColumnInitializer_Error_TooFewArguments) { +TEST_P(MatrixConstructorTest, ColumnConstructor_Error_TooFewArguments) { // matNxM(vecM(), ...); with N - 1 arguments // matNxM(vecM(), ...); with N - 1 arguments @@ -2428,11 +2430,11 @@ TEST_P(MatrixInitializerTest, ColumnInitializer_Error_TooFewArguments) { WrapInFunction(tc); EXPECT_FALSE(r()->Resolve()); - EXPECT_THAT(r()->error(), HasSubstr("12:34 error: no matching initializer for " + + EXPECT_THAT(r()->error(), HasSubstr("12:34 error: no matching constructor for " + MatrixStr(param) + "(" + args_tys.str() + ")")); } -TEST_P(MatrixInitializerTest, ElementInitializer_Error_TooFewArguments) { +TEST_P(MatrixConstructorTest, ElementConstructor_Error_TooFewArguments) { // matNxM(f32,...,f32); with N*M - 1 arguments // matNxM(f16,...,f16); with N*M - 1 arguments @@ -2456,11 +2458,11 @@ TEST_P(MatrixInitializerTest, ElementInitializer_Error_TooFewArguments) { WrapInFunction(tc); EXPECT_FALSE(r()->Resolve()); - EXPECT_THAT(r()->error(), HasSubstr("12:34 error: no matching initializer for " + + EXPECT_THAT(r()->error(), HasSubstr("12:34 error: no matching constructor for " + MatrixStr(param) + "(" + args_tys.str() + ")")); } -TEST_P(MatrixInitializerTest, ColumnInitializer_Error_TooManyArguments) { +TEST_P(MatrixConstructorTest, ColumnConstructor_Error_TooManyArguments) { // matNxM(vecM(), ...); with N + 1 arguments // matNxM(vecM(), ...); with N + 1 arguments @@ -2485,11 +2487,11 @@ TEST_P(MatrixInitializerTest, ColumnInitializer_Error_TooManyArguments) { WrapInFunction(tc); EXPECT_FALSE(r()->Resolve()); - EXPECT_THAT(r()->error(), HasSubstr("12:34 error: no matching initializer for " + + EXPECT_THAT(r()->error(), HasSubstr("12:34 error: no matching constructor for " + MatrixStr(param) + "(" + args_tys.str() + ")")); } -TEST_P(MatrixInitializerTest, ElementInitializer_Error_TooManyArguments) { +TEST_P(MatrixConstructorTest, ElementConstructor_Error_TooManyArguments) { // matNxM(f32,...,f32); with N*M + 1 arguments // matNxM(f16,...,f16); with N*M + 1 arguments @@ -2513,11 +2515,11 @@ TEST_P(MatrixInitializerTest, ElementInitializer_Error_TooManyArguments) { WrapInFunction(tc); EXPECT_FALSE(r()->Resolve()); - EXPECT_THAT(r()->error(), HasSubstr("12:34 error: no matching initializer for " + + EXPECT_THAT(r()->error(), HasSubstr("12:34 error: no matching constructor for " + MatrixStr(param) + "(" + args_tys.str() + ")")); } -TEST_P(MatrixInitializerTest, ColumnInitializer_Error_InvalidArgumentType) { +TEST_P(MatrixConstructorTest, ColumnConstructor_Error_InvalidArgumentType) { // matNxM(vec, vec, ...); N arguments // matNxM(vec, vec, ...); N arguments @@ -2541,11 +2543,11 @@ TEST_P(MatrixInitializerTest, ColumnInitializer_Error_InvalidArgumentType) { WrapInFunction(tc); EXPECT_FALSE(r()->Resolve()); - EXPECT_THAT(r()->error(), HasSubstr("12:34 error: no matching initializer for " + + EXPECT_THAT(r()->error(), HasSubstr("12:34 error: no matching constructor for " + MatrixStr(param) + "(" + args_tys.str() + ")")); } -TEST_P(MatrixInitializerTest, ElementInitializer_Error_InvalidArgumentType) { +TEST_P(MatrixConstructorTest, ElementConstructor_Error_InvalidArgumentType) { // matNxM(u32, u32, ...); N*M arguments // matNxM(u32, u32, ...); N*M arguments @@ -2568,11 +2570,11 @@ TEST_P(MatrixInitializerTest, ElementInitializer_Error_InvalidArgumentType) { WrapInFunction(tc); EXPECT_FALSE(r()->Resolve()); - EXPECT_THAT(r()->error(), HasSubstr("12:34 error: no matching initializer for " + + EXPECT_THAT(r()->error(), HasSubstr("12:34 error: no matching constructor for " + MatrixStr(param) + "(" + args_tys.str() + ")")); } -TEST_P(MatrixInitializerTest, ColumnInitializer_Error_TooFewRowsInVectorArgument) { +TEST_P(MatrixConstructorTest, ColumnConstructor_Error_TooFewRowsInVectorArgument) { // matNxM(vecM(),...,vecM-1()); // matNxM(vecM(),...,vecM-1()); @@ -2606,11 +2608,11 @@ TEST_P(MatrixInitializerTest, ColumnInitializer_Error_TooFewRowsInVectorArgument WrapInFunction(tc); EXPECT_FALSE(r()->Resolve()); - EXPECT_THAT(r()->error(), HasSubstr("12:34 error: no matching initializer for " + + EXPECT_THAT(r()->error(), HasSubstr("12:34 error: no matching constructor for " + MatrixStr(param) + "(" + args_tys.str() + ")")); } -TEST_P(MatrixInitializerTest, ColumnInitializer_Error_TooManyRowsInVectorArgument) { +TEST_P(MatrixConstructorTest, ColumnConstructor_Error_TooManyRowsInVectorArgument) { // matNxM(vecM(),...,vecM+1()); // matNxM(vecM(),...,vecM+1()); @@ -2643,11 +2645,11 @@ TEST_P(MatrixInitializerTest, ColumnInitializer_Error_TooManyRowsInVectorArgumen WrapInFunction(tc); EXPECT_FALSE(r()->Resolve()); - EXPECT_THAT(r()->error(), HasSubstr("12:34 error: no matching initializer for " + + EXPECT_THAT(r()->error(), HasSubstr("12:34 error: no matching constructor for " + MatrixStr(param) + "(" + args_tys.str() + ")")); } -TEST_P(MatrixInitializerTest, ZeroValue_Success) { +TEST_P(MatrixConstructorTest, ZeroValue_Success) { // matNxM(); // matNxM(); @@ -2662,7 +2664,7 @@ TEST_P(MatrixInitializerTest, ZeroValue_Success) { ASSERT_TRUE(r()->Resolve()) << r()->error(); } -TEST_P(MatrixInitializerTest, WithColumns_Success) { +TEST_P(MatrixConstructorTest, WithColumns_Success) { // matNxM(vecM(), ...); with N arguments // matNxM(vecM(), ...); with N arguments @@ -2683,7 +2685,7 @@ TEST_P(MatrixInitializerTest, WithColumns_Success) { ASSERT_TRUE(r()->Resolve()) << r()->error(); } -TEST_P(MatrixInitializerTest, WithElements_Success) { +TEST_P(MatrixConstructorTest, WithElements_Success) { // matNxM(f32,...,f32); with N*M arguments // matNxM(f16,...,f16); with N*M arguments @@ -2703,7 +2705,7 @@ TEST_P(MatrixInitializerTest, WithElements_Success) { ASSERT_TRUE(r()->Resolve()) << r()->error(); } -TEST_P(MatrixInitializerTest, ElementTypeAlias_Error) { +TEST_P(MatrixConstructorTest, ElementTypeAlias_Error) { // matNxM(vecM(), ...); with N arguments // matNxM(vecM(), ...); with N arguments @@ -2729,11 +2731,11 @@ TEST_P(MatrixInitializerTest, ElementTypeAlias_Error) { WrapInFunction(tc); EXPECT_FALSE(r()->Resolve()); - EXPECT_THAT(r()->error(), HasSubstr("12:34 error: no matching initializer for " + + EXPECT_THAT(r()->error(), HasSubstr("12:34 error: no matching constructor for " + MatrixStr(param) + "(" + args_tys.str() + ")")); } -TEST_P(MatrixInitializerTest, ElementTypeAlias_Success) { +TEST_P(MatrixConstructorTest, ElementTypeAlias_Success) { // matNxM(vecM(), ...); with N arguments // matNxM(vecM(), ...); with N arguments @@ -2756,7 +2758,7 @@ TEST_P(MatrixInitializerTest, ElementTypeAlias_Success) { ASSERT_TRUE(r()->Resolve()) << r()->error(); } -TEST_F(ResolverTypeInitializerValidationTest, MatrixInitializer_ArgumentTypeAlias_Error) { +TEST_F(ResolverValueConstructorValidationTest, MatrixConstructor_ArgumentTypeAlias_Error) { auto* alias = Alias("VectorUnsigned2", ty.vec2()); auto* tc = Call(Source{{12, 34}}, ty.mat2x2(), Call(ty.Of(alias)), vec2()); WrapInFunction(tc); @@ -2764,10 +2766,10 @@ TEST_F(ResolverTypeInitializerValidationTest, MatrixInitializer_ArgumentTypeAlia EXPECT_FALSE(r()->Resolve()); EXPECT_THAT( r()->error(), - HasSubstr("12:34 error: no matching initializer for mat2x2(vec2, vec2)")); + HasSubstr("12:34 error: no matching constructor for mat2x2(vec2, vec2)")); } -TEST_P(MatrixInitializerTest, ArgumentTypeAlias_Success) { +TEST_P(MatrixConstructorTest, ArgumentTypeAlias_Success) { const auto param = GetParam(); Enable(builtin::Extension::kF16); @@ -2787,7 +2789,7 @@ TEST_P(MatrixInitializerTest, ArgumentTypeAlias_Success) { ASSERT_TRUE(r()->Resolve()) << r()->error(); } -TEST_P(MatrixInitializerTest, ArgumentElementTypeAlias_Error) { +TEST_P(MatrixConstructorTest, ArgumentElementTypeAlias_Error) { const auto param = GetParam(); Enable(builtin::Extension::kF16); @@ -2810,11 +2812,11 @@ TEST_P(MatrixInitializerTest, ArgumentElementTypeAlias_Error) { WrapInFunction(tc); EXPECT_FALSE(r()->Resolve()); - EXPECT_THAT(r()->error(), HasSubstr("12:34 error: no matching initializer for " + + EXPECT_THAT(r()->error(), HasSubstr("12:34 error: no matching constructor for " + MatrixStr(param) + "(" + args_tys.str() + ")")); } -TEST_P(MatrixInitializerTest, ArgumentElementTypeAlias_Success) { +TEST_P(MatrixConstructorTest, ArgumentElementTypeAlias_Success) { const auto param = GetParam(); Enable(builtin::Extension::kF16); @@ -2834,7 +2836,7 @@ TEST_P(MatrixInitializerTest, ArgumentElementTypeAlias_Success) { ASSERT_TRUE(r()->Resolve()) << r()->error(); } -TEST_P(MatrixInitializerTest, InferElementTypeFromVectors) { +TEST_P(MatrixConstructorTest, InferElementTypeFromVectors) { const auto param = GetParam(); Enable(builtin::Extension::kF16); @@ -2851,7 +2853,7 @@ TEST_P(MatrixInitializerTest, InferElementTypeFromVectors) { ASSERT_TRUE(r()->Resolve()) << r()->error(); } -TEST_P(MatrixInitializerTest, InferElementTypeFromScalars) { +TEST_P(MatrixConstructorTest, InferElementTypeFromScalars) { const auto param = GetParam(); Enable(builtin::Extension::kF16); @@ -2867,13 +2869,13 @@ TEST_P(MatrixInitializerTest, InferElementTypeFromScalars) { ASSERT_TRUE(r()->Resolve()) << r()->error(); } -TEST_P(MatrixInitializerTest, CannotInferElementTypeFromVectors_Mismatch) { +TEST_P(MatrixConstructorTest, CannotInferElementTypeFromVectors_Mismatch) { const auto param = GetParam(); Enable(builtin::Extension::kF16); std::stringstream err; - err << "12:34 error: no matching initializer for mat" << param.columns << "x" << param.rows + err << "12:34 error: no matching constructor for mat" << param.columns << "x" << param.rows << "("; utils::Vector args; @@ -2898,13 +2900,13 @@ TEST_P(MatrixInitializerTest, CannotInferElementTypeFromVectors_Mismatch) { EXPECT_THAT(r()->error(), HasSubstr(err.str())); } -TEST_P(MatrixInitializerTest, CannotInferElementTypeFromScalars_Mismatch) { +TEST_P(MatrixConstructorTest, CannotInferElementTypeFromScalars_Mismatch) { const auto param = GetParam(); Enable(builtin::Extension::kF16); std::stringstream err; - err << "12:34 error: no matching initializer for mat" << param.columns << "x" << param.rows + err << "12:34 error: no matching constructor for mat" << param.columns << "x" << param.rows << "("; utils::Vector args; @@ -2930,8 +2932,8 @@ TEST_P(MatrixInitializerTest, CannotInferElementTypeFromScalars_Mismatch) { EXPECT_THAT(r()->error(), HasSubstr(err.str())); } -INSTANTIATE_TEST_SUITE_P(ResolverTypeInitializerValidationTest, - MatrixInitializerTest, +INSTANTIATE_TEST_SUITE_P(ResolverValueConstructorValidationTest, + MatrixConstructorTest, testing::Values(MatrixParamsFor(), MatrixParamsFor(), MatrixParamsFor(), @@ -2950,9 +2952,9 @@ INSTANTIATE_TEST_SUITE_P(ResolverTypeInitializerValidationTest, MatrixParamsFor(), MatrixParamsFor(), MatrixParamsFor())); -} // namespace MatrixInitializer +} // namespace MatrixConstructor -namespace StructInitializer { +namespace StructConstructor { using builder::CreatePtrs; using builder::CreatePtrsFor; using builder::mat2x2; @@ -2983,10 +2985,10 @@ constexpr CreatePtrs all_types[] = { auto number_of_members = testing::Values(2u, 32u, 64u); -using StructInitializerInputsTest = +using StructConstructorInputsTest = ResolverTestWithParam>; // number of struct members -TEST_P(StructInitializerInputsTest, TooFew) { +TEST_P(StructConstructorInputsTest, TooFew) { auto& param = GetParam(); auto& str_params = std::get<0>(param); uint32_t N = std::get<1>(param); @@ -3007,11 +3009,11 @@ TEST_P(StructInitializerInputsTest, TooFew) { auto* tc = Call(Source{{12, 34}}, ty.Of(s), values); WrapInFunction(tc); EXPECT_FALSE(r()->Resolve()); - EXPECT_EQ(r()->error(), "12:34 error: struct initializer has too few inputs: expected " + + EXPECT_EQ(r()->error(), "12:34 error: structure constructor has too few inputs: expected " + std::to_string(N) + ", found " + std::to_string(N - 1)); } -TEST_P(StructInitializerInputsTest, TooMany) { +TEST_P(StructConstructorInputsTest, TooMany) { auto& param = GetParam(); auto& str_params = std::get<0>(param); uint32_t N = std::get<1>(param); @@ -3032,18 +3034,18 @@ TEST_P(StructInitializerInputsTest, TooMany) { auto* tc = Call(Source{{12, 34}}, ty.Of(s), values); WrapInFunction(tc); EXPECT_FALSE(r()->Resolve()); - EXPECT_EQ(r()->error(), "12:34 error: struct initializer has too many inputs: expected " + + EXPECT_EQ(r()->error(), "12:34 error: structure constructor has too many inputs: expected " + std::to_string(N) + ", found " + std::to_string(N + 1)); } -INSTANTIATE_TEST_SUITE_P(ResolverTypeInitializerValidationTest, - StructInitializerInputsTest, +INSTANTIATE_TEST_SUITE_P(ResolverValueConstructorValidationTest, + StructConstructorInputsTest, testing::Combine(testing::ValuesIn(all_types), number_of_members)); -using StructInitializerTypeTest = +using StructConstructorTypeTest = ResolverTestWithParam>; // number of struct members -TEST_P(StructInitializerTypeTest, AllTypes) { +TEST_P(StructConstructorTypeTest, AllTypes) { auto& param = GetParam(); auto& str_params = std::get<0>(param); auto& ctor_params = std::get<1>(param); @@ -3057,12 +3059,12 @@ TEST_P(StructInitializerTypeTest, AllTypes) { utils::Vector members; utils::Vector values; - // make the last value of the initializer to have a different type - uint32_t initializer_value_with_different_type = N - 1; + // make the last value of the constructor to have a different type + uint32_t constructor_value_with_different_type = N - 1; for (uint32_t i = 0; i < N; i++) { ast::Type struct_type = str_params.ast(*this); members.Push(Member("member_" + std::to_string(i), struct_type)); - auto* ctor_value_expr = (i == initializer_value_with_different_type) + auto* ctor_value_expr = (i == constructor_value_with_different_type) ? ctor_params.expr_from_double(*this, 0) : str_params.expr_from_double(*this, 0); values.Push(ctor_value_expr); @@ -3072,19 +3074,19 @@ TEST_P(StructInitializerTypeTest, AllTypes) { WrapInFunction(tc); std::stringstream err; - err << "error: type in struct initializer does not match struct member "; + err << "error: type in structure constructor does not match struct member "; err << "type: expected '" << str_params.name() << "', found '" << ctor_params.name() << "'"; EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), err.str()); } -INSTANTIATE_TEST_SUITE_P(ResolverTypeInitializerValidationTest, - StructInitializerTypeTest, +INSTANTIATE_TEST_SUITE_P(ResolverValueConstructorValidationTest, + StructConstructorTypeTest, testing::Combine(testing::ValuesIn(all_types), testing::ValuesIn(all_types), number_of_members)); -TEST_F(ResolverTypeInitializerValidationTest, Struct_Nested) { +TEST_F(ResolverValueConstructorValidationTest, Struct_Nested) { auto* inner_m = Member("m", ty.i32()); auto* inner_s = Structure("inner_s", utils::Vector{inner_m}); @@ -3097,11 +3099,11 @@ TEST_F(ResolverTypeInitializerValidationTest, Struct_Nested) { WrapInFunction(tc); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), - "error: type in struct initializer does not match struct member " + "error: type in structure constructor does not match struct member " "type: expected 'inner_s', found 'i32'"); } -TEST_F(ResolverTypeInitializerValidationTest, Struct) { +TEST_F(ResolverValueConstructorValidationTest, Struct) { auto* m = Member("m", ty.i32()); auto* s = Structure("MyInputs", utils::Vector{m}); auto* tc = Call(Source{{12, 34}}, ty.Of(s)); @@ -3109,7 +3111,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Struct) { ASSERT_TRUE(r()->Resolve()) << r()->error(); } -TEST_F(ResolverTypeInitializerValidationTest, Struct_Empty) { +TEST_F(ResolverValueConstructorValidationTest, Struct_Empty) { auto* str = Structure("S", utils::Vector{ Member("a", ty.i32()), Member("b", ty.f32()), @@ -3119,31 +3121,31 @@ TEST_F(ResolverTypeInitializerValidationTest, Struct_Empty) { WrapInFunction(Call(ty.Of(str))); ASSERT_TRUE(r()->Resolve()) << r()->error(); } -} // namespace StructInitializer +} // namespace StructConstructor -TEST_F(ResolverTypeInitializerValidationTest, NonConstructibleType_Atomic) { +TEST_F(ResolverValueConstructorValidationTest, NonConstructibleType_Atomic) { WrapInFunction(Assign(Phony(), Call(Source{{12, 34}}, ty.atomic(ty.i32())))); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: type is not constructible"); } -TEST_F(ResolverTypeInitializerValidationTest, NonConstructibleType_AtomicArray) { +TEST_F(ResolverValueConstructorValidationTest, NonConstructibleType_AtomicArray) { WrapInFunction(Assign(Phony(), Call(Source{{12, 34}}, ty.array(ty.atomic(ty.i32()), 4_i)))); EXPECT_FALSE(r()->Resolve()); - EXPECT_EQ(r()->error(), "12:34 error: array initializer has non-constructible element type"); + EXPECT_EQ(r()->error(), "12:34 error: array constructor has non-constructible element type"); } -TEST_F(ResolverTypeInitializerValidationTest, NonConstructibleType_AtomicStructMember) { +TEST_F(ResolverValueConstructorValidationTest, NonConstructibleType_AtomicStructMember) { auto* str = Structure("S", utils::Vector{Member("a", ty.atomic(ty.i32()))}); WrapInFunction(Assign(Phony(), Call(Source{{12, 34}}, ty.Of(str)))); EXPECT_FALSE(r()->Resolve()); - EXPECT_EQ(r()->error(), "12:34 error: struct initializer has non-constructible type"); + EXPECT_EQ(r()->error(), "12:34 error: structure constructor has non-constructible type"); } -TEST_F(ResolverTypeInitializerValidationTest, NonConstructibleType_Sampler) { +TEST_F(ResolverValueConstructorValidationTest, NonConstructibleType_Sampler) { WrapInFunction( Assign(Phony(), Call(Source{{12, 34}}, ty.sampler(type::SamplerKind::kSampler)))); @@ -3151,42 +3153,42 @@ TEST_F(ResolverTypeInitializerValidationTest, NonConstructibleType_Sampler) { EXPECT_EQ(r()->error(), "12:34 error: type is not constructible"); } -TEST_F(ResolverTypeInitializerValidationTest, BuilinTypeInitializerAsStatement) { +TEST_F(ResolverValueConstructorValidationTest, BuilinTypeConstructorAsStatement) { WrapInFunction(CallStmt(vec2(Source{{12, 34}}, 1_f, 2_f))); EXPECT_FALSE(r()->Resolve()); - EXPECT_EQ(r()->error(), "12:34 error: type initializer evaluated but not used"); + EXPECT_EQ(r()->error(), "12:34 error: value constructor evaluated but not used"); } -TEST_F(ResolverTypeInitializerValidationTest, StructInitializerAsStatement) { +TEST_F(ResolverValueConstructorValidationTest, StructConstructorAsStatement) { Structure("S", utils::Vector{Member("m", ty.i32())}); WrapInFunction(CallStmt(Call(Source{{12, 34}}, "S", 1_a))); EXPECT_FALSE(r()->Resolve()); - EXPECT_EQ(r()->error(), "12:34 error: type initializer evaluated but not used"); + EXPECT_EQ(r()->error(), "12:34 error: value constructor evaluated but not used"); } -TEST_F(ResolverTypeInitializerValidationTest, AliasInitializerAsStatement) { +TEST_F(ResolverValueConstructorValidationTest, AliasConstructorAsStatement) { Alias("A", ty.i32()); WrapInFunction(CallStmt(Call(Source{{12, 34}}, "A", 1_i))); EXPECT_FALSE(r()->Resolve()); - EXPECT_EQ(r()->error(), "12:34 error: type initializer evaluated but not used"); + EXPECT_EQ(r()->error(), "12:34 error: value constructor evaluated but not used"); } -TEST_F(ResolverTypeInitializerValidationTest, BuilinTypeConversionAsStatement) { +TEST_F(ResolverValueConstructorValidationTest, BuilinTypeConversionAsStatement) { WrapInFunction(CallStmt(Call(Source{{12, 34}}, ty.f32(), 1_i))); EXPECT_FALSE(r()->Resolve()); - EXPECT_EQ(r()->error(), "12:34 error: type conversion evaluated but not used"); + EXPECT_EQ(r()->error(), "12:34 error: value conversion evaluated but not used"); } -TEST_F(ResolverTypeInitializerValidationTest, AliasConversionAsStatement) { +TEST_F(ResolverValueConstructorValidationTest, AliasConversionAsStatement) { Alias("A", ty.i32()); WrapInFunction(CallStmt(Call(Source{{12, 34}}, "A", 1_f))); EXPECT_FALSE(r()->Resolve()); - EXPECT_EQ(r()->error(), "12:34 error: type conversion evaluated but not used"); + EXPECT_EQ(r()->error(), "12:34 error: value conversion evaluated but not used"); } } // namespace diff --git a/src/tint/sem/call_target.h b/src/tint/sem/call_target.h index 153eb8aa54..4f0ab33a73 100644 --- a/src/tint/sem/call_target.h +++ b/src/tint/sem/call_target.h @@ -62,8 +62,8 @@ struct CallTargetSignature { } }; -/// CallTarget is the base for callable functions, builtins, type initializers -/// and type casts. +/// CallTarget is the base for callable functions, builtins, value constructors and value +/// conversions. class CallTarget : public Castable { public: /// Constructor diff --git a/src/tint/sem/type_initializer.cc b/src/tint/sem/value_constructor.cc similarity index 67% rename from src/tint/sem/type_initializer.cc rename to src/tint/sem/value_constructor.cc index d6e0383ba4..62be478f6e 100644 --- a/src/tint/sem/type_initializer.cc +++ b/src/tint/sem/value_constructor.cc @@ -12,19 +12,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/sem/type_initializer.h" +#include "src/tint/sem/value_constructor.h" #include -TINT_INSTANTIATE_TYPEINFO(tint::sem::TypeInitializer); +TINT_INSTANTIATE_TYPEINFO(tint::sem::ValueConstructor); namespace tint::sem { -TypeInitializer::TypeInitializer(const type::Type* type, - utils::VectorRef parameters, - EvaluationStage stage) +ValueConstructor::ValueConstructor(const type::Type* type, + utils::VectorRef parameters, + EvaluationStage stage) : Base(type, std::move(parameters), stage, /* must_use */ true) {} -TypeInitializer::~TypeInitializer() = default; +ValueConstructor::~ValueConstructor() = default; } // namespace tint::sem diff --git a/src/tint/sem/type_initializer.h b/src/tint/sem/value_constructor.h similarity index 63% rename from src/tint/sem/type_initializer.h rename to src/tint/sem/value_constructor.h index b46faa8ae5..aef827b507 100644 --- a/src/tint/sem/type_initializer.h +++ b/src/tint/sem/value_constructor.h @@ -12,29 +12,29 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SRC_TINT_SEM_TYPE_INITIALIZER_H_ -#define SRC_TINT_SEM_TYPE_INITIALIZER_H_ +#ifndef SRC_TINT_SEM_VALUE_CONSTRUCTOR_H_ +#define SRC_TINT_SEM_VALUE_CONSTRUCTOR_H_ #include "src/tint/sem/call_target.h" #include "src/tint/utils/vector.h" namespace tint::sem { -/// TypeInitializer is the CallTarget for a type initializer. -class TypeInitializer final : public Castable { +/// ValueConstructor is the CallTarget for a value constructor. +class ValueConstructor final : public Castable { public: /// Constructor /// @param type the type that's being constructed - /// @param parameters the type initializer parameters + /// @param parameters the constructor parameters /// @param stage the earliest evaluation stage for the expression - TypeInitializer(const type::Type* type, - utils::VectorRef parameters, - EvaluationStage stage); + ValueConstructor(const type::Type* type, + utils::VectorRef parameters, + EvaluationStage stage); /// Destructor - ~TypeInitializer() override; + ~ValueConstructor() override; }; } // namespace tint::sem -#endif // SRC_TINT_SEM_TYPE_INITIALIZER_H_ +#endif // SRC_TINT_SEM_VALUE_CONSTRUCTOR_H_ diff --git a/src/tint/sem/type_conversion.cc b/src/tint/sem/value_conversion.cc similarity index 69% rename from src/tint/sem/type_conversion.cc rename to src/tint/sem/value_conversion.cc index e33fdadf38..37331afb5f 100644 --- a/src/tint/sem/type_conversion.cc +++ b/src/tint/sem/value_conversion.cc @@ -12,17 +12,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/sem/type_conversion.h" +#include "src/tint/sem/value_conversion.h" -TINT_INSTANTIATE_TYPEINFO(tint::sem::TypeConversion); +TINT_INSTANTIATE_TYPEINFO(tint::sem::ValueConversion); namespace tint::sem { -TypeConversion::TypeConversion(const type::Type* type, - const sem::Parameter* parameter, - EvaluationStage stage) +ValueConversion::ValueConversion(const type::Type* type, + const sem::Parameter* parameter, + EvaluationStage stage) : Base(type, utils::Vector{parameter}, stage, /* must_use */ true) {} -TypeConversion::~TypeConversion() = default; +ValueConversion::~ValueConversion() = default; } // namespace tint::sem diff --git a/src/tint/sem/type_conversion.h b/src/tint/sem/value_conversion.h similarity index 73% rename from src/tint/sem/type_conversion.h rename to src/tint/sem/value_conversion.h index c48912731e..b79caa364e 100644 --- a/src/tint/sem/type_conversion.h +++ b/src/tint/sem/value_conversion.h @@ -12,24 +12,24 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SRC_TINT_SEM_TYPE_CONVERSION_H_ -#define SRC_TINT_SEM_TYPE_CONVERSION_H_ +#ifndef SRC_TINT_SEM_VALUE_CONVERSION_H_ +#define SRC_TINT_SEM_VALUE_CONVERSION_H_ #include "src/tint/sem/call_target.h" namespace tint::sem { -/// TypeConversion is the CallTarget for a type conversion (cast). -class TypeConversion final : public Castable { +/// ValueConversion is the CallTarget for a value conversion (cast). +class ValueConversion final : public Castable { public: /// Constructor /// @param type the target type of the cast /// @param parameter the type cast parameter /// @param stage the earliest evaluation stage for the expression - TypeConversion(const type::Type* type, const sem::Parameter* parameter, EvaluationStage stage); + ValueConversion(const type::Type* type, const sem::Parameter* parameter, EvaluationStage stage); /// Destructor - ~TypeConversion() override; + ~ValueConversion() override; /// @returns the cast source type const type::Type* Source() const { return Parameters()[0]->Type(); } @@ -40,4 +40,4 @@ class TypeConversion final : public Castable { } // namespace tint::sem -#endif // SRC_TINT_SEM_TYPE_CONVERSION_H_ +#endif // SRC_TINT_SEM_VALUE_CONVERSION_H_ diff --git a/src/tint/transform/decompose_strided_array.cc b/src/tint/transform/decompose_strided_array.cc index e92b85e16b..838948e1a6 100644 --- a/src/tint/transform/decompose_strided_array.cc +++ b/src/tint/transform/decompose_strided_array.cc @@ -22,7 +22,7 @@ #include "src/tint/sem/call.h" #include "src/tint/sem/member_accessor_expression.h" #include "src/tint/sem/type_expression.h" -#include "src/tint/sem/type_initializer.h" +#include "src/tint/sem/value_constructor.h" #include "src/tint/sem/value_expression.h" #include "src/tint/transform/simplify_pointers.h" #include "src/tint/utils/hash.h" @@ -134,18 +134,16 @@ Transform::ApplyResult DecomposeStridedArray::Apply(const Program* src, return nullptr; }); - // Find all array type initializer expressions for array types that have had - // their element changed to a single field structure. These initializers are - // adjusted to wrap each of the arguments with an additional initializer for - // the new element structure type. - // Example: + // Find all constructor expressions for array types that have had their element changed to a + // single field structure. These constructors are adjusted to wrap each of the arguments with an + // additional initializer for the new element structure type. Example: // `@stride(32) array(1, 2, 3)` // -> // `array(strided_arr(1), strided_arr(2), strided_arr(3))` ctx.ReplaceAll([&](const ast::CallExpression* expr) -> const ast::Expression* { if (!expr->args.IsEmpty()) { if (auto* call = sem.Get(expr)->UnwrapMaterialize()->As()) { - if (auto* ctor = call->Target()->As()) { + if (auto* ctor = call->Target()->As()) { if (auto* arr = ctor->ReturnType()->As()) { // Begin by cloning the array initializer type or name // If this is an unaliased array, this may add a new entry to diff --git a/src/tint/transform/pad_structs.cc b/src/tint/transform/pad_structs.cc index eef67eb49c..79bc63158b 100644 --- a/src/tint/transform/pad_structs.cc +++ b/src/tint/transform/pad_structs.cc @@ -22,7 +22,7 @@ #include "src/tint/program_builder.h" #include "src/tint/sem/call.h" #include "src/tint/sem/module.h" -#include "src/tint/sem/type_initializer.h" +#include "src/tint/sem/value_constructor.h" using namespace tint::number_suffixes; // NOLINT @@ -114,7 +114,7 @@ Transform::ApplyResult PadStructs::Apply(const Program* src, const DataMap&, Dat if (!call) { return nullptr; } - auto* cons = call->Target()->As(); + auto* cons = call->Target()->As(); if (!cons) { return nullptr; } diff --git a/src/tint/transform/promote_initializers_to_let.cc b/src/tint/transform/promote_initializers_to_let.cc index 7bc7d51ea9..e201f11b87 100644 --- a/src/tint/transform/promote_initializers_to_let.cc +++ b/src/tint/transform/promote_initializers_to_let.cc @@ -20,7 +20,7 @@ #include "src/tint/program_builder.h" #include "src/tint/sem/call.h" #include "src/tint/sem/statement.h" -#include "src/tint/sem/type_initializer.h" +#include "src/tint/sem/value_constructor.h" #include "src/tint/transform/utils/hoist_to_decl_before.h" #include "src/tint/type/struct.h" #include "src/tint/utils/hashset.h" @@ -58,8 +58,8 @@ Transform::ApplyResult PromoteInitializersToLet::Apply(const Program* src, } auto* ctor = root_expr->UnwrapMaterialize()->As(); - if (!ctor || !ctor->Target()->Is()) { - // Root expression is not a type constructor. Not interested in this. + if (!ctor || !ctor->Target()->Is()) { + // Root expression is not a value constructor. Not interested in this. return false; } } diff --git a/src/tint/transform/remove_phonies.cc b/src/tint/transform/remove_phonies.cc index 6131892a2e..b6d877da04 100644 --- a/src/tint/transform/remove_phonies.cc +++ b/src/tint/transform/remove_phonies.cc @@ -61,8 +61,8 @@ Transform::ApplyResult RemovePhonies::Apply(const Program* src, const DataMap&, if (!ast::TraverseExpressions( stmt->rhs, b.Diagnostics(), [&](const ast::CallExpression* expr) { // ast::CallExpression may map to a function or builtin call - // (both may have side-effects), or a type initializer or - // type conversion (both do not have side effects). + // (both may have side-effects), or a value constructor or value + // conversion (both do not have side effects). auto* call = sem.Get(expr); if (!call) { // Semantic node must be a Materialize, in which case the diff --git a/src/tint/transform/renamer.cc b/src/tint/transform/renamer.cc index f2aea29a07..3ddb6c6472 100644 --- a/src/tint/transform/renamer.cc +++ b/src/tint/transform/renamer.cc @@ -21,9 +21,9 @@ #include "src/tint/sem/builtin_enum_expression.h" #include "src/tint/sem/call.h" #include "src/tint/sem/member_accessor_expression.h" -#include "src/tint/sem/type_conversion.h" #include "src/tint/sem/type_expression.h" -#include "src/tint/sem/type_initializer.h" +#include "src/tint/sem/value_constructor.h" +#include "src/tint/sem/value_conversion.h" #include "src/tint/text/unicode.h" TINT_INSTANTIATE_TYPEINFO(tint::transform::Renamer); @@ -1309,10 +1309,10 @@ Transform::ApplyResult Renamer::Apply(const Program* src, [&](const sem::Builtin*) { preserved_identifiers.Add(call->target->identifier); }, - [&](const sem::TypeConversion*) { + [&](const sem::ValueConversion*) { preserve_if_builtin_type(call->target->identifier); }, - [&](const sem::TypeInitializer*) { + [&](const sem::ValueConstructor*) { preserve_if_builtin_type(call->target->identifier); }); }); diff --git a/src/tint/transform/renamer_test.cc b/src/tint/transform/renamer_test.cc index 4e9e7c6872..8ff6898424 100644 --- a/src/tint/transform/renamer_test.cc +++ b/src/tint/transform/renamer_test.cc @@ -1792,7 +1792,7 @@ fn tint_symbol() { TEST_P(RenamerBuiltinTypeTest, PreserveTypeConversion) { if (std::string_view(GetParam()) == "array") { - return; // Cannot type convert arrays. + return; // Cannot value convert arrays. } auto expand = [&](const char* source) { diff --git a/src/tint/transform/vectorize_matrix_conversions.cc b/src/tint/transform/vectorize_matrix_conversions.cc index e920417090..748346e03b 100644 --- a/src/tint/transform/vectorize_matrix_conversions.cc +++ b/src/tint/transform/vectorize_matrix_conversions.cc @@ -20,7 +20,7 @@ #include "src/tint/program_builder.h" #include "src/tint/sem/call.h" -#include "src/tint/sem/type_conversion.h" +#include "src/tint/sem/value_conversion.h" #include "src/tint/sem/value_expression.h" #include "src/tint/type/abstract_numeric.h" #include "src/tint/utils/hash.h" @@ -36,7 +36,8 @@ bool ShouldRun(const Program* program) { for (auto* node : program->ASTNodes().Objects()) { if (auto* sem = program->Sem().GetVal(node)) { if (auto* call = sem->UnwrapMaterialize()->As()) { - if (call->Target()->Is() && call->Type()->Is()) { + if (call->Target()->Is() && + call->Type()->Is()) { auto& args = call->Arguments(); if (args.Length() == 1 && args[0]->Type()->UnwrapRef()->is_float_matrix()) { return true; @@ -71,7 +72,7 @@ Transform::ApplyResult VectorizeMatrixConversions::Apply(const Program* src, ctx.ReplaceAll([&](const ast::CallExpression* expr) -> const ast::CallExpression* { auto* call = src->Sem().Get(expr)->UnwrapMaterialize()->As(); - auto* ty_conv = call->Target()->As(); + auto* ty_conv = call->Target()->As(); if (!ty_conv) { return nullptr; } diff --git a/src/tint/transform/vectorize_scalar_matrix_initializers.cc b/src/tint/transform/vectorize_scalar_matrix_initializers.cc index 5c58280372..e35cfb3fa1 100644 --- a/src/tint/transform/vectorize_scalar_matrix_initializers.cc +++ b/src/tint/transform/vectorize_scalar_matrix_initializers.cc @@ -19,7 +19,7 @@ #include "src/tint/program_builder.h" #include "src/tint/sem/call.h" -#include "src/tint/sem/type_initializer.h" +#include "src/tint/sem/value_constructor.h" #include "src/tint/sem/value_expression.h" #include "src/tint/type/abstract_numeric.h" #include "src/tint/utils/map.h" @@ -32,7 +32,7 @@ namespace { bool ShouldRun(const Program* program) { for (auto* node : program->ASTNodes().Objects()) { if (auto* call = program->Sem().Get(node)) { - if (call->Target()->Is() && call->Type()->Is()) { + if (call->Target()->Is() && call->Type()->Is()) { auto& args = call->Arguments(); if (!args.IsEmpty() && args[0]->Type()->UnwrapRef()->is_scalar()) { return true; @@ -63,7 +63,7 @@ Transform::ApplyResult VectorizeScalarMatrixInitializers::Apply(const Program* s ctx.ReplaceAll([&](const ast::CallExpression* expr) -> const ast::CallExpression* { auto* call = src->Sem().Get(expr)->UnwrapMaterialize()->As(); - auto* ty_init = call->Target()->As(); + auto* ty_init = call->Target()->As(); if (!ty_init) { return nullptr; } diff --git a/src/tint/transform/zero_init_workgroup_memory.cc b/src/tint/transform/zero_init_workgroup_memory.cc index 7dafc0644c..9040e09b3d 100644 --- a/src/tint/transform/zero_init_workgroup_memory.cc +++ b/src/tint/transform/zero_init_workgroup_memory.cc @@ -436,9 +436,8 @@ struct ZeroInitWorkgroupMemory::State { } /// @returns true if a variable with store type `ty` can be efficiently zeroed - /// by assignment of a type initializer without operands. If - /// CanTriviallyZero() returns false, then the type needs to be - /// initialized by decomposing the initialization into multiple + /// by assignment of a value constructor without operands. If CanTriviallyZero() returns false, + /// then the type needs to be initialized by decomposing the initialization into multiple /// sub-initializations. /// @param ty the type to inspect bool CanTriviallyZero(const type::Type* ty) { diff --git a/src/tint/utils/block_allocator.h b/src/tint/utils/block_allocator.h index e75a0c6691..b1465cb8cf 100644 --- a/src/tint/utils/block_allocator.h +++ b/src/tint/utils/block_allocator.h @@ -210,7 +210,7 @@ class BlockAllocator { /// Creates a new `TYPE` owned by the BlockAllocator. /// When the BlockAllocator is destructed the object will be destructed and freed. - /// @param args the arguments to pass to the type constructor + /// @param args the arguments to pass to the constructor /// @returns the pointer to the constructed object template TYPE* Create(ARGS&&... args) { diff --git a/src/tint/writer/append_vector.cc b/src/tint/writer/append_vector.cc index c212378be1..c31667d5b5 100644 --- a/src/tint/writer/append_vector.cc +++ b/src/tint/writer/append_vector.cc @@ -18,8 +18,8 @@ #include #include "src/tint/sem/call.h" -#include "src/tint/sem/type_conversion.h" -#include "src/tint/sem/type_initializer.h" +#include "src/tint/sem/value_constructor.h" +#include "src/tint/sem/value_conversion.h" #include "src/tint/sem/value_expression.h" #include "src/tint/utils/transform.h" @@ -28,14 +28,14 @@ using namespace tint::number_suffixes; // NOLINT namespace tint::writer { namespace { -struct VectorInitializerInfo { +struct VectorConstructorInfo { const sem::Call* call = nullptr; - const sem::TypeInitializer* ctor = nullptr; + const sem::ValueConstructor* ctor = nullptr; operator bool() const { return call != nullptr; } }; -VectorInitializerInfo AsVectorInitializer(const sem::ValueExpression* expr) { +VectorConstructorInfo AsVectorConstructor(const sem::ValueExpression* expr) { if (auto* call = expr->As()) { - if (auto* ctor = call->Target()->As()) { + if (auto* ctor = call->Target()->As()) { if (ctor->ReturnType()->Is()) { return {call, ctor}; } @@ -103,20 +103,20 @@ const sem::Call* AppendVector(ProgramBuilder* b, auto packed_ast_ty = b->ty.vec(packed_el_ast_ty, packed_size); auto* packed_sem_ty = b->create(packed_el_sem_ty, packed_size); - // If the coordinates are already passed in a vector initializer, with only + // If the coordinates are already passed in a vector constructor, with only // scalar components supplied, extract the elements into the new vector // instead of nesting a vector-in-vector. - // If the coordinates are a zero-initializer of the vector, then expand that + // If the coordinates are a zero-constructor of the vector, then expand that // to scalar zeros. - // The other cases for a nested vector initializer are when it is used + // The other cases for a nested vector constructor are when it is used // to convert a vector of a different type, e.g. vec2(vec2()). // In that case, preserve the original argument, or you'll get a type error. utils::Vector packed; - if (auto vc = AsVectorInitializer(vector_sem)) { + if (auto vc = AsVectorConstructor(vector_sem)) { const auto num_supplied = vc.call->Arguments().Length(); if (num_supplied == 0) { - // Zero-value vector initializer. Populate with zeros + // Zero-value vector constructor. Populate with zeros for (uint32_t i = 0; i < packed_size - 1; i++) { auto* zero = Zero(*b, packed_el_sem_ty, statement); packed.Push(zero); @@ -134,7 +134,7 @@ const sem::Call* AppendVector(ProgramBuilder* b, if (packed_el_sem_ty != scalar_sem->Type()->UnwrapRef()) { // Cast scalar to the vector element type auto* scalar_cast_ast = b->Call(packed_el_ast_ty, scalar_ast); - auto* scalar_cast_target = b->create( + auto* scalar_cast_target = b->create( packed_el_sem_ty, b->create(nullptr, 0u, scalar_sem->Type()->UnwrapRef(), builtin::AddressSpace::kUndefined, @@ -150,11 +150,11 @@ const sem::Call* AppendVector(ProgramBuilder* b, packed.Push(scalar_sem); } - auto* initializer_ast = + auto* ctor_ast = b->Call(packed_ast_ty, utils::Transform(packed, [&](const sem::ValueExpression* expr) { return expr->Declaration(); })); - auto* initializer_target = b->create( + auto* ctor_target = b->create( packed_sem_ty, utils::Transform( packed, @@ -164,13 +164,12 @@ const sem::Call* AppendVector(ProgramBuilder* b, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined); }), sem::EvaluationStage::kRuntime); - auto* initializer_sem = - b->create(initializer_ast, initializer_target, sem::EvaluationStage::kRuntime, - std::move(packed), statement, - /* constant_value */ nullptr, - /* has_side_effects */ false); - b->Sem().Add(initializer_ast, initializer_sem); - return initializer_sem; + auto* ctor_sem = b->create(ctor_ast, ctor_target, sem::EvaluationStage::kRuntime, + std::move(packed), statement, + /* constant_value */ nullptr, + /* has_side_effects */ false); + b->Sem().Add(ctor_ast, ctor_sem); + return ctor_sem; } } // namespace tint::writer diff --git a/src/tint/writer/append_vector.h b/src/tint/writer/append_vector.h index 91be10b953..0528c528e4 100644 --- a/src/tint/writer/append_vector.h +++ b/src/tint/writer/append_vector.h @@ -30,7 +30,7 @@ namespace tint::writer { /// A helper function used to append a vector with an additional scalar. /// If the scalar's type does not match the target vector element type, -/// then it is value-converted (via TypeInitializer) before being added. +/// then it is value-converted (via ValueConstructor) before being added. /// All types must have been assigned to the expressions and their child nodes /// before calling. /// @param builder the program builder. diff --git a/src/tint/writer/append_vector_test.cc b/src/tint/writer/append_vector_test.cc index 8f2491684d..0303c3c08c 100644 --- a/src/tint/writer/append_vector_test.cc +++ b/src/tint/writer/append_vector_test.cc @@ -16,7 +16,7 @@ #include "src/tint/ast/test_helper.h" #include "src/tint/program_builder.h" #include "src/tint/resolver/resolver.h" -#include "src/tint/sem/type_initializer.h" +#include "src/tint/sem/value_constructor.h" #include "gtest/gtest.h" @@ -54,7 +54,7 @@ TEST_F(AppendVectorTest, Vec2i32_i32) { EXPECT_EQ(call->Arguments()[1], Sem().Get(scalar_2)); EXPECT_EQ(call->Arguments()[2], Sem().Get(scalar_3)); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); ASSERT_TRUE(ctor->ReturnType()->Is()); EXPECT_EQ(ctor->ReturnType()->As()->Width(), 3u); @@ -99,7 +99,7 @@ TEST_F(AppendVectorTest, Vec2i32_u32) { EXPECT_EQ(call->Arguments()[1], Sem().Get(scalar_2)); EXPECT_EQ(call->Arguments()[2], Sem().Get(u32_to_i32)); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); ASSERT_TRUE(ctor->ReturnType()->Is()); EXPECT_EQ(ctor->ReturnType()->As()->Width(), 3u); @@ -149,7 +149,7 @@ TEST_F(AppendVectorTest, Vec2i32FromVec2u32_u32) { EXPECT_EQ(call->Arguments()[0], Sem().Get(vec_12)); EXPECT_EQ(call->Arguments()[1], Sem().Get(u32_to_i32)); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); ASSERT_TRUE(ctor->ReturnType()->Is()); @@ -193,7 +193,7 @@ TEST_F(AppendVectorTest, Vec2i32_f32) { EXPECT_EQ(call->Arguments()[1], Sem().Get(scalar_2)); EXPECT_EQ(call->Arguments()[2], Sem().Get(f32_to_i32)); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); ASSERT_TRUE(ctor->ReturnType()->Is()); EXPECT_EQ(ctor->ReturnType()->As()->Width(), 3u); @@ -236,7 +236,7 @@ TEST_F(AppendVectorTest, Vec3i32_i32) { EXPECT_EQ(call->Arguments()[2], Sem().Get(scalar_3)); EXPECT_EQ(call->Arguments()[3], Sem().Get(scalar_4)); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); ASSERT_TRUE(ctor->ReturnType()->Is()); EXPECT_EQ(ctor->ReturnType()->As()->Width(), 4u); @@ -274,7 +274,7 @@ TEST_F(AppendVectorTest, Vec2i32Var_i32) { EXPECT_EQ(call->Arguments()[0], Sem().Get(vec_12)); EXPECT_EQ(call->Arguments()[1], Sem().Get(scalar_3)); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); ASSERT_TRUE(ctor->ReturnType()->Is()); EXPECT_EQ(ctor->ReturnType()->As()->Width(), 3u); @@ -314,7 +314,7 @@ TEST_F(AppendVectorTest, Vec2i32_i32Var) { EXPECT_EQ(call->Arguments()[1], Sem().Get(scalar_2)); EXPECT_EQ(call->Arguments()[2], Sem().Get(scalar_3)); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); ASSERT_TRUE(ctor->ReturnType()->Is()); EXPECT_EQ(ctor->ReturnType()->As()->Width(), 3u); @@ -352,7 +352,7 @@ TEST_F(AppendVectorTest, Vec2i32Var_i32Var) { EXPECT_EQ(call->Arguments()[0], Sem().Get(vec_12)); EXPECT_EQ(call->Arguments()[1], Sem().Get(scalar_3)); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); ASSERT_TRUE(ctor->ReturnType()->Is()); EXPECT_EQ(ctor->ReturnType()->As()->Width(), 3u); @@ -393,7 +393,7 @@ TEST_F(AppendVectorTest, Vec2i32Var_f32Var) { EXPECT_EQ(call->Arguments()[0], Sem().Get(vec_12)); EXPECT_EQ(call->Arguments()[1], Sem().Get(f32_to_i32)); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); ASSERT_TRUE(ctor->ReturnType()->Is()); EXPECT_EQ(ctor->ReturnType()->As()->Width(), 3u); @@ -430,7 +430,7 @@ TEST_F(AppendVectorTest, Vec2boolVar_boolVar) { EXPECT_EQ(call->Arguments()[0], Sem().Get(vec_12)); EXPECT_EQ(call->Arguments()[1], Sem().Get(scalar_3)); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); ASSERT_TRUE(ctor->ReturnType()->Is()); EXPECT_EQ(ctor->ReturnType()->As()->Width(), 3u); @@ -471,7 +471,7 @@ TEST_F(AppendVectorTest, ZeroVec3i32_i32) { EXPECT_EQ(call->Arguments()[2], Sem().Get(vec_0004->args[2])); EXPECT_EQ(call->Arguments()[3], Sem().Get(scalar)); - auto* ctor = call->Target()->As(); + auto* ctor = call->Target()->As(); ASSERT_NE(ctor, nullptr); ASSERT_TRUE(ctor->ReturnType()->Is()); EXPECT_EQ(ctor->ReturnType()->As()->Width(), 4u); diff --git a/src/tint/writer/glsl/generator_impl.cc b/src/tint/writer/glsl/generator_impl.cc index 147cc570bb..e8b5b9bd08 100644 --- a/src/tint/writer/glsl/generator_impl.cc +++ b/src/tint/writer/glsl/generator_impl.cc @@ -36,8 +36,8 @@ #include "src/tint/sem/statement.h" #include "src/tint/sem/struct.h" #include "src/tint/sem/switch_statement.h" -#include "src/tint/sem/type_conversion.h" -#include "src/tint/sem/type_initializer.h" +#include "src/tint/sem/value_constructor.h" +#include "src/tint/sem/value_conversion.h" #include "src/tint/sem/variable.h" #include "src/tint/transform/add_block_attribute.h" #include "src/tint/transform/add_empty_entry_point.h" @@ -712,8 +712,8 @@ bool GeneratorImpl::EmitCall(std::ostream& out, const ast::CallExpression* expr) call->Target(), // [&](const sem::Function* fn) { return EmitFunctionCall(out, call, fn); }, [&](const sem::Builtin* builtin) { return EmitBuiltinCall(out, call, builtin); }, - [&](const sem::TypeConversion* conv) { return EmitTypeConversion(out, call, conv); }, - [&](const sem::TypeInitializer* init) { return EmitTypeInitializer(out, call, init); }, + [&](const sem::ValueConversion* conv) { return EmitValueConversion(out, call, conv); }, + [&](const sem::ValueConstructor* ctor) { return EmitValueConstructor(out, call, ctor); }, [&](Default) { TINT_ICE(Writer, diagnostics_) << "unhandled call target: " << call->Target()->TypeInfo().name; @@ -827,9 +827,9 @@ bool GeneratorImpl::EmitBuiltinCall(std::ostream& out, return true; } -bool GeneratorImpl::EmitTypeConversion(std::ostream& out, - const sem::Call* call, - const sem::TypeConversion* conv) { +bool GeneratorImpl::EmitValueConversion(std::ostream& out, + const sem::Call* call, + const sem::ValueConversion* conv) { if (!EmitType(out, conv->Target(), builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) { return false; @@ -843,13 +843,13 @@ bool GeneratorImpl::EmitTypeConversion(std::ostream& out, return true; } -bool GeneratorImpl::EmitTypeInitializer(std::ostream& out, - const sem::Call* call, - const sem::TypeInitializer* ctor) { +bool GeneratorImpl::EmitValueConstructor(std::ostream& out, + const sem::Call* call, + const sem::ValueConstructor* ctor) { auto* type = ctor->ReturnType(); - // If the type initializer is empty then we need to construct with the zero - // value for all components. + // If the value constructor is empty then we need to construct with the zero value for all + // components. if (call->Arguments().IsEmpty()) { return EmitZeroValue(out, type); } diff --git a/src/tint/writer/glsl/generator_impl.h b/src/tint/writer/glsl/generator_impl.h index 260852e9e6..d220877077 100644 --- a/src/tint/writer/glsl/generator_impl.h +++ b/src/tint/writer/glsl/generator_impl.h @@ -43,10 +43,10 @@ // Forward declarations namespace tint::sem { -class Call; class Builtin; -class TypeInitializer; -class TypeConversion; +class Call; +class ValueConstructor; +class ValueConversion; } // namespace tint::sem namespace tint::writer::glsl { @@ -160,22 +160,22 @@ class GeneratorImpl : public TextGenerator { /// @param builtin the builtin being called /// @returns true if the expression is emitted bool EmitBuiltinCall(std::ostream& out, const sem::Call* call, const sem::Builtin* builtin); - /// Handles generating a type conversion expression + /// Handles generating a value conversion expression /// @param out the output of the expression stream /// @param call the call expression - /// @param conv the type conversion + /// @param conv the value conversion /// @returns true if the expression is emitted - bool EmitTypeConversion(std::ostream& out, - const sem::Call* call, - const sem::TypeConversion* conv); - /// Handles generating a type initializer expression - /// @param out the output of the expression stream - /// @param call the call expression - /// @param ctor the type initializer - /// @returns true if the expression is emitted - bool EmitTypeInitializer(std::ostream& out, + bool EmitValueConversion(std::ostream& out, const sem::Call* call, - const sem::TypeInitializer* ctor); + const sem::ValueConversion* conv); + /// Handles generating a value constructor expression + /// @param out the output of the expression stream + /// @param call the call expression + /// @param ctor the value constructor + /// @returns true if the expression is emitted + bool EmitValueConstructor(std::ostream& out, + const sem::Call* call, + const sem::ValueConstructor* ctor); /// Handles generating a barrier builtin call /// @param out the output of the expression stream /// @param builtin the semantic information for the barrier builtin diff --git a/src/tint/writer/glsl/generator_impl_initializer_test.cc b/src/tint/writer/glsl/generator_impl_constructor_test.cc similarity index 78% rename from src/tint/writer/glsl/generator_impl_initializer_test.cc rename to src/tint/writer/glsl/generator_impl_constructor_test.cc index d62942d143..2f4b3d0ef8 100644 --- a/src/tint/writer/glsl/generator_impl_initializer_test.cc +++ b/src/tint/writer/glsl/generator_impl_constructor_test.cc @@ -22,9 +22,9 @@ namespace { using ::testing::HasSubstr; -using GlslGeneratorImplTest_Initializer = TestHelper; +using GlslGeneratorImplTest_Constructor = TestHelper; -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Bool) { +TEST_F(GlslGeneratorImplTest_Constructor, Bool) { WrapInFunction(Expr(false)); GeneratorImpl& gen = Build(); @@ -33,7 +33,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Bool) { EXPECT_THAT(gen.result(), HasSubstr("false")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Int) { +TEST_F(GlslGeneratorImplTest_Constructor, Int) { WrapInFunction(Expr(-12345_i)); GeneratorImpl& gen = Build(); @@ -42,7 +42,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Int) { EXPECT_THAT(gen.result(), HasSubstr("-12345")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_UInt) { +TEST_F(GlslGeneratorImplTest_Constructor, UInt) { WrapInFunction(Expr(56779_u)); GeneratorImpl& gen = Build(); @@ -51,7 +51,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_UInt) { EXPECT_THAT(gen.result(), HasSubstr("56779u")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Float) { +TEST_F(GlslGeneratorImplTest_Constructor, Float) { // Use a number close to 1<<30 but whose decimal representation ends in 0. WrapInFunction(Expr(f32((1 << 30) - 4))); @@ -61,7 +61,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Float) { EXPECT_THAT(gen.result(), HasSubstr("1073741824.0f")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_F16) { +TEST_F(GlslGeneratorImplTest_Constructor, F16) { Enable(builtin::Extension::kF16); // Use a number close to 1<<16 but whose decimal representation ends in 0. @@ -73,7 +73,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_F16) { EXPECT_THAT(gen.result(), HasSubstr("32752.0hf")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Float) { +TEST_F(GlslGeneratorImplTest_Constructor, Type_Float) { WrapInFunction(Call(-1.2e-5_f)); GeneratorImpl& gen = Build(); @@ -82,7 +82,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Float) { EXPECT_THAT(gen.result(), HasSubstr("-0.000012f")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_F16) { +TEST_F(GlslGeneratorImplTest_Constructor, Type_F16) { Enable(builtin::Extension::kF16); WrapInFunction(Call(-1.2e-3_h)); @@ -93,7 +93,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_F16) { EXPECT_THAT(gen.result(), HasSubstr("-0.00119972229hf")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Bool) { +TEST_F(GlslGeneratorImplTest_Constructor, Type_Bool) { WrapInFunction(Call(true)); GeneratorImpl& gen = Build(); @@ -102,7 +102,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Bool) { EXPECT_THAT(gen.result(), HasSubstr("true")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Int) { +TEST_F(GlslGeneratorImplTest_Constructor, Type_Int) { WrapInFunction(Call(-12345_i)); GeneratorImpl& gen = Build(); @@ -111,7 +111,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Int) { EXPECT_THAT(gen.result(), HasSubstr("-12345")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Uint) { +TEST_F(GlslGeneratorImplTest_Constructor, Type_Uint) { WrapInFunction(Call(12345_u)); GeneratorImpl& gen = Build(); @@ -120,7 +120,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Uint) { EXPECT_THAT(gen.result(), HasSubstr("12345u")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_F32) { +TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_F32) { WrapInFunction(vec3(1_f, 2_f, 3_f)); GeneratorImpl& gen = Build(); @@ -129,7 +129,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_F32) { EXPECT_THAT(gen.result(), HasSubstr("vec3(1.0f, 2.0f, 3.0f)")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_F16) { +TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_F16) { Enable(builtin::Extension::kF16); WrapInFunction(vec3(1_h, 2_h, 3_h)); @@ -140,7 +140,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_F16) { EXPECT_THAT(gen.result(), HasSubstr("f16vec3(1.0hf, 2.0hf, 3.0hf)")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_Empty_F32) { +TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_Empty_F32) { WrapInFunction(vec3()); GeneratorImpl& gen = Build(); @@ -149,7 +149,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_Empty_F32) { EXPECT_THAT(gen.result(), HasSubstr("vec3(0.0f)")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_Empty_F16) { +TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_Empty_F16) { Enable(builtin::Extension::kF16); WrapInFunction(vec3()); @@ -160,7 +160,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_Empty_F16) { EXPECT_THAT(gen.result(), HasSubstr("f16vec3(0.0hf)")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_SingleScalar_F32_Literal) { +TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F32_Literal) { WrapInFunction(vec3(2_f)); GeneratorImpl& gen = Build(); @@ -169,7 +169,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_SingleScalar_ EXPECT_THAT(gen.result(), HasSubstr("vec3(2.0f)")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_SingleScalar_F16_Literal) { +TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F16_Literal) { Enable(builtin::Extension::kF16); WrapInFunction(vec3(2_h)); @@ -180,7 +180,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_SingleScalar_ EXPECT_THAT(gen.result(), HasSubstr("f16vec3(2.0hf)")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_SingleScalar_F32_Var) { +TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F32_Var) { auto* var = Var("v", Expr(2_f)); auto* cast = vec3(var); WrapInFunction(var, cast); @@ -192,7 +192,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_SingleScalar_ vec3 tint_symbol = vec3(v);)")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_SingleScalar_F16_Var) { +TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F16_Var) { Enable(builtin::Extension::kF16); auto* var = Var("v", Expr(2_h)); @@ -206,7 +206,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_SingleScalar_ f16vec3 tint_symbol = f16vec3(v);)")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_SingleScalar_Bool) { +TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_Bool) { WrapInFunction(vec3(true)); GeneratorImpl& gen = Build(); @@ -215,7 +215,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_SingleScalar_ EXPECT_THAT(gen.result(), HasSubstr("bvec3(true)")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_SingleScalar_Int) { +TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_Int) { WrapInFunction(vec3(2_i)); GeneratorImpl& gen = Build(); @@ -224,7 +224,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_SingleScalar_ EXPECT_THAT(gen.result(), HasSubstr("ivec3(2)")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_SingleScalar_UInt) { +TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_UInt) { WrapInFunction(vec3(2_u)); GeneratorImpl& gen = Build(); @@ -233,7 +233,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_SingleScalar_ EXPECT_THAT(gen.result(), HasSubstr("uvec3(2u)")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_F32) { +TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_F32) { WrapInFunction(mat2x3(vec3(1_f, 2_f, 3_f), vec3(3_f, 4_f, 5_f))); GeneratorImpl& gen = Build(); @@ -243,7 +243,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_F32) { EXPECT_THAT(gen.result(), HasSubstr("mat2x3(vec3(1.0f, 2.0f, 3.0f), vec3(3.0f, 4.0f, 5.0f))")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_F16) { +TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_F16) { Enable(builtin::Extension::kF16); WrapInFunction(mat2x3(vec3(1_h, 2_h, 3_h), vec3(3_h, 4_h, 5_h))); @@ -256,7 +256,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_F16) { HasSubstr("f16mat2x3(f16vec3(1.0hf, 2.0hf, 3.0hf), f16vec3(3.0hf, 4.0hf, 5.0hf))")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_Complex_F32) { +TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_Complex_F32) { // mat4x4( // vec4(2.0f, 3.0f, 4.0f, 8.0f), // vec4(), @@ -270,10 +270,10 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_Complex_F32) auto* vector_identical_init = vec4(vec4(Expr(f32(42.0)), Expr(f32(21.0)), Expr(f32(6.0)), Expr(f32(-5.0)))); - auto* initializer = mat4x4(vector_literal, vector_zero_init, vector_single_scalar_init, - vector_identical_init); + auto* ctor = mat4x4(vector_literal, vector_zero_init, vector_single_scalar_init, + vector_identical_init); - WrapInFunction(initializer); + WrapInFunction(ctor); GeneratorImpl& gen = Build(); @@ -283,7 +283,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_Complex_F32) "vec4(7.0f), vec4(42.0f, 21.0f, 6.0f, -5.0f))")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_Complex_F16) { +TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_Complex_F16) { // mat4x4( // vec4(2.0h, 3.0h, 4.0h, 8.0h), // vec4(), @@ -299,10 +299,10 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_Complex_F16) auto* vector_identical_init = vec4(vec4(Expr(f16(42.0)), Expr(f16(21.0)), Expr(f16(6.0)), Expr(f16(-5.0)))); - auto* initializer = mat4x4(vector_literal, vector_zero_init, vector_single_scalar_init, - vector_identical_init); + auto* ctor = mat4x4(vector_literal, vector_zero_init, vector_single_scalar_init, + vector_identical_init); - WrapInFunction(initializer); + WrapInFunction(ctor); GeneratorImpl& gen = Build(); @@ -313,7 +313,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_Complex_F16) "f16vec4(7.0hf), f16vec4(42.0hf, 21.0hf, 6.0hf, -5.0hf))")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_Empty_F32) { +TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_Empty_F32) { WrapInFunction(mat2x3()); GeneratorImpl& gen = Build(); @@ -323,7 +323,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_Empty_F32) { EXPECT_THAT(gen.result(), HasSubstr("mat2x3 tint_symbol = mat2x3(vec3(0.0f), vec3(0.0f))")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_Empty_F16) { +TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_Empty_F16) { Enable(builtin::Extension::kF16); WrapInFunction(mat2x3()); @@ -336,7 +336,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_Empty_F16) { HasSubstr("f16mat2x3 tint_symbol = f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_Identity_F32) { +TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_Identity_F32) { // fn f() { // var m_1: mat4x4 = mat4x4(); // var m_2: mat4x4 = mat4x4(m_1); @@ -354,7 +354,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_Identity_F32) EXPECT_THAT(gen.result(), HasSubstr("mat4 m_2 = mat4(m_1);")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_Identity_F16) { +TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_Identity_F16) { // fn f() { // var m_1: mat4x4 = mat4x4(); // var m_2: mat4x4 = mat4x4(m_1); @@ -374,7 +374,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_Identity_F16) EXPECT_THAT(gen.result(), HasSubstr("f16mat4 m_2 = f16mat4(m_1);")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Array) { +TEST_F(GlslGeneratorImplTest_Constructor, Type_Array) { WrapInFunction(Call(ty.array(ty.vec3(), 3_u), vec3(1_f, 2_f, 3_f), vec3(4_f, 5_f, 6_f), vec3(7_f, 8_f, 9_f))); @@ -386,7 +386,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Array) { "vec3(7.0f, 8.0f, 9.0f))")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Array_Empty) { +TEST_F(GlslGeneratorImplTest_Constructor, Type_Array_Empty) { WrapInFunction(Call(ty.array(ty.vec3(), 3_u))); GeneratorImpl& gen = Build(); @@ -395,7 +395,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Array_Empty) { EXPECT_THAT(gen.result(), HasSubstr("vec3[3](vec3(0.0f), vec3(0.0f), vec3(0.0f))")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Struct) { +TEST_F(GlslGeneratorImplTest_Constructor, Type_Struct) { auto* str = Structure("S", utils::Vector{ Member("a", ty.i32()), Member("b", ty.f32()), @@ -410,7 +410,7 @@ TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Struct) { EXPECT_THAT(gen.result(), HasSubstr("S(1, 2.0f, ivec3(3, 4, 5))")); } -TEST_F(GlslGeneratorImplTest_Initializer, EmitInitializer_Type_Struct_Empty) { +TEST_F(GlslGeneratorImplTest_Constructor, Type_Struct_Empty) { auto* str = Structure("S", utils::Vector{ Member("a", ty.i32()), Member("b", ty.f32()), diff --git a/src/tint/writer/hlsl/generator_impl.cc b/src/tint/writer/hlsl/generator_impl.cc index dbcd4b61e7..cce8c06597 100644 --- a/src/tint/writer/hlsl/generator_impl.cc +++ b/src/tint/writer/hlsl/generator_impl.cc @@ -37,8 +37,8 @@ #include "src/tint/sem/statement.h" #include "src/tint/sem/struct.h" #include "src/tint/sem/switch_statement.h" -#include "src/tint/sem/type_conversion.h" -#include "src/tint/sem/type_initializer.h" +#include "src/tint/sem/value_constructor.h" +#include "src/tint/sem/value_conversion.h" #include "src/tint/sem/variable.h" #include "src/tint/transform/add_empty_entry_point.h" #include "src/tint/transform/array_length_from_uniform.h" @@ -876,10 +876,11 @@ bool GeneratorImpl::EmitCall(std::ostream& out, const ast::CallExpression* expr) auto* call = builder_.Sem().Get(expr); auto* target = call->Target(); return Switch( - target, [&](const sem::Function* func) { return EmitFunctionCall(out, call, func); }, + target, // + [&](const sem::Function* func) { return EmitFunctionCall(out, call, func); }, [&](const sem::Builtin* builtin) { return EmitBuiltinCall(out, call, builtin); }, - [&](const sem::TypeConversion* conv) { return EmitTypeConversion(out, call, conv); }, - [&](const sem::TypeInitializer* ctor) { return EmitTypeInitializer(out, call, ctor); }, + [&](const sem::ValueConversion* conv) { return EmitValueConversion(out, call, conv); }, + [&](const sem::ValueConstructor* ctor) { return EmitValueConstructor(out, call, ctor); }, [&](Default) { TINT_ICE(Writer, diagnostics_) << "unhandled call target: " << target->TypeInfo().name; return false; @@ -1027,9 +1028,9 @@ bool GeneratorImpl::EmitBuiltinCall(std::ostream& out, return true; } -bool GeneratorImpl::EmitTypeConversion(std::ostream& out, - const sem::Call* call, - const sem::TypeConversion* conv) { +bool GeneratorImpl::EmitValueConversion(std::ostream& out, + const sem::Call* call, + const sem::ValueConversion* conv) { if (!EmitType(out, conv->Target(), builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) { return false; @@ -1044,13 +1045,13 @@ bool GeneratorImpl::EmitTypeConversion(std::ostream& out, return true; } -bool GeneratorImpl::EmitTypeInitializer(std::ostream& out, - const sem::Call* call, - const sem::TypeInitializer* ctor) { +bool GeneratorImpl::EmitValueConstructor(std::ostream& out, + const sem::Call* call, + const sem::ValueConstructor* ctor) { auto* type = call->Type(); - // If the type initializer is empty then we need to construct with the zero - // value for all components. + // If the value constructor arguments are empty then we need to construct with the zero value + // for all components. if (call->Arguments().IsEmpty()) { return EmitZeroValue(out, type); } diff --git a/src/tint/writer/hlsl/generator_impl.h b/src/tint/writer/hlsl/generator_impl.h index abf1fcb9ab..6db120c3ad 100644 --- a/src/tint/writer/hlsl/generator_impl.h +++ b/src/tint/writer/hlsl/generator_impl.h @@ -43,10 +43,10 @@ // Forward declarations namespace tint::sem { -class Call; class Builtin; -class TypeInitializer; -class TypeConversion; +class Call; +class ValueConstructor; +class ValueConversion; } // namespace tint::sem namespace tint::writer::hlsl { @@ -140,22 +140,22 @@ class GeneratorImpl : public TextGenerator { /// @param builtin the builtin being called /// @returns true if the expression is emitted bool EmitBuiltinCall(std::ostream& out, const sem::Call* call, const sem::Builtin* builtin); - /// Handles generating a type conversion expression + /// Handles generating a value conversion expression /// @param out the output of the expression stream /// @param call the call expression - /// @param conv the type conversion + /// @param conv the value conversion /// @returns true if the expression is emitted - bool EmitTypeConversion(std::ostream& out, - const sem::Call* call, - const sem::TypeConversion* conv); - /// Handles generating a type initializer expression - /// @param out the output of the expression stream - /// @param call the call expression - /// @param ctor the type initializer - /// @returns true if the expression is emitted - bool EmitTypeInitializer(std::ostream& out, + bool EmitValueConversion(std::ostream& out, const sem::Call* call, - const sem::TypeInitializer* ctor); + const sem::ValueConversion* conv); + /// Handles generating a value constructor expression + /// @param out the output of the expression stream + /// @param call the call expression + /// @param ctor the value constructor + /// @returns true if the expression is emitted + bool EmitValueConstructor(std::ostream& out, + const sem::Call* call, + const sem::ValueConstructor* ctor); /// Handles generating a call expression to a /// transform::DecomposeMemoryAccess::Intrinsic for a uniform buffer /// @param out the output of the expression stream diff --git a/src/tint/writer/hlsl/generator_impl_initializer_test.cc b/src/tint/writer/hlsl/generator_impl_constructor_test.cc similarity index 80% rename from src/tint/writer/hlsl/generator_impl_initializer_test.cc rename to src/tint/writer/hlsl/generator_impl_constructor_test.cc index ebc206ae4b..6cd264e1c7 100644 --- a/src/tint/writer/hlsl/generator_impl_initializer_test.cc +++ b/src/tint/writer/hlsl/generator_impl_constructor_test.cc @@ -22,9 +22,9 @@ namespace { using ::testing::HasSubstr; -using HlslGeneratorImplTest_Initializer = TestHelper; +using HlslGeneratorImplTest_Constructor = TestHelper; -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Bool) { +TEST_F(HlslGeneratorImplTest_Constructor, Bool) { WrapInFunction(Expr(false)); GeneratorImpl& gen = Build(); @@ -33,7 +33,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Bool) { EXPECT_THAT(gen.result(), HasSubstr("false")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Int) { +TEST_F(HlslGeneratorImplTest_Constructor, Int) { WrapInFunction(Expr(-12345_i)); GeneratorImpl& gen = Build(); @@ -42,7 +42,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Int) { EXPECT_THAT(gen.result(), HasSubstr("-12345")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_UInt) { +TEST_F(HlslGeneratorImplTest_Constructor, UInt) { WrapInFunction(Expr(56779_u)); GeneratorImpl& gen = Build(); @@ -51,7 +51,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_UInt) { EXPECT_THAT(gen.result(), HasSubstr("56779u")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Float) { +TEST_F(HlslGeneratorImplTest_Constructor, Float) { // Use a number close to 1<<30 but whose decimal representation ends in 0. WrapInFunction(Expr(f32((1 << 30) - 4))); @@ -61,7 +61,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Float) { EXPECT_THAT(gen.result(), HasSubstr("1073741824.0f")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_F16) { +TEST_F(HlslGeneratorImplTest_Constructor, F16) { Enable(builtin::Extension::kF16); // Use a number close to 1<<16 but whose decimal representation ends in 0. @@ -73,7 +73,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_F16) { EXPECT_THAT(gen.result(), HasSubstr("float16_t(32752.0h)")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Float) { +TEST_F(HlslGeneratorImplTest_Constructor, Type_Float) { WrapInFunction(Call(-1.2e-5_f)); GeneratorImpl& gen = Build(); @@ -82,7 +82,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Float) { EXPECT_THAT(gen.result(), HasSubstr("-0.000012f")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_F16) { +TEST_F(HlslGeneratorImplTest_Constructor, Type_F16) { Enable(builtin::Extension::kF16); WrapInFunction(Call(-1.2e-3_h)); @@ -93,7 +93,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_F16) { EXPECT_THAT(gen.result(), HasSubstr("float16_t(-0.00119972229h)")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Bool) { +TEST_F(HlslGeneratorImplTest_Constructor, Type_Bool) { WrapInFunction(Call(true)); GeneratorImpl& gen = Build(); @@ -102,7 +102,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Bool) { EXPECT_THAT(gen.result(), HasSubstr("true")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Int) { +TEST_F(HlslGeneratorImplTest_Constructor, Type_Int) { WrapInFunction(Call(-12345_i)); GeneratorImpl& gen = Build(); @@ -111,7 +111,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Int) { EXPECT_THAT(gen.result(), HasSubstr("-12345")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Uint) { +TEST_F(HlslGeneratorImplTest_Constructor, Type_Uint) { WrapInFunction(Call(12345_u)); GeneratorImpl& gen = Build(); @@ -120,7 +120,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Uint) { EXPECT_THAT(gen.result(), HasSubstr("12345u")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_F32) { +TEST_F(HlslGeneratorImplTest_Constructor, Type_Vec_F32) { WrapInFunction(vec3(1_f, 2_f, 3_f)); GeneratorImpl& gen = Build(); @@ -129,7 +129,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_F32) { EXPECT_THAT(gen.result(), HasSubstr("float3(1.0f, 2.0f, 3.0f)")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_F16) { +TEST_F(HlslGeneratorImplTest_Constructor, Type_Vec_F16) { Enable(builtin::Extension::kF16); WrapInFunction(vec3(1_h, 2_h, 3_h)); @@ -142,7 +142,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_F16) { HasSubstr("vector(float16_t(1.0h), float16_t(2.0h), float16_t(3.0h))")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_Empty_F32) { +TEST_F(HlslGeneratorImplTest_Constructor, Type_Vec_Empty_F32) { WrapInFunction(vec3()); GeneratorImpl& gen = Build(); @@ -151,7 +151,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_Empty_F32) { EXPECT_THAT(gen.result(), HasSubstr("0.0f).xxx")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_Empty_F16) { +TEST_F(HlslGeneratorImplTest_Constructor, Type_Vec_Empty_F16) { Enable(builtin::Extension::kF16); WrapInFunction(vec3()); @@ -162,7 +162,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_Empty_F16) { EXPECT_THAT(gen.result(), HasSubstr("(float16_t(0.0h)).xxx")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_SingleScalar_F32_Literal) { +TEST_F(HlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F32_Literal) { WrapInFunction(vec3(2_f)); GeneratorImpl& gen = Build(); @@ -171,7 +171,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_SingleScalar_ EXPECT_THAT(gen.result(), HasSubstr("2.0f).xxx")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_SingleScalar_F16_Literal) { +TEST_F(HlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F16_Literal) { Enable(builtin::Extension::kF16); WrapInFunction(vec3(2_h)); @@ -182,7 +182,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_SingleScalar_ EXPECT_THAT(gen.result(), HasSubstr("(float16_t(2.0h)).xxx")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_SingleScalar_F32_Var) { +TEST_F(HlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F32_Var) { auto* var = Var("v", Expr(2_f)); auto* cast = vec3(var); WrapInFunction(var, cast); @@ -194,7 +194,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_SingleScalar_ const float3 tint_symbol = float3((v).xxx);)")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_SingleScalar_F16_Var) { +TEST_F(HlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F16_Var) { Enable(builtin::Extension::kF16); auto* var = Var("v", Expr(2_h)); @@ -208,7 +208,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_SingleScalar_ const vector tint_symbol = vector((v).xxx);)")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_SingleScalar_Bool_Literal) { +TEST_F(HlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_Bool_Literal) { WrapInFunction(vec3(true)); GeneratorImpl& gen = Build(); @@ -217,7 +217,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_SingleScalar_ EXPECT_THAT(gen.result(), HasSubstr("(true).xxx")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_SingleScalar_Bool_Var) { +TEST_F(HlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_Bool_Var) { auto* var = Var("v", Expr(true)); auto* cast = vec3(var); WrapInFunction(var, cast); @@ -229,7 +229,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_SingleScalar_ const bool3 tint_symbol = bool3((v).xxx);)")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_SingleScalar_Int) { +TEST_F(HlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_Int) { WrapInFunction(vec3(2_i)); GeneratorImpl& gen = Build(); @@ -238,7 +238,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_SingleScalar_ EXPECT_THAT(gen.result(), HasSubstr("2).xxx")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_SingleScalar_UInt) { +TEST_F(HlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_UInt) { WrapInFunction(vec3(2_u)); GeneratorImpl& gen = Build(); @@ -247,7 +247,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Vec_SingleScalar_ EXPECT_THAT(gen.result(), HasSubstr("2u).xxx")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_F32) { +TEST_F(HlslGeneratorImplTest_Constructor, Type_Mat_F32) { WrapInFunction(mat2x3(vec3(1_f, 2_f, 3_f), vec3(3_f, 4_f, 5_f))); GeneratorImpl& gen = Build(); @@ -258,7 +258,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_F32) { HasSubstr("float2x3(float3(1.0f, 2.0f, 3.0f), float3(3.0f, 4.0f, 5.0f))")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_F16) { +TEST_F(HlslGeneratorImplTest_Constructor, Type_Mat_F16) { Enable(builtin::Extension::kF16); WrapInFunction(mat2x3(vec3(1_h, 2_h, 3_h), vec3(3_h, 4_h, 5_h))); @@ -273,7 +273,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_F16) { "3>(float16_t(3.0h), float16_t(4.0h), float16_t(5.0h)))")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_Complex_F32) { +TEST_F(HlslGeneratorImplTest_Constructor, Type_Mat_Complex_F32) { // mat4x4( // vec4(2.0f, 3.0f, 4.0f, 8.0f), // vec4(), @@ -287,10 +287,10 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_Complex_F32) auto* vector_identical_init = vec4(vec4(Expr(f32(42.0)), Expr(f32(21.0)), Expr(f32(6.0)), Expr(f32(-5.0)))); - auto* initializer = mat4x4(vector_literal, vector_zero_init, vector_single_scalar_init, + auto* constructor = mat4x4(vector_literal, vector_zero_init, vector_single_scalar_init, vector_identical_init); - WrapInFunction(initializer); + WrapInFunction(constructor); GeneratorImpl& gen = Build(); @@ -300,7 +300,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_Complex_F32) "(7.0f).xxxx, float4(42.0f, 21.0f, 6.0f, -5.0f))")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_Complex_F16) { +TEST_F(HlslGeneratorImplTest_Constructor, Type_Mat_Complex_F16) { // mat4x4( // vec4(2.0h, 3.0h, 4.0h, 8.0h), // vec4(), @@ -316,10 +316,10 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_Complex_F16) auto* vector_identical_init = vec4(vec4(Expr(f16(42.0)), Expr(f16(21.0)), Expr(f16(6.0)), Expr(f16(-5.0)))); - auto* initializer = mat4x4(vector_literal, vector_zero_init, vector_single_scalar_init, + auto* constructor = mat4x4(vector_literal, vector_zero_init, vector_single_scalar_init, vector_identical_init); - WrapInFunction(initializer); + WrapInFunction(constructor); GeneratorImpl& gen = Build(); @@ -333,7 +333,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_Complex_F16) "float16_t(6.0h), float16_t(-5.0h)))")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_Empty_F32) { +TEST_F(HlslGeneratorImplTest_Constructor, Type_Mat_Empty_F32) { WrapInFunction(mat2x3()); GeneratorImpl& gen = Build(); @@ -343,7 +343,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_Empty_F32) { EXPECT_THAT(gen.result(), HasSubstr("float2x3 tint_symbol = float2x3((0.0f).xxx, (0.0f).xxx)")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_Empty_F16) { +TEST_F(HlslGeneratorImplTest_Constructor, Type_Mat_Empty_F16) { Enable(builtin::Extension::kF16); WrapInFunction(mat2x3()); @@ -356,7 +356,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_Empty_F16) { HasSubstr("matrix((float16_t(0.0h)).xxx, (float16_t(0.0h)).xxx)")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_Identity_F32) { +TEST_F(HlslGeneratorImplTest_Constructor, Type_Mat_Identity_F32) { // fn f() { // var m_1: mat4x4 = mat4x4(); // var m_2: mat4x4 = mat4x4(m_1); @@ -374,7 +374,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_Identity_F32) EXPECT_THAT(gen.result(), HasSubstr("float4x4 m_2 = float4x4(m_1);")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_Identity_F16) { +TEST_F(HlslGeneratorImplTest_Constructor, Type_Mat_Identity_F16) { // fn f() { // var m_1: mat4x4 = mat4x4(); // var m_2: mat4x4 = mat4x4(m_1); @@ -395,7 +395,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Mat_Identity_F16) HasSubstr("matrix m_2 = matrix(m_1);")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Array) { +TEST_F(HlslGeneratorImplTest_Constructor, Type_Array) { WrapInFunction(Call(ty.array(ty.vec3(), 3_u), vec3(1_f, 2_f, 3_f), vec3(4_f, 5_f, 6_f), vec3(7_f, 8_f, 9_f))); @@ -406,7 +406,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Array) { " float3(7.0f, 8.0f, 9.0f)}")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Array_Empty) { +TEST_F(HlslGeneratorImplTest_Constructor, Type_Array_Empty) { WrapInFunction(Call(ty.array(ty.vec3(), 3_u))); GeneratorImpl& gen = Build(); @@ -415,7 +415,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Array_Empty) { EXPECT_THAT(gen.result(), HasSubstr("(float3[3])0")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Struct) { +TEST_F(HlslGeneratorImplTest_Constructor, Type_Struct) { auto* str = Structure("S", utils::Vector{ Member("a", ty.i32()), Member("b", ty.f32()), @@ -430,7 +430,7 @@ TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Struct) { EXPECT_THAT(gen.result(), HasSubstr("{1, 2.0f, int3(3, 4, 5)}")); } -TEST_F(HlslGeneratorImplTest_Initializer, EmitInitializer_Type_Struct_Empty) { +TEST_F(HlslGeneratorImplTest_Constructor, Type_Struct_Empty) { auto* str = Structure("S", utils::Vector{ Member("a", ty.i32()), Member("b", ty.f32()), diff --git a/src/tint/writer/msl/generator_impl.cc b/src/tint/writer/msl/generator_impl.cc index d401cd2f3c..c4332073da 100644 --- a/src/tint/writer/msl/generator_impl.cc +++ b/src/tint/writer/msl/generator_impl.cc @@ -37,8 +37,8 @@ #include "src/tint/sem/module.h" #include "src/tint/sem/struct.h" #include "src/tint/sem/switch_statement.h" -#include "src/tint/sem/type_conversion.h" -#include "src/tint/sem/type_initializer.h" +#include "src/tint/sem/value_constructor.h" +#include "src/tint/sem/value_conversion.h" #include "src/tint/sem/variable.h" #include "src/tint/transform/array_length_from_uniform.h" #include "src/tint/transform/builtin_polyfill.h" @@ -640,8 +640,8 @@ bool GeneratorImpl::EmitCall(std::ostream& out, const ast::CallExpression* expr) return Switch( target, [&](const sem::Function* func) { return EmitFunctionCall(out, call, func); }, [&](const sem::Builtin* builtin) { return EmitBuiltinCall(out, call, builtin); }, - [&](const sem::TypeConversion* conv) { return EmitTypeConversion(out, call, conv); }, - [&](const sem::TypeInitializer* ctor) { return EmitTypeInitializer(out, call, ctor); }, + [&](const sem::ValueConversion* conv) { return EmitTypeConversion(out, call, conv); }, + [&](const sem::ValueConstructor* ctor) { return EmitTypeInitializer(out, call, ctor); }, [&](Default) { TINT_ICE(Writer, diagnostics_) << "unhandled call target: " << target->TypeInfo().name; return false; @@ -785,7 +785,7 @@ bool GeneratorImpl::EmitBuiltinCall(std::ostream& out, bool GeneratorImpl::EmitTypeConversion(std::ostream& out, const sem::Call* call, - const sem::TypeConversion* conv) { + const sem::ValueConversion* conv) { if (!EmitType(out, conv->Target(), "")) { return false; } @@ -801,7 +801,7 @@ bool GeneratorImpl::EmitTypeConversion(std::ostream& out, bool GeneratorImpl::EmitTypeInitializer(std::ostream& out, const sem::Call* call, - const sem::TypeInitializer* ctor) { + const sem::ValueConstructor* ctor) { auto* type = ctor->ReturnType(); const char* terminator = ")"; diff --git a/src/tint/writer/msl/generator_impl.h b/src/tint/writer/msl/generator_impl.h index 57c129b195..9c7c0d4938 100644 --- a/src/tint/writer/msl/generator_impl.h +++ b/src/tint/writer/msl/generator_impl.h @@ -46,10 +46,10 @@ // Forward declarations namespace tint::sem { -class Call; class Builtin; -class TypeInitializer; -class TypeConversion; +class Call; +class ValueConstructor; +class ValueConversion; } // namespace tint::sem namespace tint::writer::msl { @@ -144,22 +144,22 @@ class GeneratorImpl : public TextGenerator { /// @param builtin the builtin being called /// @returns true if the call expression is emitted bool EmitBuiltinCall(std::ostream& out, const sem::Call* call, const sem::Builtin* builtin); - /// Handles generating a type conversion expression + /// Handles generating a value conversion expression /// @param out the output of the expression stream /// @param call the call expression - /// @param conv the type conversion + /// @param conv the value conversion /// @returns true if the expression is emitted bool EmitTypeConversion(std::ostream& out, const sem::Call* call, - const sem::TypeConversion* conv); - /// Handles generating a type initializer + const sem::ValueConversion* conv); + /// Handles generating a value constructor /// @param out the output of the expression stream /// @param call the call expression - /// @param ctor the type initializer + /// @param ctor the value constructor /// @returns true if the initializer is emitted bool EmitTypeInitializer(std::ostream& out, const sem::Call* call, - const sem::TypeInitializer* ctor); + const sem::ValueConstructor* ctor); /// Handles generating a function call /// @param out the output of the expression stream /// @param call the call expression diff --git a/src/tint/writer/msl/generator_impl_initializer_test.cc b/src/tint/writer/msl/generator_impl_constructor_test.cc similarity index 82% rename from src/tint/writer/msl/generator_impl_initializer_test.cc rename to src/tint/writer/msl/generator_impl_constructor_test.cc index fbd1def306..ba567ab5c6 100644 --- a/src/tint/writer/msl/generator_impl_initializer_test.cc +++ b/src/tint/writer/msl/generator_impl_constructor_test.cc @@ -22,9 +22,9 @@ namespace { using ::testing::HasSubstr; -using MslGeneratorImplTest = TestHelper; +using MslGeneratorImplTest_Constructor = TestHelper; -TEST_F(MslGeneratorImplTest, EmitInitializer_Bool) { +TEST_F(MslGeneratorImplTest_Constructor, Bool) { WrapInFunction(Expr(false)); GeneratorImpl& gen = Build(); @@ -33,7 +33,7 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_Bool) { EXPECT_THAT(gen.result(), HasSubstr("false")); } -TEST_F(MslGeneratorImplTest, EmitInitializer_Int) { +TEST_F(MslGeneratorImplTest_Constructor, Int) { WrapInFunction(Expr(-12345_i)); GeneratorImpl& gen = Build(); @@ -42,7 +42,7 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_Int) { EXPECT_THAT(gen.result(), HasSubstr("-12345")); } -TEST_F(MslGeneratorImplTest, EmitInitializer_UInt) { +TEST_F(MslGeneratorImplTest_Constructor, UInt) { WrapInFunction(Expr(56779_u)); GeneratorImpl& gen = Build(); @@ -51,7 +51,7 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_UInt) { EXPECT_THAT(gen.result(), HasSubstr("56779u")); } -TEST_F(MslGeneratorImplTest, EmitInitializer_Float) { +TEST_F(MslGeneratorImplTest_Constructor, Float) { // Use a number close to 1<<30 but whose decimal representation ends in 0. WrapInFunction(Expr(f32((1 << 30) - 4))); @@ -61,7 +61,7 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_Float) { EXPECT_THAT(gen.result(), HasSubstr("1073741824.0f")); } -TEST_F(MslGeneratorImplTest, EmitInitializer_F16) { +TEST_F(MslGeneratorImplTest_Constructor, F16) { Enable(builtin::Extension::kF16); // Use a number close to 1<<16 but whose decimal representation ends in 0. @@ -73,7 +73,7 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_F16) { EXPECT_THAT(gen.result(), HasSubstr("32752.0h")); } -TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Float) { +TEST_F(MslGeneratorImplTest_Constructor, Type_Float) { WrapInFunction(Call(-1.2e-5_f)); GeneratorImpl& gen = Build(); @@ -82,7 +82,7 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Float) { EXPECT_THAT(gen.result(), HasSubstr("-0.000012f")); } -TEST_F(MslGeneratorImplTest, EmitInitializer_Type_F16) { +TEST_F(MslGeneratorImplTest_Constructor, Type_F16) { Enable(builtin::Extension::kF16); WrapInFunction(Call(-1.2e-3_h)); @@ -93,7 +93,7 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_Type_F16) { EXPECT_THAT(gen.result(), HasSubstr("-0.00119972229h")); } -TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Bool) { +TEST_F(MslGeneratorImplTest_Constructor, Type_Bool) { WrapInFunction(Call(true)); GeneratorImpl& gen = Build(); @@ -102,7 +102,7 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Bool) { EXPECT_THAT(gen.result(), HasSubstr("true")); } -TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Int) { +TEST_F(MslGeneratorImplTest_Constructor, Type_Int) { WrapInFunction(Call(-12345_i)); GeneratorImpl& gen = Build(); @@ -111,7 +111,7 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Int) { EXPECT_THAT(gen.result(), HasSubstr("-12345")); } -TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Uint) { +TEST_F(MslGeneratorImplTest_Constructor, Type_Uint) { WrapInFunction(Call(12345_u)); GeneratorImpl& gen = Build(); @@ -120,7 +120,7 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Uint) { EXPECT_THAT(gen.result(), HasSubstr("12345u")); } -TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Vec_F32) { +TEST_F(MslGeneratorImplTest_Constructor, Type_Vec_F32) { WrapInFunction(vec3(1_f, 2_f, 3_f)); GeneratorImpl& gen = Build(); @@ -129,7 +129,7 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Vec_F32) { EXPECT_THAT(gen.result(), HasSubstr("float3(1.0f, 2.0f, 3.0f)")); } -TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Vec_F16) { +TEST_F(MslGeneratorImplTest_Constructor, Type_Vec_F16) { Enable(builtin::Extension::kF16); WrapInFunction(vec3(1_h, 2_h, 3_h)); @@ -140,7 +140,7 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Vec_F16) { EXPECT_THAT(gen.result(), HasSubstr("half3(1.0h, 2.0h, 3.0h)")); } -TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Vec_Empty_F32) { +TEST_F(MslGeneratorImplTest_Constructor, Type_Vec_Empty_F32) { WrapInFunction(vec3()); GeneratorImpl& gen = Build(); @@ -149,7 +149,7 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Vec_Empty_F32) { EXPECT_THAT(gen.result(), HasSubstr("float3(0.0f)")); } -TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Vec_Empty_F16) { +TEST_F(MslGeneratorImplTest_Constructor, Type_Vec_Empty_F16) { Enable(builtin::Extension::kF16); WrapInFunction(vec3()); @@ -160,7 +160,7 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Vec_Empty_F16) { EXPECT_THAT(gen.result(), HasSubstr("half3(0.0h)")); } -TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Vec_SingleScalar_F32_Literal) { +TEST_F(MslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F32_Literal) { WrapInFunction(vec3(2_f)); GeneratorImpl& gen = Build(); @@ -169,7 +169,7 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Vec_SingleScalar_F32_Literal) EXPECT_THAT(gen.result(), HasSubstr("float3(2.0f)")); } -TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Vec_SingleScalar_F16_Literal) { +TEST_F(MslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F16_Literal) { Enable(builtin::Extension::kF16); WrapInFunction(vec3(2_h)); @@ -180,7 +180,7 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Vec_SingleScalar_F16_Literal) EXPECT_THAT(gen.result(), HasSubstr("half3(2.0h)")); } -TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Vec_SingleScalar_F32_Var) { +TEST_F(MslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F32_Var) { auto* var = Var("v", Expr(2_f)); auto* cast = vec3(var); WrapInFunction(var, cast); @@ -192,7 +192,7 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Vec_SingleScalar_F32_Var) { float3 const tint_symbol = float3(v);)")); } -TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Vec_SingleScalar_F16_Var) { +TEST_F(MslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F16_Var) { Enable(builtin::Extension::kF16); auto* var = Var("v", Expr(2_h)); @@ -206,7 +206,7 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Vec_SingleScalar_F16_Var) { half3 const tint_symbol = half3(v);)")); } -TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Vec_SingleScalar_Bool) { +TEST_F(MslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_Bool) { WrapInFunction(vec3(true)); GeneratorImpl& gen = Build(); @@ -215,7 +215,7 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Vec_SingleScalar_Bool) { EXPECT_THAT(gen.result(), HasSubstr("bool3(true)")); } -TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Vec_SingleScalar_Int) { +TEST_F(MslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_Int) { WrapInFunction(vec3(2_i)); GeneratorImpl& gen = Build(); @@ -224,7 +224,7 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Vec_SingleScalar_Int) { EXPECT_THAT(gen.result(), HasSubstr("int3(2)")); } -TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Vec_SingleScalar_UInt) { +TEST_F(MslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_UInt) { WrapInFunction(vec3(2_u)); GeneratorImpl& gen = Build(); @@ -233,7 +233,7 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Vec_SingleScalar_UInt) { EXPECT_THAT(gen.result(), HasSubstr("uint3(2u)")); } -TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Mat_F32) { +TEST_F(MslGeneratorImplTest_Constructor, Type_Mat_F32) { WrapInFunction(mat2x3(vec3(1_f, 2_f, 3_f), vec3(3_f, 4_f, 5_f))); GeneratorImpl& gen = Build(); @@ -244,7 +244,7 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Mat_F32) { HasSubstr("float2x3(float3(1.0f, 2.0f, 3.0f), float3(3.0f, 4.0f, 5.0f))")); } -TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Mat_F16) { +TEST_F(MslGeneratorImplTest_Constructor, Type_Mat_F16) { Enable(builtin::Extension::kF16); WrapInFunction(mat2x3(vec3(1_h, 2_h, 3_h), vec3(3_h, 4_h, 5_h))); @@ -257,7 +257,7 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Mat_F16) { HasSubstr("half2x3(half3(1.0h, 2.0h, 3.0h), half3(3.0h, 4.0h, 5.0h))")); } -TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Mat_Complex_F32) { +TEST_F(MslGeneratorImplTest_Constructor, Type_Mat_Complex_F32) { // mat4x4( // vec4(2.0f, 3.0f, 4.0f, 8.0f), // vec4(), @@ -271,10 +271,10 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Mat_Complex_F32) { auto* vector_identical_init = vec4(vec4(Expr(f32(42.0)), Expr(f32(21.0)), Expr(f32(6.0)), Expr(f32(-5.0)))); - auto* initializer = mat4x4(vector_literal, vector_zero_init, vector_single_scalar_init, + auto* constructor = mat4x4(vector_literal, vector_zero_init, vector_single_scalar_init, vector_identical_init); - WrapInFunction(initializer); + WrapInFunction(constructor); GeneratorImpl& gen = Build(); @@ -284,7 +284,7 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Mat_Complex_F32) { "float4(7.0f), float4(42.0f, 21.0f, 6.0f, -5.0f))")); } -TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Mat_Complex_F16) { +TEST_F(MslGeneratorImplTest_Constructor, Type_Mat_Complex_F16) { // mat4x4( // vec4(2.0h, 3.0h, 4.0h, 8.0h), // vec4(), @@ -300,10 +300,10 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Mat_Complex_F16) { auto* vector_identical_init = vec4(vec4(Expr(f16(42.0)), Expr(f16(21.0)), Expr(f16(6.0)), Expr(f16(-5.0)))); - auto* initializer = mat4x4(vector_literal, vector_zero_init, vector_single_scalar_init, + auto* constructor = mat4x4(vector_literal, vector_zero_init, vector_single_scalar_init, vector_identical_init); - WrapInFunction(initializer); + WrapInFunction(constructor); GeneratorImpl& gen = Build(); @@ -313,7 +313,7 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Mat_Complex_F16) { "half4(7.0h), half4(42.0h, 21.0h, 6.0h, -5.0h))")); } -TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Mat_Empty_F32) { +TEST_F(MslGeneratorImplTest_Constructor, Type_Mat_Empty_F32) { WrapInFunction(mat2x3()); GeneratorImpl& gen = Build(); @@ -324,7 +324,7 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Mat_Empty_F32) { HasSubstr("float2x3 const tint_symbol = float2x3(float3(0.0f), float3(0.0f))")); } -TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Mat_Empty_F16) { +TEST_F(MslGeneratorImplTest_Constructor, Type_Mat_Empty_F16) { Enable(builtin::Extension::kF16); WrapInFunction(mat2x3()); @@ -337,7 +337,7 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Mat_Empty_F16) { HasSubstr("half2x3 const tint_symbol = half2x3(half3(0.0h), half3(0.0h))")); } -TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Mat_Identity_F32) { +TEST_F(MslGeneratorImplTest_Constructor, Type_Mat_Identity_F32) { // fn f() { // var m_1: mat4x4 = mat4x4(); // var m_2: mat4x4 = mat4x4(m_1); @@ -355,7 +355,7 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Mat_Identity_F32) { EXPECT_THAT(gen.result(), HasSubstr("float4x4 m_2 = float4x4(m_1);")); } -TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Mat_Identity_F16) { +TEST_F(MslGeneratorImplTest_Constructor, Type_Mat_Identity_F16) { // fn f() { // var m_1: mat4x4 = mat4x4(); // var m_2: mat4x4 = mat4x4(m_1); @@ -375,7 +375,7 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Mat_Identity_F16) { EXPECT_THAT(gen.result(), HasSubstr("half4x4 m_2 = half4x4(m_1);")); } -TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Array) { +TEST_F(MslGeneratorImplTest_Constructor, Type_Array) { WrapInFunction(Call(ty.array(ty.vec3(), 3_u), vec3(1_f, 2_f, 3_f), vec3(4_f, 5_f, 6_f), vec3(7_f, 8_f, 9_f))); @@ -386,7 +386,7 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Array) { "float3(7.0f, 8.0f, 9.0f)}")); } -TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Struct) { +TEST_F(MslGeneratorImplTest_Constructor, Type_Struct) { auto* str = Structure("S", utils::Vector{ Member("a", ty.i32()), Member("b", ty.f32()), @@ -401,7 +401,7 @@ TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Struct) { EXPECT_THAT(gen.result(), HasSubstr("{.a=1, .b=2.0f, .c=int3(3, 4, 5)}")); } -TEST_F(MslGeneratorImplTest, EmitInitializer_Type_Struct_Empty) { +TEST_F(MslGeneratorImplTest_Constructor, Type_Struct_Empty) { auto* str = Structure("S", utils::Vector{ Member("a", ty.i32()), Member("b", ty.f32()), diff --git a/src/tint/writer/spirv/builder.cc b/src/tint/writer/spirv/builder.cc index 9c85bc14d8..ad0d7466f5 100644 --- a/src/tint/writer/spirv/builder.cc +++ b/src/tint/writer/spirv/builder.cc @@ -33,8 +33,8 @@ #include "src/tint/sem/statement.h" #include "src/tint/sem/struct.h" #include "src/tint/sem/switch_statement.h" -#include "src/tint/sem/type_conversion.h" -#include "src/tint/sem/type_initializer.h" +#include "src/tint/sem/value_constructor.h" +#include "src/tint/sem/value_conversion.h" #include "src/tint/sem/variable.h" #include "src/tint/transform/add_block_attribute.h" #include "src/tint/type/array.h" @@ -770,7 +770,7 @@ bool Builder::GenerateGlobalVariable(const ast::Variable* v) { uint32_t init_id = 0; if (auto* ctor = v->initializer) { - init_id = GenerateInitializerExpression(v, ctor); + init_id = GenerateConstructorExpression(v, ctor); if (init_id == 0) { return false; } @@ -1247,7 +1247,7 @@ uint32_t Builder::GetGLSLstd450Import() { return id; } -uint32_t Builder::GenerateInitializerExpression(const ast::Variable* var, +uint32_t Builder::GenerateConstructorExpression(const ast::Variable* var, const ast::Expression* expr) { if (auto* sem = builder_.Sem().GetVal(expr)) { if (auto constant = sem->ConstantValue()) { @@ -1255,15 +1255,15 @@ uint32_t Builder::GenerateInitializerExpression(const ast::Variable* var, } } if (auto* call = builder_.Sem().Get(expr)) { - if (call->Target()->IsAnyOf()) { - return GenerateTypeInitializerOrConversion(call, var); + if (call->Target()->IsAnyOf()) { + return GenerateValueConstructorOrConversion(call, var); } } - error_ = "unknown initializer expression"; + error_ = "unknown constructor expression"; return 0; } -bool Builder::IsInitializerConst(const ast::Expression* expr) { +bool Builder::IsConstructorConst(const ast::Expression* expr) { bool is_const = true; ast::TraverseExpressions(expr, builder_.Diagnostics(), [&](const ast::Expression* e) { if (e->Is()) { @@ -1277,7 +1277,7 @@ bool Builder::IsInitializerConst(const ast::Expression* expr) { return ast::TraverseAction::Skip; } auto* call = sem->As(); - if (call->Target()->Is()) { + if (call->Target()->Is()) { return ast::TraverseAction::Descend; } } @@ -1288,19 +1288,19 @@ bool Builder::IsInitializerConst(const ast::Expression* expr) { return is_const; } -uint32_t Builder::GenerateTypeInitializerOrConversion(const sem::Call* call, - const ast::Variable* var) { +uint32_t Builder::GenerateValueConstructorOrConversion(const sem::Call* call, + const ast::Variable* var) { auto& args = call->Arguments(); auto* global_var = builder_.Sem().Get(var); auto* result_type = call->Type(); - // Generate the zero initializer if there are no values provided. + // Generate the zero constructor if there are no values provided. if (args.IsEmpty()) { return GenerateConstantNullIfNeeded(result_type->UnwrapRef()); } result_type = result_type->UnwrapRef(); - bool initializer_is_const = IsInitializerConst(call->Declaration()); + bool constructor_is_const = IsConstructorConst(call->Declaration()); if (has_error()) { return 0; } @@ -1335,7 +1335,7 @@ uint32_t Builder::GenerateTypeInitializerOrConversion(const sem::Call* call, return 0; } - bool result_is_constant_composite = initializer_is_const; + bool result_is_constant_composite = constructor_is_const; bool result_is_spec_composite = false; if (auto* vec = result_type->As()) { @@ -2243,13 +2243,14 @@ uint32_t Builder::GenerateCallExpression(const ast::CallExpression* expr) { auto* call = builder_.Sem().Get(expr); auto* target = call->Target(); return Switch( - target, [&](const sem::Function* func) { return GenerateFunctionCall(call, func); }, + target, // + [&](const sem::Function* func) { return GenerateFunctionCall(call, func); }, [&](const sem::Builtin* builtin) { return GenerateBuiltinCall(call, builtin); }, - [&](const sem::TypeConversion*) { - return GenerateTypeInitializerOrConversion(call, nullptr); + [&](const sem::ValueConversion*) { + return GenerateValueConstructorOrConversion(call, nullptr); }, - [&](const sem::TypeInitializer*) { - return GenerateTypeInitializerOrConversion(call, nullptr); + [&](const sem::ValueConstructor*) { + return GenerateValueConstructorOrConversion(call, nullptr); }, [&](Default) { TINT_ICE(Writer, builder_.Diagnostics()) diff --git a/src/tint/writer/spirv/builder.h b/src/tint/writer/spirv/builder.h index adfe65908f..53fb108360 100644 --- a/src/tint/writer/spirv/builder.h +++ b/src/tint/writer/spirv/builder.h @@ -45,8 +45,8 @@ namespace tint::sem { class Call; class Load; -class TypeInitializer; -class TypeConversion; +class ValueConstructor; +class ValueConversion; } // namespace tint::sem namespace tint::type { class Reference; @@ -338,11 +338,11 @@ class Builder { /// instruction set, if one doesn't exist yet, and returns the import ID. /// @returns the import ID, or 0 on error. uint32_t GetGLSLstd450Import(); - /// Generates a initializer expression + /// Generates a constructor expression /// @param var the variable generated for, nullptr if no variable associated. /// @param expr the expression to generate /// @returns the ID of the expression or 0 on failure. - uint32_t GenerateInitializerExpression(const ast::Variable* var, const ast::Expression* expr); + uint32_t GenerateConstructorExpression(const ast::Variable* var, const ast::Expression* expr); /// Generates a literal constant if needed /// @param lit the literal to generate /// @returns the ID on success or 0 on failure @@ -373,11 +373,11 @@ class Builder { /// @param builtin the builtin being called /// @returns the expression ID on success or 0 otherwise uint32_t GenerateBuiltinCall(const sem::Call* call, const sem::Builtin* builtin); - /// Handles generating a type initializer or type conversion expression + /// Handles generating a value constructor or value conversion expression /// @param call the call expression /// @param var the variable that is being initialized. May be null. /// @returns the expression ID on success or 0 otherwise - uint32_t GenerateTypeInitializerOrConversion(const sem::Call* call, const ast::Variable* var); + uint32_t GenerateValueConstructorOrConversion(const sem::Call* call, const ast::Variable* var); /// Generates a texture builtin call. Emits an error and returns false if /// we're currently outside a function. /// @param call the call expression @@ -538,10 +538,10 @@ class Builder { /// @returns SPIR-V image format type SpvImageFormat convert_texel_format_to_spv(const builtin::TexelFormat format); - /// Determines if the given type initializer is created from constant values + /// Determines if the given value constructor is created from constant values /// @param expr the expression to check - /// @returns true if the initializer is constant - bool IsInitializerConst(const ast::Expression* expr); + /// @returns true if the constructor is constant + bool IsConstructorConst(const ast::Expression* expr); private: /// @returns an Operand with a new result ID in it. Increments the next_id_ diff --git a/src/tint/writer/spirv/builder_initializer_expression_test.cc b/src/tint/writer/spirv/builder_constructor_expression_test.cc similarity index 88% rename from src/tint/writer/spirv/builder_initializer_expression_test.cc rename to src/tint/writer/spirv/builder_constructor_expression_test.cc index cf382e0fd2..29a47acec4 100644 --- a/src/tint/writer/spirv/builder_initializer_expression_test.cc +++ b/src/tint/writer/spirv/builder_constructor_expression_test.cc @@ -20,15 +20,15 @@ using namespace tint::number_suffixes; // NOLINT namespace tint::writer::spirv { namespace { -using SpvBuilderInitializerTest = TestHelper; +using SpvBuilderConstructorTest = TestHelper; -TEST_F(SpvBuilderInitializerTest, Const) { +TEST_F(SpvBuilderConstructorTest, Const) { auto* c = Expr(42.2_f); auto* g = GlobalVar("g", ty.f32(), c, builtin::AddressSpace::kPrivate); spirv::Builder& b = Build(); - EXPECT_EQ(b.GenerateInitializerExpression(g, c), 2u); + EXPECT_EQ(b.GenerateConstructorExpression(g, c), 2u); ASSERT_FALSE(b.has_error()) << b.error(); EXPECT_EQ(DumpInstructions(b.types()), R"(%1 = OpTypeFloat 32 @@ -36,13 +36,13 @@ TEST_F(SpvBuilderInitializerTest, Const) { )"); } -TEST_F(SpvBuilderInitializerTest, Type) { +TEST_F(SpvBuilderConstructorTest, Type) { auto* t = vec3(1_f, 1_f, 3_f); WrapInFunction(t); spirv::Builder& b = Build(); - EXPECT_EQ(b.GenerateInitializerExpression(nullptr, t), 5u); + EXPECT_EQ(b.GenerateConstructorExpression(nullptr, t), 5u); ASSERT_FALSE(b.has_error()) << b.error(); EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32 @@ -53,7 +53,7 @@ TEST_F(SpvBuilderInitializerTest, Type) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_WithCasts) { +TEST_F(SpvBuilderConstructorTest, Type_WithCasts) { auto* t = vec2(Call(1_i), Call(1_i)); WrapInFunction(t); @@ -72,7 +72,7 @@ TEST_F(SpvBuilderInitializerTest, Type_WithCasts) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_WithAlias) { +TEST_F(SpvBuilderConstructorTest, Type_WithAlias) { // type Int = i32 // cast(2.3f) @@ -91,7 +91,7 @@ TEST_F(SpvBuilderInitializerTest, Type_WithAlias) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_IdentifierExpression_Param) { +TEST_F(SpvBuilderConstructorTest, Type_IdentifierExpression_Param) { auto* var = Var("ident", ty.f32()); auto* t = vec2(1_f, "ident"); @@ -121,7 +121,7 @@ TEST_F(SpvBuilderInitializerTest, Type_IdentifierExpression_Param) { )"); } -TEST_F(SpvBuilderInitializerTest, Vector_Bitcast_Params) { +TEST_F(SpvBuilderConstructorTest, Vector_Bitcast_Params) { auto* var = Var("v", vec3(1_f, 2_f, 3_f)); auto* cast = Bitcast(ty.vec3(), var); WrapInFunction(var, cast); @@ -150,7 +150,7 @@ TEST_F(SpvBuilderInitializerTest, Vector_Bitcast_Params) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Bool_With_Bool) { +TEST_F(SpvBuilderConstructorTest, Type_Bool_With_Bool) { auto* cast = Call(true); WrapInFunction(cast); @@ -167,7 +167,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Bool_With_Bool) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_I32_With_I32) { +TEST_F(SpvBuilderConstructorTest, Type_I32_With_I32) { auto* cast = Call(2_i); WrapInFunction(cast); @@ -182,7 +182,7 @@ TEST_F(SpvBuilderInitializerTest, Type_I32_With_I32) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_U32_With_U32) { +TEST_F(SpvBuilderConstructorTest, Type_U32_With_U32) { auto* cast = Call(2_u); WrapInFunction(cast); @@ -197,7 +197,7 @@ TEST_F(SpvBuilderInitializerTest, Type_U32_With_U32) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_F32_With_F32) { +TEST_F(SpvBuilderConstructorTest, Type_F32_With_F32) { auto* cast = Call(2_f); WrapInFunction(cast); @@ -212,7 +212,7 @@ TEST_F(SpvBuilderInitializerTest, Type_F32_With_F32) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_F16_With_F16) { +TEST_F(SpvBuilderConstructorTest, Type_F16_With_F16) { Enable(builtin::Extension::kF16); auto* cast = Call(2_h); @@ -229,7 +229,7 @@ TEST_F(SpvBuilderInitializerTest, Type_F16_With_F16) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec2_With_Bool_Literal) { +TEST_F(SpvBuilderConstructorTest, Type_Vec2_With_Bool_Literal) { auto* cast = vec2(true); WrapInFunction(cast); @@ -246,7 +246,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec2_With_Bool_Literal) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec2_With_Bool_Var) { +TEST_F(SpvBuilderConstructorTest, Type_Vec2_With_Bool_Var) { auto* var = Var("v", Expr(true)); auto* cast = vec2(var); WrapInFunction(var, cast); @@ -270,7 +270,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec2_With_Bool_Var) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec2_With_F32_Literal) { +TEST_F(SpvBuilderConstructorTest, Type_Vec2_With_F32_Literal) { auto* cast = vec2(2_f); WrapInFunction(cast); @@ -287,7 +287,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec2_With_F32_Literal) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec2_With_F16_Literal) { +TEST_F(SpvBuilderConstructorTest, Type_Vec2_With_F16_Literal) { Enable(builtin::Extension::kF16); auto* cast = vec2(2_h); @@ -306,7 +306,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec2_With_F16_Literal) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec2_With_F32_F32) { +TEST_F(SpvBuilderConstructorTest, Type_Vec2_With_F32_F32) { auto* var = Decl(Var("x", ty.f32(), Expr(2_f))); auto* cast = vec2("x", "x"); WrapInFunction(var, cast); @@ -331,7 +331,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec2_With_F32_F32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec2_With_F16_F16) { +TEST_F(SpvBuilderConstructorTest, Type_Vec2_With_F16_F16) { Enable(builtin::Extension::kF16); auto* var = Decl(Var("x", ty.f16(), Expr(2_h))); @@ -358,7 +358,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec2_With_F16_F16) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec2_With_F32_F32_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec2_With_F32_F32_Const) { auto* cast = vec2(1_f, 2_f); WrapInFunction(cast); @@ -376,7 +376,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec2_With_F32_F32_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec2_With_F16_F16_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec2_With_F16_F16_Const) { Enable(builtin::Extension::kF16); auto* cast = vec2(1_h, 2_h); @@ -396,7 +396,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec2_With_F16_F16_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec2_F32_With_Vec2) { +TEST_F(SpvBuilderConstructorTest, Type_Vec2_F32_With_Vec2) { auto* var = Decl(Var("x", ty.vec2(), vec2(1_f, 2_f))); auto* cast = vec2("x"); WrapInFunction(var, cast); @@ -421,7 +421,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec2_F32_With_Vec2) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec2_F16_With_Vec2) { +TEST_F(SpvBuilderConstructorTest, Type_Vec2_F16_With_Vec2) { Enable(builtin::Extension::kF16); auto* var = Decl(Var("x", ty.vec2(), vec2(1_h, 2_h))); @@ -448,7 +448,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec2_F16_With_Vec2) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec2_F32_With_Vec2_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec2_F32_With_Vec2_Const) { auto* cast = vec2(vec2(1_f, 2_f)); WrapInFunction(cast); @@ -466,7 +466,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec2_F32_With_Vec2_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec2_F16_With_Vec2_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec2_F16_With_Vec2_Const) { Enable(builtin::Extension::kF16); auto* cast = vec2(vec2(1_h, 2_h)); @@ -486,7 +486,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec2_F16_With_Vec2_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_F32) { +TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_F32) { auto* var = Decl(Var("x", ty.f32(), Expr(2_f))); auto* cast = vec3("x", "x", "x"); WrapInFunction(var, cast); @@ -512,7 +512,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_F32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_F16) { +TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_F16) { Enable(builtin::Extension::kF16); auto* var = Decl(Var("x", ty.f16(), Expr(2_h))); @@ -540,7 +540,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_F16) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_F32_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_F32_Const) { auto* cast = vec3(1_f, 2_f, 3_f); WrapInFunction(cast); @@ -559,7 +559,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_F32_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_F16_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_F16_Const) { Enable(builtin::Extension::kF16); auto* cast = vec3(1_h, 2_h, 3_h); @@ -580,7 +580,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_F16_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_Bool) { +TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_Bool) { auto* var = Decl(Var("x", ty.bool_(), Expr(true))); auto* cast = vec3("x", "x", "x"); WrapInFunction(var, cast); @@ -606,7 +606,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_Bool) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_Bool_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_Bool_Const) { auto* cast = vec3(true, false, true); WrapInFunction(cast); @@ -624,7 +624,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_Bool_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_F32_F32_F32) { +TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_F32_F32_F32) { auto* var = Decl(Var("x", ty.f32(), Expr(2_f))); auto* cast = vec3("x", "x", "x"); WrapInFunction(var, cast); @@ -650,7 +650,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_F32_F32_F32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_F16_F16_F16) { +TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_F16_F16_F16) { Enable(builtin::Extension::kF16); auto* var = Decl(Var("x", ty.f16(), Expr(2_h))); @@ -678,7 +678,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_F16_F16_F16) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_F32_F32_F32_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_F32_F32_F32_Const) { auto* cast = vec3(1_f, 2_f, 3_f); WrapInFunction(cast); @@ -697,7 +697,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_F32_F32_F32_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_F16_F16_F16_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_F16_F16_F16_Const) { Enable(builtin::Extension::kF16); auto* cast = vec3(1_h, 2_h, 3_h); @@ -718,7 +718,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_F16_F16_F16_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_F32_Vec2) { +TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_F32_Vec2) { auto* var = Decl(Var("x", ty.vec2(), vec2(2_f, 3_f))); auto* cast = vec3(1_f, "x"); WrapInFunction(var, cast); @@ -748,7 +748,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_F32_Vec2) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_F16_Vec2) { +TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_F16_Vec2) { Enable(builtin::Extension::kF16); auto* var = Decl(Var("x", ty.vec2(), vec2(2_h, 3_h))); @@ -780,7 +780,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_F16_Vec2) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_F32_Vec2_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_F32_Vec2_Const) { auto* cast = vec3(1_f, vec2(2_f, 3_f)); WrapInFunction(cast); @@ -799,7 +799,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_F32_Vec2_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_F16_Vec2_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_F16_Vec2_Const) { Enable(builtin::Extension::kF16); auto* cast = vec3(1_h, vec2(2_h, 3_h)); @@ -820,7 +820,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_F16_Vec2_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_Vec2_F32) { +TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_Vec2_F32) { auto* var = Decl(Var("x", ty.vec2(), vec2(1_f, 2_f))); auto* cast = vec3("x", 3_f); WrapInFunction(var, cast); @@ -850,7 +850,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_Vec2_F32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_Vec2_F16) { +TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_Vec2_F16) { Enable(builtin::Extension::kF16); auto* var = Decl(Var("x", ty.vec2(), vec2(1_h, 2_h))); @@ -882,7 +882,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_Vec2_F16) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_Vec2_F32_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_Vec2_F32_Const) { auto* cast = vec3(vec2(1_f, 2_f), 3_f); WrapInFunction(cast); @@ -901,7 +901,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_Vec2_F32_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_Vec2_F16_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_Vec2_F16_Const) { Enable(builtin::Extension::kF16); auto* cast = vec3(vec2(1_h, 2_h), 3_h); @@ -922,7 +922,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec3_With_Vec2_F16_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec3_F32_With_Vec3) { +TEST_F(SpvBuilderConstructorTest, Type_Vec3_F32_With_Vec3) { auto* var = Decl(Var("x", ty.vec3(), vec3(1_f, 2_f, 3_f))); auto* cast = vec3("x"); WrapInFunction(var, cast); @@ -948,7 +948,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec3_F32_With_Vec3) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec3_F16_With_Vec3) { +TEST_F(SpvBuilderConstructorTest, Type_Vec3_F16_With_Vec3) { Enable(builtin::Extension::kF16); auto* var = Decl(Var("x", ty.vec3(), vec3(1_h, 2_h, 3_h))); @@ -976,7 +976,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec3_F16_With_Vec3) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec3_F32_With_Vec3_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec3_F32_With_Vec3_Const) { auto* cast = vec3(vec3(1_f, 2_f, 3_f)); WrapInFunction(cast); @@ -995,7 +995,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec3_F32_With_Vec3_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec3_F16_With_Vec3_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec3_F16_With_Vec3_Const) { Enable(builtin::Extension::kF16); auto* cast = vec3(vec3(1_h, 2_h, 3_h)); @@ -1016,7 +1016,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec3_F16_With_Vec3_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_Bool) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_Bool) { auto* var = Decl(Var("x", ty.bool_(), Expr(true))); auto* cast = vec4("x"); WrapInFunction(var, cast); @@ -1040,7 +1040,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_Bool) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_Bool_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_Bool_Const) { auto* cast = vec4(true); WrapInFunction(cast); @@ -1057,7 +1057,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_Bool_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F32) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F32) { auto* var = Decl(Var("x", ty.f32(), Expr(2_f))); auto* cast = vec4("x"); WrapInFunction(var, cast); @@ -1081,7 +1081,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F16) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F16) { Enable(builtin::Extension::kF16); auto* var = Decl(Var("x", ty.f16(), Expr(2_h))); @@ -1107,7 +1107,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F16) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F32_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F32_Const) { auto* cast = vec4(2_f); WrapInFunction(cast); @@ -1124,7 +1124,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F32_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F16_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F16_Const) { Enable(builtin::Extension::kF16); auto* cast = vec4(2_h); @@ -1143,7 +1143,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F16_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F32_F32_F32_F32) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F32_F32_F32_F32) { auto* var = Decl(Var("x", ty.f32(), Expr(2_f))); auto* cast = vec4("x", "x", "x", "x"); WrapInFunction(var, cast); @@ -1170,7 +1170,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F32_F32_F32_F32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F16_F16_F16_F16) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F16_F16_F16_F16) { Enable(builtin::Extension::kF16); auto* var = Decl(Var("x", ty.f16(), Expr(2_h))); @@ -1199,7 +1199,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F16_F16_F16_F16) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F32_F32_F32_F32_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F32_F32_F32_F32_Const) { auto* cast = vec4(1_f, 2_f, 3_f, 4_f); WrapInFunction(cast); @@ -1219,7 +1219,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F32_F32_F32_F32_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F16_F16_F16_F16_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F16_F16_F16_F16_Const) { Enable(builtin::Extension::kF16); auto* cast = vec4(1_h, 2_h, 3_h, 4_h); @@ -1241,7 +1241,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F16_F16_F16_F16_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F32_F32_Vec2) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F32_F32_Vec2) { auto* var = Decl(Var("x", ty.vec2(), vec2(1_f, 2_f))); auto* cast = vec4(1_f, 2_f, "x"); WrapInFunction(var, cast); @@ -1270,7 +1270,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F32_F32_Vec2) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F16_F16_Vec2) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F16_F16_Vec2) { Enable(builtin::Extension::kF16); auto* var = Decl(Var("x", ty.vec2(), vec2(1_h, 2_h))); @@ -1301,7 +1301,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F16_F16_Vec2) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F32_F32_Vec2_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F32_F32_Vec2_Const) { auto* cast = vec4(1_f, 2_f, vec2(3_f, 4_f)); WrapInFunction(cast); @@ -1321,7 +1321,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F32_F32_Vec2_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F16_F16_Vec2_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F16_F16_Vec2_Const) { Enable(builtin::Extension::kF16); auto* cast = vec4(1_h, 2_h, vec2(3_h, 4_h)); @@ -1343,7 +1343,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F16_F16_Vec2_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F32_Vec2_F32) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F32_Vec2_F32) { auto* var = Decl(Var("x", ty.vec2(), vec2(2_f, 3_f))); auto* cast = vec4(1_f, "x", 4_f); WrapInFunction(var, cast); @@ -1374,7 +1374,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F32_Vec2_F32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F16_Vec2_F16) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F16_Vec2_F16) { Enable(builtin::Extension::kF16); auto* var = Decl(Var("x", ty.vec2(), vec2(2_h, 3_h))); @@ -1407,7 +1407,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F16_Vec2_F16) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F32_Vec2_F32_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F32_Vec2_F32_Const) { auto* cast = vec4(1_f, vec2(2_f, 3_f), 4_f); WrapInFunction(cast); @@ -1427,7 +1427,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F32_Vec2_F32_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F16_Vec2_F16_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F16_Vec2_F16_Const) { Enable(builtin::Extension::kF16); auto* cast = vec4(1_h, vec2(2_h, 3_h), 4_h); @@ -1449,7 +1449,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F16_Vec2_F16_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_Vec2_F32_F32) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_Vec2_F32_F32) { auto* var = Decl(Var("x", ty.vec2(), vec2(1_f, 2_f))); auto* cast = vec4("x", 3_f, 4_f); WrapInFunction(var, cast); @@ -1480,7 +1480,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_Vec2_F32_F32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_Vec2_F16_F16) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_Vec2_F16_F16) { Enable(builtin::Extension::kF16); auto* var = Decl(Var("x", ty.vec2(), vec2(1_h, 2_h))); @@ -1513,7 +1513,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_Vec2_F16_F16) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_Vec2_F32_F32_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_Vec2_F32_F32_Const) { auto* cast = vec4(vec2(1_f, 2_f), 3_f, 4_f); WrapInFunction(cast); @@ -1533,7 +1533,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_Vec2_F32_F32_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_Vec2_F16_F16_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_Vec2_F16_F16_Const) { Enable(builtin::Extension::kF16); auto* cast = vec4(vec2(1_h, 2_h), 3_h, 4_h); @@ -1555,7 +1555,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_Vec2_F16_F16_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_F32_With_Vec2_Vec2) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_F32_With_Vec2_Vec2) { auto* var = Decl(Var("x", ty.vec2(), vec2(1_f, 2_f))); auto* cast = vec4("x", "x"); WrapInFunction(var, cast); @@ -1587,7 +1587,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_F32_With_Vec2_Vec2) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_F16_With_Vec2_Vec2) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_F16_With_Vec2_Vec2) { Enable(builtin::Extension::kF16); auto* var = Decl(Var("x", ty.vec2(), vec2(1_h, 2_h))); @@ -1621,7 +1621,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_F16_With_Vec2_Vec2) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_F32_With_Vec2_Vec2_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_F32_With_Vec2_Vec2_Const) { auto* cast = vec4(vec2(1_f, 2_f), vec2(1_f, 2_f)); WrapInFunction(cast); @@ -1639,7 +1639,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_F32_With_Vec2_Vec2_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_F16_With_Vec2_Vec2_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_F16_With_Vec2_Vec2_Const) { Enable(builtin::Extension::kF16); auto* cast = vec4(vec2(1_h, 2_h), vec2(1_h, 2_h)); @@ -1659,7 +1659,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_F16_With_Vec2_Vec2_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F32_Vec3) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F32_Vec3) { auto* var = Decl(Var("x", ty.vec3(), vec3(2_f, 2_f, 2_f))); auto* cast = vec4(2_f, "x"); WrapInFunction(var, cast); @@ -1688,7 +1688,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F32_Vec3) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F16_Vec3) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F16_Vec3) { Enable(builtin::Extension::kF16); auto* var = Decl(Var("x", ty.vec3(), vec3(2_h, 2_h, 2_h))); @@ -1719,7 +1719,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F16_Vec3) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F32_Vec3_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F32_Vec3_Const) { auto* cast = vec4(2_f, vec3(2_f, 2_f, 2_f)); WrapInFunction(cast); @@ -1736,7 +1736,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F32_Vec3_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F16_Vec3_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F16_Vec3_Const) { Enable(builtin::Extension::kF16); auto* cast = vec4(2_h, vec3(2_h, 2_h, 2_h)); @@ -1755,7 +1755,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_F16_Vec3_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_Vec3_F32) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_Vec3_F32) { auto* var = Decl(Var("x", ty.vec3(), vec3(2_f, 2_f, 2_f))); auto* cast = vec4("x", 2_f); WrapInFunction(var, cast); @@ -1784,7 +1784,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_Vec3_F32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_Vec3_F16) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_Vec3_F16) { Enable(builtin::Extension::kF16); auto* var = Decl(Var("x", ty.vec3(), vec3(2_h, 2_h, 2_h))); @@ -1815,7 +1815,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_Vec3_F16) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_Vec3_F32_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_Vec3_F32_Const) { auto* cast = vec4(vec3(2_f, 2_f, 2_f), 2_f); WrapInFunction(cast); @@ -1832,7 +1832,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_Vec3_F32_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_Vec3_F16_Const) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_Vec3_F16_Const) { Enable(builtin::Extension::kF16); auto* cast = vec4(vec3(2_h, 2_h, 2_h), 2_h); @@ -1851,7 +1851,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_With_Vec3_F16_Const) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_F32_With_Vec4) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_F32_With_Vec4) { auto* value = vec4(2_f, 2_f, 2_f, 2_f); auto* cast = vec4(value); WrapInFunction(cast); @@ -1869,7 +1869,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_F32_With_Vec4) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_Vec4_F16_With_Vec4) { +TEST_F(SpvBuilderConstructorTest, Type_Vec4_F16_With_Vec4) { Enable(builtin::Extension::kF16); auto* value = vec4(2_h, 2_h, 2_h, 2_h); @@ -1889,7 +1889,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Vec4_F16_With_Vec4) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"()"); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalConst_F32_With_F32) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_F32_With_F32) { auto* ctor = Call(2_f); GlobalConst("g", ty.f32(), ctor); WrapInFunction(Decl(Var("l", Expr("g")))); @@ -1910,7 +1910,7 @@ OpReturn Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalConst_F16_With_F16) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_F16_With_F16) { Enable(builtin::Extension::kF16); auto* ctor = Call(2_h); @@ -1933,7 +1933,7 @@ OpReturn Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_F32_With_F32) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_F32_With_F32) { auto* ctor = Call(2_f); GlobalVar("g", ty.f32(), builtin::AddressSpace::kPrivate, ctor); @@ -1950,7 +1950,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_F32_With_F32) { Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_F16_With_F16) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_F16_With_F16) { Enable(builtin::Extension::kF16); auto* ctor = Call(2_h); @@ -1969,7 +1969,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_F16_With_F16) { Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalConst_U32_With_F32) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_U32_With_F32) { auto* ctor = Call(1.5_f); GlobalConst("g", ty.u32(), ctor); WrapInFunction(Decl(Var("l", Expr("g")))); @@ -1990,7 +1990,7 @@ OpReturn Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalConst_U32_With_F16) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_U32_With_F16) { Enable(builtin::Extension::kF16); auto* ctor = Call(1.5_h); @@ -2013,7 +2013,7 @@ OpReturn Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_U32_With_F32) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_U32_With_F32) { auto* ctor = Call(1.5_f); GlobalVar("g", ty.u32(), builtin::AddressSpace::kPrivate, ctor); @@ -2030,7 +2030,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_U32_With_F32) { Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_U32_With_F16) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_U32_With_F16) { Enable(builtin::Extension::kF16); auto* ctor = Call(1.5_h); @@ -2049,7 +2049,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_U32_With_F16) { Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalConst_Vec2_With_F32) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec2_With_F32) { auto* cast = vec2(2_f); GlobalConst("g", ty.vec2(), cast); WrapInFunction(Decl(Var("l", Expr("g")))); @@ -2072,7 +2072,7 @@ OpReturn Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalConst_Vec2_With_F16) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec2_With_F16) { Enable(builtin::Extension::kF16); auto* cast = vec2(2_h); @@ -2097,14 +2097,14 @@ OpReturn Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec2_With_F32) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec2_With_F32) { auto* cast = vec2(2_f); auto* g = GlobalVar("g", ty.vec2(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); b.push_function(Function{}); - EXPECT_EQ(b.GenerateInitializerExpression(g, cast), 4u); + EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u); EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32 %1 = OpTypeVector %2 2 @@ -2113,7 +2113,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec2_With_F32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec2_With_F16) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec2_With_F16) { Enable(builtin::Extension::kF16); auto* cast = vec2(2_h); @@ -2122,7 +2122,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec2_With_F16) { spirv::Builder& b = Build(); b.push_function(Function{}); - EXPECT_EQ(b.GenerateInitializerExpression(g, cast), 4u); + EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u); EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 16 %1 = OpTypeVector %2 2 @@ -2131,7 +2131,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec2_With_F16) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalConst_Vec2_F32_With_Vec2) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec2_F32_With_Vec2) { auto* cast = vec2(vec2(2_f, 2_f)); GlobalConst("g", ty.vec2(), cast); WrapInFunction(Decl(Var("l", Expr("g")))); @@ -2154,7 +2154,7 @@ OpReturn Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalConst_Vec2_F16_With_Vec2) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec2_F16_With_Vec2) { Enable(builtin::Extension::kF16); auto* cast = vec2(vec2(2_h, 2_h)); @@ -2179,7 +2179,7 @@ OpReturn Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec2_F32_With_Vec2) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec2_F32_With_Vec2) { auto* cast = vec2(vec2(2_f, 2_f)); GlobalVar("a", ty.vec2(), builtin::AddressSpace::kPrivate, cast); @@ -2199,7 +2199,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec2_F32_With_Vec2) { Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec2_F16_With_Vec2) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec2_F16_With_Vec2) { Enable(builtin::Extension::kF16); auto* cast = vec2(vec2(2_h, 2_h)); @@ -2221,7 +2221,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec2_F16_With_Vec2) { Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalConst_Vec3_F32_With_Vec3) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec3_F32_With_Vec3) { auto* cast = vec3(vec3(2_f, 2_f, 2_f)); GlobalConst("g", ty.vec3(), cast); WrapInFunction(Decl(Var("l", Expr("g")))); @@ -2244,7 +2244,7 @@ OpReturn Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalConst_Vec3_F16_With_Vec3) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec3_F16_With_Vec3) { Enable(builtin::Extension::kF16); auto* cast = vec3(vec3(2_h, 2_h, 2_h)); @@ -2269,7 +2269,7 @@ OpReturn Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec3_F32_With_Vec3) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec3_F32_With_Vec3) { auto* cast = vec3(vec3(2_f, 2_f, 2_f)); GlobalVar("a", ty.vec3(), builtin::AddressSpace::kPrivate, cast); @@ -2289,7 +2289,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec3_F32_With_Vec3) { Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec3_F16_With_Vec3) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec3_F16_With_Vec3) { Enable(builtin::Extension::kF16); auto* cast = vec3(vec3(2_h, 2_h, 2_h)); @@ -2311,7 +2311,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec3_F16_With_Vec3) { Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalConst_Vec4_F32_With_Vec4) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec4_F32_With_Vec4) { auto* cast = vec4(vec4(2_f, 2_f, 2_f, 2_f)); GlobalConst("g", ty.vec4(), cast); WrapInFunction(Decl(Var("l", Expr("g")))); @@ -2334,7 +2334,7 @@ OpReturn Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalConst_Vec4_F16_With_Vec4) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec4_F16_With_Vec4) { Enable(builtin::Extension::kF16); auto* cast = vec4(vec4(2_h, 2_h, 2_h, 2_h)); @@ -2359,7 +2359,7 @@ OpReturn Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_F32_With_Vec4) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec4_F32_With_Vec4) { auto* cast = vec4(vec4(2_f, 2_f, 2_f, 2_f)); GlobalVar("a", ty.vec4(), builtin::AddressSpace::kPrivate, cast); @@ -2379,7 +2379,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_F32_With_Vec4) { Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_F16_With_Vec4) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec4_F16_With_Vec4) { Enable(builtin::Extension::kF16); auto* cast = vec4(vec4(2_h, 2_h, 2_h, 2_h)); @@ -2401,7 +2401,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_F16_With_Vec4) { Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalConst_Vec3_With_F32) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec3_With_F32) { auto* cast = vec3(2_f); GlobalConst("g", ty.vec3(), cast); WrapInFunction(Decl(Var("l", Expr("g")))); @@ -2424,7 +2424,7 @@ OpReturn Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalConst_Vec3_With_F16) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec3_With_F16) { Enable(builtin::Extension::kF16); auto* cast = vec3(2_h); @@ -2449,14 +2449,14 @@ OpReturn Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec3_With_F32) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec3_With_F32) { auto* cast = vec3(2_f); auto* g = GlobalVar("g", ty.vec3(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); b.push_function(Function{}); - EXPECT_EQ(b.GenerateInitializerExpression(g, cast), 4u); + EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u); EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32 %1 = OpTypeVector %2 3 @@ -2465,7 +2465,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec3_With_F32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec3_With_F16) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec3_With_F16) { Enable(builtin::Extension::kF16); auto* cast = vec3(2_h); @@ -2474,7 +2474,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec3_With_F16) { spirv::Builder& b = Build(); b.push_function(Function{}); - EXPECT_EQ(b.GenerateInitializerExpression(g, cast), 4u); + EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u); EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 16 %1 = OpTypeVector %2 3 @@ -2483,7 +2483,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec3_With_F16) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalConst_Vec3_With_F32_Vec2) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec3_With_F32_Vec2) { auto* cast = vec3(2_f, vec2(2_f, 2_f)); GlobalConst("g", ty.vec3(), cast); WrapInFunction(Decl(Var("l", Expr("g")))); @@ -2506,7 +2506,7 @@ OpReturn Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalConst_Vec3_With_F16_Vec2) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec3_With_F16_Vec2) { Enable(builtin::Extension::kF16); auto* cast = vec3(2_h, vec2(2_h, 2_h)); @@ -2531,14 +2531,14 @@ OpReturn Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec3_With_F32_Vec2) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec3_With_F32_Vec2) { auto* cast = vec3(2_f, vec2(2_f, 2_f)); auto* g = GlobalVar("g", ty.vec3(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); b.push_function(Function{}); - EXPECT_EQ(b.GenerateInitializerExpression(g, cast), 4u); + EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u); EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32 %1 = OpTypeVector %2 3 @@ -2547,7 +2547,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec3_With_F32_Vec2) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec3_With_F16_Vec2) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec3_With_F16_Vec2) { Enable(builtin::Extension::kF16); auto* cast = vec3(2_h, vec2(2_h, 2_h)); @@ -2556,7 +2556,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec3_With_F16_Vec2) { spirv::Builder& b = Build(); b.push_function(Function{}); - EXPECT_EQ(b.GenerateInitializerExpression(g, cast), 4u); + EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u); EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 16 %1 = OpTypeVector %2 3 @@ -2565,7 +2565,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec3_With_F16_Vec2) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalConst_Vec3_With_Vec2_F32) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec3_With_Vec2_F32) { auto* cast = vec3(vec2(2_f, 2_f), 2_f); GlobalConst("g", ty.vec3(), cast); WrapInFunction(Decl(Var("l", Expr("g")))); @@ -2588,7 +2588,7 @@ OpReturn Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalConst_Vec3_With_Vec2_F16) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec3_With_Vec2_F16) { Enable(builtin::Extension::kF16); auto* cast = vec3(vec2(2_h, 2_h), 2_h); @@ -2613,14 +2613,14 @@ OpReturn Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec3_With_Vec2_F32) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec3_With_Vec2_F32) { auto* cast = vec3(vec2(2_f, 2_f), 2_f); auto* g = GlobalVar("g", ty.vec3(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); b.push_function(Function{}); - EXPECT_EQ(b.GenerateInitializerExpression(g, cast), 4u); + EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u); EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32 %1 = OpTypeVector %2 3 @@ -2629,7 +2629,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec3_With_Vec2_F32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec3_With_Vec2_F16) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec3_With_Vec2_F16) { Enable(builtin::Extension::kF16); auto* cast = vec3(vec2(2_h, 2_h), 2_h); @@ -2638,7 +2638,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec3_With_Vec2_F16) { spirv::Builder& b = Build(); b.push_function(Function{}); - EXPECT_EQ(b.GenerateInitializerExpression(g, cast), 4u); + EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u); EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 16 %1 = OpTypeVector %2 3 @@ -2647,7 +2647,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec3_With_Vec2_F16) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalConst_Vec4_With_F32) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec4_With_F32) { auto* cast = vec4(2_f); GlobalConst("g", ty.vec4(), cast); WrapInFunction(Decl(Var("l", Expr("g")))); @@ -2670,7 +2670,7 @@ OpReturn Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalConst_Vec4_With_F16) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec4_With_F16) { Enable(builtin::Extension::kF16); auto* cast = vec4(2_h); @@ -2695,14 +2695,14 @@ OpReturn Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_F32) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec4_With_F32) { auto* cast = vec4(2_f); auto* g = GlobalVar("g", ty.vec4(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); b.push_function(Function{}); - EXPECT_EQ(b.GenerateInitializerExpression(g, cast), 4u); + EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u); EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32 %1 = OpTypeVector %2 4 @@ -2711,7 +2711,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_F32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_F16) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec4_With_F16) { Enable(builtin::Extension::kF16); auto* cast = vec4(2_h); @@ -2720,7 +2720,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_F16) { spirv::Builder& b = Build(); b.push_function(Function{}); - EXPECT_EQ(b.GenerateInitializerExpression(g, cast), 4u); + EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u); EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 16 %1 = OpTypeVector %2 4 @@ -2729,7 +2729,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_F16) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalConst_Vec4_With_F32_F32_Vec2) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec4_With_F32_F32_Vec2) { auto* cast = vec4(2_f, 2_f, vec2(2_f, 2_f)); GlobalConst("g", ty.vec4(), cast); WrapInFunction(Decl(Var("l", Expr("g")))); @@ -2752,7 +2752,7 @@ OpReturn Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalConst_Vec4_With_F16_F16_Vec2) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec4_With_F16_F16_Vec2) { Enable(builtin::Extension::kF16); auto* cast = vec4(2_h, 2_h, vec2(2_h, 2_h)); @@ -2777,14 +2777,14 @@ OpReturn Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_F32_F32_Vec2) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec4_With_F32_F32_Vec2) { auto* cast = vec4(2_f, 2_f, vec2(2_f, 2_f)); auto* g = GlobalVar("g", ty.vec4(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); b.push_function(Function{}); - EXPECT_EQ(b.GenerateInitializerExpression(g, cast), 4u); + EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u); EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32 %1 = OpTypeVector %2 4 @@ -2793,7 +2793,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_F32_F32_Vec2) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_F16_F16_Vec2) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec4_With_F16_F16_Vec2) { Enable(builtin::Extension::kF16); auto* cast = vec4(2_h, 2_h, vec2(2_h, 2_h)); @@ -2802,7 +2802,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_F16_F16_Vec2) { spirv::Builder& b = Build(); b.push_function(Function{}); - EXPECT_EQ(b.GenerateInitializerExpression(g, cast), 4u); + EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u); EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 16 %1 = OpTypeVector %2 4 @@ -2811,7 +2811,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_F16_F16_Vec2) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalConst_Vec4_With_F32_Vec2_F32) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec4_With_F32_Vec2_F32) { auto* cast = vec4(2_f, vec2(2_f, 2_f), 2_f); GlobalConst("g", ty.vec4(), cast); WrapInFunction(Decl(Var("l", Expr("g")))); @@ -2834,7 +2834,7 @@ OpReturn Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalConst_Vec4_With_F16_Vec2_F16) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec4_With_F16_Vec2_F16) { Enable(builtin::Extension::kF16); auto* cast = vec4(2_h, vec2(2_h, 2_h), 2_h); @@ -2859,14 +2859,14 @@ OpReturn Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_F32_Vec2_F32) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec4_With_F32_Vec2_F32) { auto* cast = vec4(2_f, vec2(2_f, 2_f), 2_f); auto* g = GlobalVar("g", ty.vec4(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); b.push_function(Function{}); - EXPECT_EQ(b.GenerateInitializerExpression(g, cast), 4u); + EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u); EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32 %1 = OpTypeVector %2 4 @@ -2875,7 +2875,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_F32_Vec2_F32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_F16_Vec2_F16) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec4_With_F16_Vec2_F16) { Enable(builtin::Extension::kF16); auto* cast = vec4(2_h, vec2(2_h, 2_h), 2_h); @@ -2884,7 +2884,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_F16_Vec2_F16) { spirv::Builder& b = Build(); b.push_function(Function{}); - EXPECT_EQ(b.GenerateInitializerExpression(g, cast), 4u); + EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u); EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 16 %1 = OpTypeVector %2 4 @@ -2893,7 +2893,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_F16_Vec2_F16) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalConst_Vec4_With_Vec2_F32_F32) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec4_With_Vec2_F32_F32) { auto* cast = vec4(vec2(2_f, 2_f), 2_f, 2_f); GlobalConst("g", ty.vec4(), cast); WrapInFunction(Decl(Var("l", Expr("g")))); @@ -2916,7 +2916,7 @@ OpReturn Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalConst_Vec4_With_Vec2_F16_F16) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec4_With_Vec2_F16_F16) { Enable(builtin::Extension::kF16); auto* cast = vec4(vec2(2_h, 2_h), 2_h, 2_h); @@ -2941,14 +2941,14 @@ OpReturn Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_Vec2_F32_F32) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec4_With_Vec2_F32_F32) { auto* cast = vec4(vec2(2_f, 2_f), 2_f, 2_f); auto* g = GlobalVar("g", ty.vec4(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); b.push_function(Function{}); - EXPECT_EQ(b.GenerateInitializerExpression(g, cast), 4u); + EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u); EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32 %1 = OpTypeVector %2 4 @@ -2957,7 +2957,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_Vec2_F32_F32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_Vec2_F16_F16) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec4_With_Vec2_F16_F16) { Enable(builtin::Extension::kF16); auto* cast = vec4(vec2(2_h, 2_h), 2_h, 2_h); @@ -2966,7 +2966,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_Vec2_F16_F16) { spirv::Builder& b = Build(); b.push_function(Function{}); - EXPECT_EQ(b.GenerateInitializerExpression(g, cast), 4u); + EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u); EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 16 %1 = OpTypeVector %2 4 @@ -2975,7 +2975,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_Vec2_F16_F16) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalConst_Vec4_F32_With_Vec2_Vec2) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec4_F32_With_Vec2_Vec2) { auto* cast = vec4(vec2(2_f, 2_f), vec2(2_f, 2_f)); GlobalConst("g", ty.vec4(), cast); WrapInFunction(Decl(Var("l", Expr("g")))); @@ -2998,7 +2998,7 @@ OpReturn Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalConst_Vec4_F16_With_Vec2_Vec2) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec4_F16_With_Vec2_Vec2) { Enable(builtin::Extension::kF16); auto* cast = vec4(vec2(2_h, 2_h), vec2(2_h, 2_h)); @@ -3023,14 +3023,14 @@ OpReturn Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_F32_With_Vec2_Vec2) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec4_F32_With_Vec2_Vec2) { auto* cast = vec4(vec2(2_f, 2_f), vec2(2_f, 2_f)); auto* g = GlobalVar("g", ty.vec4(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); b.push_function(Function{}); - EXPECT_EQ(b.GenerateInitializerExpression(g, cast), 4u); + EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u); EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32 %1 = OpTypeVector %2 4 @@ -3039,7 +3039,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_F32_With_Vec2_Vec2) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_F16_With_Vec2_Vec2) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec4_F16_With_Vec2_Vec2) { Enable(builtin::Extension::kF16); auto* cast = vec4(vec2(2_h, 2_h), vec2(2_h, 2_h)); @@ -3048,7 +3048,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_F16_With_Vec2_Vec2) { spirv::Builder& b = Build(); b.push_function(Function{}); - EXPECT_EQ(b.GenerateInitializerExpression(g, cast), 4u); + EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u); EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 16 %1 = OpTypeVector %2 4 @@ -3057,7 +3057,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_F16_With_Vec2_Vec2) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalConst_Vec4_With_F32_Vec3) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec4_With_F32_Vec3) { auto* cast = vec4(2_f, vec3(2_f, 2_f, 2_f)); GlobalConst("g", ty.vec4(), cast); WrapInFunction(Decl(Var("l", Expr("g")))); @@ -3080,14 +3080,14 @@ OpReturn Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_F32_Vec3) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec4_With_F32_Vec3) { auto* cast = vec4(2_f, vec3(2_f, 2_f, 2_f)); auto* g = GlobalVar("g", ty.vec4(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); b.push_function(Function{}); - EXPECT_EQ(b.GenerateInitializerExpression(g, cast), 4u); + EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u); EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32 %1 = OpTypeVector %2 4 @@ -3096,7 +3096,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_F32_Vec3) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_F16_Vec3) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec4_With_F16_Vec3) { Enable(builtin::Extension::kF16); auto* cast = vec4(2_h, vec3(2_h, 2_h, 2_h)); @@ -3105,7 +3105,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_F16_Vec3) { spirv::Builder& b = Build(); b.push_function(Function{}); - EXPECT_EQ(b.GenerateInitializerExpression(g, cast), 4u); + EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u); EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 16 %1 = OpTypeVector %2 4 @@ -3114,7 +3114,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_F16_Vec3) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalConst_Vec4_With_Vec3_F32) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec4_With_Vec3_F32) { auto* cast = vec4(vec3(2_f, 2_f, 2_f), 2_f); GlobalConst("g", ty.vec4(), cast); WrapInFunction(Decl(Var("l", Expr("g")))); @@ -3137,7 +3137,7 @@ OpReturn Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalConst_Vec4_With_Vec3_F16) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalConst_Vec4_With_Vec3_F16) { Enable(builtin::Extension::kF16); auto* cast = vec4(vec3(2_h, 2_h, 2_h), 2_h); @@ -3162,14 +3162,14 @@ OpReturn Validate(b); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_Vec3_F32) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec4_With_Vec3_F32) { auto* cast = vec4(vec3(2_f, 2_f, 2_f), 2_f); auto* g = GlobalVar("g", ty.vec4(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); b.push_function(Function{}); - EXPECT_EQ(b.GenerateInitializerExpression(g, cast), 4u); + EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u); EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32 %1 = OpTypeVector %2 4 @@ -3178,7 +3178,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_Vec3_F32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_Vec3_F16) { +TEST_F(SpvBuilderConstructorTest, Type_GlobalVar_Vec4_With_Vec3_F16) { Enable(builtin::Extension::kF16); auto* cast = vec4(vec3(2_h, 2_h, 2_h), 2_h); @@ -3187,7 +3187,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_Vec3_F16) { spirv::Builder& b = Build(); b.push_function(Function{}); - EXPECT_EQ(b.GenerateInitializerExpression(g, cast), 4u); + EXPECT_EQ(b.GenerateConstructorExpression(g, cast), 4u); EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 16 %1 = OpTypeVector %2 4 @@ -3196,7 +3196,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_Vec3_F16) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Mat2x2_F32_With_Vec2_Vec2) { +TEST_F(SpvBuilderConstructorTest, Type_Mat2x2_F32_With_Vec2_Vec2) { auto* cast = mat2x2(vec2(2_f, 2_f), vec2(2_f, 2_f)); WrapInFunction(cast); @@ -3214,7 +3214,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Mat2x2_F32_With_Vec2_Vec2) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Mat2x2_F16_With_Vec2_Vec2) { +TEST_F(SpvBuilderConstructorTest, Type_Mat2x2_F16_With_Vec2_Vec2) { Enable(builtin::Extension::kF16); auto* cast = mat2x2(vec2(2_h, 2_h), vec2(2_h, 2_h)); @@ -3234,7 +3234,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Mat2x2_F16_With_Vec2_Vec2) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Mat3x2_F32_With_Vec2_Vec2_Vec2) { +TEST_F(SpvBuilderConstructorTest, Type_Mat3x2_F32_With_Vec2_Vec2_Vec2) { auto* cast = mat3x2(vec2(2_f, 2_f), vec2(2_f, 2_f), vec2(2_f, 2_f)); WrapInFunction(cast); @@ -3252,7 +3252,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Mat3x2_F32_With_Vec2_Vec2_Vec2) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Mat3x2_F16_With_Vec2_Vec2_Vec2) { +TEST_F(SpvBuilderConstructorTest, Type_Mat3x2_F16_With_Vec2_Vec2_Vec2) { Enable(builtin::Extension::kF16); auto* cast = mat3x2(vec2(2_h, 2_h), vec2(2_h, 2_h), vec2(2_h, 2_h)); @@ -3272,7 +3272,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Mat3x2_F16_With_Vec2_Vec2_Vec2) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Mat4x2_F32_With_Vec2_Vec2_Vec2_Vec2) { +TEST_F(SpvBuilderConstructorTest, Type_Mat4x2_F32_With_Vec2_Vec2_Vec2_Vec2) { auto* cast = mat4x2(vec2(2_f, 2_f), vec2(2_f, 2_f), vec2(2_f, 2_f), vec2(2_f, 2_f)); WrapInFunction(cast); @@ -3291,7 +3291,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Mat4x2_F32_With_Vec2_Vec2_Vec2_Vec2) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Mat4x2_F16_With_Vec2_Vec2_Vec2_Vec2) { +TEST_F(SpvBuilderConstructorTest, Type_Mat4x2_F16_With_Vec2_Vec2_Vec2_Vec2) { Enable(builtin::Extension::kF16); auto* cast = mat4x2(vec2(2_h, 2_h), vec2(2_h, 2_h), vec2(2_h, 2_h), @@ -3312,7 +3312,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Mat4x2_F16_With_Vec2_Vec2_Vec2_Vec2) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Mat2x3_F32_With_Vec3_Vec3) { +TEST_F(SpvBuilderConstructorTest, Type_Mat2x3_F32_With_Vec3_Vec3) { auto* cast = mat2x3(vec3(2_f, 2_f, 2_f), vec3(2_f, 2_f, 2_f)); WrapInFunction(cast); @@ -3330,7 +3330,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Mat2x3_F32_With_Vec3_Vec3) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Mat2x3_F16_With_Vec3_Vec3) { +TEST_F(SpvBuilderConstructorTest, Type_Mat2x3_F16_With_Vec3_Vec3) { Enable(builtin::Extension::kF16); auto* cast = mat2x3(vec3(2_h, 2_h, 2_h), vec3(2_h, 2_h, 2_h)); @@ -3350,7 +3350,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Mat2x3_F16_With_Vec3_Vec3) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Mat3x3_F32_With_Vec3_Vec3_Vec3) { +TEST_F(SpvBuilderConstructorTest, Type_Mat3x3_F32_With_Vec3_Vec3_Vec3) { auto* cast = mat3x3(vec3(2_f, 2_f, 2_f), vec3(2_f, 2_f, 2_f), vec3(2_f, 2_f, 2_f)); WrapInFunction(cast); @@ -3369,7 +3369,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Mat3x3_F32_With_Vec3_Vec3_Vec3) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Mat3x3_F16_With_Vec3_Vec3_Vec3) { +TEST_F(SpvBuilderConstructorTest, Type_Mat3x3_F16_With_Vec3_Vec3_Vec3) { Enable(builtin::Extension::kF16); auto* cast = @@ -3390,7 +3390,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Mat3x3_F16_With_Vec3_Vec3_Vec3) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Mat4x3_F32_With_Vec3_Vec3_Vec3_Vec3) { +TEST_F(SpvBuilderConstructorTest, Type_Mat4x3_F32_With_Vec3_Vec3_Vec3_Vec3) { auto* cast = mat4x3(vec3(2_f, 2_f, 2_f), vec3(2_f, 2_f, 2_f), vec3(2_f, 2_f, 2_f), vec3(2_f, 2_f, 2_f)); WrapInFunction(cast); @@ -3409,7 +3409,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Mat4x3_F32_With_Vec3_Vec3_Vec3_Vec3) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Mat4x3_F16_With_Vec3_Vec3_Vec3_Vec3) { +TEST_F(SpvBuilderConstructorTest, Type_Mat4x3_F16_With_Vec3_Vec3_Vec3_Vec3) { Enable(builtin::Extension::kF16); auto* cast = mat4x3(vec3(2_h, 2_h, 2_h), vec3(2_h, 2_h, 2_h), @@ -3430,7 +3430,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Mat4x3_F16_With_Vec3_Vec3_Vec3_Vec3) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Mat2x4_F32_With_Vec4_Vec4) { +TEST_F(SpvBuilderConstructorTest, Type_Mat2x4_F32_With_Vec4_Vec4) { auto* cast = mat2x4(vec4(2_f, 2_f, 2_f, 2_f), vec4(2_f, 2_f, 2_f, 2_f)); WrapInFunction(cast); @@ -3448,7 +3448,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Mat2x4_F32_With_Vec4_Vec4) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Mat2x4_F16_With_Vec4_Vec4) { +TEST_F(SpvBuilderConstructorTest, Type_Mat2x4_F16_With_Vec4_Vec4) { Enable(builtin::Extension::kF16); auto* cast = mat2x4(vec4(2_h, 2_h, 2_h, 2_h), vec4(2_h, 2_h, 2_h, 2_h)); @@ -3468,7 +3468,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Mat2x4_F16_With_Vec4_Vec4) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Mat3x4_F32_With_Vec4_Vec4_Vec4) { +TEST_F(SpvBuilderConstructorTest, Type_Mat3x4_F32_With_Vec4_Vec4_Vec4) { auto* cast = mat3x4(vec4(2_f, 2_f, 2_f, 2_f), vec4(2_f, 2_f, 2_f, 2_f), vec4(2_f, 2_f, 2_f, 2_f)); WrapInFunction(cast); @@ -3487,7 +3487,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Mat3x4_F32_With_Vec4_Vec4_Vec4) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Mat3x4_F16_With_Vec4_Vec4_Vec4) { +TEST_F(SpvBuilderConstructorTest, Type_Mat3x4_F16_With_Vec4_Vec4_Vec4) { Enable(builtin::Extension::kF16); auto* cast = mat3x4(vec4(2_h, 2_h, 2_h, 2_h), vec4(2_h, 2_h, 2_h, 2_h), @@ -3508,7 +3508,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Mat3x4_F16_With_Vec4_Vec4_Vec4) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Mat4x4_F32_With_Vec4_Vec4_Vec4_Vec4) { +TEST_F(SpvBuilderConstructorTest, Type_Mat4x4_F32_With_Vec4_Vec4_Vec4_Vec4) { auto* cast = mat4x4(vec4(2_f, 2_f, 2_f, 2_f), vec4(2_f, 2_f, 2_f, 2_f), vec4(2_f, 2_f, 2_f, 2_f), vec4(2_f, 2_f, 2_f, 2_f)); WrapInFunction(cast); @@ -3527,7 +3527,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Mat4x4_F32_With_Vec4_Vec4_Vec4_Vec4) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Mat4x4_F16_With_Vec4_Vec4_Vec4_Vec4) { +TEST_F(SpvBuilderConstructorTest, Type_Mat4x4_F16_With_Vec4_Vec4_Vec4_Vec4) { Enable(builtin::Extension::kF16); auto* cast = mat4x4(vec4(2_h, 2_h, 2_h, 2_h), vec4(2_h, 2_h, 2_h, 2_h), @@ -3548,7 +3548,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Mat4x4_F16_With_Vec4_Vec4_Vec4_Vec4) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Array_5_F32) { +TEST_F(SpvBuilderConstructorTest, Type_Array_5_F32) { auto* cast = array(2_f, 2_f, 2_f, 2_f, 2_f); WrapInFunction(cast); @@ -3566,7 +3566,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Array_5_F32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Array_5_F16) { +TEST_F(SpvBuilderConstructorTest, Type_Array_5_F16) { Enable(builtin::Extension::kF16); auto* cast = array(2_h, 2_h, 2_h, 2_h, 2_h); @@ -3586,7 +3586,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Array_5_F16) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Array_2_Vec3_F32) { +TEST_F(SpvBuilderConstructorTest, Type_Array_2_Vec3_F32) { auto* first = vec3(1_f, 2_f, 3_f); auto* second = vec3(1_f, 2_f, 3_f); auto* t = Call(ty.array(ty.vec3(), 2_u), first, second); @@ -3608,7 +3608,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Array_2_Vec3_F32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Array_2_Vec3_F16) { +TEST_F(SpvBuilderConstructorTest, Type_Array_2_Vec3_F16) { Enable(builtin::Extension::kF16); auto* first = vec3(1_h, 2_h, 3_h); @@ -3632,7 +3632,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Array_2_Vec3_F16) { )"); } -TEST_F(SpvBuilderInitializerTest, CommonInitializer_TwoVectors) { +TEST_F(SpvBuilderConstructorTest, CommonInitializer_TwoVectors) { auto* v1 = vec3(2_f, 2_f, 2_f); auto* v2 = vec3(2_f, 2_f, 2_f); WrapInFunction(WrapInStatement(v1), WrapInStatement(v2)); @@ -3650,7 +3650,7 @@ TEST_F(SpvBuilderInitializerTest, CommonInitializer_TwoVectors) { )"); } -TEST_F(SpvBuilderInitializerTest, CommonInitializer_TwoArrays) { +TEST_F(SpvBuilderConstructorTest, CommonInitializer_TwoArrays) { auto* a1 = array(2_f, 2_f, 2_f); auto* a2 = array(2_f, 2_f, 2_f); WrapInFunction(WrapInStatement(a1), WrapInStatement(a2)); @@ -3670,7 +3670,7 @@ TEST_F(SpvBuilderInitializerTest, CommonInitializer_TwoArrays) { )"); } -TEST_F(SpvBuilderInitializerTest, CommonInitializer_Array_VecArray) { +TEST_F(SpvBuilderConstructorTest, CommonInitializer_Array_VecArray) { // Test that initializers of different types with the same values produce // different OpConstantComposite instructions. // crbug.com/tint/777 @@ -3695,7 +3695,7 @@ TEST_F(SpvBuilderInitializerTest, CommonInitializer_Array_VecArray) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Struct) { +TEST_F(SpvBuilderConstructorTest, Type_Struct) { auto* s = Structure("my_struct", utils::Vector{ Member("a", ty.f32()), Member("b", ty.vec3()), @@ -3720,7 +3720,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Struct) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_ZeroInit_F32) { +TEST_F(SpvBuilderConstructorTest, Type_ZeroInit_F32) { auto* t = Call(); WrapInFunction(t); @@ -3737,7 +3737,7 @@ TEST_F(SpvBuilderInitializerTest, Type_ZeroInit_F32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_ZeroInit_F16) { +TEST_F(SpvBuilderConstructorTest, Type_ZeroInit_F16) { Enable(builtin::Extension::kF16); auto* t = Call(); @@ -3756,7 +3756,7 @@ TEST_F(SpvBuilderInitializerTest, Type_ZeroInit_F16) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_ZeroInit_I32) { +TEST_F(SpvBuilderConstructorTest, Type_ZeroInit_I32) { auto* t = Call(); WrapInFunction(t); @@ -3773,7 +3773,7 @@ TEST_F(SpvBuilderInitializerTest, Type_ZeroInit_I32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_ZeroInit_U32) { +TEST_F(SpvBuilderConstructorTest, Type_ZeroInit_U32) { auto* t = Call(); WrapInFunction(t); @@ -3790,7 +3790,7 @@ TEST_F(SpvBuilderInitializerTest, Type_ZeroInit_U32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_ZeroInit_Bool) { +TEST_F(SpvBuilderConstructorTest, Type_ZeroInit_Bool) { auto* t = Call(); WrapInFunction(t); @@ -3807,7 +3807,7 @@ TEST_F(SpvBuilderInitializerTest, Type_ZeroInit_Bool) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_ZeroInit_Vector) { +TEST_F(SpvBuilderConstructorTest, Type_ZeroInit_Vector) { auto* t = vec2(); WrapInFunction(t); @@ -3825,7 +3825,7 @@ TEST_F(SpvBuilderInitializerTest, Type_ZeroInit_Vector) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_ZeroInit_Matrix_F32) { +TEST_F(SpvBuilderConstructorTest, Type_ZeroInit_Matrix_F32) { auto* t = mat4x2(); WrapInFunction(t); @@ -3844,7 +3844,7 @@ TEST_F(SpvBuilderInitializerTest, Type_ZeroInit_Matrix_F32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_ZeroInit_Matrix_F16) { +TEST_F(SpvBuilderConstructorTest, Type_ZeroInit_Matrix_F16) { Enable(builtin::Extension::kF16); auto* t = mat4x2(); @@ -3865,7 +3865,7 @@ TEST_F(SpvBuilderInitializerTest, Type_ZeroInit_Matrix_F16) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_ZeroInit_Array) { +TEST_F(SpvBuilderConstructorTest, Type_ZeroInit_Array) { auto* t = array(); WrapInFunction(t); @@ -3885,7 +3885,7 @@ TEST_F(SpvBuilderInitializerTest, Type_ZeroInit_Array) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_ZeroInit_Struct) { +TEST_F(SpvBuilderConstructorTest, Type_ZeroInit_Struct) { auto* s = Structure("my_struct", utils::Vector{Member("a", ty.f32())}); auto* t = Call(ty.Of(s)); WrapInFunction(t); @@ -3903,7 +3903,7 @@ TEST_F(SpvBuilderInitializerTest, Type_ZeroInit_Struct) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Convert_U32_To_I32) { +TEST_F(SpvBuilderConstructorTest, Type_Convert_U32_To_I32) { auto* var = Decl(Var("x", ty.u32(), Expr(2_u))); auto* cast = Call("x"); WrapInFunction(var, cast); @@ -3927,7 +3927,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_U32_To_I32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Convert_F32_To_I32) { +TEST_F(SpvBuilderConstructorTest, Type_Convert_F32_To_I32) { auto* var = Decl(Var("x", ty.f32(), Expr(2.4_f))); auto* cast = Call("x"); WrapInFunction(var, cast); @@ -3951,7 +3951,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_F32_To_I32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Convert_F16_To_I32) { +TEST_F(SpvBuilderConstructorTest, Type_Convert_F16_To_I32) { Enable(builtin::Extension::kF16); auto* var = Decl(Var("x", ty.f16(), Expr(2.4_h))); @@ -3977,7 +3977,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_F16_To_I32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Convert_I32_To_U32) { +TEST_F(SpvBuilderConstructorTest, Type_Convert_I32_To_U32) { auto* var = Decl(Var("x", ty.i32(), Expr(2_i))); auto* cast = Call("x"); WrapInFunction(var, cast); @@ -4001,7 +4001,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_I32_To_U32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Convert_F32_To_U32) { +TEST_F(SpvBuilderConstructorTest, Type_Convert_F32_To_U32) { auto* var = Decl(Var("x", ty.f32(), Expr(2.4_f))); auto* cast = Call("x"); WrapInFunction(var, cast); @@ -4025,7 +4025,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_F32_To_U32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Convert_F16_To_U32) { +TEST_F(SpvBuilderConstructorTest, Type_Convert_F16_To_U32) { Enable(builtin::Extension::kF16); auto* var = Decl(Var("x", ty.f16(), Expr(2.4_h))); @@ -4051,7 +4051,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_F16_To_U32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Convert_I32_To_F32) { +TEST_F(SpvBuilderConstructorTest, Type_Convert_I32_To_F32) { auto* var = Decl(Var("x", ty.i32(), Expr(2_i))); auto* cast = Call("x"); WrapInFunction(var, cast); @@ -4075,7 +4075,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_I32_To_F32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Convert_U32_To_F32) { +TEST_F(SpvBuilderConstructorTest, Type_Convert_U32_To_F32) { auto* var = Decl(Var("x", ty.u32(), Expr(2_u))); auto* cast = Call("x"); WrapInFunction(var, cast); @@ -4099,7 +4099,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_U32_To_F32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Convert_F16_To_F32) { +TEST_F(SpvBuilderConstructorTest, Type_Convert_F16_To_F32) { Enable(builtin::Extension::kF16); auto* var = Decl(Var("x", ty.f16(), Expr(2_h))); @@ -4125,7 +4125,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_F16_To_F32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Convert_I32_To_F16) { +TEST_F(SpvBuilderConstructorTest, Type_Convert_I32_To_F16) { Enable(builtin::Extension::kF16); auto* var = Decl(Var("x", ty.i32(), Expr(2_i))); @@ -4151,7 +4151,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_I32_To_F16) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Convert_U32_To_F16) { +TEST_F(SpvBuilderConstructorTest, Type_Convert_U32_To_F16) { Enable(builtin::Extension::kF16); auto* var = Decl(Var("x", ty.u32(), Expr(2_u))); @@ -4177,7 +4177,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_U32_To_F16) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Convert_F32_To_F16) { +TEST_F(SpvBuilderConstructorTest, Type_Convert_F32_To_F16) { Enable(builtin::Extension::kF16); auto* var = Decl(Var("x", ty.f32(), Expr(2_f))); @@ -4203,7 +4203,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_F32_To_F16) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_U32_to_I32) { +TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_U32_to_I32) { auto* var = GlobalVar("i", ty.vec3(), builtin::AddressSpace::kPrivate); auto* cast = vec3("i"); @@ -4229,7 +4229,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_U32_to_I32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_F32_to_I32) { +TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_F32_to_I32) { auto* var = GlobalVar("i", ty.vec3(), builtin::AddressSpace::kPrivate); auto* cast = vec3("i"); @@ -4255,7 +4255,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_F32_to_I32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_F16_to_I32) { +TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_F16_to_I32) { Enable(builtin::Extension::kF16); auto* var = GlobalVar("i", ty.vec3(), builtin::AddressSpace::kPrivate); @@ -4283,7 +4283,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_F16_to_I32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_I32_to_U32) { +TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_I32_to_U32) { auto* var = GlobalVar("i", ty.vec3(), builtin::AddressSpace::kPrivate); auto* cast = vec3("i"); @@ -4309,7 +4309,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_I32_to_U32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_F32_to_U32) { +TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_F32_to_U32) { auto* var = GlobalVar("i", ty.vec3(), builtin::AddressSpace::kPrivate); auto* cast = vec3("i"); @@ -4335,7 +4335,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_F32_to_U32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_F16_to_U32) { +TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_F16_to_U32) { Enable(builtin::Extension::kF16); auto* var = GlobalVar("i", ty.vec3(), builtin::AddressSpace::kPrivate); @@ -4363,7 +4363,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_F16_to_U32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_I32_to_F32) { +TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_I32_to_F32) { auto* var = GlobalVar("i", ty.vec3(), builtin::AddressSpace::kPrivate); auto* cast = vec3("i"); @@ -4389,7 +4389,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_I32_to_F32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_U32_to_F32) { +TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_U32_to_F32) { auto* var = GlobalVar("i", ty.vec3(), builtin::AddressSpace::kPrivate); auto* cast = vec3("i"); @@ -4415,7 +4415,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_U32_to_F32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_F16_to_F32) { +TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_F16_to_F32) { Enable(builtin::Extension::kF16); auto* var = GlobalVar("i", ty.vec3(), builtin::AddressSpace::kPrivate); @@ -4443,7 +4443,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_F16_to_F32) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_I32_to_F16) { +TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_I32_to_F16) { Enable(builtin::Extension::kF16); auto* var = GlobalVar("i", ty.vec3(), builtin::AddressSpace::kPrivate); @@ -4471,7 +4471,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_I32_to_F16) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_U32_to_F16) { +TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_U32_to_F16) { Enable(builtin::Extension::kF16); auto* var = GlobalVar("i", ty.vec3(), builtin::AddressSpace::kPrivate); @@ -4499,7 +4499,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_U32_to_F16) { )"); } -TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_F32_to_F16) { +TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_F32_to_F16) { Enable(builtin::Extension::kF16); auto* var = GlobalVar("i", ty.vec3(), builtin::AddressSpace::kPrivate); @@ -4527,18 +4527,18 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_F32_to_F16) { )"); } -TEST_F(SpvBuilderInitializerTest, IsInitializerConst_GlobalVectorWithAllConstInitializers) { +TEST_F(SpvBuilderConstructorTest, IsConstructorConst_GlobalVectorWithAllConstInitializers) { // vec3(1.0, 2.0, 3.0) -> true auto* t = vec3(1_f, 2_f, 3_f); WrapInFunction(t); spirv::Builder& b = Build(); - EXPECT_TRUE(b.IsInitializerConst(t)); + EXPECT_TRUE(b.IsConstructorConst(t)); EXPECT_FALSE(b.has_error()); } -TEST_F(SpvBuilderInitializerTest, IsInitializerConst_GlobalArrayWithAllConstInitializers) { +TEST_F(SpvBuilderConstructorTest, IsConstructorConst_GlobalArrayWithAllConstInitializers) { // array, 2u>(vec3(1.0, 2.0, 3.0), vec3(1.0, 2.0, 3.0)) // -> true auto* t = @@ -4547,11 +4547,11 @@ TEST_F(SpvBuilderInitializerTest, IsInitializerConst_GlobalArrayWithAllConstInit spirv::Builder& b = Build(); - EXPECT_TRUE(b.IsInitializerConst(t)); + EXPECT_TRUE(b.IsConstructorConst(t)); EXPECT_FALSE(b.has_error()); } -TEST_F(SpvBuilderInitializerTest, IsInitializerConst_GlobalVectorWithMatchingTypeInitializers) { +TEST_F(SpvBuilderConstructorTest, IsConstructorConst_GlobalVectorWithMatchingTypeInitializers) { // vec2(f32(1.0), f32(2.0)) -> false auto* t = vec2(Call(1_f), Call(2_f)); @@ -4559,11 +4559,11 @@ TEST_F(SpvBuilderInitializerTest, IsInitializerConst_GlobalVectorWithMatchingTyp spirv::Builder& b = Build(); - EXPECT_TRUE(b.IsInitializerConst(t)); + EXPECT_TRUE(b.IsConstructorConst(t)); EXPECT_FALSE(b.has_error()); } -TEST_F(SpvBuilderInitializerTest, IsInitializerConst_GlobalWithTypeConversionInitializer) { +TEST_F(SpvBuilderConstructorTest, IsConstructorConst_GlobalWithTypeConversionInitializer) { // vec2(f32(1), f32(2)) -> false auto* t = vec2(Call(1_i), Call(2_i)); @@ -4571,11 +4571,11 @@ TEST_F(SpvBuilderInitializerTest, IsInitializerConst_GlobalWithTypeConversionIni spirv::Builder& b = Build(); - EXPECT_FALSE(b.IsInitializerConst(t)); + EXPECT_FALSE(b.IsConstructorConst(t)); EXPECT_FALSE(b.has_error()); } -TEST_F(SpvBuilderInitializerTest, IsInitializerConst_VectorWithAllConstInitializers) { +TEST_F(SpvBuilderConstructorTest, IsConstructorConst_VectorWithAllConstInitializers) { // vec3(1.0, 2.0, 3.0) -> true auto* t = vec3(1_f, 2_f, 3_f); @@ -4583,11 +4583,11 @@ TEST_F(SpvBuilderInitializerTest, IsInitializerConst_VectorWithAllConstInitializ spirv::Builder& b = Build(); - EXPECT_TRUE(b.IsInitializerConst(t)); + EXPECT_TRUE(b.IsConstructorConst(t)); EXPECT_FALSE(b.has_error()); } -TEST_F(SpvBuilderInitializerTest, IsInitializerConst_Vector_WithIdent) { +TEST_F(SpvBuilderConstructorTest, IsConstructorConst_Vector_WithIdent) { // vec3(a, b, c) -> false GlobalVar("a", ty.f32(), builtin::AddressSpace::kPrivate); @@ -4599,11 +4599,11 @@ TEST_F(SpvBuilderInitializerTest, IsInitializerConst_Vector_WithIdent) { spirv::Builder& b = Build(); - EXPECT_FALSE(b.IsInitializerConst(t)); + EXPECT_FALSE(b.IsConstructorConst(t)); EXPECT_FALSE(b.has_error()); } -TEST_F(SpvBuilderInitializerTest, IsInitializerConst_ArrayWithAllConstInitializers) { +TEST_F(SpvBuilderConstructorTest, IsConstructorConst_ArrayWithAllConstInitializers) { // array, 2u>(vec3(1.0, 2.0, 3.0), vec3(1.0, 2.0, 3.0)) // -> true @@ -4615,11 +4615,11 @@ TEST_F(SpvBuilderInitializerTest, IsInitializerConst_ArrayWithAllConstInitialize spirv::Builder& b = Build(); - EXPECT_TRUE(b.IsInitializerConst(t)); + EXPECT_TRUE(b.IsConstructorConst(t)); EXPECT_FALSE(b.has_error()); } -TEST_F(SpvBuilderInitializerTest, IsInitializerConst_VectorWithTypeConversionConstInitializers) { +TEST_F(SpvBuilderConstructorTest, IsConstructorConst_VectorWithTypeConversionConstInitializers) { // vec2(f32(1), f32(2)) -> false auto* t = vec2(Call(1_i), Call(2_i)); @@ -4627,21 +4627,21 @@ TEST_F(SpvBuilderInitializerTest, IsInitializerConst_VectorWithTypeConversionCon spirv::Builder& b = Build(); - EXPECT_FALSE(b.IsInitializerConst(t)); + EXPECT_FALSE(b.IsConstructorConst(t)); EXPECT_FALSE(b.has_error()); } -TEST_F(SpvBuilderInitializerTest, IsInitializerConst_BitCastScalars) { +TEST_F(SpvBuilderConstructorTest, IsConstructorConst_BitCastScalars) { auto* t = vec2(Call(1_i), Call(1_i)); WrapInFunction(t); spirv::Builder& b = Build(); - EXPECT_FALSE(b.IsInitializerConst(t)); + EXPECT_FALSE(b.IsConstructorConst(t)); EXPECT_FALSE(b.has_error()); } -TEST_F(SpvBuilderInitializerTest, IsInitializerConst_Struct) { +TEST_F(SpvBuilderConstructorTest, IsConstructorConst_Struct) { auto* s = Structure("my_struct", utils::Vector{ Member("a", ty.f32()), Member("b", ty.vec3()), @@ -4652,11 +4652,11 @@ TEST_F(SpvBuilderInitializerTest, IsInitializerConst_Struct) { spirv::Builder& b = Build(); - EXPECT_TRUE(b.IsInitializerConst(t)); + EXPECT_TRUE(b.IsConstructorConst(t)); EXPECT_FALSE(b.has_error()); } -TEST_F(SpvBuilderInitializerTest, IsInitializerConst_Struct_WithIdentSubExpression) { +TEST_F(SpvBuilderConstructorTest, IsConstructorConst_Struct_WithIdentSubExpression) { auto* s = Structure("my_struct", utils::Vector{ Member("a", ty.f32()), Member("b", ty.vec3()), @@ -4670,11 +4670,11 @@ TEST_F(SpvBuilderInitializerTest, IsInitializerConst_Struct_WithIdentSubExpressi spirv::Builder& b = Build(); - EXPECT_FALSE(b.IsInitializerConst(t)); + EXPECT_FALSE(b.IsConstructorConst(t)); EXPECT_FALSE(b.has_error()); } -TEST_F(SpvBuilderInitializerTest, ConstantCompositeScoping) { +TEST_F(SpvBuilderConstructorTest, ConstantCompositeScoping) { // if (true) { // let x = vec3(1.0, 2.0, 3.0); // } @@ -4715,9 +4715,9 @@ OpFunctionEnd } // TODO(crbug.com/tint/1155) Implement when overrides are fully implemented. -// TEST_F(SpvBuilderInitializerTest, SpecConstantCompositeScoping) +// TEST_F(SpvBuilderConstructorTest, SpecConstantCompositeScoping) -TEST_F(SpvBuilderInitializerTest, CompositeConstructScoping) { +TEST_F(SpvBuilderConstructorTest, CompositeConstructScoping) { // var one = 1.0; // if (true) { // let x = vec3(one, 2.0, 3.0); diff --git a/src/tint/writer/wgsl/generator_impl_initializer_test.cc b/src/tint/writer/wgsl/generator_impl_constructor_test.cc similarity index 83% rename from src/tint/writer/wgsl/generator_impl_initializer_test.cc rename to src/tint/writer/wgsl/generator_impl_constructor_test.cc index 0d5686ee2d..c815f423a2 100644 --- a/src/tint/writer/wgsl/generator_impl_initializer_test.cc +++ b/src/tint/writer/wgsl/generator_impl_constructor_test.cc @@ -22,9 +22,9 @@ using namespace tint::number_suffixes; // NOLINT namespace tint::writer::wgsl { namespace { -using WgslGeneratorImplTest = TestHelper; +using WgslGeneratorImplTest_Constructor = TestHelper; -TEST_F(WgslGeneratorImplTest, EmitInitializer_Bool) { +TEST_F(WgslGeneratorImplTest_Constructor, Bool) { WrapInFunction(Expr(false)); GeneratorImpl& gen = Build(); @@ -33,7 +33,7 @@ TEST_F(WgslGeneratorImplTest, EmitInitializer_Bool) { EXPECT_THAT(gen.result(), HasSubstr("false")); } -TEST_F(WgslGeneratorImplTest, EmitInitializer_Int) { +TEST_F(WgslGeneratorImplTest_Constructor, Int) { WrapInFunction(Expr(-12345_i)); GeneratorImpl& gen = Build(); @@ -42,7 +42,7 @@ TEST_F(WgslGeneratorImplTest, EmitInitializer_Int) { EXPECT_THAT(gen.result(), HasSubstr("-12345")); } -TEST_F(WgslGeneratorImplTest, EmitInitializer_UInt) { +TEST_F(WgslGeneratorImplTest_Constructor, UInt) { WrapInFunction(Expr(56779_u)); GeneratorImpl& gen = Build(); @@ -51,7 +51,7 @@ TEST_F(WgslGeneratorImplTest, EmitInitializer_UInt) { EXPECT_THAT(gen.result(), HasSubstr("56779u")); } -TEST_F(WgslGeneratorImplTest, EmitInitializer_F32) { +TEST_F(WgslGeneratorImplTest_Constructor, F32) { // Use a number close to 1<<30 but whose decimal representation ends in 0. WrapInFunction(Expr(f32((1 << 30) - 4))); @@ -61,7 +61,7 @@ TEST_F(WgslGeneratorImplTest, EmitInitializer_F32) { EXPECT_THAT(gen.result(), HasSubstr("1073741824.0f")); } -TEST_F(WgslGeneratorImplTest, EmitInitializer_F16) { +TEST_F(WgslGeneratorImplTest_Constructor, F16) { Enable(builtin::Extension::kF16); // Use a number close to 1<<16 but whose decimal representation ends in 0. @@ -73,7 +73,7 @@ TEST_F(WgslGeneratorImplTest, EmitInitializer_F16) { EXPECT_THAT(gen.result(), HasSubstr("32752.0h")); } -TEST_F(WgslGeneratorImplTest, EmitInitializer_Type_F32) { +TEST_F(WgslGeneratorImplTest_Constructor, Type_F32) { WrapInFunction(Call(Expr(-1.2e-5_f))); GeneratorImpl& gen = Build(); @@ -82,7 +82,7 @@ TEST_F(WgslGeneratorImplTest, EmitInitializer_Type_F32) { EXPECT_THAT(gen.result(), HasSubstr("f32(-0.000012f)")); } -TEST_F(WgslGeneratorImplTest, EmitInitializer_Type_F16) { +TEST_F(WgslGeneratorImplTest_Constructor, Type_F16) { Enable(builtin::Extension::kF16); WrapInFunction(Call(Expr(-1.2e-5_h))); @@ -93,7 +93,7 @@ TEST_F(WgslGeneratorImplTest, EmitInitializer_Type_F16) { EXPECT_THAT(gen.result(), HasSubstr("f16(-1.19805336e-05h)")); } -TEST_F(WgslGeneratorImplTest, EmitInitializer_Type_Bool) { +TEST_F(WgslGeneratorImplTest_Constructor, Type_Bool) { WrapInFunction(Call(true)); GeneratorImpl& gen = Build(); @@ -102,7 +102,7 @@ TEST_F(WgslGeneratorImplTest, EmitInitializer_Type_Bool) { EXPECT_THAT(gen.result(), HasSubstr("bool(true)")); } -TEST_F(WgslGeneratorImplTest, EmitInitializer_Type_Int) { +TEST_F(WgslGeneratorImplTest_Constructor, Type_Int) { WrapInFunction(Call(-12345_i)); GeneratorImpl& gen = Build(); @@ -111,7 +111,7 @@ TEST_F(WgslGeneratorImplTest, EmitInitializer_Type_Int) { EXPECT_THAT(gen.result(), HasSubstr("i32(-12345i)")); } -TEST_F(WgslGeneratorImplTest, EmitInitializer_Type_Uint) { +TEST_F(WgslGeneratorImplTest_Constructor, Type_Uint) { WrapInFunction(Call(12345_u)); GeneratorImpl& gen = Build(); @@ -120,7 +120,7 @@ TEST_F(WgslGeneratorImplTest, EmitInitializer_Type_Uint) { EXPECT_THAT(gen.result(), HasSubstr("u32(12345u)")); } -TEST_F(WgslGeneratorImplTest, EmitInitializer_Type_Vec_F32) { +TEST_F(WgslGeneratorImplTest_Constructor, Type_Vec_F32) { WrapInFunction(vec3(1_f, 2_f, 3_f)); GeneratorImpl& gen = Build(); @@ -129,7 +129,7 @@ TEST_F(WgslGeneratorImplTest, EmitInitializer_Type_Vec_F32) { EXPECT_THAT(gen.result(), HasSubstr("vec3(1.0f, 2.0f, 3.0f)")); } -TEST_F(WgslGeneratorImplTest, EmitInitializer_Type_Vec_F16) { +TEST_F(WgslGeneratorImplTest_Constructor, Type_Vec_F16) { Enable(builtin::Extension::kF16); WrapInFunction(vec3(1_h, 2_h, 3_h)); @@ -140,7 +140,7 @@ TEST_F(WgslGeneratorImplTest, EmitInitializer_Type_Vec_F16) { EXPECT_THAT(gen.result(), HasSubstr("vec3(1.0h, 2.0h, 3.0h)")); } -TEST_F(WgslGeneratorImplTest, EmitInitializer_Type_Mat_F32) { +TEST_F(WgslGeneratorImplTest_Constructor, Type_Mat_F32) { WrapInFunction(mat2x3(vec3(1_f, 2_f, 3_f), vec3(3_f, 4_f, 5_f))); GeneratorImpl& gen = Build(); @@ -150,7 +150,7 @@ TEST_F(WgslGeneratorImplTest, EmitInitializer_Type_Mat_F32) { "vec3(3.0f, 4.0f, 5.0f))")); } -TEST_F(WgslGeneratorImplTest, EmitInitializer_Type_Mat_F16) { +TEST_F(WgslGeneratorImplTest_Constructor, Type_Mat_F16) { Enable(builtin::Extension::kF16); WrapInFunction(mat2x3(vec3(1_h, 2_h, 3_h), vec3(3_h, 4_h, 5_h))); @@ -162,7 +162,7 @@ TEST_F(WgslGeneratorImplTest, EmitInitializer_Type_Mat_F16) { "vec3(3.0h, 4.0h, 5.0h))")); } -TEST_F(WgslGeneratorImplTest, EmitInitializer_Type_Array) { +TEST_F(WgslGeneratorImplTest_Constructor, Type_Array) { WrapInFunction(Call(ty.array(ty.vec3(), 3_u), vec3(1_f, 2_f, 3_f), vec3(4_f, 5_f, 6_f), vec3(7_f, 8_f, 9_f))); @@ -174,7 +174,7 @@ TEST_F(WgslGeneratorImplTest, EmitInitializer_Type_Array) { "vec3(4.0f, 5.0f, 6.0f), vec3(7.0f, 8.0f, 9.0f))")); } -TEST_F(WgslGeneratorImplTest, EmitInitializer_Type_ImplicitArray) { +TEST_F(WgslGeneratorImplTest_Constructor, Type_ImplicitArray) { WrapInFunction(Call(ty.array(), vec3(1_f, 2_f, 3_f), vec3(4_f, 5_f, 6_f), vec3(7_f, 8_f, 9_f))); diff --git a/test/tint/array/assign_to_function_var.wgsl b/test/tint/array/assign_to_function_var.wgsl index ac8aa7110c..c89220d4c2 100644 --- a/test/tint/array/assign_to_function_var.wgsl +++ b/test/tint/array/assign_to_function_var.wgsl @@ -22,7 +22,7 @@ fn foo(src_param : ArrayType) { var dst : ArrayType; - // Assign from type constructor. + // Assign from value constructor. dst = ArrayType(vec4(1), vec4(2), vec4(3), vec4(3)); // Assign from parameter. diff --git a/test/tint/array/assign_to_private_var.wgsl b/test/tint/array/assign_to_private_var.wgsl index 07f05a2a4c..8180341f3e 100644 --- a/test/tint/array/assign_to_private_var.wgsl +++ b/test/tint/array/assign_to_private_var.wgsl @@ -23,7 +23,7 @@ fn ret_struct_arr() -> S { fn foo(src_param : ArrayType) { var src_function : ArrayType; - // Assign from type constructor. + // Assign from value constructor. dst = ArrayType(vec4(1), vec4(2), vec4(3), vec4(3)); // Assign from parameter. diff --git a/test/tint/array/assign_to_storage_var.wgsl b/test/tint/array/assign_to_storage_var.wgsl index 1b135c8b1c..69fc1ab005 100644 --- a/test/tint/array/assign_to_storage_var.wgsl +++ b/test/tint/array/assign_to_storage_var.wgsl @@ -27,7 +27,7 @@ fn ret_struct_arr() -> S { fn foo(src_param : ArrayType) { var src_function : ArrayType; - // Assign from type constructor. + // Assign from value constructor. dst.arr = ArrayType(vec4(1), vec4(2), vec4(3), vec4(3)); // Assign from parameter. diff --git a/test/tint/array/assign_to_workgroup_var.wgsl b/test/tint/array/assign_to_workgroup_var.wgsl index eb3a80b47e..74f3e67341 100644 --- a/test/tint/array/assign_to_workgroup_var.wgsl +++ b/test/tint/array/assign_to_workgroup_var.wgsl @@ -23,7 +23,7 @@ fn ret_struct_arr() -> S { fn foo(src_param : ArrayType) { var src_function : ArrayType; - // Assign from type constructor. + // Assign from value constructor. dst = ArrayType(vec4(1), vec4(2), vec4(3), vec4(3)); // Assign from parameter. diff --git a/tools/src/tint/intrinsic/ast/ast.go b/tools/src/tint/intrinsic/ast/ast.go index 321370aa60..98a8638748 100644 --- a/tools/src/tint/intrinsic/ast/ast.go +++ b/tools/src/tint/intrinsic/ast/ast.go @@ -29,7 +29,7 @@ type AST struct { Types []TypeDecl Matchers []MatcherDecl Builtins []IntrinsicDecl - Initializers []IntrinsicDecl + Constructors []IntrinsicDecl Converters []IntrinsicDecl Operators []IntrinsicDecl } @@ -52,7 +52,7 @@ func (a AST) String() string { fmt.Fprintf(&sb, "%v", b) fmt.Fprintln(&sb) } - for _, o := range a.Initializers { + for _, o := range a.Constructors { fmt.Fprintf(&sb, "%v", o) fmt.Fprintln(&sb) } @@ -123,10 +123,10 @@ const ( // Operator is a unary or binary operator. // Declared with 'op'. Operator IntrinsicKind = "operator" - // Initializer is a type initializer function. + // Constructor is a value constructor function. // Declared with 'init'. - Initializer IntrinsicKind = "initializer" - // Converter is a type conversion function. + Constructor IntrinsicKind = "constructor" + // Converter is a value conversion function. // Declared with 'conv'. Converter IntrinsicKind = "converter" ) @@ -149,8 +149,8 @@ func (i IntrinsicDecl) Format(w fmt.State, verb rune) { fmt.Fprintf(w, "fn ") case Operator: fmt.Fprintf(w, "op ") - case Initializer: - fmt.Fprintf(w, "init ") + case Constructor: + fmt.Fprintf(w, "ctor ") case Converter: fmt.Fprintf(w, "conv ") } diff --git a/tools/src/tint/intrinsic/gen/gen.go b/tools/src/tint/intrinsic/gen/gen.go index 6bfd841b53..506e108888 100644 --- a/tools/src/tint/intrinsic/gen/gen.go +++ b/tools/src/tint/intrinsic/gen/gen.go @@ -50,7 +50,7 @@ type IntrinsicTable struct { Builtins []Intrinsic // kBuiltins table content UnaryOperators []Intrinsic // kUnaryOperators table content BinaryOperators []Intrinsic // kBinaryOperators table content - InitializersAndConverters []Intrinsic // kInitializersAndConverters table content + ConstructorsAndConverters []Intrinsic // kInitializersAndConverters table content } // TemplateType is used to create the C++ TemplateTypeInfo structure @@ -387,7 +387,7 @@ func BuildIntrinsicTable(s *sem.Sem) (*IntrinsicTable, error) { {s.Builtins, &b.Builtins}, {s.UnaryOperators, &b.UnaryOperators}, {s.BinaryOperators, &b.BinaryOperators}, - {s.InitializersAndConverters, &b.InitializersAndConverters}, + {s.ConstructorsAndConverters, &b.ConstructorsAndConverters}, } { out := make([]Intrinsic, len(intrinsics.in)) for i, f := range intrinsics.in { diff --git a/tools/src/tint/intrinsic/lexer/lexer.go b/tools/src/tint/intrinsic/lexer/lexer.go index 51045d66d3..b76b1ab559 100644 --- a/tools/src/tint/intrinsic/lexer/lexer.go +++ b/tools/src/tint/intrinsic/lexer/lexer.go @@ -104,8 +104,8 @@ func (l *lexer) lex() error { l.tok(n, tok.Enum) case "type": l.tok(n, tok.Type) - case "init": - l.tok(n, tok.Initializer) + case "ctor": + l.tok(n, tok.Constructor) case "conv": l.tok(n, tok.Converter) case "match": diff --git a/tools/src/tint/intrinsic/lexer/lexer_test.go b/tools/src/tint/intrinsic/lexer/lexer_test.go index 9eda8b6275..7d16fb6d93 100644 --- a/tools/src/tint/intrinsic/lexer/lexer_test.go +++ b/tools/src/tint/intrinsic/lexer/lexer_test.go @@ -90,7 +90,7 @@ func TestLexTokens(t *testing.T) { {"type", []tok.Token{{Kind: tok.Type, Runes: []rune("type"), Source: tok.Source{ S: loc(1, 1, 0), E: loc(1, 5, 4), }}}}, - {"init", []tok.Token{{Kind: tok.Initializer, Runes: []rune("init"), Source: tok.Source{ + {"ctor", []tok.Token{{Kind: tok.Constructor, Runes: []rune("ctor"), Source: tok.Source{ S: loc(1, 1, 0), E: loc(1, 5, 4), }}}}, {"conv", []tok.Token{{Kind: tok.Converter, Runes: []rune("conv"), Source: tok.Source{ diff --git a/tools/src/tint/intrinsic/parser/parser.go b/tools/src/tint/intrinsic/parser/parser.go index 418d543166..35f5e00960 100644 --- a/tools/src/tint/intrinsic/parser/parser.go +++ b/tools/src/tint/intrinsic/parser/parser.go @@ -72,8 +72,8 @@ func (p *parser) parse() (*ast.AST, error) { case tok.Operator: out.Operators = append(out.Operators, p.operatorDecl(attributes)) attributes = nil - case tok.Initializer: - out.Initializers = append(out.Initializers, p.initializerDecl(attributes)) + case tok.Constructor: + out.Constructors = append(out.Constructors, p.constructorDecl(attributes)) attributes = nil case tok.Converter: out.Converters = append(out.Converters, p.converterDecl(attributes)) @@ -221,12 +221,12 @@ func (p *parser) operatorDecl(decos ast.Attributes) ast.IntrinsicDecl { return f } -func (p *parser) initializerDecl(decos ast.Attributes) ast.IntrinsicDecl { - p.expect(tok.Initializer, "initializer declaration") +func (p *parser) constructorDecl(decos ast.Attributes) ast.IntrinsicDecl { + p.expect(tok.Constructor, "constructor declaration") name := p.next() f := ast.IntrinsicDecl{ Source: name.Source, - Kind: ast.Initializer, + Kind: ast.Constructor, Attributes: decos, Name: string(name.Runes), } diff --git a/tools/src/tint/intrinsic/parser/parser_test.go b/tools/src/tint/intrinsic/parser/parser_test.go index 97c41f72e1..ad4cca39bb 100644 --- a/tools/src/tint/intrinsic/parser/parser_test.go +++ b/tools/src/tint/intrinsic/parser/parser_test.go @@ -440,20 +440,20 @@ func TestParser(t *testing.T) { }, }, { /////////////////////////////////////////////////////////////////// fileutils.ThisLine(), - "init F()", + "ctor F()", ast.AST{ - Initializers: []ast.IntrinsicDecl{{ - Kind: ast.Initializer, + Constructors: []ast.IntrinsicDecl{{ + Kind: ast.Constructor, Name: "F", Parameters: ast.Parameters{}, }}, }, }, { /////////////////////////////////////////////////////////////////// fileutils.ThisLine(), - "@attr init F()", + "@attr ctor F()", ast.AST{ - Initializers: []ast.IntrinsicDecl{{ - Kind: ast.Initializer, + Constructors: []ast.IntrinsicDecl{{ + Kind: ast.Constructor, Name: "F", Attributes: ast.Attributes{ {Name: "attr", Values: nil}, @@ -463,10 +463,10 @@ func TestParser(t *testing.T) { }, }, { /////////////////////////////////////////////////////////////////// fileutils.ThisLine(), - "init F(a)", + "ctor F(a)", ast.AST{ - Initializers: []ast.IntrinsicDecl{{ - Kind: ast.Initializer, + Constructors: []ast.IntrinsicDecl{{ + Kind: ast.Constructor, Name: "F", Parameters: ast.Parameters{ {Type: ast.TemplatedName{Name: "a"}}, @@ -475,10 +475,10 @@ func TestParser(t *testing.T) { }, }, { /////////////////////////////////////////////////////////////////// fileutils.ThisLine(), - "init F(a: T)", + "ctor F(a: T)", ast.AST{ - Initializers: []ast.IntrinsicDecl{{ - Kind: ast.Initializer, + Constructors: []ast.IntrinsicDecl{{ + Kind: ast.Constructor, Name: "F", Parameters: ast.Parameters{ {Name: "a", Type: ast.TemplatedName{Name: "T"}}, @@ -487,10 +487,10 @@ func TestParser(t *testing.T) { }, }, { /////////////////////////////////////////////////////////////////// fileutils.ThisLine(), - "init F(a, b)", + "ctor F(a, b)", ast.AST{ - Initializers: []ast.IntrinsicDecl{{ - Kind: ast.Initializer, + Constructors: []ast.IntrinsicDecl{{ + Kind: ast.Constructor, Name: "F", Parameters: ast.Parameters{ {Type: ast.TemplatedName{Name: "a"}}, @@ -500,10 +500,10 @@ func TestParser(t *testing.T) { }, }, { /////////////////////////////////////////////////////////////////// fileutils.ThisLine(), - "init F >()", + "ctor F >()", ast.AST{ - Initializers: []ast.IntrinsicDecl{{ - Kind: ast.Initializer, + Constructors: []ast.IntrinsicDecl{{ + Kind: ast.Constructor, Name: "F", TemplateParams: ast.TemplateParams{ { @@ -520,10 +520,10 @@ func TestParser(t *testing.T) { }, }, { /////////////////////////////////////////////////////////////////// fileutils.ThisLine(), - "init F(a: X, b: Y)", + "ctor F(a: X, b: Y)", ast.AST{ - Initializers: []ast.IntrinsicDecl{{ - Kind: ast.Initializer, + Constructors: []ast.IntrinsicDecl{{ + Kind: ast.Constructor, Name: "F", TemplateParams: ast.TemplateParams{ {Name: "T"}, @@ -539,10 +539,10 @@ func TestParser(t *testing.T) { }, }, { /////////////////////////////////////////////////////////////////// fileutils.ThisLine(), - "init F() -> X", + "ctor F() -> X", ast.AST{ - Initializers: []ast.IntrinsicDecl{{ - Kind: ast.Initializer, + Constructors: []ast.IntrinsicDecl{{ + Kind: ast.Constructor, Name: "F", ReturnType: &ast.TemplatedName{Name: "X"}, Parameters: ast.Parameters{}, @@ -550,10 +550,10 @@ func TestParser(t *testing.T) { }, }, { /////////////////////////////////////////////////////////////////// fileutils.ThisLine(), - "init F() -> X", + "ctor F() -> X", ast.AST{ - Initializers: []ast.IntrinsicDecl{{ - Kind: ast.Initializer, + Constructors: []ast.IntrinsicDecl{{ + Kind: ast.Constructor, Name: "F", ReturnType: &ast.TemplatedName{ Name: "X", diff --git a/tools/src/tint/intrinsic/resolver/resolve.go b/tools/src/tint/intrinsic/resolver/resolve.go index 398cd3dbba..787eca7f66 100644 --- a/tools/src/tint/intrinsic/resolver/resolve.go +++ b/tools/src/tint/intrinsic/resolver/resolve.go @@ -32,7 +32,7 @@ type resolver struct { builtins map[string]*sem.Intrinsic unaryOperators map[string]*sem.Intrinsic binaryOperators map[string]*sem.Intrinsic - initializersAndConverters map[string]*sem.Intrinsic + constructorsAndConverters map[string]*sem.Intrinsic enumEntryMatchers map[*sem.EnumEntry]*sem.EnumMatcher } @@ -45,7 +45,7 @@ func Resolve(a *ast.AST) (*sem.Sem, error) { builtins: map[string]*sem.Intrinsic{}, unaryOperators: map[string]*sem.Intrinsic{}, binaryOperators: map[string]*sem.Intrinsic{}, - initializersAndConverters: map[string]*sem.Intrinsic{}, + constructorsAndConverters: map[string]*sem.Intrinsic{}, enumEntryMatchers: map[*sem.EnumEntry]*sem.EnumMatcher{}, } // Declare and resolve all the enumerators @@ -88,9 +88,9 @@ func Resolve(a *ast.AST) (*sem.Sem, error) { } } - // Declare and resolve type initializers and converters - for _, c := range a.Initializers { - if err := r.intrinsic(c, r.initializersAndConverters, &r.s.InitializersAndConverters); err != nil { + // Declare and resolve value constructors and converters + for _, c := range a.Constructors { + if err := r.intrinsic(c, r.constructorsAndConverters, &r.s.ConstructorsAndConverters); err != nil { return nil, err } } @@ -98,7 +98,7 @@ func Resolve(a *ast.AST) (*sem.Sem, error) { if len(c.Parameters) != 1 { return nil, fmt.Errorf("%v conversions must have a single parameter", c.Source) } - if err := r.intrinsic(c, r.initializersAndConverters, &r.s.InitializersAndConverters); err != nil { + if err := r.intrinsic(c, r.constructorsAndConverters, &r.s.ConstructorsAndConverters); err != nil { return nil, err } } @@ -360,8 +360,8 @@ func (r *resolver) intrinsic( switch overload.Decl.Kind { case ast.Builtin, ast.Operator: overload.ConstEvalFunction = overload.Decl.Name - case ast.Initializer: - overload.ConstEvalFunction = "Init" + case ast.Constructor: + overload.ConstEvalFunction = "Ctor" case ast.Converter: overload.ConstEvalFunction = "Conv" } @@ -601,7 +601,7 @@ func (r *resolver) calculateUniqueParameterNames() []string { r.s.Builtins, r.s.UnaryOperators, r.s.BinaryOperators, - r.s.InitializersAndConverters, + r.s.ConstructorsAndConverters, } { for _, i := range intrinsics { for _, o := range i.Overloads { diff --git a/tools/src/tint/intrinsic/resolver/resolver_test.go b/tools/src/tint/intrinsic/resolver/resolver_test.go index da1036efb3..19ad98098a 100644 --- a/tools/src/tint/intrinsic/resolver/resolver_test.go +++ b/tools/src/tint/intrinsic/resolver/resolver_test.go @@ -157,13 +157,13 @@ op +(T, T)`, }, { ` type f32 -init f32(f32)`, +ctor f32(f32)`, success, }, { ` type f32 type T -init f32(T)`, +ctor f32(T)`, success, }, { ` @@ -392,57 +392,57 @@ op << (P)`, ` type i enum e { a } -init F(i) -> e`, +ctor F(i) -> e`, `file.txt:3:14 cannot use 'e' as return type. Must be a type or template type`, }, { ` type T -init F(T)`, +ctor F(T)`, `file.txt:2:10 cannot resolve 'u'`, }, { ` type x -init F(T)`, +ctor F(T)`, `file.txt:2:11 'T' template parameters do not accept template arguments`, }, { ` type A type B -init F(A)`, +ctor F(A)`, `file.txt:3:10 cannot use type 'B' as template number`, }, { ` type A enum E { b } match M: E.b -init F(A)`, +ctor F(A)`, `file.txt:4:10 cannot use enum matcher 'M' as template type`, }, { ` type T type P match m: T -init F(P)`, +ctor F(P)`, `file.txt:4:10 cannot use type matcher 'm' as template number`, }, { ` type P enum E { b } -init F(P)`, +ctor F(P)`, `file.txt:3:10 cannot use enum 'E' as template number`, }, { ` type P enum E { a b } match m: E.a | E.b -init F(P)`, +ctor F(P)`, `file.txt:4:10 cannot use enum matcher 'm' as template number`, }, { ` type P enum E { a b } match m: E.a | E.b -init F(P)`, +ctor F(P)`, `file.txt:4:16 cannot use template enum 'E' as template number`, }, { ` diff --git a/tools/src/tint/intrinsic/sem/sem.go b/tools/src/tint/intrinsic/sem/sem.go index fad95a6c9d..dcec878554 100644 --- a/tools/src/tint/intrinsic/sem/sem.go +++ b/tools/src/tint/intrinsic/sem/sem.go @@ -31,7 +31,7 @@ type Sem struct { Builtins []*Intrinsic UnaryOperators []*Intrinsic BinaryOperators []*Intrinsic - InitializersAndConverters []*Intrinsic + ConstructorsAndConverters []*Intrinsic // Maximum number of template types used across all builtins MaxTemplateTypes int // Maximum number of template numbers used across all builtins diff --git a/tools/src/tint/intrinsic/tok/tok.go b/tools/src/tint/intrinsic/tok/tok.go index 0516ce9e4e..9f27f0a092 100644 --- a/tools/src/tint/intrinsic/tok/tok.go +++ b/tools/src/tint/intrinsic/tok/tok.go @@ -31,7 +31,7 @@ const ( Match Kind = "match" Function Kind = "fn" Operator Kind = "op" - Initializer Kind = "init" + Constructor Kind = "ctor" Converter Kind = "conv" Type Kind = "type" Enum Kind = "enum"