提交 982608d7 编写于 作者: I Itai Zukerman 提交者: TensorFlower Gardener

Switched to OSS llvm build rules instead of scripts imported from third_party.

Tensorflow used custom bazel rules in third_party to build llvm.  These rules
are now part of the OSS llvm-project, so this change pulls those rules from
there instead.

To make this work, @llvm-raw needs to be loaded earlier in workspace3,
and its dependency @bazel_skylib as well.  Then llvm_setup() is called in
workspace2 to generate @llvm-project.

PiperOrigin-RevId: 392494584
Change-Id: I29e5eef66d5c26e795c0398c7402dff15debec5b
上级 2035c4ac
......@@ -10,13 +10,21 @@ load(
)
package(
default_visibility = [
"//tensorflow:__subpackages__",
"//tensorflow/compiler/tf2xla:__subpackages__",
],
default_visibility = [":friends"],
licenses = ["notice"],
)
package_group(
name = "friends",
packages = [
"//tensorflow/compiler/jit/...",
"//tensorflow/compiler/mlir/...",
"//tensorflow/compiler/tf2xla/...",
"//tensorflow/compiler/xla/...",
"//tensorflow/tools/...",
],
)
package_group(
name = "subpackages",
packages = ["//tensorflow/compiler/mlir/..."],
......@@ -258,6 +266,7 @@ tf_cc_test(
filegroup(
name = "litfiles",
srcs = glob(["runlit*py"]),
visibility = ["//tensorflow:__subpackages__"],
)
exports_files(["run_lit.sh"])
......@@ -24,6 +24,7 @@ package_group(
"//tensorflow/cc/...",
"//tensorflow/python/...",
"//tensorflow/tools/pip_package/...",
"//tensorflow/tools/...",
] + if_google([
"//learning/brain/experimental/mlir/tflite/tfmrt/...",
"//learning/brain/experimental/dtensor/...",
......
......@@ -189,9 +189,6 @@ third_party/jsoncpp.BUILD
third_party/libxsmm.BUILD
third_party/linenoise.BUILD
third_party/llvm/BUILD
third_party/llvm/expand_cmake_vars.py
third_party/llvm/llvm.autogenerated.BUILD
third_party/llvm/llvm.bzl
third_party/llvm_openmp/BUILD
third_party/llvm_openmp/cmake_vars.bzl
third_party/llvm_openmp/expand_cmake_vars.py
......
......@@ -14,6 +14,7 @@ load("@tf_toolchains//toolchains/embedded/arm-linux:arm_linux_toolchain_configur
load("//third_party:repo.bzl", "tf_http_archive")
load("//third_party/clang_toolchain:cc_configure_clang.bzl", "cc_download_clang_toolchain")
load("//tensorflow/tools/def_file_filter:def_file_filter_configure.bzl", "def_file_filter_configure")
load("//third_party/llvm:setup.bzl", "llvm_setup")
# Import third party repository rules. See go/tfbr-thirdparty.
load("//third_party/FP16:workspace.bzl", FP16 = "repo")
......@@ -32,7 +33,6 @@ load("//third_party/highwayhash:workspace.bzl", highwayhash = "repo")
load("//third_party/hwloc:workspace.bzl", hwloc = "repo")
load("//third_party/icu:workspace.bzl", icu = "repo")
load("//third_party/jpeg:workspace.bzl", jpeg = "repo")
load("//third_party/llvm:workspace.bzl", llvm = "repo")
load("//third_party/nasm:workspace.bzl", nasm = "repo")
load("//third_party/pybind11_abseil:workspace.bzl", pybind11_abseil = "repo")
load("//third_party/opencl_headers:workspace.bzl", opencl_headers = "repo")
......@@ -650,7 +650,7 @@ def _tf_repositories():
],
)
llvm("llvm-project")
llvm_setup(name = "llvm-project")
# Intel openMP that is part of LLVM sources.
tf_http_archive(
......@@ -1003,16 +1003,6 @@ def _tf_repositories():
],
)
# https://github.com/bazelbuild/bazel-skylib/releases
tf_http_archive(
name = "bazel_skylib",
sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c",
urls = [
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz",
],
)
# https://github.com/apple/swift-protobuf/releases
tf_http_archive(
name = "com_github_apple_swift_swift_protobuf",
......
......@@ -2,6 +2,7 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("//third_party:tf_runtime/workspace.bzl", tf_runtime = "repo")
load("//third_party/llvm:workspace.bzl", llvm = "repo")
def workspace():
http_archive(
......@@ -26,6 +27,20 @@ def workspace():
tf_runtime()
# https://github.com/bazelbuild/bazel-skylib/releases
http_archive(
name = "bazel_skylib",
sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c",
urls = [
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz",
],
)
# Load the raw llvm-project. llvm does not have build rules set up by default,
# but provides a script for setting up build rules via overlays.
llvm("llvm-raw")
# Alias so it can be loaded without assigning to a different symbol to prevent
# shadowing previous loads and trigger a buildifier warning.
tf_workspace3 = workspace
py_binary(
name = "expand_cmake_vars",
srcs = ["expand_cmake_vars.py"],
srcs_version = "PY3",
visibility = [
"@llvm-project//:__subpackages__",
"@llvm_openmp//:__subpackages__",
],
)
# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
#
# 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
#
# http://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.
# ==============================================================================
"""Expands CMake variables in a text file."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import re
import sys
_CMAKE_DEFINE_REGEX = re.compile(r"\s*#cmakedefine\s+([A-Za-z_0-9]*)(\s.*)?$")
_CMAKE_DEFINE01_REGEX = re.compile(r"\s*#cmakedefine01\s+([A-Za-z_0-9]*)")
_CMAKE_VAR_REGEX = re.compile(r"\${([A-Za-z_0-9]*)}")
_CMAKE_ATVAR_REGEX = re.compile(r"@([A-Za-z_0-9]*)@")
def _parse_args(argv):
"""Parses arguments with the form KEY=VALUE into a dictionary."""
result = {}
for arg in argv:
k, v = arg.split("=")
result[k] = v
return result
def _expand_variables(input_str, cmake_vars):
"""Expands ${VARIABLE}s and @VARIABLE@s in 'input_str', using dictionary 'cmake_vars'.
Args:
input_str: the string containing ${VARIABLE} or @VARIABLE@ expressions to expand.
cmake_vars: a dictionary mapping variable names to their values.
Returns:
The expanded string.
"""
def replace(match):
if match.group(1) in cmake_vars:
return cmake_vars[match.group(1)]
return ""
return _CMAKE_ATVAR_REGEX.sub(replace,_CMAKE_VAR_REGEX.sub(replace, input_str))
def _expand_cmakedefines(line, cmake_vars):
"""Expands #cmakedefine declarations, using a dictionary 'cmake_vars'."""
# Handles #cmakedefine lines
match = _CMAKE_DEFINE_REGEX.match(line)
if match:
name = match.group(1)
suffix = match.group(2) or ""
if name in cmake_vars:
return "#define {}{}\n".format(name,
_expand_variables(suffix, cmake_vars))
else:
return "/* #undef {} */\n".format(name)
# Handles #cmakedefine01 lines
match = _CMAKE_DEFINE01_REGEX.match(line)
if match:
name = match.group(1)
value = cmake_vars.get(name, "0")
return "#define {} {}\n".format(name, value)
# Otherwise return the line unchanged.
return _expand_variables(line, cmake_vars)
def main():
cmake_vars = _parse_args(sys.argv[1:])
for line in sys.stdin:
sys.stdout.write(_expand_cmakedefines(line, cmake_vars))
if __name__ == "__main__":
main()
此差异已折叠。
"""This file contains BUILD extensions for generating source code from LLVM's table definition files using the TableGen tool.
See http://llvm.org/cmds/tblgen.html for more information on the TableGen
tool.
TODO(chandlerc): Currently this expresses include-based dependencies as
"sources", and has no transitive understanding due to these files not being
correctly understood by the build system.
"""
def _dict_add(*dictionaries):
"""Returns a new `dict` that has all the entries of the given dictionaries.
If the same key is present in more than one of the input dictionaries, the
last of them in the argument list overrides any earlier ones.
This function is designed to take zero or one arguments as well as multiple
dictionaries, so that it follows arithmetic identities and callers can avoid
special cases for their inputs: the sum of zero dictionaries is the empty
dictionary, and the sum of a single dictionary is a copy of itself.
Re-implemented here to avoid adding a dependency on skylib.
Args:
*dictionaries: Zero or more dictionaries to be added.
Returns:
A new `dict` that has all the entries of the given dictionaries.
"""
result = {}
for d in dictionaries:
result.update(d)
return result
def gentbl(name, tblgen, td_file, td_srcs, tbl_outs, library = True, **kwargs):
"""gentbl() generates tabular code from a table definition file.
Args:
name: The name of the build rule for use in dependencies.
tblgen: The binary used to produce the output.
td_file: The primary table definitions file.
td_srcs: A list of table definition files included transitively.
tbl_outs: A list of tuples (opts, out), where each opts is a string of
options passed to tblgen, and the out is the corresponding output file
produced.
library: Whether to bundle the generated files into a library.
**kwargs: Keyword arguments to pass to subsidiary cc_library() rule.
"""
if td_file not in td_srcs:
td_srcs += [td_file]
includes = []
for (opts, out) in tbl_outs:
outdir = out[:out.rindex("/")]
if outdir not in includes:
includes.append(outdir)
rule_suffix = "_".join(opts.replace("-", "_").replace("=", "_").split(" "))
native.genrule(
name = "%s_%s_genrule" % (name, rule_suffix),
srcs = td_srcs,
outs = [out],
tools = [tblgen],
message = "Generating code from table: %s" % td_file,
cmd = (("$(location %s) " + "-I external/llvm-project/llvm/include " +
"-I external/llvm-project/clang/include " +
"-I $$(dirname $(location %s)) " + ("%s $(location %s) --long-string-literals=0 " +
"-o $@")) % (
tblgen,
td_file,
opts,
td_file,
)),
)
# For now, all generated files can be assumed to comprise public interfaces.
# If this is not true, you should specify library = False
# and list the generated '.inc' files in "srcs".
if library:
native.cc_library(
name = name,
textual_hdrs = [f for (_, f) in tbl_outs],
includes = includes,
**kwargs
)
def llvm_target_cmake_vars(native_arch, target_triple):
return {
"LLVM_HOST_TRIPLE": target_triple,
"LLVM_DEFAULT_TARGET_TRIPLE": target_triple,
"LLVM_NATIVE_ARCH": native_arch,
}
def _quote(s):
"""Quotes the given string for use in a shell command.
This function double-quotes the given string (in case it contains spaces or
other special characters) and escapes any special characters (dollar signs,
double-quotes, and backslashes) that may be present.
Args:
s: The string to quote.
Returns:
An escaped and quoted version of the string that can be passed to a shell
command.
"""
return ('"' +
s.replace("\\", "\\\\").replace("$", "\\$").replace('"', "\\\"") +
'"')
def cmake_var_string(cmake_vars):
"""Converts a dictionary to an input suitable for expand_cmake_vars.
Ideally we would jist stringify in the expand_cmake_vars() rule, but select()
interacts badly with genrules.
TODO(phawkins): replace the genrule() with native rule and delete this rule.
Args:
cmake_vars: a dictionary with string keys and values that are convertable to
strings.
Returns:
cmake_vars in a form suitable for passing to expand_cmake_vars.
"""
return " ".join([
_quote("{}={}".format(k, str(v)))
for (k, v) in cmake_vars.items()
])
def expand_cmake_vars(name, src, dst, cmake_vars):
"""Expands #cmakedefine, #cmakedefine01, and CMake variables in a text file.
Args:
name: the name of the rule
src: the input of the rule
dst: the output of the rule
cmake_vars: a string containing the CMake variables, as generated by
cmake_var_string.
"""
expand_cmake_vars_tool = "@org_tensorflow//third_party/llvm:expand_cmake_vars"
native.genrule(
name = name,
srcs = [src],
tools = [expand_cmake_vars_tool],
outs = [dst],
cmd = ("$(location {}) ".format(expand_cmake_vars_tool) + cmake_vars +
"< $< > $@"),
)
# TODO(phawkins): the set of CMake variables was hardcoded for expediency.
# However, we should really detect many of these via configure-time tests.
# The set of CMake variables common to all targets.
cmake_vars = {
# LLVM features
"ENABLE_BACKTRACES": 1,
"LLVM_BINDIR": "/dev/null",
"LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING": 0,
"LLVM_ENABLE_ABI_BREAKING_CHECKS": 0,
"LLVM_ENABLE_THREADS": 1,
"LLVM_ENABLE_ZLIB": 1,
"LLVM_HAS_ATOMICS": 1,
"LLVM_INCLUDEDIR": "/dev/null",
"LLVM_INFODIR": "/dev/null",
"LLVM_MANDIR": "/dev/null",
"LLVM_NATIVE_TARGET": 1,
"LLVM_NATIVE_TARGETINFO": 1,
"LLVM_NATIVE_TARGETMC": 1,
"LLVM_NATIVE_ASMPRINTER": 1,
"LLVM_NATIVE_ASMPARSER": 1,
"LLVM_NATIVE_DISASSEMBLER": 1,
"LLVM_PREFIX": "/dev/null",
"LLVM_VERSION_MAJOR": 0,
"LLVM_VERSION_MINOR": 0,
"LLVM_VERSION_PATCH": 0,
"PACKAGE_NAME": "llvm",
"PACKAGE_STRING": "llvm tensorflow-trunk",
"PACKAGE_VERSION": "tensorflow-trunk",
"RETSIGTYPE": "void",
}
# The set of CMake variables common to POSIX targets.
posix_cmake_vars = {
# Headers
"HAVE_DIRENT_H": 1,
"HAVE_DLFCN_H": 1,
"HAVE_ERRNO_H": 1,
"HAVE_EXECINFO_H": 1,
"HAVE_FCNTL_H": 1,
"HAVE_INTTYPES_H": 1,
"HAVE_PTHREAD_H": 1,
"HAVE_SIGNAL_H": 1,
"HAVE_STDINT_H": 1,
"HAVE_SYSEXITS_H": 1,
"HAVE_SYS_IOCTL_H": 1,
"HAVE_SYS_MMAN_H": 1,
"HAVE_SYS_PARAM_H": 1,
"HAVE_SYS_RESOURCE_H": 1,
"HAVE_SYS_STAT_H": 1,
"HAVE_SYS_TIME_H": 1,
"HAVE_SYS_TYPES_H": 1,
"HAVE_TERMIOS_H": 1,
"HAVE_UNISTD_H": 1,
"HAVE_ZLIB_H": 1,
# Features
"HAVE_BACKTRACE": 1,
"BACKTRACE_HEADER": "execinfo.h",
"HAVE_DLOPEN": 1,
"HAVE_FUTIMES": 1,
"HAVE_GETCWD": 1,
"HAVE_GETPAGESIZE": 1,
"HAVE_GETRLIMIT": 1,
"HAVE_GETRUSAGE": 1,
"HAVE_GETTIMEOFDAY": 1,
"HAVE_INT64_T": 1,
"HAVE_ISATTY": 1,
"HAVE_LIBEDIT": 1,
"HAVE_LIBPTHREAD": 1,
"HAVE_LIBZ": 1,
"HAVE_MKDTEMP": 1,
"HAVE_MKSTEMP": 1,
"HAVE_MKTEMP": 1,
"HAVE_PREAD": 1,
"HAVE_PTHREAD_GETSPECIFIC": 1,
"HAVE_PTHREAD_MUTEX_LOCK": 1,
"HAVE_PTHREAD_RWLOCK_INIT": 1,
"HAVE_REALPATH": 1,
"HAVE_SBRK": 1,
"HAVE_SETENV": 1,
"HAVE_SETRLIMIT": 1,
"HAVE_SIGALTSTACK": 1,
"HAVE_STRERROR": 1,
"HAVE_STRERROR_R": 1,
"HAVE_STRTOLL": 1,
"HAVE_SYSCONF": 1,
"HAVE_UINT64_T": 1,
"HAVE__UNWIND_BACKTRACE": 1,
# LLVM features
"LLVM_ON_UNIX": 1,
"LTDL_SHLIB_EXT": ".so",
}
# CMake variables specific to the Linux platform
linux_cmake_vars = {
"HAVE_MALLOC_H": 1,
"HAVE_LINK_H": 1,
"HAVE_MALLINFO": 1,
"HAVE_FUTIMENS": 1,
}
# CMake variables specific to the FreeBSD platform
freebsd_cmake_vars = {
"HAVE_MALLOC_H": 1,
"HAVE_LINK_H": 1,
}
# CMake variables specific to the Darwin (Mac OS X) platform.
darwin_cmake_vars = {
"HAVE_MALLOC_MALLOC_H": 1,
"HAVE_MALLOC_ZONE_STATISTICS": 1,
}
# CMake variables specific to the Windows platform.
win32_cmake_vars = {
# Headers
"HAVE_ERRNO_H": 1,
"HAVE_EXECINFO_H": 1,
"HAVE_FCNTL_H": 1,
"HAVE_FENV_H": 1,
"HAVE_INTTYPES_H": 1,
"HAVE_MALLOC_H": 1,
"HAVE_SIGNAL_H": 1,
"HAVE_STDINT_H": 1,
"HAVE_SYS_STAT_H": 1,
"HAVE_SYS_TYPES_H": 1,
"HAVE_ZLIB_H": 1,
# Features
"BACKTRACE_HEADER": "execinfo.h",
"HAVE_GETCWD": 1,
"HAVE_INT64_T": 1,
"HAVE_STRERROR": 1,
"HAVE_STRTOLL": 1,
"HAVE_SYSCONF": 1,
"HAVE_UINT64_T": 1,
"HAVE__CHSIZE_S": 1,
"HAVE___CHKSTK": 1,
# MSVC specific
"stricmp": "_stricmp",
"strdup": "_strdup",
# LLVM features
"LTDL_SHLIB_EXT": ".dll",
}
# Select a set of CMake variables based on the platform.
# TODO(phawkins): use a better method to select the right host triple, rather
# than hardcoding x86_64.
llvm_all_cmake_vars = select({
"@org_tensorflow//tensorflow:macos_x86_64": cmake_var_string(
_dict_add(
cmake_vars,
llvm_target_cmake_vars("X86", "x86_64-apple-darwin"),
posix_cmake_vars,
darwin_cmake_vars,
),
),
"@org_tensorflow//tensorflow:macos_arm64": cmake_var_string(
_dict_add(
cmake_vars,
llvm_target_cmake_vars("AArch64", "arm64-apple-darwin"),
posix_cmake_vars,
darwin_cmake_vars,
),
),
"@org_tensorflow//tensorflow:linux_aarch64": cmake_var_string(
_dict_add(
cmake_vars,
llvm_target_cmake_vars("AArch64", "aarch64-unknown-linux_gnu"),
posix_cmake_vars,
linux_cmake_vars,
),
),
"@org_tensorflow//tensorflow:linux_ppc64le": cmake_var_string(
_dict_add(
cmake_vars,
llvm_target_cmake_vars("PowerPC", "powerpc64le-unknown-linux_gnu"),
posix_cmake_vars,
linux_cmake_vars,
),
),
"@org_tensorflow//tensorflow:windows": cmake_var_string(
_dict_add(
cmake_vars,
llvm_target_cmake_vars("X86", "x86_64-pc-win32"),
win32_cmake_vars,
),
),
"@org_tensorflow//tensorflow:freebsd": cmake_var_string(
_dict_add(
cmake_vars,
llvm_target_cmake_vars("X86", "x86_64-unknown-freebsd"),
posix_cmake_vars,
),
),
"@org_tensorflow//tensorflow:linux_s390x": cmake_var_string(
_dict_add(
cmake_vars,
llvm_target_cmake_vars("SystemZ", "systemz-unknown-linux_gnu"),
posix_cmake_vars,
linux_cmake_vars,
),
),
"//conditions:default": cmake_var_string(
_dict_add(
cmake_vars,
llvm_target_cmake_vars("X86", "x86_64-unknown-linux_gnu"),
posix_cmake_vars,
linux_cmake_vars,
),
),
})
llvm_linkopts = select({
"@org_tensorflow//tensorflow:windows": [],
"@org_tensorflow//tensorflow:freebsd": ["-ldl", "-lm", "-lpthread", "-lexecinfo"],
"//conditions:default": ["-ldl", "-lm", "-lpthread"],
})
llvm_defines = select({
"@org_tensorflow//tensorflow:windows": [
"_CRT_SECURE_NO_DEPRECATE",
"_CRT_SECURE_NO_WARNINGS",
"_CRT_NONSTDC_NO_DEPRECATE",
"_CRT_NONSTDC_NO_WARNINGS",
"_SCL_SECURE_NO_DEPRECATE",
"_SCL_SECURE_NO_WARNINGS",
"UNICODE",
"_UNICODE",
],
"//conditions:default": [],
}) + [
"LLVM_ENABLE_STATS",
"__STDC_LIMIT_MACROS",
"__STDC_CONSTANT_MACROS",
"__STDC_FORMAT_MACROS",
"LLVM_BUILD_GLOBAL_ISEL",
]
llvm_copts = select({
"@org_tensorflow//tensorflow:windows": [
"-Zc:inline",
"-Zc:strictStrings",
"-Zc:rvalueCast",
"-Oi",
"-wd4141",
"-wd4146",
"-wd4180",
"-wd4244",
"-wd4258",
"-wd4267",
"-wd4291",
"-wd4345",
"-wd4351",
"-wd4355",
"-wd4456",
"-wd4457",
"-wd4458",
"-wd4459",
"-wd4503",
"-wd4624",
"-wd4722",
"-wd4800",
"-wd4100",
"-wd4127",
"-wd4512",
"-wd4505",
"-wd4610",
"-wd4510",
"-wd4702",
"-wd4245",
"-wd4706",
"-wd4310",
"-wd4701",
"-wd4703",
"-wd4389",
"-wd4611",
"-wd4805",
"-wd4204",
"-wd4577",
"-wd4091",
"-wd4592",
"-wd4319",
"-wd4324",
"-w14062",
"-we4238",
],
"//conditions:default": [],
})
# Platform specific sources for libSupport.
def llvm_support_platform_specific_srcs_glob():
return select({
"@org_tensorflow//tensorflow:windows": native.glob([
"lib/Support/Windows/*.inc",
"lib/Support/Windows/*.h",
]),
"//conditions:default": native.glob([
"lib/Support/Unix/*.inc",
"lib/Support/Unix/*.h",
]),
})
"""TensorFlow workspace initialization. Consult the WORKSPACE on how to use it."""
load("@llvm-raw//utils/bazel:configure.bzl", "llvm_configure", "llvm_disable_optional_support_deps")
def llvm_setup(name):
# Disable terminfo and zlib that are bundled with LLVM.
llvm_disable_optional_support_deps()
# Build @llvm-project from @llvm-raw using overlays.
llvm_configure(name = name)
......@@ -10,17 +10,10 @@ def repo(name):
tf_http_archive(
name = name,
sha256 = LLVM_SHA256,
strip_prefix = "llvm-project-" + LLVM_COMMIT,
strip_prefix = "llvm-project-{commit}".format(commit = LLVM_COMMIT),
urls = [
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/llvm/llvm-project/archive/{commit}.tar.gz".format(commit = LLVM_COMMIT),
"https://github.com/llvm/llvm-project/archive/{commit}.tar.gz".format(commit = LLVM_COMMIT),
],
link_files = {
"//third_party/llvm:llvm.autogenerated.BUILD": "llvm/BUILD",
"//third_party/mlir:BUILD": "mlir/BUILD",
"//third_party/mlir:build_defs.bzl": "mlir/build_defs.bzl",
"//third_party/mlir:linalggen.bzl": "mlir/linalggen.bzl",
"//third_party/mlir:tblgen.bzl": "mlir/tblgen.bzl",
"//third_party/mlir:test.BUILD": "mlir/test/BUILD",
},
build_file = "//third_party/llvm:BUILD.bazel",
)
此差异已折叠。
# This file is 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
"""Rules and macros for MLIR"""
def if_cuda_available(if_true, if_false = []):
return select({
# CUDA is not yet supported.
"//conditions:default": if_false,
})
def _cc_headers_only_impl(ctx):
return CcInfo(compilation_context = ctx.attr.src[CcInfo].compilation_context)
cc_headers_only = rule(
implementation = _cc_headers_only_impl,
attrs = {
"src": attr.label(
mandatory = True,
providers = [CcInfo],
),
},
doc = "Provides the headers from 'src' without linking anything.",
provides = [CcInfo],
)
# This file is 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
"""BUILD extensions for MLIR linalg generation."""
def genlinalg(name, linalggen, src, linalg_outs):
"""genlinalg() generates code from a tc spec file.
Args:
name: The name of the build rule for use in dependencies.
linalggen: The binary used to produce the output.
src: The tc spec file.
linalg_outs: A list of tuples (opts, out), where each opts is a string of
options passed to linalggen, and the out is the corresponding output file
produced.
"""
for (opts, out) in linalg_outs:
# All arguments to generate the output except output destination.
base_args = [
"$(location %s)" % linalggen,
"%s" % opts,
"$(location %s)" % src,
]
rule_suffix = "_".join(opts.replace("-", "_").replace("=", "_").split(" "))
# Rule to generate code using generated shell script.
native.genrule(
name = "%s_%s_genrule" % (name, rule_suffix),
srcs = [src],
outs = [out],
tools = [linalggen],
cmd = (" ".join(base_args)),
)
hdrs = [f for (opts, f) in linalg_outs]
native.cc_library(
name = name,
hdrs = hdrs,
textual_hdrs = hdrs,
)
# This file is 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
"""BUILD extensions for MLIR table generation."""
load("@bazel_skylib//lib:paths.bzl", "paths")
TdInfo = provider(
"Holds TableGen files and the dependencies and include paths necessary to" +
" build them.",
fields = {
"transitive_sources": "td files transitively used by this rule.",
"transitive_includes": (
"include arguments to add to the final TableGen invocation. These" +
" are the absolute directory paths that will be added with '-I'."
),
},
)
# For now we allow anything that provides DefaultInfo to just forward its files.
# In particular, this allows filegroups to be used. This is mostly to ease
# transition. In the future, the TdInfo provider will be required.
# TODO(gcmn): Switch to enforcing TdInfo provider.
def _get_dep_transitive_srcs(dep):
"""Extract TdInfo.transitive_sources, falling back to DefaultInfo.files."""
if TdInfo in dep:
return dep[TdInfo].transitive_sources
return dep[DefaultInfo].files
def _get_dep_transitive_includes(dep):
"""Extract TdInfo.transitive_includes, falling back to an empty depset()."""
if TdInfo in dep:
return dep[TdInfo].transitive_includes
return depset()
def _get_transitive_srcs(srcs, deps):
"""Obtain the source files for a target and its transitive dependencies.
Args:
srcs: a list of source files
deps: a list of targets that are direct dependencies
Returns:
a collection of the transitive sources
"""
return depset(
direct = srcs,
transitive = [_get_dep_transitive_srcs(dep) for dep in deps],
)
def _get_transitive_includes(includes, deps):
"""Obtain the includes paths for a target and its transitive dependencies.
Args:
includes: a list of include paths
deps: a list of targets that are direct dependencies
Returns:
a collection of the transitive include paths
"""
return depset(
direct = includes,
transitive = [_get_dep_transitive_includes(dep) for dep in deps],
)
def _prefix_roots(ctx, includes):
"""Map the given includes to be relative to all root directories.
This will expand them to be relative to all the root directories available
in the execution environment for ctx.run (bin and genfiles in addition to
the normal source root)
"""
prefixed_includes = []
for include in includes:
prefixed_includes.append(include)
prefixed_includes.append(paths.join(ctx.genfiles_dir.path, include))
prefixed_includes.append(paths.join(ctx.bin_dir.path, include))
return prefixed_includes
def _resolve_includes(ctx, includes):
"""Resolves include paths to paths relative to the execution root.
Relative paths are interpreted as relative to the current label's package.
Absolute paths are interpreted as relative to the current label's workspace
root."""
package = ctx.label.package
workspace_root = ctx.label.workspace_root
workspace_root = workspace_root if workspace_root else "."
resolved_includes = []
for include in includes:
if paths.is_absolute(include):
include = include.lstrip("/")
else:
include = paths.join(package, include)
include = paths.join(workspace_root, include)
resolved_includes.extend(_prefix_roots(ctx, [include]))
return resolved_includes
def _td_library_impl(ctx):
trans_srcs = _get_transitive_srcs(ctx.files.srcs, ctx.attr.deps)
trans_includes = _get_transitive_includes(
_resolve_includes(ctx, ctx.attr.includes),
ctx.attr.deps,
)
# Note that we include srcs in runfiles. A td_library doesn't compile to
# produce an output: it's just a depset of source files and include
# directories. So if it is needed for execution of some rule (likely
# something running tblgen as a test action), the files needed are the same
# as the source files.
# Note: not using merge_all, as that is not available in Bazel 4.0
runfiles = ctx.runfiles(ctx.files.srcs)
for src in ctx.attr.srcs:
runfiles = runfiles.merge(src[DefaultInfo].default_runfiles)
for dep in ctx.attr.deps:
runfiles = runfiles.merge(dep[DefaultInfo].default_runfiles)
return [
DefaultInfo(files = trans_srcs, runfiles = runfiles),
TdInfo(
transitive_sources = trans_srcs,
transitive_includes = trans_includes,
),
]
td_library = rule(
_td_library_impl,
attrs = {
"srcs": attr.label_list(allow_files = True),
"includes": attr.string_list(
doc = "Include paths to be added to the final TableGen tool" +
" invocation. Relative paths are interpreted as relative to" +
" the current label's package. Absolute paths are" +
" interpreted as relative to the current label's workspace",
),
# TODO(gcmn): limit to TdInfo providers.
"deps": attr.label_list(
doc = "Dependencies providing TableGen source files and include" +
" paths.",
),
},
)
def _gentbl_rule_impl(ctx):
td_file = ctx.file.td_file
trans_srcs = _get_transitive_srcs(
ctx.files.td_srcs + [td_file],
ctx.attr.deps,
)
# Note that the td_file.dirname is already relative to the execution root,
# i.e. may contain an `external/<workspace_name>` prefix if the current
# workspace is not the main workspace. Therefore it is not included in the
# _resolve_includes call that prepends this prefix.
trans_includes = _get_transitive_includes(
_resolve_includes(ctx, ctx.attr.includes + ["/"]) +
_prefix_roots(ctx, [td_file.dirname]),
ctx.attr.deps,
)
args = ctx.actions.args()
args.add_all(ctx.attr.opts)
args.add(td_file)
args.add_all(trans_includes, before_each = "-I")
args.add("-o", ctx.outputs.out.path)
ctx.actions.run(
outputs = [ctx.outputs.out],
inputs = trans_srcs,
executable = ctx.executable.tblgen,
arguments = [args],
mnemonic = "TdGenerate",
)
return [DefaultInfo()]
gentbl_rule = rule(
_gentbl_rule_impl,
doc = "Generates tabular code from a table definition file.",
# Match genrule behavior
output_to_genfiles = True,
attrs = {
"tblgen": attr.label(
doc = "The TableGen executable with which to generate `out`.",
executable = True,
cfg = "exec",
),
"td_file": attr.label(
doc = "The TableGen file to run through `tblgen`.",
allow_single_file = True,
mandatory = True,
),
"td_srcs": attr.label_list(
doc = "Additional TableGen files included by `td_file`. It is not" +
" necessary to list td_file here (though not an error).",
allow_files = True,
),
# TODO(gcmn): limit to TdInfo providers.
"deps": attr.label_list(
doc = "Dependencies providing TableGen source files and include" +
" paths.",
),
"out": attr.output(
doc = "The output file for the TableGen invocation.",
mandatory = True,
),
"opts": attr.string_list(
doc = "Additional command line options to add to the TableGen" +
" invocation. For include arguments, prefer to use" +
" `includes`.",
),
"includes": attr.string_list(
doc = "Include paths to be added to the final TableGen tool" +
" invocation. Relative paths are interpreted as relative to" +
" the current label's package. Absolute paths are" +
" interpreted as relative to the current label's workspace." +
" Includes are applied from all roots available in the" +
" execution environment (source, genfiles, and bin" +
" directories). The execution roots themselves and the " +
" directory of td_file are always added.",
),
},
)
# TODO(gcmn): Figure out how to reduce duplication with _gentbl_rule_impl
def _gentbl_test_impl(ctx):
td_file = ctx.file.td_file
# Note that the td_file.dirname is already relative to the execution root,
# i.e. may contain an `external/<workspace_name>` prefix if the current
# workspace is not the main workspace. Therefore it is not included in the
# _resolve_includes call that prepends this prefix.
trans_includes = _get_transitive_includes(
_resolve_includes(ctx, ctx.attr.includes + ["/"]) +
_prefix_roots(ctx, [td_file.dirname]),
ctx.attr.deps,
)
test_args = [ctx.executable.tblgen.short_path]
test_args.extend(ctx.attr.opts)
test_args.append(td_file.path)
test_args.extend(["-I " + include for include in trans_includes.to_list()])
test_args.extend(["-o", "/dev/null"])
ctx.actions.write(
ctx.outputs.executable,
content = " ".join(test_args),
is_executable = True,
)
# Note: not using merge_all, as that is not available in Bazel 4.0
runfiles = ctx.runfiles(
files = [ctx.executable.tblgen],
transitive_files = _get_transitive_srcs(
ctx.files.td_srcs + [td_file],
ctx.attr.deps,
),
)
for src in ctx.attr.td_srcs:
runfiles = runfiles.merge(src[DefaultInfo].default_runfiles)
for dep in ctx.attr.deps:
runfiles = runfiles.merge(dep[DefaultInfo].default_runfiles)
return [
coverage_common.instrumented_files_info(
ctx,
source_attributes = ["td_file", "td_srcs"],
dependency_attributes = ["tblgen", "deps"],
),
DefaultInfo(runfiles = runfiles),
]
gentbl_test = rule(
_gentbl_test_impl,
test = True,
doc = "A shell test that tests the given TablegGen invocation. Note" +
" that unlike gentbl_rule, this builds and invokes `tblgen` in the" +
" target configuration. Takes all the same arguments as gentbl_rule" +
" except for `out` (as it does not generate any output)",
attrs = {
"tblgen": attr.label(
doc = "The TableGen executable run in the shell command. Note" +
" that this is built in the target configuration.",
executable = True,
cfg = "target",
),
"td_file": attr.label(
doc = "See gentbl_rule.td_file",
allow_single_file = True,
mandatory = True,
),
"td_srcs": attr.label_list(
doc = "See gentbl_rule.td_srcs",
allow_files = True,
),
"deps": attr.label_list(doc = "See gentbl_rule.deps"),
"opts": attr.string_list(doc = "See gentbl_rule.opts"),
"includes": attr.string_list(doc = "See gentbl_rule.includes"),
},
)
def gentbl_filegroup(
name,
tblgen,
td_file,
tbl_outs,
td_srcs = [],
includes = [],
deps = [],
test = False,
skip_opts = [],
**kwargs):
"""Create multiple TableGen generated files using the same tool and input.
All generated outputs are bundled in a file group with the given name.
Args:
name: The name of the generated filegroup rule for use in dependencies.
tblgen: The binary used to produce the output.
td_file: The primary table definitions file.
tbl_outs: A list of tuples ([opts], out), where each 'opts' is a list of
options passed to tblgen, each option being a string, and 'out' is the
corresponding output file produced.
td_srcs: See gentbl_rule.td_srcs
includes: See gentbl_rule.includes
deps: See gentbl_rule.deps
test: Whether to create a shell test that invokes the tool too.
skip_opts: Files generated using these opts in tbl_outs will be excluded
from the generated filegroup.
**kwargs: Extra keyword arguments to pass to all generated rules.
"""
for (opts, out) in tbl_outs:
first_opt = opts[0] if opts else ""
rule_suffix = "_{}_{}".format(
first_opt.replace("-", "_").replace("=", "_"),
str(hash(" ".join(opts))),
)
gentbl_name = "%s_%s_genrule" % (name, rule_suffix)
gentbl_rule(
name = gentbl_name,
td_file = td_file,
tblgen = tblgen,
opts = opts,
td_srcs = td_srcs,
deps = deps,
includes = includes,
out = out,
**kwargs
)
if test:
# Also run the generator in the target configuration as a test. This
# means it gets run with asserts and sanitizers and such when they
# are enabled and is counted in coverage.
gentbl_test(
name = "%s_test" % (gentbl_name,),
td_file = td_file,
tblgen = tblgen,
opts = opts,
td_srcs = td_srcs,
deps = deps,
includes = includes,
# Shell files not executable on Windows.
# TODO(gcmn): Support windows.
tags = ["no_windows"],
**kwargs
)
included_srcs = [f for (opts, f) in tbl_outs if not any([skip_opt in opts for skip_opt in skip_opts])]
native.filegroup(
name = name,
srcs = included_srcs,
**kwargs
)
def gentbl_cc_library(
name,
tblgen,
td_file,
tbl_outs,
td_srcs = [],
includes = [],
deps = [],
strip_include_prefix = None,
test = False,
**kwargs):
"""Create multiple TableGen generated files using the same tool and input.
All generated outputs are bundled in a cc_library rule.
Args:
name: The name of the generated cc_library rule for use in dependencies.
tblgen: The binary used to produce the output.
td_file: The primary table definitions file.
tbl_outs: A list of tuples ([opts], out), where each 'opts' is a list of
options passed to tblgen, each option being a string, and 'out' is the
corresponding output file produced.
td_srcs: See gentbl_rule.td_srcs
includes: See gentbl_rule.includes
deps: See gentbl_rule.deps
strip_include_prefix: attribute to pass through to cc_library.
test: whether to create a shell test that invokes the tool too.
**kwargs: Extra keyword arguments to pass to all generated rules.
"""
filegroup_name = name + "_filegroup"
gentbl_filegroup(
name = filegroup_name,
tblgen = tblgen,
td_file = td_file,
tbl_outs = tbl_outs,
td_srcs = td_srcs,
includes = includes,
deps = deps,
test = test,
skip_opts = ["-gen-op-doc"],
**kwargs
)
native.cc_library(
name = name,
# strip_include_prefix does not apply to textual_hdrs.
# https://github.com/bazelbuild/bazel/issues/12424
hdrs = [":" + filegroup_name] if strip_include_prefix else [],
strip_include_prefix = strip_include_prefix,
textual_hdrs = [":" + filegroup_name],
**kwargs
)
# This file is 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("@llvm-project//mlir:tblgen.bzl", "gentbl_cc_library", "td_library")
package(
default_visibility = [":test_friends"],
licenses = ["notice"],
)
# Please only depend on this from MLIR tests.
package_group(
name = "test_friends",
packages = ["//..."],
)
cc_library(
name = "IRProducingAPITest",
hdrs = ["APITest.h"],
includes = ["."],
)
cc_library(
name = "TestAnalysis",
srcs = glob(["lib/Analysis/*.cpp"]),
includes = ["lib/Dialect/Test"],
deps = [
":TestDialect",
"@llvm-project//llvm:Support",
"@llvm-project//mlir:Affine",
"@llvm-project//mlir:Analysis",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:MemRefDialect",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:Support",
],
)
td_library(
name = "TestOpTdFiles",
srcs = [
"lib/Dialect/Test/TestInterfaces.td",
"lib/Dialect/Test/TestOps.td",
"@llvm-project//mlir:include/mlir/Dialect/DLTI/DLTIBase.td",
"@llvm-project//mlir:include/mlir/IR/OpAsmInterface.td",
"@llvm-project//mlir:include/mlir/IR/RegionKindInterface.td",
"@llvm-project//mlir:include/mlir/IR/SymbolInterfaces.td",
"@llvm-project//mlir:include/mlir/Interfaces/CallInterfaces.td",
"@llvm-project//mlir:include/mlir/Interfaces/ControlFlowInterfaces.td",
"@llvm-project//mlir:include/mlir/Interfaces/CopyOpInterface.td",
"@llvm-project//mlir:include/mlir/Interfaces/DataLayoutInterfaces.td",
"@llvm-project//mlir:include/mlir/Interfaces/InferTypeOpInterface.td",
],
deps = [
"@llvm-project//mlir:OpBaseTdFiles",
"@llvm-project//mlir:SideEffectTdFiles",
],
)
gentbl_cc_library(
name = "TestOpsIncGen",
strip_include_prefix = "lib/Dialect/Test",
tbl_outs = [
(
["-gen-op-decls"],
"lib/Dialect/Test/TestOps.h.inc",
),
(
["-gen-op-defs"],
"lib/Dialect/Test/TestOps.cpp.inc",
),
(
[
"-gen-dialect-decls",
"-dialect=test",
],
"lib/Dialect/Test/TestOpsDialect.h.inc",
),
(
[
"-gen-dialect-defs",
"-dialect=test",
],
"lib/Dialect/Test/TestOpsDialect.cpp.inc",
),
(
["-gen-enum-decls"],
"lib/Dialect/Test/TestOpEnums.h.inc",
),
(
["-gen-enum-defs"],
"lib/Dialect/Test/TestOpEnums.cpp.inc",
),
(
["-gen-struct-attr-decls"],
"lib/Dialect/Test/TestOpStructs.h.inc",
),
(
["-gen-struct-attr-defs"],
"lib/Dialect/Test/TestOpStructs.cpp.inc",
),
(
["-gen-rewriters"],
"lib/Dialect/Test/TestPatterns.inc",
),
],
tblgen = "@llvm-project//mlir:mlir-tblgen",
td_file = "lib/Dialect/Test/TestOps.td",
test = True,
deps = [
":TestOpTdFiles",
],
)
gentbl_cc_library(
name = "TestInterfacesIncGen",
strip_include_prefix = "lib/Dialect/Test",
tbl_outs = [
(
["-gen-attr-interface-decls"],
"lib/Dialect/Test/TestAttrInterfaces.h.inc",
),
(
["-gen-attr-interface-defs"],
"lib/Dialect/Test/TestAttrInterfaces.cpp.inc",
),
(
["-gen-type-interface-decls"],
"lib/Dialect/Test/TestTypeInterfaces.h.inc",
),
(
["-gen-type-interface-defs"],
"lib/Dialect/Test/TestTypeInterfaces.cpp.inc",
),
(
["-gen-op-interface-decls"],
"lib/Dialect/Test/TestOpInterfaces.h.inc",
),
(
["-gen-op-interface-defs"],
"lib/Dialect/Test/TestOpInterfaces.cpp.inc",
),
],
tblgen = "@llvm-project//mlir:mlir-tblgen",
td_file = "lib/Dialect/Test/TestInterfaces.td",
test = True,
deps = [
"@llvm-project//mlir:OpBaseTdFiles",
"@llvm-project//mlir:SideEffectInterfacesTdFiles",
],
)
gentbl_cc_library(
name = "TestAttrDefsIncGen",
strip_include_prefix = "lib/Dialect/Test",
tbl_outs = [
(
["-gen-attrdef-decls"],
"lib/Dialect/Test/TestAttrDefs.h.inc",
),
(
["-gen-attrdef-defs"],
"lib/Dialect/Test/TestAttrDefs.cpp.inc",
),
],
tblgen = "@llvm-project//mlir:mlir-tblgen",
td_file = "lib/Dialect/Test/TestAttrDefs.td",
test = True,
deps = [
":TestOpTdFiles",
],
)
gentbl_cc_library(
name = "TestTypeDefsIncGen",
strip_include_prefix = "lib/Dialect/Test",
tbl_outs = [
(
[
"-gen-typedef-decls",
"--typedefs-dialect=test",
],
"lib/Dialect/Test/TestTypeDefs.h.inc",
),
(
[
"-gen-typedef-defs",
"--typedefs-dialect=test",
],
"lib/Dialect/Test/TestTypeDefs.cpp.inc",
),
],
tblgen = "@llvm-project//mlir:mlir-tblgen",
td_file = "lib/Dialect/Test/TestTypeDefs.td",
test = True,
deps = [
":TestOpTdFiles",
"@llvm-project//mlir:BuiltinDialectTdFiles",
],
)
cc_library(
name = "TestDialect",
srcs = [
"lib/Dialect/Test/TestAttributes.cpp",
"lib/Dialect/Test/TestDialect.cpp",
"lib/Dialect/Test/TestInterfaces.cpp",
"lib/Dialect/Test/TestPatterns.cpp",
"lib/Dialect/Test/TestTraits.cpp",
"lib/Dialect/Test/TestTypes.cpp",
],
hdrs = [
"lib/Dialect/Test/TestAttributes.h",
"lib/Dialect/Test/TestDialect.h",
"lib/Dialect/Test/TestInterfaces.h",
"lib/Dialect/Test/TestTypes.h",
],
includes = [
"lib/Dialect/Test",
],
deps = [
":TestAttrDefsIncGen",
":TestInterfacesIncGen",
":TestOpsIncGen",
":TestTypeDefsIncGen",
"@llvm-project//llvm:Support",
"@llvm-project//mlir:ControlFlowInterfaces",
"@llvm-project//mlir:CopyOpInterface",
"@llvm-project//mlir:DLTIDialect",
"@llvm-project//mlir:DataLayoutInterfaces",
"@llvm-project//mlir:DerivedAttributeOpInterface",
"@llvm-project//mlir:Dialect",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:InferTypeOpInterface",
"@llvm-project//mlir:LLVMDialect",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:Reducer",
"@llvm-project//mlir:SideEffects",
"@llvm-project//mlir:StandardOps",
"@llvm-project//mlir:StandardOpsTransforms",
"@llvm-project//mlir:TensorDialect",
"@llvm-project//mlir:TransformUtils",
"@llvm-project//mlir:Transforms",
],
)
cc_library(
name = "TestIR",
srcs = glob(["lib/IR/*.cpp"]),
deps = [
":TestDialect",
"@llvm-project//llvm:Support",
"@llvm-project//mlir:Analysis",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:LinalgOps",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:StandardOps",
"@llvm-project//mlir:Support",
],
)
cc_library(
name = "TestPass",
srcs = glob(["lib/Pass/*.cpp"]),
deps = [
"@llvm-project//llvm:Support",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:Support",
],
)
cc_library(
name = "TestRewrite",
srcs = [
"lib/Rewrite/TestPDLByteCode.cpp",
],
deps = [
"@llvm-project//mlir:IR",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:Support",
"@llvm-project//mlir:TransformUtils",
],
)
cc_library(
name = "TestReducer",
srcs = [
"lib/Reducer/MLIRTestReducer.cpp",
],
deps = [
"@llvm-project//mlir:IR",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:Support",
],
)
cc_library(
name = "TestTransforms",
srcs = glob(["lib/Transforms/*.cpp"]),
defines = ["MLIR_CUDA_CONVERSIONS_ENABLED"],
includes = ["lib/Dialect/Test"],
deps = [
":TestDialect",
"@llvm-project//llvm:Support",
"@llvm-project//mlir:Affine",
"@llvm-project//mlir:Analysis",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:MathDialect",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:SCFDialect",
"@llvm-project//mlir:SPIRVDialect",
"@llvm-project//mlir:StandardOps",
"@llvm-project//mlir:TransformUtils",
],
)
cc_library(
name = "TestStandardToLLVM",
srcs = glob(["lib/Conversion/StandardToLLVM/*.cpp"]),
defines = ["MLIR_CUDA_CONVERSIONS_ENABLED"],
includes = ["lib/Dialect/Test"],
deps = [
":TestDialect",
"@llvm-project//mlir:LLVMCommonConversion",
"@llvm-project//mlir:LLVMDialect",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:StandardOps",
"@llvm-project//mlir:StandardToLLVM",
],
)
cc_library(
name = "TestAffine",
srcs = glob([
"lib/Dialect/Affine/*.cpp",
]),
deps = [
"@llvm-project//llvm:Support",
"@llvm-project//mlir:Affine",
"@llvm-project//mlir:AffineTransforms",
"@llvm-project//mlir:AffineUtils",
"@llvm-project//mlir:Analysis",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:MemRefDialect",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:Support",
"@llvm-project//mlir:Transforms",
"@llvm-project//mlir:VectorOps",
],
)
cc_library(
name = "TestDLTI",
srcs = glob(["lib/Dialect/DLTI/*.cpp"]),
defines = ["MLIR_CUDA_CONVERSIONS_ENABLED"],
includes = ["lib/Dialect/Test"],
deps = [
":TestDialect",
"@llvm-project//mlir:Analysis",
"@llvm-project//mlir:DLTIDialect",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:Pass",
],
)
cc_library(
name = "TestGPU",
srcs = glob(["lib/Dialect/GPU/*.cpp"]),
defines = ["MLIR_CUDA_CONVERSIONS_ENABLED"],
includes = ["lib/Dialect/Test"],
deps = [
"@llvm-project//llvm:NVPTXCodeGen",
"@llvm-project//llvm:Support",
"@llvm-project//mlir:Affine",
"@llvm-project//mlir:GPUDialect",
"@llvm-project//mlir:GPUTransforms",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:MemRefDialect",
"@llvm-project//mlir:NVVMToLLVMIRTranslation",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:ROCDLToLLVMIRTranslation",
"@llvm-project//mlir:SCFDialect",
"@llvm-project//mlir:SPIRVDialect",
"@llvm-project//mlir:StandardOps",
"@llvm-project//mlir:ToLLVMIRTranslation",
"@llvm-project//mlir:TransformUtils",
],
)
cc_library(
name = "TestLinalg",
srcs = glob(["lib/Dialect/Linalg/*.cpp"]),
defines = ["MLIR_CUDA_CONVERSIONS_ENABLED"],
includes = ["lib/Dialect/Test"],
deps = [
"@llvm-project//llvm:Support",
"@llvm-project//mlir:Affine",
"@llvm-project//mlir:GPUDialect",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:LinalgOps",
"@llvm-project//mlir:LinalgTransforms",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:StandardOps",
"@llvm-project//mlir:TransformUtils",
"@llvm-project//mlir:VectorOps",
"@llvm-project//mlir:VectorToSCF",
],
)
cc_library(
name = "TestMath",
srcs = glob(["lib/Dialect/Math/*.cpp"]),
defines = ["MLIR_CUDA_CONVERSIONS_ENABLED"],
includes = ["lib/Dialect/Test"],
deps = [
"@llvm-project//mlir:MathDialect",
"@llvm-project//mlir:MathTransforms",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:TransformUtils",
"@llvm-project//mlir:VectorOps",
],
)
cc_library(
name = "TestSCF",
srcs = glob(["lib/Dialect/SCF/*.cpp"]),
defines = ["MLIR_CUDA_CONVERSIONS_ENABLED"],
includes = ["lib/Dialect/Test"],
deps = [
"@llvm-project//llvm:Support",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:SCFDialect",
"@llvm-project//mlir:SCFTransforms",
"@llvm-project//mlir:TransformUtils",
],
)
cc_library(
name = "TestShapeDialect",
srcs = [
"lib/Dialect/Shape/TestShapeFunctions.cpp",
],
deps = [
"@llvm-project//llvm:Support",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:InferTypeOpInterface",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:Shape",
],
)
cc_library(
name = "TestSPIRV",
srcs = glob([
"lib/Dialect/SPIRV/*.cpp",
]),
deps = [
"@llvm-project//mlir:GPUDialect",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:SPIRVConversion",
"@llvm-project//mlir:SPIRVDialect",
"@llvm-project//mlir:SPIRVModuleCombiner",
"@llvm-project//mlir:Transforms",
],
)
cc_library(
name = "TestStandardOps",
srcs = glob(["lib/Dialect/StandardOps/*.cpp"]),
defines = ["MLIR_CUDA_CONVERSIONS_ENABLED"],
includes = ["lib/Dialect/Test"],
deps = [
":TestDialect",
"@llvm-project//mlir:Affine",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:StandardOps",
"@llvm-project//mlir:StandardOpsTransforms",
"@llvm-project//mlir:TransformUtils",
],
)
cc_library(
name = "TestVector",
srcs = glob(["lib/Dialect/Vector/*.cpp"]),
defines = ["MLIR_CUDA_CONVERSIONS_ENABLED"],
includes = ["lib/Dialect/Test"],
deps = [
"@llvm-project//mlir:Affine",
"@llvm-project//mlir:Analysis",
"@llvm-project//mlir:LinalgOps",
"@llvm-project//mlir:MemRefDialect",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:SCFDialect",
"@llvm-project//mlir:StandardOps",
"@llvm-project//mlir:TransformUtils",
"@llvm-project//mlir:VectorOps",
"@llvm-project//mlir:VectorToSCF",
],
)
cc_library(
name = "TestTypeDialect",
srcs = glob([
"lib/Dialect/LLVMIR/*.cpp",
]),
deps = [
":TestDialect",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:LLVMDialect",
],
)
cc_library(
name = "TestTosaDialect",
srcs = glob([
"lib/Dialect/Tosa/*.cpp",
]),
deps = [
"@llvm-project//mlir:IR",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:StandardOps",
"@llvm-project//mlir:TensorDialect",
"@llvm-project//mlir:TosaDialect",
"@llvm-project//mlir:Transforms",
],
)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册