Moving bytecode files under iree/vm/bytecode/. (#12371)
This will make it easier to add other vm backends in the future and keep
the bytecode impl from polluting the vm/ directory. The existing
`iree/vm/bytecode_module.h` location is likely pointed to by users and
will need to be updated.
diff --git a/build_tools/cmake/static_linker_test.c.in b/build_tools/cmake/static_linker_test.c.in
index a1029e3..0bfb6be 100644
--- a/build_tools/cmake/static_linker_test.c.in
+++ b/build_tools/cmake/static_linker_test.c.in
@@ -34,7 +34,7 @@
#include IREE_EMITC_HDR
#else
#include IREE_MODULE_HDR
-#include "iree/vm/bytecode_module.h"
+#include "iree/vm/bytecode/module.h"
#endif
diff --git a/compiler/src/iree/compiler/ConstEval/BUILD b/compiler/src/iree/compiler/ConstEval/BUILD
index f0b076c..2793c26 100644
--- a/compiler/src/iree/compiler/ConstEval/BUILD
+++ b/compiler/src/iree/compiler/ConstEval/BUILD
@@ -79,7 +79,7 @@
"//runtime/src/iree/modules/hal",
"//runtime/src/iree/tooling:vm_util",
"//runtime/src/iree/vm",
- "//runtime/src/iree/vm:bytecode_module",
+ "//runtime/src/iree/vm/bytecode:module",
"@llvm-project//mlir:IR",
],
)
diff --git a/compiler/src/iree/compiler/ConstEval/CMakeLists.txt b/compiler/src/iree/compiler/ConstEval/CMakeLists.txt
index 591ca21..df44a39 100644
--- a/compiler/src/iree/compiler/ConstEval/CMakeLists.txt
+++ b/compiler/src/iree/compiler/ConstEval/CMakeLists.txt
@@ -69,7 +69,7 @@
iree::modules::hal
iree::tooling::vm_util
iree::vm
- iree::vm::bytecode_module
+ iree::vm::bytecode::module
PUBLIC
)
diff --git a/compiler/src/iree/compiler/ConstEval/Runtime.h b/compiler/src/iree/compiler/ConstEval/Runtime.h
index 6d5935b..6b4a3db 100644
--- a/compiler/src/iree/compiler/ConstEval/Runtime.h
+++ b/compiler/src/iree/compiler/ConstEval/Runtime.h
@@ -11,7 +11,7 @@
#include "iree/hal/api.h"
#include "iree/modules/hal/module.h"
#include "iree/vm/api.h"
-#include "iree/vm/bytecode_module.h"
+#include "iree/vm/bytecode/module.h"
#include "mlir/IR/BuiltinAttributes.h"
#include "mlir/IR/BuiltinOps.h"
diff --git a/docs/website/docs/bindings/c-api.md b/docs/website/docs/bindings/c-api.md
index 9dbe9fa..6b62e11 100644
--- a/docs/website/docs/bindings/c-api.md
+++ b/docs/website/docs/bindings/c-api.md
@@ -72,7 +72,7 @@
// Functionality extensions can be used via custom modules.
#include "iree/modules/hal/module.h"
#include "iree/hal/drivers/local_task/registration/driver_module.h"
-#include "iree/vm/bytecode_module.h"
+#include "iree/vm/bytecode/module.h"
```
Check the API version and register components:
diff --git a/experimental/web/sample_dynamic/main.c b/experimental/web/sample_dynamic/main.c
index 52f7cfe..17bb4be 100644
--- a/experimental/web/sample_dynamic/main.c
+++ b/experimental/web/sample_dynamic/main.c
@@ -11,7 +11,7 @@
#include "iree/hal/api.h"
#include "iree/modules/hal/module.h"
#include "iree/runtime/api.h"
-#include "iree/vm/bytecode_module.h"
+#include "iree/vm/bytecode/module.h"
//===----------------------------------------------------------------------===//
// Public API
diff --git a/experimental/web/sample_static/main.c b/experimental/web/sample_static/main.c
index 9b05df9..cb0cf6c 100644
--- a/experimental/web/sample_static/main.c
+++ b/experimental/web/sample_static/main.c
@@ -8,7 +8,7 @@
#include <stdio.h>
#include "iree/runtime/api.h"
-#include "iree/vm/bytecode_module.h"
+#include "iree/vm/bytecode/module.h"
#include "mnist_bytecode.h"
//===----------------------------------------------------------------------===//
diff --git a/runtime/bindings/python/CMakeLists.txt b/runtime/bindings/python/CMakeLists.txt
index 72ddffa..defabc6 100644
--- a/runtime/bindings/python/CMakeLists.txt
+++ b/runtime/bindings/python/CMakeLists.txt
@@ -55,7 +55,7 @@
iree::hal::utils::allocators
iree::modules::hal
iree::vm
- iree::vm::bytecode_module
+ iree::vm::bytecode::module
)
iree_py_library(
diff --git a/runtime/bindings/python/vm.h b/runtime/bindings/python/vm.h
index 534a66e..464db60 100644
--- a/runtime/bindings/python/vm.h
+++ b/runtime/bindings/python/vm.h
@@ -13,7 +13,7 @@
#include "./status_utils.h"
#include "iree/base/api.h"
#include "iree/vm/api.h"
-#include "iree/vm/bytecode_module.h"
+#include "iree/vm/bytecode/module.h"
namespace iree {
namespace python {
diff --git a/runtime/bindings/tflite/BUILD b/runtime/bindings/tflite/BUILD
index 1f137c9..a6b5085 100644
--- a/runtime/bindings/tflite/BUILD
+++ b/runtime/bindings/tflite/BUILD
@@ -49,7 +49,7 @@
"//runtime/src/iree/hal/drivers",
"//runtime/src/iree/modules/hal",
"//runtime/src/iree/vm",
- "//runtime/src/iree/vm:bytecode_module",
+ "//runtime/src/iree/vm/bytecode:module",
],
)
diff --git a/runtime/bindings/tflite/CMakeLists.txt b/runtime/bindings/tflite/CMakeLists.txt
index 3d2724a..273255d 100644
--- a/runtime/bindings/tflite/CMakeLists.txt
+++ b/runtime/bindings/tflite/CMakeLists.txt
@@ -38,7 +38,7 @@
iree::hal::drivers
iree::modules::hal
iree::vm
- iree::vm::bytecode_module
+ iree::vm::bytecode::module
PUBLIC
)
diff --git a/runtime/bindings/tflite/model.c b/runtime/bindings/tflite/model.c
index fa2f538..55773a0 100644
--- a/runtime/bindings/tflite/model.c
+++ b/runtime/bindings/tflite/model.c
@@ -11,7 +11,7 @@
#include "iree/base/tracing.h"
#include "iree/modules/hal/module.h"
-#include "iree/vm/bytecode_module.h"
+#include "iree/vm/bytecode/module.h"
static iree_status_t _TfLiteModelCalculateFunctionIOCounts(
const iree_vm_function_signature_t* signature, int32_t* out_input_count,
diff --git a/runtime/src/iree/hal/local/loaders/BUILD b/runtime/src/iree/hal/local/loaders/BUILD
index 0a4ba2e..95b05d9 100644
--- a/runtime/src/iree/hal/local/loaders/BUILD
+++ b/runtime/src/iree/hal/local/loaders/BUILD
@@ -115,7 +115,7 @@
"//runtime/src/iree/hal/local:executable_loader",
"//runtime/src/iree/modules/vmvx",
"//runtime/src/iree/vm",
- "//runtime/src/iree/vm:bytecode_module",
+ "//runtime/src/iree/vm/bytecode:module",
],
)
diff --git a/runtime/src/iree/hal/local/loaders/CMakeLists.txt b/runtime/src/iree/hal/local/loaders/CMakeLists.txt
index 868e51c..495bd24 100644
--- a/runtime/src/iree/hal/local/loaders/CMakeLists.txt
+++ b/runtime/src/iree/hal/local/loaders/CMakeLists.txt
@@ -94,7 +94,7 @@
iree::hal::local::executable_loader
iree::modules::vmvx
iree::vm
- iree::vm::bytecode_module
+ iree::vm::bytecode::module
DEFINES
"IREE_HAVE_HAL_EXECUTABLE_LOADER_VMVX_MODULE=1"
PUBLIC
diff --git a/runtime/src/iree/hal/local/loaders/vmvx_module_loader.c b/runtime/src/iree/hal/local/loaders/vmvx_module_loader.c
index 8e0b3e4..5ed04e3 100644
--- a/runtime/src/iree/hal/local/loaders/vmvx_module_loader.c
+++ b/runtime/src/iree/hal/local/loaders/vmvx_module_loader.c
@@ -16,7 +16,7 @@
#include "iree/hal/local/executable_library.h"
#include "iree/hal/local/local_executable.h"
#include "iree/modules/vmvx/module.h"
-#include "iree/vm/bytecode_module.h"
+#include "iree/vm/bytecode/module.h"
#define IREE_VMVX_ENTRY_SIGNATURE "0rrriiiiiiiii_v"
diff --git a/runtime/src/iree/modules/check/BUILD b/runtime/src/iree/modules/check/BUILD
index b6ea845..77295d1 100644
--- a/runtime/src/iree/modules/check/BUILD
+++ b/runtime/src/iree/modules/check/BUILD
@@ -42,7 +42,7 @@
"//runtime/src/iree/testing:gtest_main",
"//runtime/src/iree/tooling:device_util",
"//runtime/src/iree/vm",
- "//runtime/src/iree/vm:bytecode_module",
"//runtime/src/iree/vm:cc",
+ "//runtime/src/iree/vm/bytecode:module",
],
)
diff --git a/runtime/src/iree/modules/check/CMakeLists.txt b/runtime/src/iree/modules/check/CMakeLists.txt
index 80b7862..dfb25bc 100644
--- a/runtime/src/iree/modules/check/CMakeLists.txt
+++ b/runtime/src/iree/modules/check/CMakeLists.txt
@@ -45,7 +45,7 @@
iree::testing::gtest_main
iree::tooling::device_util
iree::vm
- iree::vm::bytecode_module
+ iree::vm::bytecode::module
iree::vm::cc
)
diff --git a/runtime/src/iree/runtime/BUILD.bazel b/runtime/src/iree/runtime/BUILD.bazel
index 1c9443b..24ae360 100644
--- a/runtime/src/iree/runtime/BUILD.bazel
+++ b/runtime/src/iree/runtime/BUILD.bazel
@@ -53,6 +53,6 @@
"//runtime/src/iree/hal/drivers",
"//runtime/src/iree/modules/hal",
"//runtime/src/iree/vm",
- "//runtime/src/iree/vm:bytecode_module",
+ "//runtime/src/iree/vm/bytecode:module",
],
)
diff --git a/runtime/src/iree/runtime/CMakeLists.txt b/runtime/src/iree/runtime/CMakeLists.txt
index 1f26720..6005eb1 100644
--- a/runtime/src/iree/runtime/CMakeLists.txt
+++ b/runtime/src/iree/runtime/CMakeLists.txt
@@ -42,7 +42,7 @@
iree::hal::drivers
iree::modules::hal
iree::vm
- iree::vm::bytecode_module
+ iree::vm::bytecode::module
PUBLIC
)
diff --git a/runtime/src/iree/runtime/session.c b/runtime/src/iree/runtime/session.c
index 0324133..6e60cd9 100644
--- a/runtime/src/iree/runtime/session.c
+++ b/runtime/src/iree/runtime/session.c
@@ -16,7 +16,7 @@
#include "iree/modules/hal/module.h"
#include "iree/runtime/instance.h"
#include "iree/vm/api.h"
-#include "iree/vm/bytecode_module.h"
+#include "iree/vm/bytecode/module.h"
//===----------------------------------------------------------------------===//
// iree_runtime_session_options_t
diff --git a/runtime/src/iree/tooling/BUILD b/runtime/src/iree/tooling/BUILD
index 2c58739..18182a8 100644
--- a/runtime/src/iree/tooling/BUILD
+++ b/runtime/src/iree/tooling/BUILD
@@ -88,7 +88,7 @@
"//runtime/src/iree/modules/hal/loader",
"//runtime/src/iree/modules/vmvx",
"//runtime/src/iree/vm",
- "//runtime/src/iree/vm:bytecode_module",
+ "//runtime/src/iree/vm/bytecode:module",
],
)
@@ -160,7 +160,7 @@
"//runtime/src/iree/hal",
"//runtime/src/iree/modules/hal",
"//runtime/src/iree/vm",
- "//runtime/src/iree/vm:bytecode_module",
+ "//runtime/src/iree/vm/bytecode:module",
],
)
@@ -202,7 +202,7 @@
"//runtime/src/iree/hal",
"//runtime/src/iree/modules/hal",
"//runtime/src/iree/vm",
- "//runtime/src/iree/vm:bytecode_module",
+ "//runtime/src/iree/vm/bytecode:module",
"@com_github_yaml_libyaml//:yaml",
],
)
diff --git a/runtime/src/iree/tooling/CMakeLists.txt b/runtime/src/iree/tooling/CMakeLists.txt
index 423bf4d..5e41789 100644
--- a/runtime/src/iree/tooling/CMakeLists.txt
+++ b/runtime/src/iree/tooling/CMakeLists.txt
@@ -97,7 +97,7 @@
iree::modules::hal::loader
iree::modules::vmvx
iree::vm
- iree::vm::bytecode_module
+ iree::vm::bytecode::module
PUBLIC
)
@@ -182,7 +182,7 @@
iree::hal
iree::modules::hal
iree::vm
- iree::vm::bytecode_module
+ iree::vm::bytecode::module
PUBLIC
)
@@ -223,7 +223,7 @@
iree::hal
iree::modules::hal
iree::vm
- iree::vm::bytecode_module
+ iree::vm::bytecode::module
yaml
PUBLIC
)
diff --git a/runtime/src/iree/tooling/context_util.c b/runtime/src/iree/tooling/context_util.c
index 7937031..301819e 100644
--- a/runtime/src/iree/tooling/context_util.c
+++ b/runtime/src/iree/tooling/context_util.c
@@ -18,7 +18,7 @@
#include "iree/modules/hal/loader/module.h"
#include "iree/modules/hal/module.h"
#include "iree/tooling/device_util.h"
-#include "iree/vm/bytecode_module.h"
+#include "iree/vm/bytecode/module.h"
#if defined(IREE_HAVE_VMVX_MODULE)
#include "iree/modules/vmvx/module.h"
diff --git a/runtime/src/iree/tooling/trace_replay.c b/runtime/src/iree/tooling/trace_replay.c
index 8d2ffac..f05cac8 100644
--- a/runtime/src/iree/tooling/trace_replay.c
+++ b/runtime/src/iree/tooling/trace_replay.c
@@ -17,7 +17,7 @@
#include "iree/base/internal/path.h"
#include "iree/base/tracing.h"
#include "iree/modules/hal/module.h"
-#include "iree/vm/bytecode_module.h"
+#include "iree/vm/bytecode/module.h"
// Parameter for locally defined lcg similar to std::minstd_rand.
#define IREE_PRNG_MULTIPLIER 48271
diff --git a/runtime/src/iree/vm/BUILD b/runtime/src/iree/vm/BUILD
index 3025fac..1fac929 100644
--- a/runtime/src/iree/vm/BUILD
+++ b/runtime/src/iree/vm/BUILD
@@ -4,10 +4,8 @@
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-load("//build_tools/bazel:build_defs.oss.bzl", "iree_cmake_extra_content", "iree_runtime_cc_library", "iree_runtime_cc_test")
-load("//build_tools/bazel:iree_bytecode_module.bzl", "iree_bytecode_module")
+load("//build_tools/bazel:build_defs.oss.bzl", "iree_runtime_cc_library", "iree_runtime_cc_test")
load("//build_tools/bazel:cc_binary_benchmark.bzl", "cc_binary_benchmark")
-# load("//build_tools/bazel:iree_tablegen.bzl", "iree_gentbl_cc_library")
package(
default_visibility = ["//visibility:public"],
@@ -170,137 +168,6 @@
)
#===------------------------------------------------------------------------===#
-# Bytecode interpreter module
-#===------------------------------------------------------------------------===#
-
-iree_runtime_cc_library(
- name = "bytecode_module",
- srcs = [
- "bytecode_disasm.c",
- "bytecode_disasm.h",
- "bytecode_dispatch.c",
- "bytecode_dispatch_util.h",
- "bytecode_module.c",
- "bytecode_module_impl.h",
- "generated/bytecode_op_table.h",
- ],
- hdrs = [
- "bytecode_module.h",
- ],
- deps = [
- ":ops",
- ":vm",
- "//runtime/src/iree/base",
- "//runtime/src/iree/base:core_headers",
- "//runtime/src/iree/base:tracing",
- "//runtime/src/iree/base/internal",
- "//runtime/src/iree/base/internal/flatcc:parsing",
- "//runtime/src/iree/schemas:bytecode_module_def_c_fbs",
- ],
-)
-
-# TODO(#357): Add a script to update bytecode_op_table.h.
-# iree_gentbl_cc_library(
-# name = "bytecode_op_table_gen",
-# tbl_outs = [
-# (["--gen-iree-vm-op-table-defs"], "bytecode_op_table.h"),
-# ],
-# tblgen = "//tools:iree-tblgen",
-# td_file = "//compiler/src/iree/compiler/Dialect/VM/IR:VMOps.td",
-# deps = [
-# "//compiler/src/iree/compiler/Dialect/Util/IR:td_files",
-# "//compiler/src/iree/compiler/Dialect/VM/IR:td_files",
-# "@llvm-project//mlir:CallInterfacesTdFiles",
-# "@llvm-project//mlir:ControlFlowInterfacesTdFiles",
-# "@llvm-project//mlir:FunctionInterfacesTdFiles",
-# "@llvm-project//mlir:OpBaseTdFiles",
-# "@llvm-project//mlir:SideEffectInterfacesTdFiles",
-# ],
-# )
-
-iree_cmake_extra_content(
- content = """
-if(IREE_BUILD_COMPILER)
-""",
- inline = True,
-)
-
-iree_runtime_cc_test(
- name = "bytecode_module_test",
- srcs = [
- "bytecode_dispatch_async_test.cc",
- "bytecode_dispatch_test.cc",
- "bytecode_module_test.cc",
- ],
- deps = [
- ":bytecode_module",
- ":bytecode_module_test_module_c",
- ":vm",
- "//runtime/src/iree/base",
- "//runtime/src/iree/testing:gtest",
- "//runtime/src/iree/testing:gtest_main",
- "//runtime/src/iree/vm/test:all_bytecode_modules_c",
- "//runtime/src/iree/vm/test:async_bytecode_modules_c",
- ],
-)
-
-iree_bytecode_module(
- name = "bytecode_module_test_module",
- testonly = True,
- src = "bytecode_module_test.mlir",
- c_identifier = "iree_vm_bytecode_module_test_module",
- flags = ["--compile-mode=vm"],
-)
-
-cc_binary_benchmark(
- name = "bytecode_module_benchmark",
- testonly = True,
- srcs = ["bytecode_module_benchmark.cc"],
- deps = [
- ":bytecode_module",
- ":bytecode_module_benchmark_module_c",
- ":vm",
- "//runtime/src/iree/base",
- "//runtime/src/iree/testing:benchmark_main",
- "@com_google_benchmark//:benchmark",
- ],
-)
-
-iree_bytecode_module(
- name = "bytecode_module_benchmark_module",
- testonly = True,
- src = "bytecode_module_benchmark.mlir",
- c_identifier = "iree_vm_bytecode_module_benchmark_module",
- flags = ["--compile-mode=vm"],
-)
-
-cc_binary_benchmark(
- name = "bytecode_module_size_benchmark",
- srcs = ["bytecode_module_size_benchmark.cc"],
- deps = [
- ":bytecode_module",
- ":bytecode_module_size_benchmark_module_c",
- ":vm",
- "//runtime/src/iree/base",
- ],
-)
-
-iree_bytecode_module(
- name = "bytecode_module_size_benchmark_module",
- testonly = True,
- src = "bytecode_module_size_benchmark.mlir",
- c_identifier = "iree_vm_bytecode_module_size_benchmark_module",
- flags = ["--compile-mode=vm"],
-)
-
-iree_cmake_extra_content(
- content = """
-endif()
-""",
- inline = True,
-)
-
-#===------------------------------------------------------------------------===#
# Common VM op implementations
#===------------------------------------------------------------------------===#
diff --git a/runtime/src/iree/vm/CMakeLists.txt b/runtime/src/iree/vm/CMakeLists.txt
index 017f777..b0447c3 100644
--- a/runtime/src/iree/vm/CMakeLists.txt
+++ b/runtime/src/iree/vm/CMakeLists.txt
@@ -163,120 +163,6 @@
iree_cc_library(
NAME
- bytecode_module
- HDRS
- "bytecode_module.h"
- SRCS
- "bytecode_disasm.c"
- "bytecode_disasm.h"
- "bytecode_dispatch.c"
- "bytecode_dispatch_util.h"
- "bytecode_module.c"
- "bytecode_module_impl.h"
- "generated/bytecode_op_table.h"
- DEPS
- ::ops
- ::vm
- iree::base
- iree::base::core_headers
- iree::base::internal
- iree::base::internal::flatcc::parsing
- iree::base::tracing
- iree::schemas::bytecode_module_def_c_fbs
- PUBLIC
-)
-
-if(IREE_BUILD_COMPILER)
-
-iree_cc_test(
- NAME
- bytecode_module_test
- SRCS
- "bytecode_dispatch_async_test.cc"
- "bytecode_dispatch_test.cc"
- "bytecode_module_test.cc"
- DEPS
- ::bytecode_module
- ::bytecode_module_test_module_c
- ::vm
- iree::base
- iree::testing::gtest
- iree::testing::gtest_main
- iree::vm::test::all_bytecode_modules_c
- iree::vm::test::async_bytecode_modules_c
-)
-
-iree_bytecode_module(
- NAME
- bytecode_module_test_module
- SRC
- "bytecode_module_test.mlir"
- C_IDENTIFIER
- "iree_vm_bytecode_module_test_module"
- FLAGS
- "--compile-mode=vm"
- TESTONLY
- PUBLIC
-)
-
-iree_cc_binary_benchmark(
- NAME
- bytecode_module_benchmark
- SRCS
- "bytecode_module_benchmark.cc"
- DEPS
- ::bytecode_module
- ::bytecode_module_benchmark_module_c
- ::vm
- benchmark
- iree::base
- iree::testing::benchmark_main
- TESTONLY
-)
-
-iree_bytecode_module(
- NAME
- bytecode_module_benchmark_module
- SRC
- "bytecode_module_benchmark.mlir"
- C_IDENTIFIER
- "iree_vm_bytecode_module_benchmark_module"
- FLAGS
- "--compile-mode=vm"
- TESTONLY
- PUBLIC
-)
-
-iree_cc_binary_benchmark(
- NAME
- bytecode_module_size_benchmark
- SRCS
- "bytecode_module_size_benchmark.cc"
- DEPS
- ::bytecode_module
- ::bytecode_module_size_benchmark_module_c
- ::vm
- iree::base
- TESTONLY
-)
-
-iree_bytecode_module(
- NAME
- bytecode_module_size_benchmark_module
- SRC
- "bytecode_module_size_benchmark.mlir"
- C_IDENTIFIER
- "iree_vm_bytecode_module_size_benchmark_module"
- FLAGS
- "--compile-mode=vm"
- TESTONLY
- PUBLIC
-)
-
-endif()
-
-iree_cc_library(
- NAME
ops
HDRS
"ops.h"
diff --git a/runtime/src/iree/vm/bytecode/BUILD b/runtime/src/iree/vm/bytecode/BUILD
new file mode 100644
index 0000000..54257a3
--- /dev/null
+++ b/runtime/src/iree/vm/bytecode/BUILD
@@ -0,0 +1,147 @@
+# Copyright 2023 The IREE Authors
+#
+# Licensed under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+load("//build_tools/bazel:build_defs.oss.bzl", "iree_cmake_extra_content", "iree_runtime_cc_library", "iree_runtime_cc_test")
+load("//build_tools/bazel:iree_bytecode_module.bzl", "iree_bytecode_module")
+load("//build_tools/bazel:cc_binary_benchmark.bzl", "cc_binary_benchmark")
+# load("//build_tools/bazel:iree_tablegen.bzl", "iree_gentbl_cc_library")
+
+package(
+ default_visibility = ["//visibility:public"],
+ features = ["layering_check"],
+ licenses = ["notice"], # Apache 2.0
+)
+
+#===------------------------------------------------------------------------===#
+# Bytecode interpreter module
+#===------------------------------------------------------------------------===#
+
+iree_runtime_cc_library(
+ name = "module",
+ srcs = [
+ "disassembler.c",
+ "disassembler.h",
+ "dispatch.c",
+ "dispatch_util.h",
+ "generated/op_table.h",
+ "module.c",
+ "module_impl.h",
+ ],
+ hdrs = [
+ "module.h",
+ ],
+ deps = [
+ "//runtime/src/iree/base",
+ "//runtime/src/iree/base:core_headers",
+ "//runtime/src/iree/base:tracing",
+ "//runtime/src/iree/base/internal",
+ "//runtime/src/iree/base/internal/flatcc:parsing",
+ "//runtime/src/iree/schemas:bytecode_module_def_c_fbs",
+ "//runtime/src/iree/vm",
+ "//runtime/src/iree/vm:ops",
+ ],
+)
+
+# TODO(#357): Add a script to update op_table.h.
+# iree_gentbl_cc_library(
+# name = "op_table_gen",
+# tbl_outs = [
+# (["--gen-iree-vm-op-table-defs"], "op_table.h"),
+# ],
+# tblgen = "//tools:iree-tblgen",
+# td_file = "//compiler/src/iree/compiler/Dialect/VM/IR:VMOps.td",
+# deps = [
+# "//compiler/src/iree/compiler/Dialect/Util/IR:td_files",
+# "//compiler/src/iree/compiler/Dialect/VM/IR:td_files",
+# "@llvm-project//mlir:CallInterfacesTdFiles",
+# "@llvm-project//mlir:ControlFlowInterfacesTdFiles",
+# "@llvm-project//mlir:FunctionInterfacesTdFiles",
+# "@llvm-project//mlir:OpBaseTdFiles",
+# "@llvm-project//mlir:SideEffectInterfacesTdFiles",
+# ],
+# )
+
+iree_cmake_extra_content(
+ content = """
+if(IREE_BUILD_COMPILER)
+""",
+ inline = True,
+)
+
+iree_runtime_cc_test(
+ name = "module_test",
+ srcs = [
+ "dispatch_async_test.cc",
+ "dispatch_test.cc",
+ "module_test.cc",
+ ],
+ deps = [
+ ":module",
+ ":module_test_module_c",
+ "//runtime/src/iree/base",
+ "//runtime/src/iree/testing:gtest",
+ "//runtime/src/iree/testing:gtest_main",
+ "//runtime/src/iree/vm",
+ "//runtime/src/iree/vm/test:all_bytecode_modules_c",
+ "//runtime/src/iree/vm/test:async_bytecode_modules_c",
+ ],
+)
+
+iree_bytecode_module(
+ name = "module_test_module",
+ testonly = True,
+ src = "module_test.mlir",
+ c_identifier = "iree_vm_bytecode_module_test_module",
+ flags = ["--compile-mode=vm"],
+)
+
+cc_binary_benchmark(
+ name = "module_benchmark",
+ testonly = True,
+ srcs = ["module_benchmark.cc"],
+ deps = [
+ ":module",
+ ":module_benchmark_module_c",
+ "//runtime/src/iree/base",
+ "//runtime/src/iree/testing:benchmark_main",
+ "//runtime/src/iree/vm",
+ "@com_google_benchmark//:benchmark",
+ ],
+)
+
+iree_bytecode_module(
+ name = "module_benchmark_module",
+ testonly = True,
+ src = "module_benchmark.mlir",
+ c_identifier = "iree_vm_bytecode_module_benchmark_module",
+ flags = ["--compile-mode=vm"],
+)
+
+cc_binary_benchmark(
+ name = "module_size_benchmark",
+ srcs = ["module_size_benchmark.cc"],
+ deps = [
+ ":module",
+ ":module_size_benchmark_module_c",
+ "//runtime/src/iree/base",
+ "//runtime/src/iree/vm",
+ ],
+)
+
+iree_bytecode_module(
+ name = "module_size_benchmark_module",
+ testonly = True,
+ src = "module_size_benchmark.mlir",
+ c_identifier = "iree_vm_bytecode_module_size_benchmark_module",
+ flags = ["--compile-mode=vm"],
+)
+
+iree_cmake_extra_content(
+ content = """
+endif()
+""",
+ inline = True,
+)
diff --git a/runtime/src/iree/vm/bytecode/CMakeLists.txt b/runtime/src/iree/vm/bytecode/CMakeLists.txt
new file mode 100644
index 0000000..7e5a59b
--- /dev/null
+++ b/runtime/src/iree/vm/bytecode/CMakeLists.txt
@@ -0,0 +1,127 @@
+################################################################################
+# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
+# runtime/src/iree/vm/bytecode/BUILD #
+# #
+# Use iree_cmake_extra_content from iree/build_defs.oss.bzl to add arbitrary #
+# CMake-only content. #
+# #
+# To disable autogeneration for this file entirely, delete this header. #
+################################################################################
+
+iree_add_all_subdirs()
+
+iree_cc_library(
+ NAME
+ module
+ HDRS
+ "module.h"
+ SRCS
+ "disassembler.c"
+ "disassembler.h"
+ "dispatch.c"
+ "dispatch_util.h"
+ "generated/op_table.h"
+ "module.c"
+ "module_impl.h"
+ DEPS
+ iree::base
+ iree::base::core_headers
+ iree::base::internal
+ iree::base::internal::flatcc::parsing
+ iree::base::tracing
+ iree::schemas::bytecode_module_def_c_fbs
+ iree::vm
+ iree::vm::ops
+ PUBLIC
+)
+
+if(IREE_BUILD_COMPILER)
+
+iree_cc_test(
+ NAME
+ module_test
+ SRCS
+ "dispatch_async_test.cc"
+ "dispatch_test.cc"
+ "module_test.cc"
+ DEPS
+ ::module
+ ::module_test_module_c
+ iree::base
+ iree::testing::gtest
+ iree::testing::gtest_main
+ iree::vm
+ iree::vm::test::all_bytecode_modules_c
+ iree::vm::test::async_bytecode_modules_c
+)
+
+iree_bytecode_module(
+ NAME
+ module_test_module
+ SRC
+ "module_test.mlir"
+ C_IDENTIFIER
+ "iree_vm_bytecode_module_test_module"
+ FLAGS
+ "--compile-mode=vm"
+ TESTONLY
+ PUBLIC
+)
+
+iree_cc_binary_benchmark(
+ NAME
+ module_benchmark
+ SRCS
+ "module_benchmark.cc"
+ DEPS
+ ::module
+ ::module_benchmark_module_c
+ benchmark
+ iree::base
+ iree::testing::benchmark_main
+ iree::vm
+ TESTONLY
+)
+
+iree_bytecode_module(
+ NAME
+ module_benchmark_module
+ SRC
+ "module_benchmark.mlir"
+ C_IDENTIFIER
+ "iree_vm_bytecode_module_benchmark_module"
+ FLAGS
+ "--compile-mode=vm"
+ TESTONLY
+ PUBLIC
+)
+
+iree_cc_binary_benchmark(
+ NAME
+ module_size_benchmark
+ SRCS
+ "module_size_benchmark.cc"
+ DEPS
+ ::module
+ ::module_size_benchmark_module_c
+ iree::base
+ iree::vm
+ TESTONLY
+)
+
+iree_bytecode_module(
+ NAME
+ module_size_benchmark_module
+ SRC
+ "module_size_benchmark.mlir"
+ C_IDENTIFIER
+ "iree_vm_bytecode_module_size_benchmark_module"
+ FLAGS
+ "--compile-mode=vm"
+ TESTONLY
+ PUBLIC
+)
+
+endif()
+
+### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
diff --git a/runtime/src/iree/vm/bytecode_disasm.c b/runtime/src/iree/vm/bytecode/disassembler.c
similarity index 97%
rename from runtime/src/iree/vm/bytecode_disasm.c
rename to runtime/src/iree/vm/bytecode/disassembler.c
index 0b03914..6b0f5bf 100644
--- a/runtime/src/iree/vm/bytecode_disasm.c
+++ b/runtime/src/iree/vm/bytecode/disassembler.c
@@ -4,7 +4,7 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#include "iree/vm/bytecode_disasm.h"
+#include "iree/vm/bytecode/disassembler.h"
#include <inttypes.h>
@@ -132,7 +132,7 @@
b, "%u", ((regs)->i32[(reg)&IREE_I32_REGISTER_MASK]))); \
}
-static iree_status_t iree_vm_bytecode_disasm_emit_type_name(
+static iree_status_t iree_vm_bytecode_disassembler_emit_type_name(
const iree_vm_type_def_t* type_def, iree_string_builder_t* b) {
if (iree_vm_type_def_is_value(type_def)) {
const char* type_name;
@@ -169,13 +169,13 @@
}
}
#define EMIT_TYPE_NAME(type_def) \
- iree_vm_bytecode_disasm_emit_type_name(type_def, b);
+ iree_vm_bytecode_disassembler_emit_type_name(type_def, b);
-static iree_status_t iree_vm_bytecode_disasm_emit_operand_list(
+static iree_status_t iree_vm_bytecode_disassembler_emit_operand_list(
const iree_vm_registers_t* regs, const iree_vm_register_list_t* list,
- iree_vm_bytecode_disasm_format_t format, iree_string_builder_t* b) {
+ iree_vm_bytecode_disassembly_format_t format, iree_string_builder_t* b) {
bool include_values =
- regs && (format & IREE_VM_BYTECODE_DISASM_FORMAT_INLINE_VALUES);
+ regs && (format & IREE_VM_BYTECODE_DISASSEMBLY_FORMAT_INLINE_VALUES);
for (uint16_t i = 0; i < list->size; ++i) {
if (i > 0) {
IREE_RETURN_IF_ERROR(iree_string_builder_append_cstring(b, ", "));
@@ -191,10 +191,10 @@
return iree_ok_status();
}
#define EMIT_OPERAND_REG_LIST(reg_list) \
- iree_vm_bytecode_disasm_emit_operand_list(regs, reg_list, format, b)
-static iree_status_t iree_vm_bytecode_disasm_emit_result_list(
+ iree_vm_bytecode_disassembler_emit_operand_list(regs, reg_list, format, b)
+static iree_status_t iree_vm_bytecode_disassembler_emit_result_list(
const iree_vm_register_list_t* list,
- iree_vm_bytecode_disasm_format_t format, iree_string_builder_t* b) {
+ iree_vm_bytecode_disassembly_format_t format, iree_string_builder_t* b) {
for (uint16_t i = 0; i < list->size; ++i) {
if (i > 0) {
IREE_RETURN_IF_ERROR(iree_string_builder_append_cstring(b, ", "));
@@ -205,13 +205,13 @@
return iree_ok_status();
}
#define EMIT_RESULT_REG_LIST(reg_list) \
- iree_vm_bytecode_disasm_emit_result_list(reg_list, format, b)
-static iree_status_t iree_vm_bytecode_disasm_emit_remap_list(
+ iree_vm_bytecode_disassembler_emit_result_list(reg_list, format, b)
+static iree_status_t iree_vm_bytecode_disassembler_emit_remap_list(
const iree_vm_registers_t* regs,
const iree_vm_register_remap_list_t* remap_list,
- iree_vm_bytecode_disasm_format_t format, iree_string_builder_t* b) {
+ iree_vm_bytecode_disassembly_format_t format, iree_string_builder_t* b) {
bool include_values =
- regs && (format & IREE_VM_BYTECODE_DISASM_FORMAT_INLINE_VALUES);
+ regs && (format & IREE_VM_BYTECODE_DISASSEMBLY_FORMAT_INLINE_VALUES);
for (uint16_t i = 0; i < remap_list->size; ++i) {
if (i > 0) {
IREE_RETURN_IF_ERROR(iree_string_builder_append_cstring(b, ", "));
@@ -228,30 +228,30 @@
return iree_ok_status();
}
#define EMIT_REMAP_LIST(remap_list) \
- iree_vm_bytecode_disasm_emit_remap_list(regs, remap_list, format, b)
+ iree_vm_bytecode_disassembler_emit_remap_list(regs, remap_list, format, b)
#define EMIT_OPTIONAL_VALUE_I32(expr) \
- if (regs && (format & IREE_VM_BYTECODE_DISASM_FORMAT_INLINE_VALUES)) { \
+ if (regs && (format & IREE_VM_BYTECODE_DISASSEMBLY_FORMAT_INLINE_VALUES)) { \
IREE_RETURN_IF_ERROR(iree_string_builder_append_format(b, "(%" PRId32 ")", \
(int32_t)(expr))); \
}
-#define EMIT_OPTIONAL_VALUE_I64(expr) \
- if (regs && (format & IREE_VM_BYTECODE_DISASM_FORMAT_INLINE_VALUES)) { \
- IREE_RETURN_IF_ERROR(iree_string_builder_append_format( \
- b, "(%" PRId64 ")", *(int64_t*)&(expr))); \
+#define EMIT_OPTIONAL_VALUE_I64(expr) \
+ if (regs && (format & IREE_VM_BYTECODE_DISASSEMBLY_FORMAT_INLINE_VALUES)) { \
+ IREE_RETURN_IF_ERROR(iree_string_builder_append_format( \
+ b, "(%" PRId64 ")", *(int64_t*)&(expr))); \
}
-#define EMIT_OPTIONAL_VALUE_F32(expr) \
- if (regs && (format & IREE_VM_BYTECODE_DISASM_FORMAT_INLINE_VALUES)) { \
- IREE_RETURN_IF_ERROR( \
- iree_string_builder_append_format(b, "(%f)", *(float*)&(expr))); \
+#define EMIT_OPTIONAL_VALUE_F32(expr) \
+ if (regs && (format & IREE_VM_BYTECODE_DISASSEMBLY_FORMAT_INLINE_VALUES)) { \
+ IREE_RETURN_IF_ERROR( \
+ iree_string_builder_append_format(b, "(%f)", *(float*)&(expr))); \
}
-#define EMIT_OPTIONAL_VALUE_F64(expr) \
- if (regs && (format & IREE_VM_BYTECODE_DISASM_FORMAT_INLINE_VALUES)) { \
- IREE_RETURN_IF_ERROR( \
- iree_string_builder_append_format(b, "(%f)", *(double*)&(expr))); \
+#define EMIT_OPTIONAL_VALUE_F64(expr) \
+ if (regs && (format & IREE_VM_BYTECODE_DISASSEMBLY_FORMAT_INLINE_VALUES)) { \
+ IREE_RETURN_IF_ERROR( \
+ iree_string_builder_append_format(b, "(%f)", *(double*)&(expr))); \
}
#define EMIT_OPTIONAL_VALUE_REF(expr) \
- if (regs && (format & IREE_VM_BYTECODE_DISASM_FORMAT_INLINE_VALUES)) { \
+ if (regs && (format & IREE_VM_BYTECODE_DISASSEMBLY_FORMAT_INLINE_VALUES)) { \
iree_vm_ref_t* ref = (expr); \
if (iree_vm_ref_is_null(ref)) { \
IREE_RETURN_IF_ERROR(iree_string_builder_append_cstring(b, "(null)")); \
@@ -406,11 +406,11 @@
break; \
}
-iree_status_t iree_vm_bytecode_disasm_op(
+iree_status_t iree_vm_bytecode_disassemble_op(
iree_vm_bytecode_module_t* module,
iree_vm_bytecode_module_state_t* module_state, uint16_t function_ordinal,
iree_vm_source_offset_t pc, const iree_vm_registers_t* regs,
- iree_vm_bytecode_disasm_format_t format, iree_string_builder_t* b) {
+ iree_vm_bytecode_disassembly_format_t format, iree_string_builder_t* b) {
const uint8_t* IREE_RESTRICT bytecode_data =
module->bytecode_data.data +
module->function_descriptor_table[function_ordinal].bytecode_offset;
@@ -2130,10 +2130,9 @@
return iree_ok_status();
}
-iree_status_t iree_vm_bytecode_trace_disasm(iree_vm_stack_frame_t* frame,
- iree_vm_source_offset_t pc,
- const iree_vm_registers_t* regs,
- FILE* file) {
+iree_status_t iree_vm_bytecode_trace_disassembly(
+ iree_vm_stack_frame_t* frame, iree_vm_source_offset_t pc,
+ const iree_vm_registers_t* regs, FILE* file) {
iree_string_builder_t b;
iree_string_builder_initialize(iree_allocator_system(), &b);
@@ -2188,11 +2187,11 @@
}
if (iree_status_is_ok(status)) {
- status = iree_vm_bytecode_disasm_op(
+ status = iree_vm_bytecode_disassemble_op(
(iree_vm_bytecode_module_t*)frame->function.module,
(iree_vm_bytecode_module_state_t*)frame->module_state,
frame->function.ordinal, pc, regs,
- IREE_VM_BYTECODE_DISASM_FORMAT_INLINE_VALUES, &b);
+ IREE_VM_BYTECODE_DISASSEMBLY_FORMAT_INLINE_VALUES, &b);
}
if (iree_status_is_ok(status)) {
diff --git a/runtime/src/iree/vm/bytecode_disasm.h b/runtime/src/iree/vm/bytecode/disassembler.h
similarity index 61%
rename from runtime/src/iree/vm/bytecode_disasm.h
rename to runtime/src/iree/vm/bytecode/disassembler.h
index e946df9..0f3dd49 100644
--- a/runtime/src/iree/vm/bytecode_disasm.h
+++ b/runtime/src/iree/vm/bytecode/disassembler.h
@@ -4,23 +4,23 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#ifndef IREE_VM_BYTECODE_DISASM_H_
-#define IREE_VM_BYTECODE_DISASM_H_
+#ifndef IREE_VM_BYTECODE_DISASSEMBLER_H_
+#define IREE_VM_BYTECODE_DISASSEMBLER_H_
#include <stdio.h>
#include "iree/base/string_builder.h"
#include "iree/vm/api.h"
-#include "iree/vm/bytecode_dispatch_util.h"
-#include "iree/vm/bytecode_module_impl.h"
+#include "iree/vm/bytecode/dispatch_util.h"
+#include "iree/vm/bytecode/module_impl.h"
// Controls how bytecode disassembly is formatted.
-typedef enum iree_vm_bytecode_disasm_format_e {
- IREE_VM_BYTECODE_DISASM_FORMAT_DEFAULT = 0,
+typedef enum iree_vm_bytecode_disassembly_format_e {
+ IREE_VM_BYTECODE_DISASSEMBLY_FORMAT_DEFAULT = 0,
// Includes the input register values inline in the op text.
// Example: `%i0 <= ShrI32U %i2(5), %i3(6)`
- IREE_VM_BYTECODE_DISASM_FORMAT_INLINE_VALUES = 1u << 0,
-} iree_vm_bytecode_disasm_format_t;
+ IREE_VM_BYTECODE_DISASSEMBLY_FORMAT_INLINE_VALUES = 1u << 0,
+} iree_vm_bytecode_disassembly_format_t;
// Disassembles the bytecode operation at |pc| using the provided module state.
// Appends the disasembled op to |string_builder| in a format based on |format|.
@@ -31,16 +31,15 @@
// WARNING: this does not currently perform any verification on the bytecode;
// it's assumed all bytecode is valid. This is a debug tool: you shouldn't be
// running this in production on untrusted inputs anyway.
-iree_status_t iree_vm_bytecode_disasm_op(
+iree_status_t iree_vm_bytecode_disassemble_op(
iree_vm_bytecode_module_t* module,
iree_vm_bytecode_module_state_t* module_state, uint16_t function_ordinal,
iree_vm_source_offset_t pc, const iree_vm_registers_t* regs,
- iree_vm_bytecode_disasm_format_t format,
+ iree_vm_bytecode_disassembly_format_t format,
iree_string_builder_t* string_builder);
-iree_status_t iree_vm_bytecode_trace_disasm(iree_vm_stack_frame_t* frame,
- iree_vm_source_offset_t pc,
- const iree_vm_registers_t* regs,
- FILE* file);
+iree_status_t iree_vm_bytecode_trace_disassembly(
+ iree_vm_stack_frame_t* frame, iree_vm_source_offset_t pc,
+ const iree_vm_registers_t* regs, FILE* file);
-#endif // IREE_VM_BYTECODE_DISASM_H_
+#endif // IREE_VM_BYTECODE_DISASSEMBLER_H_
diff --git a/runtime/src/iree/vm/bytecode_dispatch.c b/runtime/src/iree/vm/bytecode/dispatch.c
similarity index 99%
rename from runtime/src/iree/vm/bytecode_dispatch.c
rename to runtime/src/iree/vm/bytecode/dispatch.c
index a271e21..5e2dbea 100644
--- a/runtime/src/iree/vm/bytecode_dispatch.c
+++ b/runtime/src/iree/vm/bytecode/dispatch.c
@@ -11,9 +11,9 @@
#include "iree/base/api.h"
#include "iree/base/internal/math.h"
#include "iree/vm/api.h"
-#include "iree/vm/bytecode_disasm.h"
-#include "iree/vm/bytecode_dispatch_util.h"
-#include "iree/vm/bytecode_module_impl.h"
+#include "iree/vm/bytecode/disassembler.h"
+#include "iree/vm/bytecode/dispatch_util.h"
+#include "iree/vm/bytecode/module_impl.h"
#include "iree/vm/ops.h"
//===----------------------------------------------------------------------===//
diff --git a/runtime/src/iree/vm/bytecode_dispatch_async_test.cc b/runtime/src/iree/vm/bytecode/dispatch_async_test.cc
similarity index 98%
rename from runtime/src/iree/vm/bytecode_dispatch_async_test.cc
rename to runtime/src/iree/vm/bytecode/dispatch_async_test.cc
index 444f003..9858e49 100644
--- a/runtime/src/iree/vm/bytecode_dispatch_async_test.cc
+++ b/runtime/src/iree/vm/bytecode/dispatch_async_test.cc
@@ -14,7 +14,7 @@
#include "iree/testing/gtest.h"
#include "iree/testing/status_matchers.h"
#include "iree/vm/api.h"
-#include "iree/vm/bytecode_module.h"
+#include "iree/vm/bytecode/module.h"
// Compiled module embedded here to avoid file IO:
#include "iree/vm/test/async_bytecode_modules.h"
diff --git a/runtime/src/iree/vm/bytecode_dispatch_test.cc b/runtime/src/iree/vm/bytecode/dispatch_test.cc
similarity index 98%
rename from runtime/src/iree/vm/bytecode_dispatch_test.cc
rename to runtime/src/iree/vm/bytecode/dispatch_test.cc
index 75d9984..c47df1b 100644
--- a/runtime/src/iree/vm/bytecode_dispatch_test.cc
+++ b/runtime/src/iree/vm/bytecode/dispatch_test.cc
@@ -13,7 +13,7 @@
#include "iree/base/api.h"
#include "iree/testing/gtest.h"
#include "iree/vm/api.h"
-#include "iree/vm/bytecode_module.h"
+#include "iree/vm/bytecode/module.h"
// Compiled module embedded here to avoid file IO:
#include "iree/vm/test/all_bytecode_modules.h"
diff --git a/runtime/src/iree/vm/bytecode_dispatch_util.h b/runtime/src/iree/vm/bytecode/dispatch_util.h
similarity index 97%
rename from runtime/src/iree/vm/bytecode_dispatch_util.h
rename to runtime/src/iree/vm/bytecode/dispatch_util.h
index 2144769..503a372 100644
--- a/runtime/src/iree/vm/bytecode_dispatch_util.h
+++ b/runtime/src/iree/vm/bytecode/dispatch_util.h
@@ -13,8 +13,8 @@
#include "iree/base/alignment.h"
#include "iree/base/config.h"
#include "iree/base/target_platform.h"
-#include "iree/vm/bytecode_module_impl.h"
-#include "iree/vm/generated/bytecode_op_table.h"
+#include "iree/vm/bytecode/generated/op_table.h"
+#include "iree/vm/bytecode/module_impl.h"
//===----------------------------------------------------------------------===//
// Shared data structures
@@ -130,10 +130,10 @@
#endif // IREE_VM_EXECUTION_TRACING_FORCE_ENABLE
#if IREE_VM_EXECUTION_TRACING_ENABLE
-#define IREE_DISPATCH_TRACE_INSTRUCTION(pc_offset, op_name) \
- if (IREE_IS_DISPATCH_TRACING_ENABLED()) { \
- IREE_RETURN_IF_ERROR(iree_vm_bytecode_trace_disasm( \
- current_frame, (pc - (pc_offset)), ®s, stderr)); \
+#define IREE_DISPATCH_TRACE_INSTRUCTION(pc_offset, op_name) \
+ if (IREE_IS_DISPATCH_TRACING_ENABLED()) { \
+ IREE_RETURN_IF_ERROR(iree_vm_bytecode_trace_disassembly( \
+ current_frame, (pc - (pc_offset)), ®s, stderr)); \
}
#else
diff --git a/runtime/src/iree/vm/generated/.clang-format b/runtime/src/iree/vm/bytecode/generated/.clang-format
similarity index 100%
rename from runtime/src/iree/vm/generated/.clang-format
rename to runtime/src/iree/vm/bytecode/generated/.clang-format
diff --git a/runtime/src/iree/vm/generated/bytecode_op_table.h b/runtime/src/iree/vm/bytecode/generated/op_table.h
similarity index 100%
rename from runtime/src/iree/vm/generated/bytecode_op_table.h
rename to runtime/src/iree/vm/bytecode/generated/op_table.h
diff --git a/runtime/src/iree/vm/bytecode_module.c b/runtime/src/iree/vm/bytecode/module.c
similarity index 99%
rename from runtime/src/iree/vm/bytecode_module.c
rename to runtime/src/iree/vm/bytecode/module.c
index ec5d091..b122f73 100644
--- a/runtime/src/iree/vm/bytecode_module.c
+++ b/runtime/src/iree/vm/bytecode/module.c
@@ -4,7 +4,7 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#include "iree/vm/bytecode_module.h"
+#include "iree/vm/bytecode/module.h"
#include <stdbool.h>
#include <stdint.h>
@@ -13,7 +13,7 @@
#include "iree/base/api.h"
#include "iree/base/tracing.h"
#include "iree/vm/api.h"
-#include "iree/vm/bytecode_module_impl.h"
+#include "iree/vm/bytecode/module_impl.h"
// Alignment applied to each segment of the archive.
// All embedded file contents (FlatBuffers, rodata, etc) are aligned to this
diff --git a/runtime/src/iree/vm/bytecode_module.h b/runtime/src/iree/vm/bytecode/module.h
similarity index 100%
rename from runtime/src/iree/vm/bytecode_module.h
rename to runtime/src/iree/vm/bytecode/module.h
diff --git a/runtime/src/iree/vm/bytecode_module_benchmark.cc b/runtime/src/iree/vm/bytecode/module_benchmark.cc
similarity index 98%
rename from runtime/src/iree/vm/bytecode_module_benchmark.cc
rename to runtime/src/iree/vm/bytecode/module_benchmark.cc
index 620a4fb..3069fb5 100644
--- a/runtime/src/iree/vm/bytecode_module_benchmark.cc
+++ b/runtime/src/iree/vm/bytecode/module_benchmark.cc
@@ -10,8 +10,8 @@
#include "benchmark/benchmark.h"
#include "iree/base/api.h"
#include "iree/vm/api.h"
-#include "iree/vm/bytecode_module.h"
-#include "iree/vm/bytecode_module_benchmark_module_c.h"
+#include "iree/vm/bytecode/module.h"
+#include "iree/vm/bytecode/module_benchmark_module_c.h"
namespace {
diff --git a/runtime/src/iree/vm/bytecode_module_benchmark.mlir b/runtime/src/iree/vm/bytecode/module_benchmark.mlir
similarity index 100%
rename from runtime/src/iree/vm/bytecode_module_benchmark.mlir
rename to runtime/src/iree/vm/bytecode/module_benchmark.mlir
diff --git a/runtime/src/iree/vm/bytecode_module_impl.h b/runtime/src/iree/vm/bytecode/module_impl.h
similarity index 100%
rename from runtime/src/iree/vm/bytecode_module_impl.h
rename to runtime/src/iree/vm/bytecode/module_impl.h
diff --git a/runtime/src/iree/vm/bytecode_module_size_benchmark.cc b/runtime/src/iree/vm/bytecode/module_size_benchmark.cc
similarity index 93%
rename from runtime/src/iree/vm/bytecode_module_size_benchmark.cc
rename to runtime/src/iree/vm/bytecode/module_size_benchmark.cc
index af5c16e..5aa2fb7 100644
--- a/runtime/src/iree/vm/bytecode_module_size_benchmark.cc
+++ b/runtime/src/iree/vm/bytecode/module_size_benchmark.cc
@@ -6,8 +6,8 @@
#include "iree/base/api.h"
#include "iree/vm/api.h"
-#include "iree/vm/bytecode_module.h"
-#include "iree/vm/bytecode_module_size_benchmark_module_c.h"
+#include "iree/vm/bytecode/module.h"
+#include "iree/vm/bytecode/module_size_benchmark_module_c.h"
extern "C" int main(int argc, char** argv) {
iree_vm_instance_t* instance = nullptr;
diff --git a/runtime/src/iree/vm/bytecode_module_size_benchmark.mlir b/runtime/src/iree/vm/bytecode/module_size_benchmark.mlir
similarity index 100%
rename from runtime/src/iree/vm/bytecode_module_size_benchmark.mlir
rename to runtime/src/iree/vm/bytecode/module_size_benchmark.mlir
diff --git a/runtime/src/iree/vm/bytecode_module_test.cc b/runtime/src/iree/vm/bytecode/module_test.cc
similarity index 98%
rename from runtime/src/iree/vm/bytecode_module_test.cc
rename to runtime/src/iree/vm/bytecode/module_test.cc
index 9b964cd..270dfc1 100644
--- a/runtime/src/iree/vm/bytecode_module_test.cc
+++ b/runtime/src/iree/vm/bytecode/module_test.cc
@@ -8,7 +8,7 @@
// This means mostly just FlatBuffer verification, module interface functions,
// etc. bytecode_dispatch_test.cc covers actual dispatch.
-#include "iree/vm/bytecode_module.h"
+#include "iree/vm/bytecode/module.h"
#include <memory>
#include <vector>
@@ -17,7 +17,7 @@
#include "iree/testing/gtest.h"
#include "iree/testing/status_matchers.h"
#include "iree/vm/api.h"
-#include "iree/vm/bytecode_module_test_module_c.h"
+#include "iree/vm/bytecode/module_test_module_c.h"
static bool operator==(const iree_vm_value_t& lhs,
const iree_vm_value_t& rhs) noexcept {
diff --git a/runtime/src/iree/vm/bytecode_module_test.mlir b/runtime/src/iree/vm/bytecode/module_test.mlir
similarity index 100%
rename from runtime/src/iree/vm/bytecode_module_test.mlir
rename to runtime/src/iree/vm/bytecode/module_test.mlir
diff --git a/runtime/src/iree/vm/test/async_ops.mlir b/runtime/src/iree/vm/test/async_ops.mlir
index fd3aa65..92da41e 100644
--- a/runtime/src/iree/vm/test/async_ops.mlir
+++ b/runtime/src/iree/vm/test/async_ops.mlir
@@ -1,4 +1,4 @@
-// Tested by iree/vm/bytecode_dispatch_async_test.cc.
+// Tested by iree/vm/bytecode/dispatch_async_test.cc.
//
// NOTE: we don't want to rely on vm.check.* and the main runner here for
// testing as it makes it hard to test failure cases; a test that doesn't run
diff --git a/samples/custom_module/basic/main.c b/samples/custom_module/basic/main.c
index 7585033..557a235 100644
--- a/samples/custom_module/basic/main.c
+++ b/samples/custom_module/basic/main.c
@@ -12,7 +12,7 @@
// uses base VM types.
#include "iree/base/api.h"
#include "iree/vm/api.h"
-#include "iree/vm/bytecode_module.h"
+#include "iree/vm/bytecode/module.h"
// HACK: this pokes in to private APIs for IO helpers while we expect
// applications to bring their own IO.
diff --git a/samples/simple_embedding/BUILD b/samples/simple_embedding/BUILD
index 95c7d10..1d8973a 100644
--- a/samples/simple_embedding/BUILD
+++ b/samples/simple_embedding/BUILD
@@ -37,7 +37,7 @@
"//runtime/src/iree/hal/local/loaders:vmvx_module_loader",
"//runtime/src/iree/modules/hal",
"//runtime/src/iree/vm",
- "//runtime/src/iree/vm:bytecode_module",
+ "//runtime/src/iree/vm/bytecode:module",
],
)
@@ -89,7 +89,7 @@
"//runtime/src/iree/hal/local/loaders:embedded_elf_loader",
"//runtime/src/iree/modules/hal",
"//runtime/src/iree/vm",
- "//runtime/src/iree/vm:bytecode_module",
+ "//runtime/src/iree/vm/bytecode:module",
],
)
@@ -196,7 +196,7 @@
"//runtime/src/iree/modules/hal",
"//runtime/src/iree/task:api",
"//runtime/src/iree/vm",
- "//runtime/src/iree/vm:bytecode_module",
+ "//runtime/src/iree/vm/bytecode:module",
],
)
@@ -235,7 +235,7 @@
"//runtime/src/iree/hal/drivers/vulkan/registration",
"//runtime/src/iree/modules/hal",
"//runtime/src/iree/vm",
- "//runtime/src/iree/vm:bytecode_module",
+ "//runtime/src/iree/vm/bytecode:module",
],
)
@@ -287,7 +287,7 @@
# "//runtime/src/iree/hal/drivers/cuda/registration",
# "//runtime/src/iree/modules/hal",
# "//runtime/src/iree/vm",
-# "//runtime/src/iree/vm:bytecode_module",
+# "//runtime/src/iree/vm/bytecode:module",
# ],
# )
diff --git a/samples/simple_embedding/CMakeLists.txt b/samples/simple_embedding/CMakeLists.txt
index 5ff7ba3..715eb8e 100644
--- a/samples/simple_embedding/CMakeLists.txt
+++ b/samples/simple_embedding/CMakeLists.txt
@@ -28,7 +28,7 @@
iree::hal::local::loaders::vmvx_module_loader
iree::modules::hal
iree::vm
- iree::vm::bytecode_module
+ iree::vm::bytecode::module
)
iree_bytecode_module(
@@ -74,7 +74,7 @@
iree::hal::local::loaders::embedded_elf_loader
iree::modules::hal
iree::vm
- iree::vm::bytecode_module
+ iree::vm::bytecode::module
)
iree_bytecode_module(
@@ -192,7 +192,7 @@
iree::modules::hal
iree::task::api
iree::vm
- iree::vm::bytecode_module
+ iree::vm::bytecode::module
)
iree_native_test(
@@ -222,7 +222,7 @@
iree::hal::drivers::vulkan::registration
iree::modules::hal
iree::vm
- iree::vm::bytecode_module
+ iree::vm::bytecode::module
)
iree_bytecode_module(
diff --git a/samples/simple_embedding/simple_embedding.c b/samples/simple_embedding/simple_embedding.c
index d7585e0..3fa0c87 100644
--- a/samples/simple_embedding/simple_embedding.c
+++ b/samples/simple_embedding/simple_embedding.c
@@ -18,7 +18,7 @@
#include "iree/hal/api.h"
#include "iree/modules/hal/module.h"
#include "iree/vm/api.h"
-#include "iree/vm/bytecode_module.h"
+#include "iree/vm/bytecode/module.h"
// A function to create the HAL device from the different backend targets.
// The HAL device is returned based on the implementation, and it must be
diff --git a/samples/static_library/create_bytecode_module.c b/samples/static_library/create_bytecode_module.c
index b7b6b21..8691201 100644
--- a/samples/static_library/create_bytecode_module.c
+++ b/samples/static_library/create_bytecode_module.c
@@ -5,7 +5,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include <stdio.h>
-#include "iree/vm/bytecode_module.h"
+#include "iree/vm/bytecode/module.h"
#include "samples/static_library/simple_mul_c.h"
// A function to create the bytecode module.
diff --git a/tools/BUILD b/tools/BUILD
index 03b4fe9..a6bdb90 100644
--- a/tools/BUILD
+++ b/tools/BUILD
@@ -75,7 +75,7 @@
"//runtime/src/iree/tooling:device_util",
"//runtime/src/iree/tooling:vm_util",
"//runtime/src/iree/vm",
- "//runtime/src/iree/vm:bytecode_module",
+ "//runtime/src/iree/vm/bytecode:module",
],
)
@@ -99,7 +99,7 @@
"//runtime/src/iree/base/internal:file_io",
"//runtime/src/iree/base/internal/flatcc:debugging",
"//runtime/src/iree/schemas:bytecode_module_def_c_fbs",
- "//runtime/src/iree/vm:bytecode_module",
+ "//runtime/src/iree/vm/bytecode:module",
],
)
@@ -143,7 +143,7 @@
"//runtime/src/iree/tooling:device_util",
"//runtime/src/iree/tooling:vm_util",
"//runtime/src/iree/vm",
- "//runtime/src/iree/vm:bytecode_module",
+ "//runtime/src/iree/vm/bytecode:module",
"@llvm-project//llvm:Support",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:LLVMToLLVMIRTranslation",
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 01111d2..7d37b6c 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -96,7 +96,7 @@
iree::tooling::device_util
iree::tooling::vm_util
iree::vm
- iree::vm::bytecode_module
+ iree::vm::bytecode::module
TESTONLY
)
@@ -125,7 +125,7 @@
iree::base::internal::file_io
iree::base::internal::flatcc::debugging
iree::schemas::bytecode_module_def_c_fbs
- iree::vm::bytecode_module
+ iree::vm::bytecode::module
)
iree_cc_binary(
@@ -281,7 +281,7 @@
iree::tooling::device_util
iree::tooling::vm_util
iree::vm
- iree::vm::bytecode_module
+ iree::vm::bytecode::module
DATA
${IREE_LLD_TARGET}
HOSTONLY
diff --git a/tools/android/run_module_app/src/main.cc b/tools/android/run_module_app/src/main.cc
index 193595e..be97e89 100644
--- a/tools/android/run_module_app/src/main.cc
+++ b/tools/android/run_module_app/src/main.cc
@@ -19,7 +19,7 @@
#include "iree/tooling/device_util.h"
#include "iree/tooling/vm_util.h"
#include "iree/vm/api.h"
-#include "iree/vm/bytecode_module.h"
+#include "iree/vm/bytecode/module.h"
namespace iree {
namespace {
diff --git a/tools/iree-check-module-main.cc b/tools/iree-check-module-main.cc
index c9c1526..82cc04f 100644
--- a/tools/iree-check-module-main.cc
+++ b/tools/iree-check-module-main.cc
@@ -24,7 +24,7 @@
#include "iree/tooling/device_util.h"
#include "iree/tooling/vm_util.h"
#include "iree/vm/api.h"
-#include "iree/vm/bytecode_module.h"
+#include "iree/vm/bytecode/module.h"
IREE_FLAG(
bool, expect_failure, false,
diff --git a/tools/iree-dump-module-main.c b/tools/iree-dump-module-main.c
index c4e7568..9f4a9a0 100644
--- a/tools/iree-dump-module-main.c
+++ b/tools/iree-dump-module-main.c
@@ -9,7 +9,7 @@
#include "iree/base/api.h"
#include "iree/base/internal/file_io.h"
#include "iree/schemas/bytecode_module_def_json_printer.h"
-#include "iree/vm/bytecode_module.h"
+#include "iree/vm/bytecode/module.h"
// Today we just print to JSON. We could do something more useful (size
// analysis, etc), but JSON should be enough.
diff --git a/tools/iree-run-mlir-main.cc b/tools/iree-run-mlir-main.cc
index 96374ee..1a252e8 100644
--- a/tools/iree-run-mlir-main.cc
+++ b/tools/iree-run-mlir-main.cc
@@ -54,7 +54,7 @@
#include "iree/tooling/device_util.h"
#include "iree/tooling/vm_util.h"
#include "iree/vm/api.h"
-#include "iree/vm/bytecode_module.h"
+#include "iree/vm/bytecode/module.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"