mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 21:47:47 +00:00
Implement phony assignment
Bug: tint:1213 Change-Id: Ib1ebc4947405c4ada7a9bdbc6bd5a36447bbd234 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/67064 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: David Neto <dneto@google.com> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Tint LUCI CQ
parent
092326894e
commit
1aa98e62c0
11
test/statements/assign/phony/addr_of_non_constructable.wgsl
Normal file
11
test/statements/assign/phony/addr_of_non_constructable.wgsl
Normal file
@@ -0,0 +1,11 @@
|
||||
[[block]]
|
||||
struct S {
|
||||
arr : array<i32>;
|
||||
};
|
||||
|
||||
[[binding(0), group(0)]] var<storage, read_write> s : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main() {
|
||||
_ = &s;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
RWByteAddressBuffer s : register(u0, space0);
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void main() {
|
||||
return;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
struct S {
|
||||
/* 0x0000 */ int arr[1];
|
||||
};
|
||||
|
||||
kernel void tint_symbol() {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 11
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %main "main"
|
||||
OpExecutionMode %main LocalSize 1 1 1
|
||||
OpName %S "S"
|
||||
OpMemberName %S 0 "arr"
|
||||
OpName %s "s"
|
||||
OpName %main "main"
|
||||
OpDecorate %S Block
|
||||
OpMemberDecorate %S 0 Offset 0
|
||||
OpDecorate %_runtimearr_int ArrayStride 4
|
||||
OpDecorate %s Binding 0
|
||||
OpDecorate %s DescriptorSet 0
|
||||
%int = OpTypeInt 32 1
|
||||
%_runtimearr_int = OpTypeRuntimeArray %int
|
||||
%S = OpTypeStruct %_runtimearr_int
|
||||
%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S
|
||||
%s = OpVariable %_ptr_StorageBuffer_S StorageBuffer
|
||||
%void = OpTypeVoid
|
||||
%6 = OpTypeFunction %void
|
||||
%main = OpFunction %void None %6
|
||||
%9 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
@@ -0,0 +1,11 @@
|
||||
[[block]]
|
||||
struct S {
|
||||
arr : array<i32>;
|
||||
};
|
||||
|
||||
[[binding(0), group(0)]] var<storage, read_write> s : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main() {
|
||||
_ = &(s);
|
||||
}
|
||||
11
test/statements/assign/phony/addr_of_runtime_array.wgsl
Normal file
11
test/statements/assign/phony/addr_of_runtime_array.wgsl
Normal file
@@ -0,0 +1,11 @@
|
||||
[[block]]
|
||||
struct S {
|
||||
arr : array<i32>;
|
||||
};
|
||||
|
||||
[[binding(0), group(0)]] var<storage, read_write> s : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main() {
|
||||
_ = &s.arr;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
RWByteAddressBuffer s : register(u0, space0);
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void main() {
|
||||
return;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
struct S {
|
||||
/* 0x0000 */ int arr[1];
|
||||
};
|
||||
|
||||
kernel void tint_symbol() {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 15
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %main "main"
|
||||
OpExecutionMode %main LocalSize 1 1 1
|
||||
OpName %S "S"
|
||||
OpMemberName %S 0 "arr"
|
||||
OpName %s "s"
|
||||
OpName %main "main"
|
||||
OpDecorate %S Block
|
||||
OpMemberDecorate %S 0 Offset 0
|
||||
OpDecorate %_runtimearr_int ArrayStride 4
|
||||
OpDecorate %s Binding 0
|
||||
OpDecorate %s DescriptorSet 0
|
||||
%int = OpTypeInt 32 1
|
||||
%_runtimearr_int = OpTypeRuntimeArray %int
|
||||
%S = OpTypeStruct %_runtimearr_int
|
||||
%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S
|
||||
%s = OpVariable %_ptr_StorageBuffer_S StorageBuffer
|
||||
%void = OpTypeVoid
|
||||
%6 = OpTypeFunction %void
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_0 = OpConstant %uint 0
|
||||
%_ptr_StorageBuffer__runtimearr_int = OpTypePointer StorageBuffer %_runtimearr_int
|
||||
%main = OpFunction %void None %6
|
||||
%9 = OpLabel
|
||||
%14 = OpAccessChain %_ptr_StorageBuffer__runtimearr_int %s %uint_0
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
@@ -0,0 +1,11 @@
|
||||
[[block]]
|
||||
struct S {
|
||||
arr : array<i32>;
|
||||
};
|
||||
|
||||
[[binding(0), group(0)]] var<storage, read_write> s : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main() {
|
||||
_ = &(s.arr);
|
||||
}
|
||||
8
test/statements/assign/phony/call.wgsl
Normal file
8
test/statements/assign/phony/call.wgsl
Normal file
@@ -0,0 +1,8 @@
|
||||
fn f(a: i32, b: i32, c: i32) -> i32 {
|
||||
return a * b + c;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main() {
|
||||
_ = f(1, 2, 3);
|
||||
}
|
||||
9
test/statements/assign/phony/call.wgsl.expected.hlsl
Normal file
9
test/statements/assign/phony/call.wgsl.expected.hlsl
Normal file
@@ -0,0 +1,9 @@
|
||||
int f(int a, int b, int c) {
|
||||
return ((a * b) + c);
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void main() {
|
||||
(void) f(1, 2, 3);
|
||||
return;
|
||||
}
|
||||
12
test/statements/assign/phony/call.wgsl.expected.msl
Normal file
12
test/statements/assign/phony/call.wgsl.expected.msl
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
int f(int a, int b, int c) {
|
||||
return as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(a) * as_type<uint>(b)))) + as_type<uint>(c)));
|
||||
}
|
||||
|
||||
kernel void tint_symbol() {
|
||||
f(1, 2, 3);
|
||||
return;
|
||||
}
|
||||
|
||||
35
test/statements/assign/phony/call.wgsl.expected.spvasm
Normal file
35
test/statements/assign/phony/call.wgsl.expected.spvasm
Normal file
@@ -0,0 +1,35 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 18
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %main "main"
|
||||
OpExecutionMode %main LocalSize 1 1 1
|
||||
OpName %f "f"
|
||||
OpName %a "a"
|
||||
OpName %b "b"
|
||||
OpName %c "c"
|
||||
OpName %main "main"
|
||||
%int = OpTypeInt 32 1
|
||||
%1 = OpTypeFunction %int %int %int %int
|
||||
%void = OpTypeVoid
|
||||
%10 = OpTypeFunction %void
|
||||
%int_1 = OpConstant %int 1
|
||||
%int_2 = OpConstant %int 2
|
||||
%int_3 = OpConstant %int 3
|
||||
%f = OpFunction %int None %1
|
||||
%a = OpFunctionParameter %int
|
||||
%b = OpFunctionParameter %int
|
||||
%c = OpFunctionParameter %int
|
||||
%7 = OpLabel
|
||||
%8 = OpIMul %int %a %b
|
||||
%9 = OpIAdd %int %8 %c
|
||||
OpReturnValue %9
|
||||
OpFunctionEnd
|
||||
%main = OpFunction %void None %10
|
||||
%13 = OpLabel
|
||||
%14 = OpFunctionCall %int %f %int_1 %int_2 %int_3
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
8
test/statements/assign/phony/call.wgsl.expected.wgsl
Normal file
8
test/statements/assign/phony/call.wgsl.expected.wgsl
Normal file
@@ -0,0 +1,8 @@
|
||||
fn f(a : i32, b : i32, c : i32) -> i32 {
|
||||
return ((a * b) + c);
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main() {
|
||||
_ = f(1, 2, 3);
|
||||
}
|
||||
8
test/statements/assign/phony/multiple_side_effects.wgsl
Normal file
8
test/statements/assign/phony/multiple_side_effects.wgsl
Normal file
@@ -0,0 +1,8 @@
|
||||
fn f(a: i32, b: i32, c: i32) -> i32 {
|
||||
return a * b + c;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main() {
|
||||
_ = f(1, 2, 3) + f(4, 5, 6) * f(7, f(8, 9, 10), 11);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
int f(int a, int b, int c) {
|
||||
return ((a * b) + c);
|
||||
}
|
||||
|
||||
void phony_sink(int p0, int p1, int p2) {
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void main() {
|
||||
phony_sink(f(1, 2, 3), f(4, 5, 6), f(7, f(8, 9, 10), 11));
|
||||
return;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
int f(int a, int b, int c) {
|
||||
return as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(a) * as_type<uint>(b)))) + as_type<uint>(c)));
|
||||
}
|
||||
|
||||
void phony_sink(int p0, int p1, int p2) {
|
||||
}
|
||||
|
||||
kernel void tint_symbol() {
|
||||
phony_sink(f(1, 2, 3), f(4, 5, 6), f(7, f(8, 9, 10), 11));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 31
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %main "main"
|
||||
OpExecutionMode %main LocalSize 1 1 1
|
||||
OpName %f "f"
|
||||
OpName %a "a"
|
||||
OpName %b "b"
|
||||
OpName %c "c"
|
||||
OpName %main "main"
|
||||
%int = OpTypeInt 32 1
|
||||
%1 = OpTypeFunction %int %int %int %int
|
||||
%void = OpTypeVoid
|
||||
%10 = OpTypeFunction %void
|
||||
%int_1 = OpConstant %int 1
|
||||
%int_2 = OpConstant %int 2
|
||||
%int_3 = OpConstant %int 3
|
||||
%int_4 = OpConstant %int 4
|
||||
%int_5 = OpConstant %int 5
|
||||
%int_6 = OpConstant %int 6
|
||||
%int_7 = OpConstant %int 7
|
||||
%int_8 = OpConstant %int 8
|
||||
%int_9 = OpConstant %int 9
|
||||
%int_10 = OpConstant %int 10
|
||||
%int_11 = OpConstant %int 11
|
||||
%f = OpFunction %int None %1
|
||||
%a = OpFunctionParameter %int
|
||||
%b = OpFunctionParameter %int
|
||||
%c = OpFunctionParameter %int
|
||||
%7 = OpLabel
|
||||
%8 = OpIMul %int %a %b
|
||||
%9 = OpIAdd %int %8 %c
|
||||
OpReturnValue %9
|
||||
OpFunctionEnd
|
||||
%main = OpFunction %void None %10
|
||||
%13 = OpLabel
|
||||
%14 = OpFunctionCall %int %f %int_1 %int_2 %int_3
|
||||
%18 = OpFunctionCall %int %f %int_4 %int_5 %int_6
|
||||
%24 = OpFunctionCall %int %f %int_8 %int_9 %int_10
|
||||
%22 = OpFunctionCall %int %f %int_7 %24 %int_11
|
||||
%29 = OpIMul %int %18 %22
|
||||
%30 = OpIAdd %int %14 %29
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
@@ -0,0 +1,8 @@
|
||||
fn f(a : i32, b : i32, c : i32) -> i32 {
|
||||
return ((a * b) + c);
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main() {
|
||||
_ = (f(1, 2, 3) + (f(4, 5, 6) * f(7, f(8, 9, 10), 11)));
|
||||
}
|
||||
12
test/statements/assign/phony/storage_buffer.wgsl
Normal file
12
test/statements/assign/phony/storage_buffer.wgsl
Normal file
@@ -0,0 +1,12 @@
|
||||
[[block]]
|
||||
struct S {
|
||||
i : i32;
|
||||
};
|
||||
|
||||
[[binding(0), group(0)]] var<storage, read_write> s : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main() {
|
||||
_ = s;
|
||||
_ = s.i;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
RWByteAddressBuffer s : register(u0, space0);
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void main() {
|
||||
return;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
struct S {
|
||||
/* 0x0000 */ int i;
|
||||
};
|
||||
|
||||
kernel void tint_symbol() {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 13
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %main "main"
|
||||
OpExecutionMode %main LocalSize 1 1 1
|
||||
OpName %S "S"
|
||||
OpMemberName %S 0 "i"
|
||||
OpName %s "s"
|
||||
OpName %main "main"
|
||||
OpDecorate %S Block
|
||||
OpMemberDecorate %S 0 Offset 0
|
||||
OpDecorate %s Binding 0
|
||||
OpDecorate %s DescriptorSet 0
|
||||
%int = OpTypeInt 32 1
|
||||
%S = OpTypeStruct %int
|
||||
%_ptr_StorageBuffer_S = OpTypePointer StorageBuffer %S
|
||||
%s = OpVariable %_ptr_StorageBuffer_S StorageBuffer
|
||||
%void = OpTypeVoid
|
||||
%5 = OpTypeFunction %void
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_0 = OpConstant %uint 0
|
||||
%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int
|
||||
%main = OpFunction %void None %5
|
||||
%8 = OpLabel
|
||||
%12 = OpAccessChain %_ptr_StorageBuffer_int %s %uint_0
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
@@ -0,0 +1,12 @@
|
||||
[[block]]
|
||||
struct S {
|
||||
i : i32;
|
||||
};
|
||||
|
||||
[[binding(0), group(0)]] var<storage, read_write> s : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main() {
|
||||
_ = s;
|
||||
_ = s.i;
|
||||
}
|
||||
12
test/statements/assign/phony/uniform_buffer.wgsl
Normal file
12
test/statements/assign/phony/uniform_buffer.wgsl
Normal file
@@ -0,0 +1,12 @@
|
||||
[[block]]
|
||||
struct S {
|
||||
i : i32;
|
||||
};
|
||||
|
||||
[[binding(0), group(0)]] var<uniform> u : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main() {
|
||||
_ = u;
|
||||
_ = u.i;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
cbuffer cbuffer_u : register(b0, space0) {
|
||||
uint4 u[1];
|
||||
};
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void main() {
|
||||
return;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
struct S {
|
||||
/* 0x0000 */ int i;
|
||||
};
|
||||
|
||||
kernel void tint_symbol() {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 13
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %main "main"
|
||||
OpExecutionMode %main LocalSize 1 1 1
|
||||
OpName %S "S"
|
||||
OpMemberName %S 0 "i"
|
||||
OpName %u "u"
|
||||
OpName %main "main"
|
||||
OpDecorate %S Block
|
||||
OpMemberDecorate %S 0 Offset 0
|
||||
OpDecorate %u NonWritable
|
||||
OpDecorate %u Binding 0
|
||||
OpDecorate %u DescriptorSet 0
|
||||
%int = OpTypeInt 32 1
|
||||
%S = OpTypeStruct %int
|
||||
%_ptr_Uniform_S = OpTypePointer Uniform %S
|
||||
%u = OpVariable %_ptr_Uniform_S Uniform
|
||||
%void = OpTypeVoid
|
||||
%5 = OpTypeFunction %void
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_0 = OpConstant %uint 0
|
||||
%_ptr_Uniform_int = OpTypePointer Uniform %int
|
||||
%main = OpFunction %void None %5
|
||||
%8 = OpLabel
|
||||
%12 = OpAccessChain %_ptr_Uniform_int %u %uint_0
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
@@ -0,0 +1,12 @@
|
||||
[[block]]
|
||||
struct S {
|
||||
i : i32;
|
||||
};
|
||||
|
||||
[[binding(0), group(0)]] var<uniform> u : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main() {
|
||||
_ = u;
|
||||
_ = u.i;
|
||||
}
|
||||
Reference in New Issue
Block a user