spirv: Implement compound assignment

Use the ExpandCompoundAssignment transform to convert compound
assignments to regular assignments.

Bug: tint:1325
Change-Id: I193a09815836755bc1f7138fe1947be39f7b7206
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/85285
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: James Price <jrprice@google.com>
This commit is contained in:
James Price
2022-03-31 22:30:10 +00:00
parent 508a9660a5
commit 16eeff387c
33 changed files with 1550 additions and 489 deletions

View File

@@ -1,13 +1,51 @@
SKIP: FAILED
fn foo() {
var<function> a : i32;
var<function> b : vec4<f32>;
var<function> c : mat2x2<f32>;
a /= 2;
b *= mat4x4<f32>();
c *= 2.0;
}
Failed to generate: Unknown statement: tint::ast::CompoundAssignmentStatement
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 31
; 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 %foo "foo"
OpName %a "a"
OpName %b "b"
OpName %c "c"
%void = OpTypeVoid
%1 = OpTypeFunction %void
%int = OpTypeInt 32 1
%_ptr_Function_int = OpTypePointer Function %int
%10 = OpConstantNull %int
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_ptr_Function_v4float = OpTypePointer Function %v4float
%15 = OpConstantNull %v4float
%v2float = OpTypeVector %float 2
%mat2v2float = OpTypeMatrix %v2float 2
%_ptr_Function_mat2v2float = OpTypePointer Function %mat2v2float
%20 = OpConstantNull %mat2v2float
%int_2 = OpConstant %int 2
%mat4v4float = OpTypeMatrix %v4float 4
%26 = OpConstantNull %mat4v4float
%float_2 = OpConstant %float 2
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
OpReturn
OpFunctionEnd
%foo = OpFunction %void None %1
%6 = OpLabel
%a = OpVariable %_ptr_Function_int Function %10
%b = OpVariable %_ptr_Function_v4float Function %15
%c = OpVariable %_ptr_Function_mat2v2float Function %20
%21 = OpLoad %int %a
%23 = OpSDiv %int %21 %int_2
OpStore %a %23
%24 = OpLoad %v4float %b
%27 = OpVectorTimesMatrix %v4float %24 %26
OpStore %b %27
%28 = OpLoad %mat2v2float %c
%30 = OpMatrixTimesScalar %mat2v2float %28 %float_2
OpStore %c %30
OpReturn
OpFunctionEnd