Create explicit compiler C API libraries and enable dynamic linking on all platforms (#11285)

This is the first step of a multi-part sequence that will:

* Rebuild the compiler/API directory into its final form.
* Move the compiler python API to its correct location
(bindings/python).
* Enable dynamic linking project wide of all compiler tools.

This first step leaves the following undone:

* Python API stays where it is (there are a lot of fiddly path
dependencies there and I opted to handle that in isolation).
* Sets everything up in an API2 which will eventually be renamed to API.
* Just gets the stub of what is needed for a delay loaded embedding API
-- the full thing will follow and be integrated into PJRT for Jax and
TensorFlow serving on the OSS side.
* The project local lld is still building static, even though the API
includes it in the shared library. Was just trying to keep the patch
size down vs there being a fundamental problem.

In the new state, there is a libIREECompiler.so.0 (or IREECompiler.dll
on Windows) which contains both the in-process APIs and the tool
entry-points. The following tools have been reworked to link against the
shared library:

* iree-compile
* iree-lld (Python side only)
* iree-opt
* iree-mlir-lsp-server

In addition, some API tests which were doing expensive static linking
now link dynamically. All said, this saves ~4-5x multi-gigabyte compiler
tool linking steps and should be a pretty substantial build iteration
improvement. I wasn't originally going to include iree-opt and
iree-mlir-lsp-server in the shared build, but based on an experiment,
they contribute negligible size (really just a few extra source files
when linked together), and the productivity and usability savings (i.e.
we can now distribute those at negligible cost) made me decide it was
worth it.

I don't know what to do about iree-run-mlir. I think I can refactor it
into something based on the compiler API that then links the runtime.
But that is for later.

I took some steps to ensure this will work on Windows and MacOS but
haven't finished verifying.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 696c991..3754730 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -647,6 +647,11 @@
     # rules that really should have them in the first place.
     target_include_directories(LLVMSupport PUBLIC ${_COMMON_INCLUDE_DIRS})
     target_include_directories(MLIRSupport PUBLIC ${_COMMON_INCLUDE_DIRS})
+
+    # Also add a library that can be depended on to get LLVM includes setup
+    # properly. bazel_to_cmake targets this for some header only pseudo deps.
+    add_library(IREELLVMIncludeSetup INTERFACE)
+    target_include_directories(IREELLVMIncludeSetup INTERFACE ${_COMMON_INCLUDE_DIRS})
   endfunction()
   _hack_llvm_include_paths()
 endif()
diff --git a/build_tools/bazel/build_defs.oss.bzl b/build_tools/bazel/build_defs.oss.bzl
index 011e915..80805f4 100644
--- a/build_tools/bazel/build_defs.oss.bzl
+++ b/build_tools/bazel/build_defs.oss.bzl
@@ -59,6 +59,19 @@
         **kwargs
     )
 
+def iree_compiler_cc_test(deps = [], **kwargs):
+    """Used for cc_test targets within the //compiler tree.
+
+    This is a pass-through to the native cc_test which adds specific
+    runtime specific options and deps.
+    """
+    native.cc_test(
+        deps = deps + [
+            "//compiler/src:defs",
+        ],
+        **kwargs
+    )
+
 def iree_runtime_cc_library(deps = [], **kwargs):
     """Used for cc_library targets within the //runtime tree.
 
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 bc5252e..a5eddee 100644
--- a/build_tools/bazel_to_cmake/bazel_to_cmake_converter.py
+++ b/build_tools/bazel_to_cmake/bazel_to_cmake_converter.py
@@ -206,6 +206,9 @@
   # ------------------------------------------------------------------------- #
 
   # Functions with no mapping to CMake. Just ignore these.
+  def alias(self, *args, **kwargs):
+    pass
+
   def load(self, *args, **kwargs):
     pass
 
@@ -371,6 +374,9 @@
   def iree_runtime_cc_test(self, deps=[], **kwargs):
     self.cc_test(deps=deps + ["//runtime/src:runtime_defines"], **kwargs)
 
+  def iree_compiler_cc_test(self, deps=[], **kwargs):
+    self.cc_test(deps=deps + ["//compiler/src:defs"], **kwargs)
+
   def cc_binary(self,
                 name,
                 srcs=None,
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 2474cc4..8b7b3ae 100644
--- a/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py
+++ b/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py
@@ -17,9 +17,7 @@
     "//runtime/src:runtime_defines": [],
 
     # IREE llvm-external-projects
-    "//llvm-external-projects/iree-dialects:IREEPyDMTransforms": [
-        "IREEPyDMPasses"
-    ],
+    "//llvm-external-projects/iree-dialects:CAPI": ["IREEDialectsCAPI"],
 
     # Disable all hard-coded codegen targets (they are expanded dynamically
     # in CMake).
@@ -34,10 +32,17 @@
     "@llvm-project//llvm:X86AsmParser": ["IREELLVMCPUTargetDeps"],
     "@llvm-project//llvm:X86CodeGen": ["IREELLVMCPUTargetDeps"],
 
+    # LLD
+    "@llvm-project//lld": ["${IREE_LLD_TARGET}"],
+    "@llvm-project//lld:COFF": ["lldCOFF"],
+    "@llvm-project//lld:Common": ["lldCommon"],
+    "@llvm-project//lld:ELF": ["lldELF"],
+    "@llvm-project//lld:MachO": ["lldMachO"],
+    "@llvm-project//lld:Wasm": ["lldWasm"],
+
     # LLVM
     "@llvm-project//llvm:config": [],
     "@llvm-project//llvm:IPO": ["LLVMipo"],
-    "@llvm-project//lld": ["${IREE_LLD_TARGET}"],
     "@llvm-project//llvm:FileCheck": ["FileCheck"],
     "@llvm-project//llvm:not": ["not"],
     # MLIR
@@ -51,6 +56,7 @@
     "@llvm-project//mlir:ShapeTransforms": ["MLIRShapeOpsTransforms"],
     "@llvm-project//mlir:ToLLVMIRTranslation": ["MLIRTargetLLVMIRExport"],
     "@llvm-project//mlir:mlir-translate": ["mlir-translate"],
+    "@llvm-project//mlir:MlirLspServerLib": ["MLIRLspServerLib"],
     "@llvm-project//mlir:MlirTableGenMain": ["MLIRTableGen"],
     "@llvm-project//mlir:MlirOptLib": ["MLIROptLib"],
     "@llvm-project//mlir:VectorOps": ["MLIRVector"],
@@ -125,7 +131,14 @@
   # Take "MLIR" and append the name part of the full target identifier, e.g.
   #   "@llvm-project//mlir:IR"   -> "MLIRIR"
   #   "@llvm-project//mlir:Pass" -> "MLIRPass"
-  return ["MLIR" + target.rsplit(":")[-1]]
+  # MLIR does not have header-only targets apart from the libraries. Here
+  # we redirect any request for a CAPI{Name}Headers to a target within IREE
+  # that sets this up.
+  label = target.rsplit(":")[-1]
+  if label.startswith("CAPI") and label.endswith("Headers"):
+    return [f"IREELLVMIncludeSetup"]
+  else:
+    return [f"MLIR{label}"]
 
 
 def _convert_llvm_target(target):
diff --git a/build_tools/cmake/iree_cc_binary.cmake b/build_tools/cmake/iree_cc_binary.cmake
index c89d802..f350fc6 100644
--- a/build_tools/cmake/iree_cc_binary.cmake
+++ b/build_tools/cmake/iree_cc_binary.cmake
@@ -20,6 +20,8 @@
 # LINKOPTS: List of link options
 # TESTONLY: for testing; won't compile when tests are disabled
 # HOSTONLY: host only; compile using host toolchain when cross-compiling
+# SETUP_INSTALL_RPATH: Sets an install RPATH which assumes the standard
+#   directory layout (to be used if linking against installed shared libs).
 #
 # Note:
 # iree_cc_binary will create a binary called ${PACKAGE_NAME}_${NAME}, e.g.
@@ -47,7 +49,7 @@
 function(iree_cc_binary)
   cmake_parse_arguments(
     _RULE
-    "EXCLUDE_FROM_ALL;HOSTONLY;TESTONLY"
+    "EXCLUDE_FROM_ALL;HOSTONLY;TESTONLY;SETUP_INSTALL_RPATH"
     "NAME"
     "SRCS;COPTS;DEFINES;LINKOPTS;DATA;DEPS"
     ${ARGN}
@@ -151,4 +153,27 @@
       COMPONENT ${_RULE_NAME}
       RUNTIME DESTINATION bin)
   endif()
+
+  # Setup RPATH if on a Unix-like system. We have two use cases that we are
+  # handling here:
+  #   1. Install tree layouts like bin/ and lib/ directories that are
+  #      peers.
+  #   2. Single directory bundles (language bindings do this) where the
+  #      shared library is placed next to the consumer.
+  #
+  # The common solution is to use an RPATH of the origin and the
+  # lib/ directory that may be a peer of the origin. Distributions
+  # outside of this setup will need to do their own manipulation.
+  if(_RULE_SETUP_INSTALL_RPATH)
+    if(APPLE OR UNIX)
+      set(_origin_prefix "\$ORIGIN")
+      if(APPLE)
+        set(_origin_prefix "@loader_path")
+      endif()
+      set_target_properties(${_NAME} PROPERTIES
+        BUILD_WITH_INSTALL_RPATH OFF
+        INSTALL_RPATH "${_origin_prefix}:${_origin_prefix}/../lib"
+      )
+    endif()
+  endif()
 endfunction()
diff --git a/build_tools/cmake/iree_cc_library.cmake b/build_tools/cmake/iree_cc_library.cmake
index f861b80..2fbbd71 100644
--- a/build_tools/cmake/iree_cc_library.cmake
+++ b/build_tools/cmake/iree_cc_library.cmake
@@ -25,7 +25,7 @@
 # Also in IDE, target will appear in IREE folder while non PUBLIC will be in IREE/internal.
 # TESTONLY: When added, this target will only be built if user passes -DIREE_BUILD_TESTS=ON to CMake.
 # SHARED: If set, will compile to a shared object.
-#
+# WINDOWS_DEF_FILE: If set, will add a windows .def file to a shared library link
 # Note:
 # By default, iree_cc_library will always create a library named iree_${NAME},
 # and alias target iree::${NAME}. The iree:: form should always be used.
@@ -61,7 +61,7 @@
   cmake_parse_arguments(
     _RULE
     "PUBLIC;TESTONLY;SHARED"
-    "NAME"
+    "NAME;WINDOWS_DEF_FILE"
     "HDRS;TEXTUAL_HDRS;SRCS;COPTS;DEFINES;LINKOPTS;DATA;DEPS;INCLUDES"
     ${ARGN}
   )
@@ -109,8 +109,14 @@
     add_library(${_OBJECTS_NAME} OBJECT)
     if(_RULE_SHARED)
       add_library(${_NAME} SHARED "$<TARGET_OBJECTS:${_OBJECTS_NAME}>")
+      if(_RULE_WINDOWS_DEF_FILE AND WIN32)
+        target_sources(${_NAME} PRIVATE "${_RULE_WINDOWS_DEF_FILE}")
+      endif()
     else()
       add_library(${_NAME} STATIC "$<TARGET_OBJECTS:${_OBJECTS_NAME}>")
+      if(_RULE_WINDOWS_DEF_FILE AND WIN32)
+        message(SEND_ERROR "If specifying a .def file library must be shared")
+      endif()
     endif()
 
     # Sources get added to the object library.
diff --git a/compiler/setup.py b/compiler/setup.py
index 602994a..e71787a 100644
--- a/compiler/setup.py
+++ b/compiler/setup.py
@@ -228,6 +228,9 @@
         "-GNinja",
         "--log-level=VERBOSE",
         "-DIREE_BUILD_PYTHON_BINDINGS=ON",
+        # Disable .so.0 style symlinking. Python wheels don't preserve links,
+        # so this ~doubles the binary size if not disabled (yikes!).
+        "-DCMAKE_PLATFORM_NO_VERSIONED_SONAME=ON",
         "-DPython3_EXECUTABLE={}".format(sys.executable),
         "-DCMAKE_BUILD_TYPE={}".format(cfg),
         get_env_cmake_option("IREE_TARGET_BACKEND_CUDA"),
@@ -251,16 +254,13 @@
       print(f"Not re-configuring (already configured)", file=sys.stderr)
 
     # Build.
-    subprocess.check_call([
-        "cmake", "--build", ".", "--target",
-        "compiler/src/iree/compiler/API/python/all"
-    ],
+    subprocess.check_call(["cmake", "--build", ".", "--target", "compiler/all"],
                           cwd=IREE_BINARY_DIR)
     print("Build complete.", file=sys.stderr)
 
-  # Install the directory we care about.
-  install_subdirectory = os.path.join(IREE_BINARY_DIR, "compiler", "src",
-                                      "iree", "compiler", "API", "python")
+  # Perform installation on the entire compiler/ tree as this is guaranteed
+  # to have all of our installation targets.
+  install_subdirectory = os.path.join(IREE_BINARY_DIR, "compiler")
   install_args = [
       "-DCMAKE_INSTALL_DO_STRIP=ON",
       f"-DCMAKE_INSTALL_PREFIX={CMAKE_INSTALL_DIR_ABS}",
diff --git a/compiler/src/iree/compiler/API/BUILD b/compiler/src/iree/compiler/API/BUILD
index f569d92..7bccd38 100644
--- a/compiler/src/iree/compiler/API/BUILD
+++ b/compiler/src/iree/compiler/API/BUILD
@@ -4,8 +4,6 @@
 # See https://llvm.org/LICENSE.txt for license information.
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
-load("//build_tools/bazel:build_defs.oss.bzl", "iree_compiler_cc_library")
-
 package(
     default_visibility = ["//visibility:public"],
     features = ["layering_check"],
@@ -51,40 +49,3 @@
         "python/test/tools/testdata/*",
     ]),
 )
-
-################################################################################
-# CAPI
-################################################################################
-
-iree_compiler_cc_library(
-    name = "CAPI",
-    srcs = [
-        "Compiler.cpp",
-        "Lld.cpp",
-        "Tools.cpp",
-    ],
-    hdrs = [
-        "Compiler.h",
-        "Tools.h",
-    ],
-    deps = [
-        "//compiler/src/iree/compiler/ConstEval",
-        "//compiler/src/iree/compiler/Dialect/VM/IR",
-        "//compiler/src/iree/compiler/Dialect/VM/Target:init_targets",
-        "//compiler/src/iree/compiler/Dialect/VM/Target/Bytecode",
-        "//compiler/src/iree/compiler/Pipelines",
-        "//compiler/src/iree/compiler/Tools:init_llvmir_translations",
-        "//compiler/src/iree/compiler/Tools:init_passes_and_dialects",
-        "//compiler/src/iree/compiler/Tools:init_targets",
-        "//compiler/src/iree/compiler/Tools:iree_compile_lib",
-        "//compiler/src/iree/compiler/Utils",
-        "@llvm-project//lld:COFF",
-        "@llvm-project//lld:Common",
-        "@llvm-project//lld:ELF",
-        "@llvm-project//lld:MachO",
-        "@llvm-project//lld:Wasm",
-        "@llvm-project//llvm:Support",
-        "@llvm-project//mlir:CAPIIR",
-        "@llvm-project//mlir:IR",
-    ],
-)
diff --git a/compiler/src/iree/compiler/API/CMakeLists.txt b/compiler/src/iree/compiler/API/CMakeLists.txt
index 7d811ab..2471e24 100644
--- a/compiler/src/iree/compiler/API/CMakeLists.txt
+++ b/compiler/src/iree/compiler/API/CMakeLists.txt
@@ -33,37 +33,6 @@
   )
 endif()
 
-add_mlir_public_c_api_library(IREECompilerCAPILib
-  Compiler.cpp
-  Tools.cpp
-  ${_OPTIONAL_SOURCES}
-  PARTIAL_SOURCES_INTENDED
-  # TODO: If installing, complains about IREEVM not being in any export set.
-  DISABLE_INSTALL
-  LINK_COMPONENTS
-    Support
-  LINK_LIBS PUBLIC
-    MLIRIR
-    iree::compiler::ConstEval
-    iree::compiler::Dialect::VM::IR::IR
-    iree::compiler::Dialect::VM::Target::init_targets
-    iree::compiler::Pipelines
-
-    # Passes and dialects.
-    iree::compiler::Tools::init_llvmir_translations
-    iree::compiler::Tools::init_passes_and_dialects
-
-    # All HAL Targets.
-    iree::compiler::Tools::init_targets
-
-    # Tools.
-    iree::compiler::Tools::iree_compile_lib
-
-    ${_OPTIONAL_LINK_LIBS}
-)
-
-add_subdirectory(test)
-
 ################################################################################
 # Language specific bindings.
 # These have an ordering dependency on the backing CAPI being defined.
diff --git a/compiler/src/iree/compiler/API/README.md b/compiler/src/iree/compiler/API/README.md
index 3503f5b..08f8fe8 100644
--- a/compiler/src/iree/compiler/API/README.md
+++ b/compiler/src/iree/compiler/API/README.md
@@ -1,11 +1,4 @@
-# IREE Compiler Backend
+# IREE Compiler API (deprecated)
 
-This is a top-level project for building public facing API packages that
-combine all dependent MLIR-based projects along with IREE's compiler backend
-API.
-
-It exports artifacts:
-
-* `iree-compiler-backend` Python wheel and source distributions, providing
-  the `iree.compiler_backend` Python packages.
-* Compiler C-API source and binary tarballs (future), with some CLI tools.
+This directory is being refactored into API2. Currently, it only contains
+the Python bindings, which will be moved soon.
diff --git a/compiler/src/iree/compiler/API/Tools.h b/compiler/src/iree/compiler/API/Tools.h
deleted file mode 100644
index 3dec5fb..0000000
--- a/compiler/src/iree/compiler/API/Tools.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2021 The IREE Authors
-//
-// Licensed under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-#ifndef IREE_COMPILER_API_TOOLS_H
-#define IREE_COMPILER_API_TOOLS_H
-
-#include "mlir-c/Support.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/// Runs the IREE compiler main function. This is used to build
-/// iree-compile-like binaries that link against a common shared library.
-MLIR_CAPI_EXPORTED int ireeCompilerRunMain(int argc, char **argv);
-
-/// Runs LLD in "generic" mode (i.e. as `lld`, requiring a -flavor command line
-/// option). This does *not* mean that we support invoking LLD as a library,
-/// but we do support creating busybox style tools that invoke it standalone
-/// by linking against the CAPI.
-MLIR_CAPI_EXPORTED int ireeCompilerRunLldMain(int argc, char **argv);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif  // IREE_COMPILER_API_TOOLS_H
diff --git a/compiler/src/iree/compiler/API/python/CMakeLists.txt b/compiler/src/iree/compiler/API/python/CMakeLists.txt
index 67f9468..a183a8e 100644
--- a/compiler/src/iree/compiler/API/python/CMakeLists.txt
+++ b/compiler/src/iree/compiler/API/python/CMakeLists.txt
@@ -100,28 +100,21 @@
   MLIRPythonSources.Dialects.vector
 
   # mhlo project.
-  MLIRHLOPythonSources
-  MLIRHLOPythonExtensions
+  # TODO: Consider re-enabling these. They have been broken for some time.
+  # MLIRHLOPythonSources
+  # MLIRHLOPythonExtensions
 
   # iree-dialects project.
   IREEDialectsPythonSources
   IREEDialectsPythonExtensions
 )
 
-add_mlir_python_common_capi_library(IREECompilerAggregateCAPI
-  INSTALL_COMPONENT IREECompilerPythonModules
-  INSTALL_DESTINATION ${_PYTHON_INSTALL_PREFIX}/iree/compiler/_mlir_libs
-  OUTPUT_DIRECTORY "${_PYTHON_BUILD_PREFIX}/iree/compiler/_mlir_libs"
-  RELATIVE_INSTALL_ROOT "../../../.."
-  DECLARED_SOURCES ${_SOURCE_COMPONENTS}
-)
-
 add_mlir_python_modules(IREECompilerPythonModules
   ROOT_PREFIX "${_PYTHON_BUILD_PREFIX}/iree/compiler"
   INSTALL_PREFIX "${_PYTHON_INSTALL_PREFIX}/iree/compiler"
   DECLARED_SOURCES ${_SOURCE_COMPONENTS}
   COMMON_CAPI_LINK_LIBS
-    IREECompilerAggregateCAPI
+    iree_compiler_API2_SharedImpl
   )
 
 
@@ -140,7 +133,7 @@
     ${target}
     ${ARG_SRCS}
   )
-  target_link_libraries(${target} IREECompilerAggregateCAPI)
+  target_link_libraries(${target} iree_compiler_API2_SharedImpl)
   set_target_properties(${target}
     PROPERTIES
       OUTPUT_NAME "${ARG_OUTPUT_NAME}"
@@ -169,6 +162,43 @@
   )
 endif()
 
+# Install shared libraries that the extension depends on. This uses
+# CMake's defer feature to evaluate the install directive once everything
+# has been evaluated (because there is no guarantee that this file evaluates
+# before the API libraries are defined). While deferred calls are generally
+# fragile, this install is purely a leaf feature (with no other calls
+# depending on its sequencing), so this use is okay.
+# We defer it to the compiler/ directory so that cmake_install.cmake targets
+# are all self contained to the compiler, which is the most common spanning
+# parent.
+cmake_language(EVAL CODE "
+cmake_language(DEFER DIRECTORY \"${IREE_SOURCE_DIR}/compiler\"
+  CALL install
+  TARGETS
+    iree_compiler_API2_SharedImpl
+  DESTINATION \"${_PYTHON_INSTALL_PREFIX}/iree/compiler/_mlir_libs\"
+)
+")
+
+# On Windows, the IREECompiler.dll must be physically adjacent to the python
+# extensions. This is only an issue for the build tree (the install tree
+# places things appropriately). There is a lot of unavoidable fragility
+# here. Most notably, the actual name of the DLL must be static and computed
+# the same as where it is built.
+if(WIN32)
+  set(_local_dll_copy
+    "${_PYTHON_BUILD_PREFIX}/iree/compiler/_mlir_libs/IREECompiler.dll")
+  add_custom_command(
+    OUTPUT "${_local_dll_copy}"
+    COMMAND "${CMAKE_COMMAND}" -E copy_if_different
+      "$<TARGET_FILE:iree_compiler_API2_SharedImpl>"
+      "${_local_dll_copy}"
+    DEPENDS iree_compiler_API2_SharedImpl
+  )
+  add_custom_target(IREEPythonCopyDLL ALL
+    DEPENDS "${_local_dll_copy}")
+endif()
+
 ################################################################################
 # Subdirectories
 ################################################################################
diff --git a/compiler/src/iree/compiler/API/python/IREECTransforms.cpp b/compiler/src/iree/compiler/API/python/IREECTransforms.cpp
index f7666f3..828b374 100644
--- a/compiler/src/iree/compiler/API/python/IREECTransforms.cpp
+++ b/compiler/src/iree/compiler/API/python/IREECTransforms.cpp
@@ -4,7 +4,7 @@
 // See https://llvm.org/LICENSE.txt for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
-#include "iree/compiler/API/Compiler.h"
+#include "iree/compiler/API2/MLIRInterop.h"
 #include "mlir/Bindings/Python/PybindAdaptors.h"
 
 namespace py = pybind11;
diff --git a/compiler/src/iree/compiler/API/python/IREECompileTool.c b/compiler/src/iree/compiler/API/python/IREECompileTool.c
index 2eae64e..68a4cde 100644
--- a/compiler/src/iree/compiler/API/python/IREECompileTool.c
+++ b/compiler/src/iree/compiler/API/python/IREECompileTool.c
@@ -4,6 +4,6 @@
 // See https://llvm.org/LICENSE.txt for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
-#include "iree/compiler/API/Tools.h"
+#include "iree/compiler/API2/ToolEntryPoints.h"
 
 int main(int argc, char **argv) { return ireeCompilerRunMain(argc, argv); }
diff --git a/compiler/src/iree/compiler/API/python/LldTool.c b/compiler/src/iree/compiler/API/python/LldTool.c
index dfc2ac6..08b4532 100644
--- a/compiler/src/iree/compiler/API/python/LldTool.c
+++ b/compiler/src/iree/compiler/API/python/LldTool.c
@@ -4,6 +4,6 @@
 // See https://llvm.org/LICENSE.txt for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
-#include "iree/compiler/API/Tools.h"
+#include "iree/compiler/API2/ToolEntryPoints.h"
 
 int main(int argc, char **argv) { return ireeCompilerRunLldMain(argc, argv); }
diff --git a/compiler/src/iree/compiler/API/python/test/transforms/ireec/CMakeLists.txt b/compiler/src/iree/compiler/API/python/test/transforms/ireec/CMakeLists.txt
index 63cd792..384f33a 100644
--- a/compiler/src/iree/compiler/API/python/test/transforms/ireec/CMakeLists.txt
+++ b/compiler/src/iree/compiler/API/python/test/transforms/ireec/CMakeLists.txt
@@ -11,10 +11,9 @@
     "compiler_options_test.py"
 )
 
-# This test fails while importing chlo, which needs a fix for the stablehlo transition.
-# iree_py_test(
-#   NAME
-#     compile_sample_module
-#   SRCS
-#     "compile_sample_module.py"
-# )
+iree_py_test(
+  NAME
+    compile_sample_module
+  SRCS
+    "compile_sample_module.py"
+)
diff --git a/compiler/src/iree/compiler/API/python/test/transforms/ireec/compile_sample_module.py b/compiler/src/iree/compiler/API/python/test/transforms/ireec/compile_sample_module.py
index 8f96500..492efb3 100644
--- a/compiler/src/iree/compiler/API/python/test/transforms/ireec/compile_sample_module.py
+++ b/compiler/src/iree/compiler/API/python/test/transforms/ireec/compile_sample_module.py
@@ -13,8 +13,8 @@
 # The compiler re-exports API access to a number of dialects. If one of these
 # fails to import, it indicates a build issue.
 from iree.compiler.dialects import arith
-from iree.compiler.dialects import chlo
-from iree.compiler.dialects import mhlo
+#from iree.compiler.dialects import chlo
+#from iree.compiler.dialects import mhlo
 from iree.compiler.dialects import iree_input
 from iree.compiler.dialects import builtin
 from iree.compiler.dialects import linalg
@@ -41,7 +41,7 @@
 
   options = ireec.CompilerOptions("--iree-hal-target-backends=llvm-cpu")
   print(options)
-  pm = passmanager.PassManager()
+  pm = passmanager.PassManager(anchor_op="builtin.module")
   ireec.build_iree_vm_pass_pipeline(options, pm)
   pm.run(input_module)
 
diff --git a/compiler/src/iree/compiler/API/test/CMakeLists.txt b/compiler/src/iree/compiler/API/test/CMakeLists.txt
deleted file mode 100644
index 92d2e67..0000000
--- a/compiler/src/iree/compiler/API/test/CMakeLists.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-# Copyright 2022 The IREE Authors
-#
-# Licensed under the Apache License v2.0 with LLVM Exceptions.
-# See https://llvm.org/LICENSE.txt for license information.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-if(NOT IREE_BUILD_TESTS)
-  return()
-endif()
-
-iree_cc_binary(
-  NAME
-    api-test-binary
-  SRCS
-    "api-test-main.c"
-  DEPS
-    IREECompilerCAPILib
-    MLIRCAPIIR
-    iree::base
-  EXCLUDE_FROM_ALL
-)
-
-add_dependencies(iree-test-deps "iree_compiler_API_test_api-test-binary")
-
-iree_native_test(
-  NAME
-    "api-test"
-  SRC
-    ::api-test-binary
-)
diff --git a/compiler/src/iree/compiler/API2/BUILD b/compiler/src/iree/compiler/API2/BUILD
new file mode 100644
index 0000000..2a3a982
--- /dev/null
+++ b/compiler/src/iree/compiler/API2/BUILD
@@ -0,0 +1,59 @@
+# Copyright 2022 The IREE Authors
+#
+# Licensed under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+load("//build_tools/bazel:build_defs.oss.bzl", "iree_compiler_cc_library")
+
+package(
+    default_visibility = ["//visibility:public"],
+    features = ["layering_check"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+exports_files([
+    "api_exports.c",
+    "api_exports.def",
+    "api_exports.ld",
+    "api_exports.lst",
+])
+
+iree_compiler_cc_library(
+    name = "Headers",
+    hdrs = [
+        "MLIRInterop.h",
+        "ToolEntryPoints.h",
+    ],
+    deps = [
+        "@llvm-project//mlir:CAPIIRHeaders",
+    ],
+)
+
+iree_compiler_cc_library(
+    name = "StaticImpl",
+    deps = [
+        "//compiler/src/iree/compiler/API2/Internal:IREECompileToolEntryPoint",
+        "//compiler/src/iree/compiler/API2/Internal:IREEMLIRLSPServerToolEntryPoint",
+        "//compiler/src/iree/compiler/API2/Internal:IREEOptToolEntryPoint",
+        "//compiler/src/iree/compiler/API2/Internal:LLDToolEntryPoint",
+        "//compiler/src/iree/compiler/API2/Internal:MLIRInterop",
+        "//llvm-external-projects/iree-dialects:CAPI",
+        "@llvm-project//mlir:CAPIDebug",
+        "@llvm-project//mlir:CAPIIR",
+        "@llvm-project//mlir:CAPIInterfaces",
+        "@llvm-project//mlir:CAPILinalg",
+        "@llvm-project//mlir:CAPIPDL",
+        "@llvm-project//mlir:CAPITransformDialect",
+    ],
+)
+
+# Bazel does not have a well-defined mechanism for managing
+# shared libraries in a cross-platform way. Therefore, we
+# only support static linking of tools. Separately, we do
+# build an actual shared library for platforms that support
+# it, but this is only done to support stub use-cases.
+alias(
+    name = "Impl",
+    actual = ":StaticImpl",
+)
diff --git a/compiler/src/iree/compiler/API2/CMakeLists.txt b/compiler/src/iree/compiler/API2/CMakeLists.txt
new file mode 100644
index 0000000..ef60646
--- /dev/null
+++ b/compiler/src/iree/compiler/API2/CMakeLists.txt
@@ -0,0 +1,116 @@
+################################################################################
+# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from           #
+# compiler/src/iree/compiler/API2/BUILD                                        #
+#                                                                              #
+# Use iree_cmake_extra_content from iree/build_defs.oss.bzl to add arbitrary   #
+# CMake-only content.                                                          #
+#                                                                              #
+# To disable autogeneration for this file entirely, delete this header.        #
+################################################################################
+
+iree_add_all_subdirs()
+
+iree_cc_library(
+  NAME
+    Headers
+  HDRS
+    "MLIRInterop.h"
+    "ToolEntryPoints.h"
+  DEPS
+    IREELLVMIncludeSetup
+  PUBLIC
+)
+
+iree_cc_library(
+  NAME
+    StaticImpl
+  DEPS
+    IREEDialectsCAPI
+    MLIRCAPIDebug
+    MLIRCAPIIR
+    MLIRCAPIInterfaces
+    MLIRCAPILinalg
+    MLIRCAPIPDL
+    MLIRCAPITransformDialect
+    iree::compiler::API2::Internal::IREECompileToolEntryPoint
+    iree::compiler::API2::Internal::IREEMLIRLSPServerToolEntryPoint
+    iree::compiler::API2::Internal::IREEOptToolEntryPoint
+    iree::compiler::API2::Internal::LLDToolEntryPoint
+    iree::compiler::API2::Internal::MLIRInterop
+  PUBLIC
+)
+
+### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
+
+iree_cc_library(
+  SHARED
+  NAME
+    SharedImpl
+  WINDOWS_DEF_FILE
+    # On Windows, include the generated def file.
+    ${CMAKE_CURRENT_SOURCE_DIR}/api_exports.def
+  SRCS
+    api_exports.c
+  LINKOPTS
+    # Linux uses a linker script.
+    $<$<PLATFORM_ID:Linux>:-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/api_exports.ld>
+    # MacOS uses a symbol list.
+    $<$<PLATFORM_ID:Darwin>:-Wl,--exported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/api_exports.lst>
+)
+
+# If not using sanitizers, ask linkers to error on undefined symbols.
+# For shared libraries, using sanitizers implies undefined symbols on Unix-like.
+if(NOT IREE_ENABLE_ASAN
+    AND NOT IREE_ENABLE_MSAN
+    AND NOT IREE_ENABLE_TSAN
+    AND NOT IREE_ENABLE_UBSAN)
+  target_link_options(iree_compiler_API2_SharedImpl PRIVATE
+    $<$<PLATFORM_ID:Linux>:-Wl,--no-undefined>
+    $<$<PLATFORM_ID:Darwin>:-Wl,-undefined,error>
+  )
+endif()
+
+# DANGER: iree_cc_library links its deps with PUBLIC scope, which causes
+# usage requirements to propagate from dependents to users of the shared
+# library. The shared library is intended to be used as an isolated boundary
+# for C consumers. Therefore, we depend on the backing static library with
+# PRIVATE scope explicitly here vs using a DEPS above. This kind of "boundary
+# shared library" seems to be the only place this happens, so we special
+# case vs generalizing.
+target_link_libraries(
+  iree_compiler_API2_SharedImpl
+  PRIVATE
+    iree_compiler_API2_StaticImpl
+)
+
+set_target_properties(
+  iree_compiler_API2_SharedImpl
+  PROPERTIES
+    OUTPUT_NAME "IREECompiler"
+    VERSION "0"
+    SOVERSION "0"
+
+    LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib"
+    # On Windows, DLLs go to the runtime directory and import
+    # libraries go to the lib directory.
+    # TODO: We should really be dumping binaries into bin/ not
+    # tools/. This must line up with binaries built this way because
+    # DLLs must be in the same directory as the binary.
+    RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/tools"
+    ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib"
+)
+
+install(
+  TARGETS iree_compiler_API2_SharedImpl
+  COMPONENT Compiler
+)
+
+# The bazel side uses a "Impl" library alias to generically represent
+# static or shared. Provide a corresponding one here.
+
+iree_cc_library(
+  NAME
+    Impl
+  DEPS
+    ::SharedImpl
+)
diff --git a/compiler/src/iree/compiler/API2/Internal/BUILD b/compiler/src/iree/compiler/API2/Internal/BUILD
new file mode 100644
index 0000000..acbc3ee
--- /dev/null
+++ b/compiler/src/iree/compiler/API2/Internal/BUILD
@@ -0,0 +1,91 @@
+# Copyright 2022 The IREE Authors
+#
+# Licensed under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+load("//build_tools/bazel:build_defs.oss.bzl", "iree_compiler_cc_library")
+
+package(
+    default_visibility = ["//visibility:public"],
+    features = ["layering_check"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+iree_compiler_cc_library(
+    name = "IREECompileToolEntryPoint",
+    srcs = [
+        "IREECompileToolEntryPoint.cpp",
+    ],
+    deps = [
+        "//compiler/src/iree/compiler/API2:Headers",
+        "//compiler/src/iree/compiler/Tools:iree_compile_lib",
+    ],
+)
+
+iree_compiler_cc_library(
+    name = "IREEMLIRLSPServerToolEntryPoint",
+    srcs = [
+        "IREEMLIRLSPServerToolEntryPoint.cpp",
+    ],
+    deps = [
+        "//compiler/src/iree/compiler/API2:Headers",
+        "//compiler/src/iree/compiler/Tools:init_passes_and_dialects",
+        "@llvm-project//mlir:IR",
+        "@llvm-project//mlir:MlirLspServerLib",
+        "@llvm-project//mlir:Support",
+    ],
+)
+
+iree_compiler_cc_library(
+    name = "IREEOptToolEntryPoint",
+    srcs = [
+        "IREEOptToolEntryPoint.cpp",
+    ],
+    deps = [
+        "//compiler/src/iree/compiler/API2:Headers",
+        "//compiler/src/iree/compiler/Tools:init_passes_and_dialects",
+        "//compiler/src/iree/compiler/Tools:init_targets",
+        "@llvm-project//llvm:Support",
+        "@llvm-project//mlir:IR",
+        "@llvm-project//mlir:MlirOptLib",
+        "@llvm-project//mlir:Support",
+    ],
+)
+
+iree_compiler_cc_library(
+    name = "LLDToolEntryPoint",
+    srcs = [
+        "LLDToolEntryPoint.cpp",
+    ],
+    deps = [
+        "//compiler/src/iree/compiler/API2:Headers",
+        "@llvm-project//lld:COFF",
+        "@llvm-project//lld:Common",
+        "@llvm-project//lld:ELF",
+        "@llvm-project//lld:MachO",
+        "@llvm-project//lld:Wasm",
+        "@llvm-project//llvm:Support",
+    ],
+)
+
+iree_compiler_cc_library(
+    name = "MLIRInterop",
+    srcs = [
+        "MLIRInterop.cpp",
+    ],
+    deps = [
+        "//compiler/src/iree/compiler/API2:Headers",
+        "//compiler/src/iree/compiler/ConstEval",
+        "//compiler/src/iree/compiler/Dialect/VM/IR",
+        "//compiler/src/iree/compiler/Dialect/VM/Target:init_targets",
+        "//compiler/src/iree/compiler/Dialect/VM/Target/Bytecode",
+        "//compiler/src/iree/compiler/Pipelines",
+        "//compiler/src/iree/compiler/Tools:init_llvmir_translations",
+        "//compiler/src/iree/compiler/Tools:init_passes_and_dialects",
+        "//compiler/src/iree/compiler/Tools:init_targets",
+        "//compiler/src/iree/compiler/Utils",
+        "@llvm-project//mlir:CAPIIR",
+        "@llvm-project//mlir:IR",
+    ],
+)
diff --git a/compiler/src/iree/compiler/API2/Internal/CMakeLists.txt b/compiler/src/iree/compiler/API2/Internal/CMakeLists.txt
new file mode 100644
index 0000000..801d911
--- /dev/null
+++ b/compiler/src/iree/compiler/API2/Internal/CMakeLists.txt
@@ -0,0 +1,91 @@
+################################################################################
+# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from           #
+# compiler/src/iree/compiler/API2/Internal/BUILD                               #
+#                                                                              #
+# Use iree_cmake_extra_content from iree/build_defs.oss.bzl to add arbitrary   #
+# CMake-only content.                                                          #
+#                                                                              #
+# To disable autogeneration for this file entirely, delete this header.        #
+################################################################################
+
+iree_add_all_subdirs()
+
+iree_cc_library(
+  NAME
+    IREECompileToolEntryPoint
+  SRCS
+    "IREECompileToolEntryPoint.cpp"
+  DEPS
+    iree::compiler::API2::Headers
+    iree::compiler::Tools::iree_compile_lib
+  PUBLIC
+)
+
+iree_cc_library(
+  NAME
+    IREEMLIRLSPServerToolEntryPoint
+  SRCS
+    "IREEMLIRLSPServerToolEntryPoint.cpp"
+  DEPS
+    MLIRIR
+    MLIRLspServerLib
+    MLIRSupport
+    iree::compiler::API2::Headers
+    iree::compiler::Tools::init_passes_and_dialects
+  PUBLIC
+)
+
+iree_cc_library(
+  NAME
+    IREEOptToolEntryPoint
+  SRCS
+    "IREEOptToolEntryPoint.cpp"
+  DEPS
+    LLVMSupport
+    MLIRIR
+    MLIROptLib
+    MLIRSupport
+    iree::compiler::API2::Headers
+    iree::compiler::Tools::init_passes_and_dialects
+    iree::compiler::Tools::init_targets
+  PUBLIC
+)
+
+iree_cc_library(
+  NAME
+    LLDToolEntryPoint
+  SRCS
+    "LLDToolEntryPoint.cpp"
+  DEPS
+    LLVMSupport
+    iree::compiler::API2::Headers
+    lldCOFF
+    lldCommon
+    lldELF
+    lldMachO
+    lldWasm
+  PUBLIC
+)
+
+iree_cc_library(
+  NAME
+    MLIRInterop
+  SRCS
+    "MLIRInterop.cpp"
+  DEPS
+    MLIRCAPIIR
+    MLIRIR
+    iree::compiler::API2::Headers
+    iree::compiler::ConstEval
+    iree::compiler::Dialect::VM::IR
+    iree::compiler::Dialect::VM::Target::Bytecode
+    iree::compiler::Dialect::VM::Target::init_targets
+    iree::compiler::Pipelines
+    iree::compiler::Tools::init_llvmir_translations
+    iree::compiler::Tools::init_passes_and_dialects
+    iree::compiler::Tools::init_targets
+    iree::compiler::Utils
+  PUBLIC
+)
+
+### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
diff --git a/compiler/src/iree/compiler/API/Tools.cpp b/compiler/src/iree/compiler/API2/Internal/IREECompileToolEntryPoint.cpp
similarity index 74%
rename from compiler/src/iree/compiler/API/Tools.cpp
rename to compiler/src/iree/compiler/API2/Internal/IREECompileToolEntryPoint.cpp
index 1c533ed..dc3bad4 100644
--- a/compiler/src/iree/compiler/API/Tools.cpp
+++ b/compiler/src/iree/compiler/API2/Internal/IREECompileToolEntryPoint.cpp
@@ -4,10 +4,10 @@
 // See https://llvm.org/LICENSE.txt for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
-#include "iree/compiler/API/Tools.h"
-
+#include "iree/compiler/API2/ToolEntryPoints.h"
 #include "iree/compiler/Tools/iree_compile_lib.h"
 
 int ireeCompilerRunMain(int argc, char **argv) {
+  // TODO: Inline the actual runIreecMain here as the single place to use it.
   return mlir::iree_compiler::runIreecMain(argc, argv);
 }
diff --git a/compiler/src/iree/compiler/API2/Internal/IREEMLIRLSPServerToolEntryPoint.cpp b/compiler/src/iree/compiler/API2/Internal/IREEMLIRLSPServerToolEntryPoint.cpp
new file mode 100644
index 0000000..d38699a
--- /dev/null
+++ b/compiler/src/iree/compiler/API2/Internal/IREEMLIRLSPServerToolEntryPoint.cpp
@@ -0,0 +1,21 @@
+// Copyright 2021 The IREE Authors
+//
+// Licensed under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+// Main entry function for the IREE variant of mlir-lsp-server.
+//
+// See https://mlir.llvm.org/docs/Tools/MLIRLSP/
+
+#include "iree/compiler/API2/ToolEntryPoints.h"
+#include "iree/compiler/Tools/init_dialects.h"
+#include "mlir/IR/Dialect.h"
+#include "mlir/Support/LogicalResult.h"
+#include "mlir/Tools/mlir-lsp-server/MlirLspServerMain.h"
+
+int ireeMlirLspServerRunMain(int argc, char **argv) {
+  mlir::DialectRegistry registry;
+  mlir::iree_compiler::registerAllDialects(registry);
+  return failed(mlir::MlirLspServerMain(argc, argv, registry));
+}
diff --git a/compiler/src/iree/compiler/API2/Internal/IREEOptToolEntryPoint.cpp b/compiler/src/iree/compiler/API2/Internal/IREEOptToolEntryPoint.cpp
new file mode 100644
index 0000000..1d4602d
--- /dev/null
+++ b/compiler/src/iree/compiler/API2/Internal/IREEOptToolEntryPoint.cpp
@@ -0,0 +1,38 @@
+// Copyright 2020 The IREE Authors
+//
+// Licensed under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+// Main entry function for iree-opt and derived binaries.
+//
+// Based on mlir-opt but registers the passes and dialects we care about.
+
+#include "iree/compiler/API2/ToolEntryPoints.h"
+#include "iree/compiler/Tools/init_dialects.h"
+#include "iree/compiler/Tools/init_passes.h"
+#include "iree/compiler/Tools/init_targets.h"
+#include "llvm/Support/InitLLVM.h"
+#include "mlir/IR/Dialect.h"
+#include "mlir/Support/LogicalResult.h"
+#include "mlir/Tools/mlir-opt/MlirOptMain.h"
+
+int ireeOptRunMain(int argc, char **argv) {
+  llvm::InitLLVM y(argc, argv);
+
+  mlir::DialectRegistry registry;
+  mlir::iree_compiler::registerAllDialects(registry);
+  mlir::iree_compiler::registerAllPasses();
+  mlir::iree_compiler::registerHALTargetBackends();
+
+  // Register the pass to drop embedded transform dialect IR.
+  // TODO: this should be upstreamed.
+  mlir::linalg::transform::registerDropSchedulePass();
+
+  if (failed(MlirOptMain(argc, argv, "IREE modular optimizer driver\n",
+                         registry,
+                         /*preloadDialectsInContext=*/false))) {
+    return 1;
+  }
+  return 0;
+}
diff --git a/compiler/src/iree/compiler/API/Lld.cpp b/compiler/src/iree/compiler/API2/Internal/LLDToolEntryPoint.cpp
similarity index 97%
rename from compiler/src/iree/compiler/API/Lld.cpp
rename to compiler/src/iree/compiler/API2/Internal/LLDToolEntryPoint.cpp
index d1a9b87..37521ab 100644
--- a/compiler/src/iree/compiler/API/Lld.cpp
+++ b/compiler/src/iree/compiler/API2/Internal/LLDToolEntryPoint.cpp
@@ -12,7 +12,7 @@
 #include <cstdlib>
 #include <vector>
 
-#include "iree/compiler/API/Tools.h"
+#include "iree/compiler/API2/ToolEntryPoints.h"
 #include "lld/Common/Driver.h"
 #include "lld/Common/ErrorHandler.h"
 #include "lld/Common/Memory.h"
diff --git a/compiler/src/iree/compiler/API/Compiler.cpp b/compiler/src/iree/compiler/API2/Internal/MLIRInterop.cpp
similarity index 98%
rename from compiler/src/iree/compiler/API/Compiler.cpp
rename to compiler/src/iree/compiler/API2/Internal/MLIRInterop.cpp
index 00370b3..455f3df 100644
--- a/compiler/src/iree/compiler/API/Compiler.cpp
+++ b/compiler/src/iree/compiler/API2/Internal/MLIRInterop.cpp
@@ -4,7 +4,7 @@
 // See https://llvm.org/LICENSE.txt for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
-#include "iree/compiler/API/Compiler.h"
+#include "iree/compiler/API2/MLIRInterop.h"
 
 #include "iree/compiler/ConstEval/Passes.h"
 #include "iree/compiler/Dialect/VM/IR/VMOps.h"
diff --git a/compiler/src/iree/compiler/API/Compiler.h b/compiler/src/iree/compiler/API2/MLIRInterop.h
similarity index 88%
rename from compiler/src/iree/compiler/API/Compiler.h
rename to compiler/src/iree/compiler/API2/MLIRInterop.h
index 47fc526..f2aa2e3 100644
--- a/compiler/src/iree/compiler/API/Compiler.h
+++ b/compiler/src/iree/compiler/API2/MLIRInterop.h
@@ -4,8 +4,13 @@
 // See https://llvm.org/LICENSE.txt for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
-#ifndef IREE_COMPILER_API_COMPILER_H
-#define IREE_COMPILER_API_COMPILER_H
+// Low-level interface to IREE compiler facilities that augment and work with
+// the MLIR C-API.
+// Stability: This API, like the MLIR C-API, offers no ABI stability guarantees,
+// and API stability is best effort.
+
+#ifndef IREE_COMPILER_API2_MLIR_INTEROP_H
+#define IREE_COMPILER_API2_MLIR_INTEROP_H
 
 #include "mlir-c/Pass.h"
 #include "mlir-c/Support.h"
@@ -70,4 +75,4 @@
 }
 #endif
 
-#endif  // IREE_COMPILER_API_COMPILER_H
+#endif  // IREE_COMPILER_API2_MLIR_INTEROP_H
diff --git a/compiler/src/iree/compiler/API2/README.md b/compiler/src/iree/compiler/API2/README.md
new file mode 100644
index 0000000..f611c79
--- /dev/null
+++ b/compiler/src/iree/compiler/API2/README.md
@@ -0,0 +1,44 @@
+# IREE Compiler API
+
+IREE exports three levels of APIs for integrating IREE (and uses these APIs
+itself for building language bindings and binary tools):
+
+* Low-level MLIR API: This API builds on top of the MLIR C-API in order to
+  enable low level access to IR building, transformations and combined
+  pipelines. It provides no defined ABI or API stability guarantees, although
+  best effort is taken to not break the API unnecessarily (similar to how the
+  upstream MLIR C-API is considered).
+* Tool Entry Points: Entry points for standalone tools (i.e. `iree-compile`
+  and `iree-lld`) are provided as exported C functions to enable the
+  construction of busy-box binaries and other non-library use cases.
+* Embedding API: The high level compiler API provides programmatic access to
+  the facilities of `iree-compile` and is intended for embedding into an online
+  system which needs to invoke the compiler as a library and is interopping
+  via input and output artifacts (vs direct construction of IR against
+  in-memory data structures). This API is versioned and both API/ABI compatible
+  within a major version.
+
+Depending on build configuration, the API is built in the following ways:
+
+* Shared library: In this scenario, all of the APIs above are exported into
+  a versioned shared library.
+* Static library: Used for building a static tool (not enabled by default
+  since it adds build overhead).
+* Re-export Stub library: A static library which re-exports the Embedding API
+  and provides additional entry-points for binding to a runtime-loaded
+  shared library for the implementation. This is used as a convenience for
+  consumers which need to decouple the interface from the implementation, which
+  can happen in a variety of cases (i.e. avoiding symbol conflicts, integrating
+  across build systems, etc).
+
+## Exported symbols
+
+See the script `generate_exports.py` which generates a number of checked
+in files with names `api_exports.*` which are needed for various styles of
+linking. Presently, this script scrapes a number of headers to generate an
+export list, but this is a WIP: we would like to align upstream better and
+be explicit.
+
+It is typically pretty obvious to determine that an update is needed: libraries
+will fail to build on missing symbols, or language bindings will fail to load
+at runtime (complaining of missing symbols).
diff --git a/compiler/src/iree/compiler/API2/Shlib/Posix/BUILD.bazel b/compiler/src/iree/compiler/API2/Shlib/Posix/BUILD.bazel
new file mode 100644
index 0000000..d3717d2
--- /dev/null
+++ b/compiler/src/iree/compiler/API2/Shlib/Posix/BUILD.bazel
@@ -0,0 +1,27 @@
+# Copyright 2022 The IREE Authors
+#
+# Licensed under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+# This is problematic on anything non-Linux but Bazel has failed
+# for years to provide the flexibility to make it any better. Yolo.
+# We really only support this for some very narrow use cases that
+# need to dynamically load the compiler as a shared library, and other
+# uses are served by the cross-platform CMake build.
+cc_binary(
+    name = "libIREECompiler.so",
+    srcs = [
+        "//compiler/src/iree/compiler/API2:api_exports.c",
+    ],
+    linkopts = [
+        "-Wl,--version-script=$(location //compiler/src/iree/compiler/API2:api_exports.ld)",
+        "-Wl,--no-undefined",
+    ],
+    linkshared = 1,
+    deps = [
+        "//compiler/src/iree/compiler/API2:Headers",
+        "//compiler/src/iree/compiler/API2:StaticImpl",
+        "//compiler/src/iree/compiler/API2:api_exports.ld",
+    ],
+)
diff --git a/compiler/src/iree/compiler/API2/ToolEntryPoints.h b/compiler/src/iree/compiler/API2/ToolEntryPoints.h
new file mode 100644
index 0000000..e997fdc
--- /dev/null
+++ b/compiler/src/iree/compiler/API2/ToolEntryPoints.h
@@ -0,0 +1,41 @@
+// Copyright 2021 The IREE Authors
+//
+// Licensed under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+// Exports "main" entry-points for individual IREE compiler tools. Actual
+// binaries delegate to these main entry-points, allowing their backing
+// implementations to be commingled in a backing shared library that is
+// hermetic.
+
+#ifndef IREE_COMPILER_API2_TOOL_ENTRY_POINTS_H
+#define IREE_COMPILER_API2_TOOL_ENTRY_POINTS_H
+
+#include "mlir-c/Support.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/// Runs the IREE compiler main function. This is used to build
+/// iree-compile-like binaries that link against a common shared library.
+MLIR_CAPI_EXPORTED int ireeCompilerRunMain(int argc, char **argv);
+
+/// Runs the iree-opt main function.
+MLIR_CAPI_EXPORTED int ireeOptRunMain(int argc, char **argv);
+
+/// Runs the iree-mlir-lsp-server main function.
+MLIR_CAPI_EXPORTED int ireeMlirLspServerRunMain(int argc, char **argv);
+
+/// Runs LLD in "generic" mode (i.e. as `lld`, requiring a -flavor command line
+/// option). This does *not* mean that we support invoking LLD as a library,
+/// but we do support creating busybox style tools that invoke it standalone
+/// by linking against the CAPI.
+MLIR_CAPI_EXPORTED int ireeCompilerRunLldMain(int argc, char **argv);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif  // IREE_COMPILER_API2_TOOL_ENTRY_POINTS_H
diff --git a/compiler/src/iree/compiler/API2/api_exports.c b/compiler/src/iree/compiler/API2/api_exports.c
new file mode 100644
index 0000000..5657a1c
--- /dev/null
+++ b/compiler/src/iree/compiler/API2/api_exports.c
@@ -0,0 +1,1041 @@
+// Copyright 2022 The IREE Authors
+//
+// Licensed under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+// Generated by generate_exports.py: Do not edit.
+
+#include <stdint.h>
+
+extern void ireeCompilerBuildIREEVMPassPipeline();
+extern void ireeCompilerOptionsCreate();
+extern void ireeCompilerOptionsDestroy();
+extern void ireeCompilerOptionsGetFlags();
+extern void ireeCompilerOptionsSetFlags();
+extern void ireeCompilerRegisterAllDialects();
+extern void ireeCompilerRegisterAllPasses();
+extern void ireeCompilerRegisterTargetBackends();
+extern void ireeCompilerRunLldMain();
+extern void ireeCompilerRunMain();
+extern void ireeCompilerTranslateModuletoVMBytecode();
+extern void ireeMlirLspServerRunMain();
+extern void ireeOptRunMain();
+extern void ireeRegisterTransformExtensions();
+extern void mlirAffineAddExprGet();
+extern void mlirAffineBinaryOpExprGetLHS();
+extern void mlirAffineBinaryOpExprGetRHS();
+extern void mlirAffineCeilDivExprGet();
+extern void mlirAffineConstantExprGet();
+extern void mlirAffineConstantExprGetValue();
+extern void mlirAffineDimExprGet();
+extern void mlirAffineDimExprGetPosition();
+extern void mlirAffineExprCompose();
+extern void mlirAffineExprDump();
+extern void mlirAffineExprEqual();
+extern void mlirAffineExprGetContext();
+extern void mlirAffineExprGetLargestKnownDivisor();
+extern void mlirAffineExprIsAAdd();
+extern void mlirAffineExprIsABinary();
+extern void mlirAffineExprIsACeilDiv();
+extern void mlirAffineExprIsAConstant();
+extern void mlirAffineExprIsADim();
+extern void mlirAffineExprIsAFloorDiv();
+extern void mlirAffineExprIsAMod();
+extern void mlirAffineExprIsAMul();
+extern void mlirAffineExprIsASymbol();
+extern void mlirAffineExprIsFunctionOfDim();
+extern void mlirAffineExprIsMultipleOf();
+extern void mlirAffineExprIsPureAffine();
+extern void mlirAffineExprIsSymbolicOrConstant();
+extern void mlirAffineExprPrint();
+extern void mlirAffineFloorDivExprGet();
+extern void mlirAffineMapAttrGet();
+extern void mlirAffineMapAttrGetValue();
+extern void mlirAffineMapCompressUnusedSymbols();
+extern void mlirAffineMapConstantGet();
+extern void mlirAffineMapDump();
+extern void mlirAffineMapEmptyGet();
+extern void mlirAffineMapEqual();
+extern void mlirAffineMapGet();
+extern void mlirAffineMapGetContext();
+extern void mlirAffineMapGetMajorSubMap();
+extern void mlirAffineMapGetMinorSubMap();
+extern void mlirAffineMapGetNumDims();
+extern void mlirAffineMapGetNumInputs();
+extern void mlirAffineMapGetNumResults();
+extern void mlirAffineMapGetNumSymbols();
+extern void mlirAffineMapGetResult();
+extern void mlirAffineMapGetSingleConstantResult();
+extern void mlirAffineMapGetSubMap();
+extern void mlirAffineMapIsEmpty();
+extern void mlirAffineMapIsIdentity();
+extern void mlirAffineMapIsMinorIdentity();
+extern void mlirAffineMapIsPermutation();
+extern void mlirAffineMapIsProjectedPermutation();
+extern void mlirAffineMapIsSingleConstant();
+extern void mlirAffineMapMinorIdentityGet();
+extern void mlirAffineMapMultiDimIdentityGet();
+extern void mlirAffineMapPermutationGet();
+extern void mlirAffineMapPrint();
+extern void mlirAffineMapReplace();
+extern void mlirAffineMapZeroResultGet();
+extern void mlirAffineModExprGet();
+extern void mlirAffineMulExprGet();
+extern void mlirAffineSymbolExprGet();
+extern void mlirAffineSymbolExprGetPosition();
+extern void mlirArrayAttrGet();
+extern void mlirArrayAttrGetElement();
+extern void mlirArrayAttrGetNumElements();
+extern void mlirAttributeDump();
+extern void mlirAttributeEqual();
+extern void mlirAttributeGetContext();
+extern void mlirAttributeGetNull();
+extern void mlirAttributeGetType();
+extern void mlirAttributeGetTypeID();
+extern void mlirAttributeIsAAffineMap();
+extern void mlirAttributeIsAArray();
+extern void mlirAttributeIsABool();
+extern void mlirAttributeIsADenseBoolArray();
+extern void mlirAttributeIsADenseElements();
+extern void mlirAttributeIsADenseF32Array();
+extern void mlirAttributeIsADenseF64Array();
+extern void mlirAttributeIsADenseFPElements();
+extern void mlirAttributeIsADenseI16Array();
+extern void mlirAttributeIsADenseI32Array();
+extern void mlirAttributeIsADenseI64Array();
+extern void mlirAttributeIsADenseI8Array();
+extern void mlirAttributeIsADenseIntElements();
+extern void mlirAttributeIsADictionary();
+extern void mlirAttributeIsAElements();
+extern void mlirAttributeIsAFlatSymbolRef();
+extern void mlirAttributeIsAFloat();
+extern void mlirAttributeIsAInteger();
+extern void mlirAttributeIsAIntegerSet();
+extern void mlirAttributeIsAOpaque();
+extern void mlirAttributeIsASparseElements();
+extern void mlirAttributeIsAStridedLayout();
+extern void mlirAttributeIsAString();
+extern void mlirAttributeIsASymbolRef();
+extern void mlirAttributeIsAType();
+extern void mlirAttributeIsAUnit();
+extern void mlirAttributeParseGet();
+extern void mlirAttributePrint();
+extern void mlirBF16TypeGet();
+extern void mlirBlockAddArgument();
+extern void mlirBlockAppendOwnedOperation();
+extern void mlirBlockArgumentGetArgNumber();
+extern void mlirBlockArgumentGetOwner();
+extern void mlirBlockArgumentSetType();
+extern void mlirBlockCreate();
+extern void mlirBlockDestroy();
+extern void mlirBlockDetach();
+extern void mlirBlockEqual();
+extern void mlirBlockGetArgument();
+extern void mlirBlockGetFirstOperation();
+extern void mlirBlockGetNextInRegion();
+extern void mlirBlockGetNumArguments();
+extern void mlirBlockGetParentOperation();
+extern void mlirBlockGetParentRegion();
+extern void mlirBlockGetTerminator();
+extern void mlirBlockInsertOwnedOperation();
+extern void mlirBlockInsertOwnedOperationAfter();
+extern void mlirBlockInsertOwnedOperationBefore();
+extern void mlirBlockPrint();
+extern void mlirBoolAttrGet();
+extern void mlirBoolAttrGetValue();
+extern void mlirComplexTypeGet();
+extern void mlirComplexTypeGetElementType();
+extern void mlirContextAppendDialectRegistry();
+extern void mlirContextAttachDiagnosticHandler();
+extern void mlirContextCreate();
+extern void mlirContextDestroy();
+extern void mlirContextDetachDiagnosticHandler();
+extern void mlirContextEnableMultithreading();
+extern void mlirContextEqual();
+extern void mlirContextGetAllowUnregisteredDialects();
+extern void mlirContextGetNumLoadedDialects();
+extern void mlirContextGetNumRegisteredDialects();
+extern void mlirContextGetOrLoadDialect();
+extern void mlirContextIsRegisteredOperation();
+extern void mlirContextLoadAllAvailableDialects();
+extern void mlirContextSetAllowUnregisteredDialects();
+extern void mlirCreateExternalPass();
+extern void mlirDenseArrayGetNumElements();
+extern void mlirDenseBoolArrayGet();
+extern void mlirDenseBoolArrayGetElement();
+extern void mlirDenseElementsAttrBFloat16Get();
+extern void mlirDenseElementsAttrBoolGet();
+extern void mlirDenseElementsAttrBoolSplatGet();
+extern void mlirDenseElementsAttrDoubleGet();
+extern void mlirDenseElementsAttrDoubleSplatGet();
+extern void mlirDenseElementsAttrFloat16Get();
+extern void mlirDenseElementsAttrFloatGet();
+extern void mlirDenseElementsAttrFloatSplatGet();
+extern void mlirDenseElementsAttrGet();
+extern void mlirDenseElementsAttrGetBoolSplatValue();
+extern void mlirDenseElementsAttrGetBoolValue();
+extern void mlirDenseElementsAttrGetDoubleSplatValue();
+extern void mlirDenseElementsAttrGetDoubleValue();
+extern void mlirDenseElementsAttrGetFloatSplatValue();
+extern void mlirDenseElementsAttrGetFloatValue();
+extern void mlirDenseElementsAttrGetInt16Value();
+extern void mlirDenseElementsAttrGetInt32SplatValue();
+extern void mlirDenseElementsAttrGetInt32Value();
+extern void mlirDenseElementsAttrGetInt64SplatValue();
+extern void mlirDenseElementsAttrGetInt64Value();
+extern void mlirDenseElementsAttrGetInt8SplatValue();
+extern void mlirDenseElementsAttrGetInt8Value();
+extern void mlirDenseElementsAttrGetRawData();
+extern void mlirDenseElementsAttrGetSplatValue();
+extern void mlirDenseElementsAttrGetStringSplatValue();
+extern void mlirDenseElementsAttrGetStringValue();
+extern void mlirDenseElementsAttrGetUInt16Value();
+extern void mlirDenseElementsAttrGetUInt32SplatValue();
+extern void mlirDenseElementsAttrGetUInt32Value();
+extern void mlirDenseElementsAttrGetUInt64SplatValue();
+extern void mlirDenseElementsAttrGetUInt64Value();
+extern void mlirDenseElementsAttrGetUInt8SplatValue();
+extern void mlirDenseElementsAttrGetUInt8Value();
+extern void mlirDenseElementsAttrInt16Get();
+extern void mlirDenseElementsAttrInt32Get();
+extern void mlirDenseElementsAttrInt32SplatGet();
+extern void mlirDenseElementsAttrInt64Get();
+extern void mlirDenseElementsAttrInt64SplatGet();
+extern void mlirDenseElementsAttrInt8Get();
+extern void mlirDenseElementsAttrInt8SplatGet();
+extern void mlirDenseElementsAttrIsSplat();
+extern void mlirDenseElementsAttrRawBufferGet();
+extern void mlirDenseElementsAttrReshapeGet();
+extern void mlirDenseElementsAttrSplatGet();
+extern void mlirDenseElementsAttrStringGet();
+extern void mlirDenseElementsAttrUInt16Get();
+extern void mlirDenseElementsAttrUInt32Get();
+extern void mlirDenseElementsAttrUInt32SplatGet();
+extern void mlirDenseElementsAttrUInt64Get();
+extern void mlirDenseElementsAttrUInt64SplatGet();
+extern void mlirDenseElementsAttrUInt8Get();
+extern void mlirDenseElementsAttrUInt8SplatGet();
+extern void mlirDenseF32ArrayGet();
+extern void mlirDenseF32ArrayGetElement();
+extern void mlirDenseF64ArrayGet();
+extern void mlirDenseF64ArrayGetElement();
+extern void mlirDenseI16ArrayGet();
+extern void mlirDenseI16ArrayGetElement();
+extern void mlirDenseI32ArrayGet();
+extern void mlirDenseI32ArrayGetElement();
+extern void mlirDenseI64ArrayGet();
+extern void mlirDenseI64ArrayGetElement();
+extern void mlirDenseI8ArrayGet();
+extern void mlirDenseI8ArrayGetElement();
+extern void mlirDiagnosticGetLocation();
+extern void mlirDiagnosticGetNote();
+extern void mlirDiagnosticGetNumNotes();
+extern void mlirDiagnosticGetSeverity();
+extern void mlirDiagnosticPrint();
+extern void mlirDialectEqual();
+extern void mlirDialectGetContext();
+extern void mlirDialectGetNamespace();
+extern void mlirDialectHandleGetNamespace();
+extern void mlirDialectHandleInsertDialect();
+extern void mlirDialectHandleLoadDialect();
+extern void mlirDialectHandleRegisterDialect();
+extern void mlirDialectRegistryCreate();
+extern void mlirDialectRegistryDestroy();
+extern void mlirDictionaryAttrGet();
+extern void mlirDictionaryAttrGetElement();
+extern void mlirDictionaryAttrGetElementByName();
+extern void mlirDictionaryAttrGetNumElements();
+extern void mlirElementsAttrGetNumElements();
+extern void mlirElementsAttrGetValue();
+extern void mlirElementsAttrIsValidIndex();
+extern void mlirEmitError();
+extern void mlirEnableGlobalDebug();
+extern void mlirExternalPassSignalFailure();
+extern void mlirF16TypeGet();
+extern void mlirF32TypeGet();
+extern void mlirF64TypeGet();
+extern void mlirFlatSymbolRefAttrGet();
+extern void mlirFlatSymbolRefAttrGetValue();
+extern void mlirFloat8E4M3FNTypeGet();
+extern void mlirFloat8E5M2TypeGet();
+extern void mlirFloatAttrDoubleGet();
+extern void mlirFloatAttrDoubleGetChecked();
+extern void mlirFloatAttrGetValueDouble();
+extern void mlirFunctionTypeGet();
+extern void mlirFunctionTypeGetInput();
+extern void mlirFunctionTypeGetNumInputs();
+extern void mlirFunctionTypeGetNumResults();
+extern void mlirFunctionTypeGetResult();
+extern void mlirGetDialectHandle__iree_input__();
+extern void mlirGetDialectHandle__iree_linalg_ext__();
+extern void mlirGetDialectHandle__iree_linalg_transform__();
+extern void mlirGetDialectHandle__transform__();
+extern void mlirIREELinalgTransformRegisterPasses();
+extern void mlirIREETransformRegisterPasses();
+extern void mlirIdentifierEqual();
+extern void mlirIdentifierGet();
+extern void mlirIdentifierGetContext();
+extern void mlirIdentifierStr();
+extern void mlirIndexTypeGet();
+extern void mlirInferTypeOpInterfaceInferReturnTypes();
+extern void mlirInferTypeOpInterfaceTypeID();
+extern void mlirIntegerAttrGet();
+extern void mlirIntegerAttrGetValueInt();
+extern void mlirIntegerAttrGetValueSInt();
+extern void mlirIntegerAttrGetValueUInt();
+extern void mlirIntegerSetDump();
+extern void mlirIntegerSetEmptyGet();
+extern void mlirIntegerSetEqual();
+extern void mlirIntegerSetGet();
+extern void mlirIntegerSetGetConstraint();
+extern void mlirIntegerSetGetContext();
+extern void mlirIntegerSetGetNumConstraints();
+extern void mlirIntegerSetGetNumDims();
+extern void mlirIntegerSetGetNumEqualities();
+extern void mlirIntegerSetGetNumInequalities();
+extern void mlirIntegerSetGetNumInputs();
+extern void mlirIntegerSetGetNumSymbols();
+extern void mlirIntegerSetIsCanonicalEmpty();
+extern void mlirIntegerSetIsConstraintEq();
+extern void mlirIntegerSetPrint();
+extern void mlirIntegerSetReplaceGet();
+extern void mlirIntegerTypeGet();
+extern void mlirIntegerTypeGetWidth();
+extern void mlirIntegerTypeIsSigned();
+extern void mlirIntegerTypeIsSignless();
+extern void mlirIntegerTypeIsUnsigned();
+extern void mlirIntegerTypeSignedGet();
+extern void mlirIntegerTypeUnsignedGet();
+extern void mlirIsGlobalDebugEnabled();
+extern void mlirLinalgFillBuiltinNamedOpRegion();
+extern void mlirLocationCallSiteGet();
+extern void mlirLocationEqual();
+extern void mlirLocationFileLineColGet();
+extern void mlirLocationFusedGet();
+extern void mlirLocationGetContext();
+extern void mlirLocationNameGet();
+extern void mlirLocationPrint();
+extern void mlirLocationUnknownGet();
+extern void mlirMemRefTypeContiguousGet();
+extern void mlirMemRefTypeContiguousGetChecked();
+extern void mlirMemRefTypeGet();
+extern void mlirMemRefTypeGetAffineMap();
+extern void mlirMemRefTypeGetChecked();
+extern void mlirMemRefTypeGetLayout();
+extern void mlirMemRefTypeGetMemorySpace();
+extern void mlirModuleCreateEmpty();
+extern void mlirModuleCreateParse();
+extern void mlirModuleDestroy();
+extern void mlirModuleFromOperation();
+extern void mlirModuleGetBody();
+extern void mlirModuleGetContext();
+extern void mlirModuleGetOperation();
+extern void mlirNamedAttributeGet();
+extern void mlirNoneTypeGet();
+extern void mlirOpPassManagerAddOwnedPass();
+extern void mlirOpPassManagerAddPipeline();
+extern void mlirOpPassManagerGetNestedUnder();
+extern void mlirOpPrintingFlagsCreate();
+extern void mlirOpPrintingFlagsDestroy();
+extern void mlirOpPrintingFlagsElideLargeElementsAttrs();
+extern void mlirOpPrintingFlagsEnableDebugInfo();
+extern void mlirOpPrintingFlagsPrintGenericOpForm();
+extern void mlirOpPrintingFlagsUseLocalScope();
+extern void mlirOpResultGetOwner();
+extern void mlirOpResultGetResultNumber();
+extern void mlirOpaqueAttrGet();
+extern void mlirOpaqueAttrGetData();
+extern void mlirOpaqueAttrGetDialectNamespace();
+extern void mlirOpaqueTypeGet();
+extern void mlirOpaqueTypeGetData();
+extern void mlirOpaqueTypeGetDialectNamespace();
+extern void mlirOperationClone();
+extern void mlirOperationCreate();
+extern void mlirOperationDestroy();
+extern void mlirOperationDump();
+extern void mlirOperationEqual();
+extern void mlirOperationGetAttribute();
+extern void mlirOperationGetAttributeByName();
+extern void mlirOperationGetBlock();
+extern void mlirOperationGetContext();
+extern void mlirOperationGetFirstRegion();
+extern void mlirOperationGetLocation();
+extern void mlirOperationGetName();
+extern void mlirOperationGetNextInBlock();
+extern void mlirOperationGetNumAttributes();
+extern void mlirOperationGetNumOperands();
+extern void mlirOperationGetNumRegions();
+extern void mlirOperationGetNumResults();
+extern void mlirOperationGetNumSuccessors();
+extern void mlirOperationGetOperand();
+extern void mlirOperationGetParentOperation();
+extern void mlirOperationGetRegion();
+extern void mlirOperationGetResult();
+extern void mlirOperationGetSuccessor();
+extern void mlirOperationGetTypeID();
+extern void mlirOperationImplementsInterface();
+extern void mlirOperationImplementsInterfaceStatic();
+extern void mlirOperationMoveAfter();
+extern void mlirOperationMoveBefore();
+extern void mlirOperationPrint();
+extern void mlirOperationPrintWithFlags();
+extern void mlirOperationRemoveAttributeByName();
+extern void mlirOperationRemoveFromParent();
+extern void mlirOperationSetAttributeByName();
+extern void mlirOperationSetOperand();
+extern void mlirOperationStateAddAttributes();
+extern void mlirOperationStateAddOperands();
+extern void mlirOperationStateAddOwnedRegions();
+extern void mlirOperationStateAddResults();
+extern void mlirOperationStateAddSuccessors();
+extern void mlirOperationStateEnableResultTypeInference();
+extern void mlirOperationStateGet();
+extern void mlirOperationVerify();
+extern void mlirOperationWriteBytecode();
+extern void mlirPDLAttributeTypeGet();
+extern void mlirPDLOperationTypeGet();
+extern void mlirPDLRangeTypeGet();
+extern void mlirPDLRangeTypeGetElementType();
+extern void mlirPDLTypeTypeGet();
+extern void mlirPDLValueTypeGet();
+extern void mlirParsePassPipeline();
+extern void mlirPassManagerAddOwnedPass();
+extern void mlirPassManagerCreate();
+extern void mlirPassManagerCreateOnOperation();
+extern void mlirPassManagerDestroy();
+extern void mlirPassManagerEnableIRPrinting();
+extern void mlirPassManagerEnableVerifier();
+extern void mlirPassManagerGetAsOpPassManager();
+extern void mlirPassManagerGetNestedUnder();
+extern void mlirPassManagerRun();
+extern void mlirPrintPassPipeline();
+extern void mlirRankedTensorTypeGet();
+extern void mlirRankedTensorTypeGetChecked();
+extern void mlirRankedTensorTypeGetEncoding();
+extern void mlirRegionAppendOwnedBlock();
+extern void mlirRegionCreate();
+extern void mlirRegionDestroy();
+extern void mlirRegionEqual();
+extern void mlirRegionGetFirstBlock();
+extern void mlirRegionGetNextInOperation();
+extern void mlirRegionInsertOwnedBlock();
+extern void mlirRegionInsertOwnedBlockAfter();
+extern void mlirRegionInsertOwnedBlockBefore();
+extern void mlirRegisterLinalgPasses();
+extern void mlirShapedTypeGetDimSize();
+extern void mlirShapedTypeGetDynamicSize();
+extern void mlirShapedTypeGetDynamicStrideOrOffset();
+extern void mlirShapedTypeGetElementType();
+extern void mlirShapedTypeGetRank();
+extern void mlirShapedTypeHasRank();
+extern void mlirShapedTypeHasStaticShape();
+extern void mlirShapedTypeIsDynamicDim();
+extern void mlirShapedTypeIsDynamicSize();
+extern void mlirShapedTypeIsDynamicStrideOrOffset();
+extern void mlirSparseElementsAttrGetIndices();
+extern void mlirSparseElementsAttrGetValues();
+extern void mlirSparseElementsAttribute();
+extern void mlirStridedLayoutAttrGet();
+extern void mlirStridedLayoutAttrGetNumStrides();
+extern void mlirStridedLayoutAttrGetOffset();
+extern void mlirStridedLayoutAttrGetStride();
+extern void mlirStringAttrGet();
+extern void mlirStringAttrGetValue();
+extern void mlirStringAttrTypedGet();
+extern void mlirStringRefCreateFromCString();
+extern void mlirStringRefEqual();
+extern void mlirSymbolRefAttrGet();
+extern void mlirSymbolRefAttrGetLeafReference();
+extern void mlirSymbolRefAttrGetNestedReference();
+extern void mlirSymbolRefAttrGetNumNestedReferences();
+extern void mlirSymbolRefAttrGetRootReference();
+extern void mlirSymbolTableCreate();
+extern void mlirSymbolTableDestroy();
+extern void mlirSymbolTableErase();
+extern void mlirSymbolTableGetSymbolAttributeName();
+extern void mlirSymbolTableGetVisibilityAttributeName();
+extern void mlirSymbolTableInsert();
+extern void mlirSymbolTableLookup();
+extern void mlirSymbolTableReplaceAllSymbolUses();
+extern void mlirSymbolTableWalkSymbolTables();
+extern void mlirTransformAnyOpTypeGet();
+extern void mlirTransformOperationTypeGet();
+extern void mlirTransformOperationTypeGetOperationName();
+extern void mlirTupleTypeGet();
+extern void mlirTupleTypeGetNumTypes();
+extern void mlirTupleTypeGetType();
+extern void mlirTypeAttrGet();
+extern void mlirTypeAttrGetValue();
+extern void mlirTypeDump();
+extern void mlirTypeEqual();
+extern void mlirTypeGetContext();
+extern void mlirTypeGetTypeID();
+extern void mlirTypeIDAllocatorAllocateTypeID();
+extern void mlirTypeIDAllocatorCreate();
+extern void mlirTypeIDAllocatorDestroy();
+extern void mlirTypeIDCreate();
+extern void mlirTypeIDEqual();
+extern void mlirTypeIDHashValue();
+extern void mlirTypeIsABF16();
+extern void mlirTypeIsAComplex();
+extern void mlirTypeIsAF16();
+extern void mlirTypeIsAF32();
+extern void mlirTypeIsAF64();
+extern void mlirTypeIsAFloat8E4M3FN();
+extern void mlirTypeIsAFloat8E5M2();
+extern void mlirTypeIsAFunction();
+extern void mlirTypeIsAIndex();
+extern void mlirTypeIsAInteger();
+extern void mlirTypeIsAMemRef();
+extern void mlirTypeIsANone();
+extern void mlirTypeIsAOpaque();
+extern void mlirTypeIsAPDLAttributeType();
+extern void mlirTypeIsAPDLOperationType();
+extern void mlirTypeIsAPDLRangeType();
+extern void mlirTypeIsAPDLType();
+extern void mlirTypeIsAPDLTypeType();
+extern void mlirTypeIsAPDLValueType();
+extern void mlirTypeIsARankedTensor();
+extern void mlirTypeIsAShaped();
+extern void mlirTypeIsATensor();
+extern void mlirTypeIsATransformAnyOpType();
+extern void mlirTypeIsATransformOperationType();
+extern void mlirTypeIsATuple();
+extern void mlirTypeIsAUnrankedMemRef();
+extern void mlirTypeIsAUnrankedTensor();
+extern void mlirTypeIsAVector();
+extern void mlirTypeParseGet();
+extern void mlirTypePrint();
+extern void mlirUnitAttrGet();
+extern void mlirUnrankedMemRefTypeGet();
+extern void mlirUnrankedMemRefTypeGetChecked();
+extern void mlirUnrankedMemrefGetMemorySpace();
+extern void mlirUnrankedTensorTypeGet();
+extern void mlirUnrankedTensorTypeGetChecked();
+extern void mlirValueDump();
+extern void mlirValueEqual();
+extern void mlirValueGetType();
+extern void mlirValueIsABlockArgument();
+extern void mlirValueIsAOpResult();
+extern void mlirValuePrint();
+extern void mlirVectorTypeGet();
+extern void mlirVectorTypeGetChecked();
+
+uintptr_t __iree_compiler_hidden_force_extern() {
+  uintptr_t x = 0;
+  x += (uintptr_t)&ireeCompilerBuildIREEVMPassPipeline;
+  x += (uintptr_t)&ireeCompilerOptionsCreate;
+  x += (uintptr_t)&ireeCompilerOptionsDestroy;
+  x += (uintptr_t)&ireeCompilerOptionsGetFlags;
+  x += (uintptr_t)&ireeCompilerOptionsSetFlags;
+  x += (uintptr_t)&ireeCompilerRegisterAllDialects;
+  x += (uintptr_t)&ireeCompilerRegisterAllPasses;
+  x += (uintptr_t)&ireeCompilerRegisterTargetBackends;
+  x += (uintptr_t)&ireeCompilerRunLldMain;
+  x += (uintptr_t)&ireeCompilerRunMain;
+  x += (uintptr_t)&ireeCompilerTranslateModuletoVMBytecode;
+  x += (uintptr_t)&ireeMlirLspServerRunMain;
+  x += (uintptr_t)&ireeOptRunMain;
+  x += (uintptr_t)&ireeRegisterTransformExtensions;
+  x += (uintptr_t)&mlirAffineAddExprGet;
+  x += (uintptr_t)&mlirAffineBinaryOpExprGetLHS;
+  x += (uintptr_t)&mlirAffineBinaryOpExprGetRHS;
+  x += (uintptr_t)&mlirAffineCeilDivExprGet;
+  x += (uintptr_t)&mlirAffineConstantExprGet;
+  x += (uintptr_t)&mlirAffineConstantExprGetValue;
+  x += (uintptr_t)&mlirAffineDimExprGet;
+  x += (uintptr_t)&mlirAffineDimExprGetPosition;
+  x += (uintptr_t)&mlirAffineExprCompose;
+  x += (uintptr_t)&mlirAffineExprDump;
+  x += (uintptr_t)&mlirAffineExprEqual;
+  x += (uintptr_t)&mlirAffineExprGetContext;
+  x += (uintptr_t)&mlirAffineExprGetLargestKnownDivisor;
+  x += (uintptr_t)&mlirAffineExprIsAAdd;
+  x += (uintptr_t)&mlirAffineExprIsABinary;
+  x += (uintptr_t)&mlirAffineExprIsACeilDiv;
+  x += (uintptr_t)&mlirAffineExprIsAConstant;
+  x += (uintptr_t)&mlirAffineExprIsADim;
+  x += (uintptr_t)&mlirAffineExprIsAFloorDiv;
+  x += (uintptr_t)&mlirAffineExprIsAMod;
+  x += (uintptr_t)&mlirAffineExprIsAMul;
+  x += (uintptr_t)&mlirAffineExprIsASymbol;
+  x += (uintptr_t)&mlirAffineExprIsFunctionOfDim;
+  x += (uintptr_t)&mlirAffineExprIsMultipleOf;
+  x += (uintptr_t)&mlirAffineExprIsPureAffine;
+  x += (uintptr_t)&mlirAffineExprIsSymbolicOrConstant;
+  x += (uintptr_t)&mlirAffineExprPrint;
+  x += (uintptr_t)&mlirAffineFloorDivExprGet;
+  x += (uintptr_t)&mlirAffineMapAttrGet;
+  x += (uintptr_t)&mlirAffineMapAttrGetValue;
+  x += (uintptr_t)&mlirAffineMapCompressUnusedSymbols;
+  x += (uintptr_t)&mlirAffineMapConstantGet;
+  x += (uintptr_t)&mlirAffineMapDump;
+  x += (uintptr_t)&mlirAffineMapEmptyGet;
+  x += (uintptr_t)&mlirAffineMapEqual;
+  x += (uintptr_t)&mlirAffineMapGet;
+  x += (uintptr_t)&mlirAffineMapGetContext;
+  x += (uintptr_t)&mlirAffineMapGetMajorSubMap;
+  x += (uintptr_t)&mlirAffineMapGetMinorSubMap;
+  x += (uintptr_t)&mlirAffineMapGetNumDims;
+  x += (uintptr_t)&mlirAffineMapGetNumInputs;
+  x += (uintptr_t)&mlirAffineMapGetNumResults;
+  x += (uintptr_t)&mlirAffineMapGetNumSymbols;
+  x += (uintptr_t)&mlirAffineMapGetResult;
+  x += (uintptr_t)&mlirAffineMapGetSingleConstantResult;
+  x += (uintptr_t)&mlirAffineMapGetSubMap;
+  x += (uintptr_t)&mlirAffineMapIsEmpty;
+  x += (uintptr_t)&mlirAffineMapIsIdentity;
+  x += (uintptr_t)&mlirAffineMapIsMinorIdentity;
+  x += (uintptr_t)&mlirAffineMapIsPermutation;
+  x += (uintptr_t)&mlirAffineMapIsProjectedPermutation;
+  x += (uintptr_t)&mlirAffineMapIsSingleConstant;
+  x += (uintptr_t)&mlirAffineMapMinorIdentityGet;
+  x += (uintptr_t)&mlirAffineMapMultiDimIdentityGet;
+  x += (uintptr_t)&mlirAffineMapPermutationGet;
+  x += (uintptr_t)&mlirAffineMapPrint;
+  x += (uintptr_t)&mlirAffineMapReplace;
+  x += (uintptr_t)&mlirAffineMapZeroResultGet;
+  x += (uintptr_t)&mlirAffineModExprGet;
+  x += (uintptr_t)&mlirAffineMulExprGet;
+  x += (uintptr_t)&mlirAffineSymbolExprGet;
+  x += (uintptr_t)&mlirAffineSymbolExprGetPosition;
+  x += (uintptr_t)&mlirArrayAttrGet;
+  x += (uintptr_t)&mlirArrayAttrGetElement;
+  x += (uintptr_t)&mlirArrayAttrGetNumElements;
+  x += (uintptr_t)&mlirAttributeDump;
+  x += (uintptr_t)&mlirAttributeEqual;
+  x += (uintptr_t)&mlirAttributeGetContext;
+  x += (uintptr_t)&mlirAttributeGetNull;
+  x += (uintptr_t)&mlirAttributeGetType;
+  x += (uintptr_t)&mlirAttributeGetTypeID;
+  x += (uintptr_t)&mlirAttributeIsAAffineMap;
+  x += (uintptr_t)&mlirAttributeIsAArray;
+  x += (uintptr_t)&mlirAttributeIsABool;
+  x += (uintptr_t)&mlirAttributeIsADenseBoolArray;
+  x += (uintptr_t)&mlirAttributeIsADenseElements;
+  x += (uintptr_t)&mlirAttributeIsADenseF32Array;
+  x += (uintptr_t)&mlirAttributeIsADenseF64Array;
+  x += (uintptr_t)&mlirAttributeIsADenseFPElements;
+  x += (uintptr_t)&mlirAttributeIsADenseI16Array;
+  x += (uintptr_t)&mlirAttributeIsADenseI32Array;
+  x += (uintptr_t)&mlirAttributeIsADenseI64Array;
+  x += (uintptr_t)&mlirAttributeIsADenseI8Array;
+  x += (uintptr_t)&mlirAttributeIsADenseIntElements;
+  x += (uintptr_t)&mlirAttributeIsADictionary;
+  x += (uintptr_t)&mlirAttributeIsAElements;
+  x += (uintptr_t)&mlirAttributeIsAFlatSymbolRef;
+  x += (uintptr_t)&mlirAttributeIsAFloat;
+  x += (uintptr_t)&mlirAttributeIsAInteger;
+  x += (uintptr_t)&mlirAttributeIsAIntegerSet;
+  x += (uintptr_t)&mlirAttributeIsAOpaque;
+  x += (uintptr_t)&mlirAttributeIsASparseElements;
+  x += (uintptr_t)&mlirAttributeIsAStridedLayout;
+  x += (uintptr_t)&mlirAttributeIsAString;
+  x += (uintptr_t)&mlirAttributeIsASymbolRef;
+  x += (uintptr_t)&mlirAttributeIsAType;
+  x += (uintptr_t)&mlirAttributeIsAUnit;
+  x += (uintptr_t)&mlirAttributeParseGet;
+  x += (uintptr_t)&mlirAttributePrint;
+  x += (uintptr_t)&mlirBF16TypeGet;
+  x += (uintptr_t)&mlirBlockAddArgument;
+  x += (uintptr_t)&mlirBlockAppendOwnedOperation;
+  x += (uintptr_t)&mlirBlockArgumentGetArgNumber;
+  x += (uintptr_t)&mlirBlockArgumentGetOwner;
+  x += (uintptr_t)&mlirBlockArgumentSetType;
+  x += (uintptr_t)&mlirBlockCreate;
+  x += (uintptr_t)&mlirBlockDestroy;
+  x += (uintptr_t)&mlirBlockDetach;
+  x += (uintptr_t)&mlirBlockEqual;
+  x += (uintptr_t)&mlirBlockGetArgument;
+  x += (uintptr_t)&mlirBlockGetFirstOperation;
+  x += (uintptr_t)&mlirBlockGetNextInRegion;
+  x += (uintptr_t)&mlirBlockGetNumArguments;
+  x += (uintptr_t)&mlirBlockGetParentOperation;
+  x += (uintptr_t)&mlirBlockGetParentRegion;
+  x += (uintptr_t)&mlirBlockGetTerminator;
+  x += (uintptr_t)&mlirBlockInsertOwnedOperation;
+  x += (uintptr_t)&mlirBlockInsertOwnedOperationAfter;
+  x += (uintptr_t)&mlirBlockInsertOwnedOperationBefore;
+  x += (uintptr_t)&mlirBlockPrint;
+  x += (uintptr_t)&mlirBoolAttrGet;
+  x += (uintptr_t)&mlirBoolAttrGetValue;
+  x += (uintptr_t)&mlirComplexTypeGet;
+  x += (uintptr_t)&mlirComplexTypeGetElementType;
+  x += (uintptr_t)&mlirContextAppendDialectRegistry;
+  x += (uintptr_t)&mlirContextAttachDiagnosticHandler;
+  x += (uintptr_t)&mlirContextCreate;
+  x += (uintptr_t)&mlirContextDestroy;
+  x += (uintptr_t)&mlirContextDetachDiagnosticHandler;
+  x += (uintptr_t)&mlirContextEnableMultithreading;
+  x += (uintptr_t)&mlirContextEqual;
+  x += (uintptr_t)&mlirContextGetAllowUnregisteredDialects;
+  x += (uintptr_t)&mlirContextGetNumLoadedDialects;
+  x += (uintptr_t)&mlirContextGetNumRegisteredDialects;
+  x += (uintptr_t)&mlirContextGetOrLoadDialect;
+  x += (uintptr_t)&mlirContextIsRegisteredOperation;
+  x += (uintptr_t)&mlirContextLoadAllAvailableDialects;
+  x += (uintptr_t)&mlirContextSetAllowUnregisteredDialects;
+  x += (uintptr_t)&mlirCreateExternalPass;
+  x += (uintptr_t)&mlirDenseArrayGetNumElements;
+  x += (uintptr_t)&mlirDenseBoolArrayGet;
+  x += (uintptr_t)&mlirDenseBoolArrayGetElement;
+  x += (uintptr_t)&mlirDenseElementsAttrBFloat16Get;
+  x += (uintptr_t)&mlirDenseElementsAttrBoolGet;
+  x += (uintptr_t)&mlirDenseElementsAttrBoolSplatGet;
+  x += (uintptr_t)&mlirDenseElementsAttrDoubleGet;
+  x += (uintptr_t)&mlirDenseElementsAttrDoubleSplatGet;
+  x += (uintptr_t)&mlirDenseElementsAttrFloat16Get;
+  x += (uintptr_t)&mlirDenseElementsAttrFloatGet;
+  x += (uintptr_t)&mlirDenseElementsAttrFloatSplatGet;
+  x += (uintptr_t)&mlirDenseElementsAttrGet;
+  x += (uintptr_t)&mlirDenseElementsAttrGetBoolSplatValue;
+  x += (uintptr_t)&mlirDenseElementsAttrGetBoolValue;
+  x += (uintptr_t)&mlirDenseElementsAttrGetDoubleSplatValue;
+  x += (uintptr_t)&mlirDenseElementsAttrGetDoubleValue;
+  x += (uintptr_t)&mlirDenseElementsAttrGetFloatSplatValue;
+  x += (uintptr_t)&mlirDenseElementsAttrGetFloatValue;
+  x += (uintptr_t)&mlirDenseElementsAttrGetInt16Value;
+  x += (uintptr_t)&mlirDenseElementsAttrGetInt32SplatValue;
+  x += (uintptr_t)&mlirDenseElementsAttrGetInt32Value;
+  x += (uintptr_t)&mlirDenseElementsAttrGetInt64SplatValue;
+  x += (uintptr_t)&mlirDenseElementsAttrGetInt64Value;
+  x += (uintptr_t)&mlirDenseElementsAttrGetInt8SplatValue;
+  x += (uintptr_t)&mlirDenseElementsAttrGetInt8Value;
+  x += (uintptr_t)&mlirDenseElementsAttrGetRawData;
+  x += (uintptr_t)&mlirDenseElementsAttrGetSplatValue;
+  x += (uintptr_t)&mlirDenseElementsAttrGetStringSplatValue;
+  x += (uintptr_t)&mlirDenseElementsAttrGetStringValue;
+  x += (uintptr_t)&mlirDenseElementsAttrGetUInt16Value;
+  x += (uintptr_t)&mlirDenseElementsAttrGetUInt32SplatValue;
+  x += (uintptr_t)&mlirDenseElementsAttrGetUInt32Value;
+  x += (uintptr_t)&mlirDenseElementsAttrGetUInt64SplatValue;
+  x += (uintptr_t)&mlirDenseElementsAttrGetUInt64Value;
+  x += (uintptr_t)&mlirDenseElementsAttrGetUInt8SplatValue;
+  x += (uintptr_t)&mlirDenseElementsAttrGetUInt8Value;
+  x += (uintptr_t)&mlirDenseElementsAttrInt16Get;
+  x += (uintptr_t)&mlirDenseElementsAttrInt32Get;
+  x += (uintptr_t)&mlirDenseElementsAttrInt32SplatGet;
+  x += (uintptr_t)&mlirDenseElementsAttrInt64Get;
+  x += (uintptr_t)&mlirDenseElementsAttrInt64SplatGet;
+  x += (uintptr_t)&mlirDenseElementsAttrInt8Get;
+  x += (uintptr_t)&mlirDenseElementsAttrInt8SplatGet;
+  x += (uintptr_t)&mlirDenseElementsAttrIsSplat;
+  x += (uintptr_t)&mlirDenseElementsAttrRawBufferGet;
+  x += (uintptr_t)&mlirDenseElementsAttrReshapeGet;
+  x += (uintptr_t)&mlirDenseElementsAttrSplatGet;
+  x += (uintptr_t)&mlirDenseElementsAttrStringGet;
+  x += (uintptr_t)&mlirDenseElementsAttrUInt16Get;
+  x += (uintptr_t)&mlirDenseElementsAttrUInt32Get;
+  x += (uintptr_t)&mlirDenseElementsAttrUInt32SplatGet;
+  x += (uintptr_t)&mlirDenseElementsAttrUInt64Get;
+  x += (uintptr_t)&mlirDenseElementsAttrUInt64SplatGet;
+  x += (uintptr_t)&mlirDenseElementsAttrUInt8Get;
+  x += (uintptr_t)&mlirDenseElementsAttrUInt8SplatGet;
+  x += (uintptr_t)&mlirDenseF32ArrayGet;
+  x += (uintptr_t)&mlirDenseF32ArrayGetElement;
+  x += (uintptr_t)&mlirDenseF64ArrayGet;
+  x += (uintptr_t)&mlirDenseF64ArrayGetElement;
+  x += (uintptr_t)&mlirDenseI16ArrayGet;
+  x += (uintptr_t)&mlirDenseI16ArrayGetElement;
+  x += (uintptr_t)&mlirDenseI32ArrayGet;
+  x += (uintptr_t)&mlirDenseI32ArrayGetElement;
+  x += (uintptr_t)&mlirDenseI64ArrayGet;
+  x += (uintptr_t)&mlirDenseI64ArrayGetElement;
+  x += (uintptr_t)&mlirDenseI8ArrayGet;
+  x += (uintptr_t)&mlirDenseI8ArrayGetElement;
+  x += (uintptr_t)&mlirDiagnosticGetLocation;
+  x += (uintptr_t)&mlirDiagnosticGetNote;
+  x += (uintptr_t)&mlirDiagnosticGetNumNotes;
+  x += (uintptr_t)&mlirDiagnosticGetSeverity;
+  x += (uintptr_t)&mlirDiagnosticPrint;
+  x += (uintptr_t)&mlirDialectEqual;
+  x += (uintptr_t)&mlirDialectGetContext;
+  x += (uintptr_t)&mlirDialectGetNamespace;
+  x += (uintptr_t)&mlirDialectHandleGetNamespace;
+  x += (uintptr_t)&mlirDialectHandleInsertDialect;
+  x += (uintptr_t)&mlirDialectHandleLoadDialect;
+  x += (uintptr_t)&mlirDialectHandleRegisterDialect;
+  x += (uintptr_t)&mlirDialectRegistryCreate;
+  x += (uintptr_t)&mlirDialectRegistryDestroy;
+  x += (uintptr_t)&mlirDictionaryAttrGet;
+  x += (uintptr_t)&mlirDictionaryAttrGetElement;
+  x += (uintptr_t)&mlirDictionaryAttrGetElementByName;
+  x += (uintptr_t)&mlirDictionaryAttrGetNumElements;
+  x += (uintptr_t)&mlirElementsAttrGetNumElements;
+  x += (uintptr_t)&mlirElementsAttrGetValue;
+  x += (uintptr_t)&mlirElementsAttrIsValidIndex;
+  x += (uintptr_t)&mlirEmitError;
+  x += (uintptr_t)&mlirEnableGlobalDebug;
+  x += (uintptr_t)&mlirExternalPassSignalFailure;
+  x += (uintptr_t)&mlirF16TypeGet;
+  x += (uintptr_t)&mlirF32TypeGet;
+  x += (uintptr_t)&mlirF64TypeGet;
+  x += (uintptr_t)&mlirFlatSymbolRefAttrGet;
+  x += (uintptr_t)&mlirFlatSymbolRefAttrGetValue;
+  x += (uintptr_t)&mlirFloat8E4M3FNTypeGet;
+  x += (uintptr_t)&mlirFloat8E5M2TypeGet;
+  x += (uintptr_t)&mlirFloatAttrDoubleGet;
+  x += (uintptr_t)&mlirFloatAttrDoubleGetChecked;
+  x += (uintptr_t)&mlirFloatAttrGetValueDouble;
+  x += (uintptr_t)&mlirFunctionTypeGet;
+  x += (uintptr_t)&mlirFunctionTypeGetInput;
+  x += (uintptr_t)&mlirFunctionTypeGetNumInputs;
+  x += (uintptr_t)&mlirFunctionTypeGetNumResults;
+  x += (uintptr_t)&mlirFunctionTypeGetResult;
+  x += (uintptr_t)&mlirGetDialectHandle__iree_input__;
+  x += (uintptr_t)&mlirGetDialectHandle__iree_linalg_ext__;
+  x += (uintptr_t)&mlirGetDialectHandle__iree_linalg_transform__;
+  x += (uintptr_t)&mlirGetDialectHandle__transform__;
+  x += (uintptr_t)&mlirIREELinalgTransformRegisterPasses;
+  x += (uintptr_t)&mlirIREETransformRegisterPasses;
+  x += (uintptr_t)&mlirIdentifierEqual;
+  x += (uintptr_t)&mlirIdentifierGet;
+  x += (uintptr_t)&mlirIdentifierGetContext;
+  x += (uintptr_t)&mlirIdentifierStr;
+  x += (uintptr_t)&mlirIndexTypeGet;
+  x += (uintptr_t)&mlirInferTypeOpInterfaceInferReturnTypes;
+  x += (uintptr_t)&mlirInferTypeOpInterfaceTypeID;
+  x += (uintptr_t)&mlirIntegerAttrGet;
+  x += (uintptr_t)&mlirIntegerAttrGetValueInt;
+  x += (uintptr_t)&mlirIntegerAttrGetValueSInt;
+  x += (uintptr_t)&mlirIntegerAttrGetValueUInt;
+  x += (uintptr_t)&mlirIntegerSetDump;
+  x += (uintptr_t)&mlirIntegerSetEmptyGet;
+  x += (uintptr_t)&mlirIntegerSetEqual;
+  x += (uintptr_t)&mlirIntegerSetGet;
+  x += (uintptr_t)&mlirIntegerSetGetConstraint;
+  x += (uintptr_t)&mlirIntegerSetGetContext;
+  x += (uintptr_t)&mlirIntegerSetGetNumConstraints;
+  x += (uintptr_t)&mlirIntegerSetGetNumDims;
+  x += (uintptr_t)&mlirIntegerSetGetNumEqualities;
+  x += (uintptr_t)&mlirIntegerSetGetNumInequalities;
+  x += (uintptr_t)&mlirIntegerSetGetNumInputs;
+  x += (uintptr_t)&mlirIntegerSetGetNumSymbols;
+  x += (uintptr_t)&mlirIntegerSetIsCanonicalEmpty;
+  x += (uintptr_t)&mlirIntegerSetIsConstraintEq;
+  x += (uintptr_t)&mlirIntegerSetPrint;
+  x += (uintptr_t)&mlirIntegerSetReplaceGet;
+  x += (uintptr_t)&mlirIntegerTypeGet;
+  x += (uintptr_t)&mlirIntegerTypeGetWidth;
+  x += (uintptr_t)&mlirIntegerTypeIsSigned;
+  x += (uintptr_t)&mlirIntegerTypeIsSignless;
+  x += (uintptr_t)&mlirIntegerTypeIsUnsigned;
+  x += (uintptr_t)&mlirIntegerTypeSignedGet;
+  x += (uintptr_t)&mlirIntegerTypeUnsignedGet;
+  x += (uintptr_t)&mlirIsGlobalDebugEnabled;
+  x += (uintptr_t)&mlirLinalgFillBuiltinNamedOpRegion;
+  x += (uintptr_t)&mlirLocationCallSiteGet;
+  x += (uintptr_t)&mlirLocationEqual;
+  x += (uintptr_t)&mlirLocationFileLineColGet;
+  x += (uintptr_t)&mlirLocationFusedGet;
+  x += (uintptr_t)&mlirLocationGetContext;
+  x += (uintptr_t)&mlirLocationNameGet;
+  x += (uintptr_t)&mlirLocationPrint;
+  x += (uintptr_t)&mlirLocationUnknownGet;
+  x += (uintptr_t)&mlirMemRefTypeContiguousGet;
+  x += (uintptr_t)&mlirMemRefTypeContiguousGetChecked;
+  x += (uintptr_t)&mlirMemRefTypeGet;
+  x += (uintptr_t)&mlirMemRefTypeGetAffineMap;
+  x += (uintptr_t)&mlirMemRefTypeGetChecked;
+  x += (uintptr_t)&mlirMemRefTypeGetLayout;
+  x += (uintptr_t)&mlirMemRefTypeGetMemorySpace;
+  x += (uintptr_t)&mlirModuleCreateEmpty;
+  x += (uintptr_t)&mlirModuleCreateParse;
+  x += (uintptr_t)&mlirModuleDestroy;
+  x += (uintptr_t)&mlirModuleFromOperation;
+  x += (uintptr_t)&mlirModuleGetBody;
+  x += (uintptr_t)&mlirModuleGetContext;
+  x += (uintptr_t)&mlirModuleGetOperation;
+  x += (uintptr_t)&mlirNamedAttributeGet;
+  x += (uintptr_t)&mlirNoneTypeGet;
+  x += (uintptr_t)&mlirOpPassManagerAddOwnedPass;
+  x += (uintptr_t)&mlirOpPassManagerAddPipeline;
+  x += (uintptr_t)&mlirOpPassManagerGetNestedUnder;
+  x += (uintptr_t)&mlirOpPrintingFlagsCreate;
+  x += (uintptr_t)&mlirOpPrintingFlagsDestroy;
+  x += (uintptr_t)&mlirOpPrintingFlagsElideLargeElementsAttrs;
+  x += (uintptr_t)&mlirOpPrintingFlagsEnableDebugInfo;
+  x += (uintptr_t)&mlirOpPrintingFlagsPrintGenericOpForm;
+  x += (uintptr_t)&mlirOpPrintingFlagsUseLocalScope;
+  x += (uintptr_t)&mlirOpResultGetOwner;
+  x += (uintptr_t)&mlirOpResultGetResultNumber;
+  x += (uintptr_t)&mlirOpaqueAttrGet;
+  x += (uintptr_t)&mlirOpaqueAttrGetData;
+  x += (uintptr_t)&mlirOpaqueAttrGetDialectNamespace;
+  x += (uintptr_t)&mlirOpaqueTypeGet;
+  x += (uintptr_t)&mlirOpaqueTypeGetData;
+  x += (uintptr_t)&mlirOpaqueTypeGetDialectNamespace;
+  x += (uintptr_t)&mlirOperationClone;
+  x += (uintptr_t)&mlirOperationCreate;
+  x += (uintptr_t)&mlirOperationDestroy;
+  x += (uintptr_t)&mlirOperationDump;
+  x += (uintptr_t)&mlirOperationEqual;
+  x += (uintptr_t)&mlirOperationGetAttribute;
+  x += (uintptr_t)&mlirOperationGetAttributeByName;
+  x += (uintptr_t)&mlirOperationGetBlock;
+  x += (uintptr_t)&mlirOperationGetContext;
+  x += (uintptr_t)&mlirOperationGetFirstRegion;
+  x += (uintptr_t)&mlirOperationGetLocation;
+  x += (uintptr_t)&mlirOperationGetName;
+  x += (uintptr_t)&mlirOperationGetNextInBlock;
+  x += (uintptr_t)&mlirOperationGetNumAttributes;
+  x += (uintptr_t)&mlirOperationGetNumOperands;
+  x += (uintptr_t)&mlirOperationGetNumRegions;
+  x += (uintptr_t)&mlirOperationGetNumResults;
+  x += (uintptr_t)&mlirOperationGetNumSuccessors;
+  x += (uintptr_t)&mlirOperationGetOperand;
+  x += (uintptr_t)&mlirOperationGetParentOperation;
+  x += (uintptr_t)&mlirOperationGetRegion;
+  x += (uintptr_t)&mlirOperationGetResult;
+  x += (uintptr_t)&mlirOperationGetSuccessor;
+  x += (uintptr_t)&mlirOperationGetTypeID;
+  x += (uintptr_t)&mlirOperationImplementsInterface;
+  x += (uintptr_t)&mlirOperationImplementsInterfaceStatic;
+  x += (uintptr_t)&mlirOperationMoveAfter;
+  x += (uintptr_t)&mlirOperationMoveBefore;
+  x += (uintptr_t)&mlirOperationPrint;
+  x += (uintptr_t)&mlirOperationPrintWithFlags;
+  x += (uintptr_t)&mlirOperationRemoveAttributeByName;
+  x += (uintptr_t)&mlirOperationRemoveFromParent;
+  x += (uintptr_t)&mlirOperationSetAttributeByName;
+  x += (uintptr_t)&mlirOperationSetOperand;
+  x += (uintptr_t)&mlirOperationStateAddAttributes;
+  x += (uintptr_t)&mlirOperationStateAddOperands;
+  x += (uintptr_t)&mlirOperationStateAddOwnedRegions;
+  x += (uintptr_t)&mlirOperationStateAddResults;
+  x += (uintptr_t)&mlirOperationStateAddSuccessors;
+  x += (uintptr_t)&mlirOperationStateEnableResultTypeInference;
+  x += (uintptr_t)&mlirOperationStateGet;
+  x += (uintptr_t)&mlirOperationVerify;
+  x += (uintptr_t)&mlirOperationWriteBytecode;
+  x += (uintptr_t)&mlirPDLAttributeTypeGet;
+  x += (uintptr_t)&mlirPDLOperationTypeGet;
+  x += (uintptr_t)&mlirPDLRangeTypeGet;
+  x += (uintptr_t)&mlirPDLRangeTypeGetElementType;
+  x += (uintptr_t)&mlirPDLTypeTypeGet;
+  x += (uintptr_t)&mlirPDLValueTypeGet;
+  x += (uintptr_t)&mlirParsePassPipeline;
+  x += (uintptr_t)&mlirPassManagerAddOwnedPass;
+  x += (uintptr_t)&mlirPassManagerCreate;
+  x += (uintptr_t)&mlirPassManagerCreateOnOperation;
+  x += (uintptr_t)&mlirPassManagerDestroy;
+  x += (uintptr_t)&mlirPassManagerEnableIRPrinting;
+  x += (uintptr_t)&mlirPassManagerEnableVerifier;
+  x += (uintptr_t)&mlirPassManagerGetAsOpPassManager;
+  x += (uintptr_t)&mlirPassManagerGetNestedUnder;
+  x += (uintptr_t)&mlirPassManagerRun;
+  x += (uintptr_t)&mlirPrintPassPipeline;
+  x += (uintptr_t)&mlirRankedTensorTypeGet;
+  x += (uintptr_t)&mlirRankedTensorTypeGetChecked;
+  x += (uintptr_t)&mlirRankedTensorTypeGetEncoding;
+  x += (uintptr_t)&mlirRegionAppendOwnedBlock;
+  x += (uintptr_t)&mlirRegionCreate;
+  x += (uintptr_t)&mlirRegionDestroy;
+  x += (uintptr_t)&mlirRegionEqual;
+  x += (uintptr_t)&mlirRegionGetFirstBlock;
+  x += (uintptr_t)&mlirRegionGetNextInOperation;
+  x += (uintptr_t)&mlirRegionInsertOwnedBlock;
+  x += (uintptr_t)&mlirRegionInsertOwnedBlockAfter;
+  x += (uintptr_t)&mlirRegionInsertOwnedBlockBefore;
+  x += (uintptr_t)&mlirRegisterLinalgPasses;
+  x += (uintptr_t)&mlirShapedTypeGetDimSize;
+  x += (uintptr_t)&mlirShapedTypeGetDynamicSize;
+  x += (uintptr_t)&mlirShapedTypeGetDynamicStrideOrOffset;
+  x += (uintptr_t)&mlirShapedTypeGetElementType;
+  x += (uintptr_t)&mlirShapedTypeGetRank;
+  x += (uintptr_t)&mlirShapedTypeHasRank;
+  x += (uintptr_t)&mlirShapedTypeHasStaticShape;
+  x += (uintptr_t)&mlirShapedTypeIsDynamicDim;
+  x += (uintptr_t)&mlirShapedTypeIsDynamicSize;
+  x += (uintptr_t)&mlirShapedTypeIsDynamicStrideOrOffset;
+  x += (uintptr_t)&mlirSparseElementsAttrGetIndices;
+  x += (uintptr_t)&mlirSparseElementsAttrGetValues;
+  x += (uintptr_t)&mlirSparseElementsAttribute;
+  x += (uintptr_t)&mlirStridedLayoutAttrGet;
+  x += (uintptr_t)&mlirStridedLayoutAttrGetNumStrides;
+  x += (uintptr_t)&mlirStridedLayoutAttrGetOffset;
+  x += (uintptr_t)&mlirStridedLayoutAttrGetStride;
+  x += (uintptr_t)&mlirStringAttrGet;
+  x += (uintptr_t)&mlirStringAttrGetValue;
+  x += (uintptr_t)&mlirStringAttrTypedGet;
+  x += (uintptr_t)&mlirStringRefCreateFromCString;
+  x += (uintptr_t)&mlirStringRefEqual;
+  x += (uintptr_t)&mlirSymbolRefAttrGet;
+  x += (uintptr_t)&mlirSymbolRefAttrGetLeafReference;
+  x += (uintptr_t)&mlirSymbolRefAttrGetNestedReference;
+  x += (uintptr_t)&mlirSymbolRefAttrGetNumNestedReferences;
+  x += (uintptr_t)&mlirSymbolRefAttrGetRootReference;
+  x += (uintptr_t)&mlirSymbolTableCreate;
+  x += (uintptr_t)&mlirSymbolTableDestroy;
+  x += (uintptr_t)&mlirSymbolTableErase;
+  x += (uintptr_t)&mlirSymbolTableGetSymbolAttributeName;
+  x += (uintptr_t)&mlirSymbolTableGetVisibilityAttributeName;
+  x += (uintptr_t)&mlirSymbolTableInsert;
+  x += (uintptr_t)&mlirSymbolTableLookup;
+  x += (uintptr_t)&mlirSymbolTableReplaceAllSymbolUses;
+  x += (uintptr_t)&mlirSymbolTableWalkSymbolTables;
+  x += (uintptr_t)&mlirTransformAnyOpTypeGet;
+  x += (uintptr_t)&mlirTransformOperationTypeGet;
+  x += (uintptr_t)&mlirTransformOperationTypeGetOperationName;
+  x += (uintptr_t)&mlirTupleTypeGet;
+  x += (uintptr_t)&mlirTupleTypeGetNumTypes;
+  x += (uintptr_t)&mlirTupleTypeGetType;
+  x += (uintptr_t)&mlirTypeAttrGet;
+  x += (uintptr_t)&mlirTypeAttrGetValue;
+  x += (uintptr_t)&mlirTypeDump;
+  x += (uintptr_t)&mlirTypeEqual;
+  x += (uintptr_t)&mlirTypeGetContext;
+  x += (uintptr_t)&mlirTypeGetTypeID;
+  x += (uintptr_t)&mlirTypeIDAllocatorAllocateTypeID;
+  x += (uintptr_t)&mlirTypeIDAllocatorCreate;
+  x += (uintptr_t)&mlirTypeIDAllocatorDestroy;
+  x += (uintptr_t)&mlirTypeIDCreate;
+  x += (uintptr_t)&mlirTypeIDEqual;
+  x += (uintptr_t)&mlirTypeIDHashValue;
+  x += (uintptr_t)&mlirTypeIsABF16;
+  x += (uintptr_t)&mlirTypeIsAComplex;
+  x += (uintptr_t)&mlirTypeIsAF16;
+  x += (uintptr_t)&mlirTypeIsAF32;
+  x += (uintptr_t)&mlirTypeIsAF64;
+  x += (uintptr_t)&mlirTypeIsAFloat8E4M3FN;
+  x += (uintptr_t)&mlirTypeIsAFloat8E5M2;
+  x += (uintptr_t)&mlirTypeIsAFunction;
+  x += (uintptr_t)&mlirTypeIsAIndex;
+  x += (uintptr_t)&mlirTypeIsAInteger;
+  x += (uintptr_t)&mlirTypeIsAMemRef;
+  x += (uintptr_t)&mlirTypeIsANone;
+  x += (uintptr_t)&mlirTypeIsAOpaque;
+  x += (uintptr_t)&mlirTypeIsAPDLAttributeType;
+  x += (uintptr_t)&mlirTypeIsAPDLOperationType;
+  x += (uintptr_t)&mlirTypeIsAPDLRangeType;
+  x += (uintptr_t)&mlirTypeIsAPDLType;
+  x += (uintptr_t)&mlirTypeIsAPDLTypeType;
+  x += (uintptr_t)&mlirTypeIsAPDLValueType;
+  x += (uintptr_t)&mlirTypeIsARankedTensor;
+  x += (uintptr_t)&mlirTypeIsAShaped;
+  x += (uintptr_t)&mlirTypeIsATensor;
+  x += (uintptr_t)&mlirTypeIsATransformAnyOpType;
+  x += (uintptr_t)&mlirTypeIsATransformOperationType;
+  x += (uintptr_t)&mlirTypeIsATuple;
+  x += (uintptr_t)&mlirTypeIsAUnrankedMemRef;
+  x += (uintptr_t)&mlirTypeIsAUnrankedTensor;
+  x += (uintptr_t)&mlirTypeIsAVector;
+  x += (uintptr_t)&mlirTypeParseGet;
+  x += (uintptr_t)&mlirTypePrint;
+  x += (uintptr_t)&mlirUnitAttrGet;
+  x += (uintptr_t)&mlirUnrankedMemRefTypeGet;
+  x += (uintptr_t)&mlirUnrankedMemRefTypeGetChecked;
+  x += (uintptr_t)&mlirUnrankedMemrefGetMemorySpace;
+  x += (uintptr_t)&mlirUnrankedTensorTypeGet;
+  x += (uintptr_t)&mlirUnrankedTensorTypeGetChecked;
+  x += (uintptr_t)&mlirValueDump;
+  x += (uintptr_t)&mlirValueEqual;
+  x += (uintptr_t)&mlirValueGetType;
+  x += (uintptr_t)&mlirValueIsABlockArgument;
+  x += (uintptr_t)&mlirValueIsAOpResult;
+  x += (uintptr_t)&mlirValuePrint;
+  x += (uintptr_t)&mlirVectorTypeGet;
+  x += (uintptr_t)&mlirVectorTypeGetChecked;
+  return x;
+}
diff --git a/compiler/src/iree/compiler/API2/api_exports.def b/compiler/src/iree/compiler/API2/api_exports.def
new file mode 100644
index 0000000..c1d9842
--- /dev/null
+++ b/compiler/src/iree/compiler/API2/api_exports.def
@@ -0,0 +1,515 @@
+; Generated by generate_exports.py: Do not edit.
+EXPORTS
+  ireeCompilerBuildIREEVMPassPipeline
+  ireeCompilerOptionsCreate
+  ireeCompilerOptionsDestroy
+  ireeCompilerOptionsGetFlags
+  ireeCompilerOptionsSetFlags
+  ireeCompilerRegisterAllDialects
+  ireeCompilerRegisterAllPasses
+  ireeCompilerRegisterTargetBackends
+  ireeCompilerRunLldMain
+  ireeCompilerRunMain
+  ireeCompilerTranslateModuletoVMBytecode
+  ireeMlirLspServerRunMain
+  ireeOptRunMain
+  ireeRegisterTransformExtensions
+  mlirAffineAddExprGet
+  mlirAffineBinaryOpExprGetLHS
+  mlirAffineBinaryOpExprGetRHS
+  mlirAffineCeilDivExprGet
+  mlirAffineConstantExprGet
+  mlirAffineConstantExprGetValue
+  mlirAffineDimExprGet
+  mlirAffineDimExprGetPosition
+  mlirAffineExprCompose
+  mlirAffineExprDump
+  mlirAffineExprEqual
+  mlirAffineExprGetContext
+  mlirAffineExprGetLargestKnownDivisor
+  mlirAffineExprIsAAdd
+  mlirAffineExprIsABinary
+  mlirAffineExprIsACeilDiv
+  mlirAffineExprIsAConstant
+  mlirAffineExprIsADim
+  mlirAffineExprIsAFloorDiv
+  mlirAffineExprIsAMod
+  mlirAffineExprIsAMul
+  mlirAffineExprIsASymbol
+  mlirAffineExprIsFunctionOfDim
+  mlirAffineExprIsMultipleOf
+  mlirAffineExprIsPureAffine
+  mlirAffineExprIsSymbolicOrConstant
+  mlirAffineExprPrint
+  mlirAffineFloorDivExprGet
+  mlirAffineMapAttrGet
+  mlirAffineMapAttrGetValue
+  mlirAffineMapCompressUnusedSymbols
+  mlirAffineMapConstantGet
+  mlirAffineMapDump
+  mlirAffineMapEmptyGet
+  mlirAffineMapEqual
+  mlirAffineMapGet
+  mlirAffineMapGetContext
+  mlirAffineMapGetMajorSubMap
+  mlirAffineMapGetMinorSubMap
+  mlirAffineMapGetNumDims
+  mlirAffineMapGetNumInputs
+  mlirAffineMapGetNumResults
+  mlirAffineMapGetNumSymbols
+  mlirAffineMapGetResult
+  mlirAffineMapGetSingleConstantResult
+  mlirAffineMapGetSubMap
+  mlirAffineMapIsEmpty
+  mlirAffineMapIsIdentity
+  mlirAffineMapIsMinorIdentity
+  mlirAffineMapIsPermutation
+  mlirAffineMapIsProjectedPermutation
+  mlirAffineMapIsSingleConstant
+  mlirAffineMapMinorIdentityGet
+  mlirAffineMapMultiDimIdentityGet
+  mlirAffineMapPermutationGet
+  mlirAffineMapPrint
+  mlirAffineMapReplace
+  mlirAffineMapZeroResultGet
+  mlirAffineModExprGet
+  mlirAffineMulExprGet
+  mlirAffineSymbolExprGet
+  mlirAffineSymbolExprGetPosition
+  mlirArrayAttrGet
+  mlirArrayAttrGetElement
+  mlirArrayAttrGetNumElements
+  mlirAttributeDump
+  mlirAttributeEqual
+  mlirAttributeGetContext
+  mlirAttributeGetNull
+  mlirAttributeGetType
+  mlirAttributeGetTypeID
+  mlirAttributeIsAAffineMap
+  mlirAttributeIsAArray
+  mlirAttributeIsABool
+  mlirAttributeIsADenseBoolArray
+  mlirAttributeIsADenseElements
+  mlirAttributeIsADenseF32Array
+  mlirAttributeIsADenseF64Array
+  mlirAttributeIsADenseFPElements
+  mlirAttributeIsADenseI16Array
+  mlirAttributeIsADenseI32Array
+  mlirAttributeIsADenseI64Array
+  mlirAttributeIsADenseI8Array
+  mlirAttributeIsADenseIntElements
+  mlirAttributeIsADictionary
+  mlirAttributeIsAElements
+  mlirAttributeIsAFlatSymbolRef
+  mlirAttributeIsAFloat
+  mlirAttributeIsAInteger
+  mlirAttributeIsAIntegerSet
+  mlirAttributeIsAOpaque
+  mlirAttributeIsASparseElements
+  mlirAttributeIsAStridedLayout
+  mlirAttributeIsAString
+  mlirAttributeIsASymbolRef
+  mlirAttributeIsAType
+  mlirAttributeIsAUnit
+  mlirAttributeParseGet
+  mlirAttributePrint
+  mlirBF16TypeGet
+  mlirBlockAddArgument
+  mlirBlockAppendOwnedOperation
+  mlirBlockArgumentGetArgNumber
+  mlirBlockArgumentGetOwner
+  mlirBlockArgumentSetType
+  mlirBlockCreate
+  mlirBlockDestroy
+  mlirBlockDetach
+  mlirBlockEqual
+  mlirBlockGetArgument
+  mlirBlockGetFirstOperation
+  mlirBlockGetNextInRegion
+  mlirBlockGetNumArguments
+  mlirBlockGetParentOperation
+  mlirBlockGetParentRegion
+  mlirBlockGetTerminator
+  mlirBlockInsertOwnedOperation
+  mlirBlockInsertOwnedOperationAfter
+  mlirBlockInsertOwnedOperationBefore
+  mlirBlockPrint
+  mlirBoolAttrGet
+  mlirBoolAttrGetValue
+  mlirComplexTypeGet
+  mlirComplexTypeGetElementType
+  mlirContextAppendDialectRegistry
+  mlirContextAttachDiagnosticHandler
+  mlirContextCreate
+  mlirContextDestroy
+  mlirContextDetachDiagnosticHandler
+  mlirContextEnableMultithreading
+  mlirContextEqual
+  mlirContextGetAllowUnregisteredDialects
+  mlirContextGetNumLoadedDialects
+  mlirContextGetNumRegisteredDialects
+  mlirContextGetOrLoadDialect
+  mlirContextIsRegisteredOperation
+  mlirContextLoadAllAvailableDialects
+  mlirContextSetAllowUnregisteredDialects
+  mlirCreateExternalPass
+  mlirDenseArrayGetNumElements
+  mlirDenseBoolArrayGet
+  mlirDenseBoolArrayGetElement
+  mlirDenseElementsAttrBFloat16Get
+  mlirDenseElementsAttrBoolGet
+  mlirDenseElementsAttrBoolSplatGet
+  mlirDenseElementsAttrDoubleGet
+  mlirDenseElementsAttrDoubleSplatGet
+  mlirDenseElementsAttrFloat16Get
+  mlirDenseElementsAttrFloatGet
+  mlirDenseElementsAttrFloatSplatGet
+  mlirDenseElementsAttrGet
+  mlirDenseElementsAttrGetBoolSplatValue
+  mlirDenseElementsAttrGetBoolValue
+  mlirDenseElementsAttrGetDoubleSplatValue
+  mlirDenseElementsAttrGetDoubleValue
+  mlirDenseElementsAttrGetFloatSplatValue
+  mlirDenseElementsAttrGetFloatValue
+  mlirDenseElementsAttrGetInt16Value
+  mlirDenseElementsAttrGetInt32SplatValue
+  mlirDenseElementsAttrGetInt32Value
+  mlirDenseElementsAttrGetInt64SplatValue
+  mlirDenseElementsAttrGetInt64Value
+  mlirDenseElementsAttrGetInt8SplatValue
+  mlirDenseElementsAttrGetInt8Value
+  mlirDenseElementsAttrGetRawData
+  mlirDenseElementsAttrGetSplatValue
+  mlirDenseElementsAttrGetStringSplatValue
+  mlirDenseElementsAttrGetStringValue
+  mlirDenseElementsAttrGetUInt16Value
+  mlirDenseElementsAttrGetUInt32SplatValue
+  mlirDenseElementsAttrGetUInt32Value
+  mlirDenseElementsAttrGetUInt64SplatValue
+  mlirDenseElementsAttrGetUInt64Value
+  mlirDenseElementsAttrGetUInt8SplatValue
+  mlirDenseElementsAttrGetUInt8Value
+  mlirDenseElementsAttrInt16Get
+  mlirDenseElementsAttrInt32Get
+  mlirDenseElementsAttrInt32SplatGet
+  mlirDenseElementsAttrInt64Get
+  mlirDenseElementsAttrInt64SplatGet
+  mlirDenseElementsAttrInt8Get
+  mlirDenseElementsAttrInt8SplatGet
+  mlirDenseElementsAttrIsSplat
+  mlirDenseElementsAttrRawBufferGet
+  mlirDenseElementsAttrReshapeGet
+  mlirDenseElementsAttrSplatGet
+  mlirDenseElementsAttrStringGet
+  mlirDenseElementsAttrUInt16Get
+  mlirDenseElementsAttrUInt32Get
+  mlirDenseElementsAttrUInt32SplatGet
+  mlirDenseElementsAttrUInt64Get
+  mlirDenseElementsAttrUInt64SplatGet
+  mlirDenseElementsAttrUInt8Get
+  mlirDenseElementsAttrUInt8SplatGet
+  mlirDenseF32ArrayGet
+  mlirDenseF32ArrayGetElement
+  mlirDenseF64ArrayGet
+  mlirDenseF64ArrayGetElement
+  mlirDenseI16ArrayGet
+  mlirDenseI16ArrayGetElement
+  mlirDenseI32ArrayGet
+  mlirDenseI32ArrayGetElement
+  mlirDenseI64ArrayGet
+  mlirDenseI64ArrayGetElement
+  mlirDenseI8ArrayGet
+  mlirDenseI8ArrayGetElement
+  mlirDiagnosticGetLocation
+  mlirDiagnosticGetNote
+  mlirDiagnosticGetNumNotes
+  mlirDiagnosticGetSeverity
+  mlirDiagnosticPrint
+  mlirDialectEqual
+  mlirDialectGetContext
+  mlirDialectGetNamespace
+  mlirDialectHandleGetNamespace
+  mlirDialectHandleInsertDialect
+  mlirDialectHandleLoadDialect
+  mlirDialectHandleRegisterDialect
+  mlirDialectRegistryCreate
+  mlirDialectRegistryDestroy
+  mlirDictionaryAttrGet
+  mlirDictionaryAttrGetElement
+  mlirDictionaryAttrGetElementByName
+  mlirDictionaryAttrGetNumElements
+  mlirElementsAttrGetNumElements
+  mlirElementsAttrGetValue
+  mlirElementsAttrIsValidIndex
+  mlirEmitError
+  mlirEnableGlobalDebug
+  mlirExternalPassSignalFailure
+  mlirF16TypeGet
+  mlirF32TypeGet
+  mlirF64TypeGet
+  mlirFlatSymbolRefAttrGet
+  mlirFlatSymbolRefAttrGetValue
+  mlirFloat8E4M3FNTypeGet
+  mlirFloat8E5M2TypeGet
+  mlirFloatAttrDoubleGet
+  mlirFloatAttrDoubleGetChecked
+  mlirFloatAttrGetValueDouble
+  mlirFunctionTypeGet
+  mlirFunctionTypeGetInput
+  mlirFunctionTypeGetNumInputs
+  mlirFunctionTypeGetNumResults
+  mlirFunctionTypeGetResult
+  mlirGetDialectHandle__iree_input__
+  mlirGetDialectHandle__iree_linalg_ext__
+  mlirGetDialectHandle__iree_linalg_transform__
+  mlirGetDialectHandle__transform__
+  mlirIREELinalgTransformRegisterPasses
+  mlirIREETransformRegisterPasses
+  mlirIdentifierEqual
+  mlirIdentifierGet
+  mlirIdentifierGetContext
+  mlirIdentifierStr
+  mlirIndexTypeGet
+  mlirInferTypeOpInterfaceInferReturnTypes
+  mlirInferTypeOpInterfaceTypeID
+  mlirIntegerAttrGet
+  mlirIntegerAttrGetValueInt
+  mlirIntegerAttrGetValueSInt
+  mlirIntegerAttrGetValueUInt
+  mlirIntegerSetDump
+  mlirIntegerSetEmptyGet
+  mlirIntegerSetEqual
+  mlirIntegerSetGet
+  mlirIntegerSetGetConstraint
+  mlirIntegerSetGetContext
+  mlirIntegerSetGetNumConstraints
+  mlirIntegerSetGetNumDims
+  mlirIntegerSetGetNumEqualities
+  mlirIntegerSetGetNumInequalities
+  mlirIntegerSetGetNumInputs
+  mlirIntegerSetGetNumSymbols
+  mlirIntegerSetIsCanonicalEmpty
+  mlirIntegerSetIsConstraintEq
+  mlirIntegerSetPrint
+  mlirIntegerSetReplaceGet
+  mlirIntegerTypeGet
+  mlirIntegerTypeGetWidth
+  mlirIntegerTypeIsSigned
+  mlirIntegerTypeIsSignless
+  mlirIntegerTypeIsUnsigned
+  mlirIntegerTypeSignedGet
+  mlirIntegerTypeUnsignedGet
+  mlirIsGlobalDebugEnabled
+  mlirLinalgFillBuiltinNamedOpRegion
+  mlirLocationCallSiteGet
+  mlirLocationEqual
+  mlirLocationFileLineColGet
+  mlirLocationFusedGet
+  mlirLocationGetContext
+  mlirLocationNameGet
+  mlirLocationPrint
+  mlirLocationUnknownGet
+  mlirMemRefTypeContiguousGet
+  mlirMemRefTypeContiguousGetChecked
+  mlirMemRefTypeGet
+  mlirMemRefTypeGetAffineMap
+  mlirMemRefTypeGetChecked
+  mlirMemRefTypeGetLayout
+  mlirMemRefTypeGetMemorySpace
+  mlirModuleCreateEmpty
+  mlirModuleCreateParse
+  mlirModuleDestroy
+  mlirModuleFromOperation
+  mlirModuleGetBody
+  mlirModuleGetContext
+  mlirModuleGetOperation
+  mlirNamedAttributeGet
+  mlirNoneTypeGet
+  mlirOpPassManagerAddOwnedPass
+  mlirOpPassManagerAddPipeline
+  mlirOpPassManagerGetNestedUnder
+  mlirOpPrintingFlagsCreate
+  mlirOpPrintingFlagsDestroy
+  mlirOpPrintingFlagsElideLargeElementsAttrs
+  mlirOpPrintingFlagsEnableDebugInfo
+  mlirOpPrintingFlagsPrintGenericOpForm
+  mlirOpPrintingFlagsUseLocalScope
+  mlirOpResultGetOwner
+  mlirOpResultGetResultNumber
+  mlirOpaqueAttrGet
+  mlirOpaqueAttrGetData
+  mlirOpaqueAttrGetDialectNamespace
+  mlirOpaqueTypeGet
+  mlirOpaqueTypeGetData
+  mlirOpaqueTypeGetDialectNamespace
+  mlirOperationClone
+  mlirOperationCreate
+  mlirOperationDestroy
+  mlirOperationDump
+  mlirOperationEqual
+  mlirOperationGetAttribute
+  mlirOperationGetAttributeByName
+  mlirOperationGetBlock
+  mlirOperationGetContext
+  mlirOperationGetFirstRegion
+  mlirOperationGetLocation
+  mlirOperationGetName
+  mlirOperationGetNextInBlock
+  mlirOperationGetNumAttributes
+  mlirOperationGetNumOperands
+  mlirOperationGetNumRegions
+  mlirOperationGetNumResults
+  mlirOperationGetNumSuccessors
+  mlirOperationGetOperand
+  mlirOperationGetParentOperation
+  mlirOperationGetRegion
+  mlirOperationGetResult
+  mlirOperationGetSuccessor
+  mlirOperationGetTypeID
+  mlirOperationImplementsInterface
+  mlirOperationImplementsInterfaceStatic
+  mlirOperationMoveAfter
+  mlirOperationMoveBefore
+  mlirOperationPrint
+  mlirOperationPrintWithFlags
+  mlirOperationRemoveAttributeByName
+  mlirOperationRemoveFromParent
+  mlirOperationSetAttributeByName
+  mlirOperationSetOperand
+  mlirOperationStateAddAttributes
+  mlirOperationStateAddOperands
+  mlirOperationStateAddOwnedRegions
+  mlirOperationStateAddResults
+  mlirOperationStateAddSuccessors
+  mlirOperationStateEnableResultTypeInference
+  mlirOperationStateGet
+  mlirOperationVerify
+  mlirOperationWriteBytecode
+  mlirPDLAttributeTypeGet
+  mlirPDLOperationTypeGet
+  mlirPDLRangeTypeGet
+  mlirPDLRangeTypeGetElementType
+  mlirPDLTypeTypeGet
+  mlirPDLValueTypeGet
+  mlirParsePassPipeline
+  mlirPassManagerAddOwnedPass
+  mlirPassManagerCreate
+  mlirPassManagerCreateOnOperation
+  mlirPassManagerDestroy
+  mlirPassManagerEnableIRPrinting
+  mlirPassManagerEnableVerifier
+  mlirPassManagerGetAsOpPassManager
+  mlirPassManagerGetNestedUnder
+  mlirPassManagerRun
+  mlirPrintPassPipeline
+  mlirRankedTensorTypeGet
+  mlirRankedTensorTypeGetChecked
+  mlirRankedTensorTypeGetEncoding
+  mlirRegionAppendOwnedBlock
+  mlirRegionCreate
+  mlirRegionDestroy
+  mlirRegionEqual
+  mlirRegionGetFirstBlock
+  mlirRegionGetNextInOperation
+  mlirRegionInsertOwnedBlock
+  mlirRegionInsertOwnedBlockAfter
+  mlirRegionInsertOwnedBlockBefore
+  mlirRegisterLinalgPasses
+  mlirShapedTypeGetDimSize
+  mlirShapedTypeGetDynamicSize
+  mlirShapedTypeGetDynamicStrideOrOffset
+  mlirShapedTypeGetElementType
+  mlirShapedTypeGetRank
+  mlirShapedTypeHasRank
+  mlirShapedTypeHasStaticShape
+  mlirShapedTypeIsDynamicDim
+  mlirShapedTypeIsDynamicSize
+  mlirShapedTypeIsDynamicStrideOrOffset
+  mlirSparseElementsAttrGetIndices
+  mlirSparseElementsAttrGetValues
+  mlirSparseElementsAttribute
+  mlirStridedLayoutAttrGet
+  mlirStridedLayoutAttrGetNumStrides
+  mlirStridedLayoutAttrGetOffset
+  mlirStridedLayoutAttrGetStride
+  mlirStringAttrGet
+  mlirStringAttrGetValue
+  mlirStringAttrTypedGet
+  mlirStringRefCreateFromCString
+  mlirStringRefEqual
+  mlirSymbolRefAttrGet
+  mlirSymbolRefAttrGetLeafReference
+  mlirSymbolRefAttrGetNestedReference
+  mlirSymbolRefAttrGetNumNestedReferences
+  mlirSymbolRefAttrGetRootReference
+  mlirSymbolTableCreate
+  mlirSymbolTableDestroy
+  mlirSymbolTableErase
+  mlirSymbolTableGetSymbolAttributeName
+  mlirSymbolTableGetVisibilityAttributeName
+  mlirSymbolTableInsert
+  mlirSymbolTableLookup
+  mlirSymbolTableReplaceAllSymbolUses
+  mlirSymbolTableWalkSymbolTables
+  mlirTransformAnyOpTypeGet
+  mlirTransformOperationTypeGet
+  mlirTransformOperationTypeGetOperationName
+  mlirTupleTypeGet
+  mlirTupleTypeGetNumTypes
+  mlirTupleTypeGetType
+  mlirTypeAttrGet
+  mlirTypeAttrGetValue
+  mlirTypeDump
+  mlirTypeEqual
+  mlirTypeGetContext
+  mlirTypeGetTypeID
+  mlirTypeIDAllocatorAllocateTypeID
+  mlirTypeIDAllocatorCreate
+  mlirTypeIDAllocatorDestroy
+  mlirTypeIDCreate
+  mlirTypeIDEqual
+  mlirTypeIDHashValue
+  mlirTypeIsABF16
+  mlirTypeIsAComplex
+  mlirTypeIsAF16
+  mlirTypeIsAF32
+  mlirTypeIsAF64
+  mlirTypeIsAFloat8E4M3FN
+  mlirTypeIsAFloat8E5M2
+  mlirTypeIsAFunction
+  mlirTypeIsAIndex
+  mlirTypeIsAInteger
+  mlirTypeIsAMemRef
+  mlirTypeIsANone
+  mlirTypeIsAOpaque
+  mlirTypeIsAPDLAttributeType
+  mlirTypeIsAPDLOperationType
+  mlirTypeIsAPDLRangeType
+  mlirTypeIsAPDLType
+  mlirTypeIsAPDLTypeType
+  mlirTypeIsAPDLValueType
+  mlirTypeIsARankedTensor
+  mlirTypeIsAShaped
+  mlirTypeIsATensor
+  mlirTypeIsATransformAnyOpType
+  mlirTypeIsATransformOperationType
+  mlirTypeIsATuple
+  mlirTypeIsAUnrankedMemRef
+  mlirTypeIsAUnrankedTensor
+  mlirTypeIsAVector
+  mlirTypeParseGet
+  mlirTypePrint
+  mlirUnitAttrGet
+  mlirUnrankedMemRefTypeGet
+  mlirUnrankedMemRefTypeGetChecked
+  mlirUnrankedMemrefGetMemorySpace
+  mlirUnrankedTensorTypeGet
+  mlirUnrankedTensorTypeGetChecked
+  mlirValueDump
+  mlirValueEqual
+  mlirValueGetType
+  mlirValueIsABlockArgument
+  mlirValueIsAOpResult
+  mlirValuePrint
+  mlirVectorTypeGet
+  mlirVectorTypeGetChecked
diff --git a/compiler/src/iree/compiler/API2/api_exports.ld b/compiler/src/iree/compiler/API2/api_exports.ld
new file mode 100644
index 0000000..cdc1207
--- /dev/null
+++ b/compiler/src/iree/compiler/API2/api_exports.ld
@@ -0,0 +1,519 @@
+# Generated by generate_exports.py: Do not edit.
+VER_0 {
+  global:
+    ireeCompilerBuildIREEVMPassPipeline;
+    ireeCompilerOptionsCreate;
+    ireeCompilerOptionsDestroy;
+    ireeCompilerOptionsGetFlags;
+    ireeCompilerOptionsSetFlags;
+    ireeCompilerRegisterAllDialects;
+    ireeCompilerRegisterAllPasses;
+    ireeCompilerRegisterTargetBackends;
+    ireeCompilerRunLldMain;
+    ireeCompilerRunMain;
+    ireeCompilerTranslateModuletoVMBytecode;
+    ireeMlirLspServerRunMain;
+    ireeOptRunMain;
+    ireeRegisterTransformExtensions;
+    mlirAffineAddExprGet;
+    mlirAffineBinaryOpExprGetLHS;
+    mlirAffineBinaryOpExprGetRHS;
+    mlirAffineCeilDivExprGet;
+    mlirAffineConstantExprGet;
+    mlirAffineConstantExprGetValue;
+    mlirAffineDimExprGet;
+    mlirAffineDimExprGetPosition;
+    mlirAffineExprCompose;
+    mlirAffineExprDump;
+    mlirAffineExprEqual;
+    mlirAffineExprGetContext;
+    mlirAffineExprGetLargestKnownDivisor;
+    mlirAffineExprIsAAdd;
+    mlirAffineExprIsABinary;
+    mlirAffineExprIsACeilDiv;
+    mlirAffineExprIsAConstant;
+    mlirAffineExprIsADim;
+    mlirAffineExprIsAFloorDiv;
+    mlirAffineExprIsAMod;
+    mlirAffineExprIsAMul;
+    mlirAffineExprIsASymbol;
+    mlirAffineExprIsFunctionOfDim;
+    mlirAffineExprIsMultipleOf;
+    mlirAffineExprIsPureAffine;
+    mlirAffineExprIsSymbolicOrConstant;
+    mlirAffineExprPrint;
+    mlirAffineFloorDivExprGet;
+    mlirAffineMapAttrGet;
+    mlirAffineMapAttrGetValue;
+    mlirAffineMapCompressUnusedSymbols;
+    mlirAffineMapConstantGet;
+    mlirAffineMapDump;
+    mlirAffineMapEmptyGet;
+    mlirAffineMapEqual;
+    mlirAffineMapGet;
+    mlirAffineMapGetContext;
+    mlirAffineMapGetMajorSubMap;
+    mlirAffineMapGetMinorSubMap;
+    mlirAffineMapGetNumDims;
+    mlirAffineMapGetNumInputs;
+    mlirAffineMapGetNumResults;
+    mlirAffineMapGetNumSymbols;
+    mlirAffineMapGetResult;
+    mlirAffineMapGetSingleConstantResult;
+    mlirAffineMapGetSubMap;
+    mlirAffineMapIsEmpty;
+    mlirAffineMapIsIdentity;
+    mlirAffineMapIsMinorIdentity;
+    mlirAffineMapIsPermutation;
+    mlirAffineMapIsProjectedPermutation;
+    mlirAffineMapIsSingleConstant;
+    mlirAffineMapMinorIdentityGet;
+    mlirAffineMapMultiDimIdentityGet;
+    mlirAffineMapPermutationGet;
+    mlirAffineMapPrint;
+    mlirAffineMapReplace;
+    mlirAffineMapZeroResultGet;
+    mlirAffineModExprGet;
+    mlirAffineMulExprGet;
+    mlirAffineSymbolExprGet;
+    mlirAffineSymbolExprGetPosition;
+    mlirArrayAttrGet;
+    mlirArrayAttrGetElement;
+    mlirArrayAttrGetNumElements;
+    mlirAttributeDump;
+    mlirAttributeEqual;
+    mlirAttributeGetContext;
+    mlirAttributeGetNull;
+    mlirAttributeGetType;
+    mlirAttributeGetTypeID;
+    mlirAttributeIsAAffineMap;
+    mlirAttributeIsAArray;
+    mlirAttributeIsABool;
+    mlirAttributeIsADenseBoolArray;
+    mlirAttributeIsADenseElements;
+    mlirAttributeIsADenseF32Array;
+    mlirAttributeIsADenseF64Array;
+    mlirAttributeIsADenseFPElements;
+    mlirAttributeIsADenseI16Array;
+    mlirAttributeIsADenseI32Array;
+    mlirAttributeIsADenseI64Array;
+    mlirAttributeIsADenseI8Array;
+    mlirAttributeIsADenseIntElements;
+    mlirAttributeIsADictionary;
+    mlirAttributeIsAElements;
+    mlirAttributeIsAFlatSymbolRef;
+    mlirAttributeIsAFloat;
+    mlirAttributeIsAInteger;
+    mlirAttributeIsAIntegerSet;
+    mlirAttributeIsAOpaque;
+    mlirAttributeIsASparseElements;
+    mlirAttributeIsAStridedLayout;
+    mlirAttributeIsAString;
+    mlirAttributeIsASymbolRef;
+    mlirAttributeIsAType;
+    mlirAttributeIsAUnit;
+    mlirAttributeParseGet;
+    mlirAttributePrint;
+    mlirBF16TypeGet;
+    mlirBlockAddArgument;
+    mlirBlockAppendOwnedOperation;
+    mlirBlockArgumentGetArgNumber;
+    mlirBlockArgumentGetOwner;
+    mlirBlockArgumentSetType;
+    mlirBlockCreate;
+    mlirBlockDestroy;
+    mlirBlockDetach;
+    mlirBlockEqual;
+    mlirBlockGetArgument;
+    mlirBlockGetFirstOperation;
+    mlirBlockGetNextInRegion;
+    mlirBlockGetNumArguments;
+    mlirBlockGetParentOperation;
+    mlirBlockGetParentRegion;
+    mlirBlockGetTerminator;
+    mlirBlockInsertOwnedOperation;
+    mlirBlockInsertOwnedOperationAfter;
+    mlirBlockInsertOwnedOperationBefore;
+    mlirBlockPrint;
+    mlirBoolAttrGet;
+    mlirBoolAttrGetValue;
+    mlirComplexTypeGet;
+    mlirComplexTypeGetElementType;
+    mlirContextAppendDialectRegistry;
+    mlirContextAttachDiagnosticHandler;
+    mlirContextCreate;
+    mlirContextDestroy;
+    mlirContextDetachDiagnosticHandler;
+    mlirContextEnableMultithreading;
+    mlirContextEqual;
+    mlirContextGetAllowUnregisteredDialects;
+    mlirContextGetNumLoadedDialects;
+    mlirContextGetNumRegisteredDialects;
+    mlirContextGetOrLoadDialect;
+    mlirContextIsRegisteredOperation;
+    mlirContextLoadAllAvailableDialects;
+    mlirContextSetAllowUnregisteredDialects;
+    mlirCreateExternalPass;
+    mlirDenseArrayGetNumElements;
+    mlirDenseBoolArrayGet;
+    mlirDenseBoolArrayGetElement;
+    mlirDenseElementsAttrBFloat16Get;
+    mlirDenseElementsAttrBoolGet;
+    mlirDenseElementsAttrBoolSplatGet;
+    mlirDenseElementsAttrDoubleGet;
+    mlirDenseElementsAttrDoubleSplatGet;
+    mlirDenseElementsAttrFloat16Get;
+    mlirDenseElementsAttrFloatGet;
+    mlirDenseElementsAttrFloatSplatGet;
+    mlirDenseElementsAttrGet;
+    mlirDenseElementsAttrGetBoolSplatValue;
+    mlirDenseElementsAttrGetBoolValue;
+    mlirDenseElementsAttrGetDoubleSplatValue;
+    mlirDenseElementsAttrGetDoubleValue;
+    mlirDenseElementsAttrGetFloatSplatValue;
+    mlirDenseElementsAttrGetFloatValue;
+    mlirDenseElementsAttrGetInt16Value;
+    mlirDenseElementsAttrGetInt32SplatValue;
+    mlirDenseElementsAttrGetInt32Value;
+    mlirDenseElementsAttrGetInt64SplatValue;
+    mlirDenseElementsAttrGetInt64Value;
+    mlirDenseElementsAttrGetInt8SplatValue;
+    mlirDenseElementsAttrGetInt8Value;
+    mlirDenseElementsAttrGetRawData;
+    mlirDenseElementsAttrGetSplatValue;
+    mlirDenseElementsAttrGetStringSplatValue;
+    mlirDenseElementsAttrGetStringValue;
+    mlirDenseElementsAttrGetUInt16Value;
+    mlirDenseElementsAttrGetUInt32SplatValue;
+    mlirDenseElementsAttrGetUInt32Value;
+    mlirDenseElementsAttrGetUInt64SplatValue;
+    mlirDenseElementsAttrGetUInt64Value;
+    mlirDenseElementsAttrGetUInt8SplatValue;
+    mlirDenseElementsAttrGetUInt8Value;
+    mlirDenseElementsAttrInt16Get;
+    mlirDenseElementsAttrInt32Get;
+    mlirDenseElementsAttrInt32SplatGet;
+    mlirDenseElementsAttrInt64Get;
+    mlirDenseElementsAttrInt64SplatGet;
+    mlirDenseElementsAttrInt8Get;
+    mlirDenseElementsAttrInt8SplatGet;
+    mlirDenseElementsAttrIsSplat;
+    mlirDenseElementsAttrRawBufferGet;
+    mlirDenseElementsAttrReshapeGet;
+    mlirDenseElementsAttrSplatGet;
+    mlirDenseElementsAttrStringGet;
+    mlirDenseElementsAttrUInt16Get;
+    mlirDenseElementsAttrUInt32Get;
+    mlirDenseElementsAttrUInt32SplatGet;
+    mlirDenseElementsAttrUInt64Get;
+    mlirDenseElementsAttrUInt64SplatGet;
+    mlirDenseElementsAttrUInt8Get;
+    mlirDenseElementsAttrUInt8SplatGet;
+    mlirDenseF32ArrayGet;
+    mlirDenseF32ArrayGetElement;
+    mlirDenseF64ArrayGet;
+    mlirDenseF64ArrayGetElement;
+    mlirDenseI16ArrayGet;
+    mlirDenseI16ArrayGetElement;
+    mlirDenseI32ArrayGet;
+    mlirDenseI32ArrayGetElement;
+    mlirDenseI64ArrayGet;
+    mlirDenseI64ArrayGetElement;
+    mlirDenseI8ArrayGet;
+    mlirDenseI8ArrayGetElement;
+    mlirDiagnosticGetLocation;
+    mlirDiagnosticGetNote;
+    mlirDiagnosticGetNumNotes;
+    mlirDiagnosticGetSeverity;
+    mlirDiagnosticPrint;
+    mlirDialectEqual;
+    mlirDialectGetContext;
+    mlirDialectGetNamespace;
+    mlirDialectHandleGetNamespace;
+    mlirDialectHandleInsertDialect;
+    mlirDialectHandleLoadDialect;
+    mlirDialectHandleRegisterDialect;
+    mlirDialectRegistryCreate;
+    mlirDialectRegistryDestroy;
+    mlirDictionaryAttrGet;
+    mlirDictionaryAttrGetElement;
+    mlirDictionaryAttrGetElementByName;
+    mlirDictionaryAttrGetNumElements;
+    mlirElementsAttrGetNumElements;
+    mlirElementsAttrGetValue;
+    mlirElementsAttrIsValidIndex;
+    mlirEmitError;
+    mlirEnableGlobalDebug;
+    mlirExternalPassSignalFailure;
+    mlirF16TypeGet;
+    mlirF32TypeGet;
+    mlirF64TypeGet;
+    mlirFlatSymbolRefAttrGet;
+    mlirFlatSymbolRefAttrGetValue;
+    mlirFloat8E4M3FNTypeGet;
+    mlirFloat8E5M2TypeGet;
+    mlirFloatAttrDoubleGet;
+    mlirFloatAttrDoubleGetChecked;
+    mlirFloatAttrGetValueDouble;
+    mlirFunctionTypeGet;
+    mlirFunctionTypeGetInput;
+    mlirFunctionTypeGetNumInputs;
+    mlirFunctionTypeGetNumResults;
+    mlirFunctionTypeGetResult;
+    mlirGetDialectHandle__iree_input__;
+    mlirGetDialectHandle__iree_linalg_ext__;
+    mlirGetDialectHandle__iree_linalg_transform__;
+    mlirGetDialectHandle__transform__;
+    mlirIREELinalgTransformRegisterPasses;
+    mlirIREETransformRegisterPasses;
+    mlirIdentifierEqual;
+    mlirIdentifierGet;
+    mlirIdentifierGetContext;
+    mlirIdentifierStr;
+    mlirIndexTypeGet;
+    mlirInferTypeOpInterfaceInferReturnTypes;
+    mlirInferTypeOpInterfaceTypeID;
+    mlirIntegerAttrGet;
+    mlirIntegerAttrGetValueInt;
+    mlirIntegerAttrGetValueSInt;
+    mlirIntegerAttrGetValueUInt;
+    mlirIntegerSetDump;
+    mlirIntegerSetEmptyGet;
+    mlirIntegerSetEqual;
+    mlirIntegerSetGet;
+    mlirIntegerSetGetConstraint;
+    mlirIntegerSetGetContext;
+    mlirIntegerSetGetNumConstraints;
+    mlirIntegerSetGetNumDims;
+    mlirIntegerSetGetNumEqualities;
+    mlirIntegerSetGetNumInequalities;
+    mlirIntegerSetGetNumInputs;
+    mlirIntegerSetGetNumSymbols;
+    mlirIntegerSetIsCanonicalEmpty;
+    mlirIntegerSetIsConstraintEq;
+    mlirIntegerSetPrint;
+    mlirIntegerSetReplaceGet;
+    mlirIntegerTypeGet;
+    mlirIntegerTypeGetWidth;
+    mlirIntegerTypeIsSigned;
+    mlirIntegerTypeIsSignless;
+    mlirIntegerTypeIsUnsigned;
+    mlirIntegerTypeSignedGet;
+    mlirIntegerTypeUnsignedGet;
+    mlirIsGlobalDebugEnabled;
+    mlirLinalgFillBuiltinNamedOpRegion;
+    mlirLocationCallSiteGet;
+    mlirLocationEqual;
+    mlirLocationFileLineColGet;
+    mlirLocationFusedGet;
+    mlirLocationGetContext;
+    mlirLocationNameGet;
+    mlirLocationPrint;
+    mlirLocationUnknownGet;
+    mlirMemRefTypeContiguousGet;
+    mlirMemRefTypeContiguousGetChecked;
+    mlirMemRefTypeGet;
+    mlirMemRefTypeGetAffineMap;
+    mlirMemRefTypeGetChecked;
+    mlirMemRefTypeGetLayout;
+    mlirMemRefTypeGetMemorySpace;
+    mlirModuleCreateEmpty;
+    mlirModuleCreateParse;
+    mlirModuleDestroy;
+    mlirModuleFromOperation;
+    mlirModuleGetBody;
+    mlirModuleGetContext;
+    mlirModuleGetOperation;
+    mlirNamedAttributeGet;
+    mlirNoneTypeGet;
+    mlirOpPassManagerAddOwnedPass;
+    mlirOpPassManagerAddPipeline;
+    mlirOpPassManagerGetNestedUnder;
+    mlirOpPrintingFlagsCreate;
+    mlirOpPrintingFlagsDestroy;
+    mlirOpPrintingFlagsElideLargeElementsAttrs;
+    mlirOpPrintingFlagsEnableDebugInfo;
+    mlirOpPrintingFlagsPrintGenericOpForm;
+    mlirOpPrintingFlagsUseLocalScope;
+    mlirOpResultGetOwner;
+    mlirOpResultGetResultNumber;
+    mlirOpaqueAttrGet;
+    mlirOpaqueAttrGetData;
+    mlirOpaqueAttrGetDialectNamespace;
+    mlirOpaqueTypeGet;
+    mlirOpaqueTypeGetData;
+    mlirOpaqueTypeGetDialectNamespace;
+    mlirOperationClone;
+    mlirOperationCreate;
+    mlirOperationDestroy;
+    mlirOperationDump;
+    mlirOperationEqual;
+    mlirOperationGetAttribute;
+    mlirOperationGetAttributeByName;
+    mlirOperationGetBlock;
+    mlirOperationGetContext;
+    mlirOperationGetFirstRegion;
+    mlirOperationGetLocation;
+    mlirOperationGetName;
+    mlirOperationGetNextInBlock;
+    mlirOperationGetNumAttributes;
+    mlirOperationGetNumOperands;
+    mlirOperationGetNumRegions;
+    mlirOperationGetNumResults;
+    mlirOperationGetNumSuccessors;
+    mlirOperationGetOperand;
+    mlirOperationGetParentOperation;
+    mlirOperationGetRegion;
+    mlirOperationGetResult;
+    mlirOperationGetSuccessor;
+    mlirOperationGetTypeID;
+    mlirOperationImplementsInterface;
+    mlirOperationImplementsInterfaceStatic;
+    mlirOperationMoveAfter;
+    mlirOperationMoveBefore;
+    mlirOperationPrint;
+    mlirOperationPrintWithFlags;
+    mlirOperationRemoveAttributeByName;
+    mlirOperationRemoveFromParent;
+    mlirOperationSetAttributeByName;
+    mlirOperationSetOperand;
+    mlirOperationStateAddAttributes;
+    mlirOperationStateAddOperands;
+    mlirOperationStateAddOwnedRegions;
+    mlirOperationStateAddResults;
+    mlirOperationStateAddSuccessors;
+    mlirOperationStateEnableResultTypeInference;
+    mlirOperationStateGet;
+    mlirOperationVerify;
+    mlirOperationWriteBytecode;
+    mlirPDLAttributeTypeGet;
+    mlirPDLOperationTypeGet;
+    mlirPDLRangeTypeGet;
+    mlirPDLRangeTypeGetElementType;
+    mlirPDLTypeTypeGet;
+    mlirPDLValueTypeGet;
+    mlirParsePassPipeline;
+    mlirPassManagerAddOwnedPass;
+    mlirPassManagerCreate;
+    mlirPassManagerCreateOnOperation;
+    mlirPassManagerDestroy;
+    mlirPassManagerEnableIRPrinting;
+    mlirPassManagerEnableVerifier;
+    mlirPassManagerGetAsOpPassManager;
+    mlirPassManagerGetNestedUnder;
+    mlirPassManagerRun;
+    mlirPrintPassPipeline;
+    mlirRankedTensorTypeGet;
+    mlirRankedTensorTypeGetChecked;
+    mlirRankedTensorTypeGetEncoding;
+    mlirRegionAppendOwnedBlock;
+    mlirRegionCreate;
+    mlirRegionDestroy;
+    mlirRegionEqual;
+    mlirRegionGetFirstBlock;
+    mlirRegionGetNextInOperation;
+    mlirRegionInsertOwnedBlock;
+    mlirRegionInsertOwnedBlockAfter;
+    mlirRegionInsertOwnedBlockBefore;
+    mlirRegisterLinalgPasses;
+    mlirShapedTypeGetDimSize;
+    mlirShapedTypeGetDynamicSize;
+    mlirShapedTypeGetDynamicStrideOrOffset;
+    mlirShapedTypeGetElementType;
+    mlirShapedTypeGetRank;
+    mlirShapedTypeHasRank;
+    mlirShapedTypeHasStaticShape;
+    mlirShapedTypeIsDynamicDim;
+    mlirShapedTypeIsDynamicSize;
+    mlirShapedTypeIsDynamicStrideOrOffset;
+    mlirSparseElementsAttrGetIndices;
+    mlirSparseElementsAttrGetValues;
+    mlirSparseElementsAttribute;
+    mlirStridedLayoutAttrGet;
+    mlirStridedLayoutAttrGetNumStrides;
+    mlirStridedLayoutAttrGetOffset;
+    mlirStridedLayoutAttrGetStride;
+    mlirStringAttrGet;
+    mlirStringAttrGetValue;
+    mlirStringAttrTypedGet;
+    mlirStringRefCreateFromCString;
+    mlirStringRefEqual;
+    mlirSymbolRefAttrGet;
+    mlirSymbolRefAttrGetLeafReference;
+    mlirSymbolRefAttrGetNestedReference;
+    mlirSymbolRefAttrGetNumNestedReferences;
+    mlirSymbolRefAttrGetRootReference;
+    mlirSymbolTableCreate;
+    mlirSymbolTableDestroy;
+    mlirSymbolTableErase;
+    mlirSymbolTableGetSymbolAttributeName;
+    mlirSymbolTableGetVisibilityAttributeName;
+    mlirSymbolTableInsert;
+    mlirSymbolTableLookup;
+    mlirSymbolTableReplaceAllSymbolUses;
+    mlirSymbolTableWalkSymbolTables;
+    mlirTransformAnyOpTypeGet;
+    mlirTransformOperationTypeGet;
+    mlirTransformOperationTypeGetOperationName;
+    mlirTupleTypeGet;
+    mlirTupleTypeGetNumTypes;
+    mlirTupleTypeGetType;
+    mlirTypeAttrGet;
+    mlirTypeAttrGetValue;
+    mlirTypeDump;
+    mlirTypeEqual;
+    mlirTypeGetContext;
+    mlirTypeGetTypeID;
+    mlirTypeIDAllocatorAllocateTypeID;
+    mlirTypeIDAllocatorCreate;
+    mlirTypeIDAllocatorDestroy;
+    mlirTypeIDCreate;
+    mlirTypeIDEqual;
+    mlirTypeIDHashValue;
+    mlirTypeIsABF16;
+    mlirTypeIsAComplex;
+    mlirTypeIsAF16;
+    mlirTypeIsAF32;
+    mlirTypeIsAF64;
+    mlirTypeIsAFloat8E4M3FN;
+    mlirTypeIsAFloat8E5M2;
+    mlirTypeIsAFunction;
+    mlirTypeIsAIndex;
+    mlirTypeIsAInteger;
+    mlirTypeIsAMemRef;
+    mlirTypeIsANone;
+    mlirTypeIsAOpaque;
+    mlirTypeIsAPDLAttributeType;
+    mlirTypeIsAPDLOperationType;
+    mlirTypeIsAPDLRangeType;
+    mlirTypeIsAPDLType;
+    mlirTypeIsAPDLTypeType;
+    mlirTypeIsAPDLValueType;
+    mlirTypeIsARankedTensor;
+    mlirTypeIsAShaped;
+    mlirTypeIsATensor;
+    mlirTypeIsATransformAnyOpType;
+    mlirTypeIsATransformOperationType;
+    mlirTypeIsATuple;
+    mlirTypeIsAUnrankedMemRef;
+    mlirTypeIsAUnrankedTensor;
+    mlirTypeIsAVector;
+    mlirTypeParseGet;
+    mlirTypePrint;
+    mlirUnitAttrGet;
+    mlirUnrankedMemRefTypeGet;
+    mlirUnrankedMemRefTypeGetChecked;
+    mlirUnrankedMemrefGetMemorySpace;
+    mlirUnrankedTensorTypeGet;
+    mlirUnrankedTensorTypeGetChecked;
+    mlirValueDump;
+    mlirValueEqual;
+    mlirValueGetType;
+    mlirValueIsABlockArgument;
+    mlirValueIsAOpResult;
+    mlirValuePrint;
+    mlirVectorTypeGet;
+    mlirVectorTypeGetChecked;
+  local:
+    *;
+};
diff --git a/compiler/src/iree/compiler/API2/api_exports.lst b/compiler/src/iree/compiler/API2/api_exports.lst
new file mode 100644
index 0000000..c244ac1
--- /dev/null
+++ b/compiler/src/iree/compiler/API2/api_exports.lst
@@ -0,0 +1,514 @@
+# Generated by generate_exports.py: Do not edit.
+ireeCompilerBuildIREEVMPassPipeline
+ireeCompilerOptionsCreate
+ireeCompilerOptionsDestroy
+ireeCompilerOptionsGetFlags
+ireeCompilerOptionsSetFlags
+ireeCompilerRegisterAllDialects
+ireeCompilerRegisterAllPasses
+ireeCompilerRegisterTargetBackends
+ireeCompilerRunLldMain
+ireeCompilerRunMain
+ireeCompilerTranslateModuletoVMBytecode
+ireeMlirLspServerRunMain
+ireeOptRunMain
+ireeRegisterTransformExtensions
+mlirAffineAddExprGet
+mlirAffineBinaryOpExprGetLHS
+mlirAffineBinaryOpExprGetRHS
+mlirAffineCeilDivExprGet
+mlirAffineConstantExprGet
+mlirAffineConstantExprGetValue
+mlirAffineDimExprGet
+mlirAffineDimExprGetPosition
+mlirAffineExprCompose
+mlirAffineExprDump
+mlirAffineExprEqual
+mlirAffineExprGetContext
+mlirAffineExprGetLargestKnownDivisor
+mlirAffineExprIsAAdd
+mlirAffineExprIsABinary
+mlirAffineExprIsACeilDiv
+mlirAffineExprIsAConstant
+mlirAffineExprIsADim
+mlirAffineExprIsAFloorDiv
+mlirAffineExprIsAMod
+mlirAffineExprIsAMul
+mlirAffineExprIsASymbol
+mlirAffineExprIsFunctionOfDim
+mlirAffineExprIsMultipleOf
+mlirAffineExprIsPureAffine
+mlirAffineExprIsSymbolicOrConstant
+mlirAffineExprPrint
+mlirAffineFloorDivExprGet
+mlirAffineMapAttrGet
+mlirAffineMapAttrGetValue
+mlirAffineMapCompressUnusedSymbols
+mlirAffineMapConstantGet
+mlirAffineMapDump
+mlirAffineMapEmptyGet
+mlirAffineMapEqual
+mlirAffineMapGet
+mlirAffineMapGetContext
+mlirAffineMapGetMajorSubMap
+mlirAffineMapGetMinorSubMap
+mlirAffineMapGetNumDims
+mlirAffineMapGetNumInputs
+mlirAffineMapGetNumResults
+mlirAffineMapGetNumSymbols
+mlirAffineMapGetResult
+mlirAffineMapGetSingleConstantResult
+mlirAffineMapGetSubMap
+mlirAffineMapIsEmpty
+mlirAffineMapIsIdentity
+mlirAffineMapIsMinorIdentity
+mlirAffineMapIsPermutation
+mlirAffineMapIsProjectedPermutation
+mlirAffineMapIsSingleConstant
+mlirAffineMapMinorIdentityGet
+mlirAffineMapMultiDimIdentityGet
+mlirAffineMapPermutationGet
+mlirAffineMapPrint
+mlirAffineMapReplace
+mlirAffineMapZeroResultGet
+mlirAffineModExprGet
+mlirAffineMulExprGet
+mlirAffineSymbolExprGet
+mlirAffineSymbolExprGetPosition
+mlirArrayAttrGet
+mlirArrayAttrGetElement
+mlirArrayAttrGetNumElements
+mlirAttributeDump
+mlirAttributeEqual
+mlirAttributeGetContext
+mlirAttributeGetNull
+mlirAttributeGetType
+mlirAttributeGetTypeID
+mlirAttributeIsAAffineMap
+mlirAttributeIsAArray
+mlirAttributeIsABool
+mlirAttributeIsADenseBoolArray
+mlirAttributeIsADenseElements
+mlirAttributeIsADenseF32Array
+mlirAttributeIsADenseF64Array
+mlirAttributeIsADenseFPElements
+mlirAttributeIsADenseI16Array
+mlirAttributeIsADenseI32Array
+mlirAttributeIsADenseI64Array
+mlirAttributeIsADenseI8Array
+mlirAttributeIsADenseIntElements
+mlirAttributeIsADictionary
+mlirAttributeIsAElements
+mlirAttributeIsAFlatSymbolRef
+mlirAttributeIsAFloat
+mlirAttributeIsAInteger
+mlirAttributeIsAIntegerSet
+mlirAttributeIsAOpaque
+mlirAttributeIsASparseElements
+mlirAttributeIsAStridedLayout
+mlirAttributeIsAString
+mlirAttributeIsASymbolRef
+mlirAttributeIsAType
+mlirAttributeIsAUnit
+mlirAttributeParseGet
+mlirAttributePrint
+mlirBF16TypeGet
+mlirBlockAddArgument
+mlirBlockAppendOwnedOperation
+mlirBlockArgumentGetArgNumber
+mlirBlockArgumentGetOwner
+mlirBlockArgumentSetType
+mlirBlockCreate
+mlirBlockDestroy
+mlirBlockDetach
+mlirBlockEqual
+mlirBlockGetArgument
+mlirBlockGetFirstOperation
+mlirBlockGetNextInRegion
+mlirBlockGetNumArguments
+mlirBlockGetParentOperation
+mlirBlockGetParentRegion
+mlirBlockGetTerminator
+mlirBlockInsertOwnedOperation
+mlirBlockInsertOwnedOperationAfter
+mlirBlockInsertOwnedOperationBefore
+mlirBlockPrint
+mlirBoolAttrGet
+mlirBoolAttrGetValue
+mlirComplexTypeGet
+mlirComplexTypeGetElementType
+mlirContextAppendDialectRegistry
+mlirContextAttachDiagnosticHandler
+mlirContextCreate
+mlirContextDestroy
+mlirContextDetachDiagnosticHandler
+mlirContextEnableMultithreading
+mlirContextEqual
+mlirContextGetAllowUnregisteredDialects
+mlirContextGetNumLoadedDialects
+mlirContextGetNumRegisteredDialects
+mlirContextGetOrLoadDialect
+mlirContextIsRegisteredOperation
+mlirContextLoadAllAvailableDialects
+mlirContextSetAllowUnregisteredDialects
+mlirCreateExternalPass
+mlirDenseArrayGetNumElements
+mlirDenseBoolArrayGet
+mlirDenseBoolArrayGetElement
+mlirDenseElementsAttrBFloat16Get
+mlirDenseElementsAttrBoolGet
+mlirDenseElementsAttrBoolSplatGet
+mlirDenseElementsAttrDoubleGet
+mlirDenseElementsAttrDoubleSplatGet
+mlirDenseElementsAttrFloat16Get
+mlirDenseElementsAttrFloatGet
+mlirDenseElementsAttrFloatSplatGet
+mlirDenseElementsAttrGet
+mlirDenseElementsAttrGetBoolSplatValue
+mlirDenseElementsAttrGetBoolValue
+mlirDenseElementsAttrGetDoubleSplatValue
+mlirDenseElementsAttrGetDoubleValue
+mlirDenseElementsAttrGetFloatSplatValue
+mlirDenseElementsAttrGetFloatValue
+mlirDenseElementsAttrGetInt16Value
+mlirDenseElementsAttrGetInt32SplatValue
+mlirDenseElementsAttrGetInt32Value
+mlirDenseElementsAttrGetInt64SplatValue
+mlirDenseElementsAttrGetInt64Value
+mlirDenseElementsAttrGetInt8SplatValue
+mlirDenseElementsAttrGetInt8Value
+mlirDenseElementsAttrGetRawData
+mlirDenseElementsAttrGetSplatValue
+mlirDenseElementsAttrGetStringSplatValue
+mlirDenseElementsAttrGetStringValue
+mlirDenseElementsAttrGetUInt16Value
+mlirDenseElementsAttrGetUInt32SplatValue
+mlirDenseElementsAttrGetUInt32Value
+mlirDenseElementsAttrGetUInt64SplatValue
+mlirDenseElementsAttrGetUInt64Value
+mlirDenseElementsAttrGetUInt8SplatValue
+mlirDenseElementsAttrGetUInt8Value
+mlirDenseElementsAttrInt16Get
+mlirDenseElementsAttrInt32Get
+mlirDenseElementsAttrInt32SplatGet
+mlirDenseElementsAttrInt64Get
+mlirDenseElementsAttrInt64SplatGet
+mlirDenseElementsAttrInt8Get
+mlirDenseElementsAttrInt8SplatGet
+mlirDenseElementsAttrIsSplat
+mlirDenseElementsAttrRawBufferGet
+mlirDenseElementsAttrReshapeGet
+mlirDenseElementsAttrSplatGet
+mlirDenseElementsAttrStringGet
+mlirDenseElementsAttrUInt16Get
+mlirDenseElementsAttrUInt32Get
+mlirDenseElementsAttrUInt32SplatGet
+mlirDenseElementsAttrUInt64Get
+mlirDenseElementsAttrUInt64SplatGet
+mlirDenseElementsAttrUInt8Get
+mlirDenseElementsAttrUInt8SplatGet
+mlirDenseF32ArrayGet
+mlirDenseF32ArrayGetElement
+mlirDenseF64ArrayGet
+mlirDenseF64ArrayGetElement
+mlirDenseI16ArrayGet
+mlirDenseI16ArrayGetElement
+mlirDenseI32ArrayGet
+mlirDenseI32ArrayGetElement
+mlirDenseI64ArrayGet
+mlirDenseI64ArrayGetElement
+mlirDenseI8ArrayGet
+mlirDenseI8ArrayGetElement
+mlirDiagnosticGetLocation
+mlirDiagnosticGetNote
+mlirDiagnosticGetNumNotes
+mlirDiagnosticGetSeverity
+mlirDiagnosticPrint
+mlirDialectEqual
+mlirDialectGetContext
+mlirDialectGetNamespace
+mlirDialectHandleGetNamespace
+mlirDialectHandleInsertDialect
+mlirDialectHandleLoadDialect
+mlirDialectHandleRegisterDialect
+mlirDialectRegistryCreate
+mlirDialectRegistryDestroy
+mlirDictionaryAttrGet
+mlirDictionaryAttrGetElement
+mlirDictionaryAttrGetElementByName
+mlirDictionaryAttrGetNumElements
+mlirElementsAttrGetNumElements
+mlirElementsAttrGetValue
+mlirElementsAttrIsValidIndex
+mlirEmitError
+mlirEnableGlobalDebug
+mlirExternalPassSignalFailure
+mlirF16TypeGet
+mlirF32TypeGet
+mlirF64TypeGet
+mlirFlatSymbolRefAttrGet
+mlirFlatSymbolRefAttrGetValue
+mlirFloat8E4M3FNTypeGet
+mlirFloat8E5M2TypeGet
+mlirFloatAttrDoubleGet
+mlirFloatAttrDoubleGetChecked
+mlirFloatAttrGetValueDouble
+mlirFunctionTypeGet
+mlirFunctionTypeGetInput
+mlirFunctionTypeGetNumInputs
+mlirFunctionTypeGetNumResults
+mlirFunctionTypeGetResult
+mlirGetDialectHandle__iree_input__
+mlirGetDialectHandle__iree_linalg_ext__
+mlirGetDialectHandle__iree_linalg_transform__
+mlirGetDialectHandle__transform__
+mlirIREELinalgTransformRegisterPasses
+mlirIREETransformRegisterPasses
+mlirIdentifierEqual
+mlirIdentifierGet
+mlirIdentifierGetContext
+mlirIdentifierStr
+mlirIndexTypeGet
+mlirInferTypeOpInterfaceInferReturnTypes
+mlirInferTypeOpInterfaceTypeID
+mlirIntegerAttrGet
+mlirIntegerAttrGetValueInt
+mlirIntegerAttrGetValueSInt
+mlirIntegerAttrGetValueUInt
+mlirIntegerSetDump
+mlirIntegerSetEmptyGet
+mlirIntegerSetEqual
+mlirIntegerSetGet
+mlirIntegerSetGetConstraint
+mlirIntegerSetGetContext
+mlirIntegerSetGetNumConstraints
+mlirIntegerSetGetNumDims
+mlirIntegerSetGetNumEqualities
+mlirIntegerSetGetNumInequalities
+mlirIntegerSetGetNumInputs
+mlirIntegerSetGetNumSymbols
+mlirIntegerSetIsCanonicalEmpty
+mlirIntegerSetIsConstraintEq
+mlirIntegerSetPrint
+mlirIntegerSetReplaceGet
+mlirIntegerTypeGet
+mlirIntegerTypeGetWidth
+mlirIntegerTypeIsSigned
+mlirIntegerTypeIsSignless
+mlirIntegerTypeIsUnsigned
+mlirIntegerTypeSignedGet
+mlirIntegerTypeUnsignedGet
+mlirIsGlobalDebugEnabled
+mlirLinalgFillBuiltinNamedOpRegion
+mlirLocationCallSiteGet
+mlirLocationEqual
+mlirLocationFileLineColGet
+mlirLocationFusedGet
+mlirLocationGetContext
+mlirLocationNameGet
+mlirLocationPrint
+mlirLocationUnknownGet
+mlirMemRefTypeContiguousGet
+mlirMemRefTypeContiguousGetChecked
+mlirMemRefTypeGet
+mlirMemRefTypeGetAffineMap
+mlirMemRefTypeGetChecked
+mlirMemRefTypeGetLayout
+mlirMemRefTypeGetMemorySpace
+mlirModuleCreateEmpty
+mlirModuleCreateParse
+mlirModuleDestroy
+mlirModuleFromOperation
+mlirModuleGetBody
+mlirModuleGetContext
+mlirModuleGetOperation
+mlirNamedAttributeGet
+mlirNoneTypeGet
+mlirOpPassManagerAddOwnedPass
+mlirOpPassManagerAddPipeline
+mlirOpPassManagerGetNestedUnder
+mlirOpPrintingFlagsCreate
+mlirOpPrintingFlagsDestroy
+mlirOpPrintingFlagsElideLargeElementsAttrs
+mlirOpPrintingFlagsEnableDebugInfo
+mlirOpPrintingFlagsPrintGenericOpForm
+mlirOpPrintingFlagsUseLocalScope
+mlirOpResultGetOwner
+mlirOpResultGetResultNumber
+mlirOpaqueAttrGet
+mlirOpaqueAttrGetData
+mlirOpaqueAttrGetDialectNamespace
+mlirOpaqueTypeGet
+mlirOpaqueTypeGetData
+mlirOpaqueTypeGetDialectNamespace
+mlirOperationClone
+mlirOperationCreate
+mlirOperationDestroy
+mlirOperationDump
+mlirOperationEqual
+mlirOperationGetAttribute
+mlirOperationGetAttributeByName
+mlirOperationGetBlock
+mlirOperationGetContext
+mlirOperationGetFirstRegion
+mlirOperationGetLocation
+mlirOperationGetName
+mlirOperationGetNextInBlock
+mlirOperationGetNumAttributes
+mlirOperationGetNumOperands
+mlirOperationGetNumRegions
+mlirOperationGetNumResults
+mlirOperationGetNumSuccessors
+mlirOperationGetOperand
+mlirOperationGetParentOperation
+mlirOperationGetRegion
+mlirOperationGetResult
+mlirOperationGetSuccessor
+mlirOperationGetTypeID
+mlirOperationImplementsInterface
+mlirOperationImplementsInterfaceStatic
+mlirOperationMoveAfter
+mlirOperationMoveBefore
+mlirOperationPrint
+mlirOperationPrintWithFlags
+mlirOperationRemoveAttributeByName
+mlirOperationRemoveFromParent
+mlirOperationSetAttributeByName
+mlirOperationSetOperand
+mlirOperationStateAddAttributes
+mlirOperationStateAddOperands
+mlirOperationStateAddOwnedRegions
+mlirOperationStateAddResults
+mlirOperationStateAddSuccessors
+mlirOperationStateEnableResultTypeInference
+mlirOperationStateGet
+mlirOperationVerify
+mlirOperationWriteBytecode
+mlirPDLAttributeTypeGet
+mlirPDLOperationTypeGet
+mlirPDLRangeTypeGet
+mlirPDLRangeTypeGetElementType
+mlirPDLTypeTypeGet
+mlirPDLValueTypeGet
+mlirParsePassPipeline
+mlirPassManagerAddOwnedPass
+mlirPassManagerCreate
+mlirPassManagerCreateOnOperation
+mlirPassManagerDestroy
+mlirPassManagerEnableIRPrinting
+mlirPassManagerEnableVerifier
+mlirPassManagerGetAsOpPassManager
+mlirPassManagerGetNestedUnder
+mlirPassManagerRun
+mlirPrintPassPipeline
+mlirRankedTensorTypeGet
+mlirRankedTensorTypeGetChecked
+mlirRankedTensorTypeGetEncoding
+mlirRegionAppendOwnedBlock
+mlirRegionCreate
+mlirRegionDestroy
+mlirRegionEqual
+mlirRegionGetFirstBlock
+mlirRegionGetNextInOperation
+mlirRegionInsertOwnedBlock
+mlirRegionInsertOwnedBlockAfter
+mlirRegionInsertOwnedBlockBefore
+mlirRegisterLinalgPasses
+mlirShapedTypeGetDimSize
+mlirShapedTypeGetDynamicSize
+mlirShapedTypeGetDynamicStrideOrOffset
+mlirShapedTypeGetElementType
+mlirShapedTypeGetRank
+mlirShapedTypeHasRank
+mlirShapedTypeHasStaticShape
+mlirShapedTypeIsDynamicDim
+mlirShapedTypeIsDynamicSize
+mlirShapedTypeIsDynamicStrideOrOffset
+mlirSparseElementsAttrGetIndices
+mlirSparseElementsAttrGetValues
+mlirSparseElementsAttribute
+mlirStridedLayoutAttrGet
+mlirStridedLayoutAttrGetNumStrides
+mlirStridedLayoutAttrGetOffset
+mlirStridedLayoutAttrGetStride
+mlirStringAttrGet
+mlirStringAttrGetValue
+mlirStringAttrTypedGet
+mlirStringRefCreateFromCString
+mlirStringRefEqual
+mlirSymbolRefAttrGet
+mlirSymbolRefAttrGetLeafReference
+mlirSymbolRefAttrGetNestedReference
+mlirSymbolRefAttrGetNumNestedReferences
+mlirSymbolRefAttrGetRootReference
+mlirSymbolTableCreate
+mlirSymbolTableDestroy
+mlirSymbolTableErase
+mlirSymbolTableGetSymbolAttributeName
+mlirSymbolTableGetVisibilityAttributeName
+mlirSymbolTableInsert
+mlirSymbolTableLookup
+mlirSymbolTableReplaceAllSymbolUses
+mlirSymbolTableWalkSymbolTables
+mlirTransformAnyOpTypeGet
+mlirTransformOperationTypeGet
+mlirTransformOperationTypeGetOperationName
+mlirTupleTypeGet
+mlirTupleTypeGetNumTypes
+mlirTupleTypeGetType
+mlirTypeAttrGet
+mlirTypeAttrGetValue
+mlirTypeDump
+mlirTypeEqual
+mlirTypeGetContext
+mlirTypeGetTypeID
+mlirTypeIDAllocatorAllocateTypeID
+mlirTypeIDAllocatorCreate
+mlirTypeIDAllocatorDestroy
+mlirTypeIDCreate
+mlirTypeIDEqual
+mlirTypeIDHashValue
+mlirTypeIsABF16
+mlirTypeIsAComplex
+mlirTypeIsAF16
+mlirTypeIsAF32
+mlirTypeIsAF64
+mlirTypeIsAFloat8E4M3FN
+mlirTypeIsAFloat8E5M2
+mlirTypeIsAFunction
+mlirTypeIsAIndex
+mlirTypeIsAInteger
+mlirTypeIsAMemRef
+mlirTypeIsANone
+mlirTypeIsAOpaque
+mlirTypeIsAPDLAttributeType
+mlirTypeIsAPDLOperationType
+mlirTypeIsAPDLRangeType
+mlirTypeIsAPDLType
+mlirTypeIsAPDLTypeType
+mlirTypeIsAPDLValueType
+mlirTypeIsARankedTensor
+mlirTypeIsAShaped
+mlirTypeIsATensor
+mlirTypeIsATransformAnyOpType
+mlirTypeIsATransformOperationType
+mlirTypeIsATuple
+mlirTypeIsAUnrankedMemRef
+mlirTypeIsAUnrankedTensor
+mlirTypeIsAVector
+mlirTypeParseGet
+mlirTypePrint
+mlirUnitAttrGet
+mlirUnrankedMemRefTypeGet
+mlirUnrankedMemRefTypeGetChecked
+mlirUnrankedMemrefGetMemorySpace
+mlirUnrankedTensorTypeGet
+mlirUnrankedTensorTypeGetChecked
+mlirValueDump
+mlirValueEqual
+mlirValueGetType
+mlirValueIsABlockArgument
+mlirValueIsAOpResult
+mlirValuePrint
+mlirVectorTypeGet
+mlirVectorTypeGetChecked
diff --git a/compiler/src/iree/compiler/API2/generate_exports.py b/compiler/src/iree/compiler/API2/generate_exports.py
new file mode 100755
index 0000000..f203863
--- /dev/null
+++ b/compiler/src/iree/compiler/API2/generate_exports.py
@@ -0,0 +1,195 @@
+#!/usr/bin/env python
+# Copyright 2022 The IREE Authors
+#
+# Licensed under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+"""Scans sources and generates export files.
+
+Since we are only exporting a controlled C-API which is intended to be
+standalone and present minimal chance for conflicts, we take an explicit
+approach to generate lists of export symbols. Further, in order to ease
+the integration with the build system, we assemble exported shared libraries
+from normal static libraries that have been annotated properly at the source
+level with visibility and/or dllexport attributes (depending on platform).
+
+While it is possible to forgo this explicit control and twist the build
+system to force link leaf objects, exporting annotated symbols, in practice,
+this is quite hard to manage with a level of precision that these things need.
+Also, it runs quite counter to how build systems reason about library
+dependencies and is very invasive.
+
+Instead, once we have our list of symbols, we generate:
+
+* api_exports.ld : A GNU-style linker script for setting up exports.
+* api_exports.lst : A MacOS-style file suitable to pass to
+  --exported_symbols_list
+* api_exports.def : A Windows def file.
+* api_exports.c : Source file that triggers extern resolution for the symbols
+  we want (this is more portable/flexible vs --undefined at the expense of
+  feeling like a hack - spoilers: building shared libraries is a hack).
+
+These are files generated and checked into the repo. In this way, a human is
+in the loop on API symbol export and the API surface area becomes clearly
+documented in the source control system (vs automagically/opaquely at a low
+level of the build).
+"""
+
+from pathlib import Path
+import re
+from typing import List
+
+LOCAL_HEADER_FILES = [
+    "MLIRInterop.h",
+    "ToolEntryPoints.h",
+]
+
+MLIR_C_HEADER_FILES = [
+    "AffineExpr.h",
+    "AffineMap.h",
+    "BuiltinAttributes.h",
+    "BuiltinTypes.h",
+    "Debug.h",
+    "Diagnostics.h",
+    "IntegerSet.h",
+    "Interfaces.h",
+    "IR.h",
+    "Pass.h",
+    "Support.h",
+    "Transforms.h",
+    "Dialect/Linalg.h",
+    "Dialect/Transform.h",
+    "Dialect/PDL.h",
+]
+
+IREE_DIALECTS_HEADER_FILES = [
+    "Dialects.h",
+]
+
+EXPLICIT_EXPORTS = [
+    # MLIR registration functions that are part of generated code.
+    "mlirRegisterLinalgPasses",
+    "mlirGetDialectHandle__iree_input__",
+    "mlirGetDialectHandle__iree_linalg_ext__",
+    "mlirGetDialectHandle__iree_linalg_transform__",
+    "mlirGetDialectHandle__transform__",
+]
+
+# Matches statements that start with a well-known function declaration macro.
+# The group 'decl' contains the statement after the macro.
+MACRO_STATEMENT_PATTERN = re.compile(
+    r"\n(MLIR_CAPI_EXPORTED)\s+(?P<decl>[^\;]+);", re.MULTILINE | re.DOTALL)
+
+# Given a statement suspected to be a function declaration, extract the
+# function symbol.
+FUNC_DECL_SYMBOL_PATTERN = re.compile(r"(?P<symbol>\w+)\(",
+                                      re.MULTILINE | re.DOTALL)
+
+
+def main(repo_root: Path, api_root: Path):
+  export_symbols = list(EXPLICIT_EXPORTS)
+  # Collect symbols from local header files.
+  for local_name in LOCAL_HEADER_FILES:
+    export_symbols.extend(collect_header_exports(api_root / local_name))
+
+  # Collect symbols from iree-dialects header files.
+  for local_name in IREE_DIALECTS_HEADER_FILES:
+    export_symbols.extend(
+        collect_header_exports(
+            repo_root /
+            "llvm-external-projects/iree-dialects/include/iree-dialects-c" /
+            local_name))
+
+  # Collect symbols from mlir-c header files.
+  mlir_c_dir = repo_root / "third_party/llvm-project/mlir/include/mlir-c"
+  for local_name in MLIR_C_HEADER_FILES:
+    header_file = mlir_c_dir / local_name
+    if not header_file.exists():
+      raise RuntimeError(
+          f"Expected MLIR-C header file does not exist: {header_file}")
+    export_symbols.extend(collect_header_exports(header_file))
+
+  # Generate.
+  export_symbols.sort()
+  generate_symbol_list(export_symbols, api_root / "api_exports.lst")
+  generate_linker_script(export_symbols, api_root / "api_exports.ld")
+  generate_def_file(export_symbols, api_root / "api_exports.def")
+  generate_force_extern(export_symbols, api_root / "api_exports.c")
+
+
+def collect_header_exports(header_file: Path):
+  with open(header_file, "r") as f:
+    contents = f.read()
+
+  symbols = []
+  for m in re.finditer(MACRO_STATEMENT_PATTERN, contents):
+    decl = m.group("decl")
+    decl_m = re.search(FUNC_DECL_SYMBOL_PATTERN, decl)
+    if decl_m:
+      symbol = decl_m.group("symbol")
+      symbols.append(symbol)
+  return symbols
+
+
+def generate_symbol_list(symbols: List[str], file: Path):
+  with open(file, "wt") as f:
+    f.write("# Generated by generate_exports.py: Do not edit.\n")
+    for symbol in symbols:
+      f.write(f"{symbol}\n")
+
+
+def generate_linker_script(symbols: List[str], file: Path):
+  with open(file, "wt") as f:
+    f.write("# Generated by generate_exports.py: Do not edit.\n")
+    f.write("VER_0 {\n")
+    f.write("  global:\n")
+    for symbol in symbols:
+      f.write(f"    {symbol};\n")
+    f.write("  local:\n")
+    f.write("    *;\n")
+    f.write("};\n")
+
+
+def generate_def_file(symbols: List[str], file: Path):
+  with open(file, "wt") as f:
+    f.write("; Generated by generate_exports.py: Do not edit.\n")
+    f.write("EXPORTS\n")
+    for symbol in symbols:
+      f.write(f"  {symbol}\n")
+
+
+def generate_force_extern(symbols: List[str], file: Path):
+  with open(file, "wt") as f:
+    f.write("// Copyright 2022 The IREE Authors\n")
+    f.write("//\n")
+    f.write("// Licensed under the Apache License v2.0 with LLVM Exceptions.\n")
+    f.write("// See https://llvm.org/LICENSE.txt for license information.\n")
+    f.write("// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n")
+    f.write("\n")
+    f.write("// Generated by generate_exports.py: Do not edit.\n")
+    f.write("\n")
+    f.write("#include <stdint.h>\n")
+    f.write("\n")
+    for symbol in symbols:
+      f.write(f"extern void {symbol}();\n")
+    f.write("\n")
+    f.write("uintptr_t __iree_compiler_hidden_force_extern() {\n")
+    f.write("  uintptr_t x = 0;\n")
+    for symbol in symbols:
+      f.write(f"  x += (uintptr_t)&{symbol};\n")
+    f.write("  return x;\n")
+    f.write("}\n")
+
+
+if __name__ == "__main__":
+  script_dir = Path(__file__).parent
+  repo_root = script_dir
+  while True:
+    # Key off of "AUTHORS" file
+    if (repo_root / "AUTHORS").exists():
+      break
+    repo_root = repo_root.parent
+    if not repo_root:
+      raise RuntimeError(f"Could not find root of repo from {script_dir}")
+
+  main(repo_root=repo_root, api_root=script_dir)
diff --git a/compiler/src/iree/compiler/API/test/BUILD b/compiler/src/iree/compiler/API2/test/BUILD
similarity index 66%
rename from compiler/src/iree/compiler/API/test/BUILD
rename to compiler/src/iree/compiler/API2/test/BUILD
index 62709a3..26f7c6c 100644
--- a/compiler/src/iree/compiler/API/test/BUILD
+++ b/compiler/src/iree/compiler/API2/test/BUILD
@@ -4,25 +4,20 @@
 # See https://llvm.org/LICENSE.txt for license information.
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
-load("//build_tools/bazel:native_binary.bzl", "native_test")
+load("//build_tools/bazel:build_defs.oss.bzl", "iree_compiler_cc_test")
 
 package(
     features = ["layering_check"],
     licenses = ["notice"],  # Apache 2.0
 )
 
-cc_binary(
+iree_compiler_cc_test(
     name = "api-test-binary",
     testonly = True,
     srcs = ["api-test-main.c"],
     deps = [
-        "//compiler/src/iree/compiler/API:CAPI",
+        "//compiler/src/iree/compiler/API2:Headers",
+        "//compiler/src/iree/compiler/API2:Impl",
         "//runtime/src/iree/base",
-        "@llvm-project//mlir:CAPIIR",
     ],
 )
-
-native_test(
-    name = "api-test",
-    src = ":api-test-binary",
-)
diff --git a/compiler/src/iree/compiler/API2/test/CMakeLists.txt b/compiler/src/iree/compiler/API2/test/CMakeLists.txt
new file mode 100644
index 0000000..50b8dbe
--- /dev/null
+++ b/compiler/src/iree/compiler/API2/test/CMakeLists.txt
@@ -0,0 +1,24 @@
+################################################################################
+# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from           #
+# compiler/src/iree/compiler/API2/test/BUILD                                   #
+#                                                                              #
+# Use iree_cmake_extra_content from iree/build_defs.oss.bzl to add arbitrary   #
+# CMake-only content.                                                          #
+#                                                                              #
+# To disable autogeneration for this file entirely, delete this header.        #
+################################################################################
+
+iree_add_all_subdirs()
+
+iree_cc_test(
+  NAME
+    api-test-binary
+  SRCS
+    "api-test-main.c"
+  DEPS
+    iree::base
+    iree::compiler::API2::Headers
+    iree::compiler::API2::Impl
+)
+
+### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
diff --git a/compiler/src/iree/compiler/API/test/api-test-main.c b/compiler/src/iree/compiler/API2/test/api-test-main.c
similarity index 98%
rename from compiler/src/iree/compiler/API/test/api-test-main.c
rename to compiler/src/iree/compiler/API2/test/api-test-main.c
index 7e1bc81..32bc463 100644
--- a/compiler/src/iree/compiler/API/test/api-test-main.c
+++ b/compiler/src/iree/compiler/API2/test/api-test-main.c
@@ -15,7 +15,7 @@
 #include <stdio.h>
 
 #include "iree/base/api.h"
-#include "iree/compiler/API/Compiler.h"
+#include "iree/compiler/API2/MLIRInterop.h"
 
 static void bytecode_builder_callback(MlirStringRef str, void* userdata) {
   iree_string_builder_t* builder = (iree_string_builder_t*)userdata;
diff --git a/llvm-external-projects/iree-dialects/include/iree-dialects-c/Utils.h b/llvm-external-projects/iree-dialects/include/iree-dialects-c/Utils.h
deleted file mode 100644
index 6132ee9..0000000
--- a/llvm-external-projects/iree-dialects/include/iree-dialects-c/Utils.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2021 The IREE Authors
-//
-// Licensed under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-#ifndef IREE_DIALECTS_C_UTILS_H
-#define IREE_DIALECTS_C_UTILS_H
-
-#include "mlir-c/IR.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// TODO: Upstream C/Python APIs for symbol table.
-// Looks up the referrent operation with the given flat symbol, starting from
-// a specific op.
-MLIR_CAPI_EXPORTED MlirOperation
-ireeLookupNearestSymbolFrom(MlirOperation fromOp, MlirAttribute symbolRefAttr);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // IREE_DIALECTS_C_UTILS_H
diff --git a/llvm-external-projects/iree-dialects/lib/CAPI/CMakeLists.txt b/llvm-external-projects/iree-dialects/lib/CAPI/CMakeLists.txt
index cba823b..17561a6 100644
--- a/llvm-external-projects/iree-dialects/lib/CAPI/CMakeLists.txt
+++ b/llvm-external-projects/iree-dialects/lib/CAPI/CMakeLists.txt
@@ -1,6 +1,5 @@
 add_mlir_public_c_api_library(IREEDialectsCAPI
   Dialects.cpp
-  Utils.cpp
   LINK_LIBS PUBLIC
   MLIRIR
   MLIRTransformDialect
diff --git a/llvm-external-projects/iree-dialects/lib/CAPI/Utils.cpp b/llvm-external-projects/iree-dialects/lib/CAPI/Utils.cpp
deleted file mode 100644
index d704f2b..0000000
--- a/llvm-external-projects/iree-dialects/lib/CAPI/Utils.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2021 The IREE Authors
-//
-// Licensed under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-#include "iree-dialects-c/Utils.h"
-
-#include "mlir/CAPI/IR.h"
-#include "mlir/IR/BuiltinAttributes.h"
-#include "mlir/IR/SymbolTable.h"
-
-using namespace mlir;
-
-MlirOperation ireeLookupNearestSymbolFrom(MlirOperation fromOp,
-                                          MlirAttribute symbolRefAttr) {
-  auto symbolRefAttrCpp = unwrap(symbolRefAttr).cast<SymbolRefAttr>();
-  return wrap(
-      SymbolTable::lookupNearestSymbolFrom(unwrap(fromOp), symbolRefAttrCpp));
-}
diff --git a/llvm-external-projects/iree-dialects/python/IREEDialectsModule.cpp b/llvm-external-projects/iree-dialects/python/IREEDialectsModule.cpp
index 3c19ffb..1a85609 100644
--- a/llvm-external-projects/iree-dialects/python/IREEDialectsModule.cpp
+++ b/llvm-external-projects/iree-dialects/python/IREEDialectsModule.cpp
@@ -5,7 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 #include "iree-dialects-c/Dialects.h"
-#include "iree-dialects-c/Utils.h"
 #include "mlir-c/BuiltinAttributes.h"
 #include "mlir-c/BuiltinTypes.h"
 #include "mlir-c/Diagnostics.h"
@@ -22,28 +21,6 @@
   auto typeClass = irModule.attr("Type");
 
   //===--------------------------------------------------------------------===//
-  // Utils
-  //===--------------------------------------------------------------------===//
-
-  m.def(
-      "lookup_nearest_symbol_from",
-      [](MlirOperation fromOp, MlirAttribute symbol) {
-        if (!mlirAttributeIsASymbolRef(symbol)) {
-          throw std::invalid_argument("expected a SymbolRefAttr");
-        }
-        return ireeLookupNearestSymbolFrom(fromOp, symbol);
-      },
-      py::arg("fromOp"), py::arg("symbol"));
-
-  // TODO: Upstream this into the main Python bindings.
-  m.def(
-      "emit_error",
-      [](MlirLocation loc, std::string message) {
-        mlirEmitError(loc, message.c_str());
-      },
-      py::arg("loc"), py::arg("message"));
-
-  //===--------------------------------------------------------------------===//
   // IREEDialect
   //===--------------------------------------------------------------------===//
   auto iree_m = m.def_submodule("iree_input");
diff --git a/tools/BUILD b/tools/BUILD
index c39c18d..a8810d7 100644
--- a/tools/BUILD
+++ b/tools/BUILD
@@ -96,12 +96,8 @@
     srcs = ["iree-opt-main.cc"],
     tags = ["hostonly"],
     deps = [
-        "//compiler/src/iree/compiler/Tools:init_passes_and_dialects",
-        "//compiler/src/iree/compiler/Tools:init_targets",
-        "@llvm-project//llvm:Support",
-        "@llvm-project//mlir:IR",
-        "@llvm-project//mlir:MlirOptLib",
-        "@llvm-project//mlir:Support",
+        "//compiler/src/iree/compiler/API2:Headers",
+        "//compiler/src/iree/compiler/API2:Impl",
     ],
 )
 
@@ -109,10 +105,8 @@
     name = "iree-mlir-lsp-server",
     srcs = ["iree-mlir-lsp-server.cc"],
     deps = [
-        "//compiler/src/iree/compiler/Tools:init_passes_and_dialects",
-        "@llvm-project//mlir:IR",
-        "@llvm-project//mlir:MlirLspServerLib",
-        "@llvm-project//mlir:Support",
+        "//compiler/src/iree/compiler/API2:Headers",
+        "//compiler/src/iree/compiler/API2:Impl",
     ],
 )
 
@@ -225,6 +219,7 @@
     srcs = ["iree-compile-main.cc"],
     tags = ["hostonly"],
     deps = [
-        "//compiler/src/iree/compiler/Tools:iree_compile_lib",
+        "//compiler/src/iree/compiler/API2:Headers",
+        "//compiler/src/iree/compiler/API2:Impl",
     ],
 )
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index c1c49df..194fc3f 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -195,10 +195,12 @@
     SRCS
       "iree-compile-main.cc"
     DEPS
-      iree::compiler::Tools::iree_compile_lib
+      iree::compiler::API2::Headers
+      iree::compiler::API2::Impl
     DATA
       ${IREE_LLD_TARGET}
     HOSTONLY
+    SETUP_INSTALL_RPATH
   )
 
   iree_cc_binary(
@@ -207,15 +209,12 @@
     SRCS
       "iree-opt-main.cc"
     DEPS
-      LLVMSupport
-      MLIRIR
-      MLIROptLib
-      MLIRSupport
-      iree::compiler::Tools::init_passes_and_dialects
-      iree::compiler::Tools::init_targets
+      iree::compiler::API2::Headers
+      iree::compiler::API2::Impl
     DATA
       ${IREE_LLD_TARGET}
     HOSTONLY
+    SETUP_INSTALL_RPATH
   )
 
   iree_cc_binary(
@@ -224,12 +223,10 @@
     SRCS
       "iree-mlir-lsp-server.cc"
     DEPS
-      MLIRIR
-      MLIRLspServerLib
-      MLIRSupport
-      iree::compiler::Tools::init_passes_and_dialects
+      iree::compiler::API2::Headers
+      iree::compiler::API2::Impl
     PUBLIC
-    EXCLUDE_FROM_ALL
+    SETUP_INSTALL_RPATH
   )
 
   iree_cc_binary(
diff --git a/tools/iree-compile-main.cc b/tools/iree-compile-main.cc
index 8ee0605..9088cb2 100644
--- a/tools/iree-compile-main.cc
+++ b/tools/iree-compile-main.cc
@@ -4,8 +4,6 @@
 // See https://llvm.org/LICENSE.txt for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
-#include "iree/compiler/Tools/iree_compile_lib.h"
+#include "iree/compiler/API2/ToolEntryPoints.h"
 
-int main(int argc, char **argv) {
-  return mlir::iree_compiler::runIreecMain(argc, argv);
-}
+int main(int argc, char **argv) { return ireeCompilerRunMain(argc, argv); }
diff --git a/tools/iree-mlir-lsp-server.cc b/tools/iree-mlir-lsp-server.cc
index 9da1522..b170b38 100644
--- a/tools/iree-mlir-lsp-server.cc
+++ b/tools/iree-mlir-lsp-server.cc
@@ -8,13 +8,6 @@
 //
 // See https://mlir.llvm.org/docs/Tools/MLIRLSP/
 
-#include "iree/compiler/Tools/init_dialects.h"
-#include "mlir/IR/Dialect.h"
-#include "mlir/Support/LogicalResult.h"
-#include "mlir/Tools/mlir-lsp-server/MlirLspServerMain.h"
+#include "iree/compiler/API2/ToolEntryPoints.h"
 
-int main(int argc, char **argv) {
-  mlir::DialectRegistry registry;
-  mlir::iree_compiler::registerAllDialects(registry);
-  return failed(mlir::MlirLspServerMain(argc, argv, registry));
-}
+int main(int argc, char **argv) { return ireeMlirLspServerRunMain(argc, argv); }
diff --git a/tools/iree-opt-main.cc b/tools/iree-opt-main.cc
index 9325620..c84199b 100644
--- a/tools/iree-opt-main.cc
+++ b/tools/iree-opt-main.cc
@@ -8,30 +8,6 @@
 //
 // Based on mlir-opt but registers the passes and dialects we care about.
 
-#include "iree/compiler/Tools/init_dialects.h"
-#include "iree/compiler/Tools/init_passes.h"
-#include "iree/compiler/Tools/init_targets.h"
-#include "llvm/Support/InitLLVM.h"
-#include "mlir/IR/Dialect.h"
-#include "mlir/Support/LogicalResult.h"
-#include "mlir/Tools/mlir-opt/MlirOptMain.h"
+#include "iree/compiler/API2/ToolEntryPoints.h"
 
-int main(int argc, char **argv) {
-  llvm::InitLLVM y(argc, argv);
-
-  mlir::DialectRegistry registry;
-  mlir::iree_compiler::registerAllDialects(registry);
-  mlir::iree_compiler::registerAllPasses();
-  mlir::iree_compiler::registerHALTargetBackends();
-
-  // Register the pass to drop embedded transform dialect IR.
-  // TODO: this should be upstreamed.
-  mlir::linalg::transform::registerDropSchedulePass();
-
-  if (failed(MlirOptMain(argc, argv, "IREE modular optimizer driver\n",
-                         registry,
-                         /*preloadDialectsInContext=*/false))) {
-    return 1;
-  }
-  return 0;
-}
+int main(int argc, char **argv) { return ireeOptRunMain(argc, argv); }