Split bit size checks out of CheckType.

This Cl moves the code to check 8, 16 and 64 bit types are available to
separate Check8Bit, Check16Bit and Check64Bit helpers.

Change-Id: I61a6fb99fb30b92f7708c88983033213472c9f30
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/320659
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 ed4b164..a4c300f 100644
--- a/src/tint/lang/core/ir/structural_validator.cc
+++ b/src/tint/lang/core/ir/structural_validator.cc
@@ -686,42 +686,10 @@
             [&](const core::type::Struct* str) { return CheckStruct(str, diag); },
             [&](const core::type::Reference* ref) { return CheckRef(ref, diag, root); },
             [&](const core::type::Pointer* ptr) { return CheckPtr(ptr, diag); },
-            [&](const core::type::U64*) {
-                // u64 types are guarded by the Allow64BitIntegers property.
-                if (!ir_.properties.Contains(Property::kAllow64BitIntegers)) {
-                    diag() << "64-bit integer types are not permitted";
-                    return false;
-                }
-                return true;
-            },
-            [&](const core::type::I8*) {
-                // General use of i8 types is guarded by the Allow8BitIntegers property.
-                // They can be used as the component type of a subgroup matrix without the property.
-                if (!Is<core::type::SubgroupMatrix>(parent) &&
-                    !ir_.properties.Contains(Property::kAllow8BitIntegers)) {
-                    diag() << "8-bit integer types are not permitted";
-                    return false;
-                }
-                return true;
-            },
-            [&](const core::type::U8*) {
-                // General use of u8 types is guarded by the Allow8BitIntegers property.
-                // They can be used as the component type of a subgroup matrix without the property.
-                if (!Is<core::type::SubgroupMatrix>(parent) &&
-                    !ir_.properties.Contains(Property::kAllow8BitIntegers)) {
-                    diag() << "8-bit integer types are not permitted";
-                    return false;
-                }
-                return true;
-            },
-            [&](const core::type::U16*) {
-                // u16 types are guarded by the Allow16BitIntegers property.
-                if (!ir_.properties.Contains(Property::kAllow16BitIntegers)) {
-                    diag() << "16-bit integer types are not permitted";
-                    return false;
-                }
-                return true;
-            },
+            [&](const core::type::I8*) { return Check8Bit(diag, parent); },
+            [&](const core::type::U8*) { return Check8Bit(diag, parent); },
+            [&](const core::type::U16*) { return Check16Bit(diag); },
+            [&](const core::type::U64*) { return Check64Bit(diag); },
             [&](const core::type::Array* arr) {
                 if (!arr->ElemType()->HasCreationFixedFootprint()) {
                     diag() << "array elements, " << NameOf(type)
@@ -938,6 +906,36 @@
     }
 }
 
+// 8-bit types are guarded by the Allow8BitIntegers property.
+// They can be used as the component type of a subgroup matrix without the property.
+bool Structural::Check8Bit(std::function<diag::Diagnostic&()>& diag,
+                           const core::type::Type* parent) {
+    if (!Is<core::type::SubgroupMatrix>(parent) &&
+        !ir_.properties.Contains(Property::kAllow8BitIntegers)) {
+        diag() << "8-bit integer types are not permitted";
+        return false;
+    }
+    return true;
+}
+
+// 16-bit types are guarded by the Allow16BitIntegers property.
+bool Structural::Check16Bit(std::function<diag::Diagnostic&()>& diag) {
+    if (!ir_.properties.Contains(Property::kAllow16BitIntegers)) {
+        diag() << "16-bit integer types are not permitted";
+        return false;
+    }
+    return true;
+}
+
+// 64-bit types are guarded by the Allow64BitIntegers property.
+bool Structural::Check64Bit(std::function<diag::Diagnostic&()>& diag) {
+    if (!ir_.properties.Contains(Property::kAllow64BitIntegers)) {
+        diag() << "64-bit integer types are not permitted";
+        return false;
+    }
+    return true;
+}
+
 bool Structural::CheckPtr(const core::type::Pointer* ptr,
                           std::function<diag::Diagnostic&()>& diag) {
     if (ptr->StoreType()->Is<core::type::Void>()) {
diff --git a/src/tint/lang/core/ir/structural_validator.h b/src/tint/lang/core/ir/structural_validator.h
index 90d2aae..574cb0d 100644
--- a/src/tint/lang/core/ir/structural_validator.h
+++ b/src/tint/lang/core/ir/structural_validator.h
@@ -333,6 +333,17 @@
                   std::function<diag::Diagnostic&()>& diag,
                   const core::type::Type* root);
 
+    /// 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
+    bool Check8Bit(std::function<diag::Diagnostic&()>& diag, const core::type::Type* parent);
+    /// Checks that 16-bit types are permitted
+    /// @param diag a function that creates an error diagnostic for the source of the type
+    bool Check16Bit(std::function<diag::Diagnostic&()>& diag);
+    /// Checks that 64-bit types are permitted
+    /// @param diag a function that creates an error diagnostic for the source of the type
+    bool Check64Bit(std::function<diag::Diagnostic&()>& diag);
+
     /// Checks that `ptr` is a valid pointer type
     /// @param ptr the pointer to check
     /// @param diag a function that creates an error diagnostic for the source of the type