Switch users of cc_embed_data to c_embed_data. (#5783)
This migrates all uses of `cc_embed_data`, including indirect uses through `iree_bytecode_module`, to `c_embed_data` then deletes `iree_cc_embed_data`.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b2ec58f..ab1326a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -220,7 +220,6 @@
include(iree_cc_test)
include(iree_tablegen_library)
include(iree_tablegen_doc)
-include(iree_cc_embed_data)
include(iree_c_embed_data)
include(iree_bytecode_module)
include(iree_c_module)
diff --git a/bindings/tflite/BUILD b/bindings/tflite/BUILD
index a3d35b6..0060043 100644
--- a/bindings/tflite/BUILD
+++ b/bindings/tflite/BUILD
@@ -73,9 +73,9 @@
# ],
deps = [
":shim",
- "//bindings/tflite/testdata:add_dynamic_cc",
- "//bindings/tflite/testdata:add_multi_cc",
- "//bindings/tflite/testdata:add_static_cc",
+ "//bindings/tflite/testdata:add_dynamic_c",
+ "//bindings/tflite/testdata:add_multi_c",
+ "//bindings/tflite/testdata:add_static_c",
"//iree/testing:gtest",
"//iree/testing:gtest_main",
],
diff --git a/bindings/tflite/CMakeLists.txt b/bindings/tflite/CMakeLists.txt
index 918e48a..1563c8b 100644
--- a/bindings/tflite/CMakeLists.txt
+++ b/bindings/tflite/CMakeLists.txt
@@ -61,9 +61,9 @@
"smoke_test.cc"
DEPS
::shim
- bindings::tflite::testdata::add_dynamic_cc
- bindings::tflite::testdata::add_multi_cc
- bindings::tflite::testdata::add_static_cc
+ bindings::tflite::testdata::add_dynamic_c
+ bindings::tflite::testdata::add_multi_c
+ bindings::tflite::testdata::add_static_c
iree::testing::gtest
iree::testing::gtest_main
)
diff --git a/bindings/tflite/smoke_test.cc b/bindings/tflite/smoke_test.cc
index f26f2e5..835beff 100644
--- a/bindings/tflite/smoke_test.cc
+++ b/bindings/tflite/smoke_test.cc
@@ -33,16 +33,16 @@
// Test model is available both on the filesystem and here for embedding testing
// embedding the module directly in a binary.
-#include "bindings/tflite/testdata/add_dynamic.h"
+#include "bindings/tflite/testdata/add_dynamic_c.h"
#define IREE_BINDINGS_TFLITE_TESTDATA_ADD_DYNAMIC_EMBEDDED_DATA \
- iree::bindings::tflite::testdata::add_dynamic_create()->data
+ iree_tflite_testdata_add_dynamic_create()->data
#define IREE_BINDINGS_TFLITE_TESTDATA_ADD_DYNAMIC_EMBEDDED_SIZE \
- iree::bindings::tflite::testdata::add_dynamic_create()->size
-#include "bindings/tflite/testdata/add_static.h"
+ iree_tflite_testdata_add_dynamic_create()->size
+#include "bindings/tflite/testdata/add_static_c.h"
#define IREE_BINDINGS_TFLITE_TESTDATA_ADD_STATIC_EMBEDDED_DATA \
- iree::bindings::tflite::testdata::add_static_create()->data
+ iree_tflite_testdata_add_static_create()->data
#define IREE_BINDINGS_TFLITE_TESTDATA_ADD_STATIC_EMBEDDED_SIZE \
- iree::bindings::tflite::testdata::add_static_create()->size
+ iree_tflite_testdata_add_static_create()->size
// TODO(#3971): currently can't nicely load these due to cmake issues.
#define IREE_BINDINGS_TFLITE_TESTDATA_ADD_STATIC_PATH \
diff --git a/bindings/tflite/testdata/BUILD b/bindings/tflite/testdata/BUILD
index b3f5e6b..8c38e4c 100644
--- a/bindings/tflite/testdata/BUILD
+++ b/bindings/tflite/testdata/BUILD
@@ -24,7 +24,7 @@
name = "add_dynamic",
testonly = True,
src = "add_dynamic.mlir",
- cc_namespace = "iree::bindings::tflite::testdata",
+ c_identifier = "iree_tflite_testdata_add_dynamic",
flags = [
"-iree-native-bindings-support=false",
"-iree-tflite-bindings-support",
@@ -37,7 +37,7 @@
name = "add_multi",
testonly = True,
src = "add_multi.mlir",
- cc_namespace = "iree::bindings::tflite::testdata",
+ c_identifier = "iree_tflite_testdata_add_multi",
flags = [
"-iree-native-bindings-support=false",
"-iree-tflite-bindings-support",
@@ -50,7 +50,7 @@
name = "add_static",
testonly = True,
src = "add_static.mlir",
- cc_namespace = "iree::bindings::tflite::testdata",
+ c_identifier = "iree_tflite_testdata_add_static",
flags = [
"-iree-native-bindings-support=false",
"-iree-tflite-bindings-support",
diff --git a/bindings/tflite/testdata/CMakeLists.txt b/bindings/tflite/testdata/CMakeLists.txt
index c348838..0253cc8 100644
--- a/bindings/tflite/testdata/CMakeLists.txt
+++ b/bindings/tflite/testdata/CMakeLists.txt
@@ -23,8 +23,8 @@
add_dynamic
SRC
"add_dynamic.mlir"
- CC_NAMESPACE
- "iree::bindings::tflite::testdata"
+ C_IDENTIFIER
+ "iree_tflite_testdata_add_dynamic"
FLAGS
"-iree-native-bindings-support=false"
"-iree-tflite-bindings-support"
@@ -39,8 +39,8 @@
add_multi
SRC
"add_multi.mlir"
- CC_NAMESPACE
- "iree::bindings::tflite::testdata"
+ C_IDENTIFIER
+ "iree_tflite_testdata_add_multi"
FLAGS
"-iree-native-bindings-support=false"
"-iree-tflite-bindings-support"
@@ -55,8 +55,8 @@
add_static
SRC
"add_static.mlir"
- CC_NAMESPACE
- "iree::bindings::tflite::testdata"
+ C_IDENTIFIER
+ "iree_tflite_testdata_add_static"
FLAGS
"-iree-native-bindings-support=false"
"-iree-tflite-bindings-support"
diff --git a/build_tools/bazel_to_cmake/bazel_to_cmake_converter.py b/build_tools/bazel_to_cmake/bazel_to_cmake_converter.py
index cda1073..9616447 100644
--- a/build_tools/bazel_to_cmake/bazel_to_cmake_converter.py
+++ b/build_tools/bazel_to_cmake/bazel_to_cmake_converter.py
@@ -425,40 +425,6 @@
# Effectively an alias in IREE code.
iree_cc_binary = cc_binary
- def cc_embed_data(self,
- name,
- srcs,
- cc_file_output,
- h_file_output,
- testonly=None,
- cpp_namespace=None,
- strip_prefix=None,
- flatten=None,
- identifier=None,
- **kwargs):
- if identifier:
- self._convert_unimplemented_function("cc_embed_data",
- name + " has identifier")
- name_block = _convert_string_arg_block("NAME", name, quote=False)
- srcs_block = _convert_srcs_block(srcs)
- cc_file_output_block = _convert_string_arg_block("CC_FILE_OUTPUT",
- cc_file_output)
- h_file_output_block = _convert_string_arg_block("H_FILE_OUTPUT",
- h_file_output)
- testonly_block = _convert_option_block("TESTONLY", testonly)
- namespace_block = _convert_string_arg_block("CPP_NAMESPACE", cpp_namespace)
- flatten_block = _convert_option_block("FLATTEN", flatten)
-
- self.converter.body += (f"iree_cc_embed_data(\n"
- f"{name_block}"
- f"{srcs_block}"
- f"{cc_file_output_block}"
- f"{h_file_output_block}"
- f"{testonly_block}"
- f"{namespace_block}"
- f"{flatten_block}"
- f" PUBLIC\n)\n\n")
-
def c_embed_data(self,
name,
srcs,
@@ -469,9 +435,6 @@
flatten=None,
identifier=None,
**kwargs):
- if identifier:
- self._convert_unimplemented_function("c_embed_data",
- name + " has identifier")
name_block = _convert_string_arg_block("NAME", name, quote=False)
srcs_block = _convert_srcs_block(srcs)
c_file_output_block = _convert_string_arg_block("C_FILE_OUTPUT",
@@ -479,6 +442,7 @@
h_file_output_block = _convert_string_arg_block("H_FILE_OUTPUT",
h_file_output)
testonly_block = _convert_option_block("TESTONLY", testonly)
+ identifier_block = _convert_string_arg_block("IDENTIFIER", identifier)
flatten_block = _convert_option_block("FLATTEN", flatten)
self.converter.body += (f"iree_c_embed_data(\n"
@@ -486,6 +450,7 @@
f"{srcs_block}"
f"{c_file_output_block}"
f"{h_file_output_block}"
+ f"{identifier_block}"
f"{testonly_block}"
f"{flatten_block}"
f" PUBLIC\n)\n\n")
@@ -504,13 +469,11 @@
src,
flags=None,
translate_tool=None,
- cc_namespace=None,
- c_output=None,
+ c_identifier=None,
testonly=None):
name_block = _convert_string_arg_block("NAME", name, quote=False)
src_block = _convert_string_arg_block("SRC", src)
- namespace_block = _convert_string_arg_block("CC_NAMESPACE", cc_namespace)
- c_output_block = _convert_option_block("C_OUTPUT", c_output)
+ c_identifier_block = _convert_string_arg_block("C_IDENTIFIER", c_identifier)
translate_tool_block = _convert_translate_tool_block(translate_tool)
flags_block = _convert_string_list_block("FLAGS", flags)
testonly_block = _convert_option_block("TESTONLY", testonly)
@@ -518,8 +481,7 @@
self.converter.body += (f"iree_bytecode_module(\n"
f"{name_block}"
f"{src_block}"
- f"{namespace_block}"
- f"{c_output_block}"
+ f"{c_identifier_block}"
f"{translate_tool_block}"
f"{flags_block}"
f"{testonly_block}"
diff --git a/build_tools/cmake/iree_bytecode_module.cmake b/build_tools/cmake/iree_bytecode_module.cmake
index e297083..82f467d 100644
--- a/build_tools/cmake/iree_bytecode_module.cmake
+++ b/build_tools/cmake/iree_bytecode_module.cmake
@@ -25,8 +25,8 @@
# default flag set is "-iree-mlir-to-vm-bytecode-module".
# TRANSLATE_TOOL: Translation tool to invoke (CMake target). The default
# tool is "iree-translate".
-# CC_NAMESPACE: Wraps everything in a C++ namespace.
-# C_OUTPUT: Control flag to generate c embed code instead.
+# C_IDENTIFIER: Identifier to use for generate c embed code.
+# If omitted then no C embed code will be generated.
# PUBLIC: Add this so that this library will be exported under ${PACKAGE}::
# Also in IDE, target will appear in ${PACKAGE} folder while non PUBLIC
# will be in ${PACKAGE}/internal.
@@ -40,8 +40,8 @@
function(iree_bytecode_module)
cmake_parse_arguments(
_RULE
- "PUBLIC;TESTONLY;C_OUTPUT"
- "NAME;SRC;TRANSLATE_TOOL;CC_NAMESPACE"
+ "PUBLIC;TESTONLY"
+ "NAME;SRC;TRANSLATE_TOOL;C_IDENTIFIER"
"FLAGS"
${ARGN}
)
@@ -86,32 +86,12 @@
set(_PUBLIC_ARG "PUBLIC")
endif()
- if(DEFINED _RULE_CC_NAMESPACE)
- iree_cc_embed_data(
- NAME
- "${_RULE_NAME}_cc"
- IDENTIFIER
- "${_RULE_NAME}"
- GENERATED_SRCS
- "${_RULE_NAME}.vmfb"
- CC_FILE_OUTPUT
- "${_RULE_NAME}.cc"
- H_FILE_OUTPUT
- "${_RULE_NAME}.h"
- CPP_NAMESPACE
- "${_RULE_CC_NAMESPACE}"
- FLATTEN
- "${_PUBLIC_ARG}"
- "${_TESTONLY_ARG}"
- )
- endif()
-
- if(_RULE_C_OUTPUT)
+ if(_RULE_C_IDENTIFIER)
iree_c_embed_data(
NAME
"${_RULE_NAME}_c"
IDENTIFIER
- "${_RULE_NAME}_c"
+ "${_RULE_C_IDENTIFIER}"
GENERATED_SRCS
"${_RULE_NAME}.vmfb"
C_FILE_OUTPUT
diff --git a/build_tools/cmake/iree_cc_embed_data.cmake b/build_tools/cmake/iree_cc_embed_data.cmake
deleted file mode 100644
index 893c2e9..0000000
--- a/build_tools/cmake/iree_cc_embed_data.cmake
+++ /dev/null
@@ -1,105 +0,0 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-include(CMakeParseArguments)
-
-# iree_cc_embed_data()
-#
-# CMake function to imitate Bazel's cc_embed_data rule.
-#
-# Parameters:
-# NAME: Name of target (see Note).
-# SRCS: List of source files to embed.
-# GENERATED_SRCS: List of generated source files to embed.
-# CC_FILE_OUTPUT: The CC implementation file to output.
-# H_FILE_OUTPUT: The H header file to output.
-# CPP_NAMESPACE: Wraps everything in a C++ namespace.
-# STRIP_PREFIX: Strips this verbatim prefix from filenames (in the TOC).
-# FLATTEN: Removes all directory components from filenames (in the TOC).
-# IDENTIFIER: The identifier to use in generated names (defaults to name).
-# PUBLIC: Add this so that this library will be exported under ${PACKAGE}::
-# Also in IDE, target will appear in ${PACKAGE} folder while non PUBLIC will be
-# in ${PACKAGE}/internal.
-# TESTONLY: When added, this target will only be built if user passes
-# -DIREE_BUILD_TESTS=ON to CMake.
-# TODO(scotttodd): Support passing KWARGS down into iree_cc_library?
-#
-# Note:
-# By default, iree_cc_embed_data will always create a library named ${NAME},
-# and alias target iree::${NAME}. The iree:: form should always be used.
-# This is to reduce namespace pollution.
-function(iree_cc_embed_data)
- cmake_parse_arguments(
- _RULE
- "PUBLIC;TESTONLY;FLATTEN"
- "NAME;IDENTIFIER;STRIP_PREFIX;CC_FILE_OUTPUT;H_FILE_OUTPUT;CPP_NAMESPACE"
- "SRCS;GENERATED_SRCS"
- ${ARGN}
- )
-
- if(_RULE_TESTONLY AND NOT IREE_BUILD_TESTS)
- return()
- endif()
-
- if(DEFINED _RULE_IDENTIFIER)
- set(_IDENTIFIER ${_RULE_IDENTIFIER})
- else()
- set(_IDENTIFIER ${_RULE_NAME})
- endif()
-
- set(_ARGS)
- list(APPEND _ARGS "--output_header=${_RULE_H_FILE_OUTPUT}")
- list(APPEND _ARGS "--output_impl=${_RULE_CC_FILE_OUTPUT}")
- list(APPEND _ARGS "--identifier=${_IDENTIFIER}")
- list(APPEND _ARGS "--c_output=false")
- if(DEFINED _RULE_CPP_NAMESPACE)
- list(APPEND _ARGS "--cpp_namespace=${_RULE_CPP_NAMESPACE}")
- endif()
- if(DEFINED _RULE_STRIP_PREFIX})
- list(APPEND _ARGS "--strip_prefix=${_RULE_STRIP_PREFIX}")
- endif()
- if(DEFINED _RULE_FLATTEN})
- list(APPEND _ARGS "--flatten")
- endif()
-
- foreach(SRC ${_RULE_SRCS})
- list(APPEND _ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${SRC}")
- endforeach(SRC)
- foreach(SRC ${_RULE_GENERATED_SRCS})
- list(APPEND _ARGS "${SRC}")
- endforeach(SRC)
-
- iree_get_executable_path(_EXE_PATH generate_embed_data)
-
- add_custom_command(
- OUTPUT "${_RULE_H_FILE_OUTPUT}" "${_RULE_CC_FILE_OUTPUT}"
- COMMAND ${_EXE_PATH} ${_ARGS}
- DEPENDS ${_EXE_PATH} ${_RULE_SRCS} ${_RULE_GENERATED_SRCS}
- )
-
- if(_RULE_TESTONLY)
- set(_TESTONLY_ARG "TESTONLY")
- endif()
- if(_RULE_PUBLIC)
- set(_PUBLIC_ARG "PUBLIC")
- endif()
-
- iree_cc_library(
- NAME ${_RULE_NAME}
- HDRS "${_RULE_H_FILE_OUTPUT}"
- SRCS "${_RULE_CC_FILE_OUTPUT}"
- "${_PUBLIC_ARG}"
- "${_TESTONLY_ARG}"
- )
-endfunction()
diff --git a/build_tools/embed_data/BUILD b/build_tools/embed_data/BUILD
index 0e34c38..484d3d6 100644
--- a/build_tools/embed_data/BUILD
+++ b/build_tools/embed_data/BUILD
@@ -14,7 +14,7 @@
# Generates source files with embedded file contents.
-load(":build_defs.bzl", "c_embed_data", "cc_embed_data")
+load(":build_defs.bzl", "c_embed_data")
package(
default_visibility = ["//visibility:public"],
@@ -32,58 +32,34 @@
],
)
-cc_embed_data(
+c_embed_data(
name = "testembed1",
# do not sort
srcs = [
"file1.bin",
"data/file2.bin",
],
- cc_file_output = "testembed1.cc",
- cpp_namespace = "foobar",
+ c_file_output = "testembed1.c",
flatten = True,
h_file_output = "testembed1.h",
)
-cc_embed_data(
+c_embed_data(
name = "testembed2",
srcs = [
"data/file3.bin",
],
- cc_file_output = "testembed2.cc",
- cpp_namespace = "foobar",
+ c_file_output = "testembed2.c",
flatten = True,
h_file_output = "testembed2.h",
)
cc_test(
- name = "cc_embed_data_test",
- srcs = ["cc_embed_data_test.cc"],
- deps = [
- ":testembed1",
- ":testembed2",
- "//iree/testing:gtest",
- "//iree/testing:gtest_main",
- ],
-)
-
-c_embed_data(
- name = "testembed1_c",
- # do not sort
- srcs = [
- "file1.bin",
- "data/file2.bin",
- ],
- c_file_output = "testembed1_c.c",
- flatten = True,
- h_file_output = "testembed1_c.h",
-)
-
-cc_test(
name = "c_embed_data_test",
srcs = ["c_embed_data_test.cc"],
deps = [
- ":testembed1_c",
+ ":testembed1",
+ ":testembed2",
"//iree/testing:gtest",
"//iree/testing:gtest_main",
],
diff --git a/build_tools/embed_data/build_defs.bzl b/build_tools/embed_data/build_defs.bzl
index 59c6e91..1eb16af 100644
--- a/build_tools/embed_data/build_defs.bzl
+++ b/build_tools/embed_data/build_defs.bzl
@@ -12,86 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-"""Embeds data files into a C or C++ module."""
-
-def cc_embed_data(
- name,
- srcs,
- cc_file_output,
- h_file_output,
- testonly = False,
- cpp_namespace = None,
- strip_prefix = None,
- flatten = False,
- identifier = None,
- **kwargs):
- """Embeds 'srcs' into a C++ module.
-
- Generates a header like:
- namespace iree {
- struct iree_file_toc_t {
- const char* name; // the file's original name
- const char* data; // beginning of the file
- size_t size; // length of the file
- };
- }
- namespace foo {
- extern const struct ::iree::iree_file_toc_t* this_rule_name_create();
- }
-
- The 'this_rule_name()' function will return an array of iree_file_toc_t
- structs terminated by one that has nullptr 'name' and 'data' fields.
- The 'data' field always has an extra null terminator at the end (which
- is not included in the size).
-
- Args:
- name: The rule name, which will also be the identifier of the generated
- code symbol.
- srcs: List of files to embed.
- cc_file_output: The CC implementation file to output.
- h_file_output: The H header file to output.
- testonly: If True, only testonly targets can depend on this target.
- cpp_namespace: Wraps everything in a C++ namespace.
- strip_prefix: Strips this verbatim prefix from filenames (in the TOC).
- flatten: Removes all directory components from filenames (in the TOC).
- identifier: The identifier to use in generated names (defaults to name).
- **kwargs: Args to pass to the cc_library.
- """
- generator = "//build_tools/embed_data:generate_embed_data"
- generator_location = "$(location %s)" % generator
- if identifier == None:
- identifier = name
- flags = "--output_header='$(location %s)' --output_impl='$(location %s)'" % (
- h_file_output,
- cc_file_output,
- )
- flags += " --identifier='%s'" % (identifier,)
- flags += " --c_output=false"
- if cpp_namespace != None:
- flags += " --cpp_namespace='%s'" % (cpp_namespace,)
- if strip_prefix != None:
- flags += " --strip_prefix='%s'" % (strip_prefix,)
- if flatten:
- flags += " --flatten"
-
- native.genrule(
- name = name + "__generator",
- srcs = srcs,
- outs = [
- cc_file_output,
- h_file_output,
- ],
- tools = [generator],
- cmd = "%s $(SRCS) %s" % (generator_location, flags),
- testonly = testonly,
- )
- native.cc_library(
- name = name,
- hdrs = [h_file_output],
- srcs = [cc_file_output],
- testonly = testonly,
- **kwargs
- )
+"""Embeds data files into a C module."""
def c_embed_data(
name,
diff --git a/build_tools/embed_data/c_embed_data_test.cc b/build_tools/embed_data/c_embed_data_test.cc
index 8a8c810..896d5fc 100644
--- a/build_tools/embed_data/c_embed_data_test.cc
+++ b/build_tools/embed_data/c_embed_data_test.cc
@@ -12,31 +12,40 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "build_tools/embed_data/testembed1_c.h"
+#include "build_tools/embed_data/testembed1.h"
+#include "build_tools/embed_data/testembed2.h"
#include "iree/testing/gtest.h"
namespace {
TEST(Generator, TestContents) {
- auto* toc1 = testembed1_c_create();
+ auto* toc1 = testembed1_create();
ASSERT_EQ("file1.bin", std::string(toc1->name));
- ASSERT_EQ(R"(Are you '"Still"' here?)"
+ EXPECT_EQ(R"(Are you '"Still"' here?)"
"\n",
std::string(toc1->data));
- ASSERT_EQ(24, toc1->size);
+ EXPECT_EQ(24, toc1->size);
ASSERT_EQ(0, *(toc1->data + toc1->size));
++toc1;
ASSERT_EQ("file2.bin", std::string(toc1->name));
- ASSERT_EQ(R"(¯\_(ツ)_/¯)"
+ EXPECT_EQ(R"(¯\_(ツ)_/¯)"
"\n",
std::string(toc1->data));
ASSERT_EQ(14, toc1->size);
ASSERT_EQ(0, *(toc1->data + toc1->size));
++toc1;
- ASSERT_EQ(nullptr, toc1->name);
+ EXPECT_EQ(nullptr, toc1->name);
ASSERT_EQ(nullptr, toc1->data);
+
+ auto* toc2 = testembed2_create();
+ ASSERT_EQ("file3.bin", std::string(toc2->name));
+ EXPECT_EQ(R"(ᕕ( ᐛ )ᕗ)"
+ "\n",
+ std::string(toc2->data));
+ EXPECT_EQ(14, toc2->size);
+ ASSERT_EQ(0, *(toc2->data + toc2->size));
}
} // namespace
diff --git a/build_tools/embed_data/cc_embed_data_test.cc b/build_tools/embed_data/cc_embed_data_test.cc
deleted file mode 100644
index 2676f90..0000000
--- a/build_tools/embed_data/cc_embed_data_test.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2019 Google LLC
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "build_tools/embed_data/testembed1.h"
-#include "build_tools/embed_data/testembed2.h"
-#include "iree/testing/gtest.h"
-
-namespace {
-
-TEST(Generator, TestContents) {
- auto* toc1 = ::foobar::testembed1_create();
- ASSERT_EQ("file1.bin", std::string(toc1->name));
- ASSERT_EQ(R"(Are you '"Still"' here?)"
- "\n",
- std::string(toc1->data));
- ASSERT_EQ(24, toc1->size);
- ASSERT_EQ(0, *(toc1->data + toc1->size));
-
- ++toc1;
- ASSERT_EQ("file2.bin", std::string(toc1->name));
- ASSERT_EQ(R"(¯\_(ツ)_/¯)"
- "\n",
- std::string(toc1->data));
- ASSERT_EQ(14, toc1->size);
- ASSERT_EQ(0, *(toc1->data + toc1->size));
-
- ++toc1;
- ASSERT_EQ(nullptr, toc1->name);
- ASSERT_EQ(nullptr, toc1->data);
-
- auto* toc2 = ::foobar::testembed2_create();
- ASSERT_EQ("file3.bin", std::string(toc2->name));
- ASSERT_EQ(R"(ᕕ( ᐛ )ᕗ)"
- "\n",
- std::string(toc2->data));
- ASSERT_EQ(14, toc2->size);
- ASSERT_EQ(0, *(toc2->data + toc2->size));
-}
-
-} // namespace
diff --git a/experimental/bindings/java/com/google/iree/tests/CMakeLists.txt b/experimental/bindings/java/com/google/iree/tests/CMakeLists.txt
index 52e2859..03a9d96 100644
--- a/experimental/bindings/java/com/google/iree/tests/CMakeLists.txt
+++ b/experimental/bindings/java/com/google/iree/tests/CMakeLists.txt
@@ -18,8 +18,8 @@
simple_mul_bytecode_module
SRC
"simple_mul.mlir"
- CC_NAMESPACE
- "iree::java"
+ C_IDENTIFIER
+ "iree_java_testdata_simple_mul_bytecode_module"
FLAGS
"-iree-mlir-to-vm-bytecode-module"
"-iree-hal-target-backends=vmla"
@@ -32,7 +32,7 @@
"integration_test.cc"
DEPS
experimental::bindings::java::com::google::iree::native::cc_wrappers
- experimental::bindings::java::com::google::iree::tests::simple_mul_bytecode_module_cc
+ experimental::bindings::java::com::google::iree::tests::simple_mul_bytecode_module_c
iree::base::status
)
endif()
diff --git a/experimental/bindings/java/com/google/iree/tests/integration_test.cc b/experimental/bindings/java/com/google/iree/tests/integration_test.cc
index e745076..0240f16 100644
--- a/experimental/bindings/java/com/google/iree/tests/integration_test.cc
+++ b/experimental/bindings/java/com/google/iree/tests/integration_test.cc
@@ -18,7 +18,7 @@
#include "experimental/bindings/java/com/google/iree/native/function_wrapper.h"
#include "experimental/bindings/java/com/google/iree/native/instance_wrapper.h"
#include "experimental/bindings/java/com/google/iree/native/module_wrapper.h"
-#include "experimental/bindings/java/com/google/iree/tests/simple_mul_bytecode_module.h"
+#include "experimental/bindings/java/com/google/iree/tests/simple_mul_bytecode_module_c.h"
#include "iree/base/internal/flags.h"
namespace iree {
@@ -35,7 +35,8 @@
IREE_LOG(INFO) << "Instance created";
auto module = std::make_unique<ModuleWrapper>();
- const auto* module_file = simple_mul_bytecode_module_create();
+ const struct iree_file_toc_t* module_file =
+ iree_java_testdata_simple_mul_bytecode_module_create();
auto module_status = module->Create(
reinterpret_cast<const uint8_t*>(module_file->data), module_file->size);
if (!module_status.ok()) {
diff --git a/iree/base/testing/BUILD b/iree/base/testing/BUILD
index 299a3d1..1a330b4 100644
--- a/iree/base/testing/BUILD
+++ b/iree/base/testing/BUILD
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-load("//build_tools/embed_data:build_defs.bzl", "cc_embed_data")
+load("//build_tools/embed_data:build_defs.bzl", "c_embed_data")
package(
default_visibility = ["//visibility:public"],
@@ -27,12 +27,11 @@
linkshared = True,
)
-cc_embed_data(
+c_embed_data(
name = "dynamic_library_test_library",
testonly = True,
srcs = [":dynamic_library_test_library.so"],
- cc_file_output = "dynamic_library_test_library_embed.cc",
- cpp_namespace = "iree",
+ c_file_output = "dynamic_library_test_library_embed.c",
flatten = True,
h_file_output = "dynamic_library_test_library_embed.h",
)
diff --git a/iree/base/testing/CMakeLists.txt b/iree/base/testing/CMakeLists.txt
index 281bbb7..0de059d 100644
--- a/iree/base/testing/CMakeLists.txt
+++ b/iree/base/testing/CMakeLists.txt
@@ -24,18 +24,16 @@
SHARED
)
-iree_cc_embed_data(
+iree_c_embed_data(
NAME
dynamic_library_test_library
GENERATED_SRCS
"$<TARGET_FILE:iree::base::testing::dynamic_library_test_library.so>"
- CC_FILE_OUTPUT
- "dynamic_library_test_library_embed.cc"
+ C_FILE_OUTPUT
+ "dynamic_library_test_library_embed.c"
H_FILE_OUTPUT
"dynamic_library_test_library_embed.h"
TESTONLY
- CPP_NAMESPACE
- "iree"
FLATTEN
PUBLIC
)
diff --git a/iree/base/testing/dynamic_library_test.cc b/iree/base/testing/dynamic_library_test.cc
index 22db908..322a0d1 100644
--- a/iree/base/testing/dynamic_library_test.cc
+++ b/iree/base/testing/dynamic_library_test.cc
@@ -48,8 +48,8 @@
static void SetUpTestCase() {
// Making files available to tests, particularly across operating systems
// and build tools (Bazel/CMake) is complicated. Rather than include a test
- // dynamic library as a "testdata" file, we use cc_embed_data to package
- // the file so it's embedded in a C++ module, then write that embedded file
+ // dynamic library as a "testdata" file, we use c_embed_data to package
+ // the file so it's embedded in a C module, then write that embedded file
// to a platform/test-environment specific temp file for loading.
// System APIs for loading dynamic libraries typically require an extension.
@@ -60,7 +60,8 @@
#endif
library_temp_path_ = GetTempFilename(ext);
- const auto* file_toc = dynamic_library_test_library_create();
+ const struct iree_file_toc_t* file_toc =
+ dynamic_library_test_library_create();
IREE_ASSERT_OK(iree_file_write_contents(
library_temp_path_.c_str(),
iree_make_const_byte_span(file_toc->data, file_toc->size)));
diff --git a/iree/compiler/Dialect/HAL/BUILD b/iree/compiler/Dialect/HAL/BUILD
index 9c40547..97ece2f 100644
--- a/iree/compiler/Dialect/HAL/BUILD
+++ b/iree/compiler/Dialect/HAL/BUILD
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-load("//build_tools/embed_data:build_defs.bzl", "cc_embed_data")
+load("//build_tools/embed_data:build_defs.bzl", "c_embed_data")
package(
default_visibility = ["//visibility:public"],
@@ -20,11 +20,11 @@
licenses = ["notice"], # Apache 2.0
)
-cc_embed_data(
+c_embed_data(
name = "hal_imports",
srcs = ["hal.imports.mlir"],
- cc_file_output = "hal.imports.cc",
- cpp_namespace = "mlir::iree_compiler",
+ c_file_output = "hal.imports.c",
flatten = True,
h_file_output = "hal.imports.h",
+ identifier = "iree_hal_imports",
)
diff --git a/iree/compiler/Dialect/HAL/CMakeLists.txt b/iree/compiler/Dialect/HAL/CMakeLists.txt
index 0cbe615..293e5de 100644
--- a/iree/compiler/Dialect/HAL/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/CMakeLists.txt
@@ -10,17 +10,17 @@
iree_add_all_subdirs()
-iree_cc_embed_data(
+iree_c_embed_data(
NAME
hal_imports
SRCS
"hal.imports.mlir"
- CC_FILE_OUTPUT
- "hal.imports.cc"
+ C_FILE_OUTPUT
+ "hal.imports.c"
H_FILE_OUTPUT
"hal.imports.h"
- CPP_NAMESPACE
- "mlir::iree_compiler"
+ IDENTIFIER
+ "iree_hal_imports"
FLATTEN
PUBLIC
)
diff --git a/iree/compiler/Dialect/HAL/Conversion/HALToVM/ConvertHALToVM.cpp b/iree/compiler/Dialect/HAL/Conversion/HALToVM/ConvertHALToVM.cpp
index c67b0a0..28e17e1 100644
--- a/iree/compiler/Dialect/HAL/Conversion/HALToVM/ConvertHALToVM.cpp
+++ b/iree/compiler/Dialect/HAL/Conversion/HALToVM/ConvertHALToVM.cpp
@@ -124,9 +124,9 @@
std::tie(outerModuleOp, innerModuleOp) =
VMConversionTarget::nestModuleForConversion(getOperation());
- (void)appendImportModule(
- StringRef(hal_imports_create()->data, hal_imports_create()->size),
- innerModuleOp);
+ (void)appendImportModule(StringRef(iree_hal_imports_create()->data,
+ iree_hal_imports_create()->size),
+ innerModuleOp);
OwningRewritePatternList conversionPatterns(&getContext());
populateStandardToVMPatterns(context, typeConverter, conversionPatterns);
diff --git a/iree/compiler/Dialect/HAL/IR/HALDialect.cpp b/iree/compiler/Dialect/HAL/IR/HALDialect.cpp
index b8579be..c1e22b0 100644
--- a/iree/compiler/Dialect/HAL/IR/HALDialect.cpp
+++ b/iree/compiler/Dialect/HAL/IR/HALDialect.cpp
@@ -64,9 +64,9 @@
using VMConversionDialectInterface::VMConversionDialectInterface;
OwningModuleRef parseVMImportModule() const override {
- return mlir::parseSourceString(
- StringRef(hal_imports_create()->data, hal_imports_create()->size),
- getDialect()->getContext());
+ return mlir::parseSourceString(StringRef(iree_hal_imports_create()->data,
+ iree_hal_imports_create()->size),
+ getDialect()->getContext());
}
void populateVMConversionPatterns(
diff --git a/iree/compiler/Dialect/Modules/Check/BUILD b/iree/compiler/Dialect/Modules/Check/BUILD
index e1cf369..30ce4fe 100644
--- a/iree/compiler/Dialect/Modules/Check/BUILD
+++ b/iree/compiler/Dialect/Modules/Check/BUILD
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-load("//build_tools/embed_data:build_defs.bzl", "cc_embed_data")
+load("//build_tools/embed_data:build_defs.bzl", "c_embed_data")
package(
default_visibility = ["//visibility:public"],
@@ -20,11 +20,11 @@
licenses = ["notice"], # Apache 2.0
)
-cc_embed_data(
+c_embed_data(
name = "check_imports",
srcs = ["check.imports.mlir"],
- cc_file_output = "check.imports.cc",
- cpp_namespace = "mlir::iree_compiler::IREE::Check",
+ c_file_output = "check.imports.c",
flatten = True,
h_file_output = "check.imports.h",
+ identifier = "iree_check_imports",
)
diff --git a/iree/compiler/Dialect/Modules/Check/CMakeLists.txt b/iree/compiler/Dialect/Modules/Check/CMakeLists.txt
index a4bdb37..a3efc1c 100644
--- a/iree/compiler/Dialect/Modules/Check/CMakeLists.txt
+++ b/iree/compiler/Dialect/Modules/Check/CMakeLists.txt
@@ -10,17 +10,17 @@
iree_add_all_subdirs()
-iree_cc_embed_data(
+iree_c_embed_data(
NAME
check_imports
SRCS
"check.imports.mlir"
- CC_FILE_OUTPUT
- "check.imports.cc"
+ C_FILE_OUTPUT
+ "check.imports.c"
H_FILE_OUTPUT
"check.imports.h"
- CPP_NAMESPACE
- "mlir::iree_compiler::IREE::Check"
+ IDENTIFIER
+ "iree_check_imports"
FLATTEN
PUBLIC
)
diff --git a/iree/compiler/Dialect/Modules/Check/IR/CheckDialect.cpp b/iree/compiler/Dialect/Modules/Check/IR/CheckDialect.cpp
index 6b0cca6..fa0774a 100644
--- a/iree/compiler/Dialect/Modules/Check/IR/CheckDialect.cpp
+++ b/iree/compiler/Dialect/Modules/Check/IR/CheckDialect.cpp
@@ -34,9 +34,9 @@
using VMConversionDialectInterface::VMConversionDialectInterface;
OwningModuleRef parseVMImportModule() const override {
- return mlir::parseSourceString(
- StringRef(check_imports_create()->data, check_imports_create()->size),
- getDialect()->getContext());
+ return mlir::parseSourceString(StringRef(iree_check_imports_create()->data,
+ iree_check_imports_create()->size),
+ getDialect()->getContext());
}
void populateVMConversionPatterns(
diff --git a/iree/compiler/Dialect/Modules/Strings/BUILD b/iree/compiler/Dialect/Modules/Strings/BUILD
index 865006f..f46d092 100644
--- a/iree/compiler/Dialect/Modules/Strings/BUILD
+++ b/iree/compiler/Dialect/Modules/Strings/BUILD
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-load("//build_tools/embed_data:build_defs.bzl", "cc_embed_data")
+load("//build_tools/embed_data:build_defs.bzl", "c_embed_data")
package(
default_visibility = ["//visibility:public"],
@@ -20,11 +20,11 @@
licenses = ["notice"], # Apache 2.0
)
-cc_embed_data(
+c_embed_data(
name = "strings_imports",
srcs = ["strings.imports.mlir"],
- cc_file_output = "strings.imports.cc",
- cpp_namespace = "mlir::iree_compiler::IREE::Strings",
+ c_file_output = "strings.imports.c",
flatten = True,
h_file_output = "strings.imports.h",
+ identifier = "iree_strings_imports",
)
diff --git a/iree/compiler/Dialect/Modules/Strings/CMakeLists.txt b/iree/compiler/Dialect/Modules/Strings/CMakeLists.txt
index 56ce7e2..b5e78fe 100644
--- a/iree/compiler/Dialect/Modules/Strings/CMakeLists.txt
+++ b/iree/compiler/Dialect/Modules/Strings/CMakeLists.txt
@@ -10,17 +10,17 @@
iree_add_all_subdirs()
-iree_cc_embed_data(
+iree_c_embed_data(
NAME
strings_imports
SRCS
"strings.imports.mlir"
- CC_FILE_OUTPUT
- "strings.imports.cc"
+ C_FILE_OUTPUT
+ "strings.imports.c"
H_FILE_OUTPUT
"strings.imports.h"
- CPP_NAMESPACE
- "mlir::iree_compiler::IREE::Strings"
+ IDENTIFIER
+ "iree_strings_imports"
FLATTEN
PUBLIC
)
diff --git a/iree/compiler/Dialect/Modules/Strings/IR/Dialect.cc b/iree/compiler/Dialect/Modules/Strings/IR/Dialect.cc
index b44572d..c080ac5 100644
--- a/iree/compiler/Dialect/Modules/Strings/IR/Dialect.cc
+++ b/iree/compiler/Dialect/Modules/Strings/IR/Dialect.cc
@@ -39,9 +39,10 @@
using VMConversionDialectInterface::VMConversionDialectInterface;
OwningModuleRef parseVMImportModule() const override {
- return mlir::parseSourceString(StringRef(strings_imports_create()->data,
- strings_imports_create()->size),
- getDialect()->getContext());
+ return mlir::parseSourceString(
+ StringRef(iree_strings_imports_create()->data,
+ iree_strings_imports_create()->size),
+ getDialect()->getContext());
}
void populateVMConversionPatterns(
diff --git a/iree/compiler/Dialect/Modules/TensorList/BUILD b/iree/compiler/Dialect/Modules/TensorList/BUILD
index 57e8c58..691c41b 100644
--- a/iree/compiler/Dialect/Modules/TensorList/BUILD
+++ b/iree/compiler/Dialect/Modules/TensorList/BUILD
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-load("//build_tools/embed_data:build_defs.bzl", "cc_embed_data")
+load("//build_tools/embed_data:build_defs.bzl", "c_embed_data")
package(
default_visibility = ["//visibility:public"],
@@ -20,11 +20,11 @@
licenses = ["notice"], # Apache 2.0
)
-cc_embed_data(
+c_embed_data(
name = "tensorlist_imports",
srcs = ["tensorlist.imports.mlir"],
- cc_file_output = "tensorlist.imports.cc",
- cpp_namespace = "mlir::iree_compiler::IREE::TensorList",
+ c_file_output = "tensorlist.imports.c",
flatten = True,
h_file_output = "tensorlist.imports.h",
+ identifier = "iree_tensorlist_imports",
)
diff --git a/iree/compiler/Dialect/Modules/TensorList/CMakeLists.txt b/iree/compiler/Dialect/Modules/TensorList/CMakeLists.txt
index 795076a..b9d2f43 100644
--- a/iree/compiler/Dialect/Modules/TensorList/CMakeLists.txt
+++ b/iree/compiler/Dialect/Modules/TensorList/CMakeLists.txt
@@ -10,17 +10,17 @@
iree_add_all_subdirs()
-iree_cc_embed_data(
+iree_c_embed_data(
NAME
tensorlist_imports
SRCS
"tensorlist.imports.mlir"
- CC_FILE_OUTPUT
- "tensorlist.imports.cc"
+ C_FILE_OUTPUT
+ "tensorlist.imports.c"
H_FILE_OUTPUT
"tensorlist.imports.h"
- CPP_NAMESPACE
- "mlir::iree_compiler::IREE::TensorList"
+ IDENTIFIER
+ "iree_tensorlist_imports"
FLATTEN
PUBLIC
)
diff --git a/iree/compiler/Dialect/Modules/TensorList/IR/TensorListDialect.cpp b/iree/compiler/Dialect/Modules/TensorList/IR/TensorListDialect.cpp
index 4d25e7b..6192791 100644
--- a/iree/compiler/Dialect/Modules/TensorList/IR/TensorListDialect.cpp
+++ b/iree/compiler/Dialect/Modules/TensorList/IR/TensorListDialect.cpp
@@ -51,9 +51,10 @@
using VMConversionDialectInterface::VMConversionDialectInterface;
OwningModuleRef parseVMImportModule() const override {
- return mlir::parseSourceString(StringRef(tensorlist_imports_create()->data,
- tensorlist_imports_create()->size),
- getDialect()->getContext());
+ return mlir::parseSourceString(
+ StringRef(iree_tensorlist_imports_create()->data,
+ iree_tensorlist_imports_create()->size),
+ getDialect()->getContext());
}
void populateVMConversionPatterns(
diff --git a/iree/compiler/Dialect/VMLA/BUILD b/iree/compiler/Dialect/VMLA/BUILD
index 850ee73..34b653c 100644
--- a/iree/compiler/Dialect/VMLA/BUILD
+++ b/iree/compiler/Dialect/VMLA/BUILD
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-load("//build_tools/embed_data:build_defs.bzl", "cc_embed_data")
+load("//build_tools/embed_data:build_defs.bzl", "c_embed_data")
package(
default_visibility = ["//visibility:public"],
@@ -20,11 +20,11 @@
licenses = ["notice"], # Apache 2.0
)
-cc_embed_data(
+c_embed_data(
name = "vmla_imports",
srcs = ["vmla.imports.mlir"],
- cc_file_output = "vmla.imports.cc",
- cpp_namespace = "mlir::iree_compiler",
+ c_file_output = "vmla.imports.c",
flatten = True,
h_file_output = "vmla.imports.h",
+ identifier = "iree_vmla_imports",
)
diff --git a/iree/compiler/Dialect/VMLA/CMakeLists.txt b/iree/compiler/Dialect/VMLA/CMakeLists.txt
index 988ce6e..81371fc 100644
--- a/iree/compiler/Dialect/VMLA/CMakeLists.txt
+++ b/iree/compiler/Dialect/VMLA/CMakeLists.txt
@@ -10,17 +10,17 @@
iree_add_all_subdirs()
-iree_cc_embed_data(
+iree_c_embed_data(
NAME
vmla_imports
SRCS
"vmla.imports.mlir"
- CC_FILE_OUTPUT
- "vmla.imports.cc"
+ C_FILE_OUTPUT
+ "vmla.imports.c"
H_FILE_OUTPUT
"vmla.imports.h"
- CPP_NAMESPACE
- "mlir::iree_compiler"
+ IDENTIFIER
+ "iree_vmla_imports"
FLATTEN
PUBLIC
)
diff --git a/iree/compiler/Dialect/VMLA/Conversion/VMLAToVM/ConvertVMLAToVM.cpp b/iree/compiler/Dialect/VMLA/Conversion/VMLAToVM/ConvertVMLAToVM.cpp
index 5475b46..45712d3 100644
--- a/iree/compiler/Dialect/VMLA/Conversion/VMLAToVM/ConvertVMLAToVM.cpp
+++ b/iree/compiler/Dialect/VMLA/Conversion/VMLAToVM/ConvertVMLAToVM.cpp
@@ -398,9 +398,9 @@
std::tie(outerModuleOp, innerModuleOp) =
VMConversionTarget::nestModuleForConversion(getOperation());
- (void)appendImportModule(
- StringRef(vmla_imports_create()->data, vmla_imports_create()->size),
- innerModuleOp);
+ (void)appendImportModule(StringRef(iree_vmla_imports_create()->data,
+ iree_vmla_imports_create()->size),
+ innerModuleOp);
OwningRewritePatternList conversionPatterns(&getContext());
populateStandardToVMPatterns(context, typeConverter, conversionPatterns);
diff --git a/iree/compiler/Dialect/VMLA/IR/VMLADialect.cpp b/iree/compiler/Dialect/VMLA/IR/VMLADialect.cpp
index 529cc5b..2fbc4a0 100644
--- a/iree/compiler/Dialect/VMLA/IR/VMLADialect.cpp
+++ b/iree/compiler/Dialect/VMLA/IR/VMLADialect.cpp
@@ -36,9 +36,9 @@
using VMConversionDialectInterface::VMConversionDialectInterface;
OwningModuleRef parseVMImportModule() const override {
- return mlir::parseSourceString(
- StringRef(vmla_imports_create()->data, vmla_imports_create()->size),
- getDialect()->getContext());
+ return mlir::parseSourceString(StringRef(iree_vmla_imports_create()->data,
+ iree_vmla_imports_create()->size),
+ getDialect()->getContext());
}
void populateVMConversionPatterns(
diff --git a/iree/hal/local/elf/elf_module_test.cc b/iree/hal/local/elf/elf_module_test.cc
index da07cb6..cbf2496 100644
--- a/iree/hal/local/elf/elf_module_test.cc
+++ b/iree/hal/local/elf/elf_module_test.cc
@@ -48,8 +48,8 @@
#endif // IREE_ARCH_*
if (!iree_string_view_is_empty(pattern)) {
- for (size_t i = 0; i < iree::elf::simple_mul_dispatch_size(); ++i) {
- const auto* file_toc = &iree::elf::simple_mul_dispatch_create()[i];
+ for (size_t i = 0; i < simple_mul_dispatch_size(); ++i) {
+ const auto* file_toc = &simple_mul_dispatch_create()[i];
if (iree_string_view_match_pattern(
iree_make_cstring_view(file_toc->name), pattern)) {
return iree_make_const_byte_span(file_toc->data, file_toc->size);
diff --git a/iree/hal/local/elf/testdata/BUILD b/iree/hal/local/elf/testdata/BUILD
index 3205b59..8d9de82 100644
--- a/iree/hal/local/elf/testdata/BUILD
+++ b/iree/hal/local/elf/testdata/BUILD
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-load("//build_tools/embed_data:build_defs.bzl", "cc_embed_data")
+load("//build_tools/embed_data:build_defs.bzl", "c_embed_data")
package(
default_visibility = ["//visibility:public"],
@@ -20,12 +20,11 @@
licenses = ["notice"], # Apache 2.0
)
-cc_embed_data(
+c_embed_data(
name = "simple_mul_dispatch",
testonly = True,
srcs = glob(["simple_mul_dispatch_*.so"]),
- cc_file_output = "simple_mul_dispatch.cc",
- cpp_namespace = "iree::elf",
+ c_file_output = "simple_mul_dispatch.c",
flatten = True,
h_file_output = "simple_mul_dispatch.h",
)
diff --git a/iree/hal/local/elf/testdata/CMakeLists.txt b/iree/hal/local/elf/testdata/CMakeLists.txt
index d4488d5..bfdaa7a 100644
--- a/iree/hal/local/elf/testdata/CMakeLists.txt
+++ b/iree/hal/local/elf/testdata/CMakeLists.txt
@@ -11,18 +11,16 @@
iree_add_all_subdirs()
file(GLOB _GLOB_SIMPLE_MUL_DISPATCH_X_SO LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS simple_mul_dispatch_*.so)
-iree_cc_embed_data(
+iree_c_embed_data(
NAME
simple_mul_dispatch
SRCS
"${_GLOB_SIMPLE_MUL_DISPATCH_X_SO}"
- CC_FILE_OUTPUT
- "simple_mul_dispatch.cc"
+ C_FILE_OUTPUT
+ "simple_mul_dispatch.c"
H_FILE_OUTPUT
"simple_mul_dispatch.h"
TESTONLY
- CPP_NAMESPACE
- "iree::elf"
FLATTEN
PUBLIC
)
diff --git a/iree/modules/strings/BUILD b/iree/modules/strings/BUILD
index 009026b..11d0f79 100644
--- a/iree/modules/strings/BUILD
+++ b/iree/modules/strings/BUILD
@@ -44,7 +44,7 @@
srcs = ["strings_module_test.cc"],
deps = [
":strings_module",
- ":strings_module_test_module_cc",
+ ":strings_module_test_module_c",
"//iree/base",
"//iree/base:logging",
"//iree/hal",
@@ -64,7 +64,7 @@
name = "strings_module_test_module",
testonly = True,
src = "strings_module_test.mlir",
- cc_namespace = "iree::strings_module_test",
+ c_identifier = "iree_strings_module_test_module",
flags = [
"-iree-mlir-to-vm-bytecode-module",
"-iree-hal-target-backends=dylib-llvm-aot",
diff --git a/iree/modules/strings/CMakeLists.txt b/iree/modules/strings/CMakeLists.txt
index 72e36c3..8b663d2 100644
--- a/iree/modules/strings/CMakeLists.txt
+++ b/iree/modules/strings/CMakeLists.txt
@@ -43,7 +43,7 @@
"strings_module_test.cc"
DEPS
::strings_module
- ::strings_module_test_module_cc
+ ::strings_module_test_module_c
absl::span
benchmark
iree::base
@@ -63,8 +63,8 @@
strings_module_test_module
SRC
"strings_module_test.mlir"
- CC_NAMESPACE
- "iree::strings_module_test"
+ C_IDENTIFIER
+ "iree_strings_module_test_module"
FLAGS
"-iree-mlir-to-vm-bytecode-module"
"-iree-hal-target-backends=dylib-llvm-aot"
diff --git a/iree/modules/strings/strings_module_test.cc b/iree/modules/strings/strings_module_test.cc
index 320122f..ec810b0 100644
--- a/iree/modules/strings/strings_module_test.cc
+++ b/iree/modules/strings/strings_module_test.cc
@@ -25,7 +25,7 @@
#include "iree/modules/hal/hal_module.h"
#include "iree/modules/strings/api.h"
#include "iree/modules/strings/api_detail.h"
-#include "iree/modules/strings/strings_module_test_module.h"
+#include "iree/modules/strings/strings_module_test_module_c.h"
#include "iree/testing/gtest.h"
#include "iree/testing/status_matchers.h"
#include "iree/vm/api.h"
@@ -68,8 +68,7 @@
iree_hal_driver_release(hal_driver);
// Setup the test module.
- const auto* module_file_toc =
- iree::strings_module_test::strings_module_test_module_create();
+ const auto* module_file_toc = iree_strings_module_test_module_create();
IREE_CHECK_OK(iree_vm_bytecode_module_create(
iree_const_byte_span_t{
reinterpret_cast<const uint8_t*>(module_file_toc->data),
diff --git a/iree/modules/tensorlist/BUILD b/iree/modules/tensorlist/BUILD
index 7856690..7bddfa7 100644
--- a/iree/modules/tensorlist/BUILD
+++ b/iree/modules/tensorlist/BUILD
@@ -49,7 +49,7 @@
name = "tensorlist_test_module",
testonly = True,
src = "tensorlist_test.mlir",
- cc_namespace = "iree::modules::tensorlist",
+ c_identifier = "iree_tensorlist_test_module",
flags = [
"-iree-mlir-to-vm-bytecode-module",
"-iree-hal-target-backends=dylib-llvm-aot",
@@ -61,7 +61,7 @@
srcs = ["tensorlist_test.cc"],
deps = [
":native_module",
- ":tensorlist_test_module_cc",
+ ":tensorlist_test_module_c",
"//iree/base",
"//iree/base:logging",
"//iree/hal",
diff --git a/iree/modules/tensorlist/CMakeLists.txt b/iree/modules/tensorlist/CMakeLists.txt
index d022972..f311446 100644
--- a/iree/modules/tensorlist/CMakeLists.txt
+++ b/iree/modules/tensorlist/CMakeLists.txt
@@ -37,8 +37,8 @@
tensorlist_test_module
SRC
"tensorlist_test.mlir"
- CC_NAMESPACE
- "iree::modules::tensorlist"
+ C_IDENTIFIER
+ "iree_tensorlist_test_module"
FLAGS
"-iree-mlir-to-vm-bytecode-module"
"-iree-hal-target-backends=dylib-llvm-aot"
@@ -53,7 +53,7 @@
"tensorlist_test.cc"
DEPS
::native_module
- ::tensorlist_test_module_cc
+ ::tensorlist_test_module_c
absl::span
iree::base
iree::base::logging
diff --git a/iree/modules/tensorlist/tensorlist_test.cc b/iree/modules/tensorlist/tensorlist_test.cc
index 0dca9c1..ab00b29 100644
--- a/iree/modules/tensorlist/tensorlist_test.cc
+++ b/iree/modules/tensorlist/tensorlist_test.cc
@@ -23,7 +23,7 @@
#include "iree/hal/vmla/registration/driver_module.h"
#include "iree/modules/hal/hal_module.h"
#include "iree/modules/tensorlist/native_module.h"
-#include "iree/modules/tensorlist/tensorlist_test_module.h"
+#include "iree/modules/tensorlist/tensorlist_test_module_c.h"
#include "iree/testing/gtest.h"
#include "iree/testing/status_matchers.h"
#include "iree/vm/api.h"
@@ -62,8 +62,7 @@
iree_tensorlist_module_create(iree_allocator_system(), &native_module_))
<< "Native module failed to init";
- const auto* module_file_toc =
- iree::modules::tensorlist::tensorlist_test_module_create();
+ const auto* module_file_toc = iree_tensorlist_test_module_create();
IREE_CHECK_OK(iree_vm_bytecode_module_create(
iree_const_byte_span_t{
reinterpret_cast<const uint8_t*>(module_file_toc->data),
diff --git a/iree/runtime/demo/hello_world_explained.c b/iree/runtime/demo/hello_world_explained.c
index 82e1c8a..9d30863 100644
--- a/iree/runtime/demo/hello_world_explained.c
+++ b/iree/runtime/demo/hello_world_explained.c
@@ -60,7 +60,8 @@
// custom allocator can be provided to get a callback instead.
static iree_status_t iree_runtime_demo_load_module(
iree_runtime_session_t* session) {
- const iree_file_toc_t* module_file = simple_mul_module_c_create();
+ const iree_file_toc_t* module_file =
+ iree_runtime_testdata_simple_mul_module_create();
return iree_runtime_session_append_bytecode_module_from_memory(
session, iree_make_const_byte_span(module_file->data, module_file->size),
iree_allocator_null());
diff --git a/iree/runtime/demo/hello_world_terse.c b/iree/runtime/demo/hello_world_terse.c
index db8703b..1225fe5 100644
--- a/iree/runtime/demo/hello_world_terse.c
+++ b/iree/runtime/demo/hello_world_terse.c
@@ -59,7 +59,8 @@
iree_hal_device_release(device);
// Load your user module into the session (from memory, from file, etc).
- const iree_file_toc_t* module_file = simple_mul_module_c_create();
+ const iree_file_toc_t* module_file =
+ iree_runtime_testdata_simple_mul_module_create();
IREE_CHECK_OK(iree_runtime_session_append_bytecode_module_from_memory(
session, iree_make_const_byte_span(module_file->data, module_file->size),
iree_allocator_null()));
diff --git a/iree/runtime/testdata/BUILD b/iree/runtime/testdata/BUILD
index b5b76c8..a95f949 100644
--- a/iree/runtime/testdata/BUILD
+++ b/iree/runtime/testdata/BUILD
@@ -33,7 +33,7 @@
iree_bytecode_module(
name = "simple_mul_module",
src = "simple_mul.mlir",
- c_output = True,
+ c_identifier = "iree_runtime_testdata_simple_mul_module",
flags = [
"-iree-mlir-to-vm-bytecode-module",
"-iree-hal-target-backends=vmla",
diff --git a/iree/runtime/testdata/CMakeLists.txt b/iree/runtime/testdata/CMakeLists.txt
index 9d25169..087bd00 100644
--- a/iree/runtime/testdata/CMakeLists.txt
+++ b/iree/runtime/testdata/CMakeLists.txt
@@ -19,7 +19,8 @@
simple_mul_module
SRC
"simple_mul.mlir"
- C_OUTPUT
+ C_IDENTIFIER
+ "iree_runtime_testdata_simple_mul_module"
FLAGS
"-iree-mlir-to-vm-bytecode-module"
"-iree-hal-target-backends=vmla"
diff --git a/iree/samples/custom_modules/BUILD b/iree/samples/custom_modules/BUILD
index 2b16a06..705f968 100644
--- a/iree/samples/custom_modules/BUILD
+++ b/iree/samples/custom_modules/BUILD
@@ -33,7 +33,7 @@
iree_bytecode_module(
name = "custom_modules_test_module",
src = "custom_modules_test.mlir",
- cc_namespace = "iree::samples::custom_modules",
+ c_identifier = "iree_samples_custom_modules_test_module",
flags = [
"-iree-mlir-to-vm-bytecode-module",
"-iree-hal-target-backends=dylib-llvm-aot",
@@ -45,7 +45,7 @@
name = "custom_modules_test",
srcs = ["custom_modules_test.cc"],
deps = [
- ":custom_modules_test_module_cc",
+ ":custom_modules_test_module_c",
":native_module",
"//iree/base",
"//iree/base:logging",
diff --git a/iree/samples/custom_modules/CMakeLists.txt b/iree/samples/custom_modules/CMakeLists.txt
index 4765f55..5ffbb22 100644
--- a/iree/samples/custom_modules/CMakeLists.txt
+++ b/iree/samples/custom_modules/CMakeLists.txt
@@ -20,8 +20,8 @@
custom_modules_test_module
SRC
"custom_modules_test.mlir"
- CC_NAMESPACE
- "iree::samples::custom_modules"
+ C_IDENTIFIER
+ "iree_samples_custom_modules_test_module"
TRANSLATE_TOOL
iree_samples_custom_modules_dialect_custom-translate
FLAGS
@@ -36,7 +36,7 @@
SRCS
"custom_modules_test.cc"
DEPS
- ::custom_modules_test_module_cc
+ ::custom_modules_test_module_c
::native_module
iree::base
iree::base::logging
diff --git a/iree/samples/custom_modules/custom_modules_test.cc b/iree/samples/custom_modules/custom_modules_test.cc
index 4cb00e0..263765c 100644
--- a/iree/samples/custom_modules/custom_modules_test.cc
+++ b/iree/samples/custom_modules/custom_modules_test.cc
@@ -19,7 +19,7 @@
#include "iree/hal/api.h"
#include "iree/hal/vmla/registration/driver_module.h"
#include "iree/modules/hal/hal_module.h"
-#include "iree/samples/custom_modules/custom_modules_test_module.h"
+#include "iree/samples/custom_modules/custom_modules_test_module_c.h"
#include "iree/samples/custom_modules/native_module.h"
#include "iree/testing/gtest.h"
#include "iree/testing/status_matchers.h"
@@ -61,7 +61,7 @@
<< "Native module failed to init";
const auto* module_file_toc =
- iree::samples::custom_modules::custom_modules_test_module_create();
+ iree_samples_custom_modules_test_module_create();
IREE_CHECK_OK(iree_vm_bytecode_module_create(
iree_const_byte_span_t{
reinterpret_cast<const uint8_t*>(module_file_toc->data),
diff --git a/iree/samples/custom_modules/dialect/BUILD b/iree/samples/custom_modules/dialect/BUILD
index 19eac52..d46610b 100644
--- a/iree/samples/custom_modules/dialect/BUILD
+++ b/iree/samples/custom_modules/dialect/BUILD
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-load("//build_tools/embed_data:build_defs.bzl", "cc_embed_data")
+load("//build_tools/embed_data:build_defs.bzl", "c_embed_data")
load("//build_tools/bazel:tblgen.bzl", "gentbl")
load("//build_tools/bazel:enforce_glob.bzl", "enforce_glob")
@@ -74,13 +74,13 @@
],
)
-cc_embed_data(
+c_embed_data(
name = "custom_imports",
srcs = ["custom.imports.mlir"],
- cc_file_output = "custom.imports.cc",
- cpp_namespace = "mlir::iree_compiler::IREE::Custom",
+ c_file_output = "custom.imports.c",
flatten = True,
h_file_output = "custom.imports.h",
+ identifier = "iree_custom_imports",
)
cc_library(
diff --git a/iree/samples/custom_modules/dialect/CMakeLists.txt b/iree/samples/custom_modules/dialect/CMakeLists.txt
index 758d9fa..be71ff3 100644
--- a/iree/samples/custom_modules/dialect/CMakeLists.txt
+++ b/iree/samples/custom_modules/dialect/CMakeLists.txt
@@ -46,17 +46,17 @@
-gen-op-defs custom_ops.cc.inc
)
-iree_cc_embed_data(
+iree_c_embed_data(
NAME
custom_imports
SRCS
"custom.imports.mlir"
- CC_FILE_OUTPUT
- "custom.imports.cc"
+ C_FILE_OUTPUT
+ "custom.imports.c"
H_FILE_OUTPUT
"custom.imports.h"
- CPP_NAMESPACE
- "mlir::iree_compiler::IREE::Custom"
+ IDENTIFIER
+ "iree_custom_imports"
FLATTEN
PUBLIC
)
diff --git a/iree/samples/custom_modules/dialect/custom_dialect.cc b/iree/samples/custom_modules/dialect/custom_dialect.cc
index 0b48e8e..bd1e59f 100644
--- a/iree/samples/custom_modules/dialect/custom_dialect.cc
+++ b/iree/samples/custom_modules/dialect/custom_dialect.cc
@@ -54,7 +54,8 @@
OwningModuleRef parseVMImportModule() const override {
return mlir::parseSourceString(
- StringRef(custom_imports_create()->data, custom_imports_create()->size),
+ StringRef(iree_custom_imports_create()->data,
+ iree_custom_imports_create()->size),
getDialect()->getContext());
}
diff --git a/iree/samples/simple_embedding/BUILD b/iree/samples/simple_embedding/BUILD
index 2a536b7..77aa122 100644
--- a/iree/samples/simple_embedding/BUILD
+++ b/iree/samples/simple_embedding/BUILD
@@ -42,6 +42,7 @@
c_file_output = "simple_embedding_test_llvm_aot_rv64.c",
flatten = True,
h_file_output = "simple_embedding_test_llvm_aot_rv64.h",
+ identifier = "iree_samples_simple_embedding_rv64_test_module",
)
iree_cmake_extra_content(
@@ -117,8 +118,7 @@
iree_bytecode_module(
name = "simple_embedding_test_bytecode_module",
src = "simple_embedding_test.mlir",
- c_output = True,
- cc_namespace = "iree::samples",
+ c_identifier = "iree_samples_simple_embedding_test_module",
flags = [
"-iree-mlir-to-vm-bytecode-module",
"-iree-hal-target-backends=dylib-llvm-aot",
diff --git a/iree/samples/simple_embedding/CMakeLists.txt b/iree/samples/simple_embedding/CMakeLists.txt
index 7ab1ba4..d811f32 100644
--- a/iree/samples/simple_embedding/CMakeLists.txt
+++ b/iree/samples/simple_embedding/CMakeLists.txt
@@ -19,6 +19,8 @@
"simple_embedding_test_llvm_aot_rv64.c"
H_FILE_OUTPUT
"simple_embedding_test_llvm_aot_rv64.h"
+ IDENTIFIER
+ "iree_samples_simple_embedding_rv64_test_module"
FLATTEN
PUBLIC
)
@@ -90,9 +92,8 @@
simple_embedding_test_bytecode_module
SRC
"simple_embedding_test.mlir"
- CC_NAMESPACE
- "iree::samples"
- C_OUTPUT
+ C_IDENTIFIER
+ "iree_samples_simple_embedding_test_module"
FLAGS
"-iree-mlir-to-vm-bytecode-module"
"-iree-hal-target-backends=dylib-llvm-aot"
diff --git a/iree/samples/simple_embedding/simple_embedding.c b/iree/samples/simple_embedding/simple_embedding.c
index cba4345..b28ded9 100644
--- a/iree/samples/simple_embedding/simple_embedding.c
+++ b/iree/samples/simple_embedding/simple_embedding.c
@@ -53,13 +53,13 @@
// Load bytecode module from the embedded data.
#if IREE_ARCH_RISCV_64
const struct iree_file_toc_t* module_file_toc =
- simple_embedding_test_llvm_aot_rv64_create();
+ iree_samples_simple_embedding_rv64_test_module_create();
#else
// Note the setup here only supports native build. The bytecode is not built
// for the cross-compile execution. The code can be compiled but it will
// hit runtime error in a cross-compile environment.
const struct iree_file_toc_t* module_file_toc =
- simple_embedding_test_bytecode_module_c_create();
+ iree_samples_simple_embedding_test_module_create();
#endif
iree_vm_module_t* bytecode_module = NULL;
diff --git a/iree/samples/vulkan/CMakeLists.txt b/iree/samples/vulkan/CMakeLists.txt
index 1837991..aada407 100644
--- a/iree/samples/vulkan/CMakeLists.txt
+++ b/iree/samples/vulkan/CMakeLists.txt
@@ -22,8 +22,8 @@
simple_mul_bytecode_module
SRC
"simple_mul.mlir"
- CC_NAMESPACE
- "iree::samples::vulkan"
+ C_IDENTIFIER
+ "iree_samples_vulkan_simple_mul_bytecode_module"
FLAGS
"-iree-mlir-to-vm-bytecode-module"
"-iree-hal-target-backends=vulkan-spirv"
@@ -48,7 +48,7 @@
iree::base::internal::main
iree::hal::vulkan::registration
iree::modules::hal
- iree::samples::vulkan::simple_mul_bytecode_module_cc
+ iree::samples::vulkan::simple_mul_bytecode_module_c
iree::testing::vulkan::vulkan_gui_util
iree::vm
iree::vm::bytecode_module
diff --git a/iree/samples/vulkan/vulkan_inference_gui.cc b/iree/samples/vulkan/vulkan_inference_gui.cc
index 3ccd36e..35b1f06 100644
--- a/iree/samples/vulkan/vulkan_inference_gui.cc
+++ b/iree/samples/vulkan/vulkan_inference_gui.cc
@@ -34,7 +34,7 @@
#include "iree/base/logging.h"
// Compiled module embedded here to avoid file IO:
-#include "iree/samples/vulkan/simple_mul_bytecode_module.h"
+#include "iree/samples/vulkan/simple_mul_bytecode_module_c.h"
static VkAllocationCallbacks* g_Allocator = NULL;
static VkInstance g_Instance = VK_NULL_HANDLE;
@@ -234,8 +234,8 @@
// Load bytecode module from embedded data.
IREE_LOG(INFO) << "Loading simple_mul.mlir...";
- const auto* module_file_toc =
- iree::samples::vulkan::simple_mul_bytecode_module_create();
+ const struct iree_file_toc_t* module_file_toc =
+ iree_samples_vulkan_simple_mul_bytecode_module_create();
iree_vm_module_t* bytecode_module = nullptr;
IREE_CHECK_OK(iree_vm_bytecode_module_create(
iree_const_byte_span_t{
diff --git a/iree/tools/compilation.bzl b/iree/tools/compilation.bzl
index 500a4c9..ff38286 100644
--- a/iree/tools/compilation.bzl
+++ b/iree/tools/compilation.bzl
@@ -14,7 +14,7 @@
"""Rules for compiling IREE executables, modules, and archives."""
-load("//build_tools/embed_data:build_defs.bzl", "c_embed_data", "cc_embed_data")
+load("//build_tools/embed_data:build_defs.bzl", "c_embed_data")
# TODO(benvanik): port to a full starlark rule, document, etc.
def iree_bytecode_module(
@@ -22,8 +22,7 @@
src,
flags = ["-iree-mlir-to-vm-bytecode-module"],
translate_tool = "//iree/tools:iree-translate",
- cc_namespace = None,
- c_output = False,
+ c_identifier = "",
**kwargs):
native.genrule(
name = name,
@@ -45,25 +44,11 @@
**kwargs
)
- # 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),
- identifier = name,
- srcs = ["%s.vmfb" % (name)],
- cc_file_output = "%s.cc" % (name),
- h_file_output = "%s.h" % (name),
- cpp_namespace = cc_namespace,
- flatten = True,
- **kwargs
- )
-
# Embed the module for use in C.
- if c_output:
+ if c_identifier:
c_embed_data(
name = "%s_c" % (name),
- identifier = "%s_c" % (name),
+ identifier = c_identifier,
srcs = ["%s.vmfb" % (name)],
c_file_output = "%s_c.c" % (name),
h_file_output = "%s_c.h" % (name),
diff --git a/iree/vm/BUILD b/iree/vm/BUILD
index 49ad2eb..3cbd750 100644
--- a/iree/vm/BUILD
+++ b/iree/vm/BUILD
@@ -255,7 +255,7 @@
"//iree/base:status",
"//iree/testing:gtest",
"//iree/testing:gtest_main",
- "//iree/vm/test:all_bytecode_modules_cc",
+ "//iree/vm/test:all_bytecode_modules_c",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:span",
],
@@ -267,7 +267,7 @@
srcs = ["bytecode_module_benchmark.cc"],
deps = [
":bytecode_module",
- ":bytecode_module_benchmark_module_cc",
+ ":bytecode_module_benchmark_module_c",
":vm",
"//iree/base",
"//iree/base:logging",
@@ -286,7 +286,7 @@
name = "bytecode_module_benchmark_module",
testonly = True,
src = "bytecode_module_benchmark.mlir",
- cc_namespace = "iree::vm",
+ c_identifier = "iree_vm_bytecode_module_benchmark_module",
flags = ["-iree-vm-ir-to-bytecode-module"],
)
@@ -295,7 +295,7 @@
srcs = ["bytecode_module_size_benchmark.cc"],
deps = [
":bytecode_module",
- ":bytecode_module_size_benchmark_module_cc",
+ ":bytecode_module_size_benchmark_module_c",
":vm",
"//iree/base",
],
@@ -305,7 +305,7 @@
name = "bytecode_module_size_benchmark_module",
testonly = True,
src = "bytecode_module_size_benchmark.mlir",
- cc_namespace = "iree::vm",
+ c_identifier = "iree_vm_bytecode_module_size_benchmark_module",
flags = ["-iree-vm-ir-to-bytecode-module"],
)
diff --git a/iree/vm/CMakeLists.txt b/iree/vm/CMakeLists.txt
index b580c57..8579f5f 100644
--- a/iree/vm/CMakeLists.txt
+++ b/iree/vm/CMakeLists.txt
@@ -207,7 +207,7 @@
iree::base::status
iree::testing::gtest
iree::testing::gtest_main
- iree::vm::test::all_bytecode_modules_cc
+ iree::vm::test::all_bytecode_modules_c
LABELS
"notap"
"manual"
@@ -220,7 +220,7 @@
"bytecode_module_benchmark.cc"
DEPS
::bytecode_module
- ::bytecode_module_benchmark_module_cc
+ ::bytecode_module_benchmark_module_c
::vm
benchmark
iree::base
@@ -243,8 +243,8 @@
bytecode_module_benchmark_module
SRC
"bytecode_module_benchmark.mlir"
- CC_NAMESPACE
- "iree::vm"
+ C_IDENTIFIER
+ "iree_vm_bytecode_module_benchmark_module"
FLAGS
"-iree-vm-ir-to-bytecode-module"
TESTONLY
@@ -258,7 +258,7 @@
"bytecode_module_size_benchmark.cc"
DEPS
::bytecode_module
- ::bytecode_module_size_benchmark_module_cc
+ ::bytecode_module_size_benchmark_module_c
::vm
iree::base
)
@@ -268,8 +268,8 @@
bytecode_module_size_benchmark_module
SRC
"bytecode_module_size_benchmark.mlir"
- CC_NAMESPACE
- "iree::vm"
+ C_IDENTIFIER
+ "iree_vm_bytecode_module_size_benchmark_module"
FLAGS
"-iree-vm-ir-to-bytecode-module"
TESTONLY
diff --git a/iree/vm/bytecode_dispatch_test.cc b/iree/vm/bytecode_dispatch_test.cc
index 3f23332..1a82012 100644
--- a/iree/vm/bytecode_dispatch_test.cc
+++ b/iree/vm/bytecode_dispatch_test.cc
@@ -32,7 +32,7 @@
namespace {
struct TestParams {
- const iree::iree_file_toc_t& module_file;
+ const struct iree_file_toc_t& module_file;
std::string function_name;
};
@@ -47,8 +47,9 @@
IREE_CHECK_OK(iree_vm_register_builtin_types());
- auto* module_file_toc = iree::vm::test::all_bytecode_modules_cc_create();
- for (size_t i = 0; i < iree::vm::test::all_bytecode_modules_cc_size(); ++i) {
+ const struct iree_file_toc_t* module_file_toc =
+ all_bytecode_modules_c_create();
+ for (size_t i = 0; i < all_bytecode_modules_c_size(); ++i) {
const auto& module_file = module_file_toc[i];
iree_vm_module_t* module = nullptr;
IREE_CHECK_OK(iree_vm_bytecode_module_create(
diff --git a/iree/vm/bytecode_module_benchmark.cc b/iree/vm/bytecode_module_benchmark.cc
index 9935cdf..35158d9 100644
--- a/iree/vm/bytecode_module_benchmark.cc
+++ b/iree/vm/bytecode_module_benchmark.cc
@@ -20,7 +20,7 @@
#include "iree/base/logging.h"
#include "iree/vm/api.h"
#include "iree/vm/bytecode_module.h"
-#include "iree/vm/bytecode_module_benchmark_module.h"
+#include "iree/vm/bytecode_module_benchmark_module_c.h"
namespace {
@@ -86,7 +86,7 @@
native_import_module_create(iree_allocator_system(), &import_module));
const auto* module_file_toc =
- iree::vm::bytecode_module_benchmark_module_create();
+ iree_vm_bytecode_module_benchmark_module_create();
iree_vm_module_t* bytecode_module = nullptr;
IREE_CHECK_OK(iree_vm_bytecode_module_create(
iree_const_byte_span_t{
@@ -138,7 +138,7 @@
static void BM_ModuleCreate(benchmark::State& state) {
while (state.KeepRunning()) {
const auto* module_file_toc =
- iree::vm::bytecode_module_benchmark_module_create();
+ iree_vm_bytecode_module_benchmark_module_create();
iree_vm_module_t* module = nullptr;
IREE_CHECK_OK(iree_vm_bytecode_module_create(
iree_const_byte_span_t{
@@ -156,7 +156,7 @@
static void BM_ModuleCreateState(benchmark::State& state) {
const auto* module_file_toc =
- iree::vm::bytecode_module_benchmark_module_create();
+ iree_vm_bytecode_module_benchmark_module_create();
iree_vm_module_t* module = nullptr;
IREE_CHECK_OK(iree_vm_bytecode_module_create(
iree_const_byte_span_t{
@@ -182,7 +182,7 @@
static void BM_FullModuleInit(benchmark::State& state) {
while (state.KeepRunning()) {
const auto* module_file_toc =
- iree::vm::bytecode_module_benchmark_module_create();
+ iree_vm_bytecode_module_benchmark_module_create();
iree_vm_module_t* module = nullptr;
IREE_CHECK_OK(iree_vm_bytecode_module_create(
iree_const_byte_span_t{
diff --git a/iree/vm/bytecode_module_size_benchmark.cc b/iree/vm/bytecode_module_size_benchmark.cc
index d2a5a1c..77ccf76 100644
--- a/iree/vm/bytecode_module_size_benchmark.cc
+++ b/iree/vm/bytecode_module_size_benchmark.cc
@@ -15,14 +15,14 @@
#include "iree/base/api.h"
#include "iree/vm/api.h"
#include "iree/vm/bytecode_module.h"
-#include "iree/vm/bytecode_module_size_benchmark_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;
iree_vm_instance_create(iree_allocator_system(), &instance);
const auto* module_file_toc =
- iree::vm::bytecode_module_size_benchmark_module_create();
+ iree_vm_bytecode_module_size_benchmark_module_create();
iree_vm_module_t* module = nullptr;
iree_vm_bytecode_module_create(
iree_const_byte_span_t{
diff --git a/iree/vm/test/BUILD b/iree/vm/test/BUILD
index fd9c6f5..7036f9b 100644
--- a/iree/vm/test/BUILD
+++ b/iree/vm/test/BUILD
@@ -14,7 +14,7 @@
load("//iree:build_defs.oss.bzl", "iree_cmake_extra_content")
load("//iree/tools:compilation.bzl", "iree_bytecode_module")
-load("//build_tools/embed_data:build_defs.bzl", "cc_embed_data")
+load("//build_tools/embed_data:build_defs.bzl", "c_embed_data")
package(
default_visibility = ["//visibility:public"],
@@ -31,8 +31,8 @@
inline = True,
)
-cc_embed_data(
- name = "all_bytecode_modules_cc",
+c_embed_data(
+ name = "all_bytecode_modules_c",
srcs = [
":arithmetic_ops.vmfb",
":arithmetic_ops_f32.vmfb",
@@ -56,8 +56,7 @@
":shift_ops.vmfb",
":shift_ops_i64.vmfb",
],
- cc_file_output = "all_bytecode_modules.cc",
- cpp_namespace = "iree::vm::test",
+ c_file_output = "all_bytecode_modules.c",
flatten = True,
h_file_output = "all_bytecode_modules.h",
)
@@ -137,62 +136,53 @@
iree_bytecode_module(
name = "conversion_ops_f32",
src = "conversion_ops_f32.mlir",
- cc_namespace = "iree::vm::test",
flags = ["-iree-vm-ir-to-bytecode-module"],
)
iree_bytecode_module(
name = "conversion_ops_i64",
src = "conversion_ops_i64.mlir",
- cc_namespace = "iree::vm::test",
flags = ["-iree-vm-ir-to-bytecode-module"],
)
iree_bytecode_module(
name = "global_ops",
src = "global_ops.mlir",
- cc_namespace = "iree::vm::test",
flags = ["-iree-vm-ir-to-bytecode-module"],
)
iree_bytecode_module(
name = "global_ops_f32",
src = "global_ops_f32.mlir",
- cc_namespace = "iree::vm::test",
flags = ["-iree-vm-ir-to-bytecode-module"],
)
iree_bytecode_module(
name = "global_ops_i64",
src = "global_ops_i64.mlir",
- cc_namespace = "iree::vm::test",
flags = ["-iree-vm-ir-to-bytecode-module"],
)
iree_bytecode_module(
name = "list_ops",
src = "list_ops.mlir",
- cc_namespace = "iree::vm::test",
flags = ["-iree-vm-ir-to-bytecode-module"],
)
iree_bytecode_module(
name = "list_variant_ops",
src = "list_variant_ops.mlir",
- cc_namespace = "iree::vm::test",
flags = ["-iree-vm-ir-to-bytecode-module"],
)
iree_bytecode_module(
name = "shift_ops",
src = "shift_ops.mlir",
- cc_namespace = "iree::vm::test",
flags = ["-iree-vm-ir-to-bytecode-module"],
)
iree_bytecode_module(
name = "shift_ops_i64",
src = "shift_ops_i64.mlir",
- cc_namespace = "iree::vm::test",
flags = ["-iree-vm-ir-to-bytecode-module"],
)
diff --git a/iree/vm/test/CMakeLists.txt b/iree/vm/test/CMakeLists.txt
index 0ef8563..2ffa3c7 100644
--- a/iree/vm/test/CMakeLists.txt
+++ b/iree/vm/test/CMakeLists.txt
@@ -14,9 +14,9 @@
return()
endif()
-iree_cc_embed_data(
+iree_c_embed_data(
NAME
- all_bytecode_modules_cc
+ all_bytecode_modules_c
GENERATED_SRCS
"arithmetic_ops.vmfb"
"arithmetic_ops_f32.vmfb"
@@ -39,12 +39,10 @@
"list_variant_ops.vmfb"
"shift_ops.vmfb"
"shift_ops_i64.vmfb"
- CC_FILE_OUTPUT
- "all_bytecode_modules.cc"
+ C_FILE_OUTPUT
+ "all_bytecode_modules.c"
H_FILE_OUTPUT
"all_bytecode_modules.h"
- CPP_NAMESPACE
- "iree::vm::test"
FLATTEN
PUBLIC
)
@@ -174,8 +172,6 @@
conversion_ops_f32
SRC
"conversion_ops_f32.mlir"
- CC_NAMESPACE
- "iree::vm::test"
FLAGS
"-iree-vm-ir-to-bytecode-module"
PUBLIC
@@ -186,8 +182,6 @@
conversion_ops_i64
SRC
"conversion_ops_i64.mlir"
- CC_NAMESPACE
- "iree::vm::test"
FLAGS
"-iree-vm-ir-to-bytecode-module"
PUBLIC
@@ -198,8 +192,6 @@
global_ops
SRC
"global_ops.mlir"
- CC_NAMESPACE
- "iree::vm::test"
FLAGS
"-iree-vm-ir-to-bytecode-module"
PUBLIC
@@ -210,8 +202,6 @@
global_ops_f32
SRC
"global_ops_f32.mlir"
- CC_NAMESPACE
- "iree::vm::test"
FLAGS
"-iree-vm-ir-to-bytecode-module"
PUBLIC
@@ -222,8 +212,6 @@
global_ops_i64
SRC
"global_ops_i64.mlir"
- CC_NAMESPACE
- "iree::vm::test"
FLAGS
"-iree-vm-ir-to-bytecode-module"
PUBLIC
@@ -234,8 +222,6 @@
list_ops
SRC
"list_ops.mlir"
- CC_NAMESPACE
- "iree::vm::test"
FLAGS
"-iree-vm-ir-to-bytecode-module"
PUBLIC
@@ -246,8 +232,6 @@
list_variant_ops
SRC
"list_variant_ops.mlir"
- CC_NAMESPACE
- "iree::vm::test"
FLAGS
"-iree-vm-ir-to-bytecode-module"
PUBLIC
@@ -258,8 +242,6 @@
shift_ops
SRC
"shift_ops.mlir"
- CC_NAMESPACE
- "iree::vm::test"
FLAGS
"-iree-vm-ir-to-bytecode-module"
PUBLIC
@@ -270,8 +252,6 @@
shift_ops_i64
SRC
"shift_ops_i64.mlir"
- CC_NAMESPACE
- "iree::vm::test"
FLAGS
"-iree-vm-ir-to-bytecode-module"
PUBLIC