[tint] Add lang/wgsl/features/status

It is used to query the status of Tint language features so that Dawn
can expose the correct values in wgslLanguageFeatures.

Also moves the tests for lang/wgsl/features to lang/wgsl as
lang/wgsl/features's GN build file doesn't have support for tests (to
reduce dependencies).

Bug: dawn:2260
Change-Id: Id3c929b464c560a877a4e0410da403736c5c3de5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/163421
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/tint/cmd/test/BUILD.bazel b/src/tint/cmd/test/BUILD.bazel
index 302b464..080bcb9 100644
--- a/src/tint/cmd/test/BUILD.bazel
+++ b/src/tint/cmd/test/BUILD.bazel
@@ -53,7 +53,6 @@
     "//src/tint/lang/msl/ir:test",
     "//src/tint/lang/spirv/ir:test",
     "//src/tint/lang/wgsl/ast:test",
-    "//src/tint/lang/wgsl/features:test",
     "//src/tint/lang/wgsl/helpers:test",
     "//src/tint/lang/wgsl/program:test",
     "//src/tint/lang/wgsl/reader/lower:test",
diff --git a/src/tint/cmd/test/BUILD.cmake b/src/tint/cmd/test/BUILD.cmake
index a231ddd..3709145 100644
--- a/src/tint/cmd/test/BUILD.cmake
+++ b/src/tint/cmd/test/BUILD.cmake
@@ -54,7 +54,6 @@
   tint_lang_msl_ir_test
   tint_lang_spirv_ir_test
   tint_lang_wgsl_ast_test
-  tint_lang_wgsl_features_test
   tint_lang_wgsl_helpers_test
   tint_lang_wgsl_program_test
   tint_lang_wgsl_reader_lower_test
diff --git a/src/tint/cmd/test/BUILD.gn b/src/tint/cmd/test/BUILD.gn
index 4fcb365..e307f93 100644
--- a/src/tint/cmd/test/BUILD.gn
+++ b/src/tint/cmd/test/BUILD.gn
@@ -60,7 +60,6 @@
       "${tint_src_dir}/lang/spirv/ir:unittests",
       "${tint_src_dir}/lang/wgsl:unittests",
       "${tint_src_dir}/lang/wgsl/ast:unittests",
-      "${tint_src_dir}/lang/wgsl/features:unittests",
       "${tint_src_dir}/lang/wgsl/helpers:unittests",
       "${tint_src_dir}/lang/wgsl/program:unittests",
       "${tint_src_dir}/lang/wgsl/reader/lower:unittests",
diff --git a/src/tint/lang/wgsl/BUILD.bazel b/src/tint/lang/wgsl/BUILD.bazel
index 6541b22..f30a202 100644
--- a/src/tint/lang/wgsl/BUILD.bazel
+++ b/src/tint/lang/wgsl/BUILD.bazel
@@ -71,6 +71,8 @@
     "diagnostic_rule_test.cc",
     "diagnostic_severity_test.cc",
     "extension_test.cc",
+    "language_feature_status_test.cc",
+    "language_feature_test.cc",
     "wgsl_test.cc",
   ] + select({
     "//conditions:default": [],
diff --git a/src/tint/lang/wgsl/BUILD.cmake b/src/tint/lang/wgsl/BUILD.cmake
index 4e0a08b..17f4d73 100644
--- a/src/tint/lang/wgsl/BUILD.cmake
+++ b/src/tint/lang/wgsl/BUILD.cmake
@@ -82,6 +82,8 @@
   lang/wgsl/diagnostic_rule_test.cc
   lang/wgsl/diagnostic_severity_test.cc
   lang/wgsl/extension_test.cc
+  lang/wgsl/language_feature_status_test.cc
+  lang/wgsl/language_feature_test.cc
   lang/wgsl/wgsl_test.cc
 )
 
diff --git a/src/tint/lang/wgsl/BUILD.gn b/src/tint/lang/wgsl/BUILD.gn
index 0b9801f..1b7590c 100644
--- a/src/tint/lang/wgsl/BUILD.gn
+++ b/src/tint/lang/wgsl/BUILD.gn
@@ -71,6 +71,8 @@
       "diagnostic_rule_test.cc",
       "diagnostic_severity_test.cc",
       "extension_test.cc",
+      "language_feature_status_test.cc",
+      "language_feature_test.cc",
       "wgsl_test.cc",
     ]
     deps = [
diff --git a/src/tint/lang/wgsl/features/BUILD.bazel b/src/tint/lang/wgsl/features/BUILD.bazel
index cec9088..879fbfd 100644
--- a/src/tint/lang/wgsl/features/BUILD.bazel
+++ b/src/tint/lang/wgsl/features/BUILD.bazel
@@ -40,34 +40,15 @@
   name = "features",
   srcs = [
     "language_feature.cc",
+    "status.cc",
   ],
   hdrs = [
     "language_feature.h",
+    "status.h",
   ],
   deps = [
   ],
   copts = COPTS,
   visibility = ["//visibility:public"],
 )
