[tint][fuzz] Migrate proto definitions to common lib directory

The fuzzing proto depends on the ir proto, so needs to reference
it. Additionally tooling like the tint cli (and the future fuzz case
assembler) will need to reference the fuzzing proto.

Instead of having these leaf node targets reaching into other leaf
node directories, move the generated proto targets up into a common
utils location.

The encode/decode methods for doing IR <-> PB conversion are left in
the ir/ directory, becasue they need to access lots of the IR
internals.

Issue: 345204573
Change-Id: Ia0c91cacd2546d5bb932e6c833ed3cceeff515fc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/195335
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: David Neto <dneto@google.com>
diff --git a/src/tint/cmd/fuzz/ir/BUILD.bazel b/src/tint/cmd/fuzz/ir/BUILD.bazel
index 2532c66..308c902 100644
--- a/src/tint/cmd/fuzz/ir/BUILD.bazel
+++ b/src/tint/cmd/fuzz/ir/BUILD.bazel
@@ -96,6 +96,13 @@
 )
 
 selects.config_setting_group(
+    name = "tint_build_ir_binary_and_tint_build_ir_fuzzer",
+    match_all = [
+        ":tint_build_ir_binary",
+        ":tint_build_ir_fuzzer",
+    ],
+)
+selects.config_setting_group(
     name = "tint_build_ir_binary_and_tint_build_ir_fuzzer_and___not_is_asan__or_build_with_chromium_",
     match_all = [
         ":tint_build_ir_binary",
diff --git a/src/tint/cmd/fuzz/ir/BUILD.cfg b/src/tint/cmd/fuzz/ir/BUILD.cfg
index f90f83e..5b903ba 100644
--- a/src/tint/cmd/fuzz/ir/BUILD.cfg
+++ b/src/tint/cmd/fuzz/ir/BUILD.cfg
@@ -1,10 +1,4 @@
 {
-    "proto": {
-        "Condition": "tint_build_ir_binary && tint_build_ir_fuzzer && (!is_asan || build_with_chromium)",
-        "AdditionalDependencies": {
-            "Internal": [ "lang/core/ir/binary:proto" ]
-        }
-    },
     "fuzz_cmd": {
         /* Fuzzer has known false positive with ASAN in standalone builds */
         "Condition": "tint_build_ir_binary && tint_build_ir_fuzzer && (!is_asan || build_with_chromium)",
@@ -12,7 +6,10 @@
         "OutputName": "tint_ir_fuzzer",
         "AdditionalDependencies": {
             /* Depend on all the fuzz targets to pull them all together. */
-            "Internal": [ "**:fuzz" ],
+            "Internal": [
+                "**:fuzz",
+                "utils/protos/ir_fuzz:proto"
+            ],
             "External": [ "libprotobuf-mutator" ]
         }
     }
diff --git a/src/tint/cmd/fuzz/ir/BUILD.cmake b/src/tint/cmd/fuzz/ir/BUILD.cmake
index a2bec0b..d7933f8 100644
--- a/src/tint/cmd/fuzz/ir/BUILD.cmake
+++ b/src/tint/cmd/fuzz/ir/BUILD.cmake
@@ -36,23 +36,6 @@
 
 if(TINT_BUILD_IR_BINARY AND TINT_BUILD_IR_FUZZER AND ((NOT IS_ASAN) OR BUILD_WITH_CHROMIUM))
 ################################################################################
-# Target:    tint_cmd_fuzz_ir_proto
-# Kind:      proto
-# Condition: TINT_BUILD_IR_BINARY AND TINT_BUILD_IR_FUZZER AND ((NOT IS_ASAN) OR BUILD_WITH_CHROMIUM)
-################################################################################
-tint_add_target(tint_cmd_fuzz_ir_proto proto
-  cmd/fuzz/ir/fuzz.proto
-)
-
-if(TINT_BUILD_IR_BINARY)
-  tint_target_add_dependencies(tint_cmd_fuzz_ir_proto proto
-    tint_lang_core_ir_binary_proto
-  )
-endif(TINT_BUILD_IR_BINARY)
-
-endif(TINT_BUILD_IR_BINARY AND TINT_BUILD_IR_FUZZER AND ((NOT IS_ASAN) OR BUILD_WITH_CHROMIUM))
-if(TINT_BUILD_IR_BINARY AND TINT_BUILD_IR_FUZZER AND ((NOT IS_ASAN) OR BUILD_WITH_CHROMIUM))
-################################################################################
 # Target:    tint_cmd_fuzz_ir_fuzz_cmd
 # Kind:      fuzz_cmd
 # Condition: TINT_BUILD_IR_BINARY AND TINT_BUILD_IR_FUZZER AND ((NOT IS_ASAN) OR BUILD_WITH_CHROMIUM)
@@ -113,11 +96,11 @@
   )
 endif(TINT_BUILD_IR_BINARY)
 
-if(TINT_BUILD_IR_BINARY AND TINT_BUILD_IR_FUZZER AND ((NOT IS_ASAN) OR BUILD_WITH_CHROMIUM))
+if(TINT_BUILD_IR_BINARY AND TINT_BUILD_IR_FUZZER)
   tint_target_add_dependencies(tint_cmd_fuzz_ir_fuzz_cmd fuzz_cmd
-    tint_cmd_fuzz_ir_proto
+    tint_utils_protos_ir_fuzz_proto
   )
-endif(TINT_BUILD_IR_BINARY AND TINT_BUILD_IR_FUZZER AND ((NOT IS_ASAN) OR BUILD_WITH_CHROMIUM))
+endif(TINT_BUILD_IR_BINARY AND TINT_BUILD_IR_FUZZER)
 
 if(TINT_BUILD_MSL_WRITER)
   tint_target_add_dependencies(tint_cmd_fuzz_ir_fuzz_cmd fuzz_cmd
diff --git a/src/tint/cmd/fuzz/ir/BUILD.gn b/src/tint/cmd/fuzz/ir/BUILD.gn
index 265c344..beedcbc 100644
--- a/src/tint/cmd/fuzz/ir/BUILD.gn
+++ b/src/tint/cmd/fuzz/ir/BUILD.gn
@@ -37,17 +37,6 @@
 import("../../../../../scripts/tint_overrides_with_defaults.gni")
 
 import("${tint_src_dir}/tint.gni")
-if (tint_build_ir_binary && tint_build_ir_fuzzer &&
-    (!is_asan || build_with_chromium)) {
-  tint_proto_library("proto") {
-    sources = [ "fuzz.proto" ]
-    deps = []
-
-    if (tint_build_ir_binary) {
-      deps += [ "${tint_src_dir}/lang/core/ir/binary:proto" ]
-    }
-  }
-}
 
 tint_fuzz_source_set("fuzz") {
   sources = [
@@ -141,9 +130,8 @@
       ]
     }
 
-    if (tint_build_ir_binary && tint_build_ir_fuzzer &&
-        (!is_asan || build_with_chromium)) {
-      deps += [ "${tint_src_dir}/cmd/fuzz/ir:proto" ]
+    if (tint_build_ir_binary && tint_build_ir_fuzzer) {
+      deps += [ "${tint_src_dir}/utils/protos/ir_fuzz:proto" ]
     }
 
     if (tint_build_msl_writer) {
diff --git a/src/tint/cmd/fuzz/ir/main_fuzz.cc b/src/tint/cmd/fuzz/ir/main_fuzz.cc
index 3561eda..606230e 100644
--- a/src/tint/cmd/fuzz/ir/main_fuzz.cc
+++ b/src/tint/cmd/fuzz/ir/main_fuzz.cc
@@ -39,7 +39,7 @@
 
 TINT_BEGIN_DISABLE_PROTOBUF_WARNINGS();
 #include "src/libfuzzer/libfuzzer_macro.h"
-#include "src/tint/cmd/fuzz/ir/fuzz.pb.h"
+#include "src/tint/utils/protos/ir_fuzz/ir_fuzz.pb.h"
 #include "testing/libfuzzer/proto/lpm_interface.h"
 TINT_END_DISABLE_PROTOBUF_WARNINGS();
 
diff --git a/src/tint/lang/core/ir/binary/BUILD.cfg b/src/tint/lang/core/ir/binary/BUILD.cfg
index deb7ad2..22d8a48 100644
--- a/src/tint/lang/core/ir/binary/BUILD.cfg
+++ b/src/tint/lang/core/ir/binary/BUILD.cfg
@@ -1,3 +1,6 @@
 {
-    "condition": "tint_build_ir_binary"
+    "Condition": "tint_build_ir_binary",
+    "AdditionalDependencies": {
+            "Internal": [ "utils/protos/ir:proto" ]
+    }
 }
diff --git a/src/tint/lang/core/ir/binary/BUILD.cmake b/src/tint/lang/core/ir/binary/BUILD.cmake
index c749148..4b51be5 100644
--- a/src/tint/lang/core/ir/binary/BUILD.cmake
+++ b/src/tint/lang/core/ir/binary/BUILD.cmake
@@ -71,24 +71,13 @@
 
 if(TINT_BUILD_IR_BINARY)
   tint_target_add_dependencies(tint_lang_core_ir_binary lib
-    tint_lang_core_ir_binary_proto
+    tint_utils_protos_ir_proto
   )
 endif(TINT_BUILD_IR_BINARY)
 
 endif(TINT_BUILD_IR_BINARY)
 if(TINT_BUILD_IR_BINARY)
 ################################################################################
-# Target:    tint_lang_core_ir_binary_proto
-# Kind:      proto
-# Condition: TINT_BUILD_IR_BINARY
-################################################################################
-tint_add_target(tint_lang_core_ir_binary_proto proto
-  lang/core/ir/binary/ir.proto
-)
-
-endif(TINT_BUILD_IR_BINARY)
-if(TINT_BUILD_IR_BINARY)
-################################################################################
 # Target:    tint_lang_core_ir_binary_test
 # Kind:      test
 # Condition: TINT_BUILD_IR_BINARY
diff --git a/src/tint/lang/core/ir/binary/BUILD.gn b/src/tint/lang/core/ir/binary/BUILD.gn
index 0e3dd8e..667d631 100644
--- a/src/tint/lang/core/ir/binary/BUILD.gn
+++ b/src/tint/lang/core/ir/binary/BUILD.gn
@@ -72,16 +72,10 @@
     ]
 
     if (tint_build_ir_binary) {
-      deps += [ "${tint_src_dir}/lang/core/ir/binary:proto" ]
+      deps += [ "${tint_src_dir}/utils/protos/ir:proto" ]
     }
   }
 }
-if (tint_build_ir_binary) {
-  tint_proto_library("proto") {
-    sources = [ "ir.proto" ]
-    deps = []
-  }
-}
 if (tint_build_unittests) {
   if (tint_build_ir_binary) {
     tint_unittests_source_set("unittests") {
diff --git a/src/tint/lang/core/ir/binary/decode.cc b/src/tint/lang/core/ir/binary/decode.cc
index 770f89b..4382721 100644
--- a/src/tint/lang/core/ir/binary/decode.cc
+++ b/src/tint/lang/core/ir/binary/decode.cc
@@ -53,7 +53,7 @@
 #include "src/tint/utils/text/text_style.h"
 
 TINT_BEGIN_DISABLE_PROTOBUF_WARNINGS();
-#include "src/tint/lang/core/ir/binary/ir.pb.h"
+#include "src/tint/utils/protos/ir/ir.pb.h"
 TINT_END_DISABLE_PROTOBUF_WARNINGS();
 
 using namespace tint::core::fluent_types;  // NOLINT
diff --git a/src/tint/lang/core/ir/binary/encode.cc b/src/tint/lang/core/ir/binary/encode.cc
index bbd6290..37afd47 100644
--- a/src/tint/lang/core/ir/binary/encode.cc
+++ b/src/tint/lang/core/ir/binary/encode.cc
@@ -87,7 +87,7 @@
 #include "src/tint/utils/rtti/switch.h"
 
 TINT_BEGIN_DISABLE_PROTOBUF_WARNINGS();
-#include "src/tint/lang/core/ir/binary/ir.pb.h"
+#include "src/tint/utils/protos/ir/ir.pb.h"
 TINT_END_DISABLE_PROTOBUF_WARNINGS();
 
 namespace tint::core::ir::binary {
diff --git a/src/tint/utils/BUILD.cmake b/src/tint/utils/BUILD.cmake
index 1771b07..4b2c2df 100644
--- a/src/tint/utils/BUILD.cmake
+++ b/src/tint/utils/BUILD.cmake
@@ -47,6 +47,7 @@
 include(utils/macros/BUILD.cmake)
 include(utils/math/BUILD.cmake)
 include(utils/memory/BUILD.cmake)
+include(utils/protos/BUILD.cmake)
 include(utils/reflection/BUILD.cmake)
 include(utils/result/BUILD.cmake)
 include(utils/rtti/BUILD.cmake)
diff --git a/src/tint/utils/protos/BUILD.bazel b/src/tint/utils/protos/BUILD.bazel
new file mode 100644
index 0000000..8af47fa
--- /dev/null
+++ b/src/tint/utils/protos/BUILD.bazel
@@ -0,0 +1,39 @@
+# Copyright 2024 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.
+
+################################################################################
+# File generated by 'tools/src/cmd/gen' using the template:
+#   tools/src/cmd/gen/build/BUILD.bazel.tmpl
+#
+# To regenerate run: './tools/run gen'
+#
+#                       Do not modify this file directly
+################################################################################
+
+load("//src/tint:flags.bzl", "COPTS")
+load("@bazel_skylib//lib:selects.bzl", "selects")
+
diff --git a/src/tint/utils/protos/BUILD.cmake b/src/tint/utils/protos/BUILD.cmake
new file mode 100644
index 0000000..6886bc3
--- /dev/null
+++ b/src/tint/utils/protos/BUILD.cmake
@@ -0,0 +1,38 @@
+# Copyright 2024 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.
+
+################################################################################
+# File generated by 'tools/src/cmd/gen' using the template:
+#   tools/src/cmd/gen/build/BUILD.cmake.tmpl
+#
+# To regenerate run: './tools/run gen'
+#
+#                       Do not modify this file directly
+################################################################################
+
+include(utils/protos/ir/BUILD.cmake)
+include(utils/protos/ir_fuzz/BUILD.cmake)
diff --git a/src/tint/utils/protos/BUILD.gn b/src/tint/utils/protos/BUILD.gn
new file mode 100644
index 0000000..5dfc24c
--- /dev/null
+++ b/src/tint/utils/protos/BUILD.gn
@@ -0,0 +1,39 @@
+# Copyright 2024 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.
+
+################################################################################
+# File generated by 'tools/src/cmd/gen' using the template:
+#   tools/src/cmd/gen/build/BUILD.gn.tmpl
+#
+# To regenerate run: './tools/run gen'
+#
+#                       Do not modify this file directly
+################################################################################
+
+import("../../../../scripts/tint_overrides_with_defaults.gni")
+
+import("${tint_src_dir}/tint.gni")
diff --git a/src/tint/utils/protos/ir/BUILD.bazel b/src/tint/utils/protos/ir/BUILD.bazel
new file mode 100644
index 0000000..c280213
--- /dev/null
+++ b/src/tint/utils/protos/ir/BUILD.bazel
@@ -0,0 +1,44 @@
+# Copyright 2024 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.
+
+################################################################################
+# File generated by 'tools/src/cmd/gen' using the template:
+#   tools/src/cmd/gen/build/BUILD.bazel.tmpl
+#
+# To regenerate run: './tools/run gen'
+#
+#                       Do not modify this file directly
+################################################################################
+
+load("//src/tint:flags.bzl", "COPTS")
+load("@bazel_skylib//lib:selects.bzl", "selects")
+
+alias(
+  name = "tint_build_ir_binary",
+  actual = "//src/tint:tint_build_ir_binary_true",
+)
+
diff --git a/src/tint/utils/protos/ir/BUILD.cfg b/src/tint/utils/protos/ir/BUILD.cfg
new file mode 100644
index 0000000..122aebb
--- /dev/null
+++ b/src/tint/utils/protos/ir/BUILD.cfg
@@ -0,0 +1,3 @@
+{
+    "Condition": "tint_build_ir_binary"
+}
diff --git a/src/tint/utils/protos/ir/BUILD.cmake b/src/tint/utils/protos/ir/BUILD.cmake
new file mode 100644
index 0000000..db06426
--- /dev/null
+++ b/src/tint/utils/protos/ir/BUILD.cmake
@@ -0,0 +1,47 @@
+# Copyright 2024 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.
+
+################################################################################
+# File generated by 'tools/src/cmd/gen' using the template:
+#   tools/src/cmd/gen/build/BUILD.cmake.tmpl
+#
+# To regenerate run: './tools/run gen'
+#
+#                       Do not modify this file directly
+################################################################################
+
+if(TINT_BUILD_IR_BINARY)
+################################################################################
+# Target:    tint_utils_protos_ir_proto
+# Kind:      proto
+# Condition: TINT_BUILD_IR_BINARY
+################################################################################
+tint_add_target(tint_utils_protos_ir_proto proto
+  utils/protos/ir/ir.proto
+)
+
+endif(TINT_BUILD_IR_BINARY)
\ No newline at end of file
diff --git a/src/tint/utils/protos/ir/BUILD.gn b/src/tint/utils/protos/ir/BUILD.gn
new file mode 100644
index 0000000..2056e07
--- /dev/null
+++ b/src/tint/utils/protos/ir/BUILD.gn
@@ -0,0 +1,45 @@
+# Copyright 2024 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.
+
+################################################################################
+# File generated by 'tools/src/cmd/gen' using the template:
+#   tools/src/cmd/gen/build/BUILD.gn.tmpl
+#
+# To regenerate run: './tools/run gen'
+#
+#                       Do not modify this file directly
+################################################################################
+
+import("../../../../../scripts/tint_overrides_with_defaults.gni")
+
+import("${tint_src_dir}/tint.gni")
+if (tint_build_ir_binary) {
+  tint_proto_library("proto") {
+    sources = [ "ir.proto" ]
+    deps = []
+  }
+}
diff --git a/src/tint/lang/core/ir/binary/ir.proto b/src/tint/utils/protos/ir/ir.proto
similarity index 100%
rename from src/tint/lang/core/ir/binary/ir.proto
rename to src/tint/utils/protos/ir/ir.proto
diff --git a/src/tint/utils/protos/ir_fuzz/BUILD.bazel b/src/tint/utils/protos/ir_fuzz/BUILD.bazel
new file mode 100644
index 0000000..f8afa55
--- /dev/null
+++ b/src/tint/utils/protos/ir_fuzz/BUILD.bazel
@@ -0,0 +1,57 @@
+# Copyright 2024 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.
+
+################################################################################
+# File generated by 'tools/src/cmd/gen' using the template:
+#   tools/src/cmd/gen/build/BUILD.bazel.tmpl
+#
+# To regenerate run: './tools/run gen'
+#
+#                       Do not modify this file directly
+################################################################################
+
+load("//src/tint:flags.bzl", "COPTS")
+load("@bazel_skylib//lib:selects.bzl", "selects")
+
+alias(
+  name = "tint_build_ir_binary",
+  actual = "//src/tint:tint_build_ir_binary_true",
+)
+
+alias(
+  name = "tint_build_ir_fuzzer",
+  actual = "//src/tint:tint_build_ir_fuzzer_true",
+)
+
+selects.config_setting_group(
+    name = "tint_build_ir_binary_and_tint_build_ir_fuzzer",
+    match_all = [
+        ":tint_build_ir_binary",
+        ":tint_build_ir_fuzzer",
+    ],
+)
+
diff --git a/src/tint/utils/protos/ir_fuzz/BUILD.cfg b/src/tint/utils/protos/ir_fuzz/BUILD.cfg
new file mode 100644
index 0000000..9a6dd41
--- /dev/null
+++ b/src/tint/utils/protos/ir_fuzz/BUILD.cfg
@@ -0,0 +1,8 @@
+{
+    "Condition": "tint_build_ir_binary && tint_build_ir_fuzzer",
+    "proto": {
+        "AdditionalDependencies": {
+            "Internal": [ "utils/protos/ir:proto" ]
+        }
+    }
+}
diff --git a/src/tint/utils/protos/ir_fuzz/BUILD.cmake b/src/tint/utils/protos/ir_fuzz/BUILD.cmake
new file mode 100644
index 0000000..33dfa91
--- /dev/null
+++ b/src/tint/utils/protos/ir_fuzz/BUILD.cmake
@@ -0,0 +1,53 @@
+# Copyright 2024 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.
+
+################################################################################
+# File generated by 'tools/src/cmd/gen' using the template:
+#   tools/src/cmd/gen/build/BUILD.cmake.tmpl
+#
+# To regenerate run: './tools/run gen'
+#
+#                       Do not modify this file directly
+################################################################################
+
+if(TINT_BUILD_IR_BINARY AND TINT_BUILD_IR_FUZZER)
+################################################################################
+# Target:    tint_utils_protos_ir_fuzz_proto
+# Kind:      proto
+# Condition: TINT_BUILD_IR_BINARY AND TINT_BUILD_IR_FUZZER
+################################################################################
+tint_add_target(tint_utils_protos_ir_fuzz_proto proto
+  utils/protos/ir_fuzz/ir_fuzz.proto
+)
+
+if(TINT_BUILD_IR_BINARY)
+  tint_target_add_dependencies(tint_utils_protos_ir_fuzz_proto proto
+    tint_utils_protos_ir_proto
+  )
+endif(TINT_BUILD_IR_BINARY)
+
+endif(TINT_BUILD_IR_BINARY AND TINT_BUILD_IR_FUZZER)
\ No newline at end of file
diff --git a/src/tint/utils/protos/ir_fuzz/BUILD.gn b/src/tint/utils/protos/ir_fuzz/BUILD.gn
new file mode 100644
index 0000000..21ac599
--- /dev/null
+++ b/src/tint/utils/protos/ir_fuzz/BUILD.gn
@@ -0,0 +1,49 @@
+# Copyright 2024 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.
+
+################################################################################
+# File generated by 'tools/src/cmd/gen' using the template:
+#   tools/src/cmd/gen/build/BUILD.gn.tmpl
+#
+# To regenerate run: './tools/run gen'
+#
+#                       Do not modify this file directly
+################################################################################
+
+import("../../../../../scripts/tint_overrides_with_defaults.gni")
+
+import("${tint_src_dir}/tint.gni")
+if (tint_build_ir_binary && tint_build_ir_fuzzer) {
+  tint_proto_library("proto") {
+    sources = [ "ir_fuzz.proto" ]
+    deps = []
+
+    if (tint_build_ir_binary) {
+      deps += [ "${tint_src_dir}/utils/protos/ir:proto" ]
+    }
+  }
+}
diff --git a/src/tint/cmd/fuzz/ir/fuzz.proto b/src/tint/utils/protos/ir_fuzz/ir_fuzz.proto
similarity index 96%
rename from src/tint/cmd/fuzz/ir/fuzz.proto
rename to src/tint/utils/protos/ir_fuzz/ir_fuzz.proto
index 747c7d6..305f55f 100644
--- a/src/tint/cmd/fuzz/ir/fuzz.proto
+++ b/src/tint/utils/protos/ir_fuzz/ir_fuzz.proto
@@ -29,7 +29,7 @@
 
 package tint.cmd.fuzz.ir.pb;
 
-import "src/tint/lang/core/ir/binary/ir.proto";
+import "src/tint/utils/protos/ir/ir.proto";
 
 message Root {
     tint.core.ir.binary.pb.Module module = 1;