writers: Use the new sem::Module::DependencyOrderedDeclarations

As the resolver currently enforces in-order declarations, this does not
change the declaration order from iterating over the
ast::Module::GlobalDeclarations.

The MSL backend has been changed to use the
sem::Module::DependencyOrderedDeclarations list instead of looping over
different declaration types separately.

Bug: tint:1266
Change-Id: I698d612032285311017bfceab3c42adae1928a0e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79767
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@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 7abc32d..9d12733 100644
--- a/test/array/assign_to_function_var.wgsl.expected.msl
+++ b/test/array/assign_to_function_var.wgsl.expected.msl
@@ -4,18 +4,10 @@
 struct tint_array_wrapper {
   /* 0x0000 */ int4 arr[4];
 };
+
 struct S {
   /* 0x0000 */ tint_array_wrapper arr;
 };
-struct tint_array_wrapper_3 {
-  int arr[2];
-};
-struct tint_array_wrapper_2 {
-  tint_array_wrapper_3 arr[3];
-};
-struct tint_array_wrapper_1 {
-  tint_array_wrapper_2 arr[4];
-};
 
 tint_array_wrapper ret_arr() {
   tint_array_wrapper const tint_symbol = {.arr={}};
@@ -27,6 +19,18 @@
   return tint_symbol_1;
 }
 
+struct tint_array_wrapper_3 {
+  int arr[2];
+};
+
+struct tint_array_wrapper_2 {
+  tint_array_wrapper_3 arr[3];
+};
+
+struct tint_array_wrapper_1 {
+  tint_array_wrapper_2 arr[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 = {};
diff --git a/test/array/assign_to_private_var.wgsl.expected.msl b/test/array/assign_to_private_var.wgsl.expected.msl
index 7d8a3ab..d5127b1 100644
--- a/test/array/assign_to_private_var.wgsl.expected.msl
+++ b/test/array/assign_to_private_var.wgsl.expected.msl
@@ -4,15 +4,19 @@
 struct tint_array_wrapper {
   /* 0x0000 */ int4 arr[4];
 };
+
 struct S {
   /* 0x0000 */ tint_array_wrapper arr;
 };
+
 struct tint_array_wrapper_3 {
   int arr[2];
 };
+
 struct tint_array_wrapper_2 {
   tint_array_wrapper_3 arr[3];
 };
+
 struct tint_array_wrapper_1 {
   tint_array_wrapper_2 arr[4];
 };
diff --git a/test/array/assign_to_storage_var.wgsl.expected.msl b/test/array/assign_to_storage_var.wgsl.expected.msl
index c1a31f9..b4ba58a 100644
--- a/test/array/assign_to_storage_var.wgsl.expected.msl
+++ b/test/array/assign_to_storage_var.wgsl.expected.msl
@@ -4,18 +4,23 @@
 struct tint_array_wrapper {
   /* 0x0000 */ int4 arr[4];
 };
+
 struct S {
   /* 0x0000 */ tint_array_wrapper arr;
 };
+
 struct tint_array_wrapper_3 {
   /* 0x0000 */ int arr[2];
 };
+
 struct tint_array_wrapper_2 {
   /* 0x0000 */ tint_array_wrapper_3 arr[3];
 };
+
 struct tint_array_wrapper_1 {
   /* 0x0000 */ tint_array_wrapper_2 arr[4];
 };
+
 struct S_nested {
   /* 0x0000 */ tint_array_wrapper_1 arr;
 };
diff --git a/test/array/assign_to_subexpr.wgsl.expected.msl b/test/array/assign_to_subexpr.wgsl.expected.msl
index 9b47792..735dc30 100644
--- a/test/array/assign_to_subexpr.wgsl.expected.msl
+++ b/test/array/assign_to_subexpr.wgsl.expected.msl
@@ -4,9 +4,11 @@
 struct tint_array_wrapper {
   int arr[4];
 };
+
 struct S {
   tint_array_wrapper arr;
 };
+
 struct tint_array_wrapper_1 {
   tint_array_wrapper arr[2];
 };
diff --git a/test/array/assign_to_workgroup_var.wgsl.expected.msl b/test/array/assign_to_workgroup_var.wgsl.expected.msl
index 2c45f26..32b8290 100644
--- a/test/array/assign_to_workgroup_var.wgsl.expected.msl
+++ b/test/array/assign_to_workgroup_var.wgsl.expected.msl
@@ -4,15 +4,19 @@
 struct tint_array_wrapper {
   /* 0x0000 */ int4 arr[4];
 };
+
 struct S {
   /* 0x0000 */ tint_array_wrapper arr;
 };
+
 struct tint_array_wrapper_3 {
   int arr[2];
 };
+
 struct tint_array_wrapper_2 {
   tint_array_wrapper_3 arr[3];
 };
+
 struct tint_array_wrapper_1 {
   tint_array_wrapper_2 arr[4];
 };
diff --git a/test/array/function_parameter.wgsl.expected.msl b/test/array/function_parameter.wgsl.expected.msl
index 8cf6c26..277889e 100644
--- a/test/array/function_parameter.wgsl.expected.msl
+++ b/test/array/function_parameter.wgsl.expected.msl
@@ -4,21 +4,23 @@
 struct tint_array_wrapper {
   float arr[4];
 };
-struct tint_array_wrapper_1 {
-  tint_array_wrapper arr[3];
-};
-struct tint_array_wrapper_2 {
-  tint_array_wrapper_1 arr[2];
-};
 
 float f1(tint_array_wrapper a) {
   return a.arr[3];
 }
 
+struct tint_array_wrapper_1 {
+  tint_array_wrapper arr[3];
+};
+
 float f2(tint_array_wrapper_1 a) {
   return a.arr[2].arr[3];
 }
 
+struct tint_array_wrapper_2 {
+  tint_array_wrapper_1 arr[2];
+};
+
 float f3(tint_array_wrapper_2 a) {
   return a.arr[1].arr[2].arr[3];
 }
diff --git a/test/array/function_return_type.wgsl.expected.msl b/test/array/function_return_type.wgsl.expected.msl
index dbc3b0d..b56fe6c 100644
--- a/test/array/function_return_type.wgsl.expected.msl
+++ b/test/array/function_return_type.wgsl.expected.msl
@@ -4,23 +4,25 @@
 struct tint_array_wrapper {
   float arr[4];
 };
-struct tint_array_wrapper_1 {
-  tint_array_wrapper arr[3];
-};
-struct tint_array_wrapper_2 {
-  tint_array_wrapper_1 arr[2];
-};
 
 tint_array_wrapper f1() {
   tint_array_wrapper const tint_symbol_1 = {.arr={}};
   return tint_symbol_1;
 }
 
+struct tint_array_wrapper_1 {
+  tint_array_wrapper arr[3];
+};
+
 tint_array_wrapper_1 f2() {
   tint_array_wrapper_1 const tint_symbol_2 = {.arr={f1(), f1(), f1()}};
   return tint_symbol_2;
 }
 
+struct tint_array_wrapper_2 {
+  tint_array_wrapper_1 arr[2];
+};
+
 tint_array_wrapper_2 f3() {
   tint_array_wrapper_2 const tint_symbol_3 = {.arr={f2(), f2()}};
   return tint_symbol_3;
diff --git a/test/array/size.wgsl.expected.msl b/test/array/size.wgsl.expected.msl
index 512a9b0..0150ece 100644
--- a/test/array/size.wgsl.expected.msl
+++ b/test/array/size.wgsl.expected.msl
@@ -1,12 +1,14 @@
 #include <metal_stdlib>
 
 using namespace metal;
+constant int slen = 4;
+
+constant uint ulen = 4u;
+
 struct tint_array_wrapper {
   float arr[4];
 };
 
-constant int slen = 4;
-constant uint ulen = 4u;
 fragment void tint_symbol() {
   tint_array_wrapper signed_literal = {};
   tint_array_wrapper unsigned_literal = {};
diff --git a/test/array/strides.spvasm.expected.msl b/test/array/strides.spvasm.expected.msl
index 62f817c..8db28bd2 100644
--- a/test/array/strides.spvasm.expected.msl
+++ b/test/array/strides.spvasm.expected.msl
@@ -5,19 +5,24 @@
   /* 0x0000 */ float el;
   /* 0x0004 */ int8_t tint_pad[4];
 };
+
 struct tint_array_wrapper {
   /* 0x0000 */ strided_arr arr[2];
 };
+
 struct tint_array_wrapper_1 {
   /* 0x0000 */ tint_array_wrapper arr[3];
 };
+
 struct strided_arr_1 {
   /* 0x0000 */ tint_array_wrapper_1 el;
   /* 0x0030 */ int8_t tint_pad_1[80];
 };
+
 struct tint_array_wrapper_2 {
   /* 0x0000 */ strided_arr_1 arr[4];
 };
+
 struct S {
   /* 0x0000 */ tint_array_wrapper_2 a;
 };
diff --git a/test/array/type_constructor.wgsl.expected.msl b/test/array/type_constructor.wgsl.expected.msl
index c7c48ac..bd40591 100644
--- a/test/array/type_constructor.wgsl.expected.msl
+++ b/test/array/type_constructor.wgsl.expected.msl
@@ -4,12 +4,15 @@
 struct tint_array_wrapper {
   int arr[4];
 };
+
 struct tint_array_wrapper_2 {
   tint_array_wrapper arr[3];
 };
+
 struct tint_array_wrapper_1 {
   tint_array_wrapper_2 arr[2];
 };
+
 struct tint_array_wrapper_3 {
   tint_array_wrapper arr[2];
 };