msl: Handle buffer variables in transform

This removes a lot of awkward logic from the MSL writer, and means
that we now handle all module-scope variables with the same transform.

Change-Id: I782e36a4b88dafbc3f8364f7caa7f95c6ae3f5f1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/67643
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
diff --git a/test/array/assign_to_function_var.wgsl.expected.msl b/test/array/assign_to_function_var.wgsl.expected.msl
index 894f199..e198433 100644
--- a/test/array/assign_to_function_var.wgsl.expected.msl
+++ b/test/array/assign_to_function_var.wgsl.expected.msl
@@ -31,7 +31,7 @@
   return tint_symbol_1;
 }
 
-void foo(constant S& src_uniform, device S& src_storage, tint_array_wrapper src_param, thread tint_array_wrapper* const tint_symbol_3, threadgroup tint_array_wrapper* const tint_symbol_4) {
+void foo(tint_array_wrapper src_param, thread tint_array_wrapper* const tint_symbol_3, threadgroup tint_array_wrapper* const tint_symbol_4, const constant S* const tint_symbol_5, device S* const tint_symbol_6) {
   tint_array_wrapper src_function = {};
   tint_array_wrapper dst = {};
   tint_array_wrapper const tint_symbol_2 = {.arr={{.el=1}, {.el=2}, {.el=3}, {.el=3}}};
@@ -44,8 +44,8 @@
   dst = *(tint_symbol_3);
   dst = *(tint_symbol_4);
   dst = ret_struct_arr().arr;
-  dst = src_uniform.arr;
-  dst = src_storage.arr;
+  dst = (*(tint_symbol_5)).arr;
+  dst = (*(tint_symbol_6)).arr;
   tint_array_wrapper_1 dst_nested = {};
   tint_array_wrapper_1 src_nested = {};
   dst_nested = src_nested;
diff --git a/test/array/assign_to_private_var.wgsl.expected.msl b/test/array/assign_to_private_var.wgsl.expected.msl
index 6542b60..dd91dca 100644
--- a/test/array/assign_to_private_var.wgsl.expected.msl
+++ b/test/array/assign_to_private_var.wgsl.expected.msl
@@ -31,7 +31,7 @@
   return tint_symbol_1;
 }
 
-void foo(constant S& src_uniform, device S& src_storage, tint_array_wrapper src_param, thread tint_array_wrapper* const tint_symbol_3, thread tint_array_wrapper* const tint_symbol_4, threadgroup tint_array_wrapper* const tint_symbol_5, thread tint_array_wrapper_1* const tint_symbol_6) {
+void foo(tint_array_wrapper src_param, thread tint_array_wrapper* const tint_symbol_3, thread tint_array_wrapper* const tint_symbol_4, threadgroup tint_array_wrapper* const tint_symbol_5, const constant S* const tint_symbol_6, device S* const tint_symbol_7, thread tint_array_wrapper_1* const tint_symbol_8) {
   tint_array_wrapper src_function = {};
   tint_array_wrapper const tint_symbol_2 = {.arr={{.el=1}, {.el=2}, {.el=3}, {.el=3}}};
   *(tint_symbol_3) = tint_symbol_2;
@@ -43,9 +43,9 @@
   *(tint_symbol_3) = *(tint_symbol_4);
   *(tint_symbol_3) = *(tint_symbol_5);
   *(tint_symbol_3) = ret_struct_arr().arr;
-  *(tint_symbol_3) = src_uniform.arr;
-  *(tint_symbol_3) = src_storage.arr;
+  *(tint_symbol_3) = (*(tint_symbol_6)).arr;
+  *(tint_symbol_3) = (*(tint_symbol_7)).arr;
   tint_array_wrapper_1 src_nested = {};
-  *(tint_symbol_6) = src_nested;
+  *(tint_symbol_8) = src_nested;
 }
 
diff --git a/test/array/assign_to_storage_var.wgsl.expected.msl b/test/array/assign_to_storage_var.wgsl.expected.msl
index d1374b35..c0d7dba 100644
--- a/test/array/assign_to_storage_var.wgsl.expected.msl
+++ b/test/array/assign_to_storage_var.wgsl.expected.msl
@@ -34,21 +34,21 @@
   return tint_symbol_1;
 }
 
-void foo(constant S& src_uniform, device S& dst, device S& src_storage, device S_nested& dst_nested, tint_array_wrapper src_param, thread tint_array_wrapper* const tint_symbol_3, threadgroup tint_array_wrapper* const tint_symbol_4) {
+void foo(tint_array_wrapper src_param, device S* const tint_symbol_3, thread tint_array_wrapper* const tint_symbol_4, threadgroup tint_array_wrapper* const tint_symbol_5, const constant S* const tint_symbol_6, device S* const tint_symbol_7, device S_nested* const tint_symbol_8) {
   tint_array_wrapper src_function = {};
   tint_array_wrapper const tint_symbol_2 = {.arr={{.el=1}, {.el=2}, {.el=3}, {.el=3}}};
-  dst.arr = tint_symbol_2;
-  dst.arr = src_param;
-  dst.arr = ret_arr();
+  (*(tint_symbol_3)).arr = tint_symbol_2;
+  (*(tint_symbol_3)).arr = src_param;
+  (*(tint_symbol_3)).arr = ret_arr();
   tint_array_wrapper const src_let = {.arr={}};
-  dst.arr = src_let;
-  dst.arr = src_function;
-  dst.arr = *(tint_symbol_3);
-  dst.arr = *(tint_symbol_4);
-  dst.arr = ret_struct_arr().arr;
-  dst.arr = src_uniform.arr;
-  dst.arr = src_storage.arr;
+  (*(tint_symbol_3)).arr = src_let;
+  (*(tint_symbol_3)).arr = src_function;
+  (*(tint_symbol_3)).arr = *(tint_symbol_4);
+  (*(tint_symbol_3)).arr = *(tint_symbol_5);
+  (*(tint_symbol_3)).arr = ret_struct_arr().arr;
+  (*(tint_symbol_3)).arr = (*(tint_symbol_6)).arr;
+  (*(tint_symbol_3)).arr = (*(tint_symbol_7)).arr;
   tint_array_wrapper_1 src_nested = {};
-  dst_nested.arr = src_nested;
+  (*(tint_symbol_8)).arr = src_nested;
 }
 
diff --git a/test/array/assign_to_workgroup_var.wgsl.expected.msl b/test/array/assign_to_workgroup_var.wgsl.expected.msl
index 28d0965..0511506 100644
--- a/test/array/assign_to_workgroup_var.wgsl.expected.msl
+++ b/test/array/assign_to_workgroup_var.wgsl.expected.msl
@@ -31,7 +31,7 @@
   return tint_symbol_1;
 }
 
-void foo(constant S& src_uniform, device S& src_storage, tint_array_wrapper src_param, threadgroup tint_array_wrapper* const tint_symbol_3, thread tint_array_wrapper* const tint_symbol_4, threadgroup tint_array_wrapper* const tint_symbol_5, threadgroup tint_array_wrapper_1* const tint_symbol_6) {
+void foo(tint_array_wrapper src_param, threadgroup tint_array_wrapper* const tint_symbol_3, thread tint_array_wrapper* const tint_symbol_4, threadgroup tint_array_wrapper* const tint_symbol_5, const constant S* const tint_symbol_6, device S* const tint_symbol_7, threadgroup tint_array_wrapper_1* const tint_symbol_8) {
   tint_array_wrapper src_function = {};
   tint_array_wrapper const tint_symbol_2 = {.arr={{.el=1}, {.el=2}, {.el=3}, {.el=3}}};
   *(tint_symbol_3) = tint_symbol_2;
@@ -43,9 +43,9 @@
   *(tint_symbol_3) = *(tint_symbol_4);
   *(tint_symbol_3) = *(tint_symbol_5);
   *(tint_symbol_3) = ret_struct_arr().arr;
-  *(tint_symbol_3) = src_uniform.arr;
-  *(tint_symbol_3) = src_storage.arr;
+  *(tint_symbol_3) = (*(tint_symbol_6)).arr;
+  *(tint_symbol_3) = (*(tint_symbol_7)).arr;
   tint_array_wrapper_1 src_nested = {};
-  *(tint_symbol_6) = src_nested;
+  *(tint_symbol_8) = src_nested;
 }