Split input attachment validation from CheckType

Create a CheckInputAttachment helper for the input attachment validation
code.

Change-Id: I1c1b56adfaf84bf4ebb9dac597de5c0ddd8b8625
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/320662
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
diff --git a/src/tint/lang/core/ir/structural_validator.cc b/src/tint/lang/core/ir/structural_validator.cc
index 4b9a539..cfd3ad8 100644
--- a/src/tint/lang/core/ir/structural_validator.cc
+++ b/src/tint/lang/core/ir/structural_validator.cc
@@ -699,13 +699,7 @@
                 return CheckMultisampledTexture(ms, diag);
             },
             [&](const core::type::StorageTexture* s) { return CheckStorageTexture(s, diag); },
-            [&](const core::type::InputAttachment* i) {
-                if (!i->Type()->IsAnyOf<core::type::F32, core::type::I32, core::type::U32>()) {
-                    diag() << "invalid input attachment component type: " << NameOf(i->Type());
-                    return false;
-                }
-                return true;
-            },
+            [&](const core::type::InputAttachment* i) { return CheckInputAttachment(i, diag); },
             [&](const core::type::SubgroupMatrix* m) {
                 if (!m->Type()
                          ->IsAnyOf<core::type::F16, core::type::F32, core::type::I8,
@@ -814,6 +808,15 @@
     }
 }
 
+bool Structural::CheckInputAttachment(const core::type::InputAttachment* ia,
+                                      std::function<diag::Diagnostic&()>& diag) {
+    if (!ia->Type()->IsAnyOf<core::type::F32, core::type::I32, core::type::U32>()) {
+        diag() << "invalid input attachment component type: " << NameOf(ia->Type());
+        return false;
+    }
+    return true;
+}
+
 bool Structural::CheckStorageTexture(const core::type::StorageTexture* storage,
                                      std::function<diag::Diagnostic&()>& diag) {
     switch (storage->Dim()) {
diff --git a/src/tint/lang/core/ir/structural_validator.h b/src/tint/lang/core/ir/structural_validator.h
index bea63bb..25f7f2f 100644
--- a/src/tint/lang/core/ir/structural_validator.h
+++ b/src/tint/lang/core/ir/structural_validator.h
@@ -367,6 +367,12 @@
     bool CheckStorageTexture(const core::type::StorageTexture* storage,
                              std::function<diag::Diagnostic&()>& diag);
 
+    /// Checks that `ia` is a valid input attachment
+    /// @param ia the input attachment
+    /// @param diag a function that creates an error diagnostic for the source of the type
+    bool CheckInputAttachment(const core::type::InputAttachment* ia,
+                              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
     /// @param parent the parent type for the 8-bit type