Merge pull request #4933 from hanhanW:main-to-google

PiperOrigin-RevId: 359219520
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index 39d4fcf..0bc0f81 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -23,7 +23,7 @@
       - name: Checking out repository
         uses: actions/checkout@v2
       - name: Running bazel_to_cmake
-        run: ./build_tools/bazel_to_cmake/bazel_to_cmake.py
+        run: ./build_tools/bazel_to_cmake/bazel_to_cmake.py --verbosity=2
       - name: Checking Diff
         run: git diff --exit-code
 
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 243e3e6..274ab15 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -149,6 +149,7 @@
 
 # List of all target backends to be built by default:
 set(IREE_ALL_TARGET_BACKENDS
+  CUDA
   DYLIB-LLVM-AOT
   Metal-SPIRV
   Vulkan-SPIRV
diff --git a/build_tools/bazel_to_cmake/bazel_to_cmake.py b/build_tools/bazel_to_cmake/bazel_to_cmake.py
index db57f5a..15dc6ba 100755
--- a/build_tools/bazel_to_cmake/bazel_to_cmake.py
+++ b/build_tools/bazel_to_cmake/bazel_to_cmake.py
@@ -62,9 +62,19 @@
                       default=False)
   parser.add_argument(
       "--allow_partial_conversion",
-      help="Generates partial files, ignoring errors during conversion",
+      help="Generates partial files, ignoring errors during conversion.",
       action="store_true",
       default=False)
+  parser.add_argument(
+      "--verbosity",
+      "-v",
+      type=int,
+      default=0,
+      help="Specify verbosity level where higher verbosity emits more logging."
+      " 0 (default): Only output errors and summary statistics."
+      " 1: Also output the name of each directory as it's being processed and"
+      " whether the directory is skipped."
+      " 2: Also output when conversion was successful.")
 
   # Specify only one of these (defaults to --root_dir=iree).
   group = parser.add_mutually_exclusive_group()
@@ -106,12 +116,17 @@
         file=sys.stderr)
 
 
-def convert_directories(directories, write_files, allow_partial_conversion):
+def convert_directories(directories, write_files, allow_partial_conversion,
+                        verbosity):
   failure_dirs = []
   skip_count = 0
   success_count = 0
   for directory in directories:
-    status = convert_directory(directory, write_files, allow_partial_conversion)
+    status = convert_directory(
+        directory,
+        write_files=write_files,
+        allow_partial_conversion=allow_partial_conversion,
+        verbosity=verbosity)
     if status == Status.FAILED:
       failure_dirs.append(repo_relpath(directory))
     elif status == Status.SKIPPED:
@@ -127,61 +142,70 @@
     sys.exit(1)
 
 
-def convert_directory(directory_path, write_files, allow_partial_conversion):
+def convert_directory(directory_path, write_files, allow_partial_conversion,
+                      verbosity):
   if not os.path.isdir(directory_path):
     raise FileNotFoundError(f"Cannot find directory '{directory_path}'")
 
+  rel_dir_path = repo_relpath(directory_path)
+  if verbosity >= 1:
+    log(f"Processing {rel_dir_path}")
+
   skip_file_path = os.path.join(directory_path, ".skip_bazel_to_cmake")
   build_file_path = os.path.join(directory_path, "BUILD")
   cmakelists_file_path = os.path.join(directory_path, "CMakeLists.txt")
 
+  rel_cmakelists_file_path = repo_relpath(cmakelists_file_path)
+  rel_build_file_path = repo_relpath(build_file_path)
+
   if os.path.isfile(skip_file_path):
     return Status.SKIPPED
   if not os.path.isfile(build_file_path):
     return Status.NO_BUILD_FILE
 
-  rel_cmakelists_file_path = repo_relpath(cmakelists_file_path)
-  log(f"{rel_cmakelists_file_path}...", end="")
-
-  cmake_file_exists = os.path.isfile(cmakelists_file_path)
-  copyright_line = f"# Copyright {datetime.date.today().year} Google LLC"
-  write_allowed = write_files
-  if cmake_file_exists:
+  if os.path.isfile(cmakelists_file_path):
     with open(cmakelists_file_path) as f:
       for i, line in enumerate(f):
-        if line.startswith("# Copyright"):
-          copyright_line = line.rstrip()
         if EDIT_BLOCKING_PATTERN.search(line):
-          log(f"\n  Skipped. line {i + 1}: '{line.strip()}' prevents edits. ")
+          if verbosity >= 1:
+            log(f"Skipped. line {i + 1}: '{line.strip()}' prevents edits.",
+                indent=2)
           return Status.SKIPPED
 
+  header = (f"# Autogenerated from {rel_build_file_path} by\n"
+            f"# {repo_relpath(os.path.abspath(__file__))}")
+
   with open(build_file_path, "rt") as build_file:
     build_file_code = compile(build_file.read(), build_file_path, "exec")
     try:
       converted_text = bazel_to_cmake_converter.convert_build_file(
           build_file_code,
-          copyright_line,
+          header,
           allow_partial_conversion=allow_partial_conversion)
-      if write_allowed:
+      if write_files:
         with open(cmakelists_file_path, "wt") as cmakelists_file:
           cmakelists_file.write(converted_text)
       else:
         print(converted_text, end="")
     except (NameError, NotImplementedError) as e:
       log(
-          f"\nERROR.\n"
+          f"ERROR generating {rel_dir_path}.\n"
           f"Missing a rule handler in bazel_to_cmake_converter.py?\n"
           f"Reason: `{type(e).__name__}: {e}`",
           indent=2)
       return Status.FAILED
     except KeyError as e:
       log(
-          f"\nERROR.\n"
+          f"ERROR generating {rel_dir_path}.\n"
           f"Missing a conversion in bazel_to_cmake_targets.py?\n"
           f"Reason: `{type(e).__name__}: {e}`",
           indent=2)
       return Status.FAILED
-  log(f"Success")
+  if verbosity >= 2:
+    log(
+        f"Successfly generated {rel_cmakelists_file_path}"
+        f" from {rel_build_file_path}",
+        indent=2)
   return Status.SUCCEEDED
 
 
@@ -195,10 +219,14 @@
     root_directory_path = os.path.join(repo_root, args.root_dir)
     log(f"Converting directory tree rooted at: {root_directory_path}")
     convert_directories((root for root, _, _ in os.walk(root_directory_path)),
-                        write_files, args.allow_partial_conversion)
+                        write_files=write_files,
+                        allow_partial_conversion=args.allow_partial_conversion,
+                        verbosity=args.verbosity)
   elif args.dir:
-    convert_directories([os.path.join(repo_root, args.dir)], write_files,
-                        args.allow_partial_conversion)
+    convert_directories([os.path.join(repo_root, args.dir)],
+                        write_files=write_files,
+                        allow_partial_conversion=args.allow_partial_conversion,
+                        verbosity=args.verbosity)
 
 
 if __name__ == "__main__":
diff --git a/build_tools/bazel_to_cmake/bazel_to_cmake_converter.py b/build_tools/bazel_to_cmake/bazel_to_cmake_converter.py
index 8d6d226..6bcb2e5 100644
--- a/build_tools/bazel_to_cmake/bazel_to_cmake_converter.py
+++ b/build_tools/bazel_to_cmake/bazel_to_cmake_converter.py
@@ -304,11 +304,13 @@
                  defines=None,
                  testonly=None,
                  linkopts=None,
+                 copts=None,
                  **kwargs):
     if linkopts:
       self._convert_unimplemented_function("linkopts")
     name_block = _convert_string_arg_block("NAME", name, quote=False)
     hdrs_block = _convert_string_list_block("HDRS", hdrs, sort=True)
+    copts_block = _convert_string_list_block("COPTS", copts, sort=False)
     textual_hdrs_block = _convert_string_list_block("TEXTUAL_HDRS",
                                                     textual_hdrs,
                                                     sort=True)
@@ -320,6 +322,7 @@
 
     self.converter.body += (f"iree_cc_library(\n"
                             f"{name_block}"
+                            f"{copts_block}"
                             f"{hdrs_block}"
                             f"{textual_hdrs_block}"
                             f"{srcs_block}"
@@ -607,9 +610,8 @@
 
     self.first_error = None
 
-  def convert(self, copyright_line):
-    converted_content = (f"{copyright_line}\n"
-                         f"{self.apache_license}\n\n"
+  def convert(self, header_line):
+    converted_content = (f"{header_line}\n"
                          f"{self.header}\n\n"
                          f"iree_add_all_subdirs()\n\n"
                          f"{self.body}")
@@ -621,20 +623,6 @@
 
     return converted_content
 
-  apache_license = textwrap.dedent("""\
-    #
-    # Licensed under the Apache License, Version 2.0 (the "License");
-    # you may not use this file except in compliance with the License.
-    # You may obtain a copy of the License at
-    #
-    #      https://www.apache.org/licenses/LICENSE-2.0
-    #
-    # Unless required by applicable law or agreed to in writing, software
-    # distributed under the License is distributed on an "AS IS" BASIS,
-    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    # See the License for the specific language governing permissions and
-    # limitations under the License.""")
-
 
 def GetDict(obj):
   ret = {}
@@ -644,12 +632,10 @@
   return ret
 
 
-def convert_build_file(build_file_code,
-                       copyright_line,
-                       allow_partial_conversion=False):
+def convert_build_file(build_file_code, header, allow_partial_conversion=False):
   converter = Converter()
   exec(build_file_code, GetDict(BuildFileFunctions(converter)))
-  converted_text = converter.convert(copyright_line)
+  converted_text = converter.convert(header)
   if not allow_partial_conversion and converter.first_error:
     raise converter.first_error  # pylint: disable=raising-bad-type
   return converted_text
diff --git a/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py b/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py
index e85ec49..cccd722 100644
--- a/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py
+++ b/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py
@@ -51,6 +51,7 @@
     "@llvm-project//mlir:MlirOptLib": ["MLIROptLib"],
     "@llvm-project//mlir:VectorOps": ["MLIRVector"],
     "@llvm-project//mlir:TensorDialect": ["MLIRTensor"],
+    "@llvm-project//mlir:NVVMDialect": ["MLIRNVVMIR"],
     # Vulkan
     "@iree_vulkan_headers//:vulkan_headers": ["Vulkan::Headers"],
     # Cuda
diff --git a/build_tools/cmake/iree_copts.cmake b/build_tools/cmake/iree_copts.cmake
index fa8f56f..b673006 100644
--- a/build_tools/cmake/iree_copts.cmake
+++ b/build_tools/cmake/iree_copts.cmake
@@ -403,7 +403,8 @@
 set(LLVM_ENABLE_IDE ON CACHE BOOL "" FORCE)
 
 # TODO(ataei): Use optional build time targets selection for LLVMAOT.
-set(LLVM_TARGETS_TO_BUILD "WebAssembly;X86;ARM;AArch64;RISCV" CACHE STRING "" FORCE)
+set(LLVM_TARGETS_TO_BUILD "WebAssembly;X86;ARM;AArch64;RISCV;NVPTX"
+    CACHE STRING "" FORCE)
 
 set(LLVM_ENABLE_PROJECTS "mlir" CACHE STRING "" FORCE)
 set(LLVM_ENABLE_BINDINGS OFF CACHE BOOL "" FORCE)
diff --git a/build_tools/cmake/iree_tablegen_doc.cmake b/build_tools/cmake/iree_tablegen_doc.cmake
index 5e93390..1e25625 100644
--- a/build_tools/cmake/iree_tablegen_doc.cmake
+++ b/build_tools/cmake/iree_tablegen_doc.cmake
@@ -76,7 +76,7 @@
   endwhile()
 
   # Put all dialect docs at one place.
-  set(_DOC_DIR ${CMAKE_CURRENT_BINARY_DIR}/doc/Dialects/)
+  set(_DOC_DIR ${IREE_BINARY_DIR}/doc/Dialects/)
   # Set a target to drive copy.
   add_custom_target(${_NAME}_target
             ${CMAKE_COMMAND} -E make_directory ${_DOC_DIR}
diff --git a/docs/debugging/releases.md b/docs/debugging/releases.md
new file mode 100644
index 0000000..efd7ba9
--- /dev/null
+++ b/docs/debugging/releases.md
@@ -0,0 +1,86 @@
+# Debugging releases playbook
+
+## Tools and Locations
+
+* `.github/workflows/build_package.yml`: Release packaging jobs
+* `build_tools/github_actions/build_dist.py`: Main script to build various
+  release packages (for all platforms). We usually use this when reproing to
+  approximate exactly what the CI does. Assumes a subdirectory of `main_checkout`
+  and writes builds to `iree-build` and `iree-install` as a peer of it. To use
+  locally, just symlink your source dir as `main_checkout` in an empty
+  directory (versus checking out).
+
+## Manylinux releases
+
+The Linux releases are done in a manylinux2014 docker container. At the time of
+this writing, it has gcc 9.3.1 and Python versions 3.5 - 3.9 under `/opt/python`.
+Note that this docker image approximates a 2014 era RHEL distro, patched with
+backported (newer) dev packages. It builds with gcc and BFD linker unless if
+you arrange otherwise. `yum` can be used to get some packages.
+
+Get a docker shell (see exact docker image in build_package.yml workflow):
+
+```shell
+docker run --rm -it -v $(pwd):/work/main_checkout stellaraccident/manylinux2014_x86_64-bazel-3.7.2:latest /bin/bash
+```
+
+Remember that docker runs as root unless if you take steps otherwise. Don't
+touch write files in the `/work/main_checkout` directory to avoid scattering
+root owned files on your workstation.
+
+The default system Python is 2.x, so you must select one of the more modern
+ones:
+
+```shell
+export PATH=/opt/python/cp39-cp39/bin:$PATH
+```
+
+
+Build core installation:
+
+```shell
+# (from within docker)
+cd /work
+python ./main_checkout/build_tools/github_actions/build_dist.py main-dist
+
+# Also supports:
+#   main-dist
+#   py-runtime-pkg
+#   py-xla-compiler-tools-pkg
+#   py-tflite-compiler-tools-pkg
+#   py-tf-compiler-tools-pkg
+```
+
+You can `git bisect` on the host and keep running the above in the docker
+container. Note that every time you run `build_dist.py`, it deletes the cmake
+cache but otherwise leaves the build directory (so it pays the configure cost
+but is otherwise incremental). You can just `cd iree-build` and run `ninja`
+for faster iteration (after the first build or if changing cmake flags).
+Example:
+
+Extended debugging in the manylinux container:
+
+```shell
+cd /work/iree-build
+# If doing extended debugging in the container, these may make you happier.
+yum install ccache devtoolset-9-libasan-devel gdb
+
+# Get an LLVM symbolizer.
+yum install llvm9.0
+ln -s /usr/bin/llvm-symbolizer-9.0 /usr/bin/llvm-symbolizer
+
+# You can manipulate cmake flags. These may get you a better debug experience.
+cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DIREE_ENABLE_ASAN=ON -DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=gold -DIREE_ENABLE_CCACHE=ON .
+
+ninja
+
+# Or you may need this if buggy LLVM tools (like mlir-tblgen) are leaking :(
+ASAN_OPTIONS="detect_leaks=0" ninja
+```
+
+Other tips:
+
+* If debugging the runtime, you may have a better time just building the
+  Release mode `main-dist` package above once, which will drop binaries in the
+  `iree-install` directory. Then build the `py-runtime-pkg` or equiv and
+  iterate further in the build directory. Ditto for TF/XLA/etc.
diff --git a/iree/base/internal/CMakeLists.txt b/iree/base/internal/CMakeLists.txt
index e1ecf23..2ba6c63 100644
--- a/iree/base/internal/CMakeLists.txt
+++ b/iree/base/internal/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/base/internal/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Bindings/CMakeLists.txt b/iree/compiler/Bindings/CMakeLists.txt
index 5440971..e0758c6 100644
--- a/iree/compiler/Bindings/CMakeLists.txt
+++ b/iree/compiler/Bindings/CMakeLists.txt
@@ -1,15 +1,3 @@
-# Copyright 2021 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Bindings/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
diff --git a/iree/compiler/Bindings/TFLite/CMakeLists.txt b/iree/compiler/Bindings/TFLite/CMakeLists.txt
index 5440971..700724b 100644
--- a/iree/compiler/Bindings/TFLite/CMakeLists.txt
+++ b/iree/compiler/Bindings/TFLite/CMakeLists.txt
@@ -1,15 +1,3 @@
-# Copyright 2021 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Bindings/TFLite/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
diff --git a/iree/compiler/Bindings/TFLite/Transforms/CMakeLists.txt b/iree/compiler/Bindings/TFLite/Transforms/CMakeLists.txt
index 6d725c0..3ddb47f 100644
--- a/iree/compiler/Bindings/TFLite/Transforms/CMakeLists.txt
+++ b/iree/compiler/Bindings/TFLite/Transforms/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2021 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Bindings/TFLite/Transforms/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Bindings/TFLite/Transforms/test/CMakeLists.txt b/iree/compiler/Bindings/TFLite/Transforms/test/CMakeLists.txt
index fcc538b..ebede6e 100644
--- a/iree/compiler/Bindings/TFLite/Transforms/test/CMakeLists.txt
+++ b/iree/compiler/Bindings/TFLite/Transforms/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Bindings/TFLite/Transforms/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/CMakeLists.txt b/iree/compiler/CMakeLists.txt
index 8b864e5..eb58040 100644
--- a/iree/compiler/CMakeLists.txt
+++ b/iree/compiler/CMakeLists.txt
@@ -1,15 +1,3 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
diff --git a/iree/compiler/Conversion/BUILD b/iree/compiler/Conversion/BUILD
index bfa7317..555dc1a 100644
--- a/iree/compiler/Conversion/BUILD
+++ b/iree/compiler/Conversion/BUILD
@@ -26,6 +26,7 @@
     deps = [
         "//iree/compiler/Conversion/HLOToLinalg",
         "//iree/compiler/Conversion/LinalgToLLVM",
+        "//iree/compiler/Conversion/LinalgToNVVM",
         "//iree/compiler/Conversion/LinalgToSPIRV",
         "//iree/compiler/Conversion/LinalgToVector",
     ],
diff --git a/iree/compiler/Conversion/CMakeLists.txt b/iree/compiler/Conversion/CMakeLists.txt
index 79ead57..9f12d87 100644
--- a/iree/compiler/Conversion/CMakeLists.txt
+++ b/iree/compiler/Conversion/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Conversion/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
@@ -22,6 +10,7 @@
   DEPS
     iree::compiler::Conversion::HLOToLinalg
     iree::compiler::Conversion::LinalgToLLVM
+    iree::compiler::Conversion::LinalgToNVVM
     iree::compiler::Conversion::LinalgToSPIRV
     iree::compiler::Conversion::LinalgToVector
   PUBLIC
diff --git a/iree/compiler/Conversion/CodegenUtils/CMakeLists.txt b/iree/compiler/Conversion/CodegenUtils/CMakeLists.txt
index c2e4f5f..8ea16ef 100644
--- a/iree/compiler/Conversion/CodegenUtils/CMakeLists.txt
+++ b/iree/compiler/Conversion/CodegenUtils/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Conversion/CodegenUtils/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Conversion/Common/CMakeLists.txt b/iree/compiler/Conversion/Common/CMakeLists.txt
index afd6747..c2f1429 100644
--- a/iree/compiler/Conversion/Common/CMakeLists.txt
+++ b/iree/compiler/Conversion/Common/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Conversion/Common/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Conversion/Common/Passes.cpp b/iree/compiler/Conversion/Common/Passes.cpp
index 3856f7d..6b9d2a7 100644
--- a/iree/compiler/Conversion/Common/Passes.cpp
+++ b/iree/compiler/Conversion/Common/Passes.cpp
@@ -21,7 +21,7 @@
 
 void addLinalgBufferizePasses(OpPassManager &passManager,
                               WorkgroupMemoryAllocationFn allocationFn) {
-  passManager.addPass(createLinalgBufferizePass(allocationFn));
+  passManager.addNestedPass<FuncOp>(createLinalgBufferizePass(allocationFn));
   passManager.addNestedPass<FuncOp>(createCanonicalizerPass());
   passManager.addNestedPass<FuncOp>(createCSEPass());
   passManager.addNestedPass<FuncOp>(createRemoveDeadMemAllocsPass());
diff --git a/iree/compiler/Conversion/Common/test/CMakeLists.txt b/iree/compiler/Conversion/Common/test/CMakeLists.txt
index c8a3755..7835f6f 100644
--- a/iree/compiler/Conversion/Common/test/CMakeLists.txt
+++ b/iree/compiler/Conversion/Common/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2021 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Conversion/Common/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Conversion/HLOToHLO/CMakeLists.txt b/iree/compiler/Conversion/HLOToHLO/CMakeLists.txt
index 8c0601d..f16d800 100644
--- a/iree/compiler/Conversion/HLOToHLO/CMakeLists.txt
+++ b/iree/compiler/Conversion/HLOToHLO/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Conversion/HLOToHLO/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Conversion/HLOToHLO/test/CMakeLists.txt b/iree/compiler/Conversion/HLOToHLO/test/CMakeLists.txt
index fcc538b..4212fe0 100644
--- a/iree/compiler/Conversion/HLOToHLO/test/CMakeLists.txt
+++ b/iree/compiler/Conversion/HLOToHLO/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Conversion/HLOToHLO/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Conversion/HLOToLinalg/CMakeLists.txt b/iree/compiler/Conversion/HLOToLinalg/CMakeLists.txt
index 6b6e7da..0a1b813 100644
--- a/iree/compiler/Conversion/HLOToLinalg/CMakeLists.txt
+++ b/iree/compiler/Conversion/HLOToLinalg/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Conversion/HLOToLinalg/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Conversion/HLOToLinalg/HLOToLinalgOnBuffers.cpp b/iree/compiler/Conversion/HLOToLinalg/HLOToLinalgOnBuffers.cpp
index 6b8d2e4..0470b36 100644
--- a/iree/compiler/Conversion/HLOToLinalg/HLOToLinalgOnBuffers.cpp
+++ b/iree/compiler/Conversion/HLOToLinalg/HLOToLinalgOnBuffers.cpp
@@ -1277,19 +1277,26 @@
 void populateHLOToLinalgOnBuffersConversionPatterns(
     MLIRContext *context, OwningRewritePatternList &patterns,
     TensorToBufferMap const &resultTensorToBufferMap) {
-  patterns.insert<ConvOpConversion, DepthwiseConvOpConversion,
-                  ConcatenateOpConversion, FillOpOnTensorConversion,
-                  InitTensorOpConversion,
-                  LinalgOpOnTensorConversion<linalg::GenericOp>,
-                  LinalgOpOnTensorConversion<linalg::IndexedGenericOp>,
-                  NamedOpConversion<linalg::ConvInputNWCFilterWCFOp>,
-                  NamedOpConversion<linalg::ConvInputNHWCFilterHWCFOp>,
-                  NamedOpConversion<linalg::ConvInputNDHWCFilterDHWCFOp>,
-                  NamedOpConversion<linalg::MatmulOp>,
-                  NamedOpConversion<linalg::BatchMatmulOp>,
-                  PadTensorOpConversion, ReduceWindowOpConversion,
-                  SubTensorOpConversion, TensorReshapeOpConversion>(
-      context, resultTensorToBufferMap);
+  patterns.insert<
+      // clang-format off
+      ConvOpConversion,
+      DepthwiseConvOpConversion,
+      ConcatenateOpConversion,
+      FillOpOnTensorConversion,
+      InitTensorOpConversion,
+      LinalgOpOnTensorConversion<linalg::GenericOp>,
+      LinalgOpOnTensorConversion<linalg::IndexedGenericOp>,
+      NamedOpConversion<linalg::ConvInputNWCFilterWCFOp>,
+      NamedOpConversion<linalg::ConvInputNHWCFilterHWCFOp>,
+      NamedOpConversion<linalg::ConvInputNDHWCFilterDHWCFOp>,
+      NamedOpConversion<linalg::MatmulOp>,
+      NamedOpConversion<linalg::BatchMatmulOp>,
+      PadTensorOpConversion,
+      ReduceWindowOpConversion,
+      SubTensorOpConversion,
+      TensorReshapeOpConversion
+      // clang-format on
+      >(context, resultTensorToBufferMap);
 
   // Prefer lowering to named Linalg dpethwise convolution when possible.
   patterns.insert<DepthwiseConvOpConversion>(context, resultTensorToBufferMap,
diff --git a/iree/compiler/Conversion/HLOToLinalg/test/CMakeLists.txt b/iree/compiler/Conversion/HLOToLinalg/test/CMakeLists.txt
index fcc538b..a12ad1c 100644
--- a/iree/compiler/Conversion/HLOToLinalg/test/CMakeLists.txt
+++ b/iree/compiler/Conversion/HLOToLinalg/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Conversion/HLOToLinalg/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Conversion/LLVMToLLVM/CMakeLists.txt b/iree/compiler/Conversion/LLVMToLLVM/CMakeLists.txt
index 4b02edc..d188812 100644
--- a/iree/compiler/Conversion/LLVMToLLVM/CMakeLists.txt
+++ b/iree/compiler/Conversion/LLVMToLLVM/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Conversion/LLVMToLLVM/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Conversion/LinalgToLLVM/CMakeLists.txt b/iree/compiler/Conversion/LinalgToLLVM/CMakeLists.txt
index 00431f5..e838358 100644
--- a/iree/compiler/Conversion/LinalgToLLVM/CMakeLists.txt
+++ b/iree/compiler/Conversion/LinalgToLLVM/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Conversion/LinalgToLLVM/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Conversion/LinalgToLLVM/test/CMakeLists.txt b/iree/compiler/Conversion/LinalgToLLVM/test/CMakeLists.txt
index fcc538b..a55148d 100644
--- a/iree/compiler/Conversion/LinalgToLLVM/test/CMakeLists.txt
+++ b/iree/compiler/Conversion/LinalgToLLVM/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Conversion/LinalgToLLVM/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Conversion/LinalgToNVVM/BUILD b/iree/compiler/Conversion/LinalgToNVVM/BUILD
new file mode 100644
index 0000000..db0d69e
--- /dev/null
+++ b/iree/compiler/Conversion/LinalgToNVVM/BUILD
@@ -0,0 +1,50 @@
+# Copyright 2021 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+package(
+    default_visibility = ["//visibility:public"],
+    features = ["layering_check"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+cc_library(
+    name = "LinalgToNVVM",
+    srcs = [
+        "ConvertToNVVM.cpp",
+        "Passes.cpp",
+    ],
+    hdrs = [
+        "Passes.h",
+    ],
+    deps = [
+        "//iree/compiler/Conversion/CodegenUtils",
+        "//iree/compiler/Conversion/Common",
+        "//iree/compiler/Conversion/HLOToHLO",
+        "//iree/compiler/Conversion/HLOToLinalg",
+        "//iree/compiler/Dialect/HAL/IR",
+        "//iree/compiler/Dialect/IREE/IR",
+        "//iree/compiler/Dialect/Shape/Transforms",
+        "@llvm-project//mlir:GPUToNVVMTransforms",
+        "@llvm-project//mlir:GPUTransforms",
+        "@llvm-project//mlir:LLVMTransforms",
+        "@llvm-project//mlir:LinalgTransforms",
+        "@llvm-project//mlir:NVVMDialect",
+        "@llvm-project//mlir:Pass",
+        "@llvm-project//mlir:SCFToStandard",
+        "@llvm-project//mlir:StandardOps",
+        "@llvm-project//mlir:Transforms",
+        "@mlir-hlo//:hlo",
+        "@mlir-hlo//:legalize_to_linalg",
+    ],
+)
diff --git a/iree/compiler/Conversion/LinalgToNVVM/CMakeLists.txt b/iree/compiler/Conversion/LinalgToNVVM/CMakeLists.txt
new file mode 100644
index 0000000..e34768d
--- /dev/null
+++ b/iree/compiler/Conversion/LinalgToNVVM/CMakeLists.txt
@@ -0,0 +1,32 @@
+# Autogenerated from iree/compiler/Conversion/LinalgToNVVM/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
+iree_add_all_subdirs()
+
+iree_cc_library(
+  NAME
+    LinalgToNVVM
+  HDRS
+    "Passes.h"
+  SRCS
+    "ConvertToNVVM.cpp"
+    "Passes.cpp"
+  DEPS
+    MLIRGPU
+    MLIRGPUToNVVMTransforms
+    MLIRLinalgTransforms
+    MLIRNVVMIR
+    MLIRPass
+    MLIRSCFToStandard
+    MLIRStandard
+    MLIRStandardToLLVM
+    MLIRTransforms
+    iree::compiler::Conversion::CodegenUtils
+    iree::compiler::Conversion::Common
+    iree::compiler::Conversion::HLOToHLO
+    iree::compiler::Conversion::HLOToLinalg
+    iree::compiler::Dialect::HAL::IR
+    iree::compiler::Dialect::IREE::IR
+    iree::compiler::Dialect::Shape::Transforms
+    tensorflow::mlir_hlo
+  PUBLIC
+)
diff --git a/iree/compiler/Conversion/LinalgToNVVM/ConvertToNVVM.cpp b/iree/compiler/Conversion/LinalgToNVVM/ConvertToNVVM.cpp
new file mode 100644
index 0000000..69bb302
--- /dev/null
+++ b/iree/compiler/Conversion/LinalgToNVVM/ConvertToNVVM.cpp
@@ -0,0 +1,187 @@
+// Copyright 2021 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "iree/compiler/Conversion/CodegenUtils/FunctionUtils.h"
+#include "iree/compiler/Conversion/LinalgToNVVM/Passes.h"
+#include "iree/compiler/Dialect/IREE/IR/IREEOps.h"
+#include "mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h"
+#include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h"
+#include "mlir/Dialect/GPU/Passes.h"
+#include "mlir/Dialect/LLVMIR/NVVMDialect.h"
+#include "mlir/Dialect/StandardOps/IR/Ops.h"
+#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
+#include "mlir/Transforms/Passes.h"
+
+namespace mlir {
+namespace iree_compiler {
+
+namespace {
+
+class ConvertFunc : public ConvertToLLVMPattern {
+ public:
+  explicit ConvertFunc(MLIRContext *context, LLVMTypeConverter &converter)
+      : ConvertToLLVMPattern(mlir::FuncOp::getOperationName(), context,
+                             converter, 100) {}
+
+  LogicalResult matchAndRewrite(
+      Operation *op, ArrayRef<Value> operands,
+      ConversionPatternRewriter &rewriter) const override {
+    auto funcOp = cast<FuncOp>(op);
+    FunctionType fnType = funcOp.getType();
+    (void)fnType;
+    if (!funcOp.isPublic()) return failure();
+
+    // illegal FuncOp must have 0 inputs.
+    assert(fnType.getNumInputs() == 0 && fnType.getNumResults() == 0);
+
+    TypeConverter::SignatureConversion signatureConverter(/*numOrigInputs=*/0);
+    SmallVector<Type, 8> llvmInputTypes;
+    funcOp.walk([&](IREE::HAL::InterfaceBindingSubspanOp input) {
+      auto memrefType = input.getType().cast<MemRefType>();
+      Type elType = memrefType.getElementType();
+      auto llvmType =
+          LLVM::LLVMPointerType::get(elType, memrefType.getMemorySpace());
+      llvmInputTypes.push_back(llvmType);
+    });
+    signatureConverter.addInputs(llvmInputTypes);
+
+    // Construct newFunc with all attributes except return type & symbol name.
+    SmallVector<NamedAttribute, 4> funcAttrs;
+    for (auto attr : funcOp.getAttrs()) {
+      if (attr.first == SymbolTable::getSymbolAttrName() ||
+          attr.first == mlir::impl::getTypeAttrName()) {
+        continue;
+      }
+      funcAttrs.push_back(attr);
+    }
+
+    auto llvmFuncType = LLVM::LLVMFunctionType::get(
+        LLVM::LLVMVoidType::get(rewriter.getContext()), llvmInputTypes);
+    auto newFuncOp = rewriter.create<LLVM::LLVMFuncOp>(
+        funcOp.getLoc(), funcOp.getName(), llvmFuncType,
+        LLVM::Linkage::External, funcAttrs);
+
+    // Copy all of funcOp's operations into newFuncOp's body and perform region
+    // type conversion.
+    rewriter.inlineRegionBefore(funcOp.getBody(), newFuncOp.getBody(),
+                                newFuncOp.end());
+    if (failed(rewriter.convertRegionTypes(&newFuncOp.getBody(), *typeConverter,
+                                           &signatureConverter)))
+      return failure();
+
+    rewriter.eraseOp(funcOp);
+    return success();
+  }
+};
+
+class ConvertIREEBindingOp : public ConvertToLLVMPattern {
+ public:
+  explicit ConvertIREEBindingOp(MLIRContext *context,
+                                LLVMTypeConverter &converter)
+      : ConvertToLLVMPattern(
+            IREE::HAL::InterfaceBindingSubspanOp::getOperationName(), context,
+            converter) {}
+
+  LogicalResult matchAndRewrite(
+      Operation *op, ArrayRef<Value> operands,
+      ConversionPatternRewriter &rewriter) const override {
+    // Bail until nested under an LLVMFuncOp.
+    auto llvmFuncOp = op->getParentOfType<LLVM::LLVMFuncOp>();
+    if (!llvmFuncOp) return failure();
+    assert(llvmFuncOp.getNumArguments() > 0);
+
+    Location loc = op->getLoc();
+    auto ireeBindingOp = cast<IREE::HAL::InterfaceBindingSubspanOp>(op);
+    IREE::HAL::InterfaceBindingSubspanOpAdaptor adaptor(operands);
+    MemRefType memrefType =
+        ireeBindingOp.getResult().getType().dyn_cast<MemRefType>();
+
+    // Fetch the interface binding op and extract the buffer index from void**.
+    auto symbol = SymbolTable::lookupNearestSymbolFrom(
+        op, op->getAttrOfType<SymbolRefAttr>("binding"));
+    auto interfaceBindingOp = cast<IREE::HAL::InterfaceBindingOp>(symbol);
+    Value llvmBufferBasePtr =
+        llvmFuncOp.getArgument(interfaceBindingOp.binding());
+    if (memrefType.hasStaticShape()) {
+      auto desc = MemRefDescriptor::fromStaticShape(
+          rewriter, loc, *getTypeConverter(), memrefType, llvmBufferBasePtr);
+      rewriter.replaceOp(op, {desc});
+    } else {
+      // TODO: pull those paramters from HAL constants.
+      assert(0 && "TODO: implement dynamic shape");
+    }
+
+    return success();
+  }
+};
+
+/// A pass that replaces all occurrences of GPU device operations with their
+/// corresponding NVVM equivalent.
+///
+/// This pass only handles device code and is not meant to be run on GPU host
+/// code.
+struct ConvertToNVVMPass
+    : public PassWrapper<ConvertToNVVMPass, OperationPass<ModuleOp>> {
+  void getDependentDialects(DialectRegistry &registry) const override {
+    registry.insert<LLVM::LLVMDialect, NVVM::NVVMDialect>();
+  }
+  void runOnOperation() override {
+    ModuleOp m = getOperation();
+
+    /// Customize the bitwidth used for the device side index computations.
+    LowerToLLVMOptions options = {/*useBarePtrCallConv =*/false,
+                                  /*emitCWrappers =*/false,
+                                  /*indexBitwidth =*/64,
+                                  /*useAlignedAlloc =*/false};
+    LLVMTypeConverter converter(m.getContext(), options);
+    // Apply in-dialect lowering first. In-dialect lowering will replace ops
+    // which need to be lowered further, which is not supported by a single
+    // conversion pass.
+    {
+      OwningRewritePatternList patterns;
+      populateGpuRewritePatterns(m.getContext(), patterns);
+      (void)applyPatternsAndFoldGreedily(m, std::move(patterns));
+    }
+    {
+      OwningRewritePatternList llvmPatterns;
+      llvmPatterns.insert<ConvertFunc, ConvertIREEBindingOp>(m.getContext(),
+                                                             converter);
+      populateStdToLLVMConversionPatterns(converter, llvmPatterns);
+      populateGpuToNVVMConversionPatterns(converter, llvmPatterns);
+      LLVMConversionTarget target(getContext());
+      populateStdToLLVMFuncOpConversionPattern(converter, llvmPatterns);
+      configureGpuToNVVMConversionLegality(target);
+      target.addDynamicallyLegalOp<FuncOp>([&](FuncOp funcOp) {
+        if (isEntryPoint(funcOp)) return false;
+        return true;
+      });
+      if (failed(applyPartialConversion(m, target, std::move(llvmPatterns))))
+        signalPassFailure();
+    }
+  }
+};
+
+}  // anonymous namespace
+
+std::unique_ptr<OperationPass<ModuleOp>> createConvertToNVVMPass() {
+  return std::make_unique<ConvertToNVVMPass>();
+}
+
+static PassRegistration<ConvertToNVVMPass> pass(
+    "iree-codegen-convert-to-nvvm",
+    "Perform final conversion from builtin/GPU/HAL/standard dialect to LLVM "
+    "and NVVM dialects");
+
+}  // namespace iree_compiler
+}  // namespace mlir
diff --git a/iree/compiler/Conversion/LinalgToNVVM/Passes.cpp b/iree/compiler/Conversion/LinalgToNVVM/Passes.cpp
new file mode 100644
index 0000000..5807951
--- /dev/null
+++ b/iree/compiler/Conversion/LinalgToNVVM/Passes.cpp
@@ -0,0 +1,93 @@
+// Copyright 2021 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "iree/compiler/Conversion/LinalgToNVVM/Passes.h"
+
+#include "iree/compiler/Conversion/Common/Passes.h"
+#include "iree/compiler/Conversion/HLOToHLO/Passes.h"
+#include "iree/compiler/Conversion/HLOToLinalg/Passes.h"
+#include "iree/compiler/Dialect/Shape/Transforms/Passes.h"
+#include "mlir/Conversion/SCFToStandard/SCFToStandard.h"
+#include "mlir/Dialect/Linalg/Passes.h"
+#include "mlir/Pass/PassManager.h"
+#include "mlir/Pass/PassOptions.h"
+#include "mlir/Pass/PassRegistry.h"
+#include "mlir/Transforms/Passes.h"
+
+namespace mlir {
+namespace iree_compiler {
+
+static void addLinalgToNVVMPasses(OpPassManager &pm) {
+  //===--------------------------------------------------------------------===//
+  // Initial clean up.
+  //===--------------------------------------------------------------------===//
+  pm.addPass(createCanonicalizerPass());
+  pm.addPass(createCSEPass());
+
+  // TODO: This currently maps to a single thread. We should share Tile and
+  // distribute with other GPU backends.
+  // Linalg -> SCF
+  pm.addNestedPass<FuncOp>(createConvertLinalgToLoopsPass());
+  pm.addNestedPass<FuncOp>(createCanonicalizerPass());
+  pm.addNestedPass<FuncOp>(createCSEPass());
+
+  // SCF -> STD
+  pm.addNestedPass<FuncOp>(createLowerToCFGPass());
+  pm.addNestedPass<FuncOp>(createCanonicalizerPass());
+  pm.addNestedPass<FuncOp>(createCSEPass());
+
+  // Strip out the debug info for the kernel as CUDA driver doesn't diggest PTX
+  // debug info well.
+  pm.addPass(createStripDebugInfoPass());
+  // convert to NVVM.
+  pm.addPass(createConvertToNVVMPass());
+}
+
+void buildNVVMTransformPassPipeline(OpPassManager &pm) {
+  OpPassManager &nestedModulePM = pm.nest<ModuleOp>();
+  nestedModulePM.addPass(createInlinerPass());
+
+  WorkgroupMemoryAllocationFn allocationFn =
+      [](OpBuilder &builder, Location loc, ArrayRef<int64_t> staticShape,
+         Type elementType, ArrayRef<Value> dynamicSizes) {
+        MemRefType allocType = MemRefType::get(staticShape, elementType, {}, 3);
+        return builder.create<AllocOp>(loc, allocType, dynamicSizes);
+      };
+  addLinalgBufferizePasses(nestedModulePM, allocationFn);
+
+  //===--------------------------------------------------------------------===//
+  // Convert Linalg ops to LLVM+NVVM ops.
+  //
+  // Post-conditions:
+  //   - All Linalg/Loops/GPU/Affine/Standard ops are converted away.
+  //   - The module contains the final llvm.module ready to be serialized.
+  //===--------------------------------------------------------------------===//
+  addLinalgToNVVMPasses(nestedModulePM);
+}
+
+static PassPipelineRegistration<> linalgToNVVMPipeline(
+    "iree-codegen-linalg-to-nvvm-pipeline",
+    "Runs the progressive lowering pipeline from Linalg to NVVM",
+    [](OpPassManager &passManager) { addLinalgToNVVMPasses(passManager); });
+
+static PassPipelineRegistration<> hloToLinalgNVVMPipeline(
+    "iree-codegen-hlo-to-nvvm-pipeline",
+    "Runs the progressive lowering pipeline from XLA HLO to Linalg to "
+    "NVVM",
+    [](OpPassManager &passManager) {
+      buildNVVMTransformPassPipeline(passManager);
+    });
+
+}  // namespace iree_compiler
+}  // namespace mlir
diff --git a/iree/compiler/Conversion/LinalgToNVVM/Passes.h b/iree/compiler/Conversion/LinalgToNVVM/Passes.h
new file mode 100644
index 0000000..cb731dd
--- /dev/null
+++ b/iree/compiler/Conversion/LinalgToNVVM/Passes.h
@@ -0,0 +1,34 @@
+// Copyright 2021 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef IREE_COMPILER_CONVERSION_LINALGTONVVM_PASSES_H_
+#define IREE_COMPILER_CONVERSION_LINALGTONVVM_PASSES_H_
+
+#include "iree/compiler/Dialect/HAL/IR/HALOps.h"
+#include "mlir/Pass/Pass.h"
+
+namespace mlir {
+namespace iree_compiler {
+
+/// Performs the final conversion to NNVM+LLVM dialect.
+std::unique_ptr<OperationPass<ModuleOp>> createConvertToNVVMPass();
+
+/// Populates passes needed to lower a XLA HLO op to NVVM dialect via the
+/// structured ops path. The pass manager `pm` in here should operate on the
+/// module within the IREE::HAL::ExecutableOp.
+void buildNVVMTransformPassPipeline(OpPassManager &pm);
+}  // namespace iree_compiler
+}  // namespace mlir
+
+#endif  // IREE_COMPILER_CONVERSION_LINALGTONVVM_PASSES_H_
diff --git a/iree/compiler/Conversion/LinalgToNVVM/test/BUILD b/iree/compiler/Conversion/LinalgToNVVM/test/BUILD
new file mode 100644
index 0000000..675ed91
--- /dev/null
+++ b/iree/compiler/Conversion/LinalgToNVVM/test/BUILD
@@ -0,0 +1,32 @@
+# Copyright 2021 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Tests for common transforms.
+
+load("//iree:lit_test.bzl", "iree_lit_test_suite")
+
+package(
+    default_visibility = ["//visibility:public"],
+    features = ["layering_check"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+iree_lit_test_suite(
+    name = "lit",
+    srcs = glob(["*.mlir"]),
+    data = [
+        "//iree/tools:IreeFileCheck",
+        "//iree/tools:iree-opt",
+    ],
+)
diff --git a/iree/compiler/Conversion/LinalgToNVVM/test/CMakeLists.txt b/iree/compiler/Conversion/LinalgToNVVM/test/CMakeLists.txt
new file mode 100644
index 0000000..ecaddd9
--- /dev/null
+++ b/iree/compiler/Conversion/LinalgToNVVM/test/CMakeLists.txt
@@ -0,0 +1,14 @@
+# Autogenerated from iree/compiler/Conversion/LinalgToNVVM/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
+iree_add_all_subdirs()
+
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
+iree_lit_test_suite(
+  NAME
+    lit
+  SRCS
+    "${_GLOB_X_MLIR}"
+  DATA
+    iree::tools::IreeFileCheck
+    iree::tools::iree-opt
+)
diff --git a/iree/compiler/Conversion/LinalgToNVVM/test/convert_to_nvvm.mlir b/iree/compiler/Conversion/LinalgToNVVM/test/convert_to_nvvm.mlir
new file mode 100644
index 0000000..fb3e720
--- /dev/null
+++ b/iree/compiler/Conversion/LinalgToNVVM/test/convert_to_nvvm.mlir
@@ -0,0 +1,29 @@
+// RUN: iree-opt -iree-codegen-convert-to-nvvm %s | IreeFileCheck %s
+
+// Test that that standard and GPU ops are converted to LLVM and NVVM.
+func @abs_ex_dispatch_0() {
+  %c0 = constant 0 : index
+  %0 = hal.interface.binding.subspan @legacy_io::@arg0[%c0] : memref<16xf32>
+  %1 = hal.interface.binding.subspan @legacy_io::@arg1[%c0] : memref<16xf32>
+  %2 = hal.interface.binding.subspan @legacy_io::@ret0[%c0] : memref<16xf32>
+  %3 = "gpu.block_id"() {dimension = "x"} : () -> index
+  %4 = "gpu.block_dim"() {dimension = "x"} : () -> index
+  %5 = "gpu.thread_id"() {dimension = "x"} : () -> index
+  %6 = muli %3, %4 : index
+  %7 = addi %6, %5 : index
+  %9 = load %1[%7] : memref<16xf32>
+  %10 = load %2[%7] : memref<16xf32>
+  %11 = addf %9, %10 : f32
+  store %11, %0[%7] : memref<16xf32>
+  return
+}
+hal.interface @legacy_io attributes {sym_visibility = "private"} {
+  hal.interface.binding @arg0, set=0, binding=0, type="StorageBuffer", access="Read"
+  hal.interface.binding @arg1, set=0, binding=1, type="StorageBuffer", access="Read"
+  hal.interface.binding @ret0, set=0, binding=2, type="StorageBuffer", access="Write|Discard"
+}
+
+// CHECK-LABEL: llvm.func @abs_ex_dispatch_0
+//  CHECK-SAME: (%{{.*}}: !llvm.ptr<f32>, %{{.*}}: !llvm.ptr<f32>, %{{.*}}: !llvm.ptr<f32>)
+//      CHECK:    nvvm.read.ptx.sreg.tid.x
+//      CHECK:    llvm.fadd
diff --git a/iree/compiler/Conversion/LinalgToNVVM/test/pipeline_test.mlir b/iree/compiler/Conversion/LinalgToNVVM/test/pipeline_test.mlir
new file mode 100644
index 0000000..170dee6
--- /dev/null
+++ b/iree/compiler/Conversion/LinalgToNVVM/test/pipeline_test.mlir
@@ -0,0 +1,41 @@
+// RUN: iree-opt -pass-pipeline="hal.executable(hal.executable.target(iree-codegen-hlo-to-nvvm-pipeline))" %s | IreeFileCheck %s
+
+// Verify that a simple element wise op gets lowered succefully all the way to 
+// nvvm/llvm dialect.
+
+hal.executable @simpleMath_ex_dispatch_0 {
+  hal.interface @legacy_io {
+    hal.interface.binding @arg0, set=0, binding=0, type="StorageBuffer", access="Read"
+    hal.interface.binding @ret0, set=0, binding=1, type="StorageBuffer", access="Write|Discard"
+  }
+  hal.executable.target @cuda, filter="cuda" {
+  hal.executable.entry_point @add_dispatch_0 attributes {interface = @legacy_io, ordinal = 0 : i32, signature = (!flow.dispatch.input<16xf32>, !flow.dispatch.input<16xf32>, !flow.dispatch.output<16xf32>) -> ()}
+  module  {
+    func @add_dispatch_0() {
+      %c0 = constant 0 : index
+      %0 = hal.interface.binding.subspan @legacy_io::@arg0[%c0] : !flow.dispatch.input<16xf32>
+      %1 = hal.interface.binding.subspan @legacy_io::@arg1[%c0] : !flow.dispatch.input<16xf32>
+      %2 = hal.interface.binding.subspan @legacy_io::@ret0[%c0] : !flow.dispatch.output<16xf32>
+      %3 = linalg.init_tensor [16] : tensor<16xf32>
+      %4 = flow.dispatch.input.load %0 : !flow.dispatch.input<16xf32> -> tensor<16xf32>
+      %5 = flow.dispatch.input.load %1 : !flow.dispatch.input<16xf32> -> tensor<16xf32>
+      %6 = linalg.generic {indexing_maps = [affine_map<(d0) -> (d0)>, affine_map<(d0) -> (d0)>, affine_map<(d0) -> (d0)>], iterator_types = ["parallel"]} ins(%4, %5 : tensor<16xf32>, tensor<16xf32>) outs(%3 : tensor<16xf32>) {
+      ^bb0(%arg0: f32, %arg1: f32, %arg2: f32):  // no predecessors
+          %7 = addf %arg0, %arg1 : f32
+          linalg.yield %7 : f32
+        } -> tensor<16xf32>
+        flow.dispatch.output.store %6, %2 : tensor<16xf32> -> !flow.dispatch.output<16xf32>
+        return
+      }
+      hal.interface @legacy_io attributes {sym_visibility = "private"} {
+        hal.interface.binding @arg0, set=0, binding=0, type="StorageBuffer", access="Read"
+        hal.interface.binding @arg1, set=0, binding=1, type="StorageBuffer", access="Read"
+        hal.interface.binding @ret0, set=0, binding=2, type="StorageBuffer", access="Write|Discard"
+      }
+    }
+  }
+}
+
+// CHECK-LABEL: hal.executable @simpleMath_ex_dispatch_0
+//       CHECK:   hal.executable.target @cuda, filter="cuda" {
+//       CHECK:   llvm.fadd
diff --git a/iree/compiler/Conversion/LinalgToSPIRV/CMakeLists.txt b/iree/compiler/Conversion/LinalgToSPIRV/CMakeLists.txt
index 5abd737..9c39855 100644
--- a/iree/compiler/Conversion/LinalgToSPIRV/CMakeLists.txt
+++ b/iree/compiler/Conversion/LinalgToSPIRV/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Conversion/LinalgToSPIRV/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Conversion/LinalgToSPIRV/test/CMakeLists.txt b/iree/compiler/Conversion/LinalgToSPIRV/test/CMakeLists.txt
index fcc538b..3443f8c 100644
--- a/iree/compiler/Conversion/LinalgToSPIRV/test/CMakeLists.txt
+++ b/iree/compiler/Conversion/LinalgToSPIRV/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Conversion/LinalgToSPIRV/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Conversion/LinalgToVector/CMakeLists.txt b/iree/compiler/Conversion/LinalgToVector/CMakeLists.txt
index a241c05..4e0cfeb 100644
--- a/iree/compiler/Conversion/LinalgToVector/CMakeLists.txt
+++ b/iree/compiler/Conversion/LinalgToVector/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Conversion/LinalgToVector/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Conversion/LinalgToVector/test/CMakeLists.txt b/iree/compiler/Conversion/LinalgToVector/test/CMakeLists.txt
index fcc538b..7c64ba2 100644
--- a/iree/compiler/Conversion/LinalgToVector/test/CMakeLists.txt
+++ b/iree/compiler/Conversion/LinalgToVector/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Conversion/LinalgToVector/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/CMakeLists.txt b/iree/compiler/Dialect/CMakeLists.txt
index 8b864e5..a39d62f 100644
--- a/iree/compiler/Dialect/CMakeLists.txt
+++ b/iree/compiler/Dialect/CMakeLists.txt
@@ -1,15 +1,3 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
diff --git a/iree/compiler/Dialect/Flow/Analysis/CMakeLists.txt b/iree/compiler/Dialect/Flow/Analysis/CMakeLists.txt
index aba7fe5..e0b245a 100644
--- a/iree/compiler/Dialect/Flow/Analysis/CMakeLists.txt
+++ b/iree/compiler/Dialect/Flow/Analysis/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Flow/Analysis/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/Flow/Analysis/test/CMakeLists.txt b/iree/compiler/Dialect/Flow/Analysis/test/CMakeLists.txt
index fcc538b..08136eb 100644
--- a/iree/compiler/Dialect/Flow/Analysis/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Flow/Analysis/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Flow/Analysis/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/Flow/CMakeLists.txt b/iree/compiler/Dialect/Flow/CMakeLists.txt
index 8b864e5..d4fcb71 100644
--- a/iree/compiler/Dialect/Flow/CMakeLists.txt
+++ b/iree/compiler/Dialect/Flow/CMakeLists.txt
@@ -1,15 +1,3 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Flow/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
diff --git a/iree/compiler/Dialect/Flow/Conversion/CMakeLists.txt b/iree/compiler/Dialect/Flow/Conversion/CMakeLists.txt
index 83c21fb..661d02b 100644
--- a/iree/compiler/Dialect/Flow/Conversion/CMakeLists.txt
+++ b/iree/compiler/Dialect/Flow/Conversion/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Flow/Conversion/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/Flow/Conversion/HLOToFlow/CMakeLists.txt b/iree/compiler/Dialect/Flow/Conversion/HLOToFlow/CMakeLists.txt
index 7c9fa9e..81e5f4d 100644
--- a/iree/compiler/Dialect/Flow/Conversion/HLOToFlow/CMakeLists.txt
+++ b/iree/compiler/Dialect/Flow/Conversion/HLOToFlow/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Flow/Conversion/HLOToFlow/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/Flow/Conversion/HLOToFlow/test/CMakeLists.txt b/iree/compiler/Dialect/Flow/Conversion/HLOToFlow/test/CMakeLists.txt
index fcc538b..0712827 100644
--- a/iree/compiler/Dialect/Flow/Conversion/HLOToFlow/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Flow/Conversion/HLOToFlow/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Flow/Conversion/HLOToFlow/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/Flow/Conversion/StandardToFlow/CMakeLists.txt b/iree/compiler/Dialect/Flow/Conversion/StandardToFlow/CMakeLists.txt
index edb0e14..9d6da40 100644
--- a/iree/compiler/Dialect/Flow/Conversion/StandardToFlow/CMakeLists.txt
+++ b/iree/compiler/Dialect/Flow/Conversion/StandardToFlow/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Flow/Conversion/StandardToFlow/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/Flow/Conversion/StandardToFlow/test/CMakeLists.txt b/iree/compiler/Dialect/Flow/Conversion/StandardToFlow/test/CMakeLists.txt
index fcc538b..de87783 100644
--- a/iree/compiler/Dialect/Flow/Conversion/StandardToFlow/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Flow/Conversion/StandardToFlow/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Flow/Conversion/StandardToFlow/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/Flow/IR/CMakeLists.txt b/iree/compiler/Dialect/Flow/IR/CMakeLists.txt
index 444be05..eacf58e 100644
--- a/iree/compiler/Dialect/Flow/IR/CMakeLists.txt
+++ b/iree/compiler/Dialect/Flow/IR/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Flow/IR/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_TD LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.td)
diff --git a/iree/compiler/Dialect/Flow/IR/test/CMakeLists.txt b/iree/compiler/Dialect/Flow/IR/test/CMakeLists.txt
index fcc538b..5103be5 100644
--- a/iree/compiler/Dialect/Flow/IR/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Flow/IR/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Flow/IR/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/Flow/Transforms/BUILD b/iree/compiler/Dialect/Flow/Transforms/BUILD
index 0b859a5..d8afb12 100644
--- a/iree/compiler/Dialect/Flow/Transforms/BUILD
+++ b/iree/compiler/Dialect/Flow/Transforms/BUILD
@@ -12,6 +12,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+load("//iree:build_defs.oss.bzl", "iree_cmake_extra_content")
+
 package(
     default_visibility = ["//visibility:public"],
     features = ["layering_check"],
@@ -93,3 +95,15 @@
         "@mlir-hlo//:unfuse_batch_norm",
     ],
 )
+
+# TODO(#4919): For an unknown reason, GCC's devirtualization optimization wreaks
+# havoc on this file. Needs to be further root caused. Seems to affect both 9.x
+# and 10.x.
+iree_cmake_extra_content(
+    content = """
+set_property(SOURCE
+  DispatchLinalgOnTensors.cpp
+  PROPERTY COMPILE_FLAGS $<$<CXX_COMPILER_ID:GNU>:-fno-devirtualize>)
+""",
+    inline = True,
+)
diff --git a/iree/compiler/Dialect/Flow/Transforms/CMakeLists.txt b/iree/compiler/Dialect/Flow/Transforms/CMakeLists.txt
index e0da138..f95fd02 100644
--- a/iree/compiler/Dialect/Flow/Transforms/CMakeLists.txt
+++ b/iree/compiler/Dialect/Flow/Transforms/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Flow/Transforms/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
@@ -82,3 +70,7 @@
     tensorflow::mlir_hlo
   PUBLIC
 )
+
+set_property(SOURCE
+  DispatchLinalgOnTensors.cpp
+  PROPERTY COMPILE_FLAGS $<$<CXX_COMPILER_ID:GNU>:-fno-devirtualize>)
diff --git a/iree/compiler/Dialect/Flow/Transforms/test/CMakeLists.txt b/iree/compiler/Dialect/Flow/Transforms/test/CMakeLists.txt
index fcc538b..5c48853 100644
--- a/iree/compiler/Dialect/Flow/Transforms/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Flow/Transforms/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Flow/Transforms/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/Flow/Utils/CMakeLists.txt b/iree/compiler/Dialect/Flow/Utils/CMakeLists.txt
index 0ccb47e..7323a36 100644
--- a/iree/compiler/Dialect/Flow/Utils/CMakeLists.txt
+++ b/iree/compiler/Dialect/Flow/Utils/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Flow/Utils/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/HAL/CMakeLists.txt b/iree/compiler/Dialect/HAL/CMakeLists.txt
index 743555f..00906b3 100644
--- a/iree/compiler/Dialect/HAL/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/HAL/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_embed_data(
diff --git a/iree/compiler/Dialect/HAL/Conversion/CMakeLists.txt b/iree/compiler/Dialect/HAL/Conversion/CMakeLists.txt
index ffcb261..63ca4a6 100644
--- a/iree/compiler/Dialect/HAL/Conversion/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Conversion/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/HAL/Conversion/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/HAL/Conversion/FlowToHAL/CMakeLists.txt b/iree/compiler/Dialect/HAL/Conversion/FlowToHAL/CMakeLists.txt
index 4845e08..de76b9c 100644
--- a/iree/compiler/Dialect/HAL/Conversion/FlowToHAL/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Conversion/FlowToHAL/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/HAL/Conversion/FlowToHAL/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/HAL/Conversion/FlowToHAL/test/CMakeLists.txt b/iree/compiler/Dialect/HAL/Conversion/FlowToHAL/test/CMakeLists.txt
index fcc538b..f7a92e8 100644
--- a/iree/compiler/Dialect/HAL/Conversion/FlowToHAL/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Conversion/FlowToHAL/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/HAL/Conversion/FlowToHAL/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/HAL/Conversion/HALToHAL/CMakeLists.txt b/iree/compiler/Dialect/HAL/Conversion/HALToHAL/CMakeLists.txt
index 10816c8..37f8007 100644
--- a/iree/compiler/Dialect/HAL/Conversion/HALToHAL/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Conversion/HALToHAL/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/HAL/Conversion/HALToHAL/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/HAL/Conversion/HALToHAL/test/CMakeLists.txt b/iree/compiler/Dialect/HAL/Conversion/HALToHAL/test/CMakeLists.txt
index fcc538b..26fecb1 100644
--- a/iree/compiler/Dialect/HAL/Conversion/HALToHAL/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Conversion/HALToHAL/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/HAL/Conversion/HALToHAL/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/HAL/Conversion/HALToVM/CMakeLists.txt b/iree/compiler/Dialect/HAL/Conversion/HALToVM/CMakeLists.txt
index 9b6143a..d582a7e 100644
--- a/iree/compiler/Dialect/HAL/Conversion/HALToVM/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Conversion/HALToVM/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/HAL/Conversion/HALToVM/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/CMakeLists.txt b/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/CMakeLists.txt
index fcc538b..29fc222 100644
--- a/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/HAL/Conversion/HALToVM/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/HAL/Conversion/IREEToHAL/CMakeLists.txt b/iree/compiler/Dialect/HAL/Conversion/IREEToHAL/CMakeLists.txt
index 21f3b76..42bd6b5 100644
--- a/iree/compiler/Dialect/HAL/Conversion/IREEToHAL/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Conversion/IREEToHAL/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/HAL/Conversion/IREEToHAL/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/HAL/Conversion/IREEToHAL/test/CMakeLists.txt b/iree/compiler/Dialect/HAL/Conversion/IREEToHAL/test/CMakeLists.txt
index fcc538b..10a1d5b 100644
--- a/iree/compiler/Dialect/HAL/Conversion/IREEToHAL/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Conversion/IREEToHAL/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/HAL/Conversion/IREEToHAL/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/HAL/Conversion/StandardToHAL/CMakeLists.txt b/iree/compiler/Dialect/HAL/Conversion/StandardToHAL/CMakeLists.txt
index b4c195c..0a3af21 100644
--- a/iree/compiler/Dialect/HAL/Conversion/StandardToHAL/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Conversion/StandardToHAL/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/HAL/Conversion/StandardToHAL/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/HAL/Conversion/StandardToHAL/test/CMakeLists.txt b/iree/compiler/Dialect/HAL/Conversion/StandardToHAL/test/CMakeLists.txt
index fcc538b..caf304c 100644
--- a/iree/compiler/Dialect/HAL/Conversion/StandardToHAL/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Conversion/StandardToHAL/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/HAL/Conversion/StandardToHAL/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/HAL/IR/CMakeLists.txt b/iree/compiler/Dialect/HAL/IR/CMakeLists.txt
index 2ae1a0c..efd1b58 100644
--- a/iree/compiler/Dialect/HAL/IR/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/IR/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/HAL/IR/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_TD LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.td)
diff --git a/iree/compiler/Dialect/HAL/IR/HALBase.td b/iree/compiler/Dialect/HAL/IR/HALBase.td
index 4dce36e..7d29302 100644
--- a/iree/compiler/Dialect/HAL/IR/HALBase.td
+++ b/iree/compiler/Dialect/HAL/IR/HALBase.td
@@ -237,6 +237,7 @@
 def HAL_EF_Metal : I32EnumAttrCase<"Metal", 1297370181>;
 def HAL_EF_LLVM : I32EnumAttrCase<"LLVM", 1280071245>;
 def HAL_EF_DyLib : I32EnumAttrCase<"DyLib", 1145850178>;
+def HAL_EF_CUDA : I32EnumAttrCase<"CUDA", 1129661505>;
 def HAL_ExecutableFormatAttr :
     I32EnumAttr<"ExecutableFormat", "IREE HAL Executable format", [
       HAL_EF_Unspecified,
@@ -245,7 +246,8 @@
       HAL_EF_VMLA,
       HAL_EF_SpirV,
       HAL_EF_Metal,
-      HAL_EF_DyLib
+      HAL_EF_DyLib,
+      HAL_EF_CUDA
     ]> {
   let returnType = "IREE::HAL::ExecutableFormat";
   let convertFromStorage = "static_cast<IREE::HAL::ExecutableFormat>($_self.getInt())";
diff --git a/iree/compiler/Dialect/HAL/IR/test/CMakeLists.txt b/iree/compiler/Dialect/HAL/IR/test/CMakeLists.txt
index fcc538b..9fcd8b6 100644
--- a/iree/compiler/Dialect/HAL/IR/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/IR/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/HAL/IR/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/HAL/Target/CMakeLists.txt b/iree/compiler/Dialect/HAL/Target/CMakeLists.txt
index 0d9afcf..4fcb34a 100644
--- a/iree/compiler/Dialect/HAL/Target/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Target/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/HAL/Target/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/HAL/Target/CUDA/BUILD b/iree/compiler/Dialect/HAL/Target/CUDA/BUILD
new file mode 100644
index 0000000..718d7f1
--- /dev/null
+++ b/iree/compiler/Dialect/HAL/Target/CUDA/BUILD
@@ -0,0 +1,56 @@
+# Copyright 2021 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load("//iree:build_defs.oss.bzl", "iree_cmake_extra_content")
+
+package(
+    default_visibility = ["//visibility:public"],
+    features = ["layering_check"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+iree_cmake_extra_content(
+    content = """
+if(NOT "${IREE_TARGET_BACKEND_CUDA}")
+  return()
+endif()
+""",
+)
+
+cc_library(
+    name = "CUDA",
+    srcs = [
+        "CUDATarget.cpp",
+    ],
+    hdrs = [
+        "CUDATarget.h",
+    ],
+    deps = [
+        "//iree/base:flatcc",
+        "//iree/compiler/Conversion/LinalgToNVVM",
+        "//iree/compiler/Dialect/HAL/Target",
+        "//iree/compiler/Utils",
+        "//iree/schemas:cuda_executable_def_c_fbs",
+        "@llvm-project//llvm:Core",
+        "@llvm-project//llvm:NVPTXCodeGen",
+        "@llvm-project//llvm:Support",
+        "@llvm-project//llvm:Target",
+        "@llvm-project//mlir:LLVMDialect",
+        "@llvm-project//mlir:NVVMDialect",
+        "@llvm-project//mlir:Pass",
+        "@llvm-project//mlir:Support",
+        "@llvm-project//mlir:TargetLLVMIR",
+        "@llvm-project//mlir:TargetLLVMIRModuleTranslation",
+    ],
+)
diff --git a/iree/compiler/Dialect/HAL/Target/CUDA/CMakeLists.txt b/iree/compiler/Dialect/HAL/Target/CUDA/CMakeLists.txt
new file mode 100644
index 0000000..7c7633f
--- /dev/null
+++ b/iree/compiler/Dialect/HAL/Target/CUDA/CMakeLists.txt
@@ -0,0 +1,33 @@
+# Autogenerated from iree/compiler/Dialect/HAL/Target/CUDA/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
+if(NOT "${IREE_TARGET_BACKEND_CUDA}")
+  return()
+endif()
+
+iree_add_all_subdirs()
+
+iree_cc_library(
+  NAME
+    CUDA
+  HDRS
+    "CUDATarget.h"
+  SRCS
+    "CUDATarget.cpp"
+  DEPS
+    LLVMCore
+    LLVMNVPTXCodeGen
+    LLVMSupport
+    LLVMTarget
+    MLIRLLVMIR
+    MLIRNVVMIR
+    MLIRPass
+    MLIRSupport
+    MLIRTargetLLVMIR
+    MLIRTargetLLVMIRModuleTranslation
+    iree::base::flatcc
+    iree::compiler::Conversion::LinalgToNVVM
+    iree::compiler::Dialect::HAL::Target
+    iree::compiler::Utils
+    iree::schemas::cuda_executable_def_c_fbs
+  PUBLIC
+)
diff --git a/iree/compiler/Dialect/HAL/Target/CUDA/CUDATarget.cpp b/iree/compiler/Dialect/HAL/Target/CUDA/CUDATarget.cpp
new file mode 100644
index 0000000..4e92def
--- /dev/null
+++ b/iree/compiler/Dialect/HAL/Target/CUDA/CUDATarget.cpp
@@ -0,0 +1,201 @@
+// Copyright 2021 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "iree/compiler/Dialect/HAL/Target/CUDA/CUDATarget.h"
+
+#include "iree/compiler/Conversion/LinalgToNVVM/Passes.h"
+#include "iree/compiler/Dialect/HAL/Target/TargetRegistry.h"
+#include "iree/compiler/Utils/FlatbufferUtils.h"
+#include "iree/schemas/cuda_executable_def_builder.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/LegacyPassManager.h"
+#include "llvm/IR/Module.h"
+#include "llvm/Support/TargetRegistry.h"
+#include "llvm/Support/TargetSelect.h"
+#include "llvm/Target/TargetMachine.h"
+#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
+#include "mlir/Dialect/LLVMIR/NVVMDialect.h"
+#include "mlir/Pass/PassManager.h"
+#include "mlir/Support/LogicalResult.h"
+#include "mlir/Target/LLVMIR.h"
+#include "mlir/Target/LLVMIR/Export.h"
+
+namespace mlir {
+namespace iree_compiler {
+namespace IREE {
+namespace HAL {
+
+CUDATargetOptions getCUDATargetOptionsFromFlags() {
+  CUDATargetOptions targetOptions;
+  // TODO: flags
+  return targetOptions;
+}
+
+static std::string translateModuleToISA(llvm::Module &module,
+                                        llvm::TargetMachine &targetMachine) {
+  std::string targetISA;
+  {
+    llvm::raw_string_ostream stream(targetISA);
+    llvm::buffer_ostream pstream(stream);
+    llvm::legacy::PassManager codegenPasses;
+    targetMachine.addPassesToEmitFile(codegenPasses, pstream, nullptr,
+                                      llvm::CGFT_AssemblyFile);
+    codegenPasses.run(module);
+  }
+  return targetISA;
+}
+
+class CUDATargetBackend final : public TargetBackend {
+ public:
+  CUDATargetBackend(CUDATargetOptions options) : options_(std::move(options)) {}
+
+  std::string name() const override { return "cuda"; }
+  std::string filter_pattern() const override { return "cuda"; }
+
+  void buildTranslationPassPipeline(OpPassManager &passManager) override {
+    buildNVVMTransformPassPipeline(passManager);
+  }
+
+  LogicalResult serializeExecutable(IREE::HAL::ExecutableTargetOp targetOp,
+                                    OpBuilder &executableBuilder) override {
+    // Perform the translation in a separate context to avoid any
+    // multi-threading issues.
+    llvm::LLVMContext context;
+    mlir::registerLLVMDialectTranslation(*targetOp.getContext());
+
+    // We name our files after the executable name so that they are easy to
+    // track both during compilation (logs/artifacts/etc), as outputs (final
+    // intermediate code/binary files), and at runtime (loaded
+    // libraries/symbols/etc).
+    auto libraryName =
+        targetOp->getParentOfType<IREE::HAL::ExecutableOp>().getName().str();
+
+    ModuleOp innerModuleOp = targetOp.getInnerModule();
+
+    // Remove all the functions that are not part of the CUDA kernel.
+    // TODO: Find a better solution to handle this.
+    auto illegalFuncOps = llvm::to_vector<4>(innerModuleOp.getOps<FuncOp>());
+    for (auto funcOp : illegalFuncOps) {
+      funcOp.erase();
+    }
+    auto halInterfaceOps =
+        llvm::to_vector<1>(innerModuleOp.getOps<IREE::HAL::InterfaceOp>());
+    for (auto halOp : halInterfaceOps) {
+      halOp.erase();
+    }
+
+    auto llvmModule =
+        mlir::translateModuleToLLVMIR(innerModuleOp, context, libraryName);
+    if (!llvmModule) {
+      return targetOp.emitError() << "failed to translate the MLIR LLVM "
+                                     "dialect to the native llvm::Module";
+    }
+    for (auto func : innerModuleOp.getOps<LLVM::LLVMFuncOp>()) {
+      auto *llvmFunc = llvmModule->getFunction(func.getName());
+
+      llvm::Metadata *llvmMetadata[] = {
+          llvm::ValueAsMetadata::get(llvmFunc),
+          llvm::MDString::get(llvmModule->getContext(), "kernel"),
+          llvm::ValueAsMetadata::get(llvm::ConstantInt::get(
+              llvm::Type::getInt32Ty(llvmModule->getContext()), 1))};
+      llvm::MDNode *llvmMetadataNode =
+          llvm::MDNode::get(llvmModule->getContext(), llvmMetadata);
+      llvmModule->getOrInsertNamedMetadata("nvvm.annotations")
+          ->addOperand(llvmMetadataNode);
+    }
+
+    std::unique_ptr<llvm::TargetMachine> targetMachine;
+    {
+      llvm::Triple triple("nvptx64-nvidia-cuda");
+      std::string targetChip = "sm_35";
+      std::string features = "+ptx60";
+      std::string error;
+      const llvm::Target *target =
+          llvm::TargetRegistry::lookupTarget("", triple, error);
+      if (target == nullptr) {
+        return targetOp.emitError() << "cannot initialize target triple";
+      }
+      targetMachine.reset(target->createTargetMachine(triple.str(), targetChip,
+                                                      features, {}, {}));
+      if (targetMachine == nullptr) {
+        return targetOp.emitError() << "cannot initialize target machine";
+      }
+    }
+
+    llvmModule->setDataLayout(targetMachine->createDataLayout());
+
+    std::string targetISA = translateModuleToISA(*llvmModule, *targetMachine);
+    // Serialize cuda kernel into the binary that we will embed in the
+    // final flatbuffer.
+    FlatbufferBuilder builder;
+    auto ptxCudeRef = flatbuffers_uint8_vec_create(
+        builder, reinterpret_cast<const uint8_t *>(targetISA.c_str()),
+        targetISA.size());
+
+    auto entryPointNames = llvm::to_vector<8>(
+        llvm::map_range(targetOp.getBlock().getOps<ExecutableEntryPointOp>(),
+                        [&](auto op) { return op.getName(); }));
+    auto entryPointsRef = builder.createStringVec(entryPointNames);
+
+    iree_CUDABlockSizeDef_vec_start(builder);
+    for (auto shader : entryPointNames) {
+      // Hard-coded workgroup size.
+      iree_CUDABlockSizeDef_vec_push_create(builder, 1, 1, 1);
+    }
+    auto blockSizesRef = iree_CUDABlockSizeDef_vec_end(builder);
+
+    iree_CUDAExecutableDef_start_as_root(builder);
+    iree_CUDAExecutableDef_entry_points_add(builder, entryPointsRef);
+    iree_CUDAExecutableDef_block_sizes_add(builder, blockSizesRef);
+    iree_CUDAExecutableDef_ptx_image_add(builder, ptxCudeRef);
+    iree_CUDAExecutableDef_end_as_root(builder);
+
+    // Add the binary data to the target executable.
+    executableBuilder.create<IREE::HAL::ExecutableBinaryOp>(
+        targetOp.getLoc(), targetOp.sym_name(),
+        static_cast<uint32_t>(IREE::HAL::ExecutableFormat::CUDA),
+        builder.getBufferAttr(executableBuilder.getContext()));
+
+    return success();
+  }
+
+  std::array<Value, 3> calculateDispatchWorkgroupCount(
+      Location loc, IREE::HAL::ExecutableOp executableOp,
+      IREE::HAL::ExecutableEntryPointOp entryPointOp, ValueRange workload,
+      OpBuilder &builder) override {
+    // For now we are not tiling and just dispatch everything as 1,1,1.
+    auto constantOne = builder.createOrFold<mlir::ConstantIndexOp>(loc, 1);
+    return {constantOne, constantOne, constantOne};
+  }
+
+ private:
+  CUDATargetOptions options_;
+};
+
+void registerCUDATargetBackends(
+    std::function<CUDATargetOptions()> queryOptions) {
+  getCUDATargetOptionsFromFlags();
+  static TargetBackendRegistration registration("cuda", [=]() {
+    LLVMInitializeNVPTXTarget();
+    LLVMInitializeNVPTXTargetMC();
+    LLVMInitializeNVPTXTargetInfo();
+    LLVMInitializeNVPTXAsmPrinter();
+    return std::make_unique<CUDATargetBackend>(queryOptions());
+  });
+}
+
+}  // namespace HAL
+}  // namespace IREE
+}  // namespace iree_compiler
+}  // namespace mlir
diff --git a/iree/compiler/Dialect/HAL/Target/CUDA/CUDATarget.h b/iree/compiler/Dialect/HAL/Target/CUDA/CUDATarget.h
new file mode 100644
index 0000000..d635bf2
--- /dev/null
+++ b/iree/compiler/Dialect/HAL/Target/CUDA/CUDATarget.h
@@ -0,0 +1,41 @@
+// Copyright 2021 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef IREE_COMPILER_DIALECT_HAL_TARGET_CUDA_CUDATARGET_H_
+#define IREE_COMPILER_DIALECT_HAL_TARGET_CUDA_CUDATARGET_H_
+
+#include "iree/compiler/Dialect/HAL/Target/TargetBackend.h"
+
+namespace mlir {
+namespace iree_compiler {
+namespace IREE {
+namespace HAL {
+
+// Options controlling the CUDA translation.
+struct CUDATargetOptions {};
+
+// Returns a CUDATargetOptions struct initialized with the
+// --iree-hal-cuda-* flags.
+CUDATargetOptions getCUDATargetOptionsFromFlags();
+
+// Registers the CUDA backends.
+void registerCUDATargetBackends(
+    std::function<CUDATargetOptions()> queryOptions);
+
+}  // namespace HAL
+}  // namespace IREE
+}  // namespace iree_compiler
+}  // namespace mlir
+
+#endif  // IREE_COMPILER_DIALECT_HAL_TARGET_CUDA_CUDATARGET_H_
diff --git a/iree/compiler/Dialect/HAL/Target/CUDA/test/BUILD b/iree/compiler/Dialect/HAL/Target/CUDA/test/BUILD
new file mode 100644
index 0000000..326145d
--- /dev/null
+++ b/iree/compiler/Dialect/HAL/Target/CUDA/test/BUILD
@@ -0,0 +1,30 @@
+# Copyright 2021 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load("//iree:lit_test.bzl", "iree_lit_test_suite")
+
+package(
+    default_visibility = ["//visibility:public"],
+    features = ["layering_check"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+iree_lit_test_suite(
+    name = "lit",
+    srcs = glob(["*.mlir"]),
+    data = [
+        "//iree/tools:IreeFileCheck",
+        "//iree/tools:iree-opt",
+    ],
+)
diff --git a/iree/compiler/Dialect/HAL/Target/CUDA/test/CMakeLists.txt b/iree/compiler/Dialect/HAL/Target/CUDA/test/CMakeLists.txt
new file mode 100644
index 0000000..b45bfa1
--- /dev/null
+++ b/iree/compiler/Dialect/HAL/Target/CUDA/test/CMakeLists.txt
@@ -0,0 +1,14 @@
+# Autogenerated from iree/compiler/Dialect/HAL/Target/CUDA/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
+iree_add_all_subdirs()
+
+file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
+iree_lit_test_suite(
+  NAME
+    lit
+  SRCS
+    "${_GLOB_X_MLIR}"
+  DATA
+    iree::tools::IreeFileCheck
+    iree::tools::iree-opt
+)
diff --git a/iree/compiler/Dialect/HAL/Target/CUDA/test/smoketest.mlir b/iree/compiler/Dialect/HAL/Target/CUDA/test/smoketest.mlir
new file mode 100644
index 0000000..ceb0560
--- /dev/null
+++ b/iree/compiler/Dialect/HAL/Target/CUDA/test/smoketest.mlir
@@ -0,0 +1,36 @@
+// RUN: iree-opt -split-input-file -iree-hal-transformation-pipeline -iree-hal-target-backends=cuda %s | IreeFileCheck %s
+
+
+#map = affine_map<(d0) -> (d0)>
+module  {
+  flow.executable @add_dispatch_0 attributes {sym_visibility = "private"} {
+    flow.dispatch.entry @add_dispatch_0 attributes {signature = (tensor<16xf32>, tensor<16xf32>) -> tensor<16xf32>, workgroup_rank = 3 : index}
+    module  {
+      func @add_dispatch_0(%arg0: !flow.dispatch.input<16xf32>, %arg1: !flow.dispatch.input<16xf32>, %arg2: !flow.dispatch.output<16xf32>) {
+        %0 = linalg.init_tensor [16] : tensor<16xf32>
+        %1 = flow.dispatch.input.load %arg0 : !flow.dispatch.input<16xf32> -> tensor<16xf32>
+        %2 = flow.dispatch.input.load %arg1 : !flow.dispatch.input<16xf32> -> tensor<16xf32>
+        %3 = linalg.generic {indexing_maps = [#map, #map, #map], iterator_types = ["parallel"]} ins(%1, %2 : tensor<16xf32>, tensor<16xf32>) outs(%0 : tensor<16xf32>) {
+        ^bb0(%arg3: f32, %arg4: f32, %arg5: f32):  // no predecessors
+          %4 = addf %arg3, %arg4 : f32
+          linalg.yield %4 : f32
+        } -> tensor<16xf32>
+        flow.dispatch.output.store %3, %arg2 : tensor<16xf32> -> !flow.dispatch.output<16xf32>
+        return
+      }
+    }
+  }
+  func @add(%arg0: tensor<16xf32>, %arg1: tensor<16xf32>) -> tensor<16xf32> attributes {iree.module.export, iree.reflection = {f = "I13!B4!d16B4!d16R7!B4!d16", fv = "1"}} {
+    %c1 = constant 1 : index
+    %c16 = constant 16 : index
+    %0 = flow.ex.stream.fragment(%arg2 = %c16 : index, %arg3 = %c1 : index, %arg4 = %arg0 : tensor<16xf32>, %arg5 = %arg1 : tensor<16xf32>) -> tensor<16xf32> {
+      %1 = flow.dispatch @add_dispatch_0::@add_dispatch_0[%arg2, %arg3, %arg3] (%arg4, %arg5) : (tensor<16xf32>, tensor<16xf32>) -> tensor<16xf32>
+      flow.return %1 : tensor<16xf32>
+    }
+    return %0 : tensor<16xf32>
+  }
+}
+
+//      CHECK:   hal.executable.binary @cuda attributes {
+// CHECK-SAME:     data = dense
+// CHECK-SAME:     format = 1129661505 : i32}
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/CMakeLists.txt b/iree/compiler/Dialect/HAL/Target/LLVM/CMakeLists.txt
index 78da2d6..b08a915 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/HAL/Target/LLVM/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 if(NOT "${IREE_TARGET_BACKEND_DYLIB-LLVM-AOT}")
   return()
 endif()
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/internal/CMakeLists.txt b/iree/compiler/Dialect/HAL/Target/LLVM/internal/CMakeLists.txt
index e633016..c066cf7 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/internal/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/internal/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/HAL/Target/LLVM/internal/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/test/CMakeLists.txt b/iree/compiler/Dialect/HAL/Target/LLVM/test/CMakeLists.txt
index fcc538b..725211c 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/HAL/Target/LLVM/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/HAL/Target/MetalSPIRV/CMakeLists.txt b/iree/compiler/Dialect/HAL/Target/MetalSPIRV/CMakeLists.txt
index 235a093..3cd8366 100644
--- a/iree/compiler/Dialect/HAL/Target/MetalSPIRV/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Target/MetalSPIRV/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/HAL/Target/MetalSPIRV/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 if(NOT "${IREE_TARGET_BACKEND_METAL-SPIRV}")
   return()
 endif()
diff --git a/iree/compiler/Dialect/HAL/Target/SPIRVCommon/CMakeLists.txt b/iree/compiler/Dialect/HAL/Target/SPIRVCommon/CMakeLists.txt
index 62f1631..520d056 100644
--- a/iree/compiler/Dialect/HAL/Target/SPIRVCommon/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Target/SPIRVCommon/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/HAL/Target/SPIRVCommon/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 if(NOT "${IREE_TARGET_BACKEND_VULKAN-SPIRV}" AND
    NOT "${IREE_TARGET_BACKEND_METAL-SPIRV}")
   return()
diff --git a/iree/compiler/Dialect/HAL/Target/VMLA/CMakeLists.txt b/iree/compiler/Dialect/HAL/Target/VMLA/CMakeLists.txt
index b666d40..47d6e9f 100644
--- a/iree/compiler/Dialect/HAL/Target/VMLA/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Target/VMLA/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/HAL/Target/VMLA/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 if(NOT "${IREE_TARGET_BACKEND_VMLA}")
   return()
 endif()
diff --git a/iree/compiler/Dialect/HAL/Target/VMLA/test/CMakeLists.txt b/iree/compiler/Dialect/HAL/Target/VMLA/test/CMakeLists.txt
index fcc538b..ec0a36b 100644
--- a/iree/compiler/Dialect/HAL/Target/VMLA/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Target/VMLA/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/HAL/Target/VMLA/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/HAL/Target/VulkanSPIRV/CMakeLists.txt b/iree/compiler/Dialect/HAL/Target/VulkanSPIRV/CMakeLists.txt
index 7188ea1..dacaa7e 100644
--- a/iree/compiler/Dialect/HAL/Target/VulkanSPIRV/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Target/VulkanSPIRV/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/HAL/Target/VulkanSPIRV/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 if(NOT "${IREE_TARGET_BACKEND_VULKAN-SPIRV}")
   return()
 endif()
diff --git a/iree/compiler/Dialect/HAL/Target/VulkanSPIRV/test/CMakeLists.txt b/iree/compiler/Dialect/HAL/Target/VulkanSPIRV/test/CMakeLists.txt
index fcc538b..b5242e3 100644
--- a/iree/compiler/Dialect/HAL/Target/VulkanSPIRV/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Target/VulkanSPIRV/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/HAL/Target/VulkanSPIRV/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/HAL/Transforms/CMakeLists.txt b/iree/compiler/Dialect/HAL/Transforms/CMakeLists.txt
index 9138236..882d792 100644
--- a/iree/compiler/Dialect/HAL/Transforms/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Transforms/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/HAL/Transforms/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/HAL/Transforms/test/CMakeLists.txt b/iree/compiler/Dialect/HAL/Transforms/test/CMakeLists.txt
index fcc538b..e5dc6d6 100644
--- a/iree/compiler/Dialect/HAL/Transforms/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Transforms/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/HAL/Transforms/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/HAL/Utils/CMakeLists.txt b/iree/compiler/Dialect/HAL/Utils/CMakeLists.txt
index 87e5528..41653c4 100644
--- a/iree/compiler/Dialect/HAL/Utils/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Utils/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/HAL/Utils/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/IREE/CMakeLists.txt b/iree/compiler/Dialect/IREE/CMakeLists.txt
index 8b864e5..31be410 100644
--- a/iree/compiler/Dialect/IREE/CMakeLists.txt
+++ b/iree/compiler/Dialect/IREE/CMakeLists.txt
@@ -1,15 +1,3 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/IREE/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
diff --git a/iree/compiler/Dialect/IREE/Conversion/CMakeLists.txt b/iree/compiler/Dialect/IREE/Conversion/CMakeLists.txt
index 604cf81..8997b94 100644
--- a/iree/compiler/Dialect/IREE/Conversion/CMakeLists.txt
+++ b/iree/compiler/Dialect/IREE/Conversion/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/IREE/Conversion/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/IREE/Conversion/test/CMakeLists.txt b/iree/compiler/Dialect/IREE/Conversion/test/CMakeLists.txt
index fcc538b..d9b3701 100644
--- a/iree/compiler/Dialect/IREE/Conversion/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/IREE/Conversion/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/IREE/Conversion/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/IREE/IR/CMakeLists.txt b/iree/compiler/Dialect/IREE/IR/CMakeLists.txt
index 23dda12..f3977a8 100644
--- a/iree/compiler/Dialect/IREE/IR/CMakeLists.txt
+++ b/iree/compiler/Dialect/IREE/IR/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/IREE/IR/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_TD LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.td)
diff --git a/iree/compiler/Dialect/IREE/IR/test/CMakeLists.txt b/iree/compiler/Dialect/IREE/IR/test/CMakeLists.txt
index fcc538b..8b9bb87 100644
--- a/iree/compiler/Dialect/IREE/IR/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/IREE/IR/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/IREE/IR/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/IREE/Transforms/CMakeLists.txt b/iree/compiler/Dialect/IREE/Transforms/CMakeLists.txt
index 936a2e3..2898295 100644
--- a/iree/compiler/Dialect/IREE/Transforms/CMakeLists.txt
+++ b/iree/compiler/Dialect/IREE/Transforms/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/IREE/Transforms/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/IREE/Transforms/test/CMakeLists.txt b/iree/compiler/Dialect/IREE/Transforms/test/CMakeLists.txt
index fcc538b..a2b7daa 100644
--- a/iree/compiler/Dialect/IREE/Transforms/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/IREE/Transforms/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/IREE/Transforms/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/Modules/CMakeLists.txt b/iree/compiler/Dialect/Modules/CMakeLists.txt
index 15e9263..b2c7598 100644
--- a/iree/compiler/Dialect/Modules/CMakeLists.txt
+++ b/iree/compiler/Dialect/Modules/CMakeLists.txt
@@ -1,15 +1,3 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Modules/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
diff --git a/iree/compiler/Dialect/Modules/Check/CMakeLists.txt b/iree/compiler/Dialect/Modules/Check/CMakeLists.txt
index 951175a8..feb964c 100644
--- a/iree/compiler/Dialect/Modules/Check/CMakeLists.txt
+++ b/iree/compiler/Dialect/Modules/Check/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Modules/Check/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_embed_data(
diff --git a/iree/compiler/Dialect/Modules/Check/Conversion/CMakeLists.txt b/iree/compiler/Dialect/Modules/Check/Conversion/CMakeLists.txt
index 31aeadc..890c94e 100644
--- a/iree/compiler/Dialect/Modules/Check/Conversion/CMakeLists.txt
+++ b/iree/compiler/Dialect/Modules/Check/Conversion/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Modules/Check/Conversion/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/Modules/Check/IR/CMakeLists.txt b/iree/compiler/Dialect/Modules/Check/IR/CMakeLists.txt
index f3e7b7f..73c55ae 100644
--- a/iree/compiler/Dialect/Modules/Check/IR/CMakeLists.txt
+++ b/iree/compiler/Dialect/Modules/Check/IR/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Modules/Check/IR/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_TD LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.td)
diff --git a/iree/compiler/Dialect/Modules/Check/test/CMakeLists.txt b/iree/compiler/Dialect/Modules/Check/test/CMakeLists.txt
index fcc538b..9e34aa6 100644
--- a/iree/compiler/Dialect/Modules/Check/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Modules/Check/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Modules/Check/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/Modules/Strings/CMakeLists.txt b/iree/compiler/Dialect/Modules/Strings/CMakeLists.txt
index f2f151c..dd3407a 100644
--- a/iree/compiler/Dialect/Modules/Strings/CMakeLists.txt
+++ b/iree/compiler/Dialect/Modules/Strings/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Modules/Strings/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_embed_data(
diff --git a/iree/compiler/Dialect/Modules/Strings/Conversion/CMakeLists.txt b/iree/compiler/Dialect/Modules/Strings/Conversion/CMakeLists.txt
index df57261..8c71cf2 100644
--- a/iree/compiler/Dialect/Modules/Strings/Conversion/CMakeLists.txt
+++ b/iree/compiler/Dialect/Modules/Strings/Conversion/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Modules/Strings/Conversion/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/Modules/Strings/Conversion/test/CMakeLists.txt b/iree/compiler/Dialect/Modules/Strings/Conversion/test/CMakeLists.txt
index fcc538b..2eae26f 100644
--- a/iree/compiler/Dialect/Modules/Strings/Conversion/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Modules/Strings/Conversion/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Modules/Strings/Conversion/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/Modules/Strings/IR/CMakeLists.txt b/iree/compiler/Dialect/Modules/Strings/IR/CMakeLists.txt
index 84dc490..c58d4a2 100644
--- a/iree/compiler/Dialect/Modules/Strings/IR/CMakeLists.txt
+++ b/iree/compiler/Dialect/Modules/Strings/IR/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Modules/Strings/IR/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_TD LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.td)
diff --git a/iree/compiler/Dialect/Modules/Strings/IR/test/CMakeLists.txt b/iree/compiler/Dialect/Modules/Strings/IR/test/CMakeLists.txt
index fcc538b..423ab3a 100644
--- a/iree/compiler/Dialect/Modules/Strings/IR/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Modules/Strings/IR/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Modules/Strings/IR/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/Modules/TensorList/CMakeLists.txt b/iree/compiler/Dialect/Modules/TensorList/CMakeLists.txt
index 0b41319..87e0616 100644
--- a/iree/compiler/Dialect/Modules/TensorList/CMakeLists.txt
+++ b/iree/compiler/Dialect/Modules/TensorList/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Modules/TensorList/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_TD LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.td)
diff --git a/iree/compiler/Dialect/Modules/TensorList/Conversion/CMakeLists.txt b/iree/compiler/Dialect/Modules/TensorList/Conversion/CMakeLists.txt
index be1d4f1..793f617 100644
--- a/iree/compiler/Dialect/Modules/TensorList/Conversion/CMakeLists.txt
+++ b/iree/compiler/Dialect/Modules/TensorList/Conversion/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Modules/TensorList/Conversion/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/Modules/TensorList/Conversion/test/CMakeLists.txt b/iree/compiler/Dialect/Modules/TensorList/Conversion/test/CMakeLists.txt
index fcc538b..bd52caa 100644
--- a/iree/compiler/Dialect/Modules/TensorList/Conversion/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Modules/TensorList/Conversion/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Modules/TensorList/Conversion/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/Modules/TensorList/IR/CMakeLists.txt b/iree/compiler/Dialect/Modules/TensorList/IR/CMakeLists.txt
index ba28bdb..a682091 100644
--- a/iree/compiler/Dialect/Modules/TensorList/IR/CMakeLists.txt
+++ b/iree/compiler/Dialect/Modules/TensorList/IR/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Modules/TensorList/IR/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_TD LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.td)
diff --git a/iree/compiler/Dialect/Modules/TensorList/IR/test/CMakeLists.txt b/iree/compiler/Dialect/Modules/TensorList/IR/test/CMakeLists.txt
index fcc538b..8cb0054 100644
--- a/iree/compiler/Dialect/Modules/TensorList/IR/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Modules/TensorList/IR/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Modules/TensorList/IR/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/Sequence/IR/CMakeLists.txt b/iree/compiler/Dialect/Sequence/IR/CMakeLists.txt
index eae1fd6..ab673e8 100644
--- a/iree/compiler/Dialect/Sequence/IR/CMakeLists.txt
+++ b/iree/compiler/Dialect/Sequence/IR/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Sequence/IR/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_TD LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.td)
diff --git a/iree/compiler/Dialect/Sequence/IR/test/CMakeLists.txt b/iree/compiler/Dialect/Sequence/IR/test/CMakeLists.txt
index fcc538b..cac85f0 100644
--- a/iree/compiler/Dialect/Sequence/IR/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Sequence/IR/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Sequence/IR/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/Shape/CMakeLists.txt b/iree/compiler/Dialect/Shape/CMakeLists.txt
index 8b864e5..f7caf7d 100644
--- a/iree/compiler/Dialect/Shape/CMakeLists.txt
+++ b/iree/compiler/Dialect/Shape/CMakeLists.txt
@@ -1,15 +1,3 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Shape/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
diff --git a/iree/compiler/Dialect/Shape/Conversion/CMakeLists.txt b/iree/compiler/Dialect/Shape/Conversion/CMakeLists.txt
index efb37b4..9091ab6 100644
--- a/iree/compiler/Dialect/Shape/Conversion/CMakeLists.txt
+++ b/iree/compiler/Dialect/Shape/Conversion/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Shape/Conversion/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/Shape/Conversion/test/CMakeLists.txt b/iree/compiler/Dialect/Shape/Conversion/test/CMakeLists.txt
index fcc538b..1426f24 100644
--- a/iree/compiler/Dialect/Shape/Conversion/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Shape/Conversion/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Shape/Conversion/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/Shape/IR/CMakeLists.txt b/iree/compiler/Dialect/Shape/IR/CMakeLists.txt
index b34f685..4bc5d7d 100644
--- a/iree/compiler/Dialect/Shape/IR/CMakeLists.txt
+++ b/iree/compiler/Dialect/Shape/IR/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Shape/IR/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_TD LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.td)
diff --git a/iree/compiler/Dialect/Shape/IR/test/CMakeLists.txt b/iree/compiler/Dialect/Shape/IR/test/CMakeLists.txt
index fcc538b..ba66b56 100644
--- a/iree/compiler/Dialect/Shape/IR/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Shape/IR/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Shape/IR/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/Shape/Plugins/CMakeLists.txt b/iree/compiler/Dialect/Shape/Plugins/CMakeLists.txt
index 15e9263..83e1663 100644
--- a/iree/compiler/Dialect/Shape/Plugins/CMakeLists.txt
+++ b/iree/compiler/Dialect/Shape/Plugins/CMakeLists.txt
@@ -1,15 +1,3 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Shape/Plugins/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
diff --git a/iree/compiler/Dialect/Shape/Plugins/VMLA/CMakeLists.txt b/iree/compiler/Dialect/Shape/Plugins/VMLA/CMakeLists.txt
index 33e2494..a491182 100644
--- a/iree/compiler/Dialect/Shape/Plugins/VMLA/CMakeLists.txt
+++ b/iree/compiler/Dialect/Shape/Plugins/VMLA/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Shape/Plugins/VMLA/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/Shape/Plugins/VMLA/test/CMakeLists.txt b/iree/compiler/Dialect/Shape/Plugins/VMLA/test/CMakeLists.txt
index fcc538b..61d253b 100644
--- a/iree/compiler/Dialect/Shape/Plugins/VMLA/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Shape/Plugins/VMLA/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Shape/Plugins/VMLA/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/Shape/Plugins/XLA/CMakeLists.txt b/iree/compiler/Dialect/Shape/Plugins/XLA/CMakeLists.txt
index 5e9df3d..b29b4b7 100644
--- a/iree/compiler/Dialect/Shape/Plugins/XLA/CMakeLists.txt
+++ b/iree/compiler/Dialect/Shape/Plugins/XLA/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Shape/Plugins/XLA/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/Shape/Plugins/XLA/test/CMakeLists.txt b/iree/compiler/Dialect/Shape/Plugins/XLA/test/CMakeLists.txt
index fcc538b..196446e 100644
--- a/iree/compiler/Dialect/Shape/Plugins/XLA/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Shape/Plugins/XLA/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Shape/Plugins/XLA/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/Shape/Transforms/CMakeLists.txt b/iree/compiler/Dialect/Shape/Transforms/CMakeLists.txt
index 05a6025..411d3e5 100644
--- a/iree/compiler/Dialect/Shape/Transforms/CMakeLists.txt
+++ b/iree/compiler/Dialect/Shape/Transforms/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Shape/Transforms/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/Shape/Transforms/test/CMakeLists.txt b/iree/compiler/Dialect/Shape/Transforms/test/CMakeLists.txt
index fcc538b..1f632fa 100644
--- a/iree/compiler/Dialect/Shape/Transforms/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Shape/Transforms/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Shape/Transforms/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/Shape/Utils/CMakeLists.txt b/iree/compiler/Dialect/Shape/Utils/CMakeLists.txt
index 179c98a..431a396 100644
--- a/iree/compiler/Dialect/Shape/Utils/CMakeLists.txt
+++ b/iree/compiler/Dialect/Shape/Utils/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Shape/Utils/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/VM/Analysis/CMakeLists.txt b/iree/compiler/Dialect/VM/Analysis/CMakeLists.txt
index 24cdcbb..f5b0037 100644
--- a/iree/compiler/Dialect/VM/Analysis/CMakeLists.txt
+++ b/iree/compiler/Dialect/VM/Analysis/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/VM/Analysis/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/VM/Analysis/test/CMakeLists.txt b/iree/compiler/Dialect/VM/Analysis/test/CMakeLists.txt
index fcc538b..6de1f97 100644
--- a/iree/compiler/Dialect/VM/Analysis/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/VM/Analysis/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/VM/Analysis/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/VM/CMakeLists.txt b/iree/compiler/Dialect/VM/CMakeLists.txt
index 8b864e5..97021e5 100644
--- a/iree/compiler/Dialect/VM/CMakeLists.txt
+++ b/iree/compiler/Dialect/VM/CMakeLists.txt
@@ -1,15 +1,3 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/VM/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
diff --git a/iree/compiler/Dialect/VM/Conversion/CMakeLists.txt b/iree/compiler/Dialect/VM/Conversion/CMakeLists.txt
index 1b010fe..0375578 100644
--- a/iree/compiler/Dialect/VM/Conversion/CMakeLists.txt
+++ b/iree/compiler/Dialect/VM/Conversion/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/VM/Conversion/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/VM/Conversion/IREEToVM/CMakeLists.txt b/iree/compiler/Dialect/VM/Conversion/IREEToVM/CMakeLists.txt
index 7dd6d3c..5cef1cf 100644
--- a/iree/compiler/Dialect/VM/Conversion/IREEToVM/CMakeLists.txt
+++ b/iree/compiler/Dialect/VM/Conversion/IREEToVM/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/VM/Conversion/IREEToVM/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/VM/Conversion/IREEToVM/test/CMakeLists.txt b/iree/compiler/Dialect/VM/Conversion/IREEToVM/test/CMakeLists.txt
index fcc538b..891b440 100644
--- a/iree/compiler/Dialect/VM/Conversion/IREEToVM/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/VM/Conversion/IREEToVM/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/VM/Conversion/IREEToVM/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/VM/Conversion/StandardToVM/CMakeLists.txt b/iree/compiler/Dialect/VM/Conversion/StandardToVM/CMakeLists.txt
index bea0fe3..1cb8c88 100644
--- a/iree/compiler/Dialect/VM/Conversion/StandardToVM/CMakeLists.txt
+++ b/iree/compiler/Dialect/VM/Conversion/StandardToVM/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/VM/Conversion/StandardToVM/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/VM/Conversion/StandardToVM/test/CMakeLists.txt b/iree/compiler/Dialect/VM/Conversion/StandardToVM/test/CMakeLists.txt
index fcc538b..67db6ad 100644
--- a/iree/compiler/Dialect/VM/Conversion/StandardToVM/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/VM/Conversion/StandardToVM/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/VM/Conversion/StandardToVM/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/VM/Conversion/VMToEmitC/ConvertVMToEmitC.cpp b/iree/compiler/Dialect/VM/Conversion/VMToEmitC/ConvertVMToEmitC.cpp
index cf52f34..0777673 100644
--- a/iree/compiler/Dialect/VM/Conversion/VMToEmitC/ConvertVMToEmitC.cpp
+++ b/iree/compiler/Dialect/VM/Conversion/VMToEmitC/ConvertVMToEmitC.cpp
@@ -33,6 +33,18 @@
       }));
 }
 
+template <typename AccessOpTy, typename GlobalOpTy>
+GlobalOpTy lookupGlobalOp(AccessOpTy accessOp) {
+  FlatSymbolRefAttr globalAttr =
+      accessOp.getOperation()->template getAttrOfType<FlatSymbolRefAttr>(
+          "global");
+  GlobalOpTy globalOp =
+      accessOp.getOperation()
+          ->template getParentOfType<IREE::VM::ModuleOp>()
+          .template lookupSymbol<GlobalOpTy>(globalAttr.getValue());
+  return globalOp;
+}
+
 // Convert vm operations to emitc calls. The resultiong call has the ops
 // operands as arguments followed by an argument for every attribute.
 template <typename SrcOpTy>
@@ -78,10 +90,91 @@
   StringRef funcName;
 };
 
+template <typename LoadOpTy, typename GlobalOpTy>
+class GlobalLoadOpConversion : public OpConversionPattern<LoadOpTy> {
+  using OpConversionPattern<LoadOpTy>::OpConversionPattern;
+
+ public:
+  GlobalLoadOpConversion(MLIRContext *context, StringRef funcName)
+      : OpConversionPattern<LoadOpTy>(context), funcName(funcName) {}
+
+ private:
+  LogicalResult matchAndRewrite(
+      LoadOpTy loadOp, ArrayRef<Value> operands,
+      ConversionPatternRewriter &rewriter) const override {
+    GlobalOpTy globalOp = lookupGlobalOp<LoadOpTy, GlobalOpTy>(loadOp);
+    if (!globalOp) return loadOp.emitError() << "Unable to find GlobalOp";
+
+    auto type = loadOp.getOperation()->getResultTypes();
+    StringAttr callee = rewriter.getStringAttr(funcName);
+
+    // TODO(simon-camp): We can't represent structs in emitc (yet maybe), so the
+    // buffer where globals live after code generation as well as the state
+    // struct argument name are hardcoded here.
+    ArrayAttr args = rewriter.getArrayAttr(
+        {rewriter.getStringAttr("state->rwdata"),
+         rewriter.getUI32IntegerAttr(static_cast<uint32_t>(
+             globalOp.ordinal().getValue().getZExtValue()))});
+    ArrayAttr templateArgs;
+
+    rewriter.replaceOpWithNewOp<emitc::CallOp>(loadOp, type, callee, args,
+                                               templateArgs, operands);
+
+    return success();
+  }
+
+  StringRef funcName;
+};
+
+template <typename StoreOpTy, typename GlobalOpTy>
+class GlobalStoreOpConversion : public OpConversionPattern<StoreOpTy> {
+  using OpConversionPattern<StoreOpTy>::OpConversionPattern;
+
+ public:
+  GlobalStoreOpConversion(MLIRContext *context, StringRef funcName)
+      : OpConversionPattern<StoreOpTy>(context), funcName(funcName) {}
+
+ private:
+  LogicalResult matchAndRewrite(
+      StoreOpTy storeOp, ArrayRef<Value> operands,
+      ConversionPatternRewriter &rewriter) const override {
+    GlobalOpTy globalOp = lookupGlobalOp<StoreOpTy, GlobalOpTy>(storeOp);
+    if (!globalOp) return storeOp.emitError() << "Unable to find GlobalOp";
+
+    auto type = storeOp.getOperation()->getResultTypes();
+    StringAttr callee = rewriter.getStringAttr(funcName);
+
+    // TODO(simon-camp): We can't represent structs in emitc (yet maybe), so the
+    // buffer where globals live after code generation as well as the state
+    // struct argument name are hardcoded here.
+    ArrayAttr args = rewriter.getArrayAttr(
+        {rewriter.getStringAttr("state->rwdata"),
+         rewriter.getUI32IntegerAttr(static_cast<uint32_t>(
+             globalOp.ordinal().getValue().getZExtValue())),
+         rewriter.getIndexAttr(0)});
+    ArrayAttr templateArgs;
+
+    rewriter.replaceOpWithNewOp<emitc::CallOp>(storeOp, type, callee, args,
+                                               templateArgs, operands);
+
+    return success();
+  }
+
+  StringRef funcName;
+};
+
 }  // namespace
 
 void populateVMToCPatterns(MLIRContext *context,
                            OwningRewritePatternList &patterns) {
+  // Globals
+  patterns.insert<
+      GlobalLoadOpConversion<IREE::VM::GlobalLoadI32Op, IREE::VM::GlobalI32Op>>(
+      context, "vm_global_load_i32");
+  patterns.insert<GlobalStoreOpConversion<IREE::VM::GlobalStoreI32Op,
+                                          IREE::VM::GlobalI32Op>>(
+      context, "vm_global_store_i32");
+
   // Constants
   patterns.insert<CallOpConversion<IREE::VM::ConstI32Op>>(context,
                                                           "vm_const_i32");
@@ -225,6 +318,7 @@
     target.addLegalOp<IREE::VM::ModuleOp>();
     target.addLegalOp<IREE::VM::ModuleTerminatorOp>();
     target.addLegalOp<IREE::VM::FuncOp>();
+    target.addLegalOp<IREE::VM::GlobalI32Op>();
     target.addLegalOp<IREE::VM::ExportOp>();
 
     // Control flow ops
diff --git a/iree/compiler/Dialect/VM/IR/CMakeLists.txt b/iree/compiler/Dialect/VM/IR/CMakeLists.txt
index e180228..bdf4748 100644
--- a/iree/compiler/Dialect/VM/IR/CMakeLists.txt
+++ b/iree/compiler/Dialect/VM/IR/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/VM/IR/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_TD LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.td)
diff --git a/iree/compiler/Dialect/VM/IR/test/CMakeLists.txt b/iree/compiler/Dialect/VM/IR/test/CMakeLists.txt
index fcc538b..4db8e14 100644
--- a/iree/compiler/Dialect/VM/IR/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/VM/IR/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/VM/IR/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/VM/Target/Bytecode/CMakeLists.txt b/iree/compiler/Dialect/VM/Target/Bytecode/CMakeLists.txt
index 21a6a83..c49f604 100644
--- a/iree/compiler/Dialect/VM/Target/Bytecode/CMakeLists.txt
+++ b/iree/compiler/Dialect/VM/Target/Bytecode/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/VM/Target/Bytecode/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/VM/Target/Bytecode/test/CMakeLists.txt b/iree/compiler/Dialect/VM/Target/Bytecode/test/CMakeLists.txt
index 6495524..1b75268 100644
--- a/iree/compiler/Dialect/VM/Target/Bytecode/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/VM/Target/Bytecode/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/VM/Target/Bytecode/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/VM/Target/C/CModuleTarget.cpp b/iree/compiler/Dialect/VM/Target/C/CModuleTarget.cpp
index 3d38624..8efedb5 100644
--- a/iree/compiler/Dialect/VM/Target/C/CModuleTarget.cpp
+++ b/iree/compiler/Dialect/VM/Target/C/CModuleTarget.cpp
@@ -57,12 +57,20 @@
 }
 
 static LogicalResult printStructDefinitions(IREE::VM::ModuleOp &moduleOp,
-                                            llvm::raw_ostream &output) {
-  // TODO(simon-camp): Support stateful modules
+                                            mlir::emitc::CppEmitter &emitter) {
+  llvm::raw_ostream &output = emitter.ostream();
   std::string moduleName = moduleOp.getName().str();
 
   output << "struct " << moduleName << "_s;\n";
-  output << "struct " << moduleName << "_state_s;\n";
+  output << "struct " << moduleName << "_state_s {\n";
+
+  output << "iree_allocator_t allocator;\n";
+  output << "uint8_t rwdata["
+         << moduleOp.ordinal_counts().getValue().global_bytes() << "];\n";
+  output << "iree_vm_ref_t refs["
+         << moduleOp.ordinal_counts().getValue().global_refs() << "];\n";
+  output << "};\n";
+
   output << "typedef struct " << moduleName << "_s " << moduleName << "_t;\n";
   output << "typedef struct " << moduleName << "_state_s " << moduleName
          << "_state_t;\n";
@@ -112,6 +120,33 @@
       });
 }
 
+static LogicalResult initializeGlobals(IREE::VM::ModuleOp moduleOp,
+                                       mlir::emitc::CppEmitter &emitter) {
+  llvm::raw_ostream &output = emitter.ostream();
+
+  for (auto globalOp : moduleOp.getOps<IREE::VM::GlobalI32Op>()) {
+    Optional<Attribute> initialValue = globalOp.initial_value();
+    Optional<StringRef> initializer = globalOp.initializer();
+    if (initialValue.hasValue()) {
+      // TODO(simon-camp): We can't represent structs in emitc (yet maybe), so
+      // the struct argument name here must not be changed.
+      emitter.ostream() << "vm_global_store_i32(state->rwdata, "
+                        << globalOp.ordinal() << ", ";
+      if (failed(emitter.emitAttribute(initialValue.getValue()))) {
+        return globalOp.emitError() << "Unable to emit initial_value";
+      }
+      emitter.ostream() << ");\n";
+    } else if (initializer.hasValue()) {
+      return globalOp.emitError()
+             << "Initializers for globals not supported yet";
+    }
+  }
+
+  // TODO(simon-camp): Support vm.global.i64 and vm.global.ref
+
+  return success();
+}
+
 static LogicalResult translateCallOpToC(IREE::VM::CallOp callOp,
                                         mlir::emitc::CppEmitter &emitter) {
   return success();
@@ -151,6 +186,7 @@
 static LogicalResult translateFunctionToC(IREE::VM::ModuleOp &moduleOp,
                                           IREE::VM::FuncOp &funcOp,
                                           mlir::emitc::CppEmitter &emitter) {
+  std::string moduleName = moduleOp.getName().str();
   emitc::CppEmitter::Scope scope(emitter);
   llvm::raw_ostream &output = emitter.ostream();
 
@@ -178,7 +214,13 @@
     return failure();
   }
 
-  output << ") {\n";
+  if (funcOp.getNumArguments() + funcOp.getNumResults() > 0) {
+    output << ", ";
+  }
+
+  // TODO(simon-camp): We can't represent structs in emitc (yet maybe), so the
+  // struct argument name here must not be changed.
+  output << moduleName << "_state_t* state) {\n";
 
   for (auto &op : funcOp.getOps()) {
     if (failed(translateOpToC(op, emitter, resultNames))) {
@@ -197,10 +239,6 @@
   std::string moduleName = moduleOp.getName().str();
   llvm::raw_ostream &output = emitter.ostream();
 
-  if (failed(printStructDefinitions(moduleOp, output))) {
-    return failure();
-  }
-
   // function wrapper
   for (auto funcOp : moduleOp.getOps<IREE::VM::FuncOp>()) {
     output << "static iree_status_t "
@@ -208,7 +246,7 @@
                                 /*implSufffix=*/false)
            << "("
            << "iree_vm_stack_t* stack, " << moduleName << "_t* module, "
-           << moduleName << "_state_t* module_state";
+           << moduleName << "_state_t* state";
 
     if (funcOp.getNumArguments() > 0) {
       output << ", ";
@@ -218,7 +256,7 @@
       return failure();
     }
 
-    if (funcOp.getNumResults() > 0) {
+    if (funcOp.getNumArguments() > 0) {
       output << ", ";
     }
 
@@ -251,7 +289,10 @@
 
     output << llvm::join(resultNames, ", ");
 
-    output << ");\n}\n";
+    if (funcOp.getNumArguments() + funcOp.getNumResults() > 0) {
+      output << ", ";
+    }
+    output << "state);\n}\n";
   }
 
   auto printCStringView = [](std::string s) -> std::string {
@@ -327,26 +368,55 @@
          << "NULL,\n"
          << "};\n";
 
-  // create
-  // TODO(simon-camp): look at iree/vm/bytecode_module.h for an example of a
-  // stateful module
-  output
-      << "static iree_status_t " << moduleName << "_create("
-      << "iree_allocator_t allocator, iree_vm_module_t** "
-         "out_module) {\n"
-      << "iree_vm_module_t interface;\n"
-      << "IREE_RETURN_IF_ERROR(iree_vm_module_initialize(&interface, NULL));\n"
-      << "return iree_vm_native_module_create(&interface, "
-         "&"
-      << descriptorName << ", allocator, out_module);\n"
-      << "}\n";
+  // destroy
+  // TODO(simon-camp):
 
-  // TODO(simon-camp): generate boilerplate code
-  //   * interface functions
-  //      * destroy
-  //      * alloc_state
-  //      * free_state
-  //      * resolve_import
+  // alloc_state
+  output << "static iree_status_t " << moduleName
+         << "_alloc_state(void* self, iree_allocator_t allocator, "
+            "iree_vm_module_state_t** out_module_state) {\n"
+         << moduleName << "_state_t* state = NULL;\n"
+         << "IREE_RETURN_IF_ERROR(iree_allocator_malloc(allocator, "
+            "sizeof(*state), (void**)&state));\n "
+         << "memset(state, 0, sizeof(*state));\n"
+         << "state->allocator = allocator;\n";
+
+  // initialize globals
+  if (failed(initializeGlobals(moduleOp, emitter))) {
+    return moduleOp.emitError() << "Failed to emit global initialization";
+  }
+
+  output << "*out_module_state = (iree_vm_module_state_t*)state;\n"
+         << "return iree_ok_status();\n"
+         << "}\n";
+
+  // free_state
+  output << "static void " << moduleName
+         << "_free_state(void* self, iree_vm_module_state_t* "
+            "module_state) {\n"
+         << moduleName << "_state_t* state = (" << moduleName
+         << "_state_t*)module_state;\n"
+         << "iree_allocator_free(state->allocator, state);\n"
+         << "}\n";
+
+  // resolve_imports
+  // TODO(simon-camp):
+
+  // create
+  output << "static iree_status_t " << moduleName << "_create("
+         << "iree_allocator_t allocator, iree_vm_module_t** "
+            "out_module) {\n"
+         << "iree_vm_module_t interface;\n"
+         << "IREE_RETURN_IF_ERROR(iree_vm_module_initialize(&interface, "
+            "NULL));\n"
+         << "interface.destroy = NULL;\n"
+         << "interface.alloc_state = " << moduleName << "_alloc_state;\n"
+         << "interface.free_state = " << moduleName << "_free_state;\n"
+         << "interface.resolve_import = NULL;\n"
+         << "return iree_vm_native_module_create(&interface, "
+            "&"
+         << descriptorName << ", allocator, out_module);\n"
+         << "}\n";
 
   output << "\n";
   return success();
@@ -399,9 +469,6 @@
     // modulePasses.addPass(mlir::createCanonicalizerPass());
   }
 
-  // C target specific passes
-  modulePasses.addPass(createConvertVMToEmitCPass());
-
   modulePasses.addPass(createDropCompilerHintsPass());
 
   // Mark up the module with ordinals for each top-level op (func, etc).
@@ -411,6 +478,9 @@
   // invalidate the ordinals.
   modulePasses.addPass(IREE::VM::createOrdinalAllocationPass());
 
+  // C target specific passes
+  modulePasses.addPass(createConvertVMToEmitCPass());
+
   if (failed(passManager.run(moduleOp->getParentOfType<mlir::ModuleOp>()))) {
     return moduleOp.emitError() << "failed during transform passes";
   }
@@ -440,6 +510,11 @@
   mlir::emitc::CppEmitter emitter(output);
   mlir::emitc::CppEmitter::Scope scope(emitter);
 
+  // build struct definitions
+  if (failed(printStructDefinitions(moduleOp, emitter))) {
+    return failure();
+  }
+
   // translate functions
   for (auto funcOp : moduleOp.getOps<IREE::VM::FuncOp>()) {
     if (failed(translateFunctionToC(moduleOp, funcOp, emitter))) {
diff --git a/iree/compiler/Dialect/VM/Target/C/test/add.mlir b/iree/compiler/Dialect/VM/Target/C/test/add.mlir
index 26659b6..839aa60 100644
--- a/iree/compiler/Dialect/VM/Target/C/test/add.mlir
+++ b/iree/compiler/Dialect/VM/Target/C/test/add.mlir
@@ -2,7 +2,7 @@
 
 // CHECK: #include "iree/vm/ops.h"
 vm.module @add_module {
-  // CHECK: iree_status_t add_module_add_1_impl(int32_t v1, int32_t v2, int32_t *out0, int32_t *out1) {
+  // CHECK: iree_status_t add_module_add_1_impl(int32_t v1, int32_t v2, int32_t *out0, int32_t *out1, add_module_state_t* state) {
   vm.func @add_1(%arg0 : i32, %arg1 : i32) -> (i32, i32) {
     // CHECK-NEXT: int32_t v3 = vm_add_i32(v1, v2);
     %0 = vm.add.i32 %arg0, %arg1 : i32
diff --git a/iree/compiler/Dialect/VM/Target/C/test/calling_convention.mlir b/iree/compiler/Dialect/VM/Target/C/test/calling_convention.mlir
index 8869bf1..4c9b87a 100644
--- a/iree/compiler/Dialect/VM/Target/C/test/calling_convention.mlir
+++ b/iree/compiler/Dialect/VM/Target/C/test/calling_convention.mlir
@@ -2,19 +2,19 @@
 
 // CHECK: #include "iree/vm/ops.h"
 vm.module @calling_convention_test {
-  // CHECK: iree_status_t calling_convention_test_no_in_no_return_impl() {
+  // CHECK: iree_status_t calling_convention_test_no_in_no_return_impl(calling_convention_test_state_t* state) {
   vm.func @no_in_no_return() -> () {
     // CHECK-NEXT: return iree_ok_status();
     vm.return
   }
 
-  // CHECK: iree_status_t calling_convention_test_i32_in_no_return_impl(int32_t v1) {
+  // CHECK: iree_status_t calling_convention_test_i32_in_no_return_impl(int32_t v1, calling_convention_test_state_t* state) {
   vm.func @i32_in_no_return(%arg0 : i32) -> () {
     // CHECK-NEXT: return iree_ok_status();
     vm.return
   }
 
-  // CHECK: iree_status_t calling_convention_test_no_in_i32_return_impl(int32_t *out0) {
+  // CHECK: iree_status_t calling_convention_test_no_in_i32_return_impl(int32_t *out0, calling_convention_test_state_t* state) {
   vm.func @no_in_i32_return() -> (i32) {
     // CHECK-NEXT: int32_t v1 = vm_const_i32(32);
     %0 = vm.const.i32 32 : i32
@@ -23,7 +23,7 @@
     vm.return %0 : i32
   }
 
-  // CHECK: iree_status_t calling_convention_test_i32_in_i32_return_impl(int32_t v1, int32_t *out0) {
+  // CHECK: iree_status_t calling_convention_test_i32_in_i32_return_impl(int32_t v1, int32_t *out0, calling_convention_test_state_t* state) {
   vm.func @i32_in_i32_return(%arg0 : i32) -> (i32) {
     // CHECK-NEXT: int32_t v2 = vm_const_i32(32);
     %0 = vm.const.i32 32 : i32
diff --git a/iree/compiler/Dialect/VM/Target/C/test/global_ops.mlir b/iree/compiler/Dialect/VM/Target/C/test/global_ops.mlir
new file mode 100644
index 0000000..c357145
--- /dev/null
+++ b/iree/compiler/Dialect/VM/Target/C/test/global_ops.mlir
@@ -0,0 +1,37 @@
+// RUN: iree-translate -iree-vm-ir-to-c-module %s | IreeFileCheck %s
+
+vm.module @global_ops {
+  // check the generated state struct
+  // CHECK-LABEL: struct global_ops_state_s {
+  // CHECK-NEXT: iree_allocator_t allocator;
+  // CHECK-NEXT: uint8_t rwdata[8];
+  // CHECK-NEXT: };
+
+  vm.global.i32 @c42 42 : i32
+  vm.global.i32 @c107_mut mutable 107 : i32
+
+  vm.export @test_global_load_i32
+  // CHECK-LABEL: iree_status_t global_ops_test_global_load_i32_impl(
+  vm.func @test_global_load_i32() -> i32 {
+    // CHECK-NEXT: int32_t v1 = vm_global_load_i32(state->rwdata, 0);
+    %value = vm.global.load.i32 @c42 : i32
+    vm.return %value : i32
+  }
+
+  vm.export @test_global_store_i32
+  // CHECK-LABEL: iree_status_t global_ops_test_global_store_i32_impl(
+  vm.func @test_global_store_i32() -> i32 {
+    // CHECK-NEXT: int32_t v1 = vm_const_i32(17);
+    %c17 = vm.const.i32 17 : i32
+    // CHECK-NEXT: vm_global_store_i32(state->rwdata, 4, v1);
+    vm.global.store.i32 %c17, @c107_mut : i32
+    // CHECK-NEXT: int32_t v2 = vm_global_load_i32(state->rwdata, 4);
+    %value = vm.global.load.i32 @c107_mut : i32
+    vm.return %value : i32
+  }
+
+  // check state initialization inside the alloc_state function
+  // CHECK-LABEL: static iree_status_t global_ops_alloc_state(
+  // CHECK: vm_global_store_i32(state->rwdata, 0, 42);
+  // CHECK-NEXT: vm_global_store_i32(state->rwdata, 4, 107);
+}
diff --git a/iree/compiler/Dialect/VM/Transforms/CMakeLists.txt b/iree/compiler/Dialect/VM/Transforms/CMakeLists.txt
index 0a946fc..89fb23a 100644
--- a/iree/compiler/Dialect/VM/Transforms/CMakeLists.txt
+++ b/iree/compiler/Dialect/VM/Transforms/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/VM/Transforms/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/VM/Transforms/test/CMakeLists.txt b/iree/compiler/Dialect/VM/Transforms/test/CMakeLists.txt
index fcc538b..36060eb 100644
--- a/iree/compiler/Dialect/VM/Transforms/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/VM/Transforms/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/VM/Transforms/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/VMLA/CMakeLists.txt b/iree/compiler/Dialect/VMLA/CMakeLists.txt
index 28384d6..b45d105 100644
--- a/iree/compiler/Dialect/VMLA/CMakeLists.txt
+++ b/iree/compiler/Dialect/VMLA/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/VMLA/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_embed_data(
diff --git a/iree/compiler/Dialect/VMLA/Conversion/CMakeLists.txt b/iree/compiler/Dialect/VMLA/Conversion/CMakeLists.txt
index 52f1408..f354958 100644
--- a/iree/compiler/Dialect/VMLA/Conversion/CMakeLists.txt
+++ b/iree/compiler/Dialect/VMLA/Conversion/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/VMLA/Conversion/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/VMLA/Conversion/HALToVMLA/CMakeLists.txt b/iree/compiler/Dialect/VMLA/Conversion/HALToVMLA/CMakeLists.txt
index 2c97104..1379653 100644
--- a/iree/compiler/Dialect/VMLA/Conversion/HALToVMLA/CMakeLists.txt
+++ b/iree/compiler/Dialect/VMLA/Conversion/HALToVMLA/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/VMLA/Conversion/HALToVMLA/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/VMLA/Conversion/HALToVMLA/test/CMakeLists.txt b/iree/compiler/Dialect/VMLA/Conversion/HALToVMLA/test/CMakeLists.txt
index fcc538b..525a10b 100644
--- a/iree/compiler/Dialect/VMLA/Conversion/HALToVMLA/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/VMLA/Conversion/HALToVMLA/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/VMLA/Conversion/HALToVMLA/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/VMLA/Conversion/HLOToVMLA/CMakeLists.txt b/iree/compiler/Dialect/VMLA/Conversion/HLOToVMLA/CMakeLists.txt
index 506c86e..0be08be 100644
--- a/iree/compiler/Dialect/VMLA/Conversion/HLOToVMLA/CMakeLists.txt
+++ b/iree/compiler/Dialect/VMLA/Conversion/HLOToVMLA/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/VMLA/Conversion/HLOToVMLA/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/VMLA/Conversion/HLOToVMLA/test/CMakeLists.txt b/iree/compiler/Dialect/VMLA/Conversion/HLOToVMLA/test/CMakeLists.txt
index fcc538b..eee87da 100644
--- a/iree/compiler/Dialect/VMLA/Conversion/HLOToVMLA/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/VMLA/Conversion/HLOToVMLA/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/VMLA/Conversion/HLOToVMLA/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/VMLA/Conversion/StandardToVMLA/CMakeLists.txt b/iree/compiler/Dialect/VMLA/Conversion/StandardToVMLA/CMakeLists.txt
index 8874b50..93618c4 100644
--- a/iree/compiler/Dialect/VMLA/Conversion/StandardToVMLA/CMakeLists.txt
+++ b/iree/compiler/Dialect/VMLA/Conversion/StandardToVMLA/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/VMLA/Conversion/StandardToVMLA/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/VMLA/Conversion/StandardToVMLA/test/CMakeLists.txt b/iree/compiler/Dialect/VMLA/Conversion/StandardToVMLA/test/CMakeLists.txt
index fcc538b..81b798e 100644
--- a/iree/compiler/Dialect/VMLA/Conversion/StandardToVMLA/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/VMLA/Conversion/StandardToVMLA/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/VMLA/Conversion/StandardToVMLA/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/VMLA/Conversion/VMLAToVM/CMakeLists.txt b/iree/compiler/Dialect/VMLA/Conversion/VMLAToVM/CMakeLists.txt
index e90f8e3..b53410d 100644
--- a/iree/compiler/Dialect/VMLA/Conversion/VMLAToVM/CMakeLists.txt
+++ b/iree/compiler/Dialect/VMLA/Conversion/VMLAToVM/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/VMLA/Conversion/VMLAToVM/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/VMLA/Conversion/VMLAToVM/test/CMakeLists.txt b/iree/compiler/Dialect/VMLA/Conversion/VMLAToVM/test/CMakeLists.txt
index fcc538b..8db5239 100644
--- a/iree/compiler/Dialect/VMLA/Conversion/VMLAToVM/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/VMLA/Conversion/VMLAToVM/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/VMLA/Conversion/VMLAToVM/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/VMLA/IR/CMakeLists.txt b/iree/compiler/Dialect/VMLA/IR/CMakeLists.txt
index 52e689b..2e225a6 100644
--- a/iree/compiler/Dialect/VMLA/IR/CMakeLists.txt
+++ b/iree/compiler/Dialect/VMLA/IR/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/VMLA/IR/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_TD LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.td)
diff --git a/iree/compiler/Dialect/VMLA/IR/test/CMakeLists.txt b/iree/compiler/Dialect/VMLA/IR/test/CMakeLists.txt
index fcc538b..52bb333 100644
--- a/iree/compiler/Dialect/VMLA/IR/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/VMLA/IR/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/VMLA/IR/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/VMLA/Transforms/CMakeLists.txt b/iree/compiler/Dialect/VMLA/Transforms/CMakeLists.txt
index e0ebf15..d882ebf 100644
--- a/iree/compiler/Dialect/VMLA/Transforms/CMakeLists.txt
+++ b/iree/compiler/Dialect/VMLA/Transforms/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/VMLA/Transforms/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/VMLA/Transforms/test/CMakeLists.txt b/iree/compiler/Dialect/VMLA/Transforms/test/CMakeLists.txt
index fcc538b..61283ff 100644
--- a/iree/compiler/Dialect/VMLA/Transforms/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/VMLA/Transforms/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/VMLA/Transforms/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/Vulkan/CMakeLists.txt b/iree/compiler/Dialect/Vulkan/CMakeLists.txt
index 15e9263..364f90e 100644
--- a/iree/compiler/Dialect/Vulkan/CMakeLists.txt
+++ b/iree/compiler/Dialect/Vulkan/CMakeLists.txt
@@ -1,15 +1,3 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Vulkan/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
diff --git a/iree/compiler/Dialect/Vulkan/IR/CMakeLists.txt b/iree/compiler/Dialect/Vulkan/IR/CMakeLists.txt
index 2030807..3666907 100644
--- a/iree/compiler/Dialect/Vulkan/IR/CMakeLists.txt
+++ b/iree/compiler/Dialect/Vulkan/IR/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Vulkan/IR/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_TD LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.td)
diff --git a/iree/compiler/Dialect/Vulkan/IR/test/CMakeLists.txt b/iree/compiler/Dialect/Vulkan/IR/test/CMakeLists.txt
index fcc538b..01edd40 100644
--- a/iree/compiler/Dialect/Vulkan/IR/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Vulkan/IR/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Vulkan/IR/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Dialect/Vulkan/Utils/CMakeLists.txt b/iree/compiler/Dialect/Vulkan/Utils/CMakeLists.txt
index 1588a39..4f56b79 100644
--- a/iree/compiler/Dialect/Vulkan/Utils/CMakeLists.txt
+++ b/iree/compiler/Dialect/Vulkan/Utils/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Vulkan/Utils/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/compiler/Dialect/Vulkan/Utils/test/CMakeLists.txt b/iree/compiler/Dialect/Vulkan/Utils/test/CMakeLists.txt
index a4f0d04..dc64372 100644
--- a/iree/compiler/Dialect/Vulkan/Utils/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/Vulkan/Utils/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Dialect/Vulkan/Utils/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 if(NOT "${IREE_TARGET_BACKEND_VULKAN-SPIRV}")
   return()
 endif()
diff --git a/iree/compiler/Translation/test/CMakeLists.txt b/iree/compiler/Translation/test/CMakeLists.txt
index a936b24..ffd8244 100644
--- a/iree/compiler/Translation/test/CMakeLists.txt
+++ b/iree/compiler/Translation/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Translation/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/compiler/Utils/CMakeLists.txt b/iree/compiler/Utils/CMakeLists.txt
index 6db54f5..ef3e1ff 100644
--- a/iree/compiler/Utils/CMakeLists.txt
+++ b/iree/compiler/Utils/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/compiler/Utils/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/hal/CMakeLists.txt b/iree/hal/CMakeLists.txt
index 140e88a..01713ce 100644
--- a/iree/hal/CMakeLists.txt
+++ b/iree/hal/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/hal/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/hal/cts/CMakeLists.txt b/iree/hal/cts/CMakeLists.txt
index 9287b3b..e00d330 100644
--- a/iree/hal/cts/CMakeLists.txt
+++ b/iree/hal/cts/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/hal/cts/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/hal/cts/command_buffer_test.cc b/iree/hal/cts/command_buffer_test.cc
index b4ee8f5..1c4ea00 100644
--- a/iree/hal/cts/command_buffer_test.cc
+++ b/iree/hal/cts/command_buffer_test.cc
@@ -33,6 +33,9 @@
 using ::testing::ContainerEq;
 
 class CommandBufferTest : public CtsTestBase {
+ public:
+  CommandBufferTest() { declareUnimplementedDriver("cuda"); }
+
  protected:
   static constexpr iree_device_size_t kBufferSize = 4096;
 };
@@ -96,26 +99,28 @@
   // Fill the device buffer with segments of different values so that we can
   // test both fill and offset/size.
   uint8_t val1 = 0x07;
-  iree_hal_command_buffer_fill_buffer(
+  IREE_ASSERT_OK(iree_hal_command_buffer_fill_buffer(
       command_buffer, device_buffer,
       /*target_offset=*/0, /*length=*/kBufferSize / 4, /*pattern=*/&val1,
-      /*pattern_length=*/sizeof(val1));
+      /*pattern_length=*/sizeof(val1)));
   std::memset(reference_buffer.data(), val1, kBufferSize / 4);
 
   uint8_t val2 = 0xbe;
-  iree_hal_command_buffer_fill_buffer(command_buffer, device_buffer,
-                                      /*target_offset=*/kBufferSize / 4,
-                                      /*length=*/kBufferSize / 4,
-                                      /*pattern=*/&val2,
-                                      /*pattern_length=*/sizeof(val2));
+  IREE_ASSERT_OK(
+      iree_hal_command_buffer_fill_buffer(command_buffer, device_buffer,
+                                          /*target_offset=*/kBufferSize / 4,
+                                          /*length=*/kBufferSize / 4,
+                                          /*pattern=*/&val2,
+                                          /*pattern_length=*/sizeof(val2)));
   std::memset(reference_buffer.data() + kBufferSize / 4, val2, kBufferSize / 4);
 
   uint8_t val3 = 0x54;
-  iree_hal_command_buffer_fill_buffer(command_buffer, device_buffer,
-                                      /*target_offset=*/kBufferSize / 2,
-                                      /*length=*/kBufferSize / 2,
-                                      /*pattern=*/&val3,
-                                      /*pattern_length=*/sizeof(val3));
+  IREE_ASSERT_OK(
+      iree_hal_command_buffer_fill_buffer(command_buffer, device_buffer,
+                                          /*target_offset=*/kBufferSize / 2,
+                                          /*length=*/kBufferSize / 2,
+                                          /*pattern=*/&val3,
+                                          /*pattern_length=*/sizeof(val3)));
   std::memset(reference_buffer.data() + kBufferSize / 2, val3, kBufferSize / 2);
 
   IREE_ASSERT_OK(iree_hal_command_buffer_end(command_buffer));
diff --git a/iree/hal/cts/cts_test_base.h b/iree/hal/cts/cts_test_base.h
index 09875ad..cf7d58c 100644
--- a/iree/hal/cts/cts_test_base.h
+++ b/iree/hal/cts/cts_test_base.h
@@ -33,6 +33,12 @@
  protected:
   virtual void SetUp() {
     const std::string& driver_name = GetParam();
+    if (driver_block_list_.find(driver_name) != driver_block_list_.end()) {
+      IREE_LOG(WARNING)
+          << "Skipping test as driver is explicitly disabled for this test";
+      GTEST_SKIP();
+      return;
+    }
 
     // Get driver with the given name and create its default device.
     // Skip drivers that are (gracefully) unavailable, fail if creation fails.
@@ -122,6 +128,14 @@
   iree_hal_driver_t* driver_ = nullptr;
   iree_hal_device_t* device_ = nullptr;
   iree_hal_allocator_t* device_allocator_ = nullptr;
+  // Allow skipping tests for driver under development.
+  void declareUnimplementedDriver(const std::string& driver_name) {
+    driver_block_list_.insert(driver_name);
+  }
+  // Allow skipping tests for unsupported features.
+  void declareUnavailableDriver(const std::string& driver_name) {
+    driver_block_list_.insert(driver_name);
+  }
 
  private:
   // Gets a HAL driver with the provided name, if available.
@@ -149,6 +163,7 @@
     }
     return status;
   }
+  std::set<std::string> driver_block_list_;
 };
 
 struct GenerateTestName {
diff --git a/iree/hal/cts/descriptor_set_layout_test.cc b/iree/hal/cts/descriptor_set_layout_test.cc
index 14dd2b5..3b7df35 100644
--- a/iree/hal/cts/descriptor_set_layout_test.cc
+++ b/iree/hal/cts/descriptor_set_layout_test.cc
@@ -21,7 +21,10 @@
 namespace hal {
 namespace cts {
 
-class DescriptorSetLayoutTest : public CtsTestBase {};
+class DescriptorSetLayoutTest : public CtsTestBase {
+ public:
+  DescriptorSetLayoutTest() { declareUnimplementedDriver("cuda"); }
+};
 
 // Note: bindingCount == 0 is valid in VkDescriptorSetLayoutCreateInfo:
 // https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkDescriptorSetLayoutCreateInfo.html
diff --git a/iree/hal/cts/event_test.cc b/iree/hal/cts/event_test.cc
index b728277..083be3a 100644
--- a/iree/hal/cts/event_test.cc
+++ b/iree/hal/cts/event_test.cc
@@ -21,7 +21,10 @@
 namespace hal {
 namespace cts {
 
-class EventTest : public CtsTestBase {};
+class EventTest : public CtsTestBase {
+ public:
+  EventTest() { declareUnimplementedDriver("cuda"); }
+};
 
 TEST_P(EventTest, Create) {
   iree_hal_event_t* event;
diff --git a/iree/hal/cts/executable_layout_test.cc b/iree/hal/cts/executable_layout_test.cc
index 1df73bd..f4a3374 100644
--- a/iree/hal/cts/executable_layout_test.cc
+++ b/iree/hal/cts/executable_layout_test.cc
@@ -21,7 +21,10 @@
 namespace hal {
 namespace cts {
 
-class ExecutableLayoutTest : public CtsTestBase {};
+class ExecutableLayoutTest : public CtsTestBase {
+ public:
+  ExecutableLayoutTest() { declareUnimplementedDriver("cuda"); }
+};
 
 TEST_P(ExecutableLayoutTest, CreateWithNoLayouts) {
   iree_hal_executable_layout_t* executable_layout;
diff --git a/iree/hal/cts/semaphore_submission_test.cc b/iree/hal/cts/semaphore_submission_test.cc
index 5f9c529..5cec41f 100644
--- a/iree/hal/cts/semaphore_submission_test.cc
+++ b/iree/hal/cts/semaphore_submission_test.cc
@@ -20,7 +20,11 @@
 namespace hal {
 namespace cts {
 
-class SemaphoreSubmissionTest : public CtsTestBase {};
+class SemaphoreSubmissionTest : public CtsTestBase {
+ public:
+  // Disable cuda backend for this test as semaphores are not implemented yet.
+  SemaphoreSubmissionTest() { declareUnavailableDriver("cuda"); }
+};
 
 TEST_P(SemaphoreSubmissionTest, SubmitWithNoCommandBuffers) {
   // No waits, one signal which we immediately wait on after submit.
diff --git a/iree/hal/cts/semaphore_test.cc b/iree/hal/cts/semaphore_test.cc
index c774241..ac02fca 100644
--- a/iree/hal/cts/semaphore_test.cc
+++ b/iree/hal/cts/semaphore_test.cc
@@ -22,7 +22,11 @@
 namespace hal {
 namespace cts {
 
-class SemaphoreTest : public CtsTestBase {};
+class SemaphoreTest : public CtsTestBase {
+ public:
+  // Disable cuda backend for this test as semaphores are not implemented yet.
+  SemaphoreTest() { declareUnavailableDriver("cuda"); }
+};
 
 // Tests that a semaphore that is unused properly cleans itself up.
 TEST_P(SemaphoreTest, NoOp) {
diff --git a/iree/hal/cuda/BUILD b/iree/hal/cuda/BUILD
index 18fc69b..831fbae 100644
--- a/iree/hal/cuda/BUILD
+++ b/iree/hal/cuda/BUILD
@@ -29,6 +29,39 @@
 )
 
 cc_library(
+    name = "cuda",
+    srcs = [
+        "api.h",
+        "context_wrapper.h",
+        "cuda_allocator.c",
+        "cuda_allocator.h",
+        "cuda_buffer.c",
+        "cuda_buffer.h",
+        "cuda_device.c",
+        "cuda_device.h",
+        "cuda_driver.c",
+        "status_util.c",
+        "status_util.h",
+    ],
+    hdrs = [
+        "api.h",
+    ],
+    visibility = ["//visibility:public"],
+    deps = [
+        ":dynamic_symbols",
+        "//iree/base:api",
+        "//iree/base:core_headers",
+        "//iree/base:flatcc",
+        "//iree/base:logging",
+        "//iree/base:status",
+        "//iree/base:synchronization",
+        "//iree/base:tracing",
+        "//iree/base/internal",
+        "//iree/hal:api",
+    ],
+)
+
+cc_library(
     name = "dynamic_symbols",
     srcs = [
         "cuda_headers.h",
diff --git a/iree/hal/cuda/CMakeLists.txt b/iree/hal/cuda/CMakeLists.txt
index cc7667f..6df72d1 100644
--- a/iree/hal/cuda/CMakeLists.txt
+++ b/iree/hal/cuda/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2021 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/hal/cuda/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 if(NOT ${IREE_HAL_DRIVER_CUDA})
   return()
 endif()
@@ -20,6 +8,37 @@
 
 iree_cc_library(
   NAME
+    cuda
+  HDRS
+    "api.h"
+  SRCS
+    "api.h"
+    "context_wrapper.h"
+    "cuda_allocator.c"
+    "cuda_allocator.h"
+    "cuda_buffer.c"
+    "cuda_buffer.h"
+    "cuda_device.c"
+    "cuda_device.h"
+    "cuda_driver.c"
+    "status_util.c"
+    "status_util.h"
+  DEPS
+    ::dynamic_symbols
+    iree::base::api
+    iree::base::core_headers
+    iree::base::flatcc
+    iree::base::internal
+    iree::base::logging
+    iree::base::status
+    iree::base::synchronization
+    iree::base::tracing
+    iree::hal::api
+  PUBLIC
+)
+
+iree_cc_library(
+  NAME
     dynamic_symbols
   HDRS
     "dynamic_symbols.h"
diff --git a/iree/hal/cuda/api.h b/iree/hal/cuda/api.h
new file mode 100644
index 0000000..3c219b7
--- /dev/null
+++ b/iree/hal/cuda/api.h
@@ -0,0 +1,55 @@
+// Copyright 2021 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// See iree/base/api.h for documentation on the API conventions used.
+
+#ifndef IREE_HAL_CUDA_API_H_
+#define IREE_HAL_CUDA_API_H_
+
+#include "iree/base/api.h"
+#include "iree/hal/api.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif  // __cplusplus
+
+//===----------------------------------------------------------------------===//
+// iree_hal_cuda_driver_t
+//===----------------------------------------------------------------------===//
+
+// CUDA driver creation options.
+typedef struct {
+  // Index of the default CUDA device to use within the list of available
+  // devices.
+  int default_device_index;
+} iree_hal_cuda_driver_options_t;
+
+IREE_API_EXPORT void IREE_API_CALL iree_hal_cuda_driver_options_initialize(
+    iree_hal_cuda_driver_options_t* out_options);
+
+// Creates a CUDA HAL driver that manage its own CUcontext.
+//
+// |out_driver| must be released by the caller (see |iree_hal_driver_release|).
+IREE_API_EXPORT iree_status_t IREE_API_CALL iree_hal_cuda_driver_create(
+    iree_string_view_t identifier,
+    const iree_hal_cuda_driver_options_t* options,
+    iree_allocator_t host_allocator, iree_hal_driver_t** out_driver);
+
+// TODO(thomasraoux): Support importing a CUcontext from app.
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif  // __cplusplus
+
+#endif  // IREE_HAL_CUDA_API_H_
diff --git a/iree/hal/cuda/context_wrapper.h b/iree/hal/cuda/context_wrapper.h
new file mode 100644
index 0000000..304657d
--- /dev/null
+++ b/iree/hal/cuda/context_wrapper.h
@@ -0,0 +1,30 @@
+// Copyright 2021 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef IREE_HAL_CUDA_CONTEXT_WRAPPER_H_
+#define IREE_HAL_CUDA_CONTEXT_WRAPPER_H_
+
+#include "iree/hal/api.h"
+#include "iree/hal/cuda/cuda_headers.h"
+#include "iree/hal/cuda/dynamic_symbols.h"
+
+// Structure to wrap all objects constant within a context. This makes it
+// simpler to pass it to the different objects and saves memory.
+typedef struct {
+  CUcontext cu_context;
+  iree_allocator_t host_allocator;
+  iree_hal_cuda_dynamic_symbols_t* syms;
+} iree_hal_cuda_context_wrapper_t;
+
+#endif  // IREE_HAL_CUDA_CONTEXT_WRAPPER_H_
diff --git a/iree/hal/cuda/cuda_allocator.c b/iree/hal/cuda/cuda_allocator.c
new file mode 100644
index 0000000..9995f2b
--- /dev/null
+++ b/iree/hal/cuda/cuda_allocator.c
@@ -0,0 +1,175 @@
+// Copyright 2021 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations ufnder the License.
+
+#include "iree/hal/cuda/cuda_allocator.h"
+
+#include "iree/base/tracing.h"
+#include "iree/hal/cuda/cuda_buffer.h"
+#include "iree/hal/cuda/status_util.h"
+
+typedef struct iree_hal_cuda_allocator_s {
+  iree_hal_resource_t resource;
+  iree_hal_cuda_context_wrapper_t* context;
+} iree_hal_cuda_allocator_t;
+
+extern const iree_hal_allocator_vtable_t iree_hal_cuda_allocator_vtable;
+
+static iree_hal_cuda_allocator_t* iree_hal_cuda_allocator_cast(
+    iree_hal_allocator_t* base_value) {
+  IREE_HAL_ASSERT_TYPE(base_value, &iree_hal_cuda_allocator_vtable);
+  return (iree_hal_cuda_allocator_t*)base_value;
+}
+
+iree_status_t iree_hal_cuda_allocator_create(
+    iree_hal_cuda_context_wrapper_t* context,
+    iree_hal_allocator_t** out_allocator) {
+  IREE_ASSERT_ARGUMENT(context);
+  IREE_TRACE_ZONE_BEGIN(z0);
+  iree_hal_cuda_allocator_t* allocator = NULL;
+  iree_status_t status = iree_allocator_malloc(
+      context->host_allocator, sizeof(*allocator), (void**)&allocator);
+  if (iree_status_is_ok(status)) {
+    iree_hal_resource_initialize(&iree_hal_cuda_allocator_vtable,
+                                 &allocator->resource);
+    allocator->context = context;
+    *out_allocator = (iree_hal_allocator_t*)allocator;
+  }
+
+  IREE_TRACE_ZONE_END(z0);
+  return status;
+}
+
+static void iree_hal_cuda_allocator_destroy(
+    iree_hal_allocator_t* base_allocator) {
+  iree_hal_cuda_allocator_t* allocator =
+      iree_hal_cuda_allocator_cast(base_allocator);
+  iree_allocator_t host_allocator = allocator->context->host_allocator;
+  IREE_TRACE_ZONE_BEGIN(z0);
+
+  iree_allocator_free(host_allocator, allocator);
+
+  IREE_TRACE_ZONE_END(z0);
+}
+
+static iree_allocator_t iree_hal_cuda_allocator_host_allocator(
+    const iree_hal_allocator_t* base_allocator) {
+  iree_hal_cuda_allocator_t* allocator =
+      (iree_hal_cuda_allocator_t*)base_allocator;
+  return allocator->context->host_allocator;
+}
+
+static iree_hal_buffer_compatibility_t
+iree_hal_cuda_allocator_query_buffer_compatibility(
+    iree_hal_allocator_t* base_allocator, iree_hal_memory_type_t memory_type,
+    iree_hal_buffer_usage_t allowed_usage,
+    iree_hal_buffer_usage_t intended_usage,
+    iree_device_size_t allocation_size) {
+  // TODO(benvanik): check to ensure the allocator can serve the memory type.
+
+  // Disallow usage not permitted by the buffer itself. Since we then use this
+  // to determine compatibility below we'll naturally set the right compat flags
+  // based on what's both allowed and intended.
+  intended_usage &= allowed_usage;
+
+  // All buffers can be allocated on the heap.
+  iree_hal_buffer_compatibility_t compatibility =
+      IREE_HAL_BUFFER_COMPATIBILITY_ALLOCATABLE;
+
+  // Buffers can only be used on the queue if they are device visible.
+  if (iree_all_bits_set(memory_type, IREE_HAL_MEMORY_TYPE_DEVICE_VISIBLE)) {
+    if (iree_all_bits_set(intended_usage, IREE_HAL_BUFFER_USAGE_TRANSFER)) {
+      compatibility |= IREE_HAL_BUFFER_COMPATIBILITY_QUEUE_TRANSFER;
+    }
+    if (iree_all_bits_set(intended_usage, IREE_HAL_BUFFER_USAGE_DISPATCH)) {
+      compatibility |= IREE_HAL_BUFFER_COMPATIBILITY_QUEUE_DISPATCH;
+    }
+  }
+
+  return compatibility;
+}
+
+static iree_status_t iree_hal_cuda_allocator_allocate_buffer(
+    iree_hal_allocator_t* base_allocator, iree_hal_memory_type_t memory_type,
+    iree_hal_buffer_usage_t allowed_usage, iree_host_size_t allocation_size,
+    iree_hal_buffer_t** out_buffer) {
+  iree_hal_cuda_allocator_t* allocator =
+      iree_hal_cuda_allocator_cast(base_allocator);
+  // Guard against the corner case where the requested buffer size is 0. The
+  // application is unlikely to do anything when requesting a 0-byte buffer; but
+  // it can happen in real world use cases. So we should at least not crash.
+  if (allocation_size == 0) allocation_size = 4;
+  iree_status_t status;
+  void* host_ptr = NULL;
+  CUdeviceptr device_ptr = 0;
+  if (iree_all_bits_set(memory_type, IREE_HAL_MEMORY_TYPE_HOST_VISIBLE)) {
+    unsigned int flags = CU_MEMHOSTALLOC_DEVICEMAP;
+    if (!iree_all_bits_set(memory_type, IREE_HAL_MEMORY_TYPE_HOST_CACHED)) {
+      flags |= CU_MEMHOSTALLOC_WRITECOMBINED;
+    }
+    status =
+        CU_RESULT_TO_STATUS(allocator->context->syms,
+                            cuMemHostAlloc(&host_ptr, allocation_size, flags));
+    if (iree_status_is_ok(status)) {
+      status = CU_RESULT_TO_STATUS(
+          allocator->context->syms,
+          cuMemHostGetDevicePointer(&device_ptr, host_ptr, /*flags=*/0));
+    }
+  } else {
+    status = CU_RESULT_TO_STATUS(allocator->context->syms,
+                                 cuMemAlloc(&device_ptr, allocation_size));
+  }
+
+  if (iree_status_is_ok(status)) {
+    status = iree_hal_cuda_buffer_wrap(
+        (iree_hal_allocator_t*)allocator, memory_type,
+        IREE_HAL_MEMORY_ACCESS_ALL, allowed_usage, allocation_size,
+        /*byte_offset=*/0,
+        /*byte_length=*/allocation_size, device_ptr, host_ptr, out_buffer);
+  }
+  if (!iree_status_is_ok(status)) {
+    iree_hal_cuda_allocator_free(base_allocator, device_ptr, host_ptr,
+                                 memory_type);
+  }
+  return status;
+}
+
+void iree_hal_cuda_allocator_free(iree_hal_allocator_t* base_allocator,
+                                  CUdeviceptr device_ptr, void* host_ptr,
+                                  iree_hal_memory_type_t memory_type) {
+  iree_hal_cuda_allocator_t* allocator =
+      iree_hal_cuda_allocator_cast(base_allocator);
+  if (iree_all_bits_set(memory_type, IREE_HAL_MEMORY_TYPE_HOST_VISIBLE)) {
+    CUDA_IGNORE_ERROR(allocator->context->syms, cuMemFreeHost(host_ptr));
+  } else {
+    CUDA_IGNORE_ERROR(allocator->context->syms, cuMemFree(device_ptr));
+  }
+}
+
+static iree_status_t iree_hal_cuda_allocator_wrap_buffer(
+    iree_hal_allocator_t* base_allocator, iree_hal_memory_type_t memory_type,
+    iree_hal_memory_access_t allowed_access,
+    iree_hal_buffer_usage_t allowed_usage, iree_byte_span_t data,
+    iree_allocator_t data_allocator, iree_hal_buffer_t** out_buffer) {
+  return iree_make_status(IREE_STATUS_UNAVAILABLE,
+                          "wrapping of external buffers not supported");
+}
+
+const iree_hal_allocator_vtable_t iree_hal_cuda_allocator_vtable = {
+    .destroy = iree_hal_cuda_allocator_destroy,
+    .host_allocator = iree_hal_cuda_allocator_host_allocator,
+    .query_buffer_compatibility =
+        iree_hal_cuda_allocator_query_buffer_compatibility,
+    .allocate_buffer = iree_hal_cuda_allocator_allocate_buffer,
+    .wrap_buffer = iree_hal_cuda_allocator_wrap_buffer,
+};
diff --git a/iree/hal/cuda/cuda_allocator.h b/iree/hal/cuda/cuda_allocator.h
new file mode 100644
index 0000000..fcc015b
--- /dev/null
+++ b/iree/hal/cuda/cuda_allocator.h
@@ -0,0 +1,40 @@
+// Copyright 2021 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef IREE_HAL_CUDA_ALLOCATOR_H_
+#define IREE_HAL_CUDA_ALLOCATOR_H_
+
+#include "iree/hal/api.h"
+#include "iree/hal/cuda/context_wrapper.h"
+#include "iree/hal/cuda/status_util.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif  // __cplusplus
+
+// Create a cuda allocator.
+iree_status_t iree_hal_cuda_allocator_create(
+    iree_hal_cuda_context_wrapper_t* context,
+    iree_hal_allocator_t** out_allocator);
+
+// Free an allocation represent by the given device or host pointer.
+void iree_hal_cuda_allocator_free(iree_hal_allocator_t* allocator,
+                                  CUdeviceptr device_ptr, void* host_ptr,
+                                  iree_hal_memory_type_t memory_type);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif  // __cplusplus
+
+#endif  // IREE_HAL_CUDA_ALLOCATOR_H_
diff --git a/iree/hal/cuda/cuda_buffer.c b/iree/hal/cuda/cuda_buffer.c
new file mode 100644
index 0000000..55a2115
--- /dev/null
+++ b/iree/hal/cuda/cuda_buffer.c
@@ -0,0 +1,141 @@
+// Copyright 2021 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "iree/hal/cuda/cuda_buffer.h"
+
+#include "iree/base/tracing.h"
+#include "iree/hal/cuda/cuda_allocator.h"
+#include "iree/hal/cuda/status_util.h"
+
+typedef struct iree_hal_cuda_buffer_s {
+  iree_hal_buffer_t base;
+  void* host_ptr;
+  CUdeviceptr device_ptr;
+} iree_hal_cuda_buffer_t;
+
+extern const iree_hal_buffer_vtable_t iree_hal_cuda_buffer_vtable;
+
+static iree_hal_cuda_buffer_t* iree_hal_cuda_buffer_cast(
+    iree_hal_buffer_t* base_value) {
+  IREE_HAL_ASSERT_TYPE(base_value, &iree_hal_cuda_buffer_vtable);
+  return (iree_hal_cuda_buffer_t*)base_value;
+}
+
+iree_status_t iree_hal_cuda_buffer_wrap(
+    iree_hal_allocator_t* allocator, iree_hal_memory_type_t memory_type,
+    iree_hal_memory_access_t allowed_access,
+    iree_hal_buffer_usage_t allowed_usage, iree_device_size_t allocation_size,
+    iree_device_size_t byte_offset, iree_device_size_t byte_length,
+    CUdeviceptr device_ptr, void* host_ptr, iree_hal_buffer_t** out_buffer) {
+  IREE_ASSERT_ARGUMENT(allocator);
+  IREE_ASSERT_ARGUMENT(out_buffer);
+  IREE_TRACE_ZONE_BEGIN(z0);
+
+  iree_hal_cuda_buffer_t* buffer = NULL;
+  iree_status_t status =
+      iree_allocator_malloc(iree_hal_allocator_host_allocator(allocator),
+                            sizeof(*buffer), (void**)&buffer);
+  if (iree_status_is_ok(status)) {
+    iree_hal_resource_initialize(&iree_hal_cuda_buffer_vtable,
+                                 &buffer->base.resource);
+    buffer->base.allocator = allocator;
+    buffer->base.allocated_buffer = &buffer->base;
+    buffer->base.allocation_size = allocation_size;
+    buffer->base.byte_offset = byte_offset;
+    buffer->base.byte_length = byte_length;
+    buffer->base.memory_type = memory_type;
+    buffer->base.allowed_access = allowed_access;
+    buffer->base.allowed_usage = allowed_usage;
+    buffer->host_ptr = host_ptr;
+    buffer->device_ptr = device_ptr;
+    *out_buffer = &buffer->base;
+  }
+
+  IREE_TRACE_ZONE_END(z0);
+  return iree_ok_status();
+}
+
+static void iree_hal_cuda_buffer_destroy(iree_hal_buffer_t* base_buffer) {
+  iree_hal_cuda_buffer_t* buffer = iree_hal_cuda_buffer_cast(base_buffer);
+  iree_allocator_t host_allocator =
+      iree_hal_allocator_host_allocator(iree_hal_buffer_allocator(base_buffer));
+  IREE_TRACE_ZONE_BEGIN(z0);
+
+  iree_hal_cuda_allocator_free(buffer->base.allocator, buffer->device_ptr,
+                               buffer->host_ptr, buffer->base.memory_type);
+  iree_allocator_free(host_allocator, buffer);
+
+  IREE_TRACE_ZONE_END(z0);
+}
+
+static iree_status_t iree_hal_cuda_buffer_map_range(
+    iree_hal_buffer_t* base_buffer, iree_hal_mapping_mode_t mapping_mode,
+    iree_hal_memory_access_t memory_access,
+    iree_device_size_t local_byte_offset, iree_device_size_t local_byte_length,
+    void** out_data_ptr) {
+  iree_hal_cuda_buffer_t* buffer = iree_hal_cuda_buffer_cast(base_buffer);
+
+  if (!iree_all_bits_set(buffer->base.memory_type,
+                         IREE_HAL_MEMORY_TYPE_HOST_VISIBLE)) {
+    return iree_make_status(IREE_STATUS_INTERNAL,
+                            "trying to map memory not host visible");
+  }
+
+  uint8_t* data_ptr = (uint8_t*)(buffer->host_ptr) + local_byte_offset;
+  // If we mapped for discard scribble over the bytes. This is not a mandated
+  // behavior but it will make debugging issues easier. Alternatively for
+  // heap buffers we could reallocate them such that ASAN yells, but that
+  // would only work if the entire buffer was discarded.
+#ifndef NDEBUG
+  if (iree_any_bit_set(memory_access, IREE_HAL_MEMORY_ACCESS_DISCARD)) {
+    memset(data_ptr + local_byte_offset, 0xCD, local_byte_length);
+  }
+#endif  // !NDEBUG
+  *out_data_ptr = data_ptr;
+  return iree_ok_status();
+}
+
+static void iree_hal_cuda_buffer_unmap_range(
+    iree_hal_buffer_t* base_buffer, iree_device_size_t local_byte_offset,
+    iree_device_size_t local_byte_length, void* data_ptr) {
+  // nothing to do.
+}
+
+static iree_status_t iree_hal_cuda_buffer_invalidate_range(
+    iree_hal_buffer_t* base_buffer, iree_device_size_t local_byte_offset,
+    iree_device_size_t local_byte_length) {
+  // Nothing to do.
+  return iree_ok_status();
+}
+
+static iree_status_t iree_hal_cuda_buffer_flush_range(
+    iree_hal_buffer_t* base_buffer, iree_device_size_t local_byte_offset,
+    iree_device_size_t local_byte_length) {
+  // Nothing to do.
+  return iree_ok_status();
+}
+
+CUdeviceptr iree_hal_cuda_buffer_device_pointer(
+    iree_hal_buffer_t* base_buffer) {
+  iree_hal_cuda_buffer_t* buffer = iree_hal_cuda_buffer_cast(base_buffer);
+  return buffer->device_ptr;
+}
+
+const iree_hal_buffer_vtable_t iree_hal_cuda_buffer_vtable = {
+    .destroy = iree_hal_cuda_buffer_destroy,
+    .map_range = iree_hal_cuda_buffer_map_range,
+    .unmap_range = iree_hal_cuda_buffer_unmap_range,
+    .invalidate_range = iree_hal_cuda_buffer_invalidate_range,
+    .flush_range = iree_hal_cuda_buffer_flush_range,
+};
diff --git a/iree/hal/cuda/cuda_buffer.h b/iree/hal/cuda/cuda_buffer.h
new file mode 100644
index 0000000..b9dcd9f
--- /dev/null
+++ b/iree/hal/cuda/cuda_buffer.h
@@ -0,0 +1,42 @@
+// Copyright 2021 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef IREE_HAL_CUDA_BUFFER_H_
+#define IREE_HAL_CUDA_BUFFER_H_
+
+#include "iree/hal/api.h"
+#include "iree/hal/cuda/cuda_headers.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif  // __cplusplus
+
+// Wraps a cuda allocation in an iree_hal_buffer_t.
+iree_status_t iree_hal_cuda_buffer_wrap(
+    iree_hal_allocator_t* allocator, iree_hal_memory_type_t memory_type,
+    iree_hal_memory_access_t allowed_access,
+    iree_hal_buffer_usage_t allowed_usage, iree_device_size_t allocation_size,
+    iree_device_size_t byte_offset, iree_device_size_t byte_length,
+    CUdeviceptr device_ptr, void* host_ptr, iree_hal_buffer_t** out_buffer);
+
+// Returns the cuda base pointer for the given |buffer|.
+// This is the entire allocated_buffer and must be offset by the buffer
+// byte_offset and byte_length when used.
+CUdeviceptr iree_hal_cuda_buffer_device_pointer(iree_hal_buffer_t* buffer);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif  // __cplusplus
+
+#endif  // IREE_HAL_CUDA_BUFFER_H_
diff --git a/iree/hal/cuda/cuda_device.c b/iree/hal/cuda/cuda_device.c
new file mode 100644
index 0000000..0430fe8
--- /dev/null
+++ b/iree/hal/cuda/cuda_device.c
@@ -0,0 +1,260 @@
+// Copyright 2021 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "iree/hal/cuda/cuda_device.h"
+
+#include "iree/base/status.h"
+#include "iree/base/tracing.h"
+#include "iree/hal/cuda/api.h"
+#include "iree/hal/cuda/cuda_allocator.h"
+#include "iree/hal/cuda/dynamic_symbols.h"
+#include "iree/hal/cuda/status_util.h"
+
+//===----------------------------------------------------------------------===//
+// iree_hal_cuda_device_t
+//===----------------------------------------------------------------------===//
+
+typedef struct {
+  iree_hal_resource_t resource;
+  iree_string_view_t identifier;
+
+  // Optional driver that owns the CUDA symbols. We retain it for our lifetime
+  // to ensure the symbols remains valid.
+  iree_hal_driver_t* driver;
+
+  CUdevice device;
+
+  // TODO: support multiple streams.
+  CUstream stream;
+  iree_hal_cuda_context_wrapper_t context_wrapper;
+  iree_hal_allocator_t* device_allocator;
+
+} iree_hal_cuda_device_t;
+
+extern const iree_hal_device_vtable_t iree_hal_cuda_device_vtable;
+
+static iree_hal_cuda_device_t* iree_hal_cuda_device_cast(
+    iree_hal_device_t* base_value) {
+  IREE_HAL_ASSERT_TYPE(base_value, &iree_hal_cuda_device_vtable);
+  return (iree_hal_cuda_device_t*)base_value;
+}
+
+static void iree_hal_cuda_device_destroy(iree_hal_device_t* base_device) {
+  iree_hal_cuda_device_t* device = iree_hal_cuda_device_cast(base_device);
+  iree_allocator_t host_allocator = iree_hal_device_host_allocator(base_device);
+  IREE_TRACE_ZONE_BEGIN(z0);
+
+  // There should be no more buffers live that use the allocator.
+  iree_hal_allocator_release(device->device_allocator);
+  CUDA_IGNORE_ERROR(device->context_wrapper.syms,
+                    cuStreamDestroy(device->stream));
+
+  // Finally, destroy the device.
+  iree_hal_driver_release(device->driver);
+
+  iree_allocator_free(host_allocator, device);
+
+  IREE_TRACE_ZONE_END(z0);
+}
+
+static iree_status_t iree_hal_cuda_device_create_internal(
+    iree_hal_driver_t* driver, iree_string_view_t identifier,
+    CUdevice cu_device, CUstream stream, CUcontext context,
+    iree_hal_cuda_dynamic_symbols_t* syms, iree_allocator_t host_allocator,
+    iree_hal_device_t** out_device) {
+  iree_hal_cuda_device_t* device = NULL;
+  iree_host_size_t total_size = sizeof(*device) + identifier.size;
+  IREE_RETURN_IF_ERROR(
+      iree_allocator_malloc(host_allocator, total_size, (void**)&device));
+  memset(device, 0, total_size);
+  iree_hal_resource_initialize(&iree_hal_cuda_device_vtable, &device->resource);
+  device->driver = driver;
+  iree_hal_driver_retain(device->driver);
+  uint8_t* buffer_ptr = (uint8_t*)device + sizeof(*device);
+  buffer_ptr += iree_string_view_append_to_buffer(
+      identifier, &device->identifier, (char*)buffer_ptr);
+  device->device = cu_device;
+  device->stream = stream;
+  device->context_wrapper.cu_context = context;
+  device->context_wrapper.host_allocator = host_allocator;
+  device->context_wrapper.syms = syms;
+  iree_status_t status = iree_hal_cuda_allocator_create(
+      &device->context_wrapper, &device->device_allocator);
+  if (iree_status_is_ok(status)) {
+    *out_device = (iree_hal_device_t*)device;
+  } else {
+    iree_hal_device_release((iree_hal_device_t*)device);
+  }
+  return status;
+}
+
+iree_status_t iree_hal_cuda_device_create(iree_hal_driver_t* driver,
+                                          iree_string_view_t identifier,
+                                          iree_hal_cuda_dynamic_symbols_t* syms,
+                                          CUdevice device,
+                                          iree_allocator_t host_allocator,
+                                          iree_hal_device_t** out_device) {
+  IREE_TRACE_ZONE_BEGIN(z0);
+  CUcontext context;
+  IREE_RETURN_AND_END_ZONE_IF_ERROR(
+      z0, CU_RESULT_TO_STATUS(syms, cuCtxCreate(&context, 0, device)));
+  CUstream stream;
+  iree_status_t status = CU_RESULT_TO_STATUS(
+      syms, cuStreamCreate(&stream, CU_STREAM_NON_BLOCKING));
+
+  if (iree_status_is_ok(status)) {
+    status = iree_hal_cuda_device_create_internal(driver, identifier, device,
+                                                  stream, context, syms,
+                                                  host_allocator, out_device);
+  }
+  if (!iree_status_is_ok(status)) {
+    if (stream) {
+      syms->cuStreamDestroy(stream);
+    }
+    syms->cuCtxDestroy(context);
+  }
+  IREE_TRACE_ZONE_END(z0);
+  return status;
+}
+
+static iree_string_view_t iree_hal_cuda_device_id(
+    iree_hal_device_t* base_device) {
+  iree_hal_cuda_device_t* device = iree_hal_cuda_device_cast(base_device);
+  return device->identifier;
+}
+
+static iree_allocator_t iree_hal_cuda_device_host_allocator(
+    iree_hal_device_t* base_device) {
+  iree_hal_cuda_device_t* device = iree_hal_cuda_device_cast(base_device);
+  return device->context_wrapper.host_allocator;
+}
+
+static iree_hal_allocator_t* iree_hal_cuda_device_allocator(
+    iree_hal_device_t* base_device) {
+  iree_hal_cuda_device_t* device = iree_hal_cuda_device_cast(base_device);
+  return device->device_allocator;
+}
+
+static iree_status_t iree_hal_cuda_device_create_command_buffer(
+    iree_hal_device_t* base_device, iree_hal_command_buffer_mode_t mode,
+    iree_hal_command_category_t command_categories,
+    iree_hal_command_buffer_t** out_command_buffer) {
+  return iree_make_status(IREE_STATUS_UNIMPLEMENTED, "Not impemented on CUDA");
+}
+
+static iree_status_t iree_hal_cuda_device_create_descriptor_set(
+    iree_hal_device_t* base_device,
+    iree_hal_descriptor_set_layout_t* set_layout,
+    iree_host_size_t binding_count,
+    const iree_hal_descriptor_set_binding_t* bindings,
+    iree_hal_descriptor_set_t** out_descriptor_set) {
+  return iree_make_status(IREE_STATUS_UNIMPLEMENTED,
+                          "non-push descriptor sets still need work");
+}
+
+static iree_status_t iree_hal_cuda_device_create_descriptor_set_layout(
+    iree_hal_device_t* base_device,
+    iree_hal_descriptor_set_layout_usage_type_t usage_type,
+    iree_host_size_t binding_count,
+    const iree_hal_descriptor_set_layout_binding_t* bindings,
+    iree_hal_descriptor_set_layout_t** out_descriptor_set_layout) {
+  return iree_make_status(IREE_STATUS_UNIMPLEMENTED, "Not impemented on CUDA");
+}
+
+static iree_status_t iree_hal_cuda_device_create_event(
+    iree_hal_device_t* base_device, iree_hal_event_t** out_event) {
+  return iree_make_status(IREE_STATUS_UNIMPLEMENTED, "Not impemented on CUDA");
+}
+
+static iree_status_t iree_hal_cuda_device_create_executable_cache(
+    iree_hal_device_t* base_device, iree_string_view_t identifier,
+    iree_hal_executable_cache_t** out_executable_cache) {
+  return iree_make_status(IREE_STATUS_UNIMPLEMENTED, "Not impemented on CUDA");
+}
+
+static iree_status_t iree_hal_cuda_device_create_executable_layout(
+    iree_hal_device_t* base_device, iree_host_size_t push_constants,
+    iree_host_size_t set_layout_count,
+    iree_hal_descriptor_set_layout_t** set_layouts,
+    iree_hal_executable_layout_t** out_executable_layout) {
+  return iree_make_status(IREE_STATUS_UNIMPLEMENTED, "Not impemented on CUDA");
+}
+
+static iree_status_t iree_hal_cuda_device_create_semaphore(
+    iree_hal_device_t* base_device, uint64_t initial_value,
+    iree_hal_semaphore_t** out_semaphore) {
+  return iree_make_status(IREE_STATUS_UNIMPLEMENTED, "Not impemented on CUDA");
+}
+
+static iree_status_t iree_hal_cuda_device_queue_submit(
+    iree_hal_device_t* base_device,
+    iree_hal_command_category_t command_categories, uint64_t queue_affinity,
+    iree_host_size_t batch_count, const iree_hal_submission_batch_t* batches) {
+  return iree_make_status(IREE_STATUS_UNIMPLEMENTED, "Not impemented on CUDA");
+}
+
+static iree_status_t iree_hal_cuda_device_wait_semaphores_with_timeout(
+    iree_hal_device_t* base_device, iree_hal_wait_mode_t wait_mode,
+    const iree_hal_semaphore_list_t* semaphore_list,
+    iree_duration_t timeout_ns) {
+  return iree_make_status(IREE_STATUS_UNIMPLEMENTED,
+                          "semaphore not implemented");
+}
+
+static iree_status_t iree_hal_cuda_device_wait_semaphores_with_deadline(
+    iree_hal_device_t* base_device, iree_hal_wait_mode_t wait_mode,
+    const iree_hal_semaphore_list_t* semaphore_list, iree_time_t deadline_ns) {
+  return iree_make_status(IREE_STATUS_UNIMPLEMENTED,
+                          "semaphore not implemented");
+}
+
+static iree_status_t iree_hal_cuda_device_wait_idle_with_deadline(
+    iree_hal_device_t* base_device, iree_time_t deadline_ns) {
+  iree_hal_cuda_device_t* device = iree_hal_cuda_device_cast(base_device);
+  // Wait until the stream is done.
+  // TODO(thomasraoux): CUDA doesn't support a deadline for wait, figure out how
+  // to handle it better.
+  CUDA_RETURN_IF_ERROR(device->context_wrapper.syms,
+                       cuStreamSynchronize(device->stream),
+                       "cuStreamSynchronize");
+  return iree_ok_status();
+}
+
+static iree_status_t iree_hal_cuda_device_wait_idle_with_timeout(
+    iree_hal_device_t* base_device, iree_duration_t timeout_ns) {
+  return iree_hal_cuda_device_wait_idle_with_deadline(
+      base_device, iree_relative_timeout_to_deadline_ns(timeout_ns));
+}
+
+const iree_hal_device_vtable_t iree_hal_cuda_device_vtable = {
+    .destroy = iree_hal_cuda_device_destroy,
+    .id = iree_hal_cuda_device_id,
+    .host_allocator = iree_hal_cuda_device_host_allocator,
+    .device_allocator = iree_hal_cuda_device_allocator,
+    .create_command_buffer = iree_hal_cuda_device_create_command_buffer,
+    .create_descriptor_set = iree_hal_cuda_device_create_descriptor_set,
+    .create_descriptor_set_layout =
+        iree_hal_cuda_device_create_descriptor_set_layout,
+    .create_event = iree_hal_cuda_device_create_event,
+    .create_executable_cache = iree_hal_cuda_device_create_executable_cache,
+    .create_executable_layout = iree_hal_cuda_device_create_executable_layout,
+    .create_semaphore = iree_hal_cuda_device_create_semaphore,
+    .queue_submit = iree_hal_cuda_device_queue_submit,
+    .wait_semaphores_with_deadline =
+        iree_hal_cuda_device_wait_semaphores_with_deadline,
+    .wait_semaphores_with_timeout =
+        iree_hal_cuda_device_wait_semaphores_with_timeout,
+    .wait_idle_with_deadline = iree_hal_cuda_device_wait_idle_with_deadline,
+    .wait_idle_with_timeout = iree_hal_cuda_device_wait_idle_with_timeout,
+};
diff --git a/iree/hal/cuda/cuda_device.h b/iree/hal/cuda/cuda_device.h
new file mode 100644
index 0000000..5d7d4ab
--- /dev/null
+++ b/iree/hal/cuda/cuda_device.h
@@ -0,0 +1,38 @@
+// Copyright 2021 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef IREE_HAL_CUDA_CUDA_DEVICE_H_
+#define IREE_HAL_CUDA_CUDA_DEVICE_H_
+
+#include "iree/hal/api.h"
+#include "iree/hal/cuda/api.h"
+#include "iree/hal/cuda/dynamic_symbols.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif  // __cplusplus
+
+// Creates a device that owns and manages its own CUcontext.
+iree_status_t iree_hal_cuda_device_create(iree_hal_driver_t* driver,
+                                          iree_string_view_t identifier,
+                                          iree_hal_cuda_dynamic_symbols_t* syms,
+                                          CUdevice device,
+                                          iree_allocator_t host_allocator,
+                                          iree_hal_device_t** out_device);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif  // __cplusplus
+
+#endif  // IREE_HAL_CUDA_CUDA_DEVICE_H_
diff --git a/iree/hal/cuda/cuda_driver.c b/iree/hal/cuda/cuda_driver.c
new file mode 100644
index 0000000..1f83363
--- /dev/null
+++ b/iree/hal/cuda/cuda_driver.c
@@ -0,0 +1,210 @@
+// Copyright 2021 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "iree/base/tracing.h"
+#include "iree/hal/cuda/api.h"
+#include "iree/hal/cuda/cuda_device.h"
+#include "iree/hal/cuda/dynamic_symbols.h"
+#include "iree/hal/cuda/status_util.h"
+
+typedef struct {
+  iree_hal_resource_t resource;
+  iree_allocator_t host_allocator;
+  // Identifier used for the driver in the IREE driver registry.
+  // We allow overriding so that multiple CUDA versions can be exposed in the
+  // same process.
+  iree_string_view_t identifier;
+  int default_device_index;
+  // CUDA symbols.
+  iree_hal_cuda_dynamic_symbols_t syms;
+} iree_hal_cuda_driver_t;
+
+// Pick a fixed lenght size for device names.
+#define IREE_MAX_CUDA_DEVICE_NAME_LENGTH 100
+
+extern const iree_hal_driver_vtable_t iree_hal_cuda_driver_vtable;
+
+static iree_hal_cuda_driver_t* iree_hal_cuda_driver_cast(
+    iree_hal_driver_t* base_value) {
+  IREE_HAL_ASSERT_TYPE(base_value, &iree_hal_cuda_driver_vtable);
+  return (iree_hal_cuda_driver_t*)base_value;
+}
+
+IREE_API_EXPORT void IREE_API_CALL iree_hal_cuda_driver_options_initialize(
+    iree_hal_cuda_driver_options_t* out_options) {
+  memset(out_options, 0, sizeof(*out_options));
+  out_options->default_device_index = 0;
+}
+
+static iree_status_t iree_hal_cuda_driver_create_internal(
+    iree_string_view_t identifier,
+    const iree_hal_cuda_driver_options_t* options,
+    iree_allocator_t host_allocator, iree_hal_driver_t** out_driver) {
+  iree_hal_cuda_driver_t* driver = NULL;
+  iree_host_size_t total_size = sizeof(*driver) + identifier.size;
+  IREE_RETURN_IF_ERROR(
+      iree_allocator_malloc(host_allocator, total_size, (void**)&driver));
+  iree_hal_resource_initialize(&iree_hal_cuda_driver_vtable, &driver->resource);
+  driver->host_allocator = host_allocator;
+  iree_string_view_append_to_buffer(
+      identifier, &driver->identifier,
+      (char*)driver + total_size - identifier.size);
+  driver->default_device_index = options->default_device_index;
+  iree_status_t status = load_symbols(&driver->syms);
+  if (iree_status_is_ok(status)) {
+    *out_driver = (iree_hal_driver_t*)driver;
+  } else {
+    iree_hal_driver_release((iree_hal_driver_t*)driver);
+  }
+  return status;
+}
+
+static void iree_hal_cuda_driver_destroy(iree_hal_driver_t* base_driver) {
+  iree_hal_cuda_driver_t* driver = iree_hal_cuda_driver_cast(base_driver);
+  iree_allocator_t host_allocator = driver->host_allocator;
+  IREE_TRACE_ZONE_BEGIN(z0);
+
+  unload_symbols(&driver->syms);
+  iree_allocator_free(host_allocator, driver);
+
+  IREE_TRACE_ZONE_END(z0);
+}
+
+IREE_API_EXPORT iree_status_t IREE_API_CALL iree_hal_cuda_driver_create(
+    iree_string_view_t identifier,
+    const iree_hal_cuda_driver_options_t* options,
+    iree_allocator_t host_allocator, iree_hal_driver_t** out_driver) {
+  IREE_ASSERT_ARGUMENT(options);
+  IREE_ASSERT_ARGUMENT(out_driver);
+  IREE_TRACE_ZONE_BEGIN(z0);
+
+  iree_status_t status = iree_hal_cuda_driver_create_internal(
+      identifier, options, host_allocator, out_driver);
+
+  IREE_TRACE_ZONE_END(z0);
+  return status;
+}
+
+// Populates device information from the given CUDA physical device handle.
+// |out_device_info| must point to valid memory and additional data will be
+// appended to |buffer_ptr| and the new pointer is returned.
+static uint8_t* iree_hal_cuda_populate_device_info(
+    CUdevice device, iree_hal_cuda_dynamic_symbols_t* syms, uint8_t* buffer_ptr,
+    iree_hal_device_info_t* out_device_info) {
+  char device_name[IREE_MAX_CUDA_DEVICE_NAME_LENGTH];
+  CUDA_IGNORE_ERROR(syms,
+                    cuDeviceGetName(device_name, sizeof(device_name), device));
+  memset(out_device_info, 0, sizeof(*out_device_info));
+  out_device_info->device_id = (iree_hal_device_id_t)device;
+
+  iree_string_view_t device_name_string =
+      iree_make_string_view(device_name, strlen(device_name));
+  buffer_ptr += iree_string_view_append_to_buffer(
+      device_name_string, &out_device_info->name, (char*)buffer_ptr);
+  return buffer_ptr;
+}
+
+static iree_status_t iree_hal_cuda_driver_query_available_devices(
+    iree_hal_driver_t* base_driver, iree_allocator_t host_allocator,
+    iree_hal_device_info_t** out_device_infos,
+    iree_host_size_t* out_device_info_count) {
+  iree_hal_cuda_driver_t* driver = iree_hal_cuda_driver_cast(base_driver);
+  // Query the number of available CUDA devices.
+  int device_count = 0;
+  CUDA_RETURN_IF_ERROR(&driver->syms, cuDeviceGetCount(&device_count),
+                       "cuDeviceGetCount");
+
+  // Allocate the return infos and populate with the devices.
+  iree_hal_device_info_t* device_infos = NULL;
+  iree_host_size_t total_size = device_count * sizeof(iree_hal_device_info_t);
+  for (iree_host_size_t i = 0; i < device_count; ++i) {
+    total_size += IREE_MAX_CUDA_DEVICE_NAME_LENGTH * sizeof(char);
+  }
+  iree_status_t status =
+      iree_allocator_malloc(host_allocator, total_size, (void**)&device_infos);
+  if (iree_status_is_ok(status)) {
+    uint8_t* buffer_ptr =
+        (uint8_t*)device_infos + device_count * sizeof(iree_hal_device_info_t);
+    for (iree_host_size_t i = 0; i < device_count; ++i) {
+      CUdevice device;
+      iree_status_t status = CU_RESULT_TO_STATUS(
+          &driver->syms, cuDeviceGet(&device, i), "cuDeviceGet");
+      if (!iree_status_is_ok(status)) break;
+      buffer_ptr = iree_hal_cuda_populate_device_info(
+          device, &driver->syms, buffer_ptr, &device_infos[i]);
+    }
+  }
+  if (iree_status_is_ok(status)) {
+    *out_device_info_count = device_count;
+    *out_device_infos = device_infos;
+  } else {
+    iree_allocator_free(host_allocator, device_infos);
+  }
+  return status;
+}
+
+static iree_status_t iree_hal_cuda_driver_select_default_device(
+    iree_hal_cuda_dynamic_symbols_t* syms, int default_device_index,
+    iree_allocator_t host_allocator, CUdevice* out_device) {
+  int device_count = 0;
+  CUDA_RETURN_IF_ERROR(syms, cuDeviceGetCount(&device_count),
+                       "cuDeviceGetCount");
+  iree_status_t status = iree_ok_status();
+  if (device_count == 0 || default_device_index >= device_count) {
+    status = iree_make_status(IREE_STATUS_NOT_FOUND,
+                              "default device %d not found (of %d enumerated)",
+                              default_device_index, device_count);
+  } else {
+    CUdevice device;
+    CUDA_RETURN_IF_ERROR(syms, cuDeviceGet(&device, default_device_index),
+                         "cuDeviceGet");
+    *out_device = device;
+  }
+  return status;
+}
+
+static iree_status_t iree_hal_cuda_driver_create_device(
+    iree_hal_driver_t* base_driver, iree_hal_device_id_t device_id,
+    iree_allocator_t host_allocator, iree_hal_device_t** out_device) {
+  iree_hal_cuda_driver_t* driver = iree_hal_cuda_driver_cast(base_driver);
+  IREE_TRACE_ZONE_BEGIN(z0);
+
+  IREE_RETURN_AND_END_ZONE_IF_ERROR(
+      z0, CU_RESULT_TO_STATUS(&driver->syms, cuInit(0), "cuInit"));
+  // Use either the specified device (enumerated earlier) or whatever default
+  // one was specified when the driver was created.
+  CUdevice device = (CUdevice)device_id;
+  if (device == 0) {
+    IREE_RETURN_AND_END_ZONE_IF_ERROR(
+        z0, iree_hal_cuda_driver_select_default_device(
+                &driver->syms, driver->default_device_index, host_allocator,
+                &device));
+  }
+
+  iree_string_view_t device_name = iree_make_cstring_view("cuda");
+
+  // Attempt to create the device.
+  iree_status_t status =
+      iree_hal_cuda_device_create(base_driver, device_name, &driver->syms,
+                                  device, host_allocator, out_device);
+
+  IREE_TRACE_ZONE_END(z0);
+  return status;
+}
+
+const iree_hal_driver_vtable_t iree_hal_cuda_driver_vtable = {
+    .destroy = iree_hal_cuda_driver_destroy,
+    .query_available_devices = iree_hal_cuda_driver_query_available_devices,
+    .create_device = iree_hal_cuda_driver_create_device,
+};
diff --git a/iree/hal/cuda/dynamic_symbols.cc b/iree/hal/cuda/dynamic_symbols.cc
index 0927116..df13a4d 100644
--- a/iree/hal/cuda/dynamic_symbols.cc
+++ b/iree/hal/cuda/dynamic_symbols.cc
@@ -17,15 +17,12 @@
 #include <cstddef>
 
 #include "absl/types/span.h"
+#include "iree/base/dynamic_library.h"
 #include "iree/base/status.h"
 #include "iree/base/target_platform.h"
 #include "iree/base/tracing.h"
 
-namespace iree {
-namespace hal {
-namespace cuda {
-
-static const char* kCudaLoaderSearchNames[] = {
+static const char* kCUDALoaderSearchNames[] = {
 #if defined(IREE_PLATFORM_WINDOWS)
     "nvcuda.dll",
 #else
@@ -33,28 +30,31 @@
 #endif
 };
 
-Status DynamicSymbols::LoadSymbols() {
-  IREE_TRACE_SCOPE();
+extern "C" {
 
-  IREE_RETURN_IF_ERROR(DynamicLibrary::Load(
-      absl::MakeSpan(kCudaLoaderSearchNames), &loader_library_));
+iree_status_t load_symbols(iree_hal_cuda_dynamic_symbols_t* syms) {
+  std::unique_ptr<iree::DynamicLibrary> loader_library;
+  IREE_RETURN_IF_ERROR(iree::DynamicLibrary::Load(
+      absl::MakeSpan(kCUDALoaderSearchNames), &loader_library));
 
-#define CU_PFN_DECL(cudaSymbolName)                                         \
+#define CU_PFN_DECL(cudaSymbolName, ...)                                    \
   {                                                                         \
-    using FuncPtrT = std::add_pointer<decltype(::cudaSymbolName)>::type;    \
+    using FuncPtrT = decltype(syms->cudaSymbolName);                        \
     static const char* kName = #cudaSymbolName;                             \
-    cudaSymbolName = loader_library_->GetSymbol<FuncPtrT>(kName);           \
-    if (!cudaSymbolName) {                                                  \
+    syms->cudaSymbolName = loader_library->GetSymbol<FuncPtrT>(kName);      \
+    if (!syms->cudaSymbolName) {                                            \
       return iree_make_status(IREE_STATUS_UNAVAILABLE, "symbol not found"); \
     }                                                                       \
   }
 
 #include "dynamic_symbols_tables.h"
 #undef CU_PFN_DECL
-
-  return OkStatus();
+  syms->opaque_loader_library_ = (void*)loader_library.release();
+  return iree_ok_status();
 }
 
-}  // namespace cuda
-}  // namespace hal
-}  // namespace iree
+void unload_symbols(iree_hal_cuda_dynamic_symbols_t* syms) {
+  delete (iree::DynamicLibrary*)syms->opaque_loader_library_;
+}
+
+}  // extern "C"
\ No newline at end of file
diff --git a/iree/hal/cuda/dynamic_symbols.h b/iree/hal/cuda/dynamic_symbols.h
index 9d2c40e..436b32d 100644
--- a/iree/hal/cuda/dynamic_symbols.h
+++ b/iree/hal/cuda/dynamic_symbols.h
@@ -15,38 +15,29 @@
 #ifndef IREE_HAL_CUDA_DYNAMIC_SYMBOLS_H_
 #define IREE_HAL_CUDA_DYNAMIC_SYMBOLS_H_
 
-#include <cstdint>
-#include <functional>
-#include <memory>
-
-#include "iree/base/dynamic_library.h"
-#include "iree/base/status.h"
+#include "iree/base/api.h"
 #include "iree/hal/cuda/cuda_headers.h"
 
-namespace iree {
-namespace hal {
-namespace cuda {
-
+#ifdef __cplusplus
+extern "C" {
+#endif  // __cplusplus
 /// DyanmicSymbols allow loading dynamically a subset of CUDA driver API. It
 /// loads all the function declared in `dynamic_symbol_tables.def` and fail if
 /// any of the symbol is not available. The functions signatures are matching
 /// the declarations in `cuda.h`.
-struct DynamicSymbols {
-  Status LoadSymbols();
-
-#define CU_PFN_DECL(cudaSymbolName) \
-  std::add_pointer<decltype(::cudaSymbolName)>::type cudaSymbolName;
-
+typedef struct {
+#define CU_PFN_DECL(cudaSymbolName, ...) \
+  CUresult (*cudaSymbolName)(__VA_ARGS__);
 #include "dynamic_symbols_tables.h"
 #undef CU_PFN_DECL
+  void* opaque_loader_library_;
+} iree_hal_cuda_dynamic_symbols_t;
 
- private:
-  // Cuda Loader dynamic library.
-  std::unique_ptr<DynamicLibrary> loader_library_;
-};
+iree_status_t load_symbols(iree_hal_cuda_dynamic_symbols_t* syms);
+void unload_symbols(iree_hal_cuda_dynamic_symbols_t* syms);
 
-}  // namespace cuda
-}  // namespace hal
-}  // namespace iree
+#ifdef __cplusplus
+}  // extern "C"
+#endif  // __cplusplus
 
 #endif  // IREE_HAL_CUDA_DYNAMIC_SYMBOLS_H_
diff --git a/iree/hal/cuda/dynamic_symbols_tables.h b/iree/hal/cuda/dynamic_symbols_tables.h
index 5adece6..1a9fbaa 100644
--- a/iree/hal/cuda/dynamic_symbols_tables.h
+++ b/iree/hal/cuda/dynamic_symbols_tables.h
@@ -12,79 +12,37 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-CU_PFN_DECL(cuCtxCreate)
-CU_PFN_DECL(cuCtxDestroy)
-CU_PFN_DECL(cuCtxEnablePeerAccess)
-CU_PFN_DECL(cuCtxGetCurrent)
-CU_PFN_DECL(cuCtxGetDevice)
-CU_PFN_DECL(cuCtxGetSharedMemConfig)
-CU_PFN_DECL(cuCtxSetCurrent)
-CU_PFN_DECL(cuCtxSetSharedMemConfig)
-CU_PFN_DECL(cuCtxSynchronize)
-CU_PFN_DECL(cuDeviceCanAccessPeer)
-CU_PFN_DECL(cuDeviceGet)
-CU_PFN_DECL(cuDeviceGetAttribute)
-CU_PFN_DECL(cuDeviceGetCount)
-CU_PFN_DECL(cuDeviceGetName)
-CU_PFN_DECL(cuDeviceGetPCIBusId)
-CU_PFN_DECL(cuDevicePrimaryCtxGetState)
-CU_PFN_DECL(cuDevicePrimaryCtxRelease)
-CU_PFN_DECL(cuDevicePrimaryCtxRetain)
-CU_PFN_DECL(cuDevicePrimaryCtxSetFlags)
-CU_PFN_DECL(cuDeviceTotalMem)
-CU_PFN_DECL(cuDriverGetVersion)
-CU_PFN_DECL(cuEventCreate)
-CU_PFN_DECL(cuEventDestroy)
-CU_PFN_DECL(cuEventElapsedTime)
-CU_PFN_DECL(cuEventQuery)
-CU_PFN_DECL(cuEventRecord)
-CU_PFN_DECL(cuEventSynchronize)
-CU_PFN_DECL(cuFuncGetAttribute)
-CU_PFN_DECL(cuFuncSetCacheConfig)
-CU_PFN_DECL(cuGetErrorName)
-CU_PFN_DECL(cuGetErrorString)
-CU_PFN_DECL(cuGraphAddMemcpyNode)
-CU_PFN_DECL(cuGraphAddMemsetNode)
-CU_PFN_DECL(cuGraphAddKernelNode)
-CU_PFN_DECL(cuGraphCreate)
-CU_PFN_DECL(cuGraphDestroy)
-CU_PFN_DECL(cuGraphExecDestroy)
-CU_PFN_DECL(cuGraphGetNodes)
-CU_PFN_DECL(cuGraphInstantiate)
-CU_PFN_DECL(cuGraphLaunch)
-CU_PFN_DECL(cuInit)
-CU_PFN_DECL(cuLaunchKernel)
-CU_PFN_DECL(cuMemAlloc)
-CU_PFN_DECL(cuMemAllocManaged)
-CU_PFN_DECL(cuMemFree)
-CU_PFN_DECL(cuMemFreeHost)
-CU_PFN_DECL(cuMemGetAddressRange)
-CU_PFN_DECL(cuMemGetInfo)
-CU_PFN_DECL(cuMemHostAlloc)
-CU_PFN_DECL(cuMemHostGetDevicePointer)
-CU_PFN_DECL(cuMemHostRegister)
-CU_PFN_DECL(cuMemHostUnregister)
-CU_PFN_DECL(cuMemcpyDtoD)
-CU_PFN_DECL(cuMemcpyDtoDAsync)
-CU_PFN_DECL(cuMemcpyDtoH)
-CU_PFN_DECL(cuMemcpyDtoHAsync)
-CU_PFN_DECL(cuMemcpyHtoD)
-CU_PFN_DECL(cuMemcpyHtoDAsync)
-CU_PFN_DECL(cuMemsetD32)
-CU_PFN_DECL(cuMemsetD32Async)
-CU_PFN_DECL(cuMemsetD8)
-CU_PFN_DECL(cuMemsetD8Async)
-CU_PFN_DECL(cuModuleGetFunction)
-CU_PFN_DECL(cuModuleGetGlobal)
-CU_PFN_DECL(cuModuleLoadDataEx)
-CU_PFN_DECL(cuModuleLoadFatBinary)
-CU_PFN_DECL(cuModuleUnload)
-CU_PFN_DECL(cuOccupancyMaxActiveBlocksPerMultiprocessor)
-CU_PFN_DECL(cuOccupancyMaxPotentialBlockSize)
-CU_PFN_DECL(cuPointerGetAttribute)
-CU_PFN_DECL(cuStreamAddCallback)
-CU_PFN_DECL(cuStreamCreate)
-CU_PFN_DECL(cuStreamDestroy)
-CU_PFN_DECL(cuStreamQuery)
-CU_PFN_DECL(cuStreamSynchronize)
-CU_PFN_DECL(cuStreamWaitEvent)
+CU_PFN_DECL(cuCtxCreate, CUcontext*, unsigned int, CUdevice)
+CU_PFN_DECL(cuCtxDestroy, CUcontext)
+CU_PFN_DECL(cuDeviceGet, CUdevice*, int)
+CU_PFN_DECL(cuDeviceGetCount, int*)
+CU_PFN_DECL(cuDeviceGetName, char*, int, CUdevice)
+CU_PFN_DECL(cuGetErrorName, CUresult, const char**)
+CU_PFN_DECL(cuGetErrorString, CUresult, const char**)
+CU_PFN_DECL(cuGraphAddMemcpyNode, CUgraphNode*, CUgraph, const CUgraphNode*,
+            size_t, const CUDA_MEMCPY3D*, CUcontext)
+CU_PFN_DECL(cuGraphAddMemsetNode, CUgraphNode*, CUgraph, const CUgraphNode*,
+            size_t, const CUDA_MEMSET_NODE_PARAMS*, CUcontext)
+CU_PFN_DECL(cuGraphAddKernelNode, CUgraphNode*, CUgraph, const CUgraphNode*,
+            size_t, const CUDA_KERNEL_NODE_PARAMS*)
+CU_PFN_DECL(cuGraphCreate, CUgraph*, unsigned int)
+CU_PFN_DECL(cuGraphDestroy, CUgraph)
+CU_PFN_DECL(cuGraphExecDestroy, CUgraphExec)
+CU_PFN_DECL(cuGraphGetNodes, CUgraph, CUgraphNode*, size_t*)
+CU_PFN_DECL(cuGraphInstantiate, CUgraphExec*, CUgraph, CUgraphNode*, char*,
+            size_t)
+CU_PFN_DECL(cuGraphLaunch, CUgraphExec, CUstream)
+CU_PFN_DECL(cuInit, unsigned int)
+CU_PFN_DECL(cuMemAlloc, CUdeviceptr*, size_t)
+CU_PFN_DECL(cuMemFree, CUdeviceptr)
+CU_PFN_DECL(cuMemFreeHost, void*)
+CU_PFN_DECL(cuMemHostAlloc, void**, size_t, unsigned int)
+CU_PFN_DECL(cuMemHostGetDevicePointer, CUdeviceptr*, void*, unsigned int)
+CU_PFN_DECL(cuModuleGetFunction, CUfunction*, CUmodule, const char*)
+CU_PFN_DECL(cuModuleLoadDataEx, CUmodule*, const void*, unsigned int,
+            CUjit_option*, void**)
+CU_PFN_DECL(cuModuleUnload, CUmodule)
+CU_PFN_DECL(cuStreamCreate, CUstream*, unsigned int)
+CU_PFN_DECL(cuStreamDestroy, CUstream)
+CU_PFN_DECL(cuStreamSynchronize, CUstream)
+CU_PFN_DECL(cuStreamWaitEvent, CUstream, CUevent, unsigned int)
diff --git a/iree/hal/cuda/dynamic_symbols_test.cc b/iree/hal/cuda/dynamic_symbols_test.cc
index 6a7967c..5b8681f 100644
--- a/iree/hal/cuda/dynamic_symbols_test.cc
+++ b/iree/hal/cuda/dynamic_symbols_test.cc
@@ -29,9 +29,9 @@
   }
 
 TEST(DynamicSymbolsTest, CreateFromSystemLoader) {
-  DynamicSymbols symbols;
-  Status status = symbols.LoadSymbols();
-  if (!status.ok()) {
+  iree_hal_cuda_dynamic_symbols_t symbols;
+  iree_status_t status = load_symbols(&symbols);
+  if (!iree_status_is_ok(status)) {
     IREE_LOG(WARNING) << "Symbols cannot be loaded, skipping test.";
     GTEST_SKIP();
   }
@@ -43,6 +43,7 @@
     CUdevice device;
     CUDE_CHECK_ERRORS(symbols.cuDeviceGet(&device, /*ordinal=*/0));
   }
+  unload_symbols(&symbols);
 }
 
 }  // namespace
diff --git a/iree/hal/cuda/registration/BUILD b/iree/hal/cuda/registration/BUILD
new file mode 100644
index 0000000..58157f4
--- /dev/null
+++ b/iree/hal/cuda/registration/BUILD
@@ -0,0 +1,51 @@
+# Copyright 2021 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load("//iree:build_defs.oss.bzl", "iree_cmake_extra_content")
+
+package(
+    default_visibility = ["//visibility:public"],
+    features = ["layering_check"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+iree_cmake_extra_content(
+    content = """
+if(${IREE_HAL_DRIVER_CUDA})
+""",
+    inline = True,
+)
+
+cc_library(
+    name = "registration",
+    srcs = ["driver_module.c"],
+    hdrs = ["driver_module.h"],
+    defines = [
+        "IREE_HAL_HAVE_CUDA_DRIVER_MODULE=1",
+    ],
+    deps = [
+        "//iree/base:core_headers",
+        "//iree/base:status",
+        "//iree/base:tracing",
+        "//iree/hal:api",
+        "//iree/hal/cuda",
+    ],
+)
+
+iree_cmake_extra_content(
+    content = """
+endif()
+""",
+    inline = True,
+)
diff --git a/iree/hal/cuda/registration/CMakeLists.txt b/iree/hal/cuda/registration/CMakeLists.txt
new file mode 100644
index 0000000..93d8dac
--- /dev/null
+++ b/iree/hal/cuda/registration/CMakeLists.txt
@@ -0,0 +1,25 @@
+# Autogenerated from iree/hal/cuda/registration/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
+iree_add_all_subdirs()
+
+if(${IREE_HAL_DRIVER_CUDA})
+
+iree_cc_library(
+  NAME
+    registration
+  HDRS
+    "driver_module.h"
+  SRCS
+    "driver_module.c"
+  DEPS
+    iree::base::core_headers
+    iree::base::status
+    iree::base::tracing
+    iree::hal::api
+    iree::hal::cuda
+  DEFINES
+    "IREE_HAL_HAVE_CUDA_DRIVER_MODULE=1"
+  PUBLIC
+)
+
+endif()
diff --git a/iree/hal/cuda/registration/driver_module.c b/iree/hal/cuda/registration/driver_module.c
new file mode 100644
index 0000000..5677cd1
--- /dev/null
+++ b/iree/hal/cuda/registration/driver_module.c
@@ -0,0 +1,72 @@
+// Copyright 2021 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "iree/hal/cuda/registration/driver_module.h"
+
+#include <inttypes.h>
+
+#include "iree/base/status.h"
+#include "iree/base/target_platform.h"
+#include "iree/base/tracing.h"
+#include "iree/hal/cuda/api.h"
+
+#define IREE_HAL_CUDA_DRIVER_ID 0x43554441u  // CUDA
+
+static iree_status_t iree_hal_cuda_driver_factory_enumerate(
+    void* self, const iree_hal_driver_info_t** out_driver_infos,
+    iree_host_size_t* out_driver_info_count) {
+  // NOTE: we could query supported cuda versions or featuresets here.
+  static const iree_hal_driver_info_t driver_infos[1] = {{
+      .driver_id = IREE_HAL_CUDA_DRIVER_ID,
+      .driver_name = iree_string_view_literal("cuda"),
+      .full_name = iree_string_view_literal("CUDA (dynamic)"),
+  }};
+  *out_driver_info_count = IREE_ARRAYSIZE(driver_infos);
+  *out_driver_infos = driver_infos;
+  return iree_ok_status();
+}
+
+static iree_status_t iree_hal_cuda_driver_factory_try_create(
+    void* self, iree_hal_driver_id_t driver_id, iree_allocator_t allocator,
+    iree_hal_driver_t** out_driver) {
+  IREE_ASSERT_ARGUMENT(out_driver);
+  *out_driver = NULL;
+  if (driver_id != IREE_HAL_CUDA_DRIVER_ID) {
+    return iree_make_status(IREE_STATUS_UNAVAILABLE,
+                            "no driver with ID %016" PRIu64
+                            " is provided by this factory",
+                            driver_id);
+  }
+  IREE_TRACE_ZONE_BEGIN(z0);
+  // When we expose more than one driver (different cuda versions, etc) we
+  // can name them here:
+  iree_string_view_t identifier = iree_make_cstring_view("cuda");
+
+  iree_hal_cuda_driver_options_t driver_options;
+  iree_hal_cuda_driver_options_initialize(&driver_options);
+  iree_status_t status = iree_hal_cuda_driver_create(
+      identifier, &driver_options, allocator, out_driver);
+  IREE_TRACE_ZONE_END(z0);
+  return status;
+}
+
+IREE_API_EXPORT iree_status_t IREE_API_CALL
+iree_hal_cuda_driver_module_register(iree_hal_driver_registry_t* registry) {
+  static const iree_hal_driver_factory_t factory = {
+      .self = NULL,
+      .enumerate = iree_hal_cuda_driver_factory_enumerate,
+      .try_create = iree_hal_cuda_driver_factory_try_create,
+  };
+  return iree_hal_driver_registry_register_factory(registry, &factory);
+}
diff --git a/iree/hal/cuda/registration/driver_module.h b/iree/hal/cuda/registration/driver_module.h
new file mode 100644
index 0000000..897594c
--- /dev/null
+++ b/iree/hal/cuda/registration/driver_module.h
@@ -0,0 +1,31 @@
+// Copyright 2021 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef IREE_HAL_CUDA_REGISTRATION_DRIVER_MODULE_H_
+#define IREE_HAL_CUDA_REGISTRATION_DRIVER_MODULE_H_
+
+#include "iree/hal/api.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif  // __cplusplus
+
+IREE_API_EXPORT iree_status_t IREE_API_CALL
+iree_hal_cuda_driver_module_register(iree_hal_driver_registry_t* registry);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif  // __cplusplus
+
+#endif  // IREE_HAL_CUDA_REGISTRATION_DRIVER_MODULE_H_
diff --git a/iree/hal/cuda/status_util.c b/iree/hal/cuda/status_util.c
new file mode 100644
index 0000000..9a084a8
--- /dev/null
+++ b/iree/hal/cuda/status_util.c
@@ -0,0 +1,38 @@
+// Copyright 2021 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "iree/hal/cuda/status_util.h"
+
+#include "iree/hal/cuda/dynamic_symbols.h"
+
+iree_status_t iree_hal_cuda_result_to_status(
+    iree_hal_cuda_dynamic_symbols_t* syms, CUresult result, const char* file,
+    uint32_t line) {
+  if (IREE_LIKELY(result == CUDA_SUCCESS)) {
+    return iree_ok_status();
+  }
+
+  const char* error_name = NULL;
+  if (syms->cuGetErrorName(result, &error_name) != CUDA_SUCCESS) {
+    error_name = "UNKNOWN";
+  }
+
+  const char* error_string = NULL;
+  if (syms->cuGetErrorString(result, &error_string) != CUDA_SUCCESS) {
+    error_string = "Unknown error.";
+  }
+  return iree_make_status(IREE_STATUS_INTERNAL,
+                          "CUDA driver error '%s' (%d): %s", error_name, result,
+                          error_string);
+}
diff --git a/iree/hal/cuda/status_util.h b/iree/hal/cuda/status_util.h
new file mode 100644
index 0000000..45ffe2d
--- /dev/null
+++ b/iree/hal/cuda/status_util.h
@@ -0,0 +1,60 @@
+// Copyright 2021 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef IREE_HAL_CUDA_STATUS_UTIL_H_
+#define IREE_HAL_CUDA_STATUS_UTIL_H_
+
+#include "iree/base/api.h"
+#include "iree/hal/cuda/dynamic_symbols.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif  // __cplusplus
+
+// Converts a CUresult to an iree_status_t.
+//
+// Usage:
+//   iree_status_t status = CU_RESULT_TO_STATUS(cuDoThing(...));
+#define CU_RESULT_TO_STATUS(syms, expr, ...) \
+  iree_hal_cuda_result_to_status((syms), ((syms)->expr), __FILE__, __LINE__)
+
+// IREE_RETURN_IF_ERROR but implicitly converts the CUresult return value to
+// a Status.
+//
+// Usage:
+//   CUDA_RETURN_IF_ERROR(cuDoThing(...), "message");
+#define CUDA_RETURN_IF_ERROR(syms, expr, ...)                                 \
+  IREE_RETURN_IF_ERROR(iree_hal_cuda_result_to_status((syms), ((syms)->expr), \
+                                                      __FILE__, __LINE__),    \
+                       __VA_ARGS__)
+
+// IREE_IGNORE_ERROR but implicitly converts the CUresult return value to a
+// Status.
+//
+// Usage:
+//   CUDA_IGNORE_ERROR(cuDoThing(...));
+#define CUDA_IGNORE_ERROR(syms, expr)                                      \
+  IREE_IGNORE_ERROR(iree_hal_cuda_result_to_status((syms), ((syms)->expr), \
+                                                   __FILE__, __LINE__))
+
+// Converts a CUresult to a Status object.
+iree_status_t iree_hal_cuda_result_to_status(
+    iree_hal_cuda_dynamic_symbols_t* syms, CUresult result, const char* file,
+    uint32_t line);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif  // __cplusplus
+
+#endif  // IREE_HAL_CUDA_STATUS_UTIL_H_
diff --git a/iree/hal/drivers/CMakeLists.txt b/iree/hal/drivers/CMakeLists.txt
index 305bcb5..1994aef 100644
--- a/iree/hal/drivers/CMakeLists.txt
+++ b/iree/hal/drivers/CMakeLists.txt
@@ -15,6 +15,9 @@
 # bazel_to_cmake: DO NOT EDIT (custom configuration vars)
 
 set(IREE_HAL_DRIVER_MODULES)
+if(${IREE_HAL_DRIVER_CUDA})
+  list(APPEND IREE_HAL_DRIVER_MODULES iree::hal::cuda::registration)
+endif()
 if(${IREE_HAL_DRIVER_DYLIB})
   list(APPEND IREE_HAL_DRIVER_MODULES iree::hal::dylib::registration)
 endif()
diff --git a/iree/hal/drivers/init.c b/iree/hal/drivers/init.c
index bb36616..bbcd9b9 100644
--- a/iree/hal/drivers/init.c
+++ b/iree/hal/drivers/init.c
@@ -16,6 +16,10 @@
 
 #include "iree/base/tracing.h"
 
+#if defined(IREE_HAL_HAVE_CUDA_DRIVER_MODULE)
+#include "iree/hal/cuda/registration/driver_module.h"
+#endif  // IREE_HAL_HAVE_CUDA_DRIVER_MODULE
+
 #if defined(IREE_HAL_HAVE_DYLIB_DRIVER_MODULE)
 #include "iree/hal/dylib/registration/driver_module.h"
 #endif  // IREE_HAL_HAVE_DYLIB_DRIVER_MODULE
@@ -32,6 +36,11 @@
 iree_hal_register_all_available_drivers(iree_hal_driver_registry_t* registry) {
   IREE_TRACE_ZONE_BEGIN(z0);
 
+#if defined(IREE_HAL_HAVE_CUDA_DRIVER_MODULE)
+  IREE_RETURN_AND_END_ZONE_IF_ERROR(
+      z0, iree_hal_cuda_driver_module_register(registry));
+#endif  // IREE_HAL_HAVE_CUDA_DRIVER_MODULE
+
 #if defined(IREE_HAL_HAVE_DYLIB_DRIVER_MODULE)
   IREE_RETURN_AND_END_ZONE_IF_ERROR(
       z0, iree_hal_dylib_driver_module_register(registry));
diff --git a/iree/hal/dylib/CMakeLists.txt b/iree/hal/dylib/CMakeLists.txt
index 15e9263..f209e8a 100644
--- a/iree/hal/dylib/CMakeLists.txt
+++ b/iree/hal/dylib/CMakeLists.txt
@@ -1,15 +1,3 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/hal/dylib/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
diff --git a/iree/hal/dylib/registration/CMakeLists.txt b/iree/hal/dylib/registration/CMakeLists.txt
index 6dcab19..a589f18 100644
--- a/iree/hal/dylib/registration/CMakeLists.txt
+++ b/iree/hal/dylib/registration/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/hal/dylib/registration/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 if(NOT ${IREE_HAL_DRIVER_DYLIB})
diff --git a/iree/hal/local/CMakeLists.txt b/iree/hal/local/CMakeLists.txt
index b633fa9..e2eed7c 100644
--- a/iree/hal/local/CMakeLists.txt
+++ b/iree/hal/local/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/hal/local/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/hal/local/loaders/CMakeLists.txt b/iree/hal/local/loaders/CMakeLists.txt
index 9c9ab43..ee0bd0f 100644
--- a/iree/hal/local/loaders/CMakeLists.txt
+++ b/iree/hal/local/loaders/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/hal/local/loaders/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/hal/testing/CMakeLists.txt b/iree/hal/testing/CMakeLists.txt
index 8faecc3..75d2faf 100644
--- a/iree/hal/testing/CMakeLists.txt
+++ b/iree/hal/testing/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/hal/testing/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/hal/vmla/CMakeLists.txt b/iree/hal/vmla/CMakeLists.txt
index 8b864e5..17ea62f 100644
--- a/iree/hal/vmla/CMakeLists.txt
+++ b/iree/hal/vmla/CMakeLists.txt
@@ -1,15 +1,3 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/hal/vmla/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
diff --git a/iree/hal/vmla/registration/CMakeLists.txt b/iree/hal/vmla/registration/CMakeLists.txt
index 6c5e184..15ae730 100644
--- a/iree/hal/vmla/registration/CMakeLists.txt
+++ b/iree/hal/vmla/registration/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/hal/vmla/registration/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 if(${IREE_HAL_DRIVER_VMLA})
diff --git a/iree/hal/vulkan/CMakeLists.txt b/iree/hal/vulkan/CMakeLists.txt
index 1d6dd8a..e5d8490 100644
--- a/iree/hal/vulkan/CMakeLists.txt
+++ b/iree/hal/vulkan/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/hal/vulkan/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 if(NOT ${IREE_HAL_DRIVER_VULKAN})
   return()
 endif()
diff --git a/iree/hal/vulkan/registration/CMakeLists.txt b/iree/hal/vulkan/registration/CMakeLists.txt
index 44e1df9..080c629 100644
--- a/iree/hal/vulkan/registration/CMakeLists.txt
+++ b/iree/hal/vulkan/registration/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/hal/vulkan/registration/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 if(${IREE_HAL_DRIVER_VULKAN})
diff --git a/iree/hal/vulkan/util/CMakeLists.txt b/iree/hal/vulkan/util/CMakeLists.txt
index ed7532c..2c71390 100644
--- a/iree/hal/vulkan/util/CMakeLists.txt
+++ b/iree/hal/vulkan/util/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/hal/vulkan/util/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/modules/CMakeLists.txt b/iree/modules/CMakeLists.txt
index 15e9263..20c3b6b 100644
--- a/iree/modules/CMakeLists.txt
+++ b/iree/modules/CMakeLists.txt
@@ -1,15 +1,3 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/modules/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
diff --git a/iree/modules/check/test/CMakeLists.txt b/iree/modules/check/test/CMakeLists.txt
index f29865e..be367c0 100644
--- a/iree/modules/check/test/CMakeLists.txt
+++ b/iree/modules/check/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/modules/check/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/modules/hal/CMakeLists.txt b/iree/modules/hal/CMakeLists.txt
index 6e602e2..506773b 100644
--- a/iree/modules/hal/CMakeLists.txt
+++ b/iree/modules/hal/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/modules/hal/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/modules/strings/CMakeLists.txt b/iree/modules/strings/CMakeLists.txt
index 8347aee..ab6bb69 100644
--- a/iree/modules/strings/CMakeLists.txt
+++ b/iree/modules/strings/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/modules/strings/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/modules/tensorlist/CMakeLists.txt b/iree/modules/tensorlist/CMakeLists.txt
index a2e9047..ca60589 100644
--- a/iree/modules/tensorlist/CMakeLists.txt
+++ b/iree/modules/tensorlist/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/modules/tensorlist/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/modules/vmla/CMakeLists.txt b/iree/modules/vmla/CMakeLists.txt
index 12da0d1..9bfa599 100644
--- a/iree/modules/vmla/CMakeLists.txt
+++ b/iree/modules/vmla/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/modules/vmla/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 if(NOT ${IREE_HAL_DRIVER_VMLA})
   return()
 endif()
diff --git a/iree/samples/CMakeLists.txt b/iree/samples/CMakeLists.txt
index 8b864e5..cf7bb89 100644
--- a/iree/samples/CMakeLists.txt
+++ b/iree/samples/CMakeLists.txt
@@ -1,15 +1,3 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/samples/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
diff --git a/iree/samples/custom_modules/CMakeLists.txt b/iree/samples/custom_modules/CMakeLists.txt
index 0e93972..cab086e 100644
--- a/iree/samples/custom_modules/CMakeLists.txt
+++ b/iree/samples/custom_modules/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/samples/custom_modules/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 if(NOT "${IREE_TARGET_BACKEND_VMLA}" OR
    NOT "${IREE_HAL_DRIVER_VMLA}")
   return()
diff --git a/iree/samples/custom_modules/dialect/CMakeLists.txt b/iree/samples/custom_modules/dialect/CMakeLists.txt
index f47b32b..adf437d 100644
--- a/iree/samples/custom_modules/dialect/CMakeLists.txt
+++ b/iree/samples/custom_modules/dialect/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/samples/custom_modules/dialect/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_TD LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.td)
diff --git a/iree/samples/custom_modules/dialect/test/CMakeLists.txt b/iree/samples/custom_modules/dialect/test/CMakeLists.txt
index 303f0ca..188f616 100644
--- a/iree/samples/custom_modules/dialect/test/CMakeLists.txt
+++ b/iree/samples/custom_modules/dialect/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/samples/custom_modules/dialect/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/samples/simple_embedding/CMakeLists.txt b/iree/samples/simple_embedding/CMakeLists.txt
index 01904c4..fe32455 100644
--- a/iree/samples/simple_embedding/CMakeLists.txt
+++ b/iree/samples/simple_embedding/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/samples/simple_embedding/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_bytecode_module(
diff --git a/iree/schemas/CMakeLists.txt b/iree/schemas/CMakeLists.txt
index d280e47..7ef70f1 100644
--- a/iree/schemas/CMakeLists.txt
+++ b/iree/schemas/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/schemas/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 flatbuffer_c_library(
diff --git a/iree/task/CMakeLists.txt b/iree/task/CMakeLists.txt
index d8be366..275e8a4 100644
--- a/iree/task/CMakeLists.txt
+++ b/iree/task/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/task/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/task/testing/CMakeLists.txt b/iree/task/testing/CMakeLists.txt
index 1134143..2cd7271 100644
--- a/iree/task/testing/CMakeLists.txt
+++ b/iree/task/testing/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/task/testing/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/test/CMakeLists.txt b/iree/test/CMakeLists.txt
index 15e9263..fb16aed 100644
--- a/iree/test/CMakeLists.txt
+++ b/iree/test/CMakeLists.txt
@@ -1,15 +1,3 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
diff --git a/iree/test/e2e/CMakeLists.txt b/iree/test/e2e/CMakeLists.txt
index 15e9263..18011a0 100644
--- a/iree/test/e2e/CMakeLists.txt
+++ b/iree/test/e2e/CMakeLists.txt
@@ -1,15 +1,3 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/test/e2e/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
diff --git a/iree/test/e2e/hackability/CMakeLists.txt b/iree/test/e2e/hackability/CMakeLists.txt
index e2b4157..6887b93 100644
--- a/iree/test/e2e/hackability/CMakeLists.txt
+++ b/iree/test/e2e/hackability/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/test/e2e/hackability/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/test/e2e/linalg_tensor_ops/CMakeLists.txt b/iree/test/e2e/linalg_tensor_ops/CMakeLists.txt
index 147ba39..00db9d5 100644
--- a/iree/test/e2e/linalg_tensor_ops/CMakeLists.txt
+++ b/iree/test/e2e/linalg_tensor_ops/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2021 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/test/e2e/linalg_tensor_ops/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/test/e2e/llvm_specific/CMakeLists.txt b/iree/test/e2e/llvm_specific/CMakeLists.txt
index cdaa26c..a708860 100644
--- a/iree/test/e2e/llvm_specific/CMakeLists.txt
+++ b/iree/test/e2e/llvm_specific/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/test/e2e/llvm_specific/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_check_single_backend_test_suite(
diff --git a/iree/test/e2e/models/CMakeLists.txt b/iree/test/e2e/models/CMakeLists.txt
index 9dfe6d1..27be36b 100644
--- a/iree/test/e2e/models/CMakeLists.txt
+++ b/iree/test/e2e/models/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/test/e2e/models/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/test/e2e/regression/CMakeLists.txt b/iree/test/e2e/regression/CMakeLists.txt
index 8f4a266..9395f1a 100644
--- a/iree/test/e2e/regression/CMakeLists.txt
+++ b/iree/test/e2e/regression/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/test/e2e/regression/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/test/e2e/structural/CMakeLists.txt b/iree/test/e2e/structural/CMakeLists.txt
index 4932aa1..78ceb40 100644
--- a/iree/test/e2e/structural/CMakeLists.txt
+++ b/iree/test/e2e/structural/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/test/e2e/structural/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/test/e2e/tosa_ops/CMakeLists.txt b/iree/test/e2e/tosa_ops/CMakeLists.txt
index 356c083..5ed89e9 100644
--- a/iree/test/e2e/tosa_ops/CMakeLists.txt
+++ b/iree/test/e2e/tosa_ops/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/test/e2e/tosa_ops/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/test/e2e/tosa_ops/clamp.mlir b/iree/test/e2e/tosa_ops/clamp.mlir
new file mode 100644
index 0000000..e5a215d
--- /dev/null
+++ b/iree/test/e2e/tosa_ops/clamp.mlir
@@ -0,0 +1,13 @@
+func @tensor_float() attributes { iree.module.export } {
+  %0 = iree.unfoldable_constant dense<[1.0, 0.0, 4.5, 2.0]> : tensor<4xf32>
+  %result = "tosa.clamp"(%0) {min_int = 1 : i64, max_int = 4 : i64, min_fp = 1.0 : f32, max_fp = 4.0 : f32} : (tensor<4xf32>) -> tensor<4xf32>
+  check.expect_almost_eq_const(%result, dense<[1.0, 1.0, 4.0, 2.0]> : tensor<4xf32>) : tensor<4xf32>
+  return
+}
+
+func @tensor_int() attributes { iree.module.export } {
+  %0 = iree.unfoldable_constant dense<[1, 0, 5, 2]> : tensor<4xi32>
+  %result = "tosa.clamp"(%0) {min_int = 1 : i64, max_int = 4 : i64, min_fp = 1.0 : f32, max_fp = 4.0 : f32} : (tensor<4xi32>) -> tensor<4xi32>
+  check.expect_eq_const(%result, dense<[1, 1, 4, 2]> : tensor<4xi32>) : tensor<4xi32>
+  return
+}
diff --git a/iree/test/e2e/tosa_ops/mul.mlir b/iree/test/e2e/tosa_ops/mul.mlir
new file mode 100644
index 0000000..9586683
--- /dev/null
+++ b/iree/test/e2e/tosa_ops/mul.mlir
@@ -0,0 +1,24 @@
+func @tensor_float() attributes { iree.module.export } {
+  %0 = iree.unfoldable_constant dense<[1.0, 0.0, 3.0, 4.0]> : tensor<4xf32>
+  %1 = iree.unfoldable_constant dense<[5.0, 6.0, -3.0, 8.0]> : tensor<4xf32>
+  %result = "tosa.mul"(%0, %1) {shift = 0 : i32} : (tensor<4xf32>, tensor<4xf32>) -> tensor<4xf32>
+  check.expect_almost_eq_const(%result, dense<[5.0, 0.0, -9.0, 32.0]> : tensor<4xf32>) : tensor<4xf32>
+  return
+}
+
+func @tensor_int() attributes { iree.module.export } {
+  %0 = iree.unfoldable_constant dense<[1, 0, 3, 4]> : tensor<4xi32>
+  %1 = iree.unfoldable_constant dense<[5, 6, -3, 8]> : tensor<4xi32>
+  %result = "tosa.mul"(%0, %1) {shift = 0 : i32} : (tensor<4xi32>, tensor<4xi32>) -> tensor<4xi32>
+  check.expect_eq_const(%result, dense<[5, 0, -9, 32]> : tensor<4xi32>) : tensor<4xi32>
+  return
+}
+
+func @tensor_int_shifted() attributes { iree.module.export } {
+  %0 = iree.unfoldable_constant dense<[1, 0, 3, 4]> : tensor<4xi32>
+  %1 = iree.unfoldable_constant dense<[5, 6, -3, 8]> : tensor<4xi32>
+  %result = "tosa.mul"(%0, %1) {shift = 1 : i32} : (tensor<4xi32>, tensor<4xi32>) -> tensor<4xi32>
+  check.expect_eq_const(%result, dense<[2, 0, -5, 16]> : tensor<4xi32>) : tensor<4xi32>
+  return
+}
+
diff --git a/iree/test/e2e/tosa_ops/negate.mlir b/iree/test/e2e/tosa_ops/negate.mlir
new file mode 100644
index 0000000..4c204f7
--- /dev/null
+++ b/iree/test/e2e/tosa_ops/negate.mlir
@@ -0,0 +1,13 @@
+func @tensor_float() attributes { iree.module.export } {
+  %0 = iree.unfoldable_constant dense<[-1.0, -0.5, 0.0, 1.0]> : tensor<4xf32>
+  %result = "tosa.negate"(%0) : (tensor<4xf32>) -> tensor<4xf32>
+  check.expect_almost_eq_const(%result, dense<[1.0, 0.5, 0.0, -1.0]> : tensor<4xf32>) : tensor<4xf32>
+  return
+}
+
+func @tensor_int() attributes { iree.module.export } {
+  %0 = iree.unfoldable_constant dense<[-1, 0, 3, 1]> : tensor<4xi32>
+  %result = "tosa.negate"(%0) : (tensor<4xi32>) -> tensor<4xi32>
+  check.expect_eq_const(%result, dense<[1, 0, -3, -1]> : tensor<4xi32>) : tensor<4xi32>
+  return
+}
diff --git a/iree/test/e2e/tosa_ops/reluN.mlir b/iree/test/e2e/tosa_ops/reluN.mlir
new file mode 100644
index 0000000..e444a32
--- /dev/null
+++ b/iree/test/e2e/tosa_ops/reluN.mlir
@@ -0,0 +1,13 @@
+func @tensor_float() attributes { iree.module.export } {
+  %0 = iree.unfoldable_constant dense<[1.0, -1.0, 3.0, 5.0]> : tensor<4xf32>
+  %result = "tosa.reluN"(%0) {max_fp = 4.0 : f32, max_int = 4 : i64} : (tensor<4xf32>) -> tensor<4xf32>
+  check.expect_almost_eq_const(%result, dense<[1.0, 0.0, 3.0, 4.0]> : tensor<4xf32>) : tensor<4xf32>
+  return
+}
+
+func @tensor_int() attributes { iree.module.export } {
+  %0 = iree.unfoldable_constant dense<[1, -1, 3, 5]> : tensor<4xi32>
+  %result = "tosa.reluN"(%0) {max_fp = 4.0 : f32, max_int = 4 : i64} : (tensor<4xi32>) -> tensor<4xi32>
+  check.expect_eq_const(%result, dense<[1, 0, 3, 4]> : tensor<4xi32>) : tensor<4xi32>
+  return
+}
diff --git a/iree/test/e2e/tosa_ops/rsqrt.mlir b/iree/test/e2e/tosa_ops/rsqrt.mlir
new file mode 100644
index 0000000..ee958ea
--- /dev/null
+++ b/iree/test/e2e/tosa_ops/rsqrt.mlir
@@ -0,0 +1,6 @@
+func @tensor_float() attributes { iree.module.export } {
+  %0 = iree.unfoldable_constant dense<[16.0, 4.0, 9.0, 1.0]> : tensor<4xf32>
+  %result = "tosa.rsqrt"(%0) : (tensor<4xf32>) -> tensor<4xf32>
+  check.expect_almost_eq_const(%result, dense<[0.25, 0.5, 0.3333, 1.0]> : tensor<4xf32>) : tensor<4xf32>
+  return
+}
diff --git a/iree/test/e2e/tosa_ops/select.mlir b/iree/test/e2e/tosa_ops/select.mlir
new file mode 100644
index 0000000..331ad82
--- /dev/null
+++ b/iree/test/e2e/tosa_ops/select.mlir
@@ -0,0 +1,17 @@
+func @tensor_float() attributes { iree.module.export } {
+  %0 = iree.unfoldable_constant dense<[0, 0, 1, 1]> : tensor<4xi1>
+  %1 = iree.unfoldable_constant dense<[1.0, 5.0, 3.0, 4.0]> : tensor<4xf32>
+  %2 = iree.unfoldable_constant dense<[5.0, 1.0, 3.0, 1.5]> : tensor<4xf32>
+  %result = "tosa.select"(%0, %1, %2) : (tensor<4xi1>, tensor<4xf32>, tensor<4xf32>) -> tensor<4xf32>
+  check.expect_almost_eq_const(%result, dense<[5.0, 1.0, 3.0, 4.0]> : tensor<4xf32>) : tensor<4xf32>
+  return
+}
+
+func @tensor_int() attributes { iree.module.export } {
+  %0 = iree.unfoldable_constant dense<[0, 0, 1, 1]> : tensor<4xi1>
+  %1 = iree.unfoldable_constant dense<[1, 5, 3, 4]> : tensor<4xi32>
+  %2 = iree.unfoldable_constant dense<[5, 1, 3, 1]> : tensor<4xi32>
+  %result = "tosa.select"(%0, %1, %2) : (tensor<4xi1>, tensor<4xi32>, tensor<4xi32>) -> tensor<4xi32>
+  check.expect_eq_const(%result, dense<[5, 1, 3, 4]> : tensor<4xi32>) : tensor<4xi32>
+  return
+}
diff --git a/iree/test/e2e/vulkan_specific/CMakeLists.txt b/iree/test/e2e/vulkan_specific/CMakeLists.txt
index b4b5198..1514d38 100644
--- a/iree/test/e2e/vulkan_specific/CMakeLists.txt
+++ b/iree/test/e2e/vulkan_specific/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/test/e2e/vulkan_specific/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/test/e2e/xla_ops/CMakeLists.txt b/iree/test/e2e/xla_ops/CMakeLists.txt
index 1fda8a4..9fdbbd8 100644
--- a/iree/test/e2e/xla_ops/CMakeLists.txt
+++ b/iree/test/e2e/xla_ops/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/test/e2e/xla_ops/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/test/e2e/xla_ops/partial/CMakeLists.txt b/iree/test/e2e/xla_ops/partial/CMakeLists.txt
index 43b2bba..3042daf 100644
--- a/iree/test/e2e/xla_ops/partial/CMakeLists.txt
+++ b/iree/test/e2e/xla_ops/partial/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2021 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/test/e2e/xla_ops/partial/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/testing/CMakeLists.txt b/iree/testing/CMakeLists.txt
index 850f287..ebc350c 100644
--- a/iree/testing/CMakeLists.txt
+++ b/iree/testing/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/testing/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/tools/BUILD b/iree/tools/BUILD
index 46b45fa..66f8188 100644
--- a/iree/tools/BUILD
+++ b/iree/tools/BUILD
@@ -180,8 +180,10 @@
         "IREE_HAVE_VMLA_TARGET",
         "IREE_HAVE_VULKANSPIRV_TARGET",
         "IREE_HAVE_METALSPIRV_TARGET",
+        "IREE_HAVE_CUDA_TARGET",
     ],
     deps = [
+        "//iree/compiler/Dialect/HAL/Target/CUDA",
         "//iree/compiler/Dialect/HAL/Target/LLVM",
         "//iree/compiler/Dialect/HAL/Target/MetalSPIRV",
         "//iree/compiler/Dialect/HAL/Target/VMLA",
diff --git a/iree/tools/CMakeLists.txt b/iree/tools/CMakeLists.txt
index fc141a1..73ea65f 100644
--- a/iree/tools/CMakeLists.txt
+++ b/iree/tools/CMakeLists.txt
@@ -37,6 +37,10 @@
   list(APPEND IREE_COMPILER_TARGETS iree::compiler::Dialect::HAL::Target::VulkanSPIRV)
   list(APPEND IREE_COMPILER_TARGET_COPTS "-DIREE_HAVE_VULKANSPIRV_TARGET")
 endif()
+if("${IREE_TARGET_BACKEND_CUDA}")
+  list(APPEND IREE_COMPILER_TARGETS iree::compiler::Dialect::HAL::Target::CUDA)
+  list(APPEND IREE_COMPILER_TARGET_COPTS "-DIREE_HAVE_CUDA_TARGET")
+endif()
 
 if(IREE_ENABLE_EMITC)
   set(IREE_OPT_CONDITIONAL_DEPS
diff --git a/iree/tools/init_targets.cc b/iree/tools/init_targets.cc
index 6b17648..7231886 100644
--- a/iree/tools/init_targets.cc
+++ b/iree/tools/init_targets.cc
@@ -26,6 +26,9 @@
 #ifdef IREE_HAVE_VULKANSPIRV_TARGET
 #include "iree/compiler/Dialect/HAL/Target/VulkanSPIRV/VulkanSPIRVTarget.h"
 #endif
+#ifdef IREE_HAVE_CUDA_TARGET
+#include "iree/compiler/Dialect/HAL/Target/CUDA/CUDATarget.h"
+#endif
 
 namespace mlir {
 namespace iree_compiler {
@@ -53,6 +56,10 @@
     IREE::HAL::registerVulkanSPIRVTargetBackends(
         []() { return IREE::HAL::getVulkanSPIRVTargetOptionsFromFlags(); });
 #endif
+#ifdef IREE_HAVE_CUDA_TARGET
+    IREE::HAL::registerCUDATargetBackends(
+        []() { return IREE::HAL::getCUDATargetOptionsFromFlags(); });
+#endif
     return true;
   }();
   (void)init_once;
diff --git a/iree/tools/test/CMakeLists.txt b/iree/tools/test/CMakeLists.txt
index 331fd76..17c99b1 100644
--- a/iree/tools/test/CMakeLists.txt
+++ b/iree/tools/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/tools/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 file(GLOB _GLOB_X_MLIR LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS *.mlir)
diff --git a/iree/tools/utils/CMakeLists.txt b/iree/tools/utils/CMakeLists.txt
index 36114b4..095131a 100644
--- a/iree/tools/utils/CMakeLists.txt
+++ b/iree/tools/utils/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/tools/utils/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/vm/CMakeLists.txt b/iree/vm/CMakeLists.txt
index 35c845a..4a323b1 100644
--- a/iree/vm/CMakeLists.txt
+++ b/iree/vm/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/vm/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 iree_cc_library(
diff --git a/iree/vm/bytecode_dispatch.c b/iree/vm/bytecode_dispatch.c
index abdc9dd..7ab1301 100644
--- a/iree/vm/bytecode_dispatch.c
+++ b/iree/vm/bytecode_dispatch.c
@@ -656,9 +656,9 @@
             module_state->rwdata_storage.data_length);
       }
       int32_t* value = VM_DecResultRegI32("value");
-      const int32_t* global_ptr =
-          (const int32_t*)(module_state->rwdata_storage.data + byte_offset);
-      *value = *global_ptr;
+      const int32_t global_value =
+          vm_global_load_i32(module_state->rwdata_storage.data, byte_offset);
+      *value = global_value;
     });
 
     DISPATCH_OP(CORE, GlobalStoreI32, {
@@ -671,9 +671,8 @@
             module_state->rwdata_storage.data_length);
       }
       int32_t value = VM_DecOperandRegI32("value");
-      int32_t* global_ptr =
-          (int32_t*)(module_state->rwdata_storage.data + byte_offset);
-      *global_ptr = value;
+      vm_global_store_i32(module_state->rwdata_storage.data, byte_offset,
+                          value);
     });
 
     DISPATCH_OP(CORE, GlobalLoadIndirectI32, {
@@ -686,9 +685,9 @@
             module_state->rwdata_storage.data_length);
       }
       int32_t* value = VM_DecResultRegI32("value");
-      const int32_t* global_ptr =
-          (const int32_t*)(module_state->rwdata_storage.data + byte_offset);
-      *value = *global_ptr;
+      const int32_t global_value =
+          vm_global_load_i32(module_state->rwdata_storage.data, byte_offset);
+      *value = global_value;
     });
 
     DISPATCH_OP(CORE, GlobalStoreIndirectI32, {
@@ -701,9 +700,8 @@
             module_state->rwdata_storage.data_length);
       }
       int32_t value = VM_DecOperandRegI32("value");
-      int32_t* global_ptr =
-          (int32_t*)(module_state->rwdata_storage.data + byte_offset);
-      *global_ptr = value;
+      vm_global_store_i32(module_state->rwdata_storage.data, byte_offset,
+                          value);
     });
 
     DISPATCH_OP(CORE, GlobalLoadRef, {
diff --git a/iree/vm/ops.h b/iree/vm/ops.h
index 0e62a51..453f376 100644
--- a/iree/vm/ops.h
+++ b/iree/vm/ops.h
@@ -18,6 +18,21 @@
 #include <stdint.h>
 
 //===------------------------------------------------------------------===//
+// Globals
+//===------------------------------------------------------------------===//
+
+static inline int32_t vm_global_load_i32(uint8_t* base, uint32_t byte_offset) {
+  const int32_t* global_ptr = (const int32_t*)(base + byte_offset);
+  return *global_ptr;
+}
+
+static inline void vm_global_store_i32(uint8_t* base, uint32_t byte_offset,
+                                       int32_t value) {
+  int32_t* global_ptr = (int32_t*)(base + byte_offset);
+  *global_ptr = value;
+}
+
+//===------------------------------------------------------------------===//
 // Constants
 //===------------------------------------------------------------------===//
 
@@ -120,11 +135,12 @@
 //===------------------------------------------------------------------===//
 // Check ops
 // TODO(simon-camp): These macros should be removed once control flow ops are
-// supported in the c module target
+// supported in the c module target.
+// Note that this will fail if message contains a comma
 #define VM_CHECK_EQ(a, b, message)                                          \
   if (a != b) {                                                             \
     return iree_status_allocate(IREE_STATUS_FAILED_PRECONDITION, "<vm>", 0, \
-                                iree_make_cstring_view("message"));         \
+                                iree_make_cstring_view(#message));          \
   }
 
 //===------------------------------------------------------------------===//
diff --git a/iree/vm/test/BUILD b/iree/vm/test/BUILD
index ac52126..47bb1b0 100644
--- a/iree/vm/test/BUILD
+++ b/iree/vm/test/BUILD
@@ -42,6 +42,7 @@
         ":control_flow_ops.vmfb",
         ":conversion_ops.vmfb",
         ":conversion_ops_i64.vmfb",
+        ":global_ops.vmfb",
         ":list_ops.vmfb",
         ":shift_ops.vmfb",
         ":shift_ops_i64.vmfb",
@@ -97,6 +98,14 @@
 iree_bytecode_module(
     name = "conversion_ops_i64",
     src = "conversion_ops_i64.mlir",
+    cc_namespace = "iree::vm::test",
+    flags = ["-iree-vm-ir-to-bytecode-module"],
+)
+
+iree_bytecode_module(
+    name = "global_ops",
+    src = "global_ops.mlir",
+    cc_namespace = "iree::vm::test",
     flags = ["-iree-vm-ir-to-bytecode-module"],
 )
 
diff --git a/iree/vm/test/CMakeLists.txt b/iree/vm/test/CMakeLists.txt
index a6546c6..425dbbb 100644
--- a/iree/vm/test/CMakeLists.txt
+++ b/iree/vm/test/CMakeLists.txt
@@ -1,17 +1,5 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
+# Autogenerated from iree/vm/test/BUILD by
+# build_tools/bazel_to_cmake/bazel_to_cmake.py
 iree_add_all_subdirs()
 
 if (NOT ${IREE_BUILD_COMPILER} OR NOT ${IREE_BUILD_TESTS})
@@ -30,6 +18,7 @@
     "control_flow_ops.vmfb"
     "conversion_ops.vmfb"
     "conversion_ops_i64.vmfb"
+    "global_ops.vmfb"
     "list_ops.vmfb"
     "shift_ops.vmfb"
     "shift_ops_i64.vmfb"
@@ -118,6 +107,20 @@
     conversion_ops_i64
   SRC
     "conversion_ops_i64.mlir"
+  CC_NAMESPACE
+    "iree::vm::test"
+  FLAGS
+    "-iree-vm-ir-to-bytecode-module"
+  PUBLIC
+)
+
+iree_bytecode_module(
+  NAME
+    global_ops
+  SRC
+    "global_ops.mlir"
+  CC_NAMESPACE
+    "iree::vm::test"
   FLAGS
     "-iree-vm-ir-to-bytecode-module"
   PUBLIC
diff --git a/iree/vm/test/emitc/CMakeLists.txt b/iree/vm/test/emitc/CMakeLists.txt
index d4ff381..da6234d 100644
--- a/iree/vm/test/emitc/CMakeLists.txt
+++ b/iree/vm/test/emitc/CMakeLists.txt
@@ -36,6 +36,7 @@
     ::assignment_ops_i64_cc
     ::conversion_ops_cc
     ::conversion_ops_i64_cc
+    ::global_ops_cc
     ::shift_ops_cc
     ::shift_ops_i64_cc
 )
@@ -114,6 +115,18 @@
 
 iree_bytecode_module(
   NAME
+    global_ops
+  SRC
+    "../global_ops.mlir"
+  CC_NAMESPACE
+    "iree::vm::test::emitc"
+  FLAGS
+    "-iree-vm-ir-to-c-module"
+  PUBLIC
+)
+
+iree_bytecode_module(
+  NAME
     shift_ops
   SRC
     "../shift_ops.mlir"
diff --git a/iree/vm/test/emitc/module_test.cc b/iree/vm/test/emitc/module_test.cc
index 0c664ea..a834160 100644
--- a/iree/vm/test/emitc/module_test.cc
+++ b/iree/vm/test/emitc/module_test.cc
@@ -24,6 +24,7 @@
 #include "iree/vm/test/emitc/assignment_ops_i64.vmfb"
 #include "iree/vm/test/emitc/conversion_ops.vmfb"
 #include "iree/vm/test/emitc/conversion_ops_i64.vmfb"
+#include "iree/vm/test/emitc/global_ops.vmfb"
 #include "iree/vm/test/emitc/shift_ops.vmfb"
 #include "iree/vm/test/emitc/shift_ops_i64.vmfb"
 
@@ -58,6 +59,7 @@
       {assignment_ops_i64_descriptor_, assignment_ops_i64_create},
       {conversion_ops_descriptor_, conversion_ops_create},
       {conversion_ops_i64_descriptor_, conversion_ops_i64_create},
+      {global_ops_descriptor_, global_ops_create},
       {shift_ops_descriptor_, shift_ops_create},
       {shift_ops_i64_descriptor_, shift_ops_i64_create}};
 
diff --git a/iree/vm/test/global_ops.mlir b/iree/vm/test/global_ops.mlir
new file mode 100644
index 0000000..44d07b7
--- /dev/null
+++ b/iree/vm/test/global_ops.mlir
@@ -0,0 +1,28 @@
+vm.module @global_ops {
+
+  //===--------------------------------------------------------------------===//
+  // global.i32
+  //===--------------------------------------------------------------------===//
+
+  vm.global.i32 @c42 42 : i32
+  vm.global.i32 @c107_mut mutable 107 : i32
+  // TODO(simon-camp): Add test for initializer
+
+  vm.export @test_global_load_i32
+  vm.func @test_global_load_i32() {
+    %actual = vm.global.load.i32 @c42 : i32
+    %expected = vm.const.i32 42 : i32
+    vm.check.eq %actual, %expected, "@c42 != 42" : i32
+    vm.return
+  }
+
+  vm.export @test_global_store_i32
+  vm.func @test_global_store_i32() {
+    %c17 = vm.const.i32 17 : i32
+    vm.global.store.i32 %c17, @c107_mut : i32
+    %actual = vm.global.load.i32 @c107_mut : i32
+    vm.check.eq %actual, %c17, "@c107_mut != 17" : i32
+    vm.return
+  }
+
+}
diff --git a/scripts/git/update_to_llvm_syncpoint.py b/scripts/git/update_to_llvm_syncpoint.py
index ccc9d90..e67b584 100755
--- a/scripts/git/update_to_llvm_syncpoint.py
+++ b/scripts/git/update_to_llvm_syncpoint.py
@@ -56,7 +56,7 @@
         "Update to the most recent commit with a matching version of LLVM",
 }
 
-TF_WORKSPACE_FILEPATH = "tensorflow/workspace.bzl"
+TF_LLVM_WORKSPACE_FILEPATH = "third_party/llvm/workspace.bzl"
 TF_WORKSPACE_LLVM_COMMIT_REGEXP = re.compile(
     r"""\s*LLVM_COMMIT\s*=\s*"(.+)"\s*""", flags=re.MULTILINE)
 MLIR_HLO_LLVM_VERSION_FILEPATH = "build_tools/llvm_version.txt"
@@ -161,7 +161,7 @@
 
   # Update TensorFlow
   new_tf_commit = find_new_commit_from_version_file(args.tensorflow_path,
-                                                    TF_WORKSPACE_FILEPATH,
+                                                    TF_LLVM_WORKSPACE_FILEPATH,
                                                     current_llvm_commit,
                                                     args.tensorflow_rev)
   print("\n*** Updating TensorFlow to", new_tf_commit, "***")
@@ -328,7 +328,7 @@
   # TensorFlow keeps its commit in workspace.bzl on a line like:
   # LLVM_COMMIT = "..."
   # Yeah. This is how we do it.
-  workspace_path = os.path.join(tensorflow_path, TF_WORKSPACE_FILEPATH)
+  workspace_path = os.path.join(tensorflow_path, TF_LLVM_WORKSPACE_FILEPATH)
 
   for line in open(workspace_path, "r", encoding="UTF-8"):
     m = re.match(TF_WORKSPACE_LLVM_COMMIT_REGEXP, line)