-cc_library(
-  name = "test",
-  alwayslink = True,
-  srcs = [
-    "language_feature_test.cc",
-  ],
-  deps = [
-    "//src/tint/lang/wgsl/features",
-    "//src/tint/utils/containers",
-    "//src/tint/utils/ice",
-    "//src/tint/utils/macros",
-    "//src/tint/utils/math",
-    "//src/tint/utils/memory",
-    "//src/tint/utils/rtti",
-    "//src/tint/utils/text",
-    "//src/tint/utils/traits",
-    "@gtest",
-  ],
-  copts = COPTS,
-  visibility = ["//visibility:public"],
-)
 
diff --git a/src/tint/lang/wgsl/features/BUILD.cmake b/src/tint/lang/wgsl/features/BUILD.cmake
index 9bbfe60..7746c88 100644
--- a/src/tint/lang/wgsl/features/BUILD.cmake
+++ b/src/tint/lang/wgsl/features/BUILD.cmake
@@ -41,28 +41,6 @@
 tint_add_target(tint_lang_wgsl_features lib
   lang/wgsl/features/language_feature.cc
   lang/wgsl/features/language_feature.h
-)
-
-################################################################################
-# Target:    tint_lang_wgsl_features_test
-# Kind:      test
-################################################################################
-tint_add_target(tint_lang_wgsl_features_test test
-  lang/wgsl/features/language_feature_test.cc
-)
-
-tint_target_add_dependencies(tint_lang_wgsl_features_test test
-  tint_lang_wgsl_features
-  tint_utils_containers
-  tint_utils_ice
-  tint_utils_macros
-  tint_utils_math
-  tint_utils_memory
-  tint_utils_rtti
-  tint_utils_text
-  tint_utils_traits
-)
-
-tint_target_add_external_dependencies(tint_lang_wgsl_features_test test
-  "gtest"
+  lang/wgsl/features/status.cc
+  lang/wgsl/features/status.h
 )
diff --git a/src/tint/lang/wgsl/features/BUILD.gn b/src/tint/lang/wgsl/features/BUILD.gn
index db3557a..95dea3f 100644
--- a/src/tint/lang/wgsl/features/BUILD.gn
+++ b/src/tint/lang/wgsl/features/BUILD.gn
@@ -38,6 +38,8 @@
   sources = [
     "language_feature.cc",
     "language_feature.h",
+    "status.cc",
+    "status.h",
   ]
   deps = []
 
