tint: Deprecated module-scope 'let' for 'const'

Enable the parsing of 'const'.
Warn on use of module-scope 'let', and automatically replace with 'const'.

Fixed: tint:1580
Change-Id: I214aabca80686dc6b60ae21a7a57fbfb4898ea83
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93786
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Ben Clayton
2022-06-29 00:55:36 +00:00
committed by Dawn LUCI CQ
parent 03f88e6f49
commit c64ca23d94
224 changed files with 1443 additions and 2495 deletions

View File

@@ -2,6 +2,6 @@
void f() {
const int a = 4;
const int3 b = int3(1, 2, 3);
const int3 r = (a / b);
const int3 r = (a / (b == int3(0, 0, 0) ? int3(1, 1, 1) : b));
return;
}

View File

@@ -2,6 +2,6 @@
void f() {
const uint a = 4u;
const uint3 b = uint3(1u, 2u, 3u);
const uint3 r = (a / b);
const uint3 r = (a / (b == uint3(0u, 0u, 0u) ? uint3(1u, 1u, 1u) : b));
return;
}

View File

@@ -2,6 +2,6 @@
void f() {
const int3 a = int3(1, 2, 3);
const int3 b = int3(4, 5, 6);
const int3 r = (a / b);
const int3 r = (a / (b == int3(0, 0, 0) ? int3(1, 1, 1) : b));
return;
}

View File

@@ -2,6 +2,6 @@
void f() {
const uint3 a = uint3(1u, 2u, 3u);
const uint3 b = uint3(4u, 5u, 6u);
const uint3 r = (a / b);
const uint3 r = (a / (b == uint3(0u, 0u, 0u) ? uint3(1u, 1u, 1u) : b));
return;
}

View File

@@ -2,6 +2,6 @@
void f() {
const int a = 4;
const int3 b = int3(0, 2, 0);
const int3 r = (a / int3(1, 2, 1));
const int3 r = (a / (b == int3(0, 0, 0) ? int3(1, 1, 1) : b));
return;
}

View File

@@ -2,6 +2,6 @@
void f() {
const uint a = 4u;
const uint3 b = uint3(0u, 2u, 0u);
const uint3 r = (a / uint3(1u, 2u, 1u));
const uint3 r = (a / (b == uint3(0u, 0u, 0u) ? uint3(1u, 1u, 1u) : b));
return;
}

View File

@@ -2,6 +2,6 @@
void f() {
const int3 a = int3(1, 2, 3);
const int3 b = int3(0, 5, 0);
const int3 r = (a / int3(1, 5, 1));
const int3 r = (a / (b == int3(0, 0, 0) ? int3(1, 1, 1) : b));
return;
}

View File

@@ -2,6 +2,6 @@
void f() {
const uint3 a = uint3(1u, 2u, 3u);
const uint3 b = uint3(0u, 5u, 0u);
const uint3 r = (a / uint3(1u, 5u, 1u));
const uint3 r = (a / (b == uint3(0u, 0u, 0u) ? uint3(1u, 1u, 1u) : b));
return;
}

View File

@@ -2,6 +2,6 @@
void f() {
const int a = 4;
const int3 b = int3(1, 2, 3);
const int3 r = (a % b);
const int3 r = (a % (b == int3(0, 0, 0) ? int3(1, 1, 1) : b));
return;
}

View File

@@ -2,6 +2,6 @@
void f() {
const uint a = 4u;
const uint3 b = uint3(1u, 2u, 3u);
const uint3 r = (a % b);
const uint3 r = (a % (b == uint3(0u, 0u, 0u) ? uint3(1u, 1u, 1u) : b));
return;
}

View File

@@ -2,6 +2,6 @@
void f() {
const int3 a = int3(1, 2, 3);
const int3 b = int3(4, 5, 6);
const int3 r = (a % b);
const int3 r = (a % (b == int3(0, 0, 0) ? int3(1, 1, 1) : b));
return;
}

View File

@@ -2,6 +2,6 @@
void f() {
const uint3 a = uint3(1u, 2u, 3u);
const uint3 b = uint3(4u, 5u, 6u);
const uint3 r = (a % b);
const uint3 r = (a % (b == uint3(0u, 0u, 0u) ? uint3(1u, 1u, 1u) : b));
return;
}

View File

@@ -2,6 +2,6 @@
void f() {
const int a = 4;
const int3 b = int3(0, 2, 0);
const int3 r = (a % int3(1, 2, 1));
const int3 r = (a % (b == int3(0, 0, 0) ? int3(1, 1, 1) : b));
return;
}

View File

@@ -2,6 +2,6 @@
void f() {
const uint a = 4u;
const uint3 b = uint3(0u, 2u, 0u);
const uint3 r = (a % uint3(1u, 2u, 1u));
const uint3 r = (a % (b == uint3(0u, 0u, 0u) ? uint3(1u, 1u, 1u) : b));
return;
}

View File

@@ -2,6 +2,6 @@
void f() {
const int3 a = int3(1, 2, 3);
const int3 b = int3(0, 5, 0);
const int3 r = (a % int3(1, 5, 1));
const int3 r = (a % (b == int3(0, 0, 0) ? int3(1, 1, 1) : b));
return;
}

View File

@@ -2,6 +2,6 @@
void f() {
const uint3 a = uint3(1u, 2u, 3u);
const uint3 b = uint3(0u, 5u, 0u);
const uint3 r = (a % uint3(1u, 5u, 1u));
const uint3 r = (a % (b == uint3(0u, 0u, 0u) ? uint3(1u, 1u, 1u) : b));
return;
}

View File

@@ -6,6 +6,6 @@ void unused_entry_point() {
}
int f() {
int a[8] = int[8](1, 2, 3, 4, 5, 6, 7, 8);
return 2;
return a[1];
}

View File

@@ -5,5 +5,5 @@ void unused_entry_point() {
int f() {
const int a[8] = {1, 2, 3, 4, 5, 6, 7, 8};
return 2;
return a[1];
}

View File

@@ -17,6 +17,6 @@ struct tint_array {
int f() {
tint_array<int, 8> const a = tint_array<int, 8>{1, 2, 3, 4, 5, 6, 7, 8};
int const i = 1;
return 2;
return a[i];
}

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 21
; Bound: 27
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -9,6 +9,7 @@
OpExecutionMode %unused_entry_point LocalSize 1 1 1
OpName %unused_entry_point "unused_entry_point"
OpName %f "f"
OpName %var_for_index "var_for_index"
OpDecorate %_arr_int_uint_8 ArrayStride 4
%void = OpTypeVoid
%1 = OpTypeFunction %void
@@ -26,11 +27,18 @@
%int_7 = OpConstant %int 7
%int_8 = OpConstant %int 8
%20 = OpConstantComposite %_arr_int_uint_8 %int_1 %int_2 %int_3 %int_4 %int_5 %int_6 %int_7 %int_8
%_ptr_Function__arr_int_uint_8 = OpTypePointer Function %_arr_int_uint_8
%23 = OpConstantNull %_arr_int_uint_8
%_ptr_Function_int = OpTypePointer Function %int
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
OpReturn
OpFunctionEnd
%f = OpFunction %int None %5
%8 = OpLabel
OpReturnValue %int_2
%var_for_index = OpVariable %_ptr_Function__arr_int_uint_8 Function %23
OpStore %var_for_index %20
%25 = OpAccessChain %_ptr_Function_int %var_for_index %int_1
%26 = OpLoad %int %25
OpReturnValue %26
OpFunctionEnd

View File

@@ -6,6 +6,6 @@ void unused_entry_point() {
}
vec3 f() {
mat3 m = mat3(vec3(1.0f, 2.0f, 3.0f), vec3(4.0f, 5.0f, 6.0f), vec3(7.0f, 8.0f, 9.0f));
return vec3(4.0f, 5.0f, 6.0f);
return m[1];
}

View File

@@ -5,5 +5,5 @@ void unused_entry_point() {
float3 f() {
const float3x3 m = float3x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f));
return float3(4.0f, 5.0f, 6.0f);
return m[1];
}

View File

@@ -4,6 +4,6 @@ using namespace metal;
float3 f() {
float3x3 const m = float3x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f));
int const i = 1;
return float3(4.0f, 5.0f, 6.0f);
return m[i];
}

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 26
; Bound: 32
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -9,6 +9,7 @@
OpExecutionMode %unused_entry_point LocalSize 1 1 1
OpName %unused_entry_point "unused_entry_point"
OpName %f "f"
OpName %var_for_index "var_for_index"
%void = OpTypeVoid
%1 = OpTypeFunction %void
%float = OpTypeFloat 32
@@ -30,11 +31,18 @@
%23 = OpConstantComposite %mat3v3float %14 %18 %22
%int = OpTypeInt 32 1
%int_1 = OpConstant %int 1
%_ptr_Function_mat3v3float = OpTypePointer Function %mat3v3float
%28 = OpConstantNull %mat3v3float
%_ptr_Function_v3float = OpTypePointer Function %v3float
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
OpReturn
OpFunctionEnd
%f = OpFunction %v3float None %5
%9 = OpLabel
OpReturnValue %18
%var_for_index = OpVariable %_ptr_Function_mat3v3float Function %28
OpStore %var_for_index %23
%30 = OpAccessChain %_ptr_Function_v3float %var_for_index %int_1
%31 = OpLoad %v3float %30
OpReturnValue %31
OpFunctionEnd

View File

@@ -6,6 +6,6 @@ void unused_entry_point() {
}
float f() {
vec3 v = vec3(1.0f, 2.0f, 3.0f);
return 2.0f;
return v[1];
}

View File

@@ -5,5 +5,5 @@ void unused_entry_point() {
float f() {
const float3 v = float3(1.0f, 2.0f, 3.0f);
return 2.0f;
return v[1];
}

View File

@@ -4,6 +4,6 @@ using namespace metal;
float f() {
float3 const v = float3(1.0f, 2.0f, 3.0f);
int const i = 1;
return 2.0f;
return v[i];
}

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 16
; Bound: 17
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -26,5 +26,6 @@
OpFunctionEnd
%f = OpFunction %float None %5
%8 = OpLabel
OpReturnValue %float_2
%16 = OpVectorExtractDynamic %float %13 %int_1
OpReturnValue %16
OpFunctionEnd

View File

@@ -6,6 +6,6 @@ void unused_entry_point() {
}
int f() {
int a[8] = int[8](1, 2, 3, 4, 5, 6, 7, 8);
return 2;
return a[1];
}

View File

@@ -5,5 +5,5 @@ void unused_entry_point() {
int f() {
const int a[8] = {1, 2, 3, 4, 5, 6, 7, 8};
return 2;
return a[1];
}

View File

@@ -16,6 +16,6 @@ struct tint_array {
int f() {
tint_array<int, 8> const a = tint_array<int, 8>{1, 2, 3, 4, 5, 6, 7, 8};
return 2;
return a[1];
}

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 21
; Bound: 22
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -32,5 +32,6 @@
OpFunctionEnd
%f = OpFunction %int None %5
%8 = OpLabel
OpReturnValue %int_2
%21 = OpCompositeExtract %int %20 1
OpReturnValue %21
OpFunctionEnd

View File

@@ -6,6 +6,6 @@ void unused_entry_point() {
}
vec3 f() {
mat3 m = mat3(vec3(1.0f, 2.0f, 3.0f), vec3(4.0f, 5.0f, 6.0f), vec3(7.0f, 8.0f, 9.0f));
return vec3(4.0f, 5.0f, 6.0f);
return m[1];
}

View File

@@ -5,5 +5,5 @@ void unused_entry_point() {
float3 f() {
const float3x3 m = float3x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f));
return float3(4.0f, 5.0f, 6.0f);
return m[1];
}

View File

@@ -3,6 +3,6 @@
using namespace metal;
float3 f() {
float3x3 const m = float3x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f));
return float3(4.0f, 5.0f, 6.0f);
return m[1];
}

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 24
; Bound: 27
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -28,11 +28,14 @@
%float_9 = OpConstant %float 9
%22 = OpConstantComposite %v3float %float_7 %float_8 %float_9
%23 = OpConstantComposite %mat3v3float %14 %18 %22
%int = OpTypeInt 32 1
%int_1 = OpConstant %int 1
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
OpReturn
OpFunctionEnd
%f = OpFunction %v3float None %5
%9 = OpLabel
OpReturnValue %18
%26 = OpCompositeExtract %v3float %23 1
OpReturnValue %26
OpFunctionEnd

View File

@@ -6,6 +6,6 @@ void unused_entry_point() {
}
float f() {
vec3 v = vec3(1.0f, 2.0f, 3.0f);
return 2.0f;
return v[1];
}

View File

@@ -5,5 +5,5 @@ void unused_entry_point() {
float f() {
const float3 v = float3(1.0f, 2.0f, 3.0f);
return 2.0f;
return v[1];
}

View File

@@ -3,6 +3,6 @@
using namespace metal;
float f() {
float3 const v = float3(1.0f, 2.0f, 3.0f);
return 2.0f;
return v[1];
}

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 14
; Bound: 17
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -18,11 +18,14 @@
%float_2 = OpConstant %float 2
%float_3 = OpConstant %float 3
%13 = OpConstantComposite %v3float %float_1 %float_2 %float_3
%int = OpTypeInt 32 1
%int_1 = OpConstant %int 1
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
OpReturn
OpFunctionEnd
%f = OpFunction %float None %5
%8 = OpLabel
OpReturnValue %float_2
%16 = OpCompositeExtract %float %13 1
OpReturnValue %16
OpFunctionEnd