First step of releasing bazel BUILD files.

Note that there is follow-on work needed to map third_party dependencies and other things that differ between the upstream source of truth (where these originate) and the github repo (i.e. I haven't tried and don't expect that this actually builds yet).

PiperOrigin-RevId: 273378016
diff --git a/WORKSPACE b/WORKSPACE
new file mode 100644
index 0000000..4669781
--- /dev/null
+++ b/WORKSPACE
@@ -0,0 +1 @@
+# Workspace file for the IREE project.
diff --git a/iree/BUILD b/iree/BUILD
new file mode 100644
index 0000000..342272e
--- /dev/null
+++ b/iree/BUILD
@@ -0,0 +1,13 @@
+# Main IREE build file.
+
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+# Marker library which can be extended to provide flags for things that
+# need to know the platform target.
+cc_library(
+    name = "target_config",
+    defines = ["IREE_UNSPECIFIED_TARGET=1"],
+)
diff --git a/iree/base/BUILD b/iree/base/BUILD
new file mode 100644
index 0000000..40f58a9
--- /dev/null
+++ b/iree/base/BUILD
@@ -0,0 +1,354 @@
+# Common types and utilities used in the IREE codebase.
+
+load("//iree:build_defs.bzl", "platform_trampoline_deps")
+
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+cc_library(
+    name = "api",
+    srcs = ["api.cc"],
+    hdrs = ["api.h"],
+    visibility = ["//visibility:public"],
+    deps = [
+        ":api_hdrs",
+        ":api_util",
+        ":file_mapping",
+        ":tracing",
+    ],
+)
+
+cc_library(
+    name = "api_hdrs",
+    hdrs = ["api.h"],
+)
+
+cc_library(
+    name = "api_util",
+    hdrs = ["api_util.h"],
+    deps = [
+        ":api_hdrs",
+        ":status",
+    ],
+)
+
+cc_library(
+    name = "arena",
+    srcs = ["arena.cc"],
+    hdrs = ["arena.h"],
+    deps = [
+        ":logging",
+        "//third_party/absl/base:core_headers",
+        "//third_party/absl/types:span",
+    ],
+)
+
+cc_test(
+    name = "arena_test",
+    srcs = ["arena_test.cc"],
+    deps = [
+        ":arena",
+        "//testing/base/public:gunit_main",
+    ],
+)
+
+cc_library(
+    name = "bitfield",
+    hdrs = ["bitfield.h"],
+    deps = [
+        "//third_party/absl/types:span",
+    ],
+)
+
+cc_test(
+    name = "bitfield_test",
+    srcs = ["bitfield_test.cc"],
+    deps = [
+        ":bitfield",
+        "//testing/base/public:gunit_main",
+        "//third_party/absl/base:core_headers",
+    ],
+)
+
+cc_library(
+    name = "file_io",
+    hdrs = ["file_io.h"],
+    deps = [
+        ":status",
+        ":target_platform",
+        "//third_party/absl/memory",
+        "//third_party/absl/strings",
+        "//third_party/absl/types:span",
+    ] + platform_trampoline_deps("file_io"),
+)
+
+cc_library(
+    name = "file_io_hdrs",
+    hdrs = ["file_io.h"],
+    deps = [":status"],
+)
+
+cc_library(
+    name = "file_mapping",
+    hdrs = ["file_mapping.h"],
+    deps = [
+        ":ref_ptr",
+        ":status",
+        "//third_party/absl/memory",
+        "//third_party/absl/strings",
+        "//third_party/absl/types:span",
+    ] + platform_trampoline_deps("file_mapping"),
+)
+
+cc_library(
+    name = "file_mapping_hdrs",
+    hdrs = ["file_mapping.h"],
+    deps = [
+        ":ref_ptr",
+        ":status",
+        "//third_party/absl/types:span",
+    ],
+)
+
+cc_library(
+    name = "file_path",
+    srcs = ["file_path.cc"],
+    hdrs = ["file_path.h"],
+    deps = [
+        "//third_party/absl/strings",
+    ],
+)
+
+cc_library(
+    name = "flatbuffer_util",
+    srcs = ["flatbuffer_util.cc"],
+    hdrs = ["flatbuffer_util.h"],
+    deps = [
+        ":file_mapping",
+        ":memory",
+        ":source_location",
+        ":status",
+        ":tracing",
+        "//third_party/absl/base:core_headers",
+        "//third_party/absl/memory",
+        "//third_party/absl/strings",
+        "//third_party/absl/types:optional",
+        "//third_party/absl/types:span",
+        "//third_party/flatbuffers",
+    ],
+)
+
+cc_library(
+    name = "init",
+    hdrs = ["init.h"],
+    deps = platform_trampoline_deps("init"),
+)
+
+cc_library(
+    name = "intrusive_list",
+    hdrs = [
+        "intrusive_list.h",
+        "intrusive_list_ref_ptr.inc",
+        "intrusive_list_unique_ptr.inc",
+    ],
+    deps = [
+        ":logging",
+        ":ref_ptr",
+    ],
+)
+
+cc_test(
+    name = "intrusive_list_test",
+    srcs = [
+        "intrusive_list_ref_ptr_test.cc",
+        "intrusive_list_test.cc",
+        "intrusive_list_unique_ptr_test.cc",
+    ],
+    deps = [
+        ":intrusive_list",
+        "//testing/base/public:gunit_main",
+    ],
+)
+
+cc_library(
+    name = "logging",
+    hdrs = ["logging.h"],
+    deps = platform_trampoline_deps("logging"),
+)
+
+cc_library(
+    name = "math",
+    hdrs = ["math.h"],
+    deps = [
+        "//third_party/absl/base:core_headers",
+    ],
+)
+
+cc_library(
+    name = "memory",
+    hdrs = ["memory.h"],
+    deps = [
+        "//third_party/absl/types:span",
+    ],
+)
+
+cc_library(
+    name = "ref_ptr",
+    hdrs = ["ref_ptr.h"],
+    deps = [
+        ":logging",
+        "//third_party/absl/base:core_headers",
+    ],
+)
+
+cc_test(
+    name = "ref_ptr_test",
+    size = "small",
+    srcs = ["ref_ptr_test.cc"],
+    deps = [
+        ":ref_ptr",
+        "//testing/base/public:gunit_main",
+    ],
+)
+
+cc_library(
+    name = "shape",
+    srcs = ["shape.cc"],
+    hdrs = ["shape.h"],
+    deps = [
+        ":logging",
+        ":source_location",
+        ":status",
+        "//third_party/absl/meta:type_traits",
+        "//third_party/absl/strings",
+        "//third_party/absl/types:span",
+    ],
+)
+
+cc_test(
+    name = "shape_test",
+    srcs = ["shape_test.cc"],
+    deps = [
+        ":shape",
+        ":status",
+        ":status_matchers",
+        "//testing/base/public:gunit_main",
+    ],
+)
+
+cc_library(
+    name = "source_location",
+    hdrs = ["source_location.h"],
+    deps = platform_trampoline_deps("source_location"),
+)
+
+cc_library(
+    name = "status",
+    hdrs = ["status.h"],
+    deps = [
+        ":source_location",
+    ] + platform_trampoline_deps("status"),
+)
+
+cc_library(
+    name = "status_matchers",
+    testonly = 1,
+    hdrs = ["status_matchers.h"],
+    deps = platform_trampoline_deps("status_matchers"),
+)
+
+cc_library(
+    name = "target_platform",
+    hdrs = ["target_platform.h"],
+)
+
+cc_library(
+    name = "time",
+    hdrs = ["time.h"],
+    deps = [
+        "//third_party/absl/time",
+    ],
+)
+
+cc_library(
+    name = "tracing",
+    hdrs = ["tracing.h"],
+    deps = [
+        "//iree:target_config",
+        "//third_party/tracing_framework_bindings_cpp",
+    ] + select({
+        "//third_party/tracing_framework_bindings_cpp:wtf_enable": [":tracing_enabled"],
+        "//conditions:default": [":tracing_disabled"],
+    }),
+)
+
+cc_library(
+    name = "tracing_disabled",
+    srcs = [
+        "tracing.h",
+        "tracing_disabled.cc",
+    ],
+    visibility = ["//visibility:private"],
+    deps = [
+        ":init",
+        ":logging",
+        "//third_party/absl/flags:flag",
+        "//third_party/tracing_framework_bindings_cpp",
+    ],
+    alwayslink = 1,
+)
+
+cc_library(
+    name = "tracing_enabled",
+    srcs = [
+        "tracing.cc",
+        "tracing.h",
+    ],
+    visibility = ["//visibility:private"],
+    deps = [
+        ":file_io",
+        ":file_path",
+        ":init",
+        ":logging",
+        ":status",
+        "//third_party/absl/base:core_headers",
+        "//third_party/absl/flags:flag",
+        "//third_party/absl/strings",
+        "//third_party/absl/synchronization",
+        "//third_party/absl/time",
+        "//third_party/tracing_framework_bindings_cpp",
+    ],
+    alwayslink = 1,
+)
+
+cc_library(
+    name = "wait_handle",
+    srcs = ["wait_handle.cc"],
+    hdrs = ["wait_handle.h"],
+    deps = [
+        ":logging",
+        ":ref_ptr",
+        ":source_location",
+        ":status",
+        ":time",
+        "//third_party/absl/base:core_headers",
+        "//third_party/absl/container:fixed_array",
+        "//third_party/absl/strings",
+        "//third_party/absl/time",
+        "//third_party/absl/types:span",
+    ],
+)
+
+cc_test(
+    name = "wait_handle_test",
+    srcs = ["wait_handle_test.cc"],
+    deps = [
+        ":status",
+        ":status_matchers",
+        ":wait_handle",
+        "//testing/base/public:gunit_main",
+        "//third_party/absl/time",
+    ],
+)
diff --git a/iree/base/internal/BUILD b/iree/base/internal/BUILD
new file mode 100644
index 0000000..a18d009
--- /dev/null
+++ b/iree/base/internal/BUILD
@@ -0,0 +1,118 @@
+# Implementations for iree/base/
+
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+cc_library(
+    name = "file_handle_win32",
+    srcs = ["file_handle_win32.cc"],
+    hdrs = ["file_handle_win32.h"],
+    deps = [
+        "//iree/base:status",
+        "//iree/base:target_platform",
+        "//third_party/absl/memory",
+        "//third_party/absl/strings",
+    ],
+)
+
+cc_library(
+    name = "file_io_internal",
+    srcs = [
+        "file_io_posix.cc",
+        "file_io_win32.cc",
+    ],
+    deps = [
+        ":file_handle_win32",
+        "//iree/base:file_io_hdrs",
+        "//iree/base:status",
+        "//iree/base:target_platform",
+        "//third_party/absl/memory",
+        "//third_party/absl/strings",
+    ],
+)
+
+cc_library(
+    name = "file_mapping_internal",
+    srcs = [
+        "file_mapping_posix.cc",
+        "file_mapping_win32.cc",
+    ],
+    deps = [
+        ":file_handle_win32",
+        "//iree/base:file_mapping_hdrs",
+        "//iree/base:target_platform",
+        "//iree/base:tracing",
+        "//third_party/absl/memory",
+        "//third_party/absl/strings",
+    ],
+)
+
+cc_library(
+    name = "init_internal",
+    srcs = ["init_internal.cc"],
+    hdrs = ["init_internal.h"],
+    deps = [
+        "//iree/base:target_platform",
+        "//third_party/absl/flags:parse",
+    ],
+)
+
+cc_library(
+    name = "logging_internal",
+    srcs = ["logging.cc"],
+    hdrs = ["logging.h"],
+    deps = [
+        "//third_party/absl/base:core_headers",
+        "//third_party/absl/flags:flag",
+    ],
+)
+
+cc_library(
+    name = "source_location_internal",
+    hdrs = ["source_location.h"],
+)
+
+cc_library(
+    name = "status_internal",
+    srcs = [
+        "status.cc",
+        "status_builder.cc",
+        "status_errno.cc",
+        "status_errors.cc",
+        "status_win32_errors.cc",
+        "statusor.cc",
+    ],
+    hdrs = [
+        "status.h",
+        "status_builder.h",
+        "status_errno.h",
+        "status_errors.h",
+        "status_macros.h",
+        "status_win32_errors.h",
+        "statusor.h",
+    ],
+    deps = [
+        ":logging_internal",
+        "//iree/base:source_location",
+        "//iree/base:target_platform",
+        "//third_party/absl/base:core_headers",
+        "//third_party/absl/debugging:stacktrace",
+        "//third_party/absl/flags:flag",
+        "//third_party/absl/memory",
+        "//third_party/absl/strings",
+    ],
+)
+
+cc_library(
+    name = "status_matchers_internal",
+    testonly = 1,
+    hdrs = ["status_matchers.h"],
+    deps = [
+        "//iree/base:status",
+        "//testing/base/public:gunit_for_library",
+        "//third_party/absl/strings",
+        "//third_party/absl/types:optional",
+    ],
+)
diff --git a/iree/base/source_location.h b/iree/base/source_location.h
index e983557..d4a10ca 100644
--- a/iree/base/source_location.h
+++ b/iree/base/source_location.h
@@ -16,7 +16,7 @@
 #define IREE_BASE_SOURCE_LOCATION_H_
 
 #ifdef IREE_CONFIG_GOOGLE_INTERNAL
-#include "iree/base/google/source_location_absl.h"
+#include "iree/base/google/source_location_google.h"
 #else
 #include "iree/base/internal/source_location.h"
 #endif  // IREE_CONFIG_GOOGLE_INTERNAL
diff --git a/iree/build_defs.bzl b/iree/build_defs.bzl
new file mode 100644
index 0000000..4e8d51f
--- /dev/null
+++ b/iree/build_defs.bzl
@@ -0,0 +1,20 @@
+"""Common Bazel definitions for IREE."""
+
+def platform_trampoline_deps(basename):
+    """Produce a list of deps for the given `basename` platform target.
+
+    Example:
+      "file_mapping" -> ["//iree/base/internal/file_mapping_internal"]
+
+    This is used for compatibility with various methods of including the
+    library in foreign source control systems.
+
+    Args:
+      basename: Library name prefix for a library in base/internal.
+    Returns:
+      A list of dependencies for depending on the library in a platform
+      sensitive way.
+    """
+    return [
+        "//iree/base/internal:%s_internal" % basename,
+    ]
diff --git a/iree/compiler/BUILD b/iree/compiler/BUILD
new file mode 100644
index 0000000..2b86f73
--- /dev/null
+++ b/iree/compiler/BUILD
@@ -0,0 +1,4 @@
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
diff --git a/iree/compiler/IR/BUILD b/iree/compiler/IR/BUILD
new file mode 100644
index 0000000..47ea631
--- /dev/null
+++ b/iree/compiler/IR/BUILD
@@ -0,0 +1,108 @@
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+load("//third_party/llvm/llvm/projects/google_mlir:tblgen.bzl", "gentbl")
+
+exports_files(["OpBase.td"])
+
+filegroup(
+    name = "td_files",
+    srcs = glob(["*.td"]),
+)
+
+cc_library(
+    name = "IR",
+    srcs = [
+        "ConfigOps.cpp",
+        "ConfigOps.cpp.inc",
+        "Dialect.cpp",
+        "Enums.cpp.inc",
+        "Ops.cpp",
+        "Ops.cpp.inc",
+        "StructureOps.cpp",
+        "StructureOps.cpp.inc",
+        "Traits.cpp",
+        "Types.cpp",
+    ],
+    hdrs = [
+        "ConfigOps.h",
+        "ConfigOps.h.inc",
+        "Dialect.h",
+        "Enums.h.inc",
+        "Ops.h",
+        "Ops.h.inc",
+        "StructureOps.h",
+        "StructureOps.h.inc",
+        "Traits.h",
+        "Types.h",
+    ],
+    deps = [
+        ":ConfigOpsGen",
+        ":EnumsGen",
+        ":OpsGen",
+        ":StructureOpsGen",
+        "//third_party/llvm/llvm:support",
+        "//third_party/llvm/llvm/projects/google_mlir:IR",
+        "//third_party/llvm/llvm/projects/google_mlir:StandardOps",
+        "//third_party/llvm/llvm/projects/google_mlir:Support",
+    ],
+    alwayslink = 1,
+)
+
+gentbl(
+    name = "ConfigOpsGen",
+    tbl_outs = [
+        ("-gen-op-decls", "ConfigOps.h.inc"),
+        ("-gen-op-defs", "ConfigOps.cpp.inc"),
+    ],
+    tblgen = "//third_party/llvm/llvm/projects/google_mlir:mlir-tblgen",
+    td_file = "ConfigOps.td",
+    td_srcs = [
+        ":td_files",
+        "//third_party/llvm/llvm/projects/google_mlir:OpBaseTdFiles",
+    ],
+)
+
+gentbl(
+    name = "EnumsGen",
+    tbl_outs = [
+        ("-gen-enum-decls", "Enums.h.inc"),
+        ("-gen-enum-defs", "Enums.cpp.inc"),
+    ],
+    tblgen = "//third_party/llvm/llvm/projects/google_mlir:mlir-tblgen",
+    td_file = "OpBase.td",
+    td_srcs = [
+        ":td_files",
+        "//third_party/llvm/llvm/projects/google_mlir:OpBaseTdFiles",
+    ],
+)
+
+gentbl(
+    name = "OpsGen",
+    tbl_outs = [
+        ("-gen-op-decls", "Ops.h.inc"),
+        ("-gen-op-defs", "Ops.cpp.inc"),
+    ],
+    tblgen = "//third_party/llvm/llvm/projects/google_mlir:mlir-tblgen",
+    td_file = "Ops.td",
+    td_srcs = [
+        ":td_files",
+        "//third_party/llvm/llvm/projects/google_mlir:OpBaseTdFiles",
+    ],
+)
+
+gentbl(
+    name = "StructureOpsGen",
+    tbl_outs = [
+        ("-gen-op-decls", "StructureOps.h.inc"),
+        ("-gen-op-defs", "StructureOps.cpp.inc"),
+    ],
+    tblgen = "//third_party/llvm/llvm/projects/google_mlir:mlir-tblgen",
+    td_file = "StructureOps.td",
+    td_srcs = [
+        ":td_files",
+        "//third_party/llvm/llvm/projects/google_mlir:OpBaseTdFiles",
+    ],
+)
diff --git a/iree/compiler/IR/Interpreter/BUILD b/iree/compiler/IR/Interpreter/BUILD
new file mode 100644
index 0000000..ba30fe5
--- /dev/null
+++ b/iree/compiler/IR/Interpreter/BUILD
@@ -0,0 +1,75 @@
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+load("//third_party/llvm/llvm/projects/google_mlir:tblgen.bzl", "gentbl")
+
+filegroup(
+    name = "td_files",
+    srcs = glob(["*.td"]),
+)
+
+cc_library(
+    name = "Interpreter",
+    srcs = [
+        "HLDialect.cpp",
+        "HLOps.cpp",
+        "HLOps.cpp.inc",
+        "LLDialect.cpp",
+        "LLOps.cpp",
+        "LLOps.cpp.inc",
+        "OpWriters.cpp",
+    ],
+    hdrs = [
+        "HLDialect.h",
+        "HLOps.h",
+        "HLOps.h.inc",
+        "LLDialect.h",
+        "LLOps.h",
+        "LLOps.h.inc",
+        "OpWriters.h",
+    ],
+    deps = [
+        ":HLOpsGen",
+        ":LLOpsGen",
+        "//iree/compiler/IR",
+        "//iree/compiler/Serialization",
+        "//iree/compiler/Utils",
+        "//iree/schemas/bytecode:interpreter_bytecode_v0",
+        "//third_party/llvm/llvm:support",
+        "//third_party/llvm/llvm/projects/google_mlir:IR",
+        "//third_party/llvm/llvm/projects/google_mlir:StandardOps",
+    ],
+    alwayslink = 1,
+)
+
+gentbl(
+    name = "HLOpsGen",
+    tbl_outs = [
+        ("-gen-op-decls", "HLOps.h.inc"),
+        ("-gen-op-defs", "HLOps.cpp.inc"),
+    ],
+    tblgen = "//third_party/llvm/llvm/projects/google_mlir:mlir-tblgen",
+    td_file = "HLOps.td",
+    td_srcs = [
+        ":td_files",
+        "//third_party/llvm/llvm/projects/google_mlir:include/mlir/IR/OpBase.td",
+        "//iree/compiler/IR:OpBase.td",
+    ],
+)
+
+gentbl(
+    name = "LLOpsGen",
+    tbl_outs = [
+        ("-gen-op-decls", "LLOps.h.inc"),
+        ("-gen-op-defs", "LLOps.cpp.inc"),
+    ],
+    tblgen = "//third_party/llvm/llvm/projects/google_mlir:mlir-tblgen",
+    td_file = "LLOps.td",
+    td_srcs = [
+        ":td_files",
+        "//third_party/llvm/llvm/projects/google_mlir:include/mlir/IR/OpBase.td",
+        "//iree/compiler/IR:OpBase.td",
+    ],
+)
diff --git a/iree/compiler/IR/Interpreter/test/BUILD b/iree/compiler/IR/Interpreter/test/BUILD
new file mode 100644
index 0000000..4da1f1c
--- /dev/null
+++ b/iree/compiler/IR/Interpreter/test/BUILD
@@ -0,0 +1,24 @@
+load("//third_party/llvm/build_defs:lit.bzl", "glob_lit_tests")
+
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+glob_lit_tests(
+    data = [":test_utilities"],
+    driver = "//iree/tools:run_lit.sh",
+    test_file_exts = ["mlir"],
+)
+
+# Bundle together all of the test utilities that are used by tests.
+filegroup(
+    name = "test_utilities",
+    testonly = True,
+    data = [
+        "//iree/tools:iree-opt",
+        "//iree/tools:iree-run-mlir",
+        "//third_party/llvm/llvm:FileCheck",
+        "//third_party/llvm/llvm/projects/google_mlir:run_lit.sh",
+    ],
+)
diff --git a/iree/compiler/IR/Sequencer/BUILD b/iree/compiler/IR/Sequencer/BUILD
new file mode 100644
index 0000000..25a6e0a
--- /dev/null
+++ b/iree/compiler/IR/Sequencer/BUILD
@@ -0,0 +1,76 @@
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+load("//third_party/llvm/llvm/projects/google_mlir:tblgen.bzl", "gentbl")
+
+filegroup(
+    name = "td_files",
+    srcs = glob(["*.td"]),
+)
+
+cc_library(
+    name = "Sequencer",
+    srcs = [
+        "HLDialect.cpp",
+        "HLOps.cpp",
+        "HLOps.cpp.inc",
+        "LLDialect.cpp",
+        "LLOps.cpp",
+        "LLOps.cpp.inc",
+        "OpWriters.cpp",
+    ],
+    hdrs = [
+        "HLDialect.h",
+        "HLOps.h",
+        "HLOps.h.inc",
+        "LLDialect.h",
+        "LLOps.h",
+        "LLOps.h.inc",
+        "OpWriters.h",
+    ],
+    deps = [
+        ":HLOpsGen",
+        ":LLOpsGen",
+        "//iree/compiler/IR",
+        "//iree/compiler/Serialization",
+        "//iree/compiler/Utils",
+        "//iree/schemas/bytecode:sequencer_bytecode_v0",
+        "//third_party/llvm/llvm:support",
+        "//third_party/llvm/llvm/projects/google_mlir:IR",
+        "//third_party/llvm/llvm/projects/google_mlir:StandardOps",
+        "//third_party/llvm/llvm/projects/google_mlir:Support",
+    ],
+    alwayslink = 1,
+)
+
+gentbl(
+    name = "HLOpsGen",
+    tbl_outs = [
+        ("-gen-op-decls", "HLOps.h.inc"),
+        ("-gen-op-defs", "HLOps.cpp.inc"),
+    ],
+    tblgen = "//third_party/llvm/llvm/projects/google_mlir:mlir-tblgen",
+    td_file = "HLOps.td",
+    td_srcs = [
+        ":td_files",
+        "//third_party/llvm/llvm/projects/google_mlir:include/mlir/IR/OpBase.td",
+        "//iree/compiler/IR:OpBase.td",
+    ],
+)
+
+gentbl(
+    name = "LLOpsGen",
+    tbl_outs = [
+        ("-gen-op-decls", "LLOps.h.inc"),
+        ("-gen-op-defs", "LLOps.cpp.inc"),
+    ],
+    tblgen = "//third_party/llvm/llvm/projects/google_mlir:mlir-tblgen",
+    td_file = "LLOps.td",
+    td_srcs = [
+        ":td_files",
+        "//third_party/llvm/llvm/projects/google_mlir:include/mlir/IR/OpBase.td",
+        "//iree/compiler/IR:OpBase.td",
+    ],
+)
diff --git a/iree/compiler/IR/Sequencer/test/BUILD b/iree/compiler/IR/Sequencer/test/BUILD
new file mode 100644
index 0000000..4da1f1c
--- /dev/null
+++ b/iree/compiler/IR/Sequencer/test/BUILD
@@ -0,0 +1,24 @@
+load("//third_party/llvm/build_defs:lit.bzl", "glob_lit_tests")
+
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+glob_lit_tests(
+    data = [":test_utilities"],
+    driver = "//iree/tools:run_lit.sh",
+    test_file_exts = ["mlir"],
+)
+
+# Bundle together all of the test utilities that are used by tests.
+filegroup(
+    name = "test_utilities",
+    testonly = True,
+    data = [
+        "//iree/tools:iree-opt",
+        "//iree/tools:iree-run-mlir",
+        "//third_party/llvm/llvm:FileCheck",
+        "//third_party/llvm/llvm/projects/google_mlir:run_lit.sh",
+    ],
+)
diff --git a/iree/compiler/IR/test/BUILD b/iree/compiler/IR/test/BUILD
new file mode 100644
index 0000000..4da1f1c
--- /dev/null
+++ b/iree/compiler/IR/test/BUILD
@@ -0,0 +1,24 @@
+load("//third_party/llvm/build_defs:lit.bzl", "glob_lit_tests")
+
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+glob_lit_tests(
+    data = [":test_utilities"],
+    driver = "//iree/tools:run_lit.sh",
+    test_file_exts = ["mlir"],
+)
+
+# Bundle together all of the test utilities that are used by tests.
+filegroup(
+    name = "test_utilities",
+    testonly = True,
+    data = [
+        "//iree/tools:iree-opt",
+        "//iree/tools:iree-run-mlir",
+        "//third_party/llvm/llvm:FileCheck",
+        "//third_party/llvm/llvm/projects/google_mlir:run_lit.sh",
+    ],
+)
diff --git a/iree/compiler/Serialization/BUILD b/iree/compiler/Serialization/BUILD
new file mode 100644
index 0000000..67fef5d
--- /dev/null
+++ b/iree/compiler/Serialization/BUILD
@@ -0,0 +1,43 @@
+# Serialization for the VM bytecode.
+
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+cc_library(
+    name = "Serialization",
+    srcs = [
+        "BytecodeTables.cpp",
+        "BytecodeWriter.cpp",
+        "VMDeviceTableBuilder.cpp",
+        "VMExecutableTableBuilder.cpp",
+        "VMFunctionBuilder.cpp",
+        "VMFunctionTableBuilder.cpp",
+        "VMModuleBuilder.cpp",
+        "VMSourceMapBuilder.cpp",
+    ],
+    hdrs = [
+        "BytecodeTables.h",
+        "BytecodeWriter.h",
+        "VMDeviceTableBuilder.h",
+        "VMExecutableTableBuilder.h",
+        "VMFunctionBuilder.h",
+        "VMFunctionTableBuilder.h",
+        "VMModuleBuilder.h",
+        "VMSourceMapBuilder.h",
+    ],
+    deps = [
+        "//iree/compiler/IR",
+        "//iree/compiler/Utils",
+        "//iree/schemas",
+        "//iree/schemas/bytecode:bytecode_v0",
+        "//iree/schemas/bytecode:interpreter_bytecode_v0",
+        "//iree/schemas/bytecode:sequencer_bytecode_v0",
+        "//third_party/flatbuffers",
+        "//third_party/llvm/llvm:support",
+        "//third_party/llvm/llvm/projects/google_mlir:IR",
+        "//third_party/llvm/llvm/projects/google_mlir:StandardOps",
+        "//third_party/llvm/llvm/projects/google_mlir:Support",
+    ],
+)
diff --git a/iree/compiler/Transforms/BUILD b/iree/compiler/Transforms/BUILD
new file mode 100644
index 0000000..2067664
--- /dev/null
+++ b/iree/compiler/Transforms/BUILD
@@ -0,0 +1,39 @@
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+cc_library(
+    name = "Transforms",
+    srcs = [
+        "AggressiveOpElimination.cpp",
+        "AssignFunctionOrdinals.cpp",
+        "ConvertFromTupleCallingConvention.cpp",
+        "ConvertToMemRefCallingConvention.cpp",
+        "DropUnreachableFunctions.cpp",
+        "DropUnusedExecutables.cpp",
+        "LegalizeTupleElementAccess.cpp",
+        "LegalizeTypeStorage.cpp",
+    ],
+    hdrs = [
+        "ConversionUtils.h",
+        "Passes.h",
+    ],
+    deps = [
+        "//iree/compiler/IR",
+        "//iree/compiler/IR/Interpreter",
+        "//iree/compiler/IR/Sequencer",
+        "//iree/compiler/Utils",
+        "//third_party/llvm/llvm:support",
+        "//third_party/llvm/llvm/projects/google_mlir:Analysis",
+        "//third_party/llvm/llvm/projects/google_mlir:IR",
+        "//third_party/llvm/llvm/projects/google_mlir:Pass",
+        "//third_party/llvm/llvm/projects/google_mlir:StandardDialectRegistration",
+        "//third_party/llvm/llvm/projects/google_mlir:StandardOps",
+        "//third_party/llvm/llvm/projects/google_mlir:Support",
+        "//third_party/llvm/llvm/projects/google_mlir:TransformUtils",
+        "//third_party/llvm/llvm/projects/google_mlir:Transforms",
+        "//third_party/tensorflow/compiler/mlir/xla:hlo",
+    ],
+    alwayslink = 1,
+)
diff --git a/iree/compiler/Transforms/Interpreter/BUILD b/iree/compiler/Transforms/Interpreter/BUILD
new file mode 100644
index 0000000..211c9d6
--- /dev/null
+++ b/iree/compiler/Transforms/Interpreter/BUILD
@@ -0,0 +1,42 @@
+# Transforms specific to the IREE interpreter.
+
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+cc_library(
+    name = "Interpreter",
+    srcs = [
+        "ExpandReductionsToOps.cpp",
+        "LegalizeInterpreterOps.cpp",
+        "LowerInterpreterDialect.cpp",
+        "LowerStdToInterpreterDialect.cpp",
+        "LowerToInterpreterDialect.cpp",
+        "LowerXLAToInterpreterDialect.cpp",
+        "MakeExecutableABI.cpp",
+    ],
+    hdrs = [
+        "Passes.h",
+        "Rewrites.h",
+    ],
+    deps = [
+        "//iree/compiler/IR",
+        "//iree/compiler/IR/Interpreter",
+        "//iree/compiler/Serialization",
+        "//iree/compiler/Transforms",
+        "//iree/compiler/Utils",
+        "//iree/schemas/bytecode:interpreter_bytecode_v0",
+        "//third_party/llvm/llvm:support",
+        "//third_party/llvm/llvm/projects/google_mlir:IR",
+        "//third_party/llvm/llvm/projects/google_mlir:Pass",
+        "//third_party/llvm/llvm/projects/google_mlir:StandardOps",
+        "//third_party/llvm/llvm/projects/google_mlir:Support",
+        "//third_party/llvm/llvm/projects/google_mlir:TransformUtils",
+        "//third_party/llvm/llvm/projects/google_mlir:Transforms",
+        "//third_party/tensorflow/compiler/mlir/xla:hlo",
+        "//third_party/tensorflow/compiler/mlir/xla:xla_legalize_to_standard",
+        "//third_party/tensorflow/compiler/mlir/xla:xla_lower_general_dot",
+    ],
+    alwayslink = 1,
+)
diff --git a/iree/compiler/Transforms/Interpreter/test/BUILD b/iree/compiler/Transforms/Interpreter/test/BUILD
new file mode 100644
index 0000000..42de132
--- /dev/null
+++ b/iree/compiler/Transforms/Interpreter/test/BUILD
@@ -0,0 +1,25 @@
+# Tests for lowering MLIR in various dialects to IREE interpreter bytecode.
+
+load("//third_party/llvm/build_defs:lit.bzl", "glob_lit_tests")
+
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+glob_lit_tests(
+    data = [":test_utilities"],
+    driver = "//iree/tools:run_lit.sh",
+    test_file_exts = ["mlir"],
+)
+
+# Bundle together all of the test utilities that are used by tests.
+filegroup(
+    name = "test_utilities",
+    testonly = True,
+    data = [
+        "//iree/tools:iree-opt",
+        "//third_party/llvm/llvm:FileCheck",
+        "//third_party/llvm/llvm/projects/google_mlir:run_lit.sh",
+    ],
+)
diff --git a/iree/compiler/Transforms/Interpreter/test/xla/BUILD b/iree/compiler/Transforms/Interpreter/test/xla/BUILD
new file mode 100644
index 0000000..2cb81f4
--- /dev/null
+++ b/iree/compiler/Transforms/Interpreter/test/xla/BUILD
@@ -0,0 +1,26 @@
+# Tests specific to lowering XLA to IREE.
+
+load("//third_party/llvm/build_defs:lit.bzl", "glob_lit_tests")
+
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+glob_lit_tests(
+    data = [":test_utilities"],
+    driver = "//iree/tools:run_lit.sh",
+    test_file_exts = ["mlir"],
+)
+
+# Bundle together all of the test utilities that are used by tests.
+filegroup(
+    name = "test_utilities",
+    testonly = True,
+    data = [
+        "//iree/tools:iree-opt",
+        "//iree/tools:iree-run-mlir",
+        "//third_party/llvm/llvm:FileCheck",
+        "//third_party/llvm/llvm/projects/google_mlir:run_lit.sh",
+    ],
+)
diff --git a/iree/compiler/Transforms/Sequencer/BUILD b/iree/compiler/Transforms/Sequencer/BUILD
new file mode 100644
index 0000000..2626daf
--- /dev/null
+++ b/iree/compiler/Transforms/Sequencer/BUILD
@@ -0,0 +1,45 @@
+# Transforms specific to the IREE sequencer.
+
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+cc_library(
+    name = "Sequencer",
+    srcs = [
+        "AssignExecutableOrdinals.cpp",
+        "AssignExecutableWorkloadAttrs.cpp",
+        "FoldCompatibleDispatchRegions.cpp",
+        "IdentifyDispatchRegions.cpp",
+        "IdentifyReductionRegions.cpp",
+        "LowerSequencerDialect.cpp",
+        "LowerStdToSequencerDialect.cpp",
+        "LowerToSequencerDialect.cpp",
+        "LowerXLAToSequencerDialect.cpp",
+        "OutlineDispatchRegions.cpp",
+        "OutlineReductionRegions.cpp",
+        "RematerializeDispatchConstants.cpp",
+    ],
+    hdrs = [
+        "Passes.h",
+        "Rewrites.h",
+    ],
+    deps = [
+        "//iree/compiler/IR",
+        "//iree/compiler/IR/Sequencer",
+        "//iree/compiler/Transforms",
+        "//iree/compiler/Utils",
+        "//third_party/llvm/llvm:support",
+        "//third_party/llvm/llvm/projects/google_mlir:IR",
+        "//third_party/llvm/llvm/projects/google_mlir:Pass",
+        "//third_party/llvm/llvm/projects/google_mlir:StandardDialectRegistration",
+        "//third_party/llvm/llvm/projects/google_mlir:StandardOps",
+        "//third_party/llvm/llvm/projects/google_mlir:Support",
+        "//third_party/llvm/llvm/projects/google_mlir:TransformUtils",
+        "//third_party/llvm/llvm/projects/google_mlir:Transforms",
+        "//third_party/tensorflow/compiler/mlir/xla:hlo",
+        "//third_party/tensorflow/compiler/mlir/xla:xla_legalize_to_standard",
+        "//third_party/tensorflow/compiler/mlir/xla:xla_lower_general_dot",
+    ],
+)
diff --git a/iree/compiler/Transforms/Sequencer/test/BUILD b/iree/compiler/Transforms/Sequencer/test/BUILD
new file mode 100644
index 0000000..1b65127
--- /dev/null
+++ b/iree/compiler/Transforms/Sequencer/test/BUILD
@@ -0,0 +1,25 @@
+# Tests specific to the sequencer.
+
+load("//third_party/llvm/build_defs:lit.bzl", "glob_lit_tests")
+
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+glob_lit_tests(
+    data = [":test_utilities"],
+    driver = "//iree/tools:run_lit.sh",
+    test_file_exts = ["mlir"],
+)
+
+# Bundle together all of the test utilities that are used by tests.
+filegroup(
+    name = "test_utilities",
+    testonly = True,
+    data = [
+        "//iree/tools:iree-opt",
+        "//third_party/llvm/llvm:FileCheck",
+        "//third_party/llvm/llvm/projects/google_mlir:run_lit.sh",
+    ],
+)
diff --git a/iree/compiler/Transforms/test/BUILD b/iree/compiler/Transforms/test/BUILD
new file mode 100644
index 0000000..b1a0fa0
--- /dev/null
+++ b/iree/compiler/Transforms/test/BUILD
@@ -0,0 +1,25 @@
+# Tests for common transforms.
+
+load("//third_party/llvm/build_defs:lit.bzl", "glob_lit_tests")
+
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+glob_lit_tests(
+    data = [":test_utilities"],
+    driver = "//iree/tools:run_lit.sh",
+    test_file_exts = ["mlir"],
+)
+
+# Bundle together all of the test utilities that are used by tests.
+filegroup(
+    name = "test_utilities",
+    testonly = True,
+    data = [
+        "//iree/tools:iree-opt",
+        "//third_party/llvm/llvm:FileCheck",
+        "//third_party/llvm/llvm/projects/google_mlir:run_lit.sh",
+    ],
+)
diff --git a/iree/compiler/Translation/BUILD b/iree/compiler/Translation/BUILD
new file mode 100644
index 0000000..2b86f73
--- /dev/null
+++ b/iree/compiler/Translation/BUILD
@@ -0,0 +1,4 @@
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
diff --git a/iree/compiler/Translation/Interpreter/BUILD b/iree/compiler/Translation/Interpreter/BUILD
new file mode 100644
index 0000000..069edb9
--- /dev/null
+++ b/iree/compiler/Translation/Interpreter/BUILD
@@ -0,0 +1,31 @@
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+cc_library(
+    name = "Interpreter",
+    srcs = ["InterpreterExecutableTranslation.cpp"],
+    hdrs = ["InterpreterExecutableTranslation.h"],
+    deps = [
+        "//iree/compiler/IR",
+        "//iree/compiler/IR/Interpreter",
+        "//iree/compiler/Serialization",
+        "//iree/compiler/Transforms",
+        "//iree/compiler/Transforms/Interpreter",
+        "//iree/compiler/Utils",
+        "//iree/schemas",
+        "//third_party/flatbuffers",
+        "//third_party/llvm/llvm:support",
+        "//third_party/llvm/llvm/projects/google_mlir:IR",
+        "//third_party/llvm/llvm/projects/google_mlir:Pass",
+        "//third_party/llvm/llvm/projects/google_mlir:StandardDialectRegistration",
+        "//third_party/llvm/llvm/projects/google_mlir:Support",
+        "//third_party/llvm/llvm/projects/google_mlir:Transforms",
+        "//third_party/llvm/llvm/projects/google_mlir:Translation",
+        "//third_party/tensorflow/compiler/mlir/xla:hlo",
+        "//third_party/tensorflow/compiler/mlir/xla:xla_dialect_registration",
+        "//third_party/tensorflow/compiler/mlir/xla:xla_legalize_to_standard",
+    ],
+    alwayslink = 1,
+)
diff --git a/iree/compiler/Translation/SPIRV/BUILD b/iree/compiler/Translation/SPIRV/BUILD
new file mode 100644
index 0000000..cb4ec3e
--- /dev/null
+++ b/iree/compiler/Translation/SPIRV/BUILD
@@ -0,0 +1,48 @@
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+cc_library(
+    name = "SPIRV",
+    srcs = [
+        "AffineExprCodegen.h",
+        "IREEIndexComputation.cpp",
+        "IREEToSPIRV.cpp",
+        "IREEToSPIRVPass.cpp",
+        "IndexComputation.cpp",
+        "SPIRVExecutableTranslation.cpp",
+        "SPIRVLowering.cpp",
+        "SPIRVLowering.h",
+        "XLAIndexPropagation.cpp",
+    ],
+    hdrs = [
+        "IREEIndexComputation.h",
+        "IREEToSPIRV.h",
+        "IREEToSPIRVPass.h",
+        "IndexComputation.h",
+        "SPIRVExecutableTranslation.h",
+        "XLAIndexPropagation.h",
+    ],
+    deps = [
+        "//iree/compiler/IR",
+        "//iree/compiler/Translation/SPIRV/Kernels",
+        "//iree/compiler/Utils",
+        "//iree/schemas",
+        "//iree/schemas:spirv_executable_def_cc_fbs",
+        "//third_party/flatbuffers",
+        "//third_party/llvm/llvm:support",
+        "//third_party/llvm/llvm/projects/google_mlir:IR",
+        "//third_party/llvm/llvm/projects/google_mlir:Pass",
+        "//third_party/llvm/llvm/projects/google_mlir:SPIRVDialect",
+        "//third_party/llvm/llvm/projects/google_mlir:SPIRVDialectRegistration",
+        "//third_party/llvm/llvm/projects/google_mlir:SPIRVSerialization",
+        "//third_party/llvm/llvm/projects/google_mlir:StandardDialectRegistration",
+        "//third_party/llvm/llvm/projects/google_mlir:StandardOps",
+        "//third_party/llvm/llvm/projects/google_mlir:Support",
+        "//third_party/llvm/llvm/projects/google_mlir:Transforms",
+        "//third_party/llvm/llvm/projects/google_mlir:Translation",
+        "//third_party/tensorflow/compiler/mlir/xla:hlo",
+    ],
+    alwayslink = 1,
+)
diff --git a/iree/compiler/Translation/SPIRV/Kernels/BUILD b/iree/compiler/Translation/SPIRV/Kernels/BUILD
new file mode 100644
index 0000000..7e1c3fc
--- /dev/null
+++ b/iree/compiler/Translation/SPIRV/Kernels/BUILD
@@ -0,0 +1,24 @@
+# A collection of hand-written kernels for special ops that cannot (yet) be
+# generated by the compiler.
+#
+# This is a grab bag right now during bringup with little structure. If you
+# have ideas on how to make this better please ping us :)
+#
+# To use the kernels add a dep against this package and use
+# mlir::iree_compiler::spirv::Kernels_create() to get the FileToc. Kernels
+# will have filenames matching their original with the extension changed to
+# '.spv' (for example 'add.comp' -> 'add.spv').
+
+load(":spirv_utils.bzl", "spirv_kernel_cc_library")
+
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+spirv_kernel_cc_library(
+    name = "Kernels",
+    srcs = [
+        "matmul.comp",
+    ],
+)
diff --git a/iree/compiler/Translation/SPIRV/Kernels/spirv_utils.bzl b/iree/compiler/Translation/SPIRV/Kernels/spirv_utils.bzl
new file mode 100644
index 0000000..e177a49
--- /dev/null
+++ b/iree/compiler/Translation/SPIRV/Kernels/spirv_utils.bzl
@@ -0,0 +1,35 @@
+"""Utilities for handling hand-written SPIR-V files."""
+
+load("//third_party/glslang:build_defs.bzl", "glsl_vulkan")
+load("//tools/build_defs/cc:cc_embed_data.bzl", "cc_embed_data")
+
+def spirv_kernel_cc_library(name, srcs):
+    """Compiles GLSL files into SPIR-V binaries and embeds them in a cc_library.
+
+    Args:
+        name: cc_library name to depend on.
+        srcs: a list of GLSL source files.
+    """
+    spv_files = []
+    for src in srcs:
+        spv_name = src.split(".")[-2]
+        glsl_vulkan(
+            name = spv_name,
+            srcs = [src],
+        )
+        spv_files.append(spv_name + ".spv")
+    native.filegroup(
+        name = name + "_files",
+        srcs = spv_files,
+    )
+    cc_embed_data(
+        name = name,
+        srcs = spv_files,
+        outs = [
+            name + ".cc",
+            name + ".h",
+        ],
+        embedopts = [
+            "--namespace=mlir::iree_compiler::spirv_kernels",
+        ],
+    )
diff --git a/iree/compiler/Translation/SPIRV/test/BUILD b/iree/compiler/Translation/SPIRV/test/BUILD
new file mode 100644
index 0000000..b1a0fa0
--- /dev/null
+++ b/iree/compiler/Translation/SPIRV/test/BUILD
@@ -0,0 +1,25 @@
+# Tests for common transforms.
+
+load("//third_party/llvm/build_defs:lit.bzl", "glob_lit_tests")
+
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+glob_lit_tests(
+    data = [":test_utilities"],
+    driver = "//iree/tools:run_lit.sh",
+    test_file_exts = ["mlir"],
+)
+
+# Bundle together all of the test utilities that are used by tests.
+filegroup(
+    name = "test_utilities",
+    testonly = True,
+    data = [
+        "//iree/tools:iree-opt",
+        "//third_party/llvm/llvm:FileCheck",
+        "//third_party/llvm/llvm/projects/google_mlir:run_lit.sh",
+    ],
+)
diff --git a/iree/compiler/Translation/Sequencer/BUILD b/iree/compiler/Translation/Sequencer/BUILD
new file mode 100644
index 0000000..9143a50
--- /dev/null
+++ b/iree/compiler/Translation/Sequencer/BUILD
@@ -0,0 +1,33 @@
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+cc_library(
+    name = "Sequencer",
+    srcs = ["SequencerModuleTranslation.cpp"],
+    hdrs = ["SequencerModuleTranslation.h"],
+    deps = [
+        "//iree/base:status",
+        "//iree/compiler/IR",
+        "//iree/compiler/IR/Sequencer",
+        "//iree/compiler/Serialization",
+        "//iree/compiler/Transforms",
+        "//iree/compiler/Transforms/Sequencer",
+        "//iree/compiler/Utils",
+        "//iree/hal:executable_format",
+        "//iree/schemas",
+        "//third_party/flatbuffers",
+        "//third_party/llvm/llvm:support",
+        "//third_party/llvm/llvm/projects/google_mlir:IR",
+        "//third_party/llvm/llvm/projects/google_mlir:Pass",
+        "//third_party/llvm/llvm/projects/google_mlir:StandardDialectRegistration",
+        "//third_party/llvm/llvm/projects/google_mlir:Support",
+        "//third_party/llvm/llvm/projects/google_mlir:Transforms",
+        "//third_party/llvm/llvm/projects/google_mlir:Translation",
+        "//third_party/tensorflow/compiler/mlir/xla:hlo",
+        "//third_party/tensorflow/compiler/mlir/xla:xla_dialect_registration",
+        "//third_party/tensorflow/compiler/mlir/xla:xla_legalize_control_flow",
+    ],
+    alwayslink = 1,
+)
diff --git a/iree/compiler/Utils/BUILD b/iree/compiler/Utils/BUILD
new file mode 100644
index 0000000..1fb0e41
--- /dev/null
+++ b/iree/compiler/Utils/BUILD
@@ -0,0 +1,39 @@
+# Utilities for working with IREE MLIR types.
+
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+cc_library(
+    name = "Utils",
+    srcs = [
+        "DispatchUtils.cpp",
+        "MemRefUtils.cpp",
+        "ModuleUtils.cpp",
+        "OpCreationUtils.cpp",
+        "OpUtils.cpp",
+        "TranslationUtils.cpp",
+    ],
+    hdrs = [
+        "DispatchUtils.h",
+        "Macros.h",
+        "MemRefUtils.h",
+        "ModuleUtils.h",
+        "OpCreationUtils.h",
+        "OpUtils.h",
+        "TranslationUtils.h",
+    ],
+    deps = [
+        "//iree/compiler/IR",
+        "//iree/schemas",
+        "//third_party/llvm/llvm:support",
+        "//third_party/llvm/llvm/projects/google_mlir:IR",
+        "//third_party/llvm/llvm/projects/google_mlir:Pass",
+        "//third_party/llvm/llvm/projects/google_mlir:StandardOps",
+        "//third_party/llvm/llvm/projects/google_mlir:Support",
+        "//third_party/llvm/llvm/projects/google_mlir:TransformUtils",
+        "//third_party/llvm/llvm/projects/google_mlir:Transforms",
+        "//third_party/tensorflow/compiler/mlir/xla:hlo",
+    ],
+)
diff --git a/iree/hal/BUILD b/iree/hal/BUILD
new file mode 100644
index 0000000..b8ed6cb
--- /dev/null
+++ b/iree/hal/BUILD
@@ -0,0 +1,372 @@
+# HAL (Hardware Abstraction Layer).
+# Subdirectories contain implementations for different hardware and
+# software backends.
+
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+cc_library(
+    name = "allocator",
+    srcs = ["allocator.cc"],
+    hdrs = ["allocator.h"],
+    deps = [
+        ":buffer",
+        "//iree/base:source_location",
+        "//iree/base:status",
+        "//iree/base:tracing",
+        "//third_party/absl/base:core_headers",
+        "//third_party/absl/types:span",
+    ],
+)
+
+cc_library(
+    name = "api",
+    srcs = ["api.cc"],
+    hdrs = ["api.h"],
+    visibility = ["//visibility:public"],
+    deps = [
+        ":api_hdrs",
+        ":buffer",
+        ":buffer_view",
+        ":fence",
+        ":semaphore",
+        "//iree/base:api_hdrs",
+        "//iree/base:api_util",
+        "//iree/base:shape",
+        "//iree/base:tracing",
+    ],
+)
+
+cc_library(
+    name = "api_hdrs",
+    hdrs = ["api.h"],
+    deps = [
+        "//iree/base:api_hdrs",
+    ],
+)
+
+cc_library(
+    name = "buffer",
+    srcs = ["buffer.cc"],
+    hdrs = ["buffer.h"],
+    deps = [
+        ":resource",
+        "//iree/base:bitfield",
+        "//iree/base:logging",
+        "//iree/base:source_location",
+        "//iree/base:status",
+        "//third_party/absl/base:core_headers",
+        "//third_party/absl/strings",
+        "//third_party/absl/types:span",
+        "//third_party/absl/types:variant",
+    ],
+)
+
+cc_test(
+    name = "buffer_test",
+    srcs = [
+        "buffer_mapping_test.cc",
+        "buffer_test.cc",
+    ],
+    deps = [
+        ":buffer",
+        ":heap_buffer",
+        "//iree/base:status",
+        "//iree/base:status_matchers",
+        "//testing/base/public:gunit_main",
+        "//third_party/absl/base:core_headers",
+        "//third_party/absl/types:span",
+    ],
+)
+
+cc_library(
+    name = "buffer_view",
+    srcs = ["buffer_view.cc"],
+    hdrs = ["buffer_view.h"],
+    deps = [
+        ":buffer",
+        "//iree/base:shape",
+        "//iree/base:source_location",
+        "//iree/base:status",
+        "//third_party/absl/container:inlined_vector",
+        "//third_party/absl/strings",
+    ],
+)
+
+cc_test(
+    name = "buffer_view_test",
+    srcs = [
+        "buffer_view_test.cc",
+    ],
+    deps = [
+        ":buffer",
+        ":buffer_view",
+        ":heap_buffer",
+        "//iree/base:status",
+        "//iree/base:status_matchers",
+        "//testing/base/public:gunit_main",
+    ],
+)
+
+cc_library(
+    name = "buffer_view_string_util",
+    srcs = ["buffer_view_string_util.cc"],
+    hdrs = ["buffer_view_string_util.h"],
+    deps = [
+        ":allocator",
+        ":buffer_view",
+        ":heap_buffer",
+        "//iree/base:source_location",
+        "//iree/base:status",
+        "//third_party/absl/strings",
+        "//third_party/absl/types:optional",
+    ],
+)
+
+cc_test(
+    name = "buffer_view_string_util_test",
+    srcs = ["buffer_view_string_util_test.cc"],
+    deps = [
+        ":buffer_view_string_util",
+        "//iree/base:status",
+        "//iree/base:status_matchers",
+        "//testing/base/public:gunit_main",
+    ],
+)
+
+cc_library(
+    name = "command_buffer",
+    srcs = ["command_buffer.cc"],
+    hdrs = ["command_buffer.h"],
+    deps = [
+        ":allocator",
+        ":buffer",
+        ":buffer_view",
+        ":event",
+        ":executable",
+        ":resource",
+        "//iree/base:bitfield",
+        "//iree/base:shape",
+        "//iree/base:status",
+        "//third_party/absl/base:core_headers",
+    ],
+)
+
+cc_library(
+    name = "command_buffer_validation",
+    srcs = ["command_buffer_validation.cc"],
+    hdrs = ["command_buffer_validation.h"],
+    deps = [
+        ":command_buffer",
+        "//iree/base:logging",
+        "//iree/base:status",
+    ],
+)
+
+cc_library(
+    name = "command_queue",
+    hdrs = ["command_queue.h"],
+    deps = [
+        ":command_buffer",
+        ":fence",
+        ":semaphore",
+        "//iree/base:bitfield",
+        "//iree/base:status",
+        "//iree/base:time",
+        "//third_party/absl/time",
+        "//third_party/absl/types:span",
+    ],
+)
+
+cc_library(
+    name = "deferred_buffer",
+    srcs = ["deferred_buffer.cc"],
+    hdrs = ["deferred_buffer.h"],
+    deps = [
+        ":allocator",
+        ":buffer",
+        "//iree/base:status",
+    ],
+)
+
+cc_test(
+    name = "deferred_buffer_test",
+    srcs = ["deferred_buffer_test.cc"],
+    deps = [
+        ":deferred_buffer",
+        ":heap_buffer",
+        "//iree/base:status_matchers",
+        "//iree/hal/testing:mock_allocator",
+        "//testing/base/public:gunit_main",
+        "//third_party/absl/memory",
+    ],
+)
+
+cc_library(
+    name = "device",
+    hdrs = ["device.h"],
+    deps = [
+        ":allocator",
+        ":buffer",
+        ":command_queue",
+        ":device_info",
+        ":event",
+        ":executable_cache",
+        ":semaphore",
+        "//iree/base:status",
+        "//iree/base:time",
+        "//third_party/absl/time",
+    ],
+)
+
+cc_library(
+    name = "device_info",
+    hdrs = ["device_info.h"],
+    deps = [
+        "//iree/base:bitfield",
+        "//third_party/absl/base:core_headers",
+    ],
+)
+
+cc_library(
+    name = "device_manager",
+    srcs = ["device_manager.cc"],
+    hdrs = ["device_manager.h"],
+    deps = [
+        ":allocator",
+        ":buffer",
+        ":command_queue",
+        ":device",
+        ":device_placement",
+        ":executable_format",
+        ":fence",
+        ":heap_buffer",
+        "//iree/base:source_location",
+        "//iree/base:status",
+        "//iree/base:time",
+        "//iree/base:tracing",
+        "//third_party/absl/synchronization",
+        "//third_party/absl/types:span",
+    ],
+)
+
+cc_library(
+    name = "device_placement",
+    hdrs = ["device_placement.h"],
+)
+
+cc_library(
+    name = "driver",
+    hdrs = ["driver.h"],
+    deps = [
+        ":device",
+        ":device_info",
+        "//iree/base:status",
+    ],
+)
+
+cc_library(
+    name = "driver_registry",
+    srcs = ["driver_registry.cc"],
+    hdrs = ["driver_registry.h"],
+    deps = [
+        ":driver",
+        "//iree/base:init",
+        "//iree/base:status",
+        "//third_party/absl/base:core_headers",
+        "//third_party/absl/synchronization",
+    ],
+)
+
+cc_library(
+    name = "event",
+    hdrs = ["event.h"],
+    deps = [
+        ":resource",
+    ],
+)
+
+cc_library(
+    name = "executable",
+    hdrs = ["executable.h"],
+    deps = [":resource"],
+)
+
+cc_library(
+    name = "executable_cache",
+    srcs = ["executable_cache.cc"],
+    hdrs = ["executable_cache.h"],
+    deps = [
+        ":executable",
+        ":executable_format",
+        ":executable_spec",
+        "//iree/base:bitfield",
+        "//iree/base:ref_ptr",
+        "//iree/base:status",
+    ],
+)
+
+cc_library(
+    name = "executable_format",
+    hdrs = ["executable_format.h"],
+    deps = [
+        "//third_party/absl/base:core_headers",
+    ],
+)
+
+cc_library(
+    name = "executable_spec",
+    hdrs = ["executable_spec.h"],
+    deps = [
+        ":executable_format",
+        "//third_party/absl/types:span",
+    ],
+)
+
+cc_library(
+    name = "fence",
+    hdrs = ["fence.h"],
+    deps = [
+        ":resource",
+        "//iree/base:status",
+    ],
+)
+
+cc_library(
+    name = "heap_buffer",
+    srcs = ["heap_buffer.cc"],
+    hdrs = ["heap_buffer.h"],
+    deps = [
+        ":allocator",
+        ":buffer",
+        "//iree/base:source_location",
+        "//iree/base:status",
+        "//iree/base:tracing",
+        "//iree/hal/host:host_buffer",
+        "//third_party/absl/base:core_headers",
+    ],
+)
+
+cc_library(
+    name = "resource",
+    hdrs = ["resource.h"],
+    deps = [
+        "//iree/base:ref_ptr",
+    ],
+)
+
+cc_library(
+    name = "semaphore",
+    hdrs = ["semaphore.h"],
+    deps = [
+        ":resource",
+        "//third_party/absl/types:variant",
+    ],
+)
+
+cc_library(
+    name = "stack_trace",
+    hdrs = ["stack_trace.h"],
+)
diff --git a/iree/hal/host/BUILD b/iree/hal/host/BUILD
new file mode 100644
index 0000000..415eea7
--- /dev/null
+++ b/iree/hal/host/BUILD
@@ -0,0 +1,155 @@
+# Default implementations for HAL types that use the host resources.
+# These are generally just wrappers around host heap memory and host threads.
+
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+cc_library(
+    name = "async_command_queue",
+    srcs = ["async_command_queue.cc"],
+    hdrs = ["async_command_queue.h"],
+    deps = [
+        ":host_submission_queue",
+        "//iree/base:status",
+        "//iree/base:tracing",
+        "//iree/hal:command_queue",
+        "//iree/hal:fence",
+        "//third_party/absl/base:core_headers",
+        "//third_party/absl/synchronization",
+    ],
+)
+
+cc_test(
+    name = "async_command_queue_test",
+    srcs = ["async_command_queue_test.cc"],
+    deps = [
+        ":async_command_queue",
+        ":host_submission_queue",
+        "//iree/base:status",
+        "//iree/base:status_matchers",
+        "//iree/base:time",
+        "//iree/hal:command_queue",
+        "//iree/hal/testing:mock_command_buffer",
+        "//iree/hal/testing:mock_command_queue",
+        "//testing/base/public:gunit_main",
+        "//third_party/absl/memory",
+        "//third_party/absl/time",
+    ],
+)
+
+cc_library(
+    name = "host_buffer",
+    srcs = ["host_buffer.cc"],
+    hdrs = ["host_buffer.h"],
+    deps = [
+        "//iree/base:logging",
+        "//iree/base:source_location",
+        "//iree/base:status",
+        "//iree/hal:buffer",
+        "//third_party/absl/base:core_headers",
+    ],
+)
+
+cc_library(
+    name = "host_event",
+    srcs = ["host_event.cc"],
+    hdrs = ["host_event.h"],
+    deps = [
+        "//iree/hal:event",
+    ],
+)
+
+cc_library(
+    name = "host_fence",
+    srcs = ["host_fence.cc"],
+    hdrs = ["host_fence.h"],
+    deps = [
+        "//iree/base:status",
+        "//iree/base:tracing",
+        "//iree/hal:fence",
+        "//third_party/absl/base:core_headers",
+        "//third_party/absl/container:inlined_vector",
+        "//third_party/absl/synchronization",
+        "//third_party/absl/types:span",
+    ],
+)
+
+cc_test(
+    name = "host_fence_test",
+    srcs = ["host_fence_test.cc"],
+    deps = [
+        ":host_fence",
+        "//iree/base:status",
+        "//iree/base:status_matchers",
+        "//testing/base/public:gunit_main",
+        "//third_party/absl/time",
+    ],
+)
+
+cc_library(
+    name = "host_local_allocator",
+    srcs = ["host_local_allocator.cc"],
+    hdrs = ["host_local_allocator.h"],
+    deps = [
+        ":host_buffer",
+        "//iree/base:source_location",
+        "//iree/base:status",
+        "//iree/base:tracing",
+        "//iree/hal:allocator",
+        "//iree/hal:buffer",
+    ],
+)
+
+cc_library(
+    name = "host_local_command_processor",
+    srcs = ["host_local_command_processor.cc"],
+    hdrs = ["host_local_command_processor.h"],
+    deps = [
+        "//iree/base:source_location",
+        "//iree/base:status",
+        "//iree/base:tracing",
+        "//iree/hal:command_buffer",
+    ],
+)
+
+cc_library(
+    name = "host_submission_queue",
+    srcs = ["host_submission_queue.cc"],
+    hdrs = ["host_submission_queue.h"],
+    deps = [
+        ":host_fence",
+        "//iree/base:intrusive_list",
+        "//iree/base:status",
+        "//iree/base:tracing",
+        "//iree/hal:command_queue",
+        "//iree/hal:fence",
+        "//iree/hal:semaphore",
+        "//third_party/absl/base:core_headers",
+        "//third_party/absl/container:inlined_vector",
+        "//third_party/absl/synchronization",
+    ],
+)
+
+cc_test(
+    name = "host_submission_queue_test",
+    srcs = ["host_submission_queue_test.cc"],
+    deps = [
+        ":host_submission_queue",
+        "//testing/base/public:gunit_main",
+    ],
+)
+
+cc_library(
+    name = "inproc_command_buffer",
+    srcs = ["inproc_command_buffer.cc"],
+    hdrs = ["inproc_command_buffer.h"],
+    deps = [
+        "//iree/base:arena",
+        "//iree/base:intrusive_list",
+        "//iree/base:status",
+        "//iree/base:tracing",
+        "//iree/hal:command_buffer",
+    ],
+)
diff --git a/iree/hal/interpreter/BUILD b/iree/hal/interpreter/BUILD
new file mode 100644
index 0000000..7cede2c
--- /dev/null
+++ b/iree/hal/interpreter/BUILD
@@ -0,0 +1,189 @@
+# HAL implementation running on the CPU using the IREE bytecode.
+
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+cc_library(
+    name = "bytecode_cache",
+    srcs = ["bytecode_cache.cc"],
+    hdrs = ["bytecode_cache.h"],
+    deps = [
+        ":bytecode_executable",
+        "//iree/base:source_location",
+        "//iree/base:status",
+        "//iree/base:tracing",
+        "//iree/hal:allocator",
+        "//iree/hal:executable",
+        "//iree/hal:executable_cache",
+        "//iree/hal:executable_format",
+    ],
+)
+
+cc_library(
+    name = "bytecode_dispatch",
+    srcs = [
+        "bytecode_dispatch.cc",
+        "bytecode_dispatch_conversion.h",
+        "bytecode_dispatch_util.cc",
+        "bytecode_dispatch_util.h",
+    ],
+    hdrs = ["bytecode_dispatch.h"],
+    deps = [
+        ":bytecode_kernels",
+        "//iree/base:logging",
+        "//iree/base:memory",
+        "//iree/base:status",
+        "//iree/hal:allocator",
+        "//iree/hal:buffer_view",
+        "//iree/hal:heap_buffer",
+        "//iree/schemas/bytecode:interpreter_bytecode_v0",
+        "//iree/vm:bytecode_reader",
+        "//iree/vm:bytecode_tables_interpreter",
+        "//iree/vm:bytecode_util",
+        "//iree/vm:function",
+        "//iree/vm:opcode_info",
+        "//iree/vm:stack",
+        "//iree/vm:type",
+        "//third_party/absl/base:core_headers",
+        "//third_party/absl/container:inlined_vector",
+        "//third_party/absl/types:span",
+    ],
+)
+
+cc_library(
+    name = "bytecode_executable",
+    srcs = ["bytecode_executable.cc"],
+    hdrs = ["bytecode_executable.h"],
+    deps = [
+        ":interpreter_context",
+        "//iree/base:status",
+        "//iree/hal:allocator",
+        "//iree/hal:executable",
+        "//iree/hal:executable_spec",
+        "//iree/vm:bytecode_tables_interpreter",
+        "//iree/vm:bytecode_validator",
+        "//iree/vm:context",
+        "//iree/vm:module",
+        "//iree/vm:module_printer",
+        "//third_party/absl/types:span",
+    ],
+)
+
+cc_library(
+    name = "bytecode_kernels",
+    hdrs = ["bytecode_kernels.h"],
+    textual_hdrs = [
+        # TODO(benvanik): SIMD variants.
+        "bytecode_kernels_generic.h",
+        "bytecode_kernels_ruy.h",
+    ],
+    deps = [
+        "//iree/base:shape",
+        "//iree/base:status",
+        "//iree/hal:buffer_view",
+        "//third_party/absl/algorithm",
+        "//third_party/absl/base:core_headers",
+        "//third_party/absl/container:flat_hash_set",
+        "//third_party/absl/container:inlined_vector",
+        "//third_party/absl/memory",
+        "//third_party/absl/types:span",
+        "//third_party/tensorflow/lite/experimental/ruy",
+        "//third_party/tensorflow/lite/experimental/ruy:context",
+    ],
+)
+
+cc_test(
+    name = "bytecode_kernels_test",
+    srcs = ["bytecode_kernels_test.cc"],
+    deps = [
+        ":bytecode_kernels",
+        "//iree/base:memory",
+        "//iree/base:status_matchers",
+        "//testing/base/public:gunit_main",
+    ],
+)
+
+cc_library(
+    name = "interpreter_command_processor",
+    srcs = ["interpreter_command_processor.cc"],
+    hdrs = ["interpreter_command_processor.h"],
+    deps = [
+        ":bytecode_executable",
+        "//iree/base:source_location",
+        "//iree/base:status",
+        "//iree/base:tracing",
+        "//iree/hal:buffer_view",
+        "//iree/hal/host:host_local_command_processor",
+        "//third_party/absl/container:inlined_vector",
+        "//third_party/absl/types:span",
+    ],
+)
+
+cc_library(
+    name = "interpreter_context",
+    srcs = ["interpreter_context.cc"],
+    hdrs = ["interpreter_context.h"],
+    deps = [
+        ":bytecode_dispatch",
+        ":bytecode_kernels",
+        "//iree/base:flatbuffer_util",
+        "//iree/base:status",
+        "//iree/hal:allocator",
+        "//iree/hal:buffer_view",
+        "//iree/vm:context",
+        "//iree/vm:function",
+        "//iree/vm:stack",
+        "//third_party/absl/types:span",
+    ],
+)
+
+cc_library(
+    name = "interpreter_device",
+    srcs = ["interpreter_device.cc"],
+    hdrs = ["interpreter_device.h"],
+    deps = [
+        ":bytecode_cache",
+        ":bytecode_kernels",
+        ":interpreter_command_processor",
+        "//iree/base:memory",
+        "//iree/base:status",
+        "//iree/base:tracing",
+        "//iree/hal:command_buffer_validation",
+        "//iree/hal:command_queue",
+        "//iree/hal:device",
+        "//iree/hal:fence",
+        "//iree/hal/host:async_command_queue",
+        "//iree/hal/host:host_event",
+        "//iree/hal/host:host_local_allocator",
+        "//iree/hal/host:host_submission_queue",
+        "//iree/hal/host:inproc_command_buffer",
+        "//third_party/absl/container:inlined_vector",
+        "//third_party/absl/memory",
+        "//third_party/absl/types:span",
+    ],
+)
+
+cc_library(
+    name = "interpreter_driver",
+    srcs = ["interpreter_driver.cc"],
+    hdrs = ["interpreter_driver.h"],
+    deps = [
+        ":interpreter_device",
+        "//iree/hal:device_info",
+        "//iree/hal:driver",
+    ],
+)
+
+cc_library(
+    name = "interpreter_driver_module",
+    srcs = ["interpreter_driver_module.cc"],
+    deps = [
+        ":interpreter_driver",
+        "//iree/base:init",
+        "//iree/base:status",
+        "//iree/hal:driver_registry",
+    ],
+    alwayslink = 1,
+)
diff --git a/iree/hal/testing/BUILD b/iree/hal/testing/BUILD
new file mode 100644
index 0000000..1adc7e0
--- /dev/null
+++ b/iree/hal/testing/BUILD
@@ -0,0 +1,36 @@
+# Test utilities for HAL-specific code.
+
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+cc_library(
+    name = "mock_allocator",
+    testonly = True,
+    hdrs = ["mock_allocator.h"],
+    deps = [
+        "//iree/hal:allocator",
+        "//testing/base/public:gunit_for_library_testonly",
+    ],
+)
+
+cc_library(
+    name = "mock_command_buffer",
+    testonly = True,
+    hdrs = ["mock_command_buffer.h"],
+    deps = [
+        "//iree/hal:command_buffer",
+        "//testing/base/public:gunit_for_library_testonly",
+    ],
+)
+
+cc_library(
+    name = "mock_command_queue",
+    testonly = True,
+    hdrs = ["mock_command_queue.h"],
+    deps = [
+        "//iree/hal:command_queue",
+        "//testing/base/public:gunit_for_library_testonly",
+    ],
+)
diff --git a/iree/hal/vulkan/BUILD b/iree/hal/vulkan/BUILD
new file mode 100644
index 0000000..fc0beae
--- /dev/null
+++ b/iree/hal/vulkan/BUILD
@@ -0,0 +1,341 @@
+# HAL implementation using Vulkan and (likely) SPIR-V executables.
+
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+cc_library(
+    name = "debug_reporter",
+    srcs = ["debug_reporter.cc"],
+    hdrs = ["debug_reporter.h"],
+    deps = [
+        ":dynamic_symbols",
+        ":status_util",
+        "//iree/base:status",
+        "//iree/base:tracing",
+        "//third_party/vulkan_headers:vulkan_headers_no_prototypes",
+    ],
+)
+
+cc_library(
+    name = "descriptor_pool_cache",
+    srcs = ["descriptor_pool_cache.cc"],
+    hdrs = ["descriptor_pool_cache.h"],
+    deps = [
+        ":dynamic_symbols",
+        ":handle_util",
+        ":status_util",
+        "//iree/base:ref_ptr",
+        "//iree/base:status",
+        "//iree/base:tracing",
+    ],
+)
+
+cc_library(
+    name = "descriptor_set_arena",
+    srcs = ["descriptor_set_arena.cc"],
+    hdrs = ["descriptor_set_arena.h"],
+    deps = [
+        ":descriptor_pool_cache",
+        ":pipeline_executable",
+        ":status_util",
+        ":vma_allocator",
+        "//iree/base:arena",
+        "//iree/base:math",
+        "//iree/base:status",
+        "//iree/base:tracing",
+        "//iree/hal:command_buffer",
+    ],
+)
+
+cc_library(
+    name = "direct_command_buffer",
+    srcs = ["direct_command_buffer.cc"],
+    hdrs = ["direct_command_buffer.h"],
+    deps = [
+        ":descriptor_pool_cache",
+        ":descriptor_set_arena",
+        ":dynamic_symbols",
+        ":handle_util",
+        ":native_event",
+        ":pipeline_executable",
+        ":status_util",
+        ":vma_allocator",
+        "//iree/base:math",
+        "//iree/base:source_location",
+        "//iree/base:status",
+        "//iree/base:tracing",
+        "//iree/hal:command_buffer",
+        "//third_party/absl/base:core_headers",
+        "//third_party/absl/container:inlined_vector",
+        "//third_party/absl/synchronization",
+        "//third_party/vulkan_headers:vulkan_headers_no_prototypes",
+    ],
+)
+
+cc_library(
+    name = "direct_command_queue",
+    srcs = ["direct_command_queue.cc"],
+    hdrs = ["direct_command_queue.h"],
+    deps = [
+        ":direct_command_buffer",
+        ":dynamic_symbols",
+        ":handle_util",
+        ":legacy_fence",
+        ":native_binary_semaphore",
+        ":status_util",
+        "//iree/base:arena",
+        "//iree/base:memory",
+        "//iree/base:source_location",
+        "//iree/base:status",
+        "//iree/base:tracing",
+        "//iree/hal:command_queue",
+        "//third_party/absl/base:core_headers",
+        "//third_party/absl/synchronization",
+        "//third_party/absl/time",
+        "//third_party/vulkan_headers:vulkan_headers_no_prototypes",
+    ],
+)
+
+cc_library(
+    name = "dynamic_symbols",
+    srcs = ["dynamic_symbols.cc"],
+    hdrs = [
+        "dynamic_symbol_tables.h",
+        "dynamic_symbols.h",
+    ],
+    linkopts = [
+        "-ldl",
+    ],
+    deps = [
+        "//third_party/absl/base:core_headers",
+        "//third_party/absl/memory",
+        "//iree/base:ref_ptr",
+        "//iree/base:target_platform",
+        "//iree/base:tracing",
+        "//third_party/vulkan_headers:vulkan_headers_no_prototypes",
+        "//iree/base:source_location",
+        "//iree/base:status",
+
+        # TODO(b/138220713): include when we run on TAP only (not locally/android).
+        # "//third_party/vulkan_loader",  # build-cleaner: keep
+    ],
+)
+
+cc_library(
+    name = "extensibility_util",
+    srcs = ["extensibility_util.cc"],
+    hdrs = ["extensibility_util.h"],
+    deps = [
+        ":dynamic_symbols",
+        ":status_util",
+        "//iree/base:status",
+        "//iree/base:tracing",
+        "//third_party/absl/types:span",
+        "//third_party/vulkan_headers:vulkan_headers_no_prototypes",
+    ],
+)
+
+cc_library(
+    name = "handle_util",
+    hdrs = ["handle_util.h"],
+    deps = [
+        ":dynamic_symbols",
+        ":extensibility_util",
+        "//iree/base:ref_ptr",
+        "//third_party/absl/synchronization",
+        "//third_party/absl/utility",
+        "//third_party/vulkan_headers:vulkan_headers_no_prototypes",
+    ],
+)
+
+cc_library(
+    name = "legacy_fence",
+    srcs = ["legacy_fence.cc"],
+    hdrs = ["legacy_fence.h"],
+    deps = [
+        ":handle_util",
+        ":status_util",
+        "//iree/base:intrusive_list",
+        "//iree/base:ref_ptr",
+        "//iree/base:source_location",
+        "//iree/base:status",
+        "//iree/base:tracing",
+        "//iree/hal:fence",
+        "//third_party/absl/base:core_headers",
+        "//third_party/absl/container:inlined_vector",
+        "//third_party/absl/synchronization",
+        "//third_party/absl/time",
+        "//third_party/vulkan_headers:vulkan_headers_no_prototypes",
+    ],
+)
+
+cc_library(
+    name = "native_binary_semaphore",
+    srcs = ["native_binary_semaphore.cc"],
+    hdrs = ["native_binary_semaphore.h"],
+    deps = [
+        ":handle_util",
+        "//iree/hal:semaphore",
+        "//third_party/vulkan_headers:vulkan_headers_no_prototypes",
+    ],
+)
+
+cc_library(
+    name = "native_event",
+    srcs = ["native_event.cc"],
+    hdrs = ["native_event.h"],
+    deps = [
+        ":handle_util",
+        "//iree/hal:event",
+        "//third_party/vulkan_headers:vulkan_headers_no_prototypes",
+    ],
+)
+
+cc_library(
+    name = "pipeline_cache",
+    srcs = ["pipeline_cache.cc"],
+    hdrs = ["pipeline_cache.h"],
+    deps = [
+        ":handle_util",
+        ":pipeline_executable",
+        ":status_util",
+        "//iree/base:source_location",
+        "//iree/base:status",
+        "//iree/base:tracing",
+        "//iree/hal:executable",
+        "//iree/hal:executable_cache",
+        "//iree/hal:executable_format",
+        "//iree/schemas:spirv_executable_def_cc_fbs",
+        "//third_party/absl/base:core_headers",
+        "//third_party/absl/container:inlined_vector",
+        "//third_party/absl/synchronization",
+        "//third_party/flatbuffers",
+        "//third_party/vulkan_headers:vulkan_headers_no_prototypes",
+    ],
+)
+
+cc_library(
+    name = "pipeline_executable",
+    srcs = ["pipeline_executable.cc"],
+    hdrs = ["pipeline_executable.h"],
+    deps = [
+        ":handle_util",
+        ":status_util",
+        "//iree/base:memory",
+        "//iree/base:source_location",
+        "//iree/base:status",
+        "//iree/base:tracing",
+        "//iree/hal:executable",
+        "//iree/hal:executable_cache",
+        "//iree/hal:executable_spec",
+        "//iree/schemas:spirv_executable_def_cc_fbs",
+        "//third_party/absl/container:inlined_vector",
+        "//third_party/vulkan_headers:vulkan_headers_no_prototypes",
+    ],
+)
+
+cc_library(
+    name = "status_util",
+    srcs = ["status_util.cc"],
+    hdrs = ["status_util.h"],
+    deps = [
+        "//iree/base:status",
+        "//third_party/vulkan_headers:vulkan_headers_no_prototypes",
+    ],
+)
+
+cc_library(
+    name = "vma_allocator",
+    srcs = [
+        "vma_allocator.cc",
+        "vma_buffer.cc",
+    ],
+    hdrs = [
+        "vma_allocator.h",
+        "vma_buffer.h",
+    ],
+    deps = [
+        ":dynamic_symbols",
+        ":handle_util",
+        ":status_util",
+        "//iree/base:source_location",
+        "//iree/base:status",
+        "//iree/base:tracing",
+        "//iree/hal:allocator",
+        "//iree/hal:buffer",
+        "//third_party/absl/flags:flag",
+        "//third_party/absl/memory",
+        "//third_party/vulkan_headers:vulkan_headers_no_prototypes",
+        "//third_party/vulkan_memory_allocator",
+    ],
+)
+
+cc_library(
+    name = "vulkan_device",
+    srcs = ["vulkan_device.cc"],
+    hdrs = ["vulkan_device.h"],
+    deps = [
+        ":descriptor_pool_cache",
+        ":direct_command_buffer",
+        ":direct_command_queue",
+        ":dynamic_symbols",
+        ":extensibility_util",
+        ":handle_util",
+        ":legacy_fence",
+        ":native_binary_semaphore",
+        ":native_event",
+        ":pipeline_cache",
+        ":status_util",
+        ":vma_allocator",
+        "//iree/base:memory",
+        "//iree/base:status",
+        "//iree/base:tracing",
+        "//iree/hal:allocator",
+        "//iree/hal:command_buffer_validation",
+        "//iree/hal:command_queue",
+        "//iree/hal:device",
+        "//iree/hal:fence",
+        "//third_party/absl/container:inlined_vector",
+        "//third_party/absl/memory",
+        "//third_party/absl/strings",
+        "//third_party/absl/synchronization",
+        "//third_party/absl/types:span",
+        "//third_party/vulkan_headers:vulkan_headers_no_prototypes",
+    ],
+)
+
+cc_library(
+    name = "vulkan_driver",
+    srcs = ["vulkan_driver.cc"],
+    hdrs = ["vulkan_driver.h"],
+    deps = [
+        ":debug_reporter",
+        ":dynamic_symbols",
+        ":extensibility_util",
+        ":status_util",
+        ":vulkan_device",
+        "//iree/base:status",
+        "//iree/base:tracing",
+        "//iree/hal:device_info",
+        "//iree/hal:driver",
+        "//third_party/absl/container:inlined_vector",
+        "//third_party/vulkan_headers:vulkan_headers_no_prototypes",
+    ],
+)
+
+cc_library(
+    name = "vulkan_driver_module",
+    srcs = ["vulkan_driver_module.cc"],
+    deps = [
+        ":dynamic_symbols",
+        ":vulkan_driver",
+        "//iree/base:init",
+        "//iree/base:status",
+        "//iree/base:tracing",
+        "//iree/hal:driver_registry",
+        "//third_party/absl/flags:flag",
+    ],
+    alwayslink = 1,
+)
diff --git a/iree/samples/hal/BUILD b/iree/samples/hal/BUILD
new file mode 100644
index 0000000..3388bb4
--- /dev/null
+++ b/iree/samples/hal/BUILD
@@ -0,0 +1,45 @@
+# Samples demonstrating use of the HAL API.
+# These do not rely on higher layers of the system (such as the VM or runtime).
+
+load("//iree/tools:compilation.bzl", "iree_module")
+
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+iree_module(
+    name = "simple_compute_test_module",
+    srcs = ["simple_compute_test.mlir"],
+    cc_namespace = "iree::hal::samples",
+)
+
+cc_test(
+    name = "simple_compute_test",
+    srcs = ["simple_compute_test.cc"],
+    data = [
+        # When building with --config=asan you must specify the following
+        # envvar when using Vulkan + a local Nvidia GPU:
+        #   LSAN_OPTIONS=suppressions=third_party/iree/tools/sanitizer_suppressions.txt
+        "//iree/tools:sanitizer_suppressions.txt",
+    ],
+    deps = [
+        ":simple_compute_test_module_cc",
+        "//testing/base/public:gunit_main",
+        "//third_party/absl/container:inlined_vector",
+        "//third_party/absl/strings",
+        "//third_party/absl/time",
+        "//iree/base:flatbuffer_util",
+        "//iree/base:status_matchers",
+        "//iree/hal:command_buffer",
+        "//iree/hal:command_queue",
+        "//iree/hal:driver_registry",
+        "//iree/schemas",
+        "//iree/base:status",
+
+        # These are the drivers we support running with and can produce
+        # executables for from the source MLIR.
+        "//iree/hal/interpreter:interpreter_driver_module",  # build-cleaner: keep
+        "//iree/hal/vulkan:vulkan_driver_module",  # build-cleaner: keep
+    ],
+)
diff --git a/iree/samples/vm/BUILD b/iree/samples/vm/BUILD
new file mode 100644
index 0000000..637b5fa
--- /dev/null
+++ b/iree/samples/vm/BUILD
@@ -0,0 +1,47 @@
+# Samples demonstrating use of the VM API.
+
+load("//iree/tools:compilation.bzl", "iree_module")
+
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+iree_module(
+    name = "simple_module_test_module",
+    srcs = ["simple_module_test.mlir"],
+    cc_namespace = "iree::vm::samples",
+)
+
+cc_test(
+    name = "simple_module_test",
+    srcs = ["simple_module_test.cc"],
+    data = [
+        # When building with --config=asan you must specify the following
+        # envvar when using Vulkan + a local Nvidia GPU:
+        #   LSAN_OPTIONS=suppressions=third_party/iree/tools/sanitizer_suppressions.txt
+        "//iree/tools:sanitizer_suppressions.txt",
+    ],
+    deps = [
+        ":simple_module_test_module_cc",
+        "//testing/base/public:gunit_main",
+        "//third_party/absl/strings",
+        "//iree/base:flatbuffer_util",
+        "//iree/base:status_matchers",
+        "//iree/hal:buffer_view",
+        "//iree/hal:command_buffer",
+        "//iree/hal:command_queue",
+        "//iree/hal:driver_registry",
+        "//iree/schemas",
+        "//iree/base:status",
+        "//iree/vm:fiber_state",
+        "//iree/vm:instance",
+        "//iree/vm:sequencer_context",
+
+        # These are the drivers we support running with and can produce
+        # executables for from the source MLIR.
+        "//iree/hal/interpreter:interpreter_driver_module",  # build-cleaner: keep
+        # TODO(benvanik): include SPIR-V.
+        # "//iree/hal/vulkan:vulkan_driver_module",  # build-cleaner: keep
+    ],
+)
diff --git a/iree/schemas/BUILD b/iree/schemas/BUILD
new file mode 100644
index 0000000..f518de5
--- /dev/null
+++ b/iree/schemas/BUILD
@@ -0,0 +1,268 @@
+load("//third_party/flatbuffers:build_defs.bzl", "flatbuffer_cc_library")
+load("//tools/build_defs/cc:cc_embed_data.bzl", "cc_embed_data")
+load("//tools/build_rules:build_test.bzl", "build_test")
+
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+FLATC_ARGS = [
+    # Preserve workspace-relative include paths in generated code.
+    "--keep-prefix",
+    # Use C++11 'enum class' for enums.
+    "--scoped-enums",
+    # Include reflection tables used for dumping debug representations.
+    "--reflect-names",
+    # Generate FooT types for unpack/pack support. Note that this should only
+    # be used in tooling as the code size/runtime overhead is non-trivial.
+    "--gen-object-api",
+]
+
+flatbuffer_cc_library(
+    name = "archive_def_cc_fbs",
+    srcs = ["archive_def.fbs"],
+    flatc_args = FLATC_ARGS,
+    gen_reflections = True,
+    includes = [
+        ":bytecode_def_cc_fbs_includes",
+        ":device_def_cc_fbs_includes",
+        ":device_group_def_cc_fbs_includes",
+        ":device_table_def_cc_fbs_includes",
+        ":executable_def_cc_fbs_includes",
+        ":executable_table_def_cc_fbs_includes",
+        ":function_def_cc_fbs_includes",
+        ":function_table_def_cc_fbs_includes",
+        ":module_def_cc_fbs_includes",
+        ":source_map_def_cc_fbs_includes",
+        ":type_def_cc_fbs_includes",
+    ],
+)
+
+flatbuffer_cc_library(
+    name = "bytecode_def_cc_fbs",
+    srcs = ["bytecode_def.fbs"],
+    flatc_args = FLATC_ARGS,
+    gen_reflections = True,
+    includes = [
+    ],
+)
+
+flatbuffer_cc_library(
+    name = "debug_service_cc_fbs",
+    srcs = ["debug_service.fbs"],
+    flatc_args = FLATC_ARGS,
+    gen_reflections = True,
+    includes = [
+        ":bytecode_def_cc_fbs_includes",
+        ":device_def_cc_fbs_includes",
+        ":device_group_def_cc_fbs_includes",
+        ":device_table_def_cc_fbs_includes",
+        ":executable_def_cc_fbs_includes",
+        ":executable_table_def_cc_fbs_includes",
+        ":function_def_cc_fbs_includes",
+        ":function_table_def_cc_fbs_includes",
+        ":module_def_cc_fbs_includes",
+        ":source_map_def_cc_fbs_includes",
+        ":type_def_cc_fbs_includes",
+    ],
+)
+
+flatbuffer_cc_library(
+    name = "device_def_cc_fbs",
+    srcs = ["device_def.fbs"],
+    flatc_args = FLATC_ARGS,
+    gen_reflections = True,
+    includes = [
+    ],
+)
+
+flatbuffer_cc_library(
+    name = "device_group_def_cc_fbs",
+    srcs = ["device_group_def.fbs"],
+    flatc_args = FLATC_ARGS,
+    gen_reflections = True,
+    includes = [
+    ],
+)
+
+flatbuffer_cc_library(
+    name = "device_table_def_cc_fbs",
+    srcs = ["device_table_def.fbs"],
+    flatc_args = FLATC_ARGS,
+    gen_reflections = True,
+    includes = [
+        ":device_def_cc_fbs_includes",
+        ":device_group_def_cc_fbs_includes",
+    ],
+)
+
+flatbuffer_cc_library(
+    name = "executable_def_cc_fbs",
+    srcs = ["executable_def.fbs"],
+    flatc_args = FLATC_ARGS,
+    gen_reflections = True,
+    includes = [
+    ],
+)
+
+flatbuffer_cc_library(
+    name = "executable_table_def_cc_fbs",
+    srcs = ["executable_table_def.fbs"],
+    flatc_args = FLATC_ARGS,
+    gen_reflections = True,
+    includes = [
+        ":executable_def_cc_fbs_includes",
+    ],
+)
+
+flatbuffer_cc_library(
+    name = "function_def_cc_fbs",
+    srcs = ["function_def.fbs"],
+    flatc_args = FLATC_ARGS,
+    gen_reflections = True,
+    includes = [
+        ":bytecode_def_cc_fbs_includes",
+        ":type_def_cc_fbs_includes",
+    ],
+)
+
+flatbuffer_cc_library(
+    name = "function_table_def_cc_fbs",
+    srcs = ["function_table_def.fbs"],
+    flatc_args = FLATC_ARGS,
+    gen_reflections = True,
+    includes = [
+        ":bytecode_def_cc_fbs_includes",
+        ":function_def_cc_fbs_includes",
+        ":type_def_cc_fbs_includes",
+    ],
+)
+
+flatbuffer_cc_library(
+    name = "module_def_cc_fbs",
+    srcs = ["module_def.fbs"],
+    flatc_args = FLATC_ARGS,
+    gen_reflections = True,
+    includes = [
+        ":bytecode_def_cc_fbs_includes",
+        ":device_def_cc_fbs_includes",
+        ":device_group_def_cc_fbs_includes",
+        ":device_table_def_cc_fbs_includes",
+        ":executable_def_cc_fbs_includes",
+        ":executable_table_def_cc_fbs_includes",
+        ":function_def_cc_fbs_includes",
+        ":function_table_def_cc_fbs_includes",
+        ":source_map_def_cc_fbs_includes",
+        ":type_def_cc_fbs_includes",
+    ],
+)
+
+flatbuffer_cc_library(
+    name = "source_map_def_cc_fbs",
+    srcs = ["source_map_def.fbs"],
+    flatc_args = FLATC_ARGS,
+    gen_reflections = True,
+    includes = [
+    ],
+)
+
+flatbuffer_cc_library(
+    name = "spirv_executable_def_cc_fbs",
+    srcs = ["spirv_executable_def.fbs"],
+    flatc_args = FLATC_ARGS,
+    gen_reflections = True,
+    includes = [
+    ],
+)
+
+flatbuffer_cc_library(
+    name = "type_def_cc_fbs",
+    srcs = ["type_def.fbs"],
+    flatc_args = FLATC_ARGS,
+    gen_reflections = True,
+    includes = [
+    ],
+)
+
+build_test(
+    name = "schema_build_test",
+    targets = [
+        ":archive_def_cc_fbs",
+        ":bytecode_def_cc_fbs",
+        ":debug_service_cc_fbs",
+        ":device_def_cc_fbs",
+        ":device_group_def_cc_fbs",
+        ":device_table_def_cc_fbs",
+        ":executable_def_cc_fbs",
+        ":executable_table_def_cc_fbs",
+        ":function_def_cc_fbs",
+        ":function_table_def_cc_fbs",
+        ":module_def_cc_fbs",
+        ":source_map_def_cc_fbs",
+        ":spirv_executable_def_cc_fbs",
+        ":type_def_cc_fbs",
+    ],
+)
+
+cc_library(
+    name = "schemas",
+    hdrs = [
+        ":archive_def_generated.h",
+        ":bytecode_def_generated.h",
+        ":debug_service_generated.h",
+        ":device_def_generated.h",
+        ":device_group_def_generated.h",
+        ":device_table_def_generated.h",
+        ":executable_def_generated.h",
+        ":executable_table_def_generated.h",
+        ":function_def_generated.h",
+        ":function_table_def_generated.h",
+        ":module_def_generated.h",
+        ":source_map_def_generated.h",
+        ":type_def_generated.h",
+    ],
+    deps = [
+        ":archive_def_cc_fbs",
+        ":bytecode_def_cc_fbs",
+        ":debug_service_cc_fbs",
+        ":device_def_cc_fbs",
+        ":device_group_def_cc_fbs",
+        ":device_table_def_cc_fbs",
+        ":executable_def_cc_fbs",
+        ":executable_table_def_cc_fbs",
+        ":function_def_cc_fbs",
+        ":function_table_def_cc_fbs",
+        ":module_def_cc_fbs",
+        ":source_map_def_cc_fbs",
+        ":spirv_executable_def_cc_fbs",
+        ":type_def_cc_fbs",
+        "//third_party/flatbuffers",
+    ],
+)
+
+cc_embed_data(
+    name = "reflection_data",
+    srcs = [
+        "archive_def.bfbs",
+        "bytecode_def.bfbs",
+        "debug_service.bfbs",
+        ":device_def.bfbs",
+        ":device_group_def.bfbs",
+        ":device_table_def.bfbs",
+        "executable_def.bfbs",
+        "executable_table_def.bfbs",
+        "function_def.bfbs",
+        "function_table_def.bfbs",
+        "module_def.bfbs",
+        "source_map_def.bfbs",
+        "spirv_executable_def.bfbs",
+        "type_def.bfbs",
+    ],
+    outs = [
+        "reflection_data.cc",
+        "reflection_data.h",
+        "reflection_data_bin.o",
+    ],
+    embedopts = ["--namespace=iree::schemas"],
+)
diff --git a/iree/schemas/bytecode/BUILD b/iree/schemas/bytecode/BUILD
new file mode 100644
index 0000000..7e421c4
--- /dev/null
+++ b/iree/schemas/bytecode/BUILD
@@ -0,0 +1,29 @@
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+cc_library(
+    name = "bytecode_v0",
+    hdrs = ["bytecode_v0.h"],
+    deps = [
+        "//iree/base:bitfield",
+        "//third_party/absl/base:core_headers",
+    ],
+)
+
+cc_library(
+    name = "interpreter_bytecode_v0",
+    hdrs = ["interpreter_bytecode_v0.h"],
+    deps = [
+        ":bytecode_v0",
+    ],
+)
+
+cc_library(
+    name = "sequencer_bytecode_v0",
+    hdrs = ["sequencer_bytecode_v0.h"],
+    deps = [
+        ":bytecode_v0",
+    ],
+)
diff --git a/iree/tools/BUILD b/iree/tools/BUILD
new file mode 100644
index 0000000..5cbfd21
--- /dev/null
+++ b/iree/tools/BUILD
@@ -0,0 +1,101 @@
+# Misc tools used to optimize, translate, and evaluate IREE.
+# Most of these are not designed to run on-device.
+
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+exports_files([
+    "run_lit.sh",
+    "sanitizer_suppressions.txt",
+])
+
+cc_binary(
+    name = "iree-opt",
+    deps = [
+        "//iree/compiler/Transforms",
+        "//iree/compiler/Transforms/Interpreter",
+        "//iree/compiler/Transforms/Sequencer",
+        "//iree/compiler/Translation/SPIRV",
+        "//third_party/llvm/llvm:support",
+        "//third_party/llvm/llvm/projects/google_mlir:AffineDialectRegistration",
+        "//third_party/llvm/llvm/projects/google_mlir:MlirOptLib",
+        "//third_party/llvm/llvm/projects/google_mlir:MlirOptMain",
+        "//third_party/llvm/llvm/projects/google_mlir:StandardDialectRegistration",
+        "//third_party/tensorflow/compiler/mlir/xla:hlo",
+        "//third_party/tensorflow/compiler/mlir/xla:xla_dialect_registration",
+    ],
+)
+
+cc_binary(
+    name = "iree-run-mlir",
+    srcs = ["run_mlir_main.cc"],
+    deps = [
+        "//third_party/absl/flags:flag",
+        "//third_party/absl/strings",
+        "//iree/base:source_location",
+        "//third_party/llvm/llvm:support",
+        "//third_party/llvm/llvm/projects/google_mlir:IR",
+        "//third_party/llvm/llvm/projects/google_mlir:Parser",
+        "//third_party/llvm/llvm/projects/google_mlir:Support",
+        "//iree/base:init",
+        "//iree/base:status",
+        "//iree/compiler/Translation/Sequencer",
+        "//iree/compiler/Translation/Interpreter",
+        "//iree/compiler/Translation/SPIRV",
+        "//iree/hal:buffer_view_string_util",
+        "//iree/hal:driver_registry",
+        "//iree/hal/interpreter:interpreter_driver_module",
+        # TODO(b/138220713): enable when we have swiftshader support.
+        # "//iree/hal/vulkan:vulkan_driver_module",
+        "//iree/schemas",
+        "//iree/vm:bytecode_tables_sequencer",
+        "//iree/vm:fiber_state",
+        "//iree/vm:instance",
+        "//iree/vm:module",
+        "//iree/vm:module_printer",
+        "//iree/vm:sequencer_context",
+        "//iree/vm/debug:debug_server_flags",
+    ],
+)
+
+cc_binary(
+    name = "iree-translate",
+    deps = [
+        "//iree/compiler/Translation/Interpreter",
+        "//iree/compiler/Translation/SPIRV",
+        "//iree/compiler/Translation/Sequencer",
+        "//third_party/llvm/llvm/projects/google_mlir:AffineDialectRegistration",
+        "//third_party/llvm/llvm/projects/google_mlir:StandardDialectRegistration",
+        "//third_party/llvm/llvm/projects/google_mlir:tools/mlir-translate/mlir-translate",
+        "//third_party/tensorflow/compiler/mlir/xla:xla_dialect_registration",
+    ],
+)
+
+cc_binary(
+    name = "run_module",
+    srcs = ["run_module_main.cc"],
+    deps = [
+        "//iree/base:file_io",
+        "//iree/base:file_path",
+        "//iree/base:init",
+        "//iree/base:source_location",
+        "//iree/base:status",
+        "//iree/hal:buffer_view_string_util",
+        "//iree/hal:driver_registry",
+        "//iree/hal/interpreter:interpreter_driver_module",
+        "//iree/schemas",
+        "//iree/vm:bytecode_printer",
+        "//iree/vm:bytecode_tables_sequencer",
+        "//iree/vm:fiber_state",
+        "//iree/vm:function",
+        "//iree/vm:instance",
+        "//iree/vm:module",
+        "//iree/vm:module_printer",
+        "//iree/vm:sequencer_context",
+        "//iree/vm/debug:debug_server_flags",
+        "//third_party/absl/flags:flag",
+        "//third_party/absl/strings",
+    ],
+)
diff --git a/iree/tools/compilation.bzl b/iree/tools/compilation.bzl
new file mode 100644
index 0000000..9c81f06
--- /dev/null
+++ b/iree/tools/compilation.bzl
@@ -0,0 +1,46 @@
+"""Rules for compiling IREE executables, modules, and archives."""
+
+load("//tools/build_defs/cc:cc_embed_data.bzl", "cc_embed_data")
+
+# TODO(benvanik): port to a full starlark rule, document, etc.
+def iree_module(
+        name,
+        srcs,
+        cc_namespace = None,
+        visibility = None):
+    native.genrule(
+        name = name,
+        srcs = srcs,
+        outs = [
+            "%s.emod" % (name),
+        ],
+        cmd = " && ".join([
+            " ".join([
+                "$(location //iree/tools:iree-translate)",
+                "-mlir-to-iree-module",
+                "--print-after-all",
+                "-o $(location %s.emod)" % (name),
+            ] + ["$(locations %s)" % (src) for src in srcs]),
+        ]),
+        tools = [
+            "//iree/tools:iree-translate",
+        ],
+        message = "Compiling IREE module %s..." % (name),
+        output_to_bindir = 1,
+    )
+
+    # Embed the module for use in C++. This avoids the need for file IO in
+    # tests and samples that would otherwise complicate execution/porting.
+    if cc_namespace:
+        cc_embed_data(
+            name = "%s_cc" % (name),
+            srcs = ["%s.emod" % (name)],
+            outs = [
+                # NOTE: we do not generate the .o as it is tricky on platforms
+                # like wasm.
+                "%s.cc" % (name),
+                "%s.h" % (name),
+            ],
+            embedopts = ["--namespace=%s" % (cc_namespace)],
+            visibility = visibility,
+        )
diff --git a/iree/tools/debugger/BUILD b/iree/tools/debugger/BUILD
new file mode 100644
index 0000000..ad4b809
--- /dev/null
+++ b/iree/tools/debugger/BUILD
@@ -0,0 +1,173 @@
+# IREE Debugger UIs.
+#
+# The main debugger UI can be used in standalone mode connected to a remote
+# host (via :debugger) or can be directly embedded into the IREE runtime to
+# allow for attaching (--iree_attach_debugger).
+#
+# By default the IREE runtime does not compile in debug support. To link it in
+# pass --define=IREE_DEBUG=1 to bazel builds of the runtime.
+
+load("//third_party/emscripten:split_transition_defs.bzl", "auto_wasm_binary")
+
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+alias(
+    name = "debugger",
+    actual = select({
+        "//tools/cc_target_os:emscripten": ":debug_app_emscripten_files",
+        "//conditions:default": ":debug_app_native",
+    }),
+)
+
+cc_library(
+    name = "debug_app_library",
+    srcs = ["debug_app.cc"],
+    hdrs = ["debug_app.h"],
+    deps = [
+        "//iree/base:source_location",
+        "//iree/base:status",
+        "//iree/schemas",
+        "//iree/vm:bytecode_printer",
+        "//iree/vm:bytecode_tables_sequencer",
+        "//iree/vm:module",
+        "//iree/vm:source_map",
+        "//iree/vm/debug:debug_client",
+        "//third_party/GL:GLES2_headers",
+        "//third_party/SDL2",
+        "//third_party/absl/flags:flag",
+        "//third_party/absl/memory",
+        "//third_party/absl/strings",
+        "//third_party/absl/types:optional",
+        "//third_party/dear_imgui",
+        "//third_party/dear_imgui:imgui_sdl_opengl3",
+    ],
+)
+
+# NOTE: users must also link in a GL implementation, like:
+#        "//third_party/GL/native:GLESv2",  # build-cleaner: keep
+cc_library(
+    name = "debug_app_embedded",
+    srcs = ["debug_app_embedded.cc"],
+    hdrs = ["debug_app_embedded.h"],
+    deps = [
+        ":debug_app_library",
+        "//iree/base:status",
+        "//third_party/SDL2",
+        "//third_party/absl/base:core_headers",
+        "//third_party/absl/memory",
+        "//third_party/absl/strings",
+        "//third_party/absl/synchronization",
+        "//third_party/dear_imgui",
+    ],
+)
+
+EMSCRIPTEN_LINKOPTS_COMMON = [
+    # Error at compile time on unresolved symbols.
+    "-s ERROR_ON_UNDEFINED_SYMBOLS=1",
+
+    # Required by SDL.
+    "-s EXTRA_EXPORTED_RUNTIME_METHODS=Pointer_stringify",
+
+    # TODO(benvanik): tweak to enable support when needed.
+    "-s ALLOW_MEMORY_GROWTH=1",
+    # "-s WASM_MEM_MAX=268435456",  # 256MB
+    # "-s TOTAL_MEMORY=268435456",  # 256MB
+]
+
+EMSCRIPTEN_LINKOPTS_DBG = [
+    # Show WASM stack trace in Chrome debugger.
+    "-g2",
+    "-s DEMANGLE_SUPPORT=1",
+
+    # Enable verbose assertions.
+    "-s ASSERTIONS=2",
+    "-s SAFE_HEAP=1",
+    "-s STACK_OVERFLOW_CHECK=2",
+]
+
+EMSCRIPTEN_LINKOPTS_OPT = []
+
+cc_binary(
+    name = "debug_app_emscripten",
+    srcs = ["debug_app_main_emscripten.cc"],
+    linkopts = EMSCRIPTEN_LINKOPTS_COMMON + select({
+        "//tools/compilation_mode:dbg": EMSCRIPTEN_LINKOPTS_DBG,
+        "//tools/compilation_mode:opt": EMSCRIPTEN_LINKOPTS_OPT,
+        "//conditions:default": EMSCRIPTEN_LINKOPTS_OPT,
+    }),
+    tags = [
+        "manual",
+        "notap",  # TODO(b/137088911): Build/test on TAP
+        "wasm",
+    ],
+    deps = [
+        ":debug_app_library",
+        "//iree/base:init",
+        "//iree/base:source_location",
+        "//iree/base:status",
+        "//third_party/SDL2",
+        "//third_party/absl/memory",
+        "//third_party/dear_imgui",
+        "//third_party/dear_imgui:imgui_sdl_opengl3",
+    ],
+)
+
+auto_wasm_binary(
+    name = "debug_app_emscripten_binary",
+    cc_target = ":debug_app_emscripten",
+    tags = ["manual"],
+)
+
+Fileset(
+    name = "debug_app_emscripten_files",
+    out = "wasm_files",
+    entries = [
+        FilesetEntry(
+            files = [":debug_app_emscripten_binary"],
+            strip_prefix = "debug_app_emscripten_binary",
+            destdir = "wasm",
+        ),
+        FilesetEntry(
+            files = ["debug_app.html"],
+            destdir = "wasm",
+        ),
+    ],
+    tags = ["manual"],
+)
+
+cc_binary(
+    name = "debug_app_native",
+    srcs = ["debug_app_main_native.cc"],
+    deps = [
+        ":debug_app_embedded",
+        "//iree/base:init",
+        "//iree/base:status",
+        "//third_party/GL/native:EGL",  # build-cleaner: keep
+        "//third_party/GL/native:GLESv2",  # build-cleaner: keep
+    ],
+)
+
+cc_binary(
+    name = "debug_cli",
+    srcs = ["debug_cli_main.cc"],
+    deps = [
+        ":debug_prompt",
+        "//iree/base:init",
+        "//iree/base:status",
+        "//third_party/absl/flags:flag",
+    ],
+)
+
+cc_library(
+    name = "debug_prompt",
+    srcs = ["debug_prompt.cc"],
+    hdrs = ["debug_prompt.h"],
+    deps = [
+        "//iree/base:status",
+        "//iree/vm/debug:debug_client",
+        "//third_party/absl/strings",
+    ],
+)
diff --git a/iree/tools/web/BUILD b/iree/tools/web/BUILD
new file mode 100644
index 0000000..3737e05
--- /dev/null
+++ b/iree/tools/web/BUILD
@@ -0,0 +1,90 @@
+# IREE web tools.
+
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+load("//third_party/emscripten:split_transition_defs.bzl", "auto_wasm_binary")
+
+EMSCRIPTEN_LINKOPTS_COMMON = [
+    # Error at compile time on unresolved symbols.
+    "-s ERROR_ON_UNDEFINED_SYMBOLS=1",
+
+    # Note: If pthreads and memory growth are enabled, WASM_MEM_MAX must be set.
+    # Also, USE_PTHREADS + ALLOW_MEMORY_GROWTH may run non-wasm code slowly.
+    # "-s ALLOW_MEMORY_GROWTH=1",
+    # "-s WASM_MEM_MAX=268435456",  # 256MB
+    # "-s TOTAL_MEMORY=268435456",  # 256MB
+
+    # Request a prepopulated pool of web workers for pthreads to use.
+    # Without this, threads may not start until the javascript thread yields.
+    # See considerations at https://emscripten.org/docs/porting/pthreads.html.
+    "-s PTHREAD_POOL_SIZE=1",
+]
+
+EMSCRIPTEN_LINKOPTS_DBG = [
+    # Show WASM stack trace in Chrome debugger.
+    "-g2",
+    "-s DEMANGLE_SUPPORT=1",
+
+    # Enable verbose assertions.
+    "-s ASSERTIONS=2",
+    "-s SAFE_HEAP=1",
+    "-s STACK_OVERFLOW_CHECK=2",
+]
+
+EMSCRIPTEN_LINKOPTS_OPT = []
+
+# To use run_module_emscripten:
+#  > bazel build third_party/iree/tools/web:run_module_emscripten_files
+
+cc_binary(
+    name = "run_module_emscripten",
+    srcs = ["run_module_emscripten.cc"],
+    linkopts = EMSCRIPTEN_LINKOPTS_COMMON + select({
+        "//tools/compilation_mode:dbg": EMSCRIPTEN_LINKOPTS_DBG,
+        "//tools/compilation_mode:opt": EMSCRIPTEN_LINKOPTS_OPT,
+        "//conditions:default": EMSCRIPTEN_LINKOPTS_OPT,
+    }),
+    tags = [
+        "manual",
+        "notap",  # TODO(b/137088911): Build/test on TAP
+        "wasm",
+    ],
+    deps = [
+        "//iree/base:init",
+        "//iree/base:status",
+        "//iree/hal:buffer_view_string_util",
+        "//iree/hal:driver_registry",
+        "//iree/hal/interpreter:interpreter_driver_module",
+        "//iree/vm:bytecode_tables_sequencer",
+        "//iree/vm:instance",
+        "//iree/vm:sequencer_context",
+        "//third_party/emscripten:embind",
+    ],
+)
+
+auto_wasm_binary(
+    name = "run_module_emscripten_binary",
+    cc_target = ":run_module_emscripten",
+    tags = ["manual"],
+    threads = "emscripten",
+)
+
+Fileset(
+    name = "run_module_emscripten_files",
+    out = "wasm_files",
+    entries = [
+        FilesetEntry(
+            files = [":run_module_emscripten_binary"],
+            strip_prefix = "run_module_emscripten_binary",
+            destdir = "wasm",
+        ),
+        FilesetEntry(
+            files = ["run_module.html"],
+            destdir = "wasm",
+        ),
+    ],
+    tags = ["manual"],
+)
diff --git a/iree/vm/BUILD b/iree/vm/BUILD
new file mode 100644
index 0000000..57e33d5
--- /dev/null
+++ b/iree/vm/BUILD
@@ -0,0 +1,308 @@
+# Bytecode VM used by the IREE sequencer and interpreter.
+
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+# Enable the debug service and other profiling features.
+# $ bazel build --define=IREE_DEBUG=1 :some_target
+config_setting(
+    name = "debug",
+    define_values = {
+        "IREE_DEBUG": "1",
+    },
+)
+
+cc_library(
+    name = "bytecode_printer",
+    srcs = ["bytecode_printer.cc"],
+    hdrs = ["bytecode_printer.h"],
+    deps = [
+        ":bytecode_util",
+        ":executable_table",
+        ":function_table",
+        ":module",
+        ":opcode_info",
+        ":source_map",
+        ":type",
+        "//iree/base:status",
+        "//iree/schemas",
+        "//iree/schemas/bytecode:bytecode_v0",
+        "//third_party/absl/base:core_headers",
+        "//third_party/absl/container:inlined_vector",
+        "//third_party/absl/strings",
+        "//third_party/absl/types:span",
+    ],
+)
+
+cc_library(
+    name = "bytecode_reader",
+    srcs = ["bytecode_reader.cc"],
+    hdrs = ["bytecode_reader.h"],
+    deps = [
+        ":function",
+        ":stack",
+        ":type",
+        "//iree/base:shape",
+        "//iree/base:status",
+        "//iree/hal:buffer_view",
+        "//iree/hal:heap_buffer",
+        "//iree/schemas/bytecode:bytecode_v0",
+        "//third_party/absl/base:core_headers",
+        "//third_party/absl/container:inlined_vector",
+    ],
+)
+
+cc_library(
+    name = "bytecode_tables_interpreter",
+    srcs = ["bytecode_tables_interpreter.cc"],
+    hdrs = ["bytecode_tables_interpreter.h"],
+    deps = [
+        ":opcode_info",
+        "//iree/schemas/bytecode:interpreter_bytecode_v0",
+    ],
+)
+
+cc_library(
+    name = "bytecode_tables_sequencer",
+    srcs = ["bytecode_tables_sequencer.cc"],
+    hdrs = ["bytecode_tables_sequencer.h"],
+    deps = [
+        ":opcode_info",
+        "//iree/schemas/bytecode:sequencer_bytecode_v0",
+    ],
+)
+
+cc_library(
+    name = "bytecode_util",
+    srcs = ["bytecode_util.cc"],
+    hdrs = ["bytecode_util.h"],
+    deps = [
+        "//iree/schemas/bytecode:bytecode_v0",
+        "//third_party/absl/strings",
+    ],
+)
+
+cc_library(
+    name = "bytecode_validator",
+    srcs = ["bytecode_validator.cc"],
+    hdrs = ["bytecode_validator.h"],
+    deps = [
+        ":context",
+        ":module",
+        "//iree/base:status",
+        "//iree/schemas",
+    ],
+)
+
+cc_library(
+    name = "context",
+    srcs = ["context.cc"],
+    hdrs = ["context.h"],
+    deps = [
+        ":function",
+        ":module",
+        "//iree/base:flatbuffer_util",
+        "//iree/base:status",
+        "//third_party/absl/strings",
+        "//third_party/absl/types:span",
+    ],
+)
+
+cc_library(
+    name = "executable_table",
+    srcs = ["executable_table.cc"],
+    hdrs = ["executable_table.h"],
+    deps = [
+        "//iree/base:flatbuffer_util",
+        "//iree/base:source_location",
+        "//iree/base:status",
+        "//iree/schemas",
+    ],
+)
+
+cc_library(
+    name = "fiber_state",
+    srcs = ["fiber_state.cc"],
+    hdrs = ["fiber_state.h"],
+    deps = [
+        ":instance",
+        ":stack",
+        "//iree/base:status",
+        "//third_party/absl/strings",
+        "//third_party/absl/types:span",
+    ],
+)
+
+cc_library(
+    name = "function",
+    srcs = ["function.cc"],
+    hdrs = ["function.h"],
+    deps = [
+        "//iree/base:flatbuffer_util",
+        "//iree/base:status",
+        "//iree/hal:buffer_view",
+        "//iree/schemas",
+        "//third_party/absl/strings",
+        "//third_party/absl/types:span",
+    ],
+)
+
+cc_library(
+    name = "function_table",
+    srcs = ["function_table.cc"],
+    hdrs = ["function_table.h"],
+    deps = [
+        ":function",
+        "//iree/base:flatbuffer_util",
+        "//iree/base:status",
+        "//iree/schemas",
+        "//third_party/absl/container:flat_hash_map",
+        "//third_party/absl/strings",
+        "//third_party/absl/types:span",
+    ],
+)
+
+cc_library(
+    name = "instance",
+    srcs = ["instance.cc"],
+    hdrs = ["instance.h"],
+    deps = [
+        "//iree/base:source_location",
+        "//iree/base:status",
+        "//iree/hal:device_manager",
+        "//iree/vm/debug:debug_server_interface",
+        "//third_party/absl/memory",
+    ],
+)
+
+cc_library(
+    name = "module",
+    srcs = ["module.cc"],
+    hdrs = ["module.h"],
+    deps = [
+        ":executable_table",
+        ":function_table",
+        "//iree/base:flatbuffer_util",
+        "//iree/base:status",
+        "//iree/schemas",
+        "//third_party/absl/memory",
+    ],
+)
+
+cc_library(
+    name = "module_printer",
+    srcs = ["module_printer.cc"],
+    hdrs = ["module_printer.h"],
+    deps = [
+        ":bytecode_printer",
+        ":module",
+        ":opcode_info",
+        ":source_map",
+        "//iree/base:bitfield",
+        "//iree/base:status",
+    ],
+)
+
+cc_library(
+    name = "opcode_info",
+    hdrs = ["opcode_info.h"],
+    deps = [
+        "//iree/schemas/bytecode:bytecode_v0",
+        "//third_party/absl/strings",
+        "//third_party/absl/types:optional",
+        "//third_party/absl/types:span",
+    ],
+)
+
+cc_library(
+    name = "sequencer_context",
+    srcs = ["sequencer_context.cc"],
+    hdrs = ["sequencer_context.h"],
+    deps = [
+        ":context",
+        ":fiber_state",
+        ":function",
+        ":instance",
+        ":module",
+        ":sequencer_dispatch",
+        "//iree/base:flatbuffer_util",
+        "//iree/base:status",
+        "//iree/hal:buffer_view",
+        "//third_party/absl/strings",
+        "//third_party/absl/types:span",
+    ],
+)
+
+cc_library(
+    name = "sequencer_dispatch",
+    srcs = ["sequencer_dispatch.cc"],
+    hdrs = ["sequencer_dispatch.h"],
+    deps = [
+        ":bytecode_reader",
+        ":bytecode_tables_sequencer",
+        ":bytecode_util",
+        ":function",
+        ":opcode_info",
+        ":stack",
+        "//iree/base:logging",
+        "//iree/base:memory",
+        "//iree/base:status",
+        "//iree/hal:buffer_view",
+        "//iree/hal:command_queue",
+        "//iree/hal:device",
+        "//iree/hal:device_placement",
+        "//iree/hal:heap_buffer",
+        "//iree/schemas/bytecode:sequencer_bytecode_v0",
+        "//third_party/absl/base:core_headers",
+        "//third_party/absl/container:inlined_vector",
+        "//third_party/absl/strings",
+        "//third_party/absl/time",
+        "//third_party/absl/types:span",
+    ],
+)
+
+cc_library(
+    name = "source_map",
+    srcs = ["source_map.cc"],
+    hdrs = ["source_map.h"],
+    deps = [
+        "//iree/base:flatbuffer_util",
+        "//iree/base:status",
+        "//iree/schemas",
+        "//third_party/absl/strings",
+        "//third_party/absl/types:optional",
+    ],
+)
+
+cc_library(
+    name = "stack",
+    srcs = [
+        "stack.cc",
+        "stack_frame.cc",
+    ],
+    hdrs = [
+        "stack.h",
+        "stack_frame.h",
+    ],
+    deps = [
+        ":function",
+        ":module",
+        "//iree/base:status",
+        "//iree/hal:buffer_view",
+        "//third_party/absl/strings",
+        "//third_party/absl/types:span",
+    ],
+)
+
+cc_library(
+    name = "type",
+    srcs = ["type.cc"],
+    hdrs = ["type.h"],
+    deps = [
+        "//iree/base:status",
+        "//iree/schemas",
+        "//iree/schemas/bytecode:bytecode_v0",
+    ],
+)
diff --git a/iree/vm/debug/BUILD b/iree/vm/debug/BUILD
new file mode 100644
index 0000000..3f480bf
--- /dev/null
+++ b/iree/vm/debug/BUILD
@@ -0,0 +1,169 @@
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+cc_library(
+    name = "debug_client",
+    srcs = ["debug_client.cc"],
+    hdrs = ["debug_client.h"],
+    deps = [
+        ":debug_client_interface",
+        ":debug_client_tcp",  # build-cleaner: keep
+        "//iree/base:source_location",
+        "//iree/base:status",
+        "//iree/schemas",
+        "//third_party/absl/container:flat_hash_map",
+        "//third_party/absl/strings",
+        "//third_party/absl/types:optional",
+        "//third_party/absl/types:span",
+    ],
+)
+
+cc_library(
+    name = "debug_client_interface",
+    hdrs = ["debug_client.h"],
+    deps = [
+        "//iree/base:status",
+        "//iree/schemas",
+        "//third_party/absl/container:flat_hash_map",
+        "//third_party/absl/strings",
+        "//third_party/absl/types:optional",
+        "//third_party/absl/types:span",
+    ],
+)
+
+cc_library(
+    name = "debug_client_tcp",
+    srcs = ["debug_client_tcp.cc"],
+    deps = [
+        ":debug_client_interface",
+        ":debug_tcp_util",
+        "//iree/base:flatbuffer_util",
+        "//iree/base:status",
+        "//iree/schemas",
+        "//iree/vm:module",
+        "//third_party/absl/container:flat_hash_map",
+        "//third_party/absl/memory",
+        "//third_party/absl/strings",
+        "//third_party/absl/types:span",
+        "//third_party/flatbuffers",
+    ],
+)
+
+cc_library(
+    name = "debug_server",
+    hdrs = ["debug_server.h"],
+    deps = [
+        ":debug_server_interface",
+        "//third_party/flatbuffers",
+        "//iree/schemas",
+        "//iree/base:status",
+    ] + select({
+        "//iree/vm:debug": [":debug_server_tcp"],
+        "//conditions:default": [":debug_server_disabled"],
+    }),
+)
+
+cc_library(
+    name = "debug_server_interface",
+    hdrs = ["debug_server.h"],
+    deps = ["//iree/base:status"],
+)
+
+cc_library(
+    name = "debug_server_disabled",
+    srcs = ["debug_server_disabled.cc"],
+    deps = [
+        ":debug_server_interface",
+        "//third_party/absl/memory",
+    ],
+)
+
+cc_library(
+    name = "debug_server_tcp",
+    srcs = ["debug_server_tcp.cc"],
+    deps = [
+        ":debug_server_interface",
+        ":debug_service",
+        ":debug_tcp_util",
+        "//iree/base:status",
+        "//iree/schemas",
+        "//third_party/absl/base:core_headers",
+        "//third_party/absl/memory",
+        "//third_party/absl/synchronization",
+        "//third_party/flatbuffers",
+    ],
+)
+
+cc_library(
+    name = "debug_server_flags",
+    srcs = ["debug_server_flags.cc"],
+    hdrs = ["debug_server_flags.h"],
+    copts = select({
+        "//iree/vm:debug": [
+            "-DIREE_DEBUG_EMBEDDED_APP_PRESENT=1",
+        ],
+        "//conditions:default": [],
+    }),
+    deps = [
+        ":debug_server",
+        "//iree/base:memory",
+        "//third_party/absl/flags:flag",
+        "//third_party/absl/strings",
+        "//iree/base:status",
+    ] + select({
+        "//iree/vm:debug": [
+            "//iree/tools/debugger:debug_app_embedded",
+            "//third_party/GL/native:EGL",  # build-cleaner: keep
+            "//third_party/GL/native:GLESv2",  # build-cleaner: keep
+        ],
+        "//conditions:default": [],
+    }),
+)
+
+cc_library(
+    name = "debug_service",
+    srcs = ["debug_service.cc"],
+    hdrs = ["debug_service.h"],
+    deps = [
+        ":debug_session",
+        "//iree/base:flatbuffer_util",
+        "//iree/base:source_location",
+        "//iree/base:status",
+        "//iree/schemas",
+        "//iree/schemas:reflection_data",
+        "//iree/vm:fiber_state",
+        "//iree/vm:instance",
+        "//iree/vm:sequencer_context",
+        "//third_party/absl/base:core_headers",
+        "//third_party/absl/strings",
+        "//third_party/absl/synchronization",
+        "//third_party/flatbuffers",
+    ],
+)
+
+cc_library(
+    name = "debug_session",
+    srcs = ["debug_session.cc"],
+    hdrs = ["debug_session.h"],
+    deps = [
+        "//iree/base:source_location",
+        "//iree/base:status",
+        "//iree/schemas",
+        "//iree/vm:fiber_state",
+        "//iree/vm:sequencer_context",
+        "//third_party/absl/base:core_headers",
+        "//third_party/absl/synchronization",
+    ],
+)
+
+cc_library(
+    name = "debug_tcp_util",
+    hdrs = ["debug_tcp_util.h"],
+    deps = [
+        "//iree/base:status",
+        "//iree/schemas",
+        "//third_party/flatbuffers",
+    ],
+)
diff --git a/test/e2e/BUILD b/test/e2e/BUILD
new file mode 100644
index 0000000..a0c3b83
--- /dev/null
+++ b/test/e2e/BUILD
@@ -0,0 +1,25 @@
+# Tests for end-to-end IREE support.
+
+load("//third_party/llvm/build_defs:lit.bzl", "glob_lit_tests")
+
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+glob_lit_tests(
+    data = [":test_utilities"],
+    driver = "//iree/tools:run_lit.sh",
+    test_file_exts = ["mlir"],
+)
+
+# Bundle together all of the test utilities that are used by tests.
+filegroup(
+    name = "test_utilities",
+    testonly = True,
+    data = [
+        "//iree/tools:iree-run-mlir",
+        "//third_party/llvm/llvm:FileCheck",
+        "//third_party/llvm/llvm/projects/google_mlir:run_lit.sh",
+    ],
+)
diff --git a/test/e2e/xla/BUILD b/test/e2e/xla/BUILD
new file mode 100644
index 0000000..a406d94
--- /dev/null
+++ b/test/e2e/xla/BUILD
@@ -0,0 +1,25 @@
+# Tests for end-to-end IREE support starting from the XLA HLO dialect.
+
+load("//third_party/llvm/build_defs:lit.bzl", "glob_lit_tests")
+
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+glob_lit_tests(
+    data = [":test_utilities"],
+    driver = "//iree/tools:run_lit.sh",
+    test_file_exts = ["mlir"],
+)
+
+# Bundle together all of the test utilities that are used by tests.
+filegroup(
+    name = "test_utilities",
+    testonly = True,
+    data = [
+        "//iree/tools:iree-run-mlir",
+        "//third_party/llvm/llvm:FileCheck",
+        "//third_party/llvm/llvm/projects/google_mlir:run_lit.sh",
+    ],
+)
diff --git a/test/models/BUILD b/test/models/BUILD
new file mode 100644
index 0000000..2d34fd8
--- /dev/null
+++ b/test/models/BUILD
@@ -0,0 +1,6 @@
+# Model files used for manual testing.
+
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)