diff --git a/src/tint/lang/wgsl/features/status.cc b/src/tint/lang/wgsl/features/status.cc
new file mode 100644
index 0000000..0f79fdc
--- /dev/null
+++ b/src/tint/lang/wgsl/features/status.cc
@@ -0,0 +1,45 @@
+// Copyright 2023 The Dawn & Tint Authors
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this
+//    list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+//    this list of conditions and the following disclaimer in the documentation
+//    and/or other materials provided with the distribution.
+//
+// 3. Neither the name of the copyright holder nor the names of its
+//    contributors may be used to endorse or promote products derived from
+//    this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "src/tint/lang/wgsl/features/status.h"
+
+#include "src/tint/lang/wgsl/features/language_feature.h"
+
+namespace tint::wgsl {
+
+FeatureStatus GetLanguageFeatureStatus(LanguageFeature f) {
+    switch (f) {
+        case LanguageFeature::kReadonlyAndReadwriteStorageTextures:
+            return FeatureStatus::kExperimental;
+        case LanguageFeature::kUndefined:
+            return FeatureStatus::kUnknown;
+    }
+
+    return FeatureStatus::kUnknown;
+}
+
+}  // namespace tint::wgsl
diff --git a/src/tint/lang/wgsl/features/status.h b/src/tint/lang/wgsl/features/status.h
new file mode 100644
index 0000000..3cb578a
--- /dev/null
+++ b/src/tint/lang/wgsl/features/status.h
@@ -0,0 +1,63 @@
+// Copyright 2023 The Dawn & Tint Authors
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this
+//    list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+//    this list of conditions and the following disclaimer in the documentation
+//    and/or other materials provided with the distribution.
+//
+// 3. Neither the name of the copyright holder nor the names of its
+//    contributors may be used to endorse or promote products derived from
+//    this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef SRC_TINT_LANG_WGSL_FEATURES_STATUS_H_
+#define SRC_TINT_LANG_WGSL_FEATURES_STATUS_H_
+
+#include <cstdint>
+
+namespace tint::wgsl {
+
+enum class LanguageFeature : uint8_t;
+
+/// The status of the implementation of a WGSL language feature so that other components (like Dawn)
+/// can query it. The enum values are in the order of least implemented to most implemented.
+enum class FeatureStatus : uint8_t {
+    // The feature is not known.
+    kUnknown,
+    // The feature is known in wgsl.def but not implemented at all.
+    kUnimplemented,
+    // The feature is at least partially implemented but might contain big security of correctness
+    // issues.
+    kUnsafeExperimental,
+    // The feature is implemented and should be safe from a security standpoint, but shouldn't be
+    // exposed by default.
+    kExperimental,
+    // The feature is implemented and can be exposed by default, but is only turned on if the
+    // feature is explicitly enabled in the wgsl reader options.
+    kShippedWithKillswitch,
+    // The feature is exposed by default and cannot be turned off.
+    kShipped,
+};
+
+/// @param f the feature to get the status of.
+/// @returns the status, or kUnknown if the feature is not known.
+FeatureStatus GetLanguageFeatureStatus(LanguageFeature f);
+
+}  // namespace tint::wgsl
+
+#endif  // SRC_TINT_LANG_WGSL_FEATURES_STATUS_H_
diff --git a/src/tint/lang/wgsl/language_feature_status_test.cc b/src/tint/lang/wgsl/language_feature_status_test.cc
new file mode 100644
index 0000000..e10062f
--- /dev/null
+++ b/src/tint/lang/wgsl/language_feature_status_test.cc
@@ -0,0 +1,43 @@
+// Copyright 2023 The Dawn & Tint Authors
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this
+//    list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+//    this list of conditions and the following disclaimer in the documentation
+//    and/or other materials provided with the distribution.
+//
+// 3. Neither the name of the copyright holder nor the names of its
+//    contributors may be used to endorse or promote products derived from
+//    this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include <gtest/gtest.h>
+
+#include "src/tint/lang/wgsl/features/language_feature.h"
+#include "src/tint/lang/wgsl/features/status.h"
+
+namespace tint::wgsl {
+namespace {
+
+TEST(LanguageFeatureStatusTest, AllFeaturesAreKnown) {
+    for (auto f : kAllLanguageFeatures) {
+        EXPECT_NE(FeatureStatus::kUnknown, GetLanguageFeatureStatus(f));
+    }
+}
+
+}  // namespace
+}  // namespace tint::wgsl
diff --git a/src/tint/lang/wgsl/features/language_feature_test.cc b/src/tint/lang/wgsl/language_feature_test.cc
similarity index 97%
rename from src/tint/lang/wgsl/features/language_feature_test.cc
rename to src/tint/lang/wgsl/language_feature_test.cc
index 295e3a5..60d8e40 100644
--- a/src/tint/lang/wgsl/features/language_feature_test.cc
+++ b/src/tint/lang/wgsl/language_feature_test.cc
@@ -27,7 +27,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 // File generated by 'tools/src/cmd/gen' using the template:
-//   src/tint/lang/wgsl/features/language_feature_test.cc.tmpl
+//   src/tint/lang/wgsl/language_feature_test.cc.tmpl
 //
 // To regenerate run: './tools/run gen'
 //
diff --git a/src/tint/lang/wgsl/features/language_feature_test.cc.tmpl b/src/tint/lang/wgsl/language_feature_test.cc.tmpl
similarity index 100%
rename from src/tint/lang/wgsl/features/language_feature_test.cc.tmpl
rename to src/tint/lang/wgsl/language_feature_test.cc.tmpl