Split CheckMatrix from CheckType.

Move the matrix validation code to a separate CheckMatrix method.

Change-Id: Ic6a4b1c4615a4ae9cd2d601b5362da49e94683e7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/320677
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
diff --git a/src/tint/lang/core/ir/structural_validator.cc b/src/tint/lang/core/ir/structural_validator.cc
index a9e3da48..a4c5614 100644
--- a/src/tint/lang/core/ir/structural_validator.cc
+++ b/src/tint/lang/core/ir/structural_validator.cc
@@ -692,13 +692,7 @@
             [&](const core::type::U64*) { return Check64Bit(diag); },
             [&](const core::type::Array* arr) { return CheckArray(arr, diag); },
             [&](const core::type::Vector* v) { return CheckVector(v, diag); },
-            [&](const core::type::Matrix* m) {
-                if (!m->Type()->IsFloatScalar()) {
-                    diag() << "matrix elements, " << NameOf(type) << ", must be float scalars";
-                    return false;
-                }
-                return true;
-            },
+            [&](const core::type::Matrix* m) { return CheckMatrix(m, diag); },
             [&](const core::type::Atomic* a) {
                 // Prior to lowering we allow for atomic operations on vec2u to support the
                 // AtomicVec2UMinMax feature.
@@ -868,6 +862,15 @@
     }
 }
 
+bool Structural::CheckMatrix(const core::type::Matrix* mat,
+                             std::function<diag::Diagnostic&()>& diag) {
+    if (!mat->Type()->IsFloatScalar()) {
+        diag() << "matrix elements, " << NameOf(mat) << ", must be float scalars";
+        return false;
+    }
+    return true;
+}
+
 bool Structural::CheckVector(const core::type::Vector* vec,
                              std::function<diag::Diagnostic&()>& diag) {
     if (!vec->Type()->IsScalar()) {
diff --git a/src/tint/lang/core/ir/structural_validator.h b/src/tint/lang/core/ir/structural_validator.h
index da8ffc6..44f4959 100644
--- a/src/tint/lang/core/ir/structural_validator.h
+++ b/src/tint/lang/core/ir/structural_validator.h
@@ -341,6 +341,10 @@
     /// @param vec the vector the validate
     /// @param diag a function that creates an error diagnostic for the source of the type
     bool CheckVector(const core::type::Vector* vec, std::function<diag::Diagnostic&()>& diag);
+    /// Checks that `mat` is a valid matrix type
+    /// @param mat the matrix the validate
+    /// @param diag a function that creates an error diagnostic for the source of the type
+    bool CheckMatrix(const core::type::Matrix* mat, std::function<diag::Diagnostic&()>& diag);
 
     /// Checks that 8-bit types are permitted
     /// @param diag a function that creates an error diagnostic for the source of the type