mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 21:47:47 +00:00
Add while statement parsing.
This CL adds parsing for the WGSL `while` statement. Bug: tint:1425 Change-Id: Ibce5e28568935ca4f51b5ac33e7a60af7a916b4a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93540 Reviewed-by: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
d10f3f4437
commit
49d1a2d950
@@ -211,6 +211,7 @@ tint_unittests_source_set("tint_unittests_ast_src") {
|
||||
"../../src/tint/ast/variable_decl_statement_test.cc",
|
||||
"../../src/tint/ast/variable_test.cc",
|
||||
"../../src/tint/ast/vector_test.cc",
|
||||
"../../src/tint/ast/while_statement_test.cc",
|
||||
"../../src/tint/ast/workgroup_attribute_test.cc",
|
||||
]
|
||||
}
|
||||
@@ -307,8 +308,8 @@ tint_unittests_source_set("tint_unittests_sem_src") {
|
||||
"../../src/tint/sem/sem_struct_test.cc",
|
||||
"../../src/tint/sem/storage_texture_test.cc",
|
||||
"../../src/tint/sem/texture_test.cc",
|
||||
"../../src/tint/sem/type_test.cc",
|
||||
"../../src/tint/sem/type_manager_test.cc",
|
||||
"../../src/tint/sem/type_test.cc",
|
||||
"../../src/tint/sem/u32_test.cc",
|
||||
"../../src/tint/sem/vector_test.cc",
|
||||
]
|
||||
@@ -359,6 +360,7 @@ tint_unittests_source_set("tint_unittests_transform_src") {
|
||||
"../../src/tint/transform/var_for_dynamic_index_test.cc",
|
||||
"../../src/tint/transform/vectorize_scalar_matrix_constructors_test.cc",
|
||||
"../../src/tint/transform/vertex_pulling_test.cc",
|
||||
"../../src/tint/transform/while_to_loop_test.cc",
|
||||
"../../src/tint/transform/wrap_arrays_in_structs_test.cc",
|
||||
"../../src/tint/transform/zero_init_workgroup_memory_test.cc",
|
||||
]
|
||||
@@ -552,6 +554,7 @@ tint_unittests_source_set("tint_unittests_wgsl_reader_src") {
|
||||
"../../src/tint/reader/wgsl/parser_impl_variable_ident_decl_test.cc",
|
||||
"../../src/tint/reader/wgsl/parser_impl_variable_qualifier_test.cc",
|
||||
"../../src/tint/reader/wgsl/parser_impl_variable_stmt_test.cc",
|
||||
"../../src/tint/reader/wgsl/parser_impl_while_stmt_test.cc",
|
||||
"../../src/tint/reader/wgsl/parser_test.cc",
|
||||
"../../src/tint/reader/wgsl/token_test.cc",
|
||||
]
|
||||
|
||||
7
test/tint/loops/while.wgsl
Normal file
7
test/tint/loops/while.wgsl
Normal file
@@ -0,0 +1,7 @@
|
||||
fn f() -> i32 {
|
||||
var i : i32;
|
||||
while (i < 4) {
|
||||
i = i + 1;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
14
test/tint/loops/while.wgsl.expected.glsl
Normal file
14
test/tint/loops/while.wgsl.expected.glsl
Normal file
@@ -0,0 +1,14 @@
|
||||
#version 310 es
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
int f() {
|
||||
int i = 0;
|
||||
while((i < 4)) {
|
||||
i = (i + 1);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
12
test/tint/loops/while.wgsl.expected.hlsl
Normal file
12
test/tint/loops/while.wgsl.expected.hlsl
Normal file
@@ -0,0 +1,12 @@
|
||||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
int f() {
|
||||
int i = 0;
|
||||
[loop] while((i < 4)) {
|
||||
i = (i + 1);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
11
test/tint/loops/while.wgsl.expected.msl
Normal file
11
test/tint/loops/while.wgsl.expected.msl
Normal file
@@ -0,0 +1,11 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
int f() {
|
||||
int i = 0;
|
||||
while((i < 4)) {
|
||||
i = as_type<int>((as_type<uint>(i) + as_type<uint>(1)));
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
51
test/tint/loops/while.wgsl.expected.spvasm
Normal file
51
test/tint/loops/while.wgsl.expected.spvasm
Normal file
@@ -0,0 +1,51 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 27
|
||||
; 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 %f "f"
|
||||
OpName %i "i"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%int = OpTypeInt 32 1
|
||||
%5 = OpTypeFunction %int
|
||||
%_ptr_Function_int = OpTypePointer Function %int
|
||||
%11 = OpConstantNull %int
|
||||
%int_4 = OpConstant %int 4
|
||||
%bool = OpTypeBool
|
||||
%int_1 = OpConstant %int 1
|
||||
%unused_entry_point = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %int None %5
|
||||
%8 = OpLabel
|
||||
%i = OpVariable %_ptr_Function_int Function %11
|
||||
OpBranch %12
|
||||
%12 = OpLabel
|
||||
OpLoopMerge %13 %14 None
|
||||
OpBranch %15
|
||||
%15 = OpLabel
|
||||
%17 = OpLoad %int %i
|
||||
%19 = OpSLessThan %bool %17 %int_4
|
||||
%16 = OpLogicalNot %bool %19
|
||||
OpSelectionMerge %21 None
|
||||
OpBranchConditional %16 %22 %21
|
||||
%22 = OpLabel
|
||||
OpBranch %13
|
||||
%21 = OpLabel
|
||||
%23 = OpLoad %int %i
|
||||
%25 = OpIAdd %int %23 %int_1
|
||||
OpStore %i %25
|
||||
OpBranch %14
|
||||
%14 = OpLabel
|
||||
OpBranch %12
|
||||
%13 = OpLabel
|
||||
%26 = OpLoad %int %i
|
||||
OpReturnValue %26
|
||||
OpFunctionEnd
|
||||
7
test/tint/loops/while.wgsl.expected.wgsl
Normal file
7
test/tint/loops/while.wgsl.expected.wgsl
Normal file
@@ -0,0 +1,7 @@
|
||||
fn f() -> i32 {
|
||||
var i : i32;
|
||||
while((i < 4)) {
|
||||
i = (i + 1);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
Reference in New Issue
Block a user