Skip to content

Commit

Permalink
Add Bazel build configuration for EmitC (iree-org#8287)
Browse files Browse the repository at this point in the history
  • Loading branch information
marbre authored Feb 10, 2022
1 parent 920b0a8 commit a0236fb
Show file tree
Hide file tree
Showing 7 changed files with 233 additions and 77 deletions.
51 changes: 51 additions & 0 deletions iree/compiler/Dialect/VM/Conversion/VMToEmitC/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright 2022 The IREE Authors
#
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

load("//iree:build_defs.oss.bzl", "iree_cmake_extra_content")

package(
default_visibility = ["//visibility:public"],
features = ["layering_check"],
licenses = ["notice"], # Apache 2.0
)

iree_cmake_extra_content(
content = """
if(NOT "${IREE_ENABLE_EMITC}")
return()
endif()
""",
)

cc_library(
name = "VMToEmitC",
srcs = [
"ConvertVMToEmitC.cpp",
"DropExcludedExports.cpp",
"EmitCTypeConverter.cpp",
],
hdrs = [
"ConvertVMToEmitC.h",
"DropExcludedExports.h",
"EmitCTypeConverter.h",
"VMAnalysis.h",
],
deps = [
"//iree/compiler/Dialect/Util/Conversion",
"//iree/compiler/Dialect/Util/IR",
"//iree/compiler/Dialect/VM/Analysis",
"//iree/compiler/Dialect/VM/IR",
"//iree/compiler/Dialect/VM/Utils:CallingConvention",
"@llvm-project//llvm:Support",
"@llvm-project//mlir:ControlFlowOps",
"@llvm-project//mlir:EmitC",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:MathDialect",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:StandardOps",
"@llvm-project//mlir:Transforms",
],
)
78 changes: 44 additions & 34 deletions iree/compiler/Dialect/VM/Conversion/VMToEmitC/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,36 +1,46 @@
# Copyright 2020 The IREE Authors
#
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
################################################################################
# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
# iree/compiler/Dialect/VM/Conversion/VMToEmitC/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. #
################################################################################

if(${IREE_ENABLE_EMITC})
iree_add_all_subdirs()

iree_cc_library(
NAME
VMToEmitC
HDRS
"ConvertVMToEmitC.h"
"DropExcludedExports.h"
"EmitCTypeConverter.h"
"VMAnalysis.h"
SRCS
"ConvertVMToEmitC.cpp"
"DropExcludedExports.cpp"
"EmitCTypeConverter.cpp"
DEPS
MLIRControlFlow
MLIREmitC
MLIRIR
MLIRPass
MLIRStandard
MLIRTransforms
iree::compiler::Dialect::Util::Conversion
iree::compiler::Dialect::Util::IR
iree::compiler::Dialect::VM::Analysis
iree::compiler::Dialect::VM::IR
iree::compiler::Dialect::VM::Utils::CallingConvention
PUBLIC
)
if(NOT "${IREE_ENABLE_EMITC}")
return()
endif()

iree_add_all_subdirs()

iree_cc_library(
NAME
VMToEmitC
HDRS
"ConvertVMToEmitC.h"
"DropExcludedExports.h"
"EmitCTypeConverter.h"
"VMAnalysis.h"
SRCS
"ConvertVMToEmitC.cpp"
"DropExcludedExports.cpp"
"EmitCTypeConverter.cpp"
DEPS
LLVMSupport
MLIRControlFlow
MLIREmitC
MLIRIR
MLIRMath
MLIRPass
MLIRStandard
MLIRTransforms
iree::compiler::Dialect::Util::Conversion
iree::compiler::Dialect::Util::IR
iree::compiler::Dialect::VM::Analysis
iree::compiler::Dialect::VM::IR
iree::compiler::Dialect::VM::Utils::CallingConvention
PUBLIC
)

### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
4 changes: 4 additions & 0 deletions iree/compiler/Dialect/VM/Target/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ package(
cc_library(
name = "init_targets",
hdrs = ["init_targets.h"],
defines = [
"IREE_HAVE_EMITC_DIALECT",
],
deps = [
"//iree/compiler/Dialect/VM/Target/Bytecode",
"//iree/compiler/Dialect/VM/Target/C",
],
)
68 changes: 68 additions & 0 deletions iree/compiler/Dialect/VM/Target/C/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Copyright 2022 The IREE Authors
#
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

load("//iree:build_defs.oss.bzl", "iree_cmake_extra_content")

package(
default_visibility = ["//visibility:public"],
features = ["layering_check"],
licenses = ["notice"], # Apache 2.0
)

iree_cmake_extra_content(
content = """
if(NOT "${IREE_ENABLE_EMITC}")
return()
endif()
""",
)

cc_library(
name = "TranslateToCpp",
srcs = [
"TranslateToCpp.cpp",
],
hdrs = [
"CppEmitter.h",
],
deps = [
"@llvm-project//llvm:Support",
"@llvm-project//mlir:ControlFlowOps",
"@llvm-project//mlir:EmitC",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:SCFDialect",
"@llvm-project//mlir:StandardOps",
"@llvm-project//mlir:Support",
],
)

cc_library(
name = "C",
srcs = [
"CModuleTarget.cpp",
"TranslationFlags.cpp",
"TranslationRegistration.cpp",
],
hdrs = [
"CModuleTarget.h",
"TranslationFlags.h",
],
deps = [
":TranslateToCpp",
"//iree/compiler/Dialect/Util/IR",
"//iree/compiler/Dialect/Util/Transforms",
"//iree/compiler/Dialect/VM/Analysis",
"//iree/compiler/Dialect/VM/Conversion/VMToEmitC",
"//iree/compiler/Dialect/VM/IR",
"//iree/compiler/Dialect/VM/Transforms",
"@llvm-project//llvm:Support",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:Support",
"@llvm-project//mlir:Transforms",
"@llvm-project//mlir:Translation",
],
)
101 changes: 58 additions & 43 deletions iree/compiler/Dialect/VM/Target/C/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,47 +1,62 @@
# Copyright 2019 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
################################################################################
# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
# iree/compiler/Dialect/VM/Target/C/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. #
################################################################################

if(NOT "${IREE_ENABLE_EMITC}")
return()
endif()

if(${IREE_ENABLE_EMITC})
iree_add_all_subdirs()
iree_add_all_subdirs()

iree_cc_library(
NAME
TranslateToCpp
HDRS
CppEmitter.h
SRCS
TranslateToCpp.cpp
DEPS
MLIREmitC
MLIRIR
MLIRControlFlow
MLIRSCF
MLIRStandard
)
iree_cc_library(
NAME
TranslateToCpp
HDRS
"CppEmitter.h"
SRCS
"TranslateToCpp.cpp"
DEPS
LLVMSupport
MLIRControlFlow
MLIREmitC
MLIRIR
MLIRSCF
MLIRStandard
MLIRSupport
PUBLIC
)

iree_cc_library(
NAME
C
HDRS
"CModuleTarget.h"
"TranslationFlags.h"
SRCS
"CModuleTarget.cpp"
"TranslationFlags.cpp"
"TranslationRegistration.cpp"
DEPS
::TranslateToCpp
LLVMSupport
MLIRIR
MLIRPass
MLIRSupport
iree::compiler::Dialect::VM::Analysis
iree::compiler::Dialect::VM::IR
iree::compiler::Dialect::VM::Conversion::VMToEmitC
PUBLIC
)
endif()
iree_cc_library(
NAME
C
HDRS
"CModuleTarget.h"
"TranslationFlags.h"
SRCS
"CModuleTarget.cpp"
"TranslationFlags.cpp"
"TranslationRegistration.cpp"
DEPS
::TranslateToCpp
LLVMSupport
MLIRIR
MLIRPass
MLIRSupport
MLIRTransforms
MLIRTranslation
iree::compiler::Dialect::Util::IR
iree::compiler::Dialect::Util::Transforms
iree::compiler::Dialect::VM::Analysis
iree::compiler::Dialect::VM::Conversion::VMToEmitC
iree::compiler::Dialect::VM::IR
iree::compiler::Dialect::VM::Transforms
PUBLIC
)

### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
4 changes: 4 additions & 0 deletions iree/compiler/Translation/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ cc_library(
name = "IREEVM",
srcs = ["IREEVM.cpp"],
hdrs = ["IREEVM.h"],
defines = [
"IREE_HAVE_EMITC_DIALECT",
],
deps = [
"//iree/compiler/Bindings/Native/Transforms",
"//iree/compiler/Bindings/TFLite/Transforms",
Expand All @@ -44,6 +47,7 @@ cc_library(
"//iree/compiler/Dialect/VM/Conversion",
"//iree/compiler/Dialect/VM/Conversion/StandardToVM",
"//iree/compiler/Dialect/VM/Target/Bytecode",
"//iree/compiler/Dialect/VM/Target/C",
"//iree/compiler/Dialect/VM/Transforms",
"//iree/compiler/InputConversion/Common",
"//iree/compiler/InputConversion/MHLO",
Expand Down
4 changes: 4 additions & 0 deletions iree/tools/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ cc_library(
"init_mlir_dialects.h",
"init_mlir_passes.h",
],
defines = [
"IREE_HAVE_EMITC_DIALECT",
],
deps = [
"@llvm-project//mlir:Affine",
"@llvm-project//mlir:AffineTransforms",
Expand All @@ -140,6 +143,7 @@ cc_library(
"@llvm-project//mlir:BufferizationDialect",
"@llvm-project//mlir:ControlFlowOps",
"@llvm-project//mlir:ConversionPasses",
"@llvm-project//mlir:EmitC",
"@llvm-project//mlir:GPUDialect",
"@llvm-project//mlir:GPUToSPIRV",
"@llvm-project//mlir:GPUTransforms",
Expand Down

0 comments on commit a0236fb

Please sign in to comment.