|  | # 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 | 
|  |  | 
|  | # Tools IREE provides for compiling, executing, and benchmarking programs, as | 
|  | # well as other utilities. | 
|  | # | 
|  | # Only binary targets and their associated main files should go in this | 
|  | # directory. Library targets and header files should be placed in the | 
|  | # appropriate subtree, e.g. `compiler/src/iree/compiler/Tools/`. | 
|  | # | 
|  | # Programs with a dependency on the compiler are not designed to run on device | 
|  | # platforms (e.g. Android), so they are tagged "hostonly". | 
|  |  | 
|  | load("//build_tools/bazel:build_defs.oss.bzl", "iree_compiler_cc_binary", "iree_runtime_cc_binary") | 
|  |  | 
|  | package( | 
|  | default_visibility = ["//visibility:public"], | 
|  | features = ["layering_check"], | 
|  | licenses = ["notice"],  # Apache 2.0 | 
|  | ) | 
|  |  | 
|  | exports_files(["lit.cfg.py"]) | 
|  |  | 
|  | iree_runtime_cc_binary( | 
|  | name = "iree-benchmark-executable", | 
|  | srcs = ["iree-benchmark-executable-main.c"], | 
|  | deps = [ | 
|  | "//runtime/src/iree/base", | 
|  | "//runtime/src/iree/base/internal:file_io", | 
|  | "//runtime/src/iree/base/internal:flags", | 
|  | "//runtime/src/iree/hal", | 
|  | "//runtime/src/iree/modules/hal:types", | 
|  | "//runtime/src/iree/testing:benchmark", | 
|  | "//runtime/src/iree/tooling:device_util", | 
|  | "//runtime/src/iree/tooling:function_io", | 
|  | "//runtime/src/iree/vm", | 
|  | ], | 
|  | ) | 
|  |  | 
|  | iree_runtime_cc_binary( | 
|  | name = "iree-benchmark-module", | 
|  | srcs = ["iree-benchmark-module-main.cc"], | 
|  | deps = [ | 
|  | "//runtime/src/iree/base", | 
|  | "//runtime/src/iree/base/internal:flags", | 
|  | "//runtime/src/iree/hal", | 
|  | "//runtime/src/iree/modules/hal:types", | 
|  | "//runtime/src/iree/tooling:context_util", | 
|  | "//runtime/src/iree/tooling:device_util", | 
|  | "//runtime/src/iree/tooling:function_io", | 
|  | "//runtime/src/iree/vm", | 
|  | "@com_google_benchmark//:benchmark", | 
|  | ], | 
|  | ) | 
|  |  | 
|  | iree_runtime_cc_binary( | 
|  | name = "iree-check-module", | 
|  | testonly = True, | 
|  | srcs = ["iree-check-module-main.cc"], | 
|  | deps = [ | 
|  | "//runtime/src/iree/base", | 
|  | "//runtime/src/iree/base/internal:file_io", | 
|  | "//runtime/src/iree/base/internal:flags", | 
|  | "//runtime/src/iree/hal", | 
|  | "//runtime/src/iree/modules/check", | 
|  | "//runtime/src/iree/testing:gtest", | 
|  | "//runtime/src/iree/tooling:context_util", | 
|  | "//runtime/src/iree/tooling:device_util", | 
|  | "//runtime/src/iree/vm", | 
|  | "//runtime/src/iree/vm/bytecode:module", | 
|  | ], | 
|  | ) | 
|  |  | 
|  | iree_runtime_cc_binary( | 
|  | name = "iree-convert-parameters", | 
|  | srcs = ["iree-convert-parameters-main.c"], | 
|  | deps = [ | 
|  | "//runtime/src/iree/base", | 
|  | "//runtime/src/iree/base/internal:file_io", | 
|  | "//runtime/src/iree/base/internal:flags", | 
|  | "//runtime/src/iree/hal", | 
|  | "//runtime/src/iree/io:parameter_index", | 
|  | "//runtime/src/iree/io:scope_map", | 
|  | "//runtime/src/iree/io/formats/irpa", | 
|  | "//runtime/src/iree/tooling:parameter_util", | 
|  | ], | 
|  | ) | 
|  |  | 
|  | iree_runtime_cc_binary( | 
|  | name = "iree-cpuinfo", | 
|  | srcs = ["iree-cpuinfo.c"], | 
|  | deps = [ | 
|  | "//runtime/src/iree/base", | 
|  | "//runtime/src/iree/base/internal:cpu", | 
|  | "//runtime/src/iree/schemas:cpu_data", | 
|  | ], | 
|  | ) | 
|  |  | 
|  | iree_runtime_cc_binary( | 
|  | name = "iree-create-parameters", | 
|  | srcs = ["iree-create-parameters-main.c"], | 
|  | deps = [ | 
|  | "//runtime/src/iree/base", | 
|  | "//runtime/src/iree/base/internal:file_io", | 
|  | "//runtime/src/iree/base/internal:flags", | 
|  | "//runtime/src/iree/hal", | 
|  | "//runtime/src/iree/io:parameter_index", | 
|  | "//runtime/src/iree/io:scope_map", | 
|  | "//runtime/src/iree/io:stream", | 
|  | "//runtime/src/iree/io/formats/irpa", | 
|  | ], | 
|  | ) | 
|  |  | 
|  | iree_runtime_cc_binary( | 
|  | name = "iree-dump-instruments", | 
|  | srcs = ["iree-dump-instruments-main.c"], | 
|  | deps = [ | 
|  | "//runtime/src/iree/base", | 
|  | "//runtime/src/iree/base/internal:file_io", | 
|  | "//runtime/src/iree/base/internal/flatcc:parsing", | 
|  | "//runtime/src/iree/schemas/instruments", | 
|  | "//runtime/src/iree/schemas/instruments:dispatch_def_c_fbs", | 
|  | ], | 
|  | ) | 
|  |  | 
|  | iree_runtime_cc_binary( | 
|  | name = "iree-dump-module", | 
|  | srcs = ["iree-dump-module-main.c"], | 
|  | deps = [ | 
|  | "//runtime/src/iree/base", | 
|  | "//runtime/src/iree/base/internal:file_io", | 
|  | "//runtime/src/iree/base/internal:flags", | 
|  | "//runtime/src/iree/base/internal/flatcc:debugging", | 
|  | "//runtime/src/iree/base/internal/flatcc:parsing", | 
|  | "//runtime/src/iree/schemas:bytecode_module_def_c_fbs", | 
|  | "//runtime/src/iree/vm/bytecode:module", | 
|  | ], | 
|  | ) | 
|  |  | 
|  | iree_runtime_cc_binary( | 
|  | name = "iree-dump-parameters", | 
|  | srcs = ["iree-dump-parameters-main.c"], | 
|  | deps = [ | 
|  | "//runtime/src/iree/base", | 
|  | "//runtime/src/iree/base/internal:file_io", | 
|  | "//runtime/src/iree/base/internal:flags", | 
|  | "//runtime/src/iree/io:parameter_index", | 
|  | "//runtime/src/iree/io:scope_map", | 
|  | "//runtime/src/iree/tooling:parameter_util", | 
|  | ], | 
|  | ) | 
|  |  | 
|  | iree_runtime_cc_binary( | 
|  | name = "iree-fatelf", | 
|  | srcs = ["iree-fatelf.c"], | 
|  | deps = [ | 
|  | "//runtime/src/iree/base", | 
|  | "//runtime/src/iree/base/internal:file_io", | 
|  | "//runtime/src/iree/base/internal:path", | 
|  | "//runtime/src/iree/hal/local/elf:elf_module", | 
|  | ], | 
|  | ) | 
|  |  | 
|  | iree_compiler_cc_binary( | 
|  | name = "iree-opt", | 
|  | srcs = ["iree-opt-main.cc"], | 
|  | tags = ["hostonly"], | 
|  | deps = [ | 
|  | "//compiler/bindings/c:headers", | 
|  | "//compiler/src/iree/compiler/API:Impl", | 
|  | ], | 
|  | ) | 
|  |  | 
|  | iree_compiler_cc_binary( | 
|  | name = "iree-mlir-lsp-server", | 
|  | srcs = ["iree-mlir-lsp-server.cc"], | 
|  | deps = [ | 
|  | "//compiler/bindings/c:headers", | 
|  | "//compiler/src/iree/compiler/API:Impl", | 
|  | ], | 
|  | ) | 
|  |  | 
|  | # The only place we cross the streams between compiler and runtime. This | 
|  | # includes a JIT compiler step and uses neither of the iree_*_cc_binary rules, | 
|  | # but rather directly depends on both the compiler and runtime include rules. | 
|  | cc_binary( | 
|  | name = "iree-run-mlir", | 
|  | srcs = ["iree-run-mlir-main.cc"], | 
|  | tags = ["hostonly"], | 
|  | deps = [ | 
|  | "//compiler/bindings/c:headers", | 
|  | "//compiler/src:defs", | 
|  | "//compiler/src/iree/compiler/API:Impl", | 
|  | "//runtime/src:runtime_defines", | 
|  | "//runtime/src/iree/base", | 
|  | "//runtime/src/iree/base/internal:flags", | 
|  | "//runtime/src/iree/hal", | 
|  | "//runtime/src/iree/tooling:context_util", | 
|  | "//runtime/src/iree/tooling:device_util", | 
|  | "//runtime/src/iree/tooling:run_module", | 
|  | "//runtime/src/iree/vm", | 
|  | ], | 
|  | ) | 
|  |  | 
|  | iree_runtime_cc_binary( | 
|  | name = "iree-run-module", | 
|  | srcs = ["iree-run-module-main.c"], | 
|  | deps = [ | 
|  | "//runtime/src/iree/base", | 
|  | "//runtime/src/iree/base/internal:flags", | 
|  | "//runtime/src/iree/hal", | 
|  | "//runtime/src/iree/tooling:context_util", | 
|  | "//runtime/src/iree/tooling:run_module", | 
|  | "//runtime/src/iree/vm", | 
|  | ], | 
|  | ) | 
|  |  | 
|  | iree_compiler_cc_binary( | 
|  | name = "iree-tblgen", | 
|  | srcs = [ | 
|  | "iree-tblgen.cpp", | 
|  | "//compiler/src/iree/compiler/Dialect/VM/Tools:GenSrcs", | 
|  | ], | 
|  | tags = ["hostonly"], | 
|  | deps = [ | 
|  | "@llvm-project//llvm:Support", | 
|  | "@llvm-project//llvm:TableGen", | 
|  | "@llvm-project//mlir:MlirTableGenMain", | 
|  | "@llvm-project//mlir:Support", | 
|  | "@llvm-project//mlir:TableGen", | 
|  | ], | 
|  | ) | 
|  |  | 
|  | iree_compiler_cc_binary( | 
|  | name = "iree-compile", | 
|  | srcs = ["iree-compile-main.cc"], | 
|  | tags = ["hostonly"], | 
|  | deps = [ | 
|  | "//compiler/bindings/c:headers", | 
|  | "//compiler/src/iree/compiler/API:Impl", | 
|  | ], | 
|  | ) | 
|  |  | 
|  | iree_compiler_cc_binary( | 
|  | name = "iree-reduce", | 
|  | srcs = ["iree-reduce.cc"], | 
|  | tags = ["hostonly"], | 
|  | deps = [ | 
|  | "//compiler/bindings/c:headers", | 
|  | "//compiler/src/iree/compiler/API:Impl", | 
|  | ], | 
|  | ) |