tint: fix identity initializer of vec from vec of abstract not remaining abstract

For "vec3(vec3<T>) -> vec3<T>", this CL makes T also include abstract
int and float (all scalars).

Bug: tint:1731
Change-Id: I776c7ba6872c3d680982dbec6b0970389e720611
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107540
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
Antonio Maiorano 2022-10-28 15:58:38 +00:00 committed by Dawn LUCI CQ
parent c303bdf705
commit 2048d4f6ef
10 changed files with 4664 additions and 4593 deletions

View File

@ -739,9 +739,9 @@ fn textureLoad<C: iu32>(texture: texture_external, coords: vec2<C>) -> vec4<f32>
@const("Identity") init f32(f32) -> f32 @const("Identity") init f32(f32) -> f32
@const("Identity") init f16(f16) -> f16 @const("Identity") init f16(f16) -> f16
@const("Identity") init bool(bool) -> bool @const("Identity") init bool(bool) -> bool
@const("Identity") init vec2<T: concrete_scalar>(vec2<T>) -> vec2<T> @const("Identity") init vec2<T: scalar>(vec2<T>) -> vec2<T>
@const("Identity") init vec3<T: concrete_scalar>(vec3<T>) -> vec3<T> @const("Identity") init vec3<T: scalar>(vec3<T>) -> vec3<T>
@const("Identity") init vec4<T: concrete_scalar>(vec4<T>) -> vec4<T> @const("Identity") init vec4<T: scalar>(vec4<T>) -> vec4<T>
@const("Identity") init mat2x2<T: f32_f16>(mat2x2<T>) -> mat2x2<T> @const("Identity") init mat2x2<T: f32_f16>(mat2x2<T>) -> mat2x2<T>
@const("Identity") init mat2x3<T: f32_f16>(mat2x3<T>) -> mat2x3<T> @const("Identity") init mat2x3<T: f32_f16>(mat2x3<T>) -> mat2x3<T>
@const("Identity") init mat2x4<T: f32_f16>(mat2x4<T>) -> mat2x4<T> @const("Identity") init mat2x4<T: f32_f16>(mat2x4<T>) -> mat2x4<T>

File diff suppressed because it is too large Load Diff

View File

@ -839,7 +839,7 @@ TEST_F(IntrinsicTableTest, MismatchTypeInitializerImplicit) {
vec3(xy: vec2<T>, z: T) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool vec3(xy: vec2<T>, z: T) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool
vec3(x: T, yz: vec2<T>) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool vec3(x: T, yz: vec2<T>) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool
vec3(T) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool vec3(T) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool
vec3(vec3<T>) -> vec3<T> where: T is f32, f16, i32, u32 or bool vec3(vec3<T>) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool
vec3<T>() -> vec3<T> where: T is f32, f16, i32, u32 or bool vec3<T>() -> vec3<T> where: T is f32, f16, i32, u32 or bool
5 candidate conversions: 5 candidate conversions:
@ -865,7 +865,7 @@ TEST_F(IntrinsicTableTest, MismatchTypeInitializerExplicit) {
vec3(x: T, yz: vec2<T>) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool vec3(x: T, yz: vec2<T>) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool
vec3(T) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool vec3(T) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool
vec3(xy: vec2<T>, z: T) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool vec3(xy: vec2<T>, z: T) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool
vec3(vec3<T>) -> vec3<T> where: T is f32, f16, i32, u32 or bool vec3(vec3<T>) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool
vec3<T>() -> vec3<T> where: T is f32, f16, i32, u32 or bool vec3<T>() -> vec3<T> where: T is f32, f16, i32, u32 or bool
5 candidate conversions: 5 candidate conversions:
@ -877,6 +877,19 @@ TEST_F(IntrinsicTableTest, MismatchTypeInitializerExplicit) {
)"); )");
} }
TEST_F(IntrinsicTableTest, MatchTypeInitializerImplicitVecFromVecAbstract) {
auto* ai = create<sem::AbstractInt>();
auto* vec3_ai = create<sem::Vector>(ai, 3u);
auto result = table->Lookup(InitConvIntrinsic::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<sem::TypeInitializer>());
ASSERT_EQ(result.target->Parameters().Length(), 1u);
EXPECT_EQ(result.target->Parameters()[0]->Type(), vec3_ai);
EXPECT_NE(result.const_eval_fn, nullptr);
}
TEST_F(IntrinsicTableTest, MatchTypeInitializerImplicitMatFromVec) { TEST_F(IntrinsicTableTest, MatchTypeInitializerImplicitMatFromVec) {
auto* af = create<sem::AbstractFloat>(); auto* af = create<sem::AbstractFloat>();
auto* vec2_ai = create<sem::Vector>(create<sem::AbstractInt>(), 2u); auto* vec2_ai = create<sem::Vector>(create<sem::AbstractInt>(), 2u);
@ -951,7 +964,7 @@ TEST_F(IntrinsicTableTest, MismatchTypeConversion) {
R"(12:34 error: no matching initializer for vec3<f32>(array<u32>) R"(12:34 error: no matching initializer for vec3<f32>(array<u32>)
6 candidate initializers: 6 candidate initializers:
vec3(vec3<T>) -> vec3<T> where: T is f32, f16, i32, u32 or bool vec3(vec3<T>) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool
vec3(T) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool vec3(T) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool
vec3<T>() -> vec3<T> where: T is f32, f16, i32, u32 or bool vec3<T>() -> vec3<T> where: T is f32, f16, i32, u32 or bool
vec3(xy: vec2<T>, z: T) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool vec3(xy: vec2<T>, z: T) -> vec3<T> where: T is abstract-int, abstract-float, f32, f16, i32, u32 or bool

View File

@ -0,0 +1,4 @@
fn g() {
const a = vec3(vec3(1, 2, 3));
const b = a.x << 40;
}

View File

@ -0,0 +1,7 @@
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
void g() {
}

View File

@ -0,0 +1,7 @@
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
void g() {
}

View File

@ -0,0 +1,9 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void unused_entry_point() {
return;
}
void g() {
}

View File

@ -0,0 +1,6 @@
#include <metal_stdlib>
using namespace metal;
void g() {
}

View File

@ -0,0 +1,21 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 7
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
OpExecutionMode %unused_entry_point LocalSize 1 1 1
OpName %unused_entry_point "unused_entry_point"
OpName %g "g"
%void = OpTypeVoid
%1 = OpTypeFunction %void
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
OpReturn
OpFunctionEnd
%g = OpFunction %void None %1
%6 = OpLabel
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,4 @@
fn g() {
const a = vec3(vec3(1, 2, 3));
const b = (a.x << 40);
}