diff --git a/utils/bazel/.bazelignore b/utils/bazel/.bazelignore new file mode 100644 --- /dev/null +++ b/utils/bazel/.bazelignore @@ -0,0 +1 @@ +llvm-project-overlay diff --git a/utils/bazel/.bazelrc b/utils/bazel/.bazelrc new file mode 100644 --- /dev/null +++ b/utils/bazel/.bazelrc @@ -0,0 +1,150 @@ +# 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 + +############################################################################### +# Common flags that apply to all configurations. +# Use sparingly for things common to all compilers and platforms. +############################################################################### +# Prevent invalid caching if input files are modified during a build. +build --experimental_guard_against_concurrent_changes + +############################################################################### +# Options to select different strategies for linking potential dependent +# libraries. The default leaves it disabled. +############################################################################### + +build:zlib_external --repo_env=BAZEL_LLVM_ZLIB_STRATEGY=external +build:zlib_system --repo_env=BAZEL_LLVM_ZLIB_STRATEGY=system + +build:terminfo_external --repo_env=BAZEL_LLVM_TERMINFO_STRATEGY=external +build:terminfo_system --repo_env=BAZEL_LLVM_TERMINFO_STRATEGY=system + +############################################################################### +# Options for "generic_clang" builds: these options should generally apply to +# builds using a Clang-based compiler, and default to the `clang` executable on +# the `PATH`. While these are provided for convenience and may serve as a +# reference, it would be preferable for users to configure an explicit C++ +# toolchain instead of relying on `.bazelrc` files. +############################################################################### + +# Set the default compiler to the `clang` binary on the `PATH`. +build:generic_clang --repo_env=CC=clang + +# C++14 standard version is required. +build:generic_clang --cxxopt=-std=c++14 --host_cxxopt=-std=c++14 + +# The Clang available on MacOS has a warning that isn't clean on MLIR code. The +# warning doesn't show up with more recent Clangs, so just disable for now. +build:generic_clang --cxxopt=-Wno-range-loop-analysis --host_cxxopt=-Wno-range-loop-analysis + +# Use `-Wall` and `-Werror` for Clang. +build:generic_clang --copt=-Wall --copt=-Werror --host_copt=-Wall --host_copt=-Werror +# This doesn't appear to be enforced by any upstream bot. +build:generic_clang --copt=-Wno-unused --host_copt=-Wno-unused + +############################################################################### +# Options for "generic_gcc" builds: these options should generally apply to +# builds using a GCC-based compiler, and default to the `gcc` executable on +# the `PATH`. While these are provided for convenience and may serve as a +# reference, it would be preferable for users to configure an explicit C++ +# toolchain instead of relying on `.bazelrc` files. +############################################################################### + +# Set the default compiler to the `gcc` binary on the `PATH`. +build:generic_gcc --repo_env=CC=gcc + +# C++14 standard version is required. +build:generic_gcc --cxxopt=-std=c++14 --host_cxxopt=-std=c++14 + +# Disable GCC warnings that are noisy and/or false positives on LLVM code. +# These need to be global as some code triggering these is in header files. +build:generic_gcc --copt=-Wno-unused-parameter --host_copt=-Wno-unused-parameter +build:generic_gcc --copt=-Wno-comment --host_copt=-Wno-comment +build:generic_gcc --cxxopt=-Wno-class-memaccess --host_cxxopt=-Wno-class-memaccess +build:generic_gcc --copt=-Wno-maybe-uninitialized --host_copt=-Wno-maybe-uninitialized +build:generic_gcc --copt=-Wno-misleading-indentation --host_copt=-Wno-misleading-indentation + +# Use `-Werror` for GCC to make sure warnings don't slip past. +build:generic_gcc --copt=-Werror --host_copt=-Werror + +############################################################################### +# Windows specific flags for building with VC. +############################################################################### + +build:msvc --copt=/WX --host_copt=/WX # Treat warnings as errors... +# ...but disable the ones that are violated +build:msvc --copt=/wd4141 --host_copt=/wd4141 # inline used more than once +build:msvc --copt=/wd4244 --host_copt=/wd4244 # conversion type -> type +build:msvc --copt=/wd4267 --host_copt=/wd4267 # conversion size_t -> type +build:msvc --copt=/wd4273 --host_copt=/wd4273 # multiple definitions with different dllimport +build:msvc --copt=/wd4319 --host_copt=/wd4319 # zero-extending after complement +build:msvc --copt=/wd4624 --host_copt=/wd4624 # destructor was implicitly defined as deleted +build:msvc --copt=/wd4804 --host_copt=/wd4804 # comparisons between bool and int +build:msvc --copt=/wd4805 --host_copt=/wd4805 # comparisons between bool and int + +build:msvc --linkopt=/WX --host_linkopt=/WX # Treat warnings as errors... +# ...but disable the ones that are violated. +build:msvc --linkopt=/IGNORE:4001 --host_linkopt=/IGNORE:4001 # no object files + +# Yay for security warnings. Boo for non-standard. +build:msvc --copt=/D_CRT_SECURE_NO_WARNINGS --host_copt=/D_CRT_SECURE_NO_WARNINGS + +############################################################################### + +############################################################################### +# Configuration for building remotely using Remote Build Execution (RBE) +# Based on https://github.com/bazelbuild/bazel-toolchains/blob/master/bazelrc/bazel-1.0.0.bazelrc +############################################################################### + +build:rbe --remote_instance_name=projects/llvm-bazel/instances/default_instance + +# Depending on how many machines are in the remote execution instance, setting +# this higher can make builds faster by allowing more jobs to run in parallel. +# Setting it too high can result in jobs that timeout, however, while waiting +# for a remote machine to execute them. +build:rbe --jobs=150 + +# Set several flags related to specifying the platform, toolchain and java +# properties. +# These flags should only be used as is for the rbe-ubuntu16-04 container +# and need to be adapted to work with other toolchain containers. +build:rbe --host_javabase=@rbe_default//java:jdk +build:rbe --javabase=@rbe_default//java:jdk +build:rbe --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8 +build:rbe --java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8 +build:rbe --crosstool_top=@rbe_default//cc:toolchain +build:rbe --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 +# Platform flags: +# The toolchain container used for execution is defined in the target indicated +# by "extra_execution_platforms", "host_platform" and "platforms". +# More about platforms: https://docs.bazel.build/versions/master/platforms.html +build:rbe --extra_toolchains=@rbe_default//config:cc-toolchain +build:rbe --extra_execution_platforms=@rbe_default//config:platform +build:rbe --host_platform=@rbe_default//config:platform +build:rbe --platforms=@rbe_default//config:platform + +build:rbe --define=EXECUTOR=remote + +# Enable remote execution so actions are performed on the remote systems. +build:rbe --remote_executor=grpcs://remotebuildexecution.googleapis.com + +# Enforce stricter environment rules, which eliminates some non-hermetic +# behavior and therefore improves both the remote cache hit rate and the +# correctness and repeatability of the build. +build:rbe --incompatible_strict_action_env=true + +# Set a higher timeout value, just in case. +build:rbe --remote_timeout=3600 + +# Local disk cache is incompatible with remote execution (for obvious reasons). +build:rbe --disk_cache="" + +# Enable authentication. This will pick up application default credentials by +# default. You can use --google_credentials=some_file.json to use a service +# account credential instead. +build:rbe --google_default_credentials=true + +# The user.bazelrc file is not checked in but available for local mods. +# Always keep this at the end of the file so that user flags override. +try-import %workspace%/user.bazelrc diff --git a/utils/bazel/.bazelversion b/utils/bazel/.bazelversion new file mode 100644 --- /dev/null +++ b/utils/bazel/.bazelversion @@ -0,0 +1 @@ +4.0.0 diff --git a/utils/bazel/.gitignore b/utils/bazel/.gitignore new file mode 100644 --- /dev/null +++ b/utils/bazel/.gitignore @@ -0,0 +1,5 @@ +# Bazel artifacts +/bazel-* + +# Per-user bazelrc files +user.bazelrc diff --git a/utils/bazel/BUILD.bazel b/utils/bazel/BUILD.bazel new file mode 100644 --- /dev/null +++ b/utils/bazel/BUILD.bazel @@ -0,0 +1,5 @@ +# 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 + +# Required to reference .bzl files in this package diff --git a/utils/bazel/README.md b/utils/bazel/README.md new file mode 100644 --- /dev/null +++ b/utils/bazel/README.md @@ -0,0 +1,130 @@ +# Introduction + +*Warning* The Bazel build is experimental and best-effort, supported in line +with the policy for +[LLVM's peripheral support tier](https://llvm.org/docs/SupportPolicy.html). +LLVM's official build system is CMake. If in doubt use that. If you make changes +to LLVM, you're expected to update the CMake build but you don't need to update +Bazel build files. Reviewers should not ask authors to update Bazel build files +unless the author has opted in to support Bazel. Keeping the Bazel build files +up-to-date is on the people who use the Bazel build. + +[Bazel](https://bazel.build/) is a multi-language build system focused on +reproducible builds to enable dependency analysis and caching for fast +incremental builds. + +The main motivation behind the existence of an LLVM Bazel build is that a number +of projects that depend on LLVM use Bazel, and Bazel works best when it knows +about the whole source tree (as opposed to installing artifacts coming from +another build system). Community members are also welcome to use Bazel for their +own development as long as they continue to maintain the official CMake build +system. See also, the +[proposal](https://github.com/llvm/llvm-www/blob/main/proposals/LP0002-BazelBuildConfiguration.md) +for adding this configuration. + +# Quick Start + +1. `git clone https://github.com/llvm/llvm-project.git; cd llvm-project` if + you don't have a checkout yet. +2. Install Bazel at the version indicated by [.bazelversion](./bazelversion), + following the official instructions, if you don't have it installed yet: + https://docs.bazel.build/versions/master/install.html. +3. `cd utils/bazel` +4. `bazel build --config=generic_clang @llvm-project//...` (if building on Unix + with Clang). `--config=generic_gcc` and `--config=msvc` are also available. + + +# Configuration + +The repository `.bazelrc` will import user-specific settings from a +`user.bazelrc` file (in addition to the standard locations). Adding your typical +config setting is recommended. + +```.bazelrc +build --config=generic_clang +``` + +You can enable +[disk caching](https://docs.bazel.build/versions/master/remote-caching.html#disk-cache), +which will cache build results + +```.bazelrc +build --disk_cache=~/.cache/bazel-disk-cache +``` + +You can instruct Bazel to use a ramdisk for its sandboxing operations via +[--sandbox_base](https://docs.bazel.build/versions/master/command-line-reference.html#flag--sandbox_base), +which can help avoid IO bottlenecks for the symlink stragegy used for +sandboxing. This is especially important with many inputs and many cores (see +https://github.com/bazelbuild/bazel/issues/11868): + +```.bazelrc +build --sandbox_base=/dev/shm +``` + +Bear in mind that this requires that your ramdisk is of sufficient size to hold +any temporary files. Anecdotally, 1GB should be sufficient. + +# Coverage + +The LLVM, MLIR, and Clang subprojects have configurations for Linux (Clang and +GCC), Mac (Clang and GCC), and Windows (MSVC). Configuration options that are +platform-specific are selected for in defines. Many are also hardcoded to the +values currently used by all supported configurations. If there is a +configuration you'd like to use that isn't supported, please send a patch. + +# Usage + +To use in dependent projects using Bazel, you can import LLVM (e.g. as a +submodule or using `http_archive`) and then use the provided configuration rule. + +FIXME: This needs to be updated to a commit that exists once such a commit +exists. +FIXME: It shouldn't be necessary to configure `http_archive` twice for the same +archive (though caching means this isn't too expensive). + +```starlark +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") + +LLVM_COMMIT = "0a1f0ee78122fc0642e8a1a18e1b2bc89c813387" + +LLVM_SHA256 = "4f59737ccfdad2cfb4587d796ce97c1eb5433de7ea0f57f248554b83e92d81d2" + +http_archive( + name = "llvm-project-raw", + build_file_content = "#empty", + sha256 = LLVM_SHA256, + strip_prefix = "llvm-project-" + LLVM_COMMIT, + urls = ["https://github.com/llvm/llvm-project/archive/{commit}.tar.gz".format(commit = LLVM_COMMIT)], +) + +http_archive( + name = "llvm-bazel", + sha256 = LLVM_SHA256, + strip_prefix = "llvm-project-{}/utils/bazel".format(LLVM_COMMIT), + urls = ["https://github.com/llvm/llvm-project/archive/{commit}.tar.gz".format(commit = LLVM_COMMIT)], +) + +load("@llvm-bazel//:configure.bzl", "llvm_configure") + +llvm_configure( + name = "llvm-project", + src_path = ".", + src_workspace = "@llvm-project-raw//:WORKSPACE", +) + +load("@llvm-bazel//:terminfo.bzl", "llvm_terminfo_system") + +maybe( + llvm_terminfo_system, + name = "llvm_terminfo", +) + +load("@llvm-bazel//:zlib.bzl", "llvm_zlib_system") + +maybe( + llvm_zlib_system, + name = "llvm_zlib", +) +``` diff --git a/utils/bazel/WORKSPACE b/utils/bazel/WORKSPACE new file mode 100644 --- /dev/null +++ b/utils/bazel/WORKSPACE @@ -0,0 +1,84 @@ +# 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(":configure.bzl", "llvm_configure") +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") + +llvm_configure( + name = "llvm-project", + overlay_path = "llvm-project-overlay", + src_path = "../..", +) + +load(":terminfo.bzl", "llvm_terminfo_from_env") + +maybe( + llvm_terminfo_from_env, + name = "llvm_terminfo", +) + +maybe( + http_archive, + name = "zlib", + build_file = "//third_party_build:zlib.BUILD", + sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1", + strip_prefix = "zlib-1.2.11", + urls = [ + "https://storage.googleapis.com/mirror.tensorflow.org/zlib.net/zlib-1.2.11.tar.gz", + "https://zlib.net/zlib-1.2.11.tar.gz", + ], +) + +load(":zlib.bzl", "llvm_zlib_from_env") + +maybe( + llvm_zlib_from_env, + name = "llvm_zlib", + external_zlib = "@zlib", +) + +maybe( + http_archive, + name = "vulkan_headers", + build_file = "//third_party_build:vulkan_headers.BUILD", + sha256 = "19f491784ef0bc73caff877d11c96a48b946b5a1c805079d9006e3fbaa5c1895", + strip_prefix = "Vulkan-Headers-9bd3f561bcee3f01d22912de10bb07ce4e23d378", + urls = [ + "https://github.com/KhronosGroup/Vulkan-Headers/archive/9bd3f561bcee3f01d22912de10bb07ce4e23d378.tar.gz", + ], +) + +load(":vulkan_sdk.bzl", "vulkan_sdk_setup") + +maybe( + vulkan_sdk_setup, + name = "vulkan_sdk", +) + +http_archive( + name = "bazel_skylib", + sha256 = "97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz", + "https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz", + ], +) + +load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") + +bazel_skylib_workspace() + +http_archive( + name = "bazel_toolchains", + sha256 = "1adf5db506a7e3c465a26988514cfc3971af6d5b3c2218925cd6e71ee443fc3f", + strip_prefix = "bazel-toolchains-4.0.0", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/releases/download/4.0.0/bazel-toolchains-4.0.0.tar.gz", + "https://github.com/bazelbuild/bazel-toolchains/releases/download/4.0.0/bazel-toolchains-4.0.0.tar.gz", + ], +) + +load("@bazel_toolchains//rules:rbe_repo.bzl", "rbe_autoconfig") +rbe_autoconfig(name = "rbe_default") diff --git a/utils/bazel/configure.bzl b/utils/bazel/configure.bzl new file mode 100644 --- /dev/null +++ b/utils/bazel/configure.bzl @@ -0,0 +1,142 @@ +# 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 + +"""Helper macros to configure the LLVM overlay project.""" + +load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") +load(":zlib.bzl", "llvm_zlib_disable", "llvm_zlib_system") +load(":terminfo.bzl", "llvm_terminfo_disable", "llvm_terminfo_system") + +# Directory of overlay files relative to WORKSPACE +DEFAULT_OVERLAY_PATH = "llvm-project-overlay" + +DEFAULT_TARGETS = [ + "AArch64", + "AMDGPU", + "ARM", + "BPF", + "Hexagon", + "Lanai", + "NVPTX", + "PowerPC", + "RISCV", + "Sparc", + "WebAssembly", + "X86", +] + +def _is_absolute(path): + """Returns `True` if `path` is an absolute path. + + Args: + path: A path (which is a string). + Returns: + `True` if `path` is an absolute path. + """ + return path.startswith("/") or (len(path) > 2 and path[1] == ":") + +def _join_path(a, b): + if _is_absolute(b): + return b + return str(a) + "/" + str(b) + +def _overlay_directories(repository_ctx): + src_workspace_path = repository_ctx.path( + repository_ctx.attr.src_workspace, + ).dirname + + src_path = _join_path(src_workspace_path, repository_ctx.attr.src_path) + + overlay_workspace_path = repository_ctx.path( + repository_ctx.attr.overlay_workspace, + ).dirname + overlay_path = _join_path( + overlay_workspace_path, + repository_ctx.attr.overlay_path, + ) + + overlay_script = repository_ctx.path( + repository_ctx.attr._overlay_script, + ) + python_bin = repository_ctx.which("python3") + if not python_bin: + # Windows typically just defines "python" as python3. The script itself + # contains a check to ensure python3. + python_bin = repository_ctx.which("python") + + if not python_bin: + fail("Failed to find python3 binary") + + cmd = [ + python_bin, + overlay_script, + "--src", + src_path, + "--overlay", + overlay_path, + "--target", + ".", + ] + exec_result = repository_ctx.execute(cmd, timeout = 20) + + if exec_result.return_code != 0: + fail(("Failed to execute overlay script: '{cmd}'\n" + + "Exited with code {return_code}\n" + + "stdout:\n{stdout}\n" + + "stderr:\n{stderr}\n").format( + cmd = " ".join([str(arg) for arg in cmd]), + return_code = exec_result.return_code, + stdout = exec_result.stdout, + stderr = exec_result.stderr, + )) + +def _llvm_configure_impl(repository_ctx): + _overlay_directories(repository_ctx) + + # Create a starlark file with the requested LLVM targets. + targets = repository_ctx.attr.targets + repository_ctx.file( + "llvm/targets.bzl", + content = "llvm_targets = " + str(targets), + executable = False, + ) + +llvm_configure = repository_rule( + implementation = _llvm_configure_impl, + local = True, + configure = True, + attrs = { + "_overlay_script": attr.label( + default = Label("//:overlay_directories.py"), + allow_single_file = True, + ), + "overlay_workspace": attr.label(default = Label("//:WORKSPACE")), + "overlay_path": attr.string(default = DEFAULT_OVERLAY_PATH), + "src_workspace": attr.label(default = Label("//:WORKSPACE")), + "src_path": attr.string(mandatory = True), + "targets": attr.string_list(default = DEFAULT_TARGETS), + }, +) + +def llvm_disable_optional_support_deps(): + maybe( + llvm_zlib_disable, + name = "llvm_zlib", + ) + + maybe( + llvm_terminfo_disable, + name = "llvm_terminfo", + ) + +def llvm_use_system_support_deps(): + maybe( + llvm_zlib_system, + name = "llvm_zlib", + ) + + maybe( + llvm_terminfo_system, + name = "llvm_terminfo", + ) diff --git a/utils/bazel/deps_impl/BUILD.bazel b/utils/bazel/deps_impl/BUILD.bazel new file mode 100644 --- /dev/null +++ b/utils/bazel/deps_impl/BUILD.bazel @@ -0,0 +1,5 @@ +# 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 + +# Required to reference files in this package diff --git a/utils/bazel/deps_impl/terminfo_disable.BUILD b/utils/bazel/deps_impl/terminfo_disable.BUILD new file mode 100644 --- /dev/null +++ b/utils/bazel/deps_impl/terminfo_disable.BUILD @@ -0,0 +1,10 @@ +# 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 + +# Empty stub library. This doesn't include any terminfo library and doesn't set +# the LLVM `#define`s to enable usage of terminfo. +cc_library( + name = "terminfo", + visibility = ["//visibility:public"], +) diff --git a/utils/bazel/deps_impl/terminfo_system.BUILD b/utils/bazel/deps_impl/terminfo_system.BUILD new file mode 100644 --- /dev/null +++ b/utils/bazel/deps_impl/terminfo_system.BUILD @@ -0,0 +1,15 @@ +# 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 + +# Wrapper library for some system terminfo. Using this only works if the +# toolchain already has the relevant library search paths configured. It also +# sets the relevant LLVM `#define`s to enoble using terminfo. +cc_library( + name = "terminfo", + defines = ["LLVM_ENABLE_TERMINFO=1"], + # Note that we will replace these link options with ones needed to + # effectively link against a terminfo providing library on the system. + linkopts = {TERMINFO_LINKOPTS}, + visibility = ["//visibility:public"], +) diff --git a/utils/bazel/deps_impl/terminfo_test.c b/utils/bazel/deps_impl/terminfo_test.c new file mode 100644 --- /dev/null +++ b/utils/bazel/deps_impl/terminfo_test.c @@ -0,0 +1,17 @@ +/* +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 +*/ + +extern int setupterm(char *term, int filedes, int *errret); +extern struct term *set_curterm(struct term *termp); +extern int del_curterm(struct term *termp); +extern int tigetnum(char *capname); + +int main() { + setupterm(0, 0, 0); + set_curterm(0); + del_curterm(0); + tigetnum(0); +} diff --git a/utils/bazel/deps_impl/zlib_disable.BUILD b/utils/bazel/deps_impl/zlib_disable.BUILD new file mode 100644 --- /dev/null +++ b/utils/bazel/deps_impl/zlib_disable.BUILD @@ -0,0 +1,10 @@ +# 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 + +# Empty stub library. This doesn't include zlib and doesn't set the LLVM +# `#define`s to enable it. +cc_library( + name = "zlib", + visibility = ["//visibility:public"], +) diff --git a/utils/bazel/deps_impl/zlib_external.BUILD b/utils/bazel/deps_impl/zlib_external.BUILD new file mode 100644 --- /dev/null +++ b/utils/bazel/deps_impl/zlib_external.BUILD @@ -0,0 +1,11 @@ +# 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 + +# Wrapper around an external zlib library to add the relevant LLVM `#define`s. +cc_library( + name = "zlib", + defines = ["LLVM_ENABLE_ZLIB=1"], + visibility = ["//visibility:public"], + deps = ["@external_zlib_repo//:zlib_rule"], +) diff --git a/utils/bazel/deps_impl/zlib_system.BUILD b/utils/bazel/deps_impl/zlib_system.BUILD new file mode 100644 --- /dev/null +++ b/utils/bazel/deps_impl/zlib_system.BUILD @@ -0,0 +1,13 @@ +# 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 + +# Wrapper library for the system's zlib. Using this only works if the toolchain +# already has the relevant header search and library search paths configured. +# It also sets the relevant LLVM `#define`s to enable zlib. +cc_library( + name = "zlib", + defines = ["LLVM_ENABLE_ZLIB=1"], + linkopts = ["-lz"], + visibility = ["//visibility:public"], +) diff --git a/utils/bazel/llvm-project-overlay/.bazelignore b/utils/bazel/llvm-project-overlay/.bazelignore new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm-project-overlay/.bazelignore @@ -0,0 +1,2 @@ +# Ignore the utils/bazel directory when this is overlayed onto the repo root. +utils/bazel diff --git a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel @@ -0,0 +1,2101 @@ +# 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:tblgen.bzl", "gentbl") +load("//llvm:binary_alias.bzl", "binary_alias") +load("//llvm:cc_plugin_library.bzl", "cc_plugin_library") + +package( + default_visibility = ["//visibility:public"], + licenses = ["notice"], +) + +exports_files([ + "tools/clang-format/clang-format.el", + "tools/clang-format/clang-format-test.el", + "tools/clang-format/clang-format.py", + "tools/clang-rename/clang-rename.el", + "tools/extra/clang-include-fixer/tool/clang-include-fixer.el", + "tools/extra/clang-include-fixer/tool/clang-include-fixer-test.el", +]) + +cc_binary( + name = "clang-tblgen", + srcs = glob([ + "utils/TableGen/*.cpp", + "utils/TableGen/*.h", + ]), + copts = [ + "$(STACK_FRAME_UNLIMITED)", + ], + linkopts = ["-ldl"], + stamp = 0, + deps = [ + "//llvm:Support", + "//llvm:TableGen", + "//llvm:config", + ], +) + +gentbl( + name = "diagnostic_defs_gen", + tbl_outs = [( + "-gen-clang-diags-defs -clang-component=%s" % c, + "include/clang/Basic/Diagnostic%sKinds.inc" % c, + ) for c in [ + "AST", + "Analysis", + "Comment", + "Common", + "CrossTU", + "Driver", + "Frontend", + "Lex", + "Parse", + "Refactoring", + "Sema", + "Serialization", + ]] + [ + ( + "-gen-clang-diag-groups", + "include/clang/Basic/DiagnosticGroups.inc", + ), + ( + "-gen-clang-diags-index-name", + "include/clang/Basic/DiagnosticIndexName.inc", + ), + ], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/Diagnostic.td", + td_srcs = glob(["include/clang/Basic/*.td"]), +) + +gentbl( + name = "basic_arm_neon_inc_gen", + tbl_outs = [( + "-gen-arm-neon-sema", + "include/clang/Basic/arm_neon.inc", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/arm_neon.td", + td_srcs = [ + "include/clang/Basic/arm_neon.td", + "include/clang/Basic/arm_neon_incl.td", + ], +) + +gentbl( + name = "basic_arm_fp16_inc_gen", + tbl_outs = [( + "-gen-arm-neon-sema", + "include/clang/Basic/arm_fp16.inc", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/arm_fp16.td", + td_srcs = [ + "include/clang/Basic/arm_fp16.td", + "include/clang/Basic/arm_neon_incl.td", + ], +) + +gentbl( + name = "basic_arm_mve_aliases_gen", + tbl_outs = [( + "-gen-arm-mve-builtin-aliases", + "include/clang/Basic/arm_mve_builtin_aliases.inc", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/arm_mve.td", + td_srcs = [ + "include/clang/Basic/arm_mve.td", + "include/clang/Basic/arm_mve_defs.td", + ], +) + +gentbl( + name = "basic_arm_sve_builtins_gen", + tbl_outs = [( + "-gen-arm-sve-builtins", + "include/clang/Basic/arm_sve_builtins.inc", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/arm_sve.td", + td_srcs = [ + "include/clang/Basic/arm_sve.td", + ], +) + +gentbl( + name = "basic_arm_sve_builtin_cg_gen", + tbl_outs = [( + "-gen-arm-sve-builtin-codegen", + "include/clang/Basic/arm_sve_builtin_cg.inc", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/arm_sve.td", + td_srcs = [ + "include/clang/Basic/arm_sve.td", + ], +) + +gentbl( + name = "basic_arm_sve_typeflags_gen", + tbl_outs = [( + "-gen-arm-sve-typeflags", + "include/clang/Basic/arm_sve_typeflags.inc", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/arm_sve.td", + td_srcs = [ + "include/clang/Basic/arm_sve.td", + ], +) + +gentbl( + name = "basic_arm_sve_sema_rangechecks_gen", + tbl_outs = [( + "-gen-arm-sve-sema-rangechecks", + "include/clang/Basic/arm_sve_sema_rangechecks.inc", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/arm_sve.td", + td_srcs = [ + "include/clang/Basic/arm_sve.td", + ], +) + +gentbl( + name = "basic_arm_mve_cg_gen", + tbl_outs = [( + "-gen-arm-mve-builtin-codegen", + "include/clang/Basic/arm_mve_builtin_cg.inc", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/arm_mve.td", + td_srcs = [ + "include/clang/Basic/arm_mve.td", + "include/clang/Basic/arm_mve_defs.td", + ], +) + +gentbl( + name = "basic_arm_mve_inc_gen", + tbl_outs = [( + "-gen-arm-mve-builtin-def", + "include/clang/Basic/arm_mve_builtins.inc", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/arm_mve.td", + td_srcs = [ + "include/clang/Basic/arm_mve.td", + "include/clang/Basic/arm_mve_defs.td", + ], +) + +gentbl( + name = "basic_arm_mve_sema_gen", + tbl_outs = [( + "-gen-arm-mve-builtin-sema", + "include/clang/Basic/arm_mve_builtin_sema.inc", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/arm_mve.td", + td_srcs = [ + "include/clang/Basic/arm_mve.td", + "include/clang/Basic/arm_mve_defs.td", + ], +) + +gentbl( + name = "basic_riscv_vector_builtins_gen", + tbl_outs = [( + "-gen-riscv-vector-builtins", + "include/clang/Basic/riscv_vector_builtins.inc", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/riscv_vector.td", + td_srcs = [ + "include/clang/Basic/riscv_vector.td", + ], +) + +gentbl( + name = "basic_riscv_vector_builtin_cg_gen", + tbl_outs = [( + "-gen-riscv-vector-builtin-codegen", + "include/clang/Basic/riscv_vector_builtin_cg.inc", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/riscv_vector.td", + td_srcs = [ + "include/clang/Basic/riscv_vector.td", + ], +) + +gentbl( + name = "basic_arm_cde_gen", + tbl_outs = [( + "-gen-arm-cde-builtin-def", + "include/clang/Basic/arm_cde_builtins.inc", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/arm_cde.td", + td_srcs = [ + "include/clang/Basic/arm_cde.td", + "include/clang/Basic/arm_mve_defs.td", + ], +) + +gentbl( + name = "basic_arm_cde_aliases_gen", + tbl_outs = [( + "-gen-arm-cde-builtin-aliases", + "include/clang/Basic/arm_cde_builtin_aliases.inc", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/arm_cde.td", + td_srcs = [ + "include/clang/Basic/arm_cde.td", + "include/clang/Basic/arm_mve_defs.td", + ], +) + +gentbl( + name = "basic_arm_cde_cg_gen", + tbl_outs = [( + "-gen-arm-cde-builtin-codegen", + "include/clang/Basic/arm_cde_builtin_cg.inc", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/arm_cde.td", + td_srcs = [ + "include/clang/Basic/arm_cde.td", + "include/clang/Basic/arm_mve_defs.td", + ], +) + +gentbl( + name = "basic_arm_cde_sema_gen", + tbl_outs = [( + "-gen-arm-cde-builtin-sema", + "include/clang/Basic/arm_cde_builtin_sema.inc", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/arm_cde.td", + td_srcs = [ + "include/clang/Basic/arm_cde.td", + "include/clang/Basic/arm_mve_defs.td", + ], +) + +gentbl( + name = "basic_attr_gen", + tbl_outs = [ + ( + "-gen-clang-attr-has-attribute-impl", + "include/clang/Basic/AttrHasAttributeImpl.inc", + ), + ( + "-gen-clang-attr-list", + "include/clang/Basic/AttrList.inc", + ), + ( + "-gen-clang-attr-subject-match-rule-list", + "include/clang/Basic/AttrSubMatchRulesList.inc", + ), + ], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/Attr.td", + td_srcs = [ + "include/clang/Basic/ASTNode.td", + "include/clang/Basic/Attr.td", + "include/clang/Basic/AttrDocs.td", + "include/clang/Basic/DeclNodes.td", + "include/clang/Basic/StmtNodes.td", + ], +) + +gentbl( + name = "libsema_openclbuiltins_inc_gen", + strip_include_prefix = "lib/Sema", + tbl_outs = [( + "-gen-clang-opencl-builtins", + "lib/Sema/OpenCLBuiltins.inc", + )], + tblgen = ":clang-tblgen", + td_file = "lib/Sema/OpenCLBuiltins.td", + td_srcs = [ + "lib/Sema/OpenCLBuiltins.td", + ], +) + +# Table definition files can be used for documentation: +filegroup( + name = "all_table_defs", + srcs = glob(["include/**/*.td"]), +) + +exports_files( + glob(["include/**/*.td"]), +) + +genrule( + name = "basic_version_gen", + outs = ["include/clang/Basic/Version.inc"], + cmd = ("printf " + + "\"#define CLANG_VERSION 12.0\n\"" + + "\"#define CLANG_VERSION_MAJOR 12\n\"" + + "\"#define CLANG_VERSION_MINOR 0\n\"" + + "\"#define CLANG_VERSION_PATCHLEVEL 0\n\"" + + "\"#define CLANG_VERSION_STRING \\\"git\\\"\n\" > $@"), +) + +cc_library( + name = "config", + hdrs = [ + "include/clang/Basic/Version.inc", + "include/clang/Config/config.h", + ], + includes = ["include"], + deps = [ + # We rely on the LLVM config library to provide configuration defines. + "//llvm:config", + ], +) + +# TODO: This should get replaced with something that actually generates the +# correct version number. +genrule( + name = "vcs_version_gen", + # This should be under lib/Basic, but because of how the include paths + # are passed through bazel, it's easier to drop generated files next to + # the other includes. + outs = ["include/VCSVersion.inc"], + cmd = "echo \"#define CLANG_REVISION \\\"git\\\"\" > $@", +) + +# A hacky library to expose some internal headers of the `basic` library to its +# own implementation source files using a stripped include prefix rather than +# file-relative-inclusion. This is inherently non-modular as these headers will +# be repeated in the sources below for file-relative-inclusion. +cc_library( + name = "basic_internal_headers", + hdrs = glob([ + "lib/Basic/*.h", + ]), + features = ["-header_modules"], + strip_include_prefix = "lib/Basic", +) + +cc_library( + name = "basic", + srcs = [ + "include/clang/Basic/Version.inc", + "include/VCSVersion.inc", + ] + glob([ + "lib/Basic/*.cpp", + "lib/Basic/*.c", + "lib/Basic/*.h", + "lib/Basic/Targets/*.cpp", + "lib/Basic/Targets/*.h", + ]), + hdrs = glob([ + "include/clang/Basic/*.h", + ]), + copts = [ + "-DHAVE_VCS_VERSION_INC", + "$(STACK_FRAME_UNLIMITED)", + ], + includes = ["include"], + textual_hdrs = [ + "include/clang/Basic/arm_fp16.inc", + "include/clang/Basic/arm_mve_builtins.inc", + "include/clang/Basic/arm_mve_builtin_aliases.inc", + "include/clang/Basic/arm_mve_builtin_cg.inc", + "include/clang/Basic/arm_mve_builtin_sema.inc", + "include/clang/Basic/arm_neon.inc", + "include/clang/Basic/AttrHasAttributeImpl.inc", + "include/clang/Basic/AttrList.inc", + "include/clang/Basic/AttrSubMatchRulesList.inc", + "include/clang/Basic/DiagnosticASTKinds.inc", + "include/clang/Basic/DiagnosticGroups.inc", + "include/clang/Basic/DiagnosticRefactoringKinds.inc", + "include/clang/Basic/DiagnosticAnalysisKinds.inc", + "include/clang/Basic/DiagnosticSemaKinds.inc", + "include/clang/Basic/DiagnosticCommentKinds.inc", + "include/clang/Basic/DiagnosticParseKinds.inc", + "include/clang/Basic/DiagnosticLexKinds.inc", + "include/clang/Basic/DiagnosticSerializationKinds.inc", + "include/clang/Basic/DiagnosticFrontendKinds.inc", + "include/clang/Basic/DiagnosticDriverKinds.inc", + "include/clang/Basic/DiagnosticCrossTUKinds.inc", + "include/clang/Basic/DiagnosticCommonKinds.inc", + "include/clang/Basic/DiagnosticIndexName.inc", + ] + glob([ + "include/clang/Basic/*.def", + ]), + deps = [ + ":basic_arm_cde_gen", + ":basic_arm_fp16_inc_gen", + ":basic_arm_mve_aliases_gen", + ":basic_arm_mve_cg_gen", + ":basic_arm_mve_inc_gen", + ":basic_arm_mve_sema_gen", + ":basic_arm_neon_inc_gen", + ":basic_arm_sve_builtins_gen", + ":basic_arm_sve_typeflags_gen", + ":basic_attr_gen", + ":basic_riscv_vector_builtin_cg_gen", + ":basic_riscv_vector_builtins_gen", + ":basic_internal_headers", + ":config", + ":diagnostic_defs_gen", + ":sema_attr_gen", + "//llvm:Core", + "//llvm:FrontendOpenMP", + "//llvm:Instrumentation", + "//llvm:MC", + "//llvm:Support", + "//llvm:Target", + "//llvm:config", + ], +) + +cc_library( + name = "lex", + srcs = glob([ + "lib/Lex/*.cpp", + "lib/Lex/*.h", + ]), + hdrs = glob([ + "include/clang/Lex/*.h", + ]), + includes = ["include"], + deps = [ + ":basic", + "//llvm:Support", + ], +) + +gentbl( + name = "ast_attr_gen", + tbl_outs = [ + ( + "-gen-clang-attr-ast-visitor", + "include/clang/AST/AttrVisitor.inc", + ), + ( + "-gen-clang-attr-classes", + "include/clang/AST/Attrs.inc", + ), + ( + "-gen-clang-attr-text-node-dump", + "include/clang/AST/AttrTextNodeDump.inc", + ), + ( + "-gen-clang-attr-node-traverse", + "include/clang/AST/AttrNodeTraverse.inc", + ), + ( + "-gen-clang-attr-impl", + "include/clang/AST/AttrImpl.inc", + ), + ], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/Attr.td", + td_srcs = [ + "include/clang/Basic/Attr.td", + "include/clang/Basic/AttrDocs.td", + "include/clang/Basic/ASTNode.td", + "include/clang/Basic/DeclNodes.td", + "include/clang/Basic/StmtNodes.td", + ], +) + +gentbl( + name = "ast_decl_nodes_gen", + tbl_outs = [( + "-gen-clang-decl-nodes", + "include/clang/AST/DeclNodes.inc", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/DeclNodes.td", + td_srcs = [ + "include/clang/Basic/ASTNode.td", + "include/clang/Basic/DeclNodes.td", + ], +) + +gentbl( + name = "ast_stmt_nodes_gen", + tbl_outs = [( + "-gen-clang-stmt-nodes", + "include/clang/AST/StmtNodes.inc", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/StmtNodes.td", + td_srcs = [ + "include/clang/Basic/ASTNode.td", + "include/clang/Basic/StmtNodes.td", + ], +) + +gentbl( + name = "ast_comment_nodes_gen", + tbl_outs = [( + "-gen-clang-comment-nodes", + "include/clang/AST/CommentNodes.inc", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/CommentNodes.td", + td_srcs = [ + "include/clang/Basic/ASTNode.td", + "include/clang/Basic/CommentNodes.td", + ], +) + +gentbl( + name = "ast_comment_command_info_gen", + tbl_outs = [ + ( + "-gen-clang-comment-command-info", + "include/clang/AST/CommentCommandInfo.inc", + ), + ( + "-gen-clang-comment-command-list", + "include/clang/AST/CommentCommandList.inc", + ), + ], + tblgen = ":clang-tblgen", + td_file = "include/clang/AST/CommentCommands.td", + td_srcs = ["include/clang/AST/CommentCommands.td"], +) + +gentbl( + name = "ast_comment_html_tags_gen", + tbl_outs = [( + "-gen-clang-comment-html-tags", + "include/clang/AST/CommentHTMLTags.inc", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/AST/CommentHTMLTags.td", + td_srcs = ["include/clang/AST/CommentHTMLTags.td"], +) + +gentbl( + name = "ast_comment_html_tags_properties_gen", + tbl_outs = [( + "-gen-clang-comment-html-tags-properties", + "include/clang/AST/CommentHTMLTagsProperties.inc", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/AST/CommentHTMLTags.td", + td_srcs = ["include/clang/AST/CommentHTMLTags.td"], +) + +gentbl( + name = "ast_comment_html_named_character_references_gen", + tbl_outs = [( + "-gen-clang-comment-html-named-character-references", + "include/clang/AST/CommentHTMLNamedCharacterReferences.inc", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/AST/CommentHTMLNamedCharacterReferences.td", + td_srcs = ["include/clang/AST/CommentHTMLNamedCharacterReferences.td"], +) + +gentbl( + name = "ast_stmt_data_collectors_gen", + tbl_outs = [( + "-gen-clang-data-collectors", + "include/clang/AST/StmtDataCollectors.inc", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/AST/StmtDataCollectors.td", + td_srcs = ["include/clang/AST/StmtDataCollectors.td"], +) + +gentbl( + name = "ast_interp_opcodes_gen", + tbl_outs = [( + "-gen-clang-opcodes", + "lib/AST/Interp/Opcodes.inc", + )], + tblgen = ":clang-tblgen", + td_file = "lib/AST/Interp/Opcodes.td", + td_srcs = ["lib/AST/Interp/Opcodes.td"], +) + +gentbl( + name = "ast_properties_base_gen", + tbl_outs = [ + ( + "-gen-clang-basic-reader", + "include/clang/AST/AbstractBasicReader.inc", + ), + ( + "-gen-clang-basic-writer", + "include/clang/AST/AbstractBasicWriter.inc", + ), + ], + tblgen = ":clang-tblgen", + td_file = "include/clang/AST/PropertiesBase.td", + td_srcs = ["include/clang/AST/PropertiesBase.td"], +) + +gentbl( + name = "ast_type_properties_gen", + tbl_outs = [ + ( + "-gen-clang-type-reader", + "include/clang/AST/AbstractTypeReader.inc", + ), + ( + "-gen-clang-type-writer", + "include/clang/AST/AbstractTypeWriter.inc", + ), + ], + tblgen = ":clang-tblgen", + td_file = "include/clang/AST/TypeProperties.td", + td_srcs = [ + "include/clang/AST/PropertiesBase.td", + "include/clang/AST/TypeProperties.td", + "include/clang/Basic/ASTNode.td", + "include/clang/Basic/TypeNodes.td", + ], +) + +gentbl( + name = "type_nodes_gen", + tbl_outs = [( + "-gen-clang-type-nodes", + "include/clang/AST/TypeNodes.inc", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/TypeNodes.td", + td_srcs = [ + "include/clang/Basic/ASTNode.td", + "include/clang/Basic/TypeNodes.td", + ], +) + +cc_library( + name = "ast", + srcs = glob([ + "lib/AST/*.cpp", + "lib/AST/*.h", + "lib/AST/Interp/*.cpp", + "lib/AST/Interp/*.h", + ]), + hdrs = glob([ + "include/clang/AST/*.h", + ]), + includes = [ + "include", + "lib/AST/Interp", + ], + textual_hdrs = [ + "include/clang/AST/AttrImpl.inc", + "include/clang/AST/AttrNodeTraverse.inc", + "include/clang/AST/Attrs.inc", + "include/clang/AST/AttrTextNodeDump.inc", + "include/clang/AST/AttrVisitor.inc", + "include/clang/AST/CommentCommandInfo.inc", + "include/clang/AST/CommentCommandList.inc", + "include/clang/AST/CommentHTMLNamedCharacterReferences.inc", + "include/clang/AST/CommentHTMLTags.inc", + "include/clang/AST/CommentHTMLTagsProperties.inc", + "include/clang/AST/CommentNodes.inc", + "include/clang/AST/DeclNodes.inc", + "include/clang/AST/StmtDataCollectors.inc", + "include/clang/AST/StmtNodes.inc", + "lib/AST/Interp/Opcodes.inc", + ] + glob([ + "include/clang/AST/*.def", + ]), + deps = [ + ":ast_attr_gen", + ":ast_comment_command_info_gen", + ":ast_comment_html_named_character_references_gen", + ":ast_comment_html_tags_gen", + ":ast_comment_html_tags_properties_gen", + ":ast_comment_nodes_gen", + ":ast_decl_nodes_gen", + ":ast_interp_opcodes_gen", + ":ast_properties_base_gen", + ":ast_stmt_data_collectors_gen", + ":ast_stmt_nodes_gen", + ":ast_type_properties_gen", + ":basic", + ":lex", + ":type_nodes_gen", + "//llvm:BinaryFormat", + "//llvm:Core", + "//llvm:FrontendOpenMP", + "//llvm:Support", + ], +) + +cc_library( + name = "index", + srcs = glob([ + "lib/Index/*.cpp", + "lib/Index/*.h", + ]), + hdrs = glob([ + "include/clang/Index/*.h", + "include/clang-c/*.h", + ]), + includes = ["include"], + deps = [ + ":ast", + ":basic", + ":format", + ":frontend", + ":lex", + ":rewrite", + ":serialization", + "//llvm:Core", + "//llvm:Support", + ], +) + +cc_library( + name = "analysis", + srcs = glob([ + "lib/Analysis/*.cpp", + "lib/Analysis/*.h", + ]), + hdrs = glob([ + "include/clang/Analysis/**/*.h", + ]), + includes = ["include"], + textual_hdrs = glob([ + "include/clang/Analysis/**/*.def", + ]), + deps = [ + ":ast", + ":ast_matchers", + ":basic", + ":lex", + "//llvm:Support", + ], +) + +gentbl( + name = "sema_attr_gen", + tbl_outs = [ + ( + "-gen-clang-attr-parsed-attr-impl", + "include/clang/Sema/AttrParsedAttrImpl.inc", + ), + ( + "-gen-clang-attr-parsed-attr-kinds", + "include/clang/Sema/AttrParsedAttrKinds.inc", + ), + ( + "-gen-clang-attr-parsed-attr-list", + "include/clang/Sema/AttrParsedAttrList.inc", + ), + ( + "-gen-clang-attr-spelling-index", + "include/clang/Sema/AttrSpellingListIndex.inc", + ), + ( + "-gen-clang-attr-template-instantiate", + "include/clang/Sema/AttrTemplateInstantiate.inc", + ), + ], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/Attr.td", + td_srcs = [ + "include/clang/Basic/ASTNode.td", + "include/clang/Basic/Attr.td", + "include/clang/Basic/AttrDocs.td", + "include/clang/Basic/DeclNodes.td", + "include/clang/Basic/StmtNodes.td", + ], +) + +cc_library( + name = "sema", + srcs = glob([ + "lib/Sema/*.cpp", + "lib/Sema/*.h", + ]), + hdrs = glob([ + "include/clang/Sema/*.h", + "include/clang-c/*.h", + ]), + copts = ["$(STACK_FRAME_UNLIMITED)"], + includes = ["include"], + textual_hdrs = [ + "include/clang/Sema/AttrParsedAttrImpl.inc", + "include/clang/Sema/AttrParsedAttrKinds.inc", + "include/clang/Sema/AttrParsedAttrList.inc", + "include/clang/Sema/AttrSpellingListIndex.inc", + "include/clang/Sema/AttrTemplateInstantiate.inc", + "lib/Sema/OpenCLBuiltins.inc", + ], + deps = [ + ":analysis", + ":ast", + ":basic", + ":basic_arm_cde_aliases_gen", + ":basic_arm_cde_sema_gen", + ":basic_arm_sve_builtins_gen", + ":basic_arm_sve_sema_rangechecks_gen", + ":edit", + ":lex", + ":libsema_openclbuiltins_inc_gen", + ":sema_attr_gen", + ":type_nodes_gen", + "//llvm:AllTargetsAsmParsers", + "//llvm:AllTargetsCodeGens", + "//llvm:Core", + "//llvm:FrontendOpenMP", + "//llvm:MC", + "//llvm:MCParser", + "//llvm:Support", + ], +) + +gentbl( + name = "parse_attr_gen", + tbl_outs = [ + ( + "-gen-clang-attr-parser-string-switches", + "include/clang/Parse/AttrParserStringSwitches.inc", + ), + ( + "-gen-clang-attr-subject-match-rules-parser-string-switches", + "include/clang/Parse/AttrSubMatchRulesParserStringSwitches.inc", + ), + ], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/Attr.td", + td_srcs = [ + "include/clang/Basic/ASTNode.td", + "include/clang/Basic/Attr.td", + "include/clang/Basic/AttrDocs.td", + "include/clang/Basic/DeclNodes.td", + "include/clang/Basic/StmtNodes.td", + ], +) + +cc_library( + name = "parse", + srcs = [ + ] + glob([ + "lib/Parse/*.cpp", + "lib/Parse/*.h", + ]), + hdrs = [ + "include/clang/Parse/AttrParserStringSwitches.inc", + "include/clang/Parse/AttrSubMatchRulesParserStringSwitches.inc", + ] + glob(["include/clang/Parse/*.h"]), + includes = ["include"], + deps = [ + ":ast", + ":basic", + ":lex", + ":parse_attr_gen", + ":sema", + "//llvm:FrontendOpenMP", + "//llvm:MC", + "//llvm:MCParser", + "//llvm:Support", + ], +) + +cc_library( + name = "ast_matchers", + srcs = glob([ + "lib/ASTMatchers/*.cpp", + "lib/ASTMatchers/*.h", + ]), + hdrs = glob(["include/clang/ASTMatchers/*.h"]), + includes = ["include"], + deps = [ + ":ast", + ":basic", + ":lex", + "//llvm:Support", + ], +) + +cc_library( + name = "ast_matchers_dynamic", + srcs = glob([ + "lib/ASTMatchers/Dynamic/*.cpp", + "lib/ASTMatchers/Dynamic/*.h", + ]), + hdrs = glob(["include/clang/ASTMatchers/Dynamic/*.h"]), + copts = ["$(STACK_FRAME_UNLIMITED)"], + includes = ["include"], + deps = [ + ":ast", + ":ast_matchers", + ":basic", + "//llvm:FrontendOpenMP", + "//llvm:Support", + ], +) + +cc_library( + name = "rewrite", + srcs = glob([ + "lib/Rewrite/*.cpp", + "lib/Rewrite/*.h", + ]), + hdrs = glob(["include/clang/Rewrite/Core/*.h"]), + includes = ["include"], + deps = [ + ":ast", + ":basic", + ":edit", + ":lex", + "//llvm:Support", + ], +) + +cc_library( + name = "testing", + srcs = glob([ + "lib/Testing/*.cpp", + ]), + hdrs = glob(["include/clang/Testing/*.h"]), + includes = ["include"], + deps = [ + ":basic", + "//llvm:Support", + ], +) + +cc_library( + name = "tooling_core", + srcs = glob([ + "lib/Tooling/Core/*.cpp", + "lib/Tooling/Core/*.h", + ]), + hdrs = glob(["include/clang/Tooling/Core/*.h"]), + includes = ["include"], + deps = [ + ":ast", + ":basic", + ":lex", + ":rewrite", + "//llvm:Support", + ], +) + +cc_library( + name = "tooling", + srcs = glob( + [ + "lib/Tooling/*.cpp", + ], + # Temporarily disable until we support the generated file. + exclude = ["lib/Tooling/NodeIntrospection.cpp"], + ), + hdrs = glob([ + "include/clang/Tooling/*.h", + ]), + includes = ["include"], + deps = [ + ":ast", + ":ast_matchers", + ":basic", + ":driver", + ":format", + ":frontend", + ":lex", + ":rewrite", + ":tooling_core", + "//llvm:Option", + "//llvm:Support", + ], +) + +cc_library( + name = "tooling_inclusions", + srcs = glob([ + "lib/Tooling/Inclusions/**/*.cpp", + ]), + hdrs = glob([ + "include/clang/Tooling/Inclusions/**/*.h", + ]), + deps = [ + ":basic", + ":lex", + ":rewrite", + ":tooling_core", + "//llvm:Support", + ], +) + +cc_library( + name = "tooling_refactoring", + srcs = glob([ + "lib/Tooling/Refactoring/**/*.cpp", + "lib/Tooling/Refactoring/**/*.h", + ]), + hdrs = glob([ + "include/clang/Tooling/Refactoring/**/*.h", + "include/clang/Tooling/Refactoring/**/*.def", + ]), + deps = [ + ":ast", + ":ast_matchers", + ":basic", + ":format", + ":frontend", + ":index", + ":lex", + ":rewrite", + ":tooling", + ":tooling_core", + "//llvm:Support", + ], +) + +gentbl( + name = "tooling_syntax_gen", + tbl_outs = [ + ("-gen-clang-syntax-node-list", "include/clang/Tooling/Syntax/Nodes.inc"), + ("-gen-clang-syntax-node-classes", "include/clang/Tooling/Syntax/NodeClasses.inc"), + ], + tblgen = ":clang-tblgen", + td_file = "include/clang/Tooling/Syntax/Nodes.td", + td_srcs = [ + "include/clang/Tooling/Syntax/Nodes.td", + "include/clang/Tooling/Syntax/Syntax.td", + ], +) + +cc_library( + name = "tooling_syntax", + srcs = glob(["lib/Tooling/Syntax/**/*.cpp"]), + hdrs = glob(["include/clang/Tooling/Syntax/**/*.h"]), + deps = [ + ":ast", + ":basic", + ":lex", + ":tooling_core", + ":tooling_syntax_gen", + "//llvm:Support", + ], +) + +cc_library( + name = "tooling_dependency_scanning", + srcs = glob(["lib/Tooling/DependencyScanning/**/*.cpp"]), + hdrs = glob(["include/clang/Tooling/DependencyScanning/**/*.h"]), + deps = [ + ":basic", + ":codegen", + ":frontend", + ":lex", + ":serialization", + ":tooling", + "//llvm:Support", + ], +) + +cc_library( + name = "transformer", + srcs = glob(["lib/Tooling/Transformer/**/*.cpp"]), + hdrs = glob(["include/clang/Tooling/Transformer/**/*.h"]), + deps = [ + ":ast", + ":ast_matchers", + ":basic", + ":lex", + ":rewrite", + ":tooling_refactoring", + "//llvm:Support", + ], +) + +cc_library( + name = "ast-diff", + srcs = glob(["lib/Tooling/ASTDiff/*.cpp"]), + hdrs = glob(["include/clang/Tooling/ASTDiff/*.h"]), + deps = [ + ":ast", + ":basic", + ":lex", + "//llvm:Support", + ], +) + +cc_library( + name = "crosstu", + srcs = glob(["lib/CrossTU/*.cpp"]), + hdrs = glob(["include/clang/CrossTU/*.h"]), + deps = [ + ":ast", + ":basic", + ":frontend", + ":index", + "//llvm:Option", + "//llvm:Support", + ], +) + +cc_library( + name = "format", + srcs = glob( + [ + "lib/Format/*.cpp", + "lib/Format/*.h", + ], + ), + hdrs = [ + "lib/Format/FormatTokenLexer.h", + "lib/Format/Macros.h", + ] + glob([ + "include/clang/Format/*.h", + ]), + includes = ["include"], + deps = [ + ":basic", + ":lex", + ":tooling_core", + ":tooling_inclusions", + "//llvm:Support", + ], +) + +cc_library( + name = "edit", + srcs = glob(["lib/Edit/*.cpp"]), + hdrs = glob(["include/clang/Edit/*.h"]), + includes = ["include"], + deps = [ + ":ast", + ":basic", + ":lex", + "//llvm:Support", + ], +) + +cc_library( + name = "static_analyzer_core_options", + hdrs = [ + "include/clang/StaticAnalyzer/Core/AnalyzerOptions.h", + ], + textual_hdrs = [ + "include/clang/StaticAnalyzer/Core/Analyses.def", + "include/clang/StaticAnalyzer/Core/AnalyzerOptions.def", + ], + deps = [ + ":basic", + ":static_analyzer_checkers_gen", + "//llvm:Support", + ], +) + +cc_library( + name = "static_analyzer_core", + srcs = glob([ + "lib/StaticAnalyzer/Core/**/*.cpp", + "lib/StaticAnalyzer/Core/**/*.h", + ]), + hdrs = glob([ + "include/clang/StaticAnalyzer/Core/**/*.h", + ]), + includes = ["include"], + textual_hdrs = glob([ + "include/clang/StaticAnalyzer/Core/**/*.def", + ]), + deps = [ + ":analysis", + ":ast", + ":ast_matchers", + ":basic", + ":crosstu", + ":driver", + ":frontend", + ":lex", + ":rewrite", + ":static_analyzer_checkers_gen", + ":tooling", + ":tooling_core", + "//llvm:Support", + ], +) + +gentbl( + name = "static_analyzer_checkers_gen", + tbl_outs = [( + "-gen-clang-sa-checkers", + "include/clang/StaticAnalyzer/Checkers/Checkers.inc", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/StaticAnalyzer/Checkers/Checkers.td", + td_srcs = [ + "include/clang/StaticAnalyzer/Checkers/CheckerBase.td", + "include/clang/StaticAnalyzer/Checkers/Checkers.td", + ], +) + +cc_library( + name = "static_analyzer_checkers", + srcs = glob([ + "lib/StaticAnalyzer/Checkers/**/*.cpp", + "lib/StaticAnalyzer/Checkers/**/*.h", + ]), + hdrs = [ + "include/clang/StaticAnalyzer/Checkers/Checkers.inc", + ] + glob([ + "include/clang/StaticAnalyzer/Checkers/**/*.h", + ]), + copts = ["$(STACK_FRAME_UNLIMITED)"], + includes = ["include"], + deps = [ + ":analysis", + ":ast", + ":ast_matchers", + ":basic", + ":driver", + ":lex", + ":static_analyzer_checkers_gen", + ":static_analyzer_core", + "//llvm:Support", + ], +) + +gentbl( + name = "driver_options_inc_gen", + tbl_outs = [( + "-gen-opt-parser-defs", + "include/clang/Driver/Options.inc", + )], + tblgen = "//llvm:llvm-tblgen", + td_file = "include/clang/Driver/Options.td", + td_srcs = [ + "//llvm:include/llvm/Option/OptParser.td", + ], +) + +cc_library( + name = "driver", + srcs = glob( + [ + "lib/Driver/*.cpp", + "lib/Driver/*.h", + "lib/Driver/Arch/*.cpp", + "lib/Driver/Arch/*.h", + "lib/Driver/ToolChains/*.cpp", + "lib/Driver/ToolChains/*.h", + "lib/Driver/ToolChains/Arch/*.cpp", + "lib/Driver/ToolChains/Arch/*.h", + ], + exclude = [ + "lib/Driver/ToolChains/MSVCSetupApi.h", + ], + ), + hdrs = glob([ + "include/clang/Driver/*.h", + ]), + copts = ["$(STACK_FRAME_UNLIMITED)"], + includes = [ + "include", + # TODO: This is likely a layering issue, but files in Arch are currently + # directly #including "Tools.h". + "lib/Driver", + ], + textual_hdrs = glob([ + "include/clang/Driver/*.def", + ]), + deps = [ + ":ast", + ":basic", + ":config", + ":driver_options_inc_gen", + ":parse", + ":static_analyzer_checkers_gen", + "//llvm:BinaryFormat", + "//llvm:MC", + "//llvm:Option", + "//llvm:ProfileData", + "//llvm:Support", + "//llvm:Target", + "//llvm:config", + ], +) + +gentbl( + name = "headers_arm_neon_gen", + tbl_outs = [( + "-gen-arm-neon", + "lib/Headers/arm_neon.h", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/arm_neon.td", + td_srcs = [ + "include/clang/Basic/arm_neon.td", + "include/clang/Basic/arm_neon_incl.td", + ], +) + +gentbl( + name = "headers_arm_fp16_gen", + tbl_outs = [( + "-gen-arm-fp16", + "lib/Headers/arm_fp16.h", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/arm_fp16.td", + td_srcs = [ + "include/clang/Basic/arm_fp16.td", + "include/clang/Basic/arm_neon_incl.td", + ], +) + +gentbl( + name = "headers_arm_mve_gen", + tbl_outs = [( + "-gen-arm-mve-header", + "lib/Headers/arm_mve.h", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/arm_mve.td", + td_srcs = [ + "include/clang/Basic/arm_mve.td", + "include/clang/Basic/arm_mve_defs.td", + ], +) + +gentbl( + name = "headers_arm_cde_gen", + tbl_outs = [( + "-gen-arm-cde-header", + "lib/Headers/arm_cde.h", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/arm_cde.td", + td_srcs = [ + "include/clang/Basic/arm_cde.td", + "include/clang/Basic/arm_mve_defs.td", + ], +) + +gentbl( + name = "headers_arm_sve_gen", + tbl_outs = [( + "-gen-arm-sve-header", + "lib/Headers/arm_sve.h", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/arm_sve.td", + td_srcs = [ + "include/clang/Basic/arm_sve.td", + ], +) + +gentbl( + name = "headers_arm_bf16_gen", + tbl_outs = [( + "-gen-arm-bf16", + "lib/Headers/arm_bf16.h", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/arm_bf16.td", + td_srcs = [ + "include/clang/Basic/arm_bf16.td", + "include/clang/Basic/arm_neon_incl.td", + ], +) + +gentbl( + name = "headers_riscv_vector", + tbl_outs = [( + "-gen-riscv-vector-header", + "lib/Headers/riscv_vector.h", + )], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/riscv_vector.td", + td_srcs = [ + "include/clang/Basic/riscv_vector.td", + ], +) + +# We generate the set of builtin headers under a special subdirectory in the +# 'bin' section of the bazel output so that they can be used as data +# dependencies. It requires listing explicitly all the generated inputs here. +builtin_headers = glob(["lib/Headers/**/*.h"]) + [ + "lib/Headers/arm_cde.h", + "lib/Headers/arm_fp16.h", + "lib/Headers/arm_mve.h", + "lib/Headers/arm_neon.h", + "lib/Headers/arm_sve.h", + "lib/Headers/arm_bf16.h", + "lib/Headers/riscv_vector.h", +] + +genrule( + name = "builtin_headers_gen", + srcs = builtin_headers, + outs = [hdr.replace("lib/Headers/", "staging/include/") for hdr in builtin_headers], + cmd = """ + for src in $(SRCS); do + relsrc=$${src/*external\\/llvm-project\\/clang\\/lib\\/Headers\\/} + target=$(@D)/staging/include/$$relsrc + mkdir -p $$(dirname $$target) + cp $$src $$target + done""", + output_to_bindir = 1, +) + +cc_library( + name = "frontend", + srcs = glob([ + "lib/Frontend/*.cpp", + "lib/Frontend/*.h", + ]), + hdrs = glob([ + "include/clang/Frontend/*.h", + ]), + copts = ["$(STACK_FRAME_UNLIMITED)"], + data = [":builtin_headers_gen"], + includes = ["include"], + textual_hdrs = glob([ + "include/clang/Frontend/*.def", + ]), + deps = [ + ":ast", + ":basic", + ":config", + ":driver", + ":driver_options_inc_gen", + ":edit", + ":lex", + ":parse", + ":sema", + ":serialization", + ":static_analyzer_core_options", + "//llvm:BinaryFormat", + "//llvm:BitReader", + "//llvm:BitstreamReader", + "//llvm:BitstreamWriter", + "//llvm:Core", + "//llvm:Linker", + "//llvm:MC", + "//llvm:Option", + "//llvm:ProfileData", + "//llvm:Support", + "//llvm:Target", + "//llvm:config", + ], +) + +cc_library( + name = "frontend_rewrite", + srcs = glob([ + "lib/Frontend/Rewrite/*.cpp", + "lib/Frontend/Rewrite/*.h", + ]), + hdrs = glob(["include/clang/Rewrite/Frontend/*.h"]), + includes = ["include"], + deps = [ + ":ast", + ":basic", + ":config", + ":edit", + ":frontend", + ":lex", + ":parse", + ":rewrite", + ":serialization", + "//llvm:Support", + ], +) + +cc_library( + name = "interpreter", + srcs = glob([ + "lib/Interpreter/*.cpp", + "lib/Interpreter/*.h", + ]), + hdrs = glob(["include/clang/Interpreter/*.h"]), + includes = ["include"], + deps = [ + ":analysis", + ":ast", + ":basic", + ":codegen", + ":driver", + ":edit", + ":frontend", + ":frontend_tool", + ":lex", + ":parse", + ":sema", + ":serialization", + "//llvm:AllTargetsAsmParsers", + "//llvm:AllTargetsCodeGens", + "//llvm:Core", + "//llvm:ExecutionEngine", + "//llvm:Option", + "//llvm:OrcJIT", + "//llvm:Support", + "//llvm:Target", + ], +) + +cc_library( + name = "codegen", + srcs = glob([ + "lib/CodeGen/*.cpp", + "lib/CodeGen/*.h", + ]), + hdrs = glob(["include/clang/CodeGen/*.h"]), + copts = ["$(STACK_FRAME_UNLIMITED)"], + includes = ["include"], + deps = [ + ":analysis", + ":ast", + ":basic", + ":basic_arm_cde_cg_gen", + ":basic_arm_sve_builtin_cg_gen", + ":basic_riscv_vector_builtin_cg_gen", + ":driver", + ":frontend", + ":lex", + ":sema", + ":type_nodes_gen", + "//llvm:AllTargetsAsmParsers", + "//llvm:Analysis", + "//llvm:BitReader", + "//llvm:BitWriter", + "//llvm:BitstreamReader", + "//llvm:CodeGen", + "//llvm:Core", + "//llvm:Coroutines", + "//llvm:Coverage", + "//llvm:DebugInfoDWARF", + "//llvm:FrontendOpenMP", + "//llvm:IPO", + "//llvm:IRReader", + "//llvm:InstCombine", + "//llvm:Instrumentation", + "//llvm:LTO", + "//llvm:Linker", + "//llvm:MC", + "//llvm:ObjCARC", + "//llvm:Object", + "//llvm:Passes", + "//llvm:ProfileData", + "//llvm:Scalar", + "//llvm:Support", + "//llvm:Target", + "//llvm:TransformUtils", + ], +) + +cc_library( + name = "static_analyzer_frontend", + srcs = glob([ + "lib/StaticAnalyzer/Frontend/**/*.cpp", + "lib/StaticAnalyzer/Frontend/**/*.h", + ]), + hdrs = glob(["include/clang/StaticAnalyzer/Frontend/**/*.h"]), + includes = ["include"], + deps = [ + ":analysis", + ":ast", + ":basic", + ":crosstu", + ":driver", + ":frontend", + ":lex", + ":rewrite", + ":serialization", + ":static_analyzer_checkers", + ":static_analyzer_core", + ":tooling", + ":tooling_core", + "//llvm:Support", + ], +) + +gentbl( + name = "serialization_attr_gen", + tbl_outs = [ + ( + "-gen-clang-attr-pch-read", + "include/clang/Serialization/AttrPCHRead.inc", + ), + ( + "-gen-clang-attr-pch-write", + "include/clang/Serialization/AttrPCHWrite.inc", + ), + ], + tblgen = ":clang-tblgen", + td_file = "include/clang/Basic/Attr.td", + td_srcs = [ + "include/clang/Basic/ASTNode.td", + "include/clang/Basic/Attr.td", + "include/clang/Basic/AttrDocs.td", + "include/clang/Basic/DeclNodes.td", + "include/clang/Basic/StmtNodes.td", + ], +) + +cc_library( + name = "serialization", + srcs = [ + "include/clang/Serialization/AttrPCHRead.inc", + "include/clang/Serialization/AttrPCHWrite.inc", + ] + glob([ + "lib/Serialization/*.cpp", + "lib/Serialization/*.h", + ]), + hdrs = glob([ + "include/clang/Serialization/*.h", + ]), + includes = ["include"], + textual_hdrs = glob([ + "include/clang/Serialization/*.def", + ]), + deps = [ + ":ast", + ":basic", + ":lex", + ":sema", + ":serialization_attr_gen", + ":type_nodes_gen", + "//llvm:BitReader", + "//llvm:BitWriter", + "//llvm:BitstreamReader", + "//llvm:BitstreamWriter", + "//llvm:FrontendOpenMP", + "//llvm:Support", + ], +) + +cc_library( + name = "frontend_tool", + srcs = glob([ + "lib/FrontendTool/*.cpp", + "lib/FrontendTool/*.h", + ]), + hdrs = glob(["include/clang/FrontendTool/*.h"]), + includes = ["include"], + deps = [ + ":arc_migrate", + ":codegen", + ":config", + ":driver", + ":frontend", + ":frontend_rewrite", + ":static_analyzer_frontend", + "//llvm:Option", + "//llvm:Support", + ], +) + +cc_library( + name = "arc_migrate", + srcs = glob([ + "lib/ARCMigrate/*.cpp", + "lib/ARCMigrate/*.h", + ]), + hdrs = glob(["include/clang/ARCMigrate/*.h"]), + includes = ["include"], + deps = [ + ":analysis", + ":ast", + ":basic", + ":edit", + ":frontend", + ":frontend_rewrite", + ":lex", + ":parse", + ":rewrite", + ":sema", + ":serialization", + ":static_analyzer_checkers", + ":static_analyzer_core", + "//llvm:Support", + ], +) + +cc_library( + name = "libclang_library", + srcs = glob([ + "tools/libclang/*.cpp", + "tools/libclang/*.h", + ]), + hdrs = glob(["include/clang-c/*.h"]), + deps = [ + ":arc_migrate", + ":ast", + ":basic", + ":codegen", + ":config", + ":driver", + ":frontend", + ":index", + ":lex", + ":rewrite", + ":sema", + ":tooling", + "//llvm:BitstreamReader", + "//llvm:FrontendOpenMP", + "//llvm:Support", + "//llvm:config", + ], +) + +cc_library( + name = "c-bindings", + hdrs = glob(["include/clang-c/*.h"]), + deps = [ + ":libclang_library", + ], + alwayslink = 1, +) + +cc_plugin_library( + name = "libclang", + deps = [":c-bindings"], +) + +filegroup( + name = "python-sources", + srcs = [ + "bindings/python/clang/cindex.py", + "bindings/python/clang/enumerations.py", + ], +) + +filegroup( + name = "python-cindex-examples", + srcs = [ + "bindings/python/examples/cindex/cindex-dump.py", + "bindings/python/examples/cindex/cindex-includes.py", + ], +) + +cc_binary( + name = "c-index-test", + testonly = 1, + srcs = [ + "tools/c-index-test/c-index-test.c", + "tools/c-index-test/core_main.cpp", + ], + copts = [ + "-Wno-uninitialized", + ], + stamp = 0, + deps = [ + ":ast", + ":basic", + ":c-bindings", + ":codegen", + ":config", + ":frontend", + ":index", + ":lex", + ":parse", + ":sema", + ":serialization", + "//llvm:Core", + "//llvm:MC", + "//llvm:Support", + ], +) + +cc_binary( + name = "arcmt-test", + testonly = 1, + srcs = ["tools/arcmt-test/arcmt-test.cpp"], + stamp = 0, + deps = [ + ":arc_migrate", + ":ast", + ":basic", + ":frontend", + ":frontend_rewrite", + ":lex", + "//llvm:Support", + ], +) + +cc_binary( + name = "c-arcmt-test", + testonly = 1, + srcs = ["tools/c-arcmt-test/c-arcmt-test.c"], + copts = ["-std=gnu99"], + stamp = 0, + deps = [ + ":c-bindings", + ":codegen", + "//llvm:MC", + "//llvm:Support", + ], +) + +cc_binary( + name = "clang-import-test", + testonly = 1, + srcs = glob([ + "tools/clang-import-test/*.cpp", + "tools/clang-import-test/*.h", + ]), + stamp = 0, + deps = [ + ":ast", + ":basic", + ":codegen", + ":driver", + ":frontend", + ":lex", + ":parse", + "//llvm:Core", + "//llvm:Support", + ], +) + +cc_library( + name = "clang-driver", + srcs = glob([ + "tools/driver/*.cpp", + "tools/driver/*.h", + ]), + copts = [ + # Disable stack frame size checks in the driver because + # clang::ensureStackAddressSpace allocates a large array on the stack. + "$(STACK_FRAME_UNLIMITED)", + ], + deps = [ + ":analysis", + ":ast", + ":basic", + ":codegen", + ":config", + ":driver", + ":frontend", + ":frontend_rewrite", + ":frontend_tool", + ":lex", + ":parse", + ":sema", + ":serialization", + ":static_analyzer_frontend", + "//llvm:AllTargetsAsmParsers", + "//llvm:AllTargetsCodeGens", + "//llvm:BitReader", + "//llvm:BitWriter", + "//llvm:CodeGen", + "//llvm:Core", + "//llvm:IPO", + "//llvm:MC", + "//llvm:MCParser", + "//llvm:Option", + "//llvm:Support", + "//llvm:Target", + "//llvm:config", + ], +) + +cc_binary( + name = "clang", + srcs = [], + stamp = 0, + deps = [ + ":clang-driver", + ], +) + +cc_binary( + name = "diagtool", + srcs = glob([ + "tools/diagtool/*.cpp", + "tools/diagtool/*.h", + ]), + stamp = 0, + deps = [ + ":basic", + ":frontend", + ":lex", + ":sema", + "//llvm:Support", + ], +) + +filegroup( + name = "exploded_graph_rewriter", + testonly = 1, + data = ["utils/analyzer/exploded-graph-rewriter.py"], +) + +filegroup( + name = "module-deps-to-rsp", + testonly = 1, + data = ["utils/module-deps-to-rsp.py"], +) + +filegroup( + name = "hmaptool", + testonly = 1, + data = ["utils/hmaptool/hmaptool"], +) + +binary_alias( + name = "clang++", + binary = ":clang", +) + +cc_binary( + name = "clang-check", + srcs = ["tools/clang-check/ClangCheck.cpp"], + stamp = 0, + deps = [ + ":ast", + ":codegen", + ":driver", + ":frontend", + ":frontend_rewrite", + ":serialization", + ":static_analyzer_frontend", + ":tooling", + ":tooling_syntax", + "//llvm:Option", + "//llvm:Support", + ], +) + +cc_binary( + name = "clang-format", + srcs = [ + "tools/clang-format/ClangFormat.cpp", + ], + stamp = 0, + deps = [ + ":basic", + ":format", + ":frontend", + ":rewrite", + "//llvm:Support", + ], +) + +cc_binary( + name = "clang-diff", + srcs = glob(["tools/clang-diff/*.cpp"]), + stamp = 0, + deps = [ + ":ast-diff", + ":tooling", + "//llvm:Support", + ], +) + +cc_binary( + name = "clang-offload-bundler", + srcs = glob(["tools/clang-offload-bundler/*.cpp"]), + stamp = 0, + deps = [ + ":basic", + ":tooling", + "//llvm:BitWriter", + "//llvm:Core", + "//llvm:Object", + "//llvm:Support", + ], +) + +cc_binary( + name = "clang-offload-wrapper", + srcs = glob(["tools/clang-offload-wrapper/*.cpp"]), + stamp = 0, + deps = [ + ":basic", + "//llvm:BitWriter", + "//llvm:Support", + "//llvm:TransformUtils", + "//llvm:ir_headers", + ], +) + +cc_binary( + name = "clang-refactor", + srcs = glob([ + "tools/clang-refactor/*.cpp", + "tools/clang-refactor/*.h", + ]), + stamp = 0, + deps = [ + ":ast", + ":basic", + ":format", + ":frontend", + ":lex", + ":rewrite", + ":tooling", + ":tooling_refactoring", + "//llvm:Support", + ], +) + +cc_binary( + name = "clang-rename", + srcs = glob(["tools/clang-rename/*.cpp"]), + stamp = 0, + deps = [ + ":basic", + ":frontend", + ":rewrite", + ":tooling", + ":tooling_refactoring", + "//llvm:Support", + ], +) + +cc_binary( + name = "clang-repl", + srcs = glob(["tools/clang-repl/*.cpp"]), + stamp = 0, + deps = [ + ":basic", + ":frontend", + ":interpreter", + ":tooling", + "//llvm:Core", + "//llvm:LineEditor", + "//llvm:Option", + "//llvm:OrcJIT", + "//llvm:Support", + ], +) + +cc_binary( + name = "clang-extdef-mapping", + srcs = glob(["tools/clang-extdef-mapping/*.cpp"]), + stamp = 0, + deps = [ + ":ast", + ":basic", + ":crosstu", + ":frontend", + ":tooling", + "//llvm:Support", + ], +) + +cc_binary( + name = "clang-scan-deps", + srcs = glob(["tools/clang-scan-deps/*.cpp"]), + stamp = 0, + deps = [ + ":frontend", + ":tooling", + ":tooling_dependency_scanning", + "//llvm:Support", + ], +) diff --git a/utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h b/utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h @@ -0,0 +1,103 @@ +/*===------- clang/Config/config.h - llvm configuration -----------*- C -*-===*/ +/* */ +/* Part of the LLVM Project, 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 */ +/* */ +/*===----------------------------------------------------------------------===*/ + +/* This is a manual port of config.h.cmake for the symbols that do not change + based on platform. Those that do change should not be defined here and + instead use Bazel cc_library defines. Some attempt has been made to extract + such symbols that do vary based on platform (for the platforms we care about) + into Bazel defines, but it is by no means complete, so if you see something + that looks wrong, it probably is. */ + +#ifdef CLANG_CONFIG_H +#error config.h can only be included once +#else +#define CLANG_CONFIG_H + +/* Bug report URL. */ +#define BUG_REPORT_URL "https://bugs.llvm.org/" + +/* Default linker to use. */ +#define CLANG_DEFAULT_LINKER "" + +/* Default C/ObjC standard to use. */ +/* #undef CLANG_DEFAULT_STD_C */ + +/* Default C++/ObjC++ standard to use. */ +/* #undef CLANG_DEFAULT_STD_CXX */ + +/* Default C++ stdlib to use. */ +#define CLANG_DEFAULT_CXX_STDLIB "" + +/* Default runtime library to use. */ +#define CLANG_DEFAULT_RTLIB "" + +/* Default unwind library to use. */ +#define CLANG_DEFAULT_UNWINDLIB "" + +/* Default objcopy to use */ +#define CLANG_DEFAULT_OBJCOPY "objcopy" + +/* Default OpenMP runtime used by -fopenmp. */ +#define CLANG_DEFAULT_OPENMP_RUNTIME "libomp" + +/* Default architecture for OpenMP offloading to Nvidia GPUs. */ +#define CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_35" + +/* Default architecture for SystemZ. */ +#define CLANG_SYSTEMZ_DEFAULT_ARCH "z10" + +/* Multilib suffix for libdir. */ +#define CLANG_LIBDIR_SUFFIX "" + +/* Relative directory for resource files */ +#define CLANG_RESOURCE_DIR "" + +/* Directories clang will search for headers */ +#define C_INCLUDE_DIRS "" + +/* Directories clang will search for configuration files */ +/* #undef CLANG_CONFIG_FILE_SYSTEM_DIR */ +/* #undef CLANG_CONFIG_FILE_USER_DIR */ + +/* Default to all compiler invocations for --sysroot=. */ +#define DEFAULT_SYSROOT "" + +/* Directory where gcc is installed. */ +#define GCC_INSTALL_PREFIX "" + +/* Define if we have libxml2 */ +/* #undef CLANG_HAVE_LIBXML */ + +/* Define if we have sys/resource.h (rlimits) */ +#define CLANG_HAVE_RLIMITS 1 + +/* The LLVM product name and version */ +#define BACKEND_PACKAGE_STRING "LLVM 12.0.0git" + +/* Linker version detected at compile time. */ +/* #undef HOST_LINK_VERSION */ + +/* pass --build-id to ld */ +/* #undef ENABLE_LINKER_BUILD_ID */ + +/* enable x86 relax relocations by default */ +#define ENABLE_X86_RELAX_RELOCATIONS 1 + +/* Enable the experimental new pass manager by default */ +#define ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER 0 + +/* Enable each functionality of modules */ +#define CLANG_ENABLE_ARCMT 1 +#define CLANG_ENABLE_OBJC_REWRITER 1 +#define CLANG_ENABLE_STATIC_ANALYZER 1 + +/* Spawn a new process clang.exe for the CC1 tool invocation, when necessary */ +#define CLANG_SPAWN_CC1 0 + +#endif diff --git a/utils/bazel/llvm-project-overlay/clang/unittests/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang/unittests/BUILD.bazel new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm-project-overlay/clang/unittests/BUILD.bazel @@ -0,0 +1,487 @@ +# 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 + +package( + default_visibility = ["//visibility:public"], + licenses = ["notice"], +) + +cc_test( + name = "ast_tests", + size = "medium", + srcs = glob( + [ + "AST/*.cpp", + "AST/*.h", + ], + allow_empty = False, + ), + shard_count = 20, + deps = [ + "//clang:ast", + "//clang:ast_matchers", + "//clang:basic", + "//clang:frontend", + "//clang:lex", + "//clang:testing", + "//clang:tooling", + "//llvm:Core", + "//llvm:Support", + "//llvm:TestingSupport", + "//llvm:gmock", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_library( + name = "ast_matchers_tests_hdrs", + testonly = 1, + hdrs = glob( + ["ASTMatchers/*.h"], + allow_empty = False, + ), + deps = [ + "//clang:ast_matchers", + "//clang:frontend", + "//clang:testing", + "//clang:tooling", + "//llvm:gtest", + ], +) + +cc_test( + name = "ast_matchers_tests", + size = "medium", + srcs = glob( + ["ASTMatchers/*.cpp"], + allow_empty = False, + ), + shard_count = 20, + deps = [ + ":ast_matchers_tests_hdrs", + "//clang:ast", + "//clang:ast_matchers", + "//clang:frontend", + "//clang:tooling", + "//llvm:Support", + "//llvm:TestingSupport", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "ast_matchers_dynamic_tests", + size = "small", + srcs = glob( + ["ASTMatchers/Dynamic/*.cpp"], + allow_empty = False, + ), + deps = [ + ":ast_matchers_tests_hdrs", + "//clang:ast_matchers", + "//clang:ast_matchers_dynamic", + "//clang:frontend", + "//clang:tooling", + "//llvm:Support", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "analysis_tests", + size = "small", + srcs = glob( + [ + "Analysis/*.cpp", + "Analysis/*.h", + ], + allow_empty = False, + ), + deps = [ + "//clang:analysis", + "//clang:ast", + "//clang:ast_matchers", + "//clang:basic", + "//clang:lex", + "//clang:parse", + "//clang:tooling", + "//llvm:Support", + "//llvm:gmock", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "basic_tests", + size = "small", + srcs = glob( + ["Basic/*.cpp"], + allow_empty = False, + ), + deps = [ + "//clang:basic", + "//clang:frontend", + "//clang:lex", + "//llvm:Support", + "//llvm:config", + "//llvm:gmock", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "codegen_tests", + size = "small", + srcs = glob( + [ + "CodeGen/*.cpp", + "CodeGen/*.h", + ], + allow_empty = False, + ), + deps = [ + "//clang:ast", + "//clang:basic", + "//clang:codegen", + "//clang:frontend", + "//clang:lex", + "//clang:parse", + "//clang:sema", + "//llvm:Core", + "//llvm:Support", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "format_tests", + size = "medium", + srcs = glob( + [ + "Format/*.cpp", + "Format/*.h", + "Tooling/*.h", + ], + allow_empty = False, + ), + copts = ["$(STACK_FRAME_UNLIMITED)"], + shard_count = 20, + deps = [ + "//clang:basic", + "//clang:format", + "//clang:frontend", + "//clang:tooling_core", + "//llvm:Support", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "frontend_tests", + size = "small", + srcs = glob( + ["Frontend/*.cpp"], + allow_empty = False, + ), + deps = [ + "//clang:ast", + "//clang:basic", + "//clang:codegen", + "//clang:driver_options_inc_gen", + "//clang:frontend", + "//clang:frontend_tool", + "//clang:lex", + "//clang:sema", + "//clang:serialization", + "//llvm:Support", + "//llvm:gmock", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "lex_tests", + size = "small", + srcs = glob( + [ + "Lex/*.cpp", + "Lex/*.h", + ], + allow_empty = False, + ), + copts = ["$(STACK_FRAME_UNLIMITED)"], + deps = [ + "//clang:ast", + "//clang:basic", + "//clang:lex", + "//clang:parse", + "//clang:sema", + "//clang:serialization", + "//llvm:Support", + "//llvm:gmock", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +# A library to carefully expose the tooling headers using the include prefix +# expected by the `rename_tests`. +cc_library( + name = "rename_tests_tooling_hdrs", + testonly = 1, + hdrs = glob( + ["Tooling/*.h"], + allow_empty = False, + ), + include_prefix = "unittests", + deps = [ + "//clang:ast", + "//clang:basic", + "//clang:frontend", + "//clang:rewrite", + "//clang:tooling", + "//clang:tooling_core", + "//llvm:Support", + "//llvm:gtest", + ], +) + +cc_test( + name = "rename_tests", + size = "small", + timeout = "moderate", + srcs = glob( + [ + "Rename/*.cpp", + "Rename/*.h", + ], + allow_empty = False, + ), + shard_count = 20, + deps = [ + ":rename_tests_tooling_hdrs", + "//clang:ast_matchers", + "//clang:basic", + "//clang:format", + "//clang:frontend", + "//clang:tooling", + "//clang:tooling_refactoring", + "//llvm:Support", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "rewrite_tests", + size = "small", + srcs = glob( + ["Rewrite/*.cpp"], + allow_empty = False, + ), + deps = [ + "//clang:rewrite", + "//clang:tooling", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "sema_tests", + size = "small", + srcs = glob( + ["Sema/*.cpp"], + allow_empty = False, + ), + deps = [ + ":ast_matchers_tests_hdrs", + "//clang:ast", + "//clang:ast_matchers", + "//clang:frontend", + "//clang:lex", + "//clang:parse", + "//clang:sema", + "//clang:tooling", + "//llvm:TestingSupport", + "//llvm:gmock", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_library( + name = "static_analyzer_test_headers", + testonly = 1, + hdrs = glob( + ["StaticAnalyzer/*.h"], + allow_empty = False, + ), + deps = [ + "//clang:ast_matchers", + "//clang:crosstu", + "//clang:frontend", + "//clang:static_analyzer_core", + "//clang:static_analyzer_frontend", + "//clang:tooling", + "//llvm:gtest", + ], +) + +cc_test( + name = "static_analyzer_tests", + size = "small", + srcs = glob( + ["StaticAnalyzer/*.cpp"], + allow_empty = False, + exclude = [ + # New test has unused-variable warnings. + "StaticAnalyzer/ParamRegionTest.cpp", + ], + ), + deps = [ + ":static_analyzer_test_headers", + "//clang:basic", + "//clang:frontend", + "//clang:static_analyzer_core", + "//clang:static_analyzer_frontend", + "//clang:tooling", + "//llvm:Support", + "//llvm:config", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "tooling_tests", + size = "medium", + srcs = glob( + [ + "Tooling/*.cpp", + "Tooling/*.h", + ], + allow_empty = False, + ), + shard_count = 20, + deps = [ + "//clang:ast", + "//clang:ast_matchers", + "//clang:basic", + "//clang:format", + "//clang:frontend", + "//clang:lex", + "//clang:rewrite", + "//clang:tooling", + "//clang:tooling_core", + "//clang:tooling_inclusions", + "//clang:tooling_refactoring", + "//clang:transformer", + "//llvm:Support", + "//llvm:TestingSupport", + "//llvm:gmock", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +# A library to carefully expose the tooling headers using the include prefix +# expected by the `tooling_recursive_ast_visitor_tests`. +cc_library( + name = "tooling_recursive_ast_visitor_tests_tooling_hdrs", + testonly = 1, + hdrs = glob( + ["Tooling/*.h"], + allow_empty = False, + ), + strip_include_prefix = "Tooling", + deps = [ + "//clang:ast", + "//clang:basic", + "//clang:frontend", + "//clang:rewrite", + "//clang:tooling", + "//clang:tooling_core", + "//llvm:Support", + "//llvm:gtest", + ], +) + +cc_test( + name = "tooling_recursive_ast_visitor_tests", + size = "medium", + srcs = glob( + ["Tooling/RecursiveASTVisitorTests/*.cpp"], + allow_empty = False, + ) + [ + "Tooling/RecursiveASTVisitorTests/CallbacksCommon.h", + ], + deps = [ + ":tooling_recursive_ast_visitor_tests_tooling_hdrs", + "//clang:ast", + "//clang:basic", + "//clang:frontend", + "//clang:lex", + "//clang:tooling", + "//clang:tooling_syntax", + "//llvm:Support", + "//llvm:TestingSupport", + "//llvm:gmock", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "tooling_syntax_tests", + size = "medium", + srcs = glob( + [ + "Tooling/Syntax/*.cpp", + "Tooling/Syntax/*.h", + ], + allow_empty = False, + ), + shard_count = 20, + deps = [ + "//clang:ast", + "//clang:basic", + "//clang:frontend", + "//clang:lex", + "//clang:testing", + "//clang:tooling", + "//clang:tooling_core", + "//clang:tooling_syntax", + "//llvm:Support", + "//llvm:TestingSupport", + "//llvm:gmock", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "libclang_tests", + size = "small", + srcs = glob( + ["libclang/*.cpp"], + allow_empty = False, + ) + [ + "libclang/TestUtils.h", + ], + deps = [ + "//clang:c-bindings", + "//llvm:Support", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel @@ -0,0 +1,4051 @@ +# 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(":template_rule.bzl", "template_rule") +load(":tblgen.bzl", "gentbl") +load(":config.bzl", "llvm_config_defines") +load(":targets.bzl", "llvm_targets") +load(":binary_alias.bzl", "binary_alias") + +package( + default_visibility = ["//visibility:public"], + licenses = ["notice"], +) + +exports_files(["LICENSE.TXT"]) + +# It may be tempting to add compiler flags here, but that should be avoided. +# The necessary warnings and other compile flags should be provided by the +# toolchain or the `.bazelrc` file. This is just a workaround until we have a +# widely available feature to enable unlimited stack frame instead of using +# this `Make` variable. +llvm_copts = [ + "$(STACK_FRAME_UNLIMITED)", +] + +template_rule( + name = "targets_def_gen", + src = "include/llvm/Config/Targets.def.in", + out = "include/llvm/Config/Targets.def", + substitutions = { + "@LLVM_ENUM_TARGETS@": "\n".join(["LLVM_TARGET({})".format(t) for t in llvm_targets]), + }, +) + +template_rule( + name = "asm_printers_def_gen", + src = "include/llvm/Config/AsmPrinters.def.in", + out = "include/llvm/Config/AsmPrinters.def", + substitutions = { + "@LLVM_ENUM_ASM_PRINTERS@": "\n".join(["LLVM_ASM_PRINTER({})".format(t) for t in llvm_targets]), + }, +) + +# List of targets with ASM parsers, filtered to our list of overall targets. +llvm_target_asm_parsers = [t for t in [ + "AArch64", + "AMDGPU", + "ARM", + "BPF", + "Hexagon", + "Lanai", + "PowerPC", + "RISCV", + "Sparc", + "WebAssembly", + "X86", +] if t in llvm_targets] + +template_rule( + name = "asm_parsers_def_gen", + src = "include/llvm/Config/AsmParsers.def.in", + out = "include/llvm/Config/AsmParsers.def", + substitutions = { + "@LLVM_ENUM_ASM_PARSERS@": "\n".join(["LLVM_ASM_PARSER({})".format(t) for t in llvm_target_asm_parsers]), + }, +) + +# List of targets with disassemblers, filtered to our list of overall targets. +llvm_target_disassemblers = [t for t in [ + "AArch64", + "AMDGPU", + "ARM", + "BPF", + "Hexagon", + "Lanai", + "PowerPC", + "RISCV", + "Sparc", + "WebAssembly", + "X86", +] if t in llvm_targets] + +template_rule( + name = "disassemblers_def_gen", + src = "include/llvm/Config/Disassemblers.def.in", + out = "include/llvm/Config/Disassemblers.def", + substitutions = { + "@LLVM_ENUM_DISASSEMBLERS@": "\n".join(["LLVM_DISASSEMBLER({})".format(t) for t in llvm_target_disassemblers]), + }, +) + +# TODO: Need to replace this with something that actually extracts the git +# commit from the LLVM source (submodule or http_archive). +genrule( + name = "version_info_gen", + outs = ["include/llvm/Config/VersionInfo.h"], + cmd = "echo \"#define LLVM_VERSION_INFO \\\"git\\\"\" > $@", +) + +template_rule( + name = "abi_breaking_h_gen", + src = "include/llvm/Config/abi-breaking.h.cmake", + out = "include/llvm/Config/abi-breaking.h", + substitutions = { + # Define to enable checks that alter the LLVM C++ ABI + "#cmakedefine01 LLVM_ENABLE_ABI_BREAKING_CHECKS": "#define LLVM_ENABLE_ABI_BREAKING_CHECKS 0", + + # Define to enable reverse iteration of unordered llvm containers + "#cmakedefine01 LLVM_ENABLE_REVERSE_ITERATION": "#define LLVM_ENABLE_REVERSE_ITERATION 0", + }, +) + +# To enable diff testing out of tree +exports_files([ + "include/llvm/Config/config.h.cmake", + "include/llvm/Config/llvm-config.h.cmake", + "include/llvm/Config/abi-breaking.h.cmake", +]) + +cc_library( + name = "config", + hdrs = [ + "include/llvm/Config/VersionInfo.h", + "include/llvm/Config/abi-breaking.h", + "include/llvm/Config/llvm-config.h", + ], + copts = llvm_copts, + defines = llvm_config_defines, + includes = ["include"], + textual_hdrs = [ + "include/llvm/Config/AsmParsers.def", + "include/llvm/Config/AsmPrinters.def", + "include/llvm/Config/Disassemblers.def", + "include/llvm/Config/Targets.def", + # Needed for include scanner to find execinfo.h + "include/llvm/Config/config.h", + ], +) + +cc_library( + name = "Demangle", + srcs = glob([ + "lib/Demangle/*.cpp", + "lib/Demangle/*.h", + ]), + hdrs = glob(["include/llvm/Demangle/*.h"]), + copts = llvm_copts, + deps = [":config"], +) + +genrule( + name = "generate_vcs_revision", + outs = ["include/llvm/Support/VCSRevision.h"], + cmd = "echo '#define LLVM_REVISION \"git\"' >> $@\n" + + "echo '#undef LLVM_REPOSITORY' >> $@\n", +) + +genrule( + name = "generate_static_extension_registry", + outs = ["include/llvm/Support/Extension.def"], + cmd = "echo -e '// extension handlers' >> $@\n" + + "echo -e '#undef HANDLE_EXTENSION' >> $@\n", +) + +cc_library( + name = "Support", + srcs = glob([ + "lib/Support/*.c", + "lib/Support/*.cpp", + "lib/Support/*.h", + "lib/Support/*.inc", + ]) + select({ + "@bazel_tools//src/conditions:windows": glob([ + "lib/Support/Windows/*.h", + "lib/Support/Windows/*.inc", + ]), + "//conditions:default": glob([ + "lib/Support/Unix/*.h", + "lib/Support/Unix/*.inc", + ]), + }), + hdrs = glob([ + "include/llvm/Support/**/*.h", + "include/llvm/ADT/*.h", + "include/llvm/MC/*.h", # TODO(maskray): Fix the layering issue. + ]) + [ + "include/llvm-c/Core.h", + "include/llvm-c/DataTypes.h", + "include/llvm-c/DisassemblerTypes.h", + "include/llvm-c/Error.h", + "include/llvm-c/ErrorHandling.h", + "include/llvm-c/ExternC.h", + "include/llvm-c/Support.h", + "include/llvm-c/Types.h", + "include/llvm/ExecutionEngine/JITSymbol.h", + "include/llvm/Support/Extension.def", + "include/llvm/Support/VCSRevision.h", + ], + copts = llvm_copts, + includes = ["include"], + linkopts = select({ + "@bazel_tools//src/conditions:windows": [], + "//conditions:default": [ + "-pthread", + "-ldl", + "-lm", + ], + }), + textual_hdrs = glob([ + "include/llvm/Support/*.def", + ]), + deps = [ + ":config", + ":Demangle", + # We unconditionally depend on the custom LLVM terminfo wrapper. This + # will be an empty library unless terminfo is enabled, in which case it + # will both provide the necessary dependencies and configuration + # defines. + "@llvm_terminfo//:terminfo", + # We unconditionally depend on the custom LLVM zlib wrapper. This will + # be an empty library unless zlib is enabled, in which case it will + # both provide the necessary dependencies and configuration defines. + "@llvm_zlib//:zlib", + ], +) + +# Note: although FileCheck (the binary) is a test utility, some non-test +# targets depend on the FileCheck library target. +cc_library( + name = "FileCheckLib", + srcs = glob([ + "lib/FileCheck/*.cpp", + "lib/FileCheck/*.h", + ]), + hdrs = glob(["include/llvm/FileCheck/*.h"]), + copts = llvm_copts, + deps = [":Support"], +) + +cc_library( + name = "LineEditor", + srcs = glob([ + "lib/LineEditor/*.cpp", + "lib/LineEditor/*.h", + ]), + hdrs = glob(["include/llvm/LineEditor/*.h"]), + copts = llvm_copts, + deps = [ + ":Support", + ":config", + ], +) + +cc_library( + name = "Option", + srcs = glob([ + "lib/Option/*.cpp", + "lib/Option/*.h", + ]), + hdrs = glob(["include/llvm/Option/*.h"]), + copts = llvm_copts, + deps = [ + ":Support", + ":config", + ], +) + +cc_library( + name = "TableGen", + srcs = glob([ + "lib/TableGen/*.cpp", + "lib/TableGen/*.h", + ]), + hdrs = glob(["include/llvm/TableGen/*.h"]), + copts = llvm_copts, + deps = [ + ":Support", + ":config", + ], +) + +# This exists to avoid circular dependencies. +cc_library( + name = "ir_headers", + hdrs = glob( + [ + "include/llvm/*.h", + "include/llvm/IR/*.h", + ], + exclude = [ + "include/llvm/LinkAllPasses.h", + ], + ) + [ + "include/llvm/IR/Value.def", + "include/llvm-c/Comdat.h", + "include/llvm-c/DebugInfo.h", + ], + copts = llvm_copts, +) + +cc_library( + name = "BinaryFormat", + srcs = glob([ + "lib/BinaryFormat/*.cpp", + "lib/BinaryFormat/*.def", + "lib/BinaryFormat/*.h", + ]), + hdrs = glob([ + "include/llvm/BinaryFormat/*.h", + ]), + copts = llvm_copts, + includes = ["include"], + textual_hdrs = glob([ + "include/llvm/BinaryFormat/*.def", + "include/llvm/BinaryFormat/ELFRelocs/*.def", + ]), + deps = [ + ":Support", + ], +) + +cc_library( + name = "DebugInfo", + hdrs = glob(["include/llvm/DebugInfo/*.h"]), + copts = llvm_copts, + deps = [ + ":Object", + ":Support", + ], +) + +cc_library( + name = "DebugInfoMSF", + srcs = glob([ + "lib/DebugInfo/MSF/*.cpp", + "lib/DebugInfo/MSF/*.h", + ]), + hdrs = glob(["include/llvm/DebugInfo/MSF/*.h"]), + copts = llvm_copts, + deps = [":Support"], +) + +cc_library( + name = "DebugInfoCodeView", + srcs = glob([ + "lib/DebugInfo/CodeView/*.cpp", + "lib/DebugInfo/CodeView/*.h", + ]), + hdrs = glob([ + "include/llvm/DebugInfo/CodeView/*.h", + ]), + copts = llvm_copts, + textual_hdrs = glob([ + "include/llvm/DebugInfo/CodeView/*.def", + ]), + deps = [ + ":BinaryFormat", + ":DebugInfoMSF", + ":Support", + ], +) + +cc_library( + name = "DebugInfoPDB", + srcs = glob([ + "lib/DebugInfo/PDB/*.cpp", + "lib/DebugInfo/PDB/*.h", + "lib/DebugInfo/PDB/Native/*.cpp", + "lib/DebugInfo/PDB/Native/*.h", + ]), + hdrs = glob([ + "include/llvm/DebugInfo/PDB/*.h", + "include/llvm/DebugInfo/PDB/Native/*.h", + ]), + copts = llvm_copts, + deps = [ + ":BinaryFormat", + ":DebugInfo", + ":DebugInfoCodeView", + ":DebugInfoMSF", + ":Object", + ":Support", + ":config", + ], +) + +cc_library( + name = "MC", + srcs = glob([ + "lib/MC/*.cpp", + "lib/MC/*.h", + ]), + hdrs = glob([ + "include/llvm/MC/*.h", + "include/llvm/MC/*.def", + "include/llvm/MC/*.inc", + ]), + copts = llvm_copts, + deps = [ + ":BinaryFormat", + ":DebugInfoCodeView", + ":Support", + ":config", + ":ir_headers", + ], +) + +cc_library( + name = "DebugInfoDWARF", + srcs = glob([ + "lib/DebugInfo/DWARF/*.cpp", + "lib/DebugInfo/DWARF/*.h", + ]), + hdrs = glob(["include/llvm/DebugInfo/DWARF/*.h"]), + copts = llvm_copts, + deps = [ + ":BinaryFormat", + ":DebugInfo", + ":MC", + ":Object", + ":Support", + ], +) + +cc_library( + name = "Symbolize", + srcs = glob([ + "lib/DebugInfo/Symbolize/*.cpp", + "lib/DebugInfo/Symbolize/*.h", + ]), + hdrs = glob(["include/llvm/DebugInfo/Symbolize/*.h"]), + copts = llvm_copts, + deps = [ + ":BinaryFormat", + ":DebugInfo", + ":DebugInfoDWARF", + ":DebugInfoPDB", + ":Demangle", + ":Object", + ":Support", + ], +) + +cc_library( + name = "tblgen", + srcs = glob([ + "utils/TableGen/*.cpp", + "utils/TableGen/GlobalISel/*.cpp", + + # We have to include these headers here as well as in the `hdrs` below + # to allow the `.cpp` files to use file-relative-inclusion to find + # them, even though consumers of this library use inclusion relative to + # `utils/TableGen` with the `strip_includes_prefix` of this library. + # This mixture appears to be incompatible with header modules. + "utils/TableGen/*.h", + "utils/TableGen/GlobalISel/*.h", + ]), + hdrs = glob([ + "utils/TableGen/*.h", + "utils/TableGen/GlobalISel/*.h", + ]), + copts = llvm_copts, + features = ["-header_modules"], + strip_include_prefix = "utils/TableGen", + deps = [ + ":MC", + ":Support", + ":TableGen", + ":config", + ], +) + +cc_binary( + name = "llvm-tblgen", + copts = llvm_copts, + stamp = 0, + deps = [ + ":tblgen", + ], +) + +gentbl( + name = "intrinsic_enums_gen", + tbl_outs = [("-gen-intrinsic-enums", "include/llvm/IR/IntrinsicEnums.inc")], + tblgen = ":llvm-tblgen", + td_file = "include/llvm/IR/Intrinsics.td", + td_srcs = glob([ + "include/llvm/CodeGen/*.td", + "include/llvm/IR/Intrinsics*.td", + ]), +) + +gentbl( + name = "intrinsics_impl_gen", + tbl_outs = [("-gen-intrinsic-impl", "include/llvm/IR/IntrinsicImpl.inc")], + tblgen = ":llvm-tblgen", + td_file = "include/llvm/IR/Intrinsics.td", + td_srcs = glob([ + "include/llvm/CodeGen/*.td", + "include/llvm/IR/Intrinsics*.td", + ]), +) + +# Note that the intrinsics are not currently set up so they can be pruned for +# disabled targets. +llvm_target_intrinsics_list = [ + { + "name": "AArch64", + "intrinsic_prefix": "aarch64", + }, + { + "name": "AMDGPU", + "intrinsic_prefix": "amdgcn", + }, + { + "name": "ARM", + "intrinsic_prefix": "arm", + }, + { + "name": "BPF", + "intrinsic_prefix": "bpf", + }, + { + "name": "Hexagon", + "intrinsic_prefix": "hexagon", + }, + { + "name": "Mips", + "intrinsic_prefix": "mips", + }, + { + "name": "NVPTX", + "intrinsic_prefix": "nvvm", + }, + { + "name": "PowerPC", + "intrinsic_prefix": "ppc", + }, + { + "name": "R600", + "intrinsic_prefix": "r600", + }, + { + "name": "RISCV", + "intrinsic_prefix": "riscv", + }, + { + "name": "S390", + "intrinsic_prefix": "s390", + }, + { + "name": "VE", + "intrinsic_prefix": "ve", + }, + { + "name": "WebAssembly", + "intrinsic_prefix": "wasm", + }, + { + "name": "X86", + "intrinsic_prefix": "x86", + }, + { + "name": "XCore", + "intrinsic_prefix": "xcore", + }, +] + +[[ + gentbl( + name = "intrinsic_" + target["name"] + "_gen", + tbl_outs = [( + "-gen-intrinsic-enums -intrinsic-prefix=" + target["intrinsic_prefix"], + "include/llvm/IR/Intrinsics" + target["name"] + ".h", + )], + tblgen = ":llvm-tblgen", + td_file = "include/llvm/IR/Intrinsics.td", + td_srcs = glob([ + "include/llvm/CodeGen/*.td", + "include/llvm/IR/*.td", + ]), + ), +] for target in llvm_target_intrinsics_list] + +gentbl( + name = "attributes_gen", + tbl_outs = [("-gen-attrs", "include/llvm/IR/Attributes.inc")], + tblgen = ":llvm-tblgen", + td_file = "include/llvm/IR/Attributes.td", + td_srcs = ["include/llvm/IR/Attributes.td"], +) + +cc_library( + name = "BitstreamReader", + srcs = glob([ + "lib/Bitstream/Reader/*.cpp", + "lib/Bitstream/Reader/*.h", + ]), + hdrs = [ + "include/llvm/Bitstream/BitCodes.h", + "include/llvm/Bitstream/BitstreamReader.h", + ], + copts = llvm_copts, + deps = [ + ":Support", + ], +) + +cc_library( + name = "BitstreamWriter", + srcs = glob([ + "lib/Bitstream/Writer/*.h", + ]), + hdrs = [ + "include/llvm/Bitstream/BitCodes.h", + "include/llvm/Bitstream/BitstreamWriter.h", + ], + copts = llvm_copts, + deps = [ + ":Support", + ], +) + +cc_library( + name = "Remarks", + srcs = glob( + [ + "lib/Remarks/*.cpp", + "lib/Remarks/*.h", + ], + exclude = ["lib/Remarks/RemarkLinker.cpp"], + ), + hdrs = glob( + [ + "include/llvm/Remarks/*.h", + ], + exclude = ["include/llvm/Remarks/RemarkLinker.h"], + ) + [ + "include/llvm-c/Remarks.h", + ], + copts = llvm_copts, + deps = [ + ":BitstreamReader", + ":BitstreamWriter", + ":Support", + ], +) + +cc_library( + name = "remark_linker", + srcs = ["lib/Remarks/RemarkLinker.cpp"], + hdrs = ["include/llvm/Remarks/RemarkLinker.h"], + copts = llvm_copts, + deps = [ + ":Object", + ":Support", + ], +) + +filegroup( + name = "llvm_intrinsics_headers", + srcs = [ + "include/llvm/IR/Intrinsics" + target["name"] + ".h" + for target in llvm_target_intrinsics_list + ], +) + +cc_library( + name = "Core", + srcs = glob([ + "lib/IR/*.cpp", + "lib/IR/*.h", + ]), + hdrs = glob( + [ + "include/llvm/*.h", + "include/llvm/IR/*.h", + ], + exclude = [ + "include/llvm/LinkAllPasses.h", + ], + ) + [ + "include/llvm-c/Comdat.h", + "include/llvm-c/DebugInfo.h", + ] + [":llvm_intrinsics_headers"], + copts = llvm_copts, + textual_hdrs = glob(["include/llvm/IR/*.def"]), + deps = [ + ":BinaryFormat", + ":Remarks", + ":Support", + ":attributes_gen", + ":config", + ":intrinsic_enums_gen", + ":intrinsics_impl_gen", + ], +) + +cc_library( + name = "BitReader", + srcs = glob([ + "lib/Bitcode/Reader/*.cpp", + "lib/Bitcode/Reader/*.h", + ]), + hdrs = [ + "include/llvm-c/BitReader.h", + "include/llvm/Bitcode/BitcodeAnalyzer.h", + "include/llvm/Bitcode/BitcodeCommon.h", + "include/llvm/Bitcode/BitcodeReader.h", + "include/llvm/Bitcode/LLVMBitCodes.h", + ], + copts = llvm_copts, + deps = [ + ":BitstreamReader", + ":Core", + ":Support", + ":config", + ], +) + +cc_library( + name = "MCParser", + srcs = glob([ + "lib/MC/MCParser/*.cpp", + "lib/MC/MCParser/*.h", + ]), + hdrs = glob(["include/llvm/MC/MCParser/*.h"]), + copts = llvm_copts, + deps = [ + ":BinaryFormat", + ":MC", + ":Support", + ":config", + ], +) + +cc_library( + name = "TextAPI", + srcs = glob([ + "lib/TextAPI/**/*.cpp", + ]), + hdrs = glob([ + "include/llvm/TextAPI/**/*.h", + "include/llvm/TextAPI/**/*.def", + "lib/TextAPI/**/*.h", + ]), + copts = llvm_copts, + deps = [ + ":BinaryFormat", + ":Support", + ], +) + +cc_library( + name = "Object", + srcs = glob([ + "lib/Object/*.cpp", + "lib/Object/*.h", + ]), + hdrs = glob([ + "include/llvm/Object/*.h", + ]) + [ + "include/llvm-c/Object.h", + ], + copts = llvm_copts, + deps = [ + ":BinaryFormat", + ":BitReader", + ":Core", + ":MC", + ":MCParser", + ":Support", + ":TextAPI", + ":config", + ], +) + +cc_library( + name = "ObjectYAML", + srcs = glob([ + "lib/ObjectYAML/*.cpp", + "lib/ObjectYAML/*.h", + ]), + hdrs = glob(["include/llvm/ObjectYAML/*.h"]), + copts = llvm_copts, + deps = [ + ":BinaryFormat", + ":DebugInfoCodeView", + ":Object", + ":Support", + ], +) + +cc_library( + name = "ProfileData", + srcs = glob([ + "lib/ProfileData/*.cpp", + "lib/ProfileData/*.h", + ]), + hdrs = glob([ + "include/llvm/ProfileData/*.h", + "include/llvm/ProfileData/*.inc", + ]), + copts = llvm_copts, + deps = [ + ":Core", + ":Support", + ":config", + ], +) + +cc_library( + name = "Coverage", + srcs = glob([ + "lib/ProfileData/Coverage/*.cpp", + "lib/ProfileData/Coverage/*.h", + ]), + hdrs = glob(["include/llvm/ProfileData/Coverage/*.h"]), + copts = llvm_copts, + deps = [ + ":Object", + ":ProfileData", + ":Support", + ], +) + +cc_library( + name = "Analysis", + srcs = glob( + [ + "lib/Analysis/*.cpp", + "lib/Analysis/*.h", + "lib/Analysis/*.def", + ], + exclude = [ + # TODO(mtrofin): Add these files to the build. + "lib/Analysis/MLInlineAdvisor.cpp", + "lib/Analysis/DevelopmentModeInlineAdvisor.cpp", + "lib/Analysis/ReleaseModeModelRunner.cpp", + "lib/Analysis/TFUtils.cpp", + ], + ), + hdrs = glob( + [ + "include/llvm/Analysis/*.h", + "include/llvm/Analysis/Utils/*.h", + ], + exclude = [ + # TODO(mtrofin): Add this file to the build. + "include/llvm/Analysis/Utils/TFUtils.h", + ], + ) + [ + "include/llvm-c/Analysis.h", + "include/llvm-c/Initialization.h", + ], + copts = llvm_copts, + textual_hdrs = glob([ + "include/llvm/Analysis/*.def", + ]), + deps = [ + ":BinaryFormat", + ":Core", + ":Object", + ":ProfileData", + ":Support", + ":config", + ], +) + +cc_library( + name = "BitWriter", + srcs = glob([ + "lib/Bitcode/Writer/*.cpp", + "lib/Bitcode/Writer/*.h", + ]), + hdrs = [ + "include/llvm-c/BitWriter.h", + "include/llvm/Bitcode/BitcodeCommon.h", + "include/llvm/Bitcode/BitcodeWriter.h", + "include/llvm/Bitcode/BitcodeWriterPass.h", + "include/llvm/Bitcode/LLVMBitCodes.h", + ], + copts = llvm_copts, + deps = [ + ":Analysis", + ":BitstreamWriter", + ":Core", + ":MC", + ":Object", + ":Support", + ":config", + ], +) + +cc_library( + name = "Target", + srcs = glob([ + "lib/Target/*.cpp", + "lib/Target/*.h", + ]), + hdrs = glob([ + "include/llvm/Target/*.h", + ]) + [ + "include/llvm-c/Target.h", + "include/llvm-c/TargetMachine.h", + ], + copts = llvm_copts, + deps = [ + ":Analysis", + ":BinaryFormat", + ":Core", + ":MC", + ":Support", + ":config", + ], +) + +cc_library( + name = "TransformUtils", + srcs = glob([ + "lib/Transforms/Utils/*.cpp", + "lib/Transforms/Utils/*.h", + ]), + hdrs = glob(["include/llvm/Transforms/Utils/*.h"]) + [ + "include/llvm/Transforms/Utils.h", + "include/llvm-c/Transforms/Utils.h", + ], + copts = llvm_copts, + deps = [ + ":Analysis", + ":BinaryFormat", + ":BitWriter", + ":Core", + ":Support", + ":Target", + ":config", + ], +) + +gentbl( + name = "InstCombineTableGen", + strip_include_prefix = "lib/Target/AMDGPU", + tbl_outs = [( + "-gen-searchable-tables", + "lib/Target/AMDGPU/InstCombineTables.inc", + )], + tblgen = ":llvm-tblgen", + td_file = "lib/Target/AMDGPU/InstCombineTables.td", + td_srcs = glob([ + "include/llvm/CodeGen/*.td", + "include/llvm/IR/Intrinsics*.td", + ]) + [ + "lib/Target/AMDGPU/InstCombineTables.td", + "include/llvm/TableGen/SearchableTable.td", + ], +) + +cc_library( + name = "InstCombine", + srcs = glob([ + "lib/Transforms/InstCombine/*.cpp", + "lib/Transforms/InstCombine/*.h", + ]), + hdrs = glob(["include/llvm/Transforms/InstCombine/*.h"]) + [ + "include/llvm-c/Transforms/InstCombine.h", + ], + copts = llvm_copts, + deps = [ + ":Analysis", + ":Core", + ":InstCombineTableGen", + ":Support", + ":Target", + ":TransformUtils", + ":config", + ], +) + +cc_library( + name = "AggressiveInstCombine", + srcs = glob([ + "lib/Transforms/AggressiveInstCombine/*.cpp", + "lib/Transforms/AggressiveInstCombine/*.h", + ]), + hdrs = [ + "include/llvm-c/Transforms/AggressiveInstCombine.h", + "include/llvm/Transforms/AggressiveInstCombine/AggressiveInstCombine.h", + ], + copts = llvm_copts, + deps = [ + ":Analysis", + ":Core", + ":Support", + ":TransformUtils", + ], +) + +cc_library( + name = "Instrumentation", + srcs = glob([ + "lib/Transforms/Instrumentation/*.cpp", + "lib/Transforms/Instrumentation/*.h", + "lib/Transforms/Instrumentation/*.inc", + ]), + hdrs = glob(["include/llvm/Transforms/Instrumentation/*.h"]) + [ + "include/llvm/Transforms/Instrumentation.h", + ], + copts = llvm_copts, + deps = [ + ":Analysis", + ":BinaryFormat", + ":Core", + ":MC", + ":ProfileData", + ":Support", + ":TransformUtils", + ":config", + ], +) + +cc_library( + name = "ObjCARC", + srcs = glob([ + "lib/Transforms/ObjCARC/*.cpp", + "lib/Transforms/ObjCARC/*.h", + ]), + hdrs = ["include/llvm/Transforms/ObjCARC.h"], + copts = llvm_copts, + deps = [ + ":Analysis", + ":Core", + ":Support", + ":Target", + ":TransformUtils", + ":config", + ], +) + +cc_library( + name = "Scalar", + srcs = glob([ + "lib/Transforms/Scalar/*.cpp", + "lib/Transforms/Scalar/*.h", + ]), + hdrs = glob(["include/llvm/Transforms/Scalar/*.h"]) + [ + "include/llvm-c/Transforms/Scalar.h", + "include/llvm/Transforms/Scalar.h", + ], + copts = llvm_copts, + deps = [ + ":AggressiveInstCombine", + ":Analysis", + ":Core", + ":InstCombine", + ":ProfileData", + ":Support", + ":Target", + ":TransformUtils", + ":config", + ], +) + +cc_library( + name = "Vectorize", + srcs = glob([ + "lib/Transforms/Vectorize/*.cpp", + "lib/Transforms/Vectorize/*.h", + ]), + hdrs = glob([ + "include/llvm/Transforms/Vectorize/*.h", + ]) + [ + "include/llvm-c/Transforms/Vectorize.h", + "include/llvm/Transforms/Vectorize.h", + ], + copts = llvm_copts, + deps = [ + ":Analysis", + ":Core", + ":Support", + ":Target", + ":TransformUtils", + ":config", + ], +) + +filegroup( + name = "omp_td_files", + srcs = glob([ + "include/llvm/Frontend/OpenMP/*.td", + "include/llvm/Frontend/Directive/*.td", + ]), +) + +gentbl( + name = "omp_gen", + library = False, + tbl_outs = [ + ("--gen-directive-decl", "include/llvm/Frontend/OpenMP/OMP.h.inc"), + ], + tblgen = ":llvm-tblgen", + td_file = "include/llvm/Frontend/OpenMP/OMP.td", + td_srcs = [":omp_td_files"], +) + +gentbl( + name = "omp_gen_impl", + library = False, + tbl_outs = [ + ("--gen-directive-impl", "include/llvm/Frontend/OpenMP/OMP.inc"), + ], + tblgen = ":llvm-tblgen", + td_file = "include/llvm/Frontend/OpenMP/OMP.td", + td_srcs = [":omp_td_files"], +) + +cc_library( + name = "FrontendOpenMP", + srcs = glob([ + "lib/Frontend/OpenMP/*.cpp", + ]), + hdrs = glob([ + "include/llvm/Frontend/OpenMP/*.h", + "include/llvm/Frontend/OpenMP/OMP/*.h", + "include/llvm/Frontend/*.h", + ]) + [ + "include/llvm/Frontend/OpenMP/OMP.h.inc", + "include/llvm/Frontend/OpenMP/OMP.inc", + ], + copts = llvm_copts, + textual_hdrs = glob([ + "include/llvm/Frontend/OpenMP/*.def", + ]), + deps = [ + ":Analysis", + ":Core", + ":Support", + ":TransformUtils", + ], +) + +filegroup( + name = "acc_td_files", + srcs = glob([ + "include/llvm/Frontend/OpenACC/*.td", + "include/llvm/Frontend/Directive/*.td", + ]), +) + +gentbl( + name = "acc_gen", + library = False, + tbl_outs = [ + ("--gen-directive-decl", "include/llvm/Frontend/OpenACC/ACC.h.inc"), + ], + tblgen = ":llvm-tblgen", + td_file = "include/llvm/Frontend/OpenACC/ACC.td", + td_srcs = [":acc_td_files"], +) + +gentbl( + name = "acc_gen_impl", + library = False, + tbl_outs = [ + ("--gen-directive-impl", "include/llvm/Frontend/OpenACC/ACC.inc"), + ], + tblgen = ":llvm-tblgen", + td_file = "include/llvm/Frontend/OpenACC/ACC.td", + td_srcs = [":acc_td_files"], +) + +cc_library( + name = "FrontendOpenACC", + srcs = glob([ + "lib/Frontend/OpenACC/*.cpp", + ]) + [ + "include/llvm/Frontend/OpenACC/ACC.inc", + ], + hdrs = glob([ + "include/llvm/Frontend/OpenACC/*.h", + ]) + ["include/llvm/Frontend/OpenACC/ACC.h.inc"], + copts = llvm_copts, + deps = [ + ":Analysis", + ":Core", + ":Support", + ":TransformUtils", + ], +) + +cc_library( + name = "AsmParser", + srcs = glob([ + "lib/AsmParser/*.cpp", + "lib/AsmParser/*.h", + ]), + hdrs = glob(["include/llvm/AsmParser/*.h"]), + copts = llvm_copts, + deps = [ + ":BinaryFormat", + ":Core", + ":Support", + ], +) + +cc_library( + name = "IRReader", + srcs = glob([ + "lib/IRReader/*.cpp", + "lib/IRReader/*.h", + ]), + hdrs = glob([ + "include/llvm/IRReader/*.h", + ]) + [ + "include/llvm-c/IRReader.h", + ], + copts = llvm_copts, + deps = [ + ":AsmParser", + ":BitReader", + ":Core", + ":Support", + ":config", + ], +) + +cc_library( + name = "Linker", + srcs = glob([ + "lib/Linker/*.cpp", + "lib/Linker/*.h", + ]), + hdrs = glob([ + "include/llvm/Linker/*.h", + ]) + [ + "include/llvm-c/Linker.h", + ], + copts = llvm_copts, + deps = [ + ":Core", + ":Support", + ":TransformUtils", + ":config", + ], +) + +cc_library( + name = "IPO", + srcs = glob([ + "lib/Transforms/IPO/*.cpp", + "lib/Transforms/IPO/*.h", + ]), + hdrs = glob([ + "include/llvm/Transforms/IPO/*.h", + ]) + [ + "include/llvm-c/Transforms/IPO.h", + "include/llvm-c/Transforms/PassManagerBuilder.h", + "include/llvm/Transforms/IPO.h", + ], + copts = llvm_copts, + deps = [ + ":AggressiveInstCombine", + ":Analysis", + ":BinaryFormat", + ":BitReader", + ":BitWriter", + ":Core", + ":FrontendOpenMP", + ":IRReader", + ":InstCombine", + ":Instrumentation", + ":Linker", + ":ObjCARC", + ":Object", + ":ProfileData", + ":Scalar", + ":Support", + ":Target", + ":TransformUtils", + ":Vectorize", + ":config", + ], +) + +cc_library( + name = "CFGuard", + srcs = glob([ + "lib/Transforms/CFGuard/*.cpp", + "lib/Transforms/CFGuard/*.h", + ]), + hdrs = ["include/llvm/Transforms/CFGuard.h"], + copts = llvm_copts, + deps = [ + ":Core", + ":Support", + ], +) + +cc_library( + name = "Coroutines", + srcs = glob([ + "lib/Transforms/Coroutines/*.cpp", + "lib/Transforms/Coroutines/*.h", + ]), + hdrs = [ + "include/llvm-c/Transforms/Coroutines.h", + "include/llvm/Transforms/Coroutines.h", + "include/llvm/Transforms/Coroutines/CoroCleanup.h", + "include/llvm/Transforms/Coroutines/CoroEarly.h", + "include/llvm/Transforms/Coroutines/CoroElide.h", + "include/llvm/Transforms/Coroutines/CoroSplit.h", + ], + copts = llvm_copts, + deps = [ + ":Analysis", + ":Core", + ":IPO", + ":Scalar", + ":Support", + ":TransformUtils", + ":config", + ], +) + +# Meta-target for clients which depend on all of the transforms libraries. +cc_library( + name = "common_transforms", + deps = [ + ":AggressiveInstCombine", + ":CFGuard", + ":Coroutines", + ":IPO", + ":InstCombine", + ":Instrumentation", + ":ObjCARC", + ":Scalar", + ":Vectorize", + ], +) + +cc_library( + name = "asm_printer_defs", + copts = llvm_copts, + textual_hdrs = glob(["lib/CodeGen/AsmPrinter/*.def"]), +) + +cc_library( + name = "CodeGen", + srcs = glob( + [ + "lib/CodeGen/**/*.cpp", + "lib/CodeGen/**/*.h", + "lib/CodeGen/SelectionDAG/*.cpp", + "lib/CodeGen/SelectionDAG/*.h", + ], + ), + hdrs = [ + "include/llvm/LinkAllPasses.h", + ] + glob( + [ + "include/llvm/CodeGen/**/*.h", + ], + ), + copts = llvm_copts, + textual_hdrs = glob([ + "include/llvm/CodeGen/**/*.def", + "include/llvm/CodeGen/**/*.inc", + ]), + deps = [ + ":Analysis", + ":AsmParser", + ":BinaryFormat", + ":BitReader", + ":BitWriter", + ":Core", + ":DebugInfoCodeView", + ":DebugInfoDWARF", + ":IPO", + ":MC", + ":MCParser", + ":ProfileData", + ":Remarks", + ":Scalar", + ":Support", + ":Target", + ":TransformUtils", + ":asm_printer_defs", + ":config", + ], +) + +cc_library( + name = "MCDisassembler", + srcs = glob([ + "lib/MC/MCDisassembler/*.cpp", + "lib/MC/MCDisassembler/*.h", + ]), + hdrs = glob([ + "include/llvm/MC/MCDisassembler/*.h", + ]) + [ + "include/llvm-c/Disassembler.h", + ], + copts = llvm_copts, + deps = [ + ":MC", + ":Support", + ":config", + ], +) + +llvm_target_lib_list = [lib for lib in [ + { + "name": "AArch64", + "short_name": "AArch64", + "tbl_outs": [ + ("-gen-register-bank", "lib/Target/AArch64/AArch64GenRegisterBank.inc"), + ("-gen-register-info", "lib/Target/AArch64/AArch64GenRegisterInfo.inc"), + ("-gen-instr-info", "lib/Target/AArch64/AArch64GenInstrInfo.inc"), + ("-gen-emitter", "lib/Target/AArch64/AArch64GenMCCodeEmitter.inc"), + ("-gen-pseudo-lowering", "lib/Target/AArch64/AArch64GenMCPseudoLowering.inc"), + ("-gen-asm-writer", "lib/Target/AArch64/AArch64GenAsmWriter.inc"), + ("-gen-asm-writer -asmwriternum=1", "lib/Target/AArch64/AArch64GenAsmWriter1.inc"), + ("-gen-asm-matcher", "lib/Target/AArch64/AArch64GenAsmMatcher.inc"), + ("-gen-dag-isel", "lib/Target/AArch64/AArch64GenDAGISel.inc"), + ("-gen-fast-isel", "lib/Target/AArch64/AArch64GenFastISel.inc"), + ("-gen-global-isel", "lib/Target/AArch64/AArch64GenGlobalISel.inc"), + ("-gen-global-isel-combiner -combiners=AArch64O0PreLegalizerCombinerHelper", "lib/Target/AArch64/AArch64GenO0PreLegalizeGICombiner.inc"), + ("-gen-global-isel-combiner -combiners=AArch64PreLegalizerCombinerHelper", "lib/Target/AArch64/AArch64GenPreLegalizeGICombiner.inc"), + ("-gen-global-isel-combiner -combiners=AArch64PostLegalizerCombinerHelper", "lib/Target/AArch64/AArch64GenPostLegalizeGICombiner.inc"), + ("-gen-global-isel-combiner -combiners=AArch64PostLegalizerLoweringHelper", "lib/Target/AArch64/AArch64GenPostLegalizeGILowering.inc"), + ("-gen-callingconv", "lib/Target/AArch64/AArch64GenCallingConv.inc"), + ("-gen-subtarget", "lib/Target/AArch64/AArch64GenSubtargetInfo.inc"), + ("-gen-disassembler", "lib/Target/AArch64/AArch64GenDisassemblerTables.inc"), + ("-gen-searchable-tables", "lib/Target/AArch64/AArch64GenSystemOperands.inc"), + ], + }, + { + "name": "ARM", + "short_name": "ARM", + "tbl_outs": [ + ("-gen-register-bank", "lib/Target/ARM/ARMGenRegisterBank.inc"), + ("-gen-register-info", "lib/Target/ARM/ARMGenRegisterInfo.inc"), + ("-gen-searchable-tables", "lib/Target/ARM/ARMGenSystemRegister.inc"), + ("-gen-instr-info", "lib/Target/ARM/ARMGenInstrInfo.inc"), + ("-gen-emitter", "lib/Target/ARM/ARMGenMCCodeEmitter.inc"), + ("-gen-pseudo-lowering", "lib/Target/ARM/ARMGenMCPseudoLowering.inc"), + ("-gen-asm-writer", "lib/Target/ARM/ARMGenAsmWriter.inc"), + ("-gen-asm-matcher", "lib/Target/ARM/ARMGenAsmMatcher.inc"), + ("-gen-dag-isel", "lib/Target/ARM/ARMGenDAGISel.inc"), + ("-gen-fast-isel", "lib/Target/ARM/ARMGenFastISel.inc"), + ("-gen-global-isel", "lib/Target/ARM/ARMGenGlobalISel.inc"), + ("-gen-callingconv", "lib/Target/ARM/ARMGenCallingConv.inc"), + ("-gen-subtarget", "lib/Target/ARM/ARMGenSubtargetInfo.inc"), + ("-gen-disassembler", "lib/Target/ARM/ARMGenDisassemblerTables.inc"), + ], + }, + { + "name": "AMDGPU", + "short_name": "AMDGPU", + "tbl_outs": [ + ("-gen-register-bank", "lib/Target/AMDGPU/AMDGPUGenRegisterBank.inc"), + ("-gen-register-info", "lib/Target/AMDGPU/AMDGPUGenRegisterInfo.inc"), + ("-gen-instr-info", "lib/Target/AMDGPU/AMDGPUGenInstrInfo.inc"), + ("-gen-emitter", "lib/Target/AMDGPU/AMDGPUGenMCCodeEmitter.inc"), + ("-gen-pseudo-lowering", "lib/Target/AMDGPU/AMDGPUGenMCPseudoLowering.inc"), + ("-gen-asm-writer", "lib/Target/AMDGPU/AMDGPUGenAsmWriter.inc"), + ("-gen-asm-matcher", "lib/Target/AMDGPU/AMDGPUGenAsmMatcher.inc"), + ("-gen-dag-isel", "lib/Target/AMDGPU/AMDGPUGenDAGISel.inc"), + ("-gen-callingconv", "lib/Target/AMDGPU/AMDGPUGenCallingConv.inc"), + ("-gen-subtarget", "lib/Target/AMDGPU/AMDGPUGenSubtargetInfo.inc"), + ("-gen-disassembler", "lib/Target/AMDGPU/AMDGPUGenDisassemblerTables.inc"), + ("-gen-searchable-tables", "lib/Target/AMDGPU/AMDGPUGenSearchableTables.inc"), + ], + "tbl_deps": [ + ":amdgpu_isel_target_gen", + ":r600_target_gen", + ], + }, + { + "name": "BPF", + "short_name": "BPF", + "tbl_outs": [ + ("-gen-asm-writer", "lib/Target/BPF/BPFGenAsmWriter.inc"), + ("-gen-asm-matcher", "lib/Target/BPF/BPFGenAsmMatcher.inc"), + ("-gen-callingconv", "lib/Target/BPF/BPFGenCallingConv.inc"), + ("-gen-dag-isel", "lib/Target/BPF/BPFGenDAGISel.inc"), + ("-gen-disassembler", "lib/Target/BPF/BPFGenDisassemblerTables.inc"), + ("-gen-emitter", "lib/Target/BPF/BPFGenMCCodeEmitter.inc"), + ("-gen-instr-info", "lib/Target/BPF/BPFGenInstrInfo.inc"), + ("-gen-register-info", "lib/Target/BPF/BPFGenRegisterInfo.inc"), + ("-gen-subtarget", "lib/Target/BPF/BPFGenSubtargetInfo.inc"), + ], + }, + { + "name": "Hexagon", + "short_name": "Hexagon", + "tbl_outs": [ + ("-gen-asm-matcher", "lib/Target/Hexagon/HexagonGenAsmMatcher.inc"), + ("-gen-asm-writer", "lib/Target/Hexagon/HexagonGenAsmWriter.inc"), + ("-gen-callingconv", "lib/Target/Hexagon/HexagonGenCallingConv.inc"), + ("-gen-dag-isel", "lib/Target/Hexagon/HexagonGenDAGISel.inc"), + ("-gen-dfa-packetizer", "lib/Target/Hexagon/HexagonGenDFAPacketizer.inc"), + ("-gen-disassembler", "lib/Target/Hexagon/HexagonGenDisassemblerTables.inc"), + ("-gen-instr-info", "lib/Target/Hexagon/HexagonGenInstrInfo.inc"), + ("-gen-emitter", "lib/Target/Hexagon/HexagonGenMCCodeEmitter.inc"), + ("-gen-register-info", "lib/Target/Hexagon/HexagonGenRegisterInfo.inc"), + ("-gen-subtarget", "lib/Target/Hexagon/HexagonGenSubtargetInfo.inc"), + ], + }, + { + "name": "Lanai", + "short_name": "Lanai", + "tbl_outs": [ + ("-gen-asm-matcher", "lib/Target/Lanai/LanaiGenAsmMatcher.inc"), + ("-gen-asm-writer", "lib/Target/Lanai/LanaiGenAsmWriter.inc"), + ("-gen-callingconv", "lib/Target/Lanai/LanaiGenCallingConv.inc"), + ("-gen-dag-isel", "lib/Target/Lanai/LanaiGenDAGISel.inc"), + ("-gen-disassembler", "lib/Target/Lanai/LanaiGenDisassemblerTables.inc"), + ("-gen-emitter", "lib/Target/Lanai/LanaiGenMCCodeEmitter.inc"), + ("-gen-instr-info", "lib/Target/Lanai/LanaiGenInstrInfo.inc"), + ("-gen-register-info", "lib/Target/Lanai/LanaiGenRegisterInfo.inc"), + ("-gen-subtarget", "lib/Target/Lanai/LanaiGenSubtargetInfo.inc"), + ], + }, + { + "name": "NVPTX", + "short_name": "NVPTX", + "tbl_outs": [ + ("-gen-register-info", "lib/Target/NVPTX/NVPTXGenRegisterInfo.inc"), + ("-gen-instr-info", "lib/Target/NVPTX/NVPTXGenInstrInfo.inc"), + ("-gen-asm-writer", "lib/Target/NVPTX/NVPTXGenAsmWriter.inc"), + ("-gen-dag-isel", "lib/Target/NVPTX/NVPTXGenDAGISel.inc"), + ("-gen-subtarget", "lib/Target/NVPTX/NVPTXGenSubtargetInfo.inc"), + ], + }, + { + "name": "PowerPC", + "short_name": "PPC", + "tbl_outs": [ + ("-gen-asm-writer", "lib/Target/PowerPC/PPCGenAsmWriter.inc"), + ("-gen-asm-matcher", "lib/Target/PowerPC/PPCGenAsmMatcher.inc"), + ("-gen-emitter", "lib/Target/PowerPC/PPCGenMCCodeEmitter.inc"), + ("-gen-register-info", "lib/Target/PowerPC/PPCGenRegisterInfo.inc"), + ("-gen-instr-info", "lib/Target/PowerPC/PPCGenInstrInfo.inc"), + ("-gen-dag-isel", "lib/Target/PowerPC/PPCGenDAGISel.inc"), + ("-gen-fast-isel", "lib/Target/PowerPC/PPCGenFastISel.inc"), + ("-gen-callingconv", "lib/Target/PowerPC/PPCGenCallingConv.inc"), + ("-gen-subtarget", "lib/Target/PowerPC/PPCGenSubtargetInfo.inc"), + ("-gen-disassembler", "lib/Target/PowerPC/PPCGenDisassemblerTables.inc"), + ("-gen-register-bank", "lib/Target/PowerPC/PPCGenRegisterBank.inc"), + ("-gen-global-isel", "lib/Target/PowerPC/PPCGenGlobalISel.inc"), + ], + }, + { + "name": "Sparc", + "short_name": "Sparc", + "tbl_outs": [ + ("-gen-asm-writer", "lib/Target/Sparc/SparcGenAsmWriter.inc"), + ("-gen-asm-matcher", "lib/Target/Sparc/SparcGenAsmMatcher.inc"), + ("-gen-emitter", "lib/Target/Sparc/SparcGenMCCodeEmitter.inc"), + ("-gen-register-info", "lib/Target/Sparc/SparcGenRegisterInfo.inc"), + ("-gen-instr-info", "lib/Target/Sparc/SparcGenInstrInfo.inc"), + ("-gen-dag-isel", "lib/Target/Sparc/SparcGenDAGISel.inc"), + ("-gen-callingconv", "lib/Target/Sparc/SparcGenCallingConv.inc"), + ("-gen-subtarget", "lib/Target/Sparc/SparcGenSubtargetInfo.inc"), + ("-gen-disassembler", "lib/Target/Sparc/SparcGenDisassemblerTables.inc"), + ], + }, + { + "name": "RISCV", + "short_name": "RISCV", + "tbl_outs": [ + ("-gen-asm-matcher", "lib/Target/RISCV/RISCVGenAsmMatcher.inc"), + ("-gen-asm-writer", "lib/Target/RISCV/RISCVGenAsmWriter.inc"), + ("-gen-compress-inst-emitter", "lib/Target/RISCV/RISCVGenCompressInstEmitter.inc"), + ("-gen-dag-isel", "lib/Target/RISCV/RISCVGenDAGISel.inc"), + ("-gen-disassembler", "lib/Target/RISCV/RISCVGenDisassemblerTables.inc"), + ("-gen-global-isel", "lib/Target/RISCV/RISCVGenGlobalISel.inc"), + ("-gen-instr-info", "lib/Target/RISCV/RISCVGenInstrInfo.inc"), + ("-gen-emitter", "lib/Target/RISCV/RISCVGenMCCodeEmitter.inc"), + ("-gen-pseudo-lowering", "lib/Target/RISCV/RISCVGenMCPseudoLowering.inc"), + ("-gen-register-bank", "lib/Target/RISCV/RISCVGenRegisterBank.inc"), + ("-gen-register-info", "lib/Target/RISCV/RISCVGenRegisterInfo.inc"), + ("-gen-subtarget", "lib/Target/RISCV/RISCVGenSubtargetInfo.inc"), + ("-gen-searchable-tables", "lib/Target/RISCV/RISCVGenSearchableTables.inc"), + ], + }, + { + "name": "WebAssembly", + "short_name": "WebAssembly", + "tbl_outs": [ + ("-gen-disassembler", "lib/Target/WebAssembly/WebAssemblyGenDisassemblerTables.inc"), + ("-gen-asm-writer", "lib/Target/WebAssembly/WebAssemblyGenAsmWriter.inc"), + ("-gen-instr-info", "lib/Target/WebAssembly/WebAssemblyGenInstrInfo.inc"), + ("-gen-dag-isel", "lib/Target/WebAssembly/WebAssemblyGenDAGISel.inc"), + ("-gen-fast-isel", "lib/Target/WebAssembly/WebAssemblyGenFastISel.inc"), + ("-gen-emitter", "lib/Target/WebAssembly/WebAssemblyGenMCCodeEmitter.inc"), + ("-gen-register-info", "lib/Target/WebAssembly/WebAssemblyGenRegisterInfo.inc"), + ("-gen-subtarget", "lib/Target/WebAssembly/WebAssemblyGenSubtargetInfo.inc"), + ("-gen-asm-matcher", "lib/Target/WebAssembly/WebAssemblyGenAsmMatcher.inc"), + ], + }, + { + "name": "X86", + "short_name": "X86", + "tbl_outs": [ + ("-gen-register-bank", "lib/Target/X86/X86GenRegisterBank.inc"), + ("-gen-register-info", "lib/Target/X86/X86GenRegisterInfo.inc"), + ("-gen-disassembler", "lib/Target/X86/X86GenDisassemblerTables.inc"), + ("-gen-instr-info", "lib/Target/X86/X86GenInstrInfo.inc"), + ("-gen-asm-writer", "lib/Target/X86/X86GenAsmWriter.inc"), + ("-gen-asm-writer -asmwriternum=1", "lib/Target/X86/X86GenAsmWriter1.inc"), + ("-gen-asm-matcher", "lib/Target/X86/X86GenAsmMatcher.inc"), + ("-gen-dag-isel", "lib/Target/X86/X86GenDAGISel.inc"), + ("-gen-fast-isel", "lib/Target/X86/X86GenFastISel.inc"), + ("-gen-global-isel", "lib/Target/X86/X86GenGlobalISel.inc"), + ("-gen-callingconv", "lib/Target/X86/X86GenCallingConv.inc"), + ("-gen-subtarget", "lib/Target/X86/X86GenSubtargetInfo.inc"), + ("-gen-x86-EVEX2VEX-tables", "lib/Target/X86/X86GenEVEX2VEXTables.inc"), + ("-gen-exegesis", "lib/Target/X86/X86GenExegesis.inc"), + ], + }, +] if lib["name"] in llvm_targets] + +cc_library( + name = "x86_target_layering_problem_hdrs", + textual_hdrs = ["lib/Target/X86/X86InstrInfo.h"], +) + +filegroup( + name = "common_target_td_sources", + srcs = glob([ + "include/llvm/CodeGen/*.td", + "include/llvm/Frontend/Directive/*.td", + "include/llvm/IR/Intrinsics*.td", + "include/llvm/TableGen/*.td", + "include/llvm/Target/*.td", + "include/llvm/Target/GlobalISel/*.td", + ]), +) + +gentbl( + name = "amdgpu_isel_target_gen", + strip_include_prefix = "lib/Target/AMDGPU", + tbl_outs = [ + ("-gen-global-isel", "lib/Target/AMDGPU/AMDGPUGenGlobalISel.inc"), + ("-gen-global-isel-combiner -combiners=AMDGPUPreLegalizerCombinerHelper", "lib/Target/AMDGPU/AMDGPUGenPreLegalizeGICombiner.inc"), + ("-gen-global-isel-combiner -combiners=AMDGPUPostLegalizerCombinerHelper", "lib/Target/AMDGPU/AMDGPUGenPostLegalizeGICombiner.inc"), + ("-gen-global-isel-combiner -combiners=AMDGPURegBankCombinerHelper", "lib/Target/AMDGPU/AMDGPUGenRegBankGICombiner.inc"), + ], + tblgen = ":llvm-tblgen", + td_file = "lib/Target/AMDGPU/AMDGPUGISel.td", + td_srcs = [ + ":common_target_td_sources", + ] + glob([ + "lib/Target/AMDGPU/*.td", + ]), +) + +gentbl( + name = "r600_target_gen", + strip_include_prefix = "lib/Target/AMDGPU", + tbl_outs = [ + ("-gen-asm-writer", "lib/Target/AMDGPU/R600GenAsmWriter.inc"), + ("-gen-callingconv", "lib/Target/AMDGPU/R600GenCallingConv.inc"), + ("-gen-dag-isel", "lib/Target/AMDGPU/R600GenDAGISel.inc"), + ("-gen-dfa-packetizer", "lib/Target/AMDGPU/R600GenDFAPacketizer.inc"), + ("-gen-instr-info", "lib/Target/AMDGPU/R600GenInstrInfo.inc"), + ("-gen-emitter", "lib/Target/AMDGPU/R600GenMCCodeEmitter.inc"), + ("-gen-register-info", "lib/Target/AMDGPU/R600GenRegisterInfo.inc"), + ("-gen-subtarget", "lib/Target/AMDGPU/R600GenSubtargetInfo.inc"), + ], + tblgen = ":llvm-tblgen", + td_file = "lib/Target/AMDGPU/R600.td", + td_srcs = [ + ":common_target_td_sources", + ] + glob([ + "lib/Target/AMDGPU/*.td", + ]), +) + +[[ + [gentbl( + name = target["name"] + "CommonTableGen", + strip_include_prefix = "lib/Target/" + target["name"], + tbl_outs = target["tbl_outs"], + tblgen = ":llvm-tblgen", + # MSVC isn't happy with long string literals, while other compilers + # which support them get significant compile time improvements with + # them enabled. Ideally this flag would only be enabled on Windows via + # a select() on `@bazel_tools//src/conditions:windows,`, but that would + # require refactoring gentbl from a macro into a rule. + # TODO(#92): Refactor gentbl to support this use + tblgen_args = "--long-string-literals=0", + td_file = "lib/Target/" + target["name"] + "/" + target["short_name"] + ".td", + td_srcs = [ + ":common_target_td_sources", + ] + glob([ + "lib/Target/" + target["name"] + "/*.td", + "lib/Target/" + target["name"] + "/GISel/*.td", + ]), + deps = target.get("tbl_deps", []), + )], + [cc_library( + name = target["name"] + "Info", + srcs = ["lib/Target/" + target["name"] + "/TargetInfo/" + target["name"] + "TargetInfo.cpp"], + hdrs = glob(["lib/Target/" + target["name"] + "/TargetInfo/*.h"]), + copts = llvm_copts, + # Workaround for https://github.com/bazelbuild/bazel/issues/3828 + # TODO(gcmn): Remove this when upgrading to a Bazel version containing + # https://github.com/bazelbuild/bazel/commit/e3b7e17b05f1 + includes = ["lib/Target/" + target["name"]], + strip_include_prefix = "lib/Target/" + target["name"], + deps = [ + ":" + target["name"] + "CommonTableGen", + ":Support", + ":Target", + ], + )], + # We cannot separate the `Utils` and `MCTargetDesc` sublibraries of + # a number of targets due to crisscrossing inclusion of headers. + [cc_library( + name = target["name"] + "UtilsAndDesc", + srcs = glob([ + "lib/Target/" + target["name"] + "/MCTargetDesc/*.cpp", + "lib/Target/" + target["name"] + "/Utils/*.cpp", + + # We have to include these headers here as well as in the `hdrs` + # below to allow the `.cpp` files to use file-relative-inclusion to + # find them, even though consumers of this library use inclusion + # relative to the target with the `strip_includes_prefix` of this + # library. This mixture is likely incompatible with header modules. + "lib/Target/" + target["name"] + "/MCTargetDesc/*.h", + "lib/Target/" + target["name"] + "/Utils/*.h", + ]), + hdrs = glob([ + "lib/Target/" + target["name"] + "/MCTargetDesc/*.h", + "lib/Target/" + target["name"] + "/Utils/*.h", + + # This a bit of a hack to allow us to expose common, internal + # target header files to other libraries within the target via + # target-relative includes. This usage of headers is inherently + # non-modular as there is a mixture of target-relative inclusion + # using this rule and file-relative inclusion using the repeated + # listing of these headers in the `srcs` of subsequent rules. + "lib/Target/" + target["name"] + "/*.h", + + # FIXME: The entries below should be `textual_hdrs` instead of + # `hdrs`, but unfortunately that doesn't work with + # `strip_include_prefix`: + # https://github.com/bazelbuild/bazel/issues/12424 + # + # Once that issue is fixed and released, we can switch this to + # `textual_hdrs` and remove the feature disabling the various Bazel + # features (both current and under-development) that motivated the + # distinction between these two. + "lib/Target/" + target["name"] + "/*.def", + "lib/Target/" + target["name"] + "/*.inc", + ]), + copts = llvm_copts, + features = [ + "-parse_headers", + "-header_modules", + ], + strip_include_prefix = "lib/Target/" + target["name"], + deps = [ + ":BinaryFormat", + # Depending on `:CodeGen` headers in this library is almost + # certainly a layering problem in numerous targets. + ":CodeGen", + ":DebugInfoCodeView", + ":MC", + ":MCDisassembler", + ":Support", + ":Target", + ":config", + ":" + target["name"] + "CommonTableGen", + ":" + target["name"] + "Info", + ], + )], + [cc_library( + name = target["name"] + "CodeGen", + srcs = glob([ + "lib/Target/" + target["name"] + "/GISel/*.cpp", + "lib/Target/" + target["name"] + "/GISel/*.h", + "lib/Target/" + target["name"] + "/*.cpp", + "lib/Target/" + target["name"] + "/*.h", + ]), + hdrs = ["lib/Target/" + target["name"] + "/" + target["short_name"] + ".h"], + copts = llvm_copts, + strip_include_prefix = "lib/Target/" + target["name"], + textual_hdrs = glob([ + "lib/Target/" + target["name"] + "/*.def", + "lib/Target/" + target["name"] + "/*.inc", + ]), + deps = [ + ":Analysis", + ":BinaryFormat", + ":CFGuard", + ":CodeGen", + ":Core", + ":IPO", + ":MC", + ":Passes", # TODO(chandlerc): Likely a layering violation. + ":ProfileData", + ":Scalar", + ":Support", + ":Target", + ":TransformUtils", + ":Vectorize", + ":config", + ":" + target["name"] + "CommonTableGen", + ":" + target["name"] + "Info", + ":" + target["name"] + "UtilsAndDesc", + ], + )], + [cc_library( + name = target["name"] + "AsmParser", + srcs = glob([ + "lib/Target/" + target["name"] + "/AsmParser/*.cpp", + "lib/Target/" + target["name"] + "/AsmParser/*.h", + ]), + copts = llvm_copts, + deps = [ + ":BinaryFormat", + ":MC", + ":MCParser", + ":Support", + ":Target", + ":" + target["name"] + "CodeGen", + ":" + target["name"] + "CommonTableGen", + ":" + target["name"] + "UtilsAndDesc", + ], + )], + # This target is a bit of a hack to allow us to expose internal + # disassembler header files via internal target-relative include paths. + # This usage of headers is inherently non-modular as there is a mixture of + # target-relative inclusion using this rule and same-directory inclusion + # using the repeated listing of these headers in the `srcs` below. + [cc_library( + name = target["name"] + "DisassemblerInternalHeaders", + # FIXME: This should be `textual_hdrs` instead of `hdrs`, but + # unfortunately that doesn't work with `strip_include_prefix`: + # https://github.com/bazelbuild/bazel/issues/12424 + # + # Once that issue is fixed and released, we can switch this to + # `textual_hdrs` and remove the feature disabling the various Bazel + # features (both current and under-development) that motivated the + # distinction between these two. + hdrs = glob([ + "lib/Target/" + target["name"] + "/Disassembler/*.h", + ]), + features = [ + "-parse_headers", + "-header_modules", + ], + strip_include_prefix = "lib/Target/" + target["name"], + )], + [cc_library( + name = target["name"] + "Disassembler", + srcs = glob([ + "lib/Target/" + target["name"] + "/Disassembler/*.cpp", + "lib/Target/" + target["name"] + "/Disassembler/*.c", + "lib/Target/" + target["name"] + "/Disassembler/*.h", + ]), + copts = llvm_copts, + deps = [ + ":CodeGen", + ":Core", + ":MC", + ":MCDisassembler", + ":Support", + ":Target", + ":" + target["name"] + "CodeGen", + ":" + target["name"] + "DisassemblerInternalHeaders", + ":" + target["name"] + "CommonTableGen", + ":" + target["name"] + "UtilsAndDesc", + ], + )], +] for target in llvm_target_lib_list] + +cc_library( + name = "AllTargetsCodeGens", + copts = llvm_copts, + deps = [ + target["name"] + "CodeGen" + for target in llvm_target_lib_list + ], +) + +cc_library( + name = "AllTargetsAsmParsers", + copts = llvm_copts, + deps = [ + target["name"] + "AsmParser" + for target in llvm_target_lib_list + ], +) + +cc_library( + name = "AllTargetsDisassemblers", + copts = llvm_copts, + deps = [ + target["name"] + "Disassembler" + for target in llvm_target_lib_list + ], +) + +cc_library( + name = "pass_registry_def", + copts = llvm_copts, + textual_hdrs = ["lib/Passes/PassRegistry.def"], +) + +cc_library( + name = "MLPolicies", + srcs = glob([ + "lib/Analysis/ML/*.cpp", + "lib/Analysis/ML/*.h", + ]), + hdrs = glob([ + "include/llvm/Analysis/ML/*.h", + ]), + copts = llvm_copts, + deps = [ + ":Analysis", + ":Core", + ":Support", + ], +) + +cc_library( + name = "Passes", + srcs = glob([ + "lib/Passes/*.cpp", + "lib/Passes/*.h", + ]), + hdrs = glob(["include/llvm/Passes/*.h"]) + ["include/llvm-c/Transforms/PassBuilder.h"], + copts = llvm_copts, + deps = [ + ":Analysis", + ":CodeGen", + ":Core", + ":Coroutines", + ":MLPolicies", + ":Support", + ":Target", + ":TransformUtils", + ":common_transforms", + ":config", + ":pass_registry_def", + ], +) + +cc_library( + name = "LTO", + srcs = glob([ + "lib/LTO/*.cpp", + "lib/LTO/*.h", + ]), + hdrs = glob([ + "include/llvm/LTO/*.h", + "include/llvm/LTO/legacy/*.h", + ]) + [ + "include/llvm-c/lto.h", + ], + copts = llvm_copts, + deps = [ + ":Analysis", + ":BitReader", + ":BitWriter", + ":CodeGen", + ":Core", + ":IRReader", + ":Linker", + ":MC", + ":MCParser", + ":Object", + ":Passes", + ":Support", + ":Target", + ":TransformUtils", + ":common_transforms", + ":config", + ], +) + +cc_library( + name = "ExecutionEngine", + srcs = glob([ + "lib/ExecutionEngine/*.cpp", + "lib/ExecutionEngine/*.h", + "lib/ExecutionEngine/RuntimeDyld/*.cpp", + "lib/ExecutionEngine/RuntimeDyld/*.h", + "lib/ExecutionEngine/RuntimeDyld/Targets/*.cpp", + "lib/ExecutionEngine/RuntimeDyld/Targets/*.h", + ]), + hdrs = glob( + [ + "include/llvm/ExecutionEngine/*.h", + ], + exclude = [ + "include/llvm/ExecutionEngine/MCJIT*.h", + "include/llvm/ExecutionEngine/OProfileWrapper.h", + ], + ) + [ + "include/llvm-c/ExecutionEngine.h", + ], + copts = llvm_copts, + deps = [ + ":BinaryFormat", + ":CodeGen", + ":Core", + ":DebugInfo", + ":MC", + ":MCDisassembler", + ":Object", + ":OrcTargetProcess", + ":Passes", + ":Support", + ":Target", + ":config", + ], +) + +cc_library( + name = "Interpreter", + srcs = glob([ + "lib/ExecutionEngine/Interpreter/*.cpp", + "lib/ExecutionEngine/Interpreter/*.h", + ]), + hdrs = ["include/llvm/ExecutionEngine/Interpreter.h"], + copts = llvm_copts, + deps = [ + ":CodeGen", + ":Core", + ":ExecutionEngine", + ":Support", + ":Target", + ":config", + ], +) + +cc_library( + name = "JITLink", + srcs = glob([ + "lib/ExecutionEngine/JITLink/*.cpp", + "lib/ExecutionEngine/JITLink/*.h", + ]), + hdrs = glob([ + "include/llvm/ExecutionEngine/JITLink/*.h", + ]), + copts = llvm_copts, + deps = [ + ":ExecutionEngine", + ":Object", + ":OrcTargetProcess", + ":Support", + ":config", + ], +) + +cc_library( + name = "MCJIT", + srcs = glob([ + "lib/ExecutionEngine/MCJIT/*.cpp", + "lib/ExecutionEngine/MCJIT/*.h", + ]), + hdrs = glob(["include/llvm/ExecutionEngine/MCJIT*.h"]), + copts = llvm_copts, + deps = [ + ":CodeGen", + ":Core", + ":ExecutionEngine", + ":MC", + ":Object", + ":Support", + ":Target", + ":config", + ], +) + +cc_library( + name = "OrcJIT", + srcs = glob([ + "lib/ExecutionEngine/Orc/*.cpp", + "lib/ExecutionEngine/Orc/*.h", + ]), + hdrs = glob([ + "include/llvm/ExecutionEngine/Orc/*.h", + "include/llvm/ExecutionEngine/Orc/RPC/*.h", + ]) + [ + "include/llvm-c/LLJIT.h", + "include/llvm-c/Orc.h", + "include/llvm-c/OrcEE.h", + ], + copts = llvm_copts, + deps = [ + ":BitReader", + ":BitWriter", + ":Core", + ":ExecutionEngine", + ":JITLink", + ":MC", + ":Object", + ":OrcShared", + ":OrcTargetProcess", + ":Support", + ":Target", + ":TransformUtils", + ":config", + ], +) + +cc_library( + name = "OrcShared", + srcs = glob([ + "lib/ExecutionEngine/Orc/Shared/*.cpp", + ]), + hdrs = glob([ + "include/llvm/ExecutionEngine/Orc/Shared/*.h", + ]), + copts = llvm_copts, + deps = [ + ":BinaryFormat", + ":CodeGen", + ":Core", + ":DebugInfo", + ":MC", + ":MCDisassembler", + ":Object", + ":Passes", + ":Support", + ":Target", + ":config", + ], +) + +cc_library( + name = "OrcTargetProcess", + srcs = glob([ + "lib/ExecutionEngine/Orc/TargetProcess/*.cpp", + ]), + hdrs = glob([ + "include/llvm/ExecutionEngine/Orc/TargetProcess/*.h", + ]), + copts = llvm_copts, + deps = [ + ":BinaryFormat", + ":CodeGen", + ":Core", + ":DebugInfo", + ":MC", + ":MCDisassembler", + ":Object", + ":OrcShared", + ":Passes", + ":Support", + ":Target", + ":config", + ], +) + +cc_library( + name = "DWARFLinker", + srcs = glob([ + "lib/DWARFLinker/*.cpp", + "lib/DWARFLinker/*.h", + ]), + hdrs = glob(["include/llvm/DWARFLinker/*.h"]), + copts = llvm_copts, + deps = [ + ":CodeGen", + ":DebugInfoDWARF", + ":Support", + ], +) + +gentbl( + name = "DllOptionsTableGen", + strip_include_prefix = "lib/ToolDrivers/llvm-dlltool", + tbl_outs = [( + "-gen-opt-parser-defs", + "lib/ToolDrivers/llvm-dlltool/Options.inc", + )], + tblgen = ":llvm-tblgen", + td_file = "lib/ToolDrivers/llvm-dlltool/Options.td", + td_srcs = ["include/llvm/Option/OptParser.td"], +) + +cc_library( + name = "DlltoolDriver", + srcs = glob(["lib/ToolDrivers/llvm-dlltool/*.cpp"]), + hdrs = glob(["include/llvm/ToolDrivers/llvm-dlltool/*.h"]), + copts = llvm_copts, + deps = [ + ":DllOptionsTableGen", + ":Object", + ":Option", + ":Support", + ], +) + +gentbl( + name = "LibOptionsTableGen", + strip_include_prefix = "lib/ToolDrivers/llvm-lib", + tbl_outs = [( + "-gen-opt-parser-defs", + "lib/ToolDrivers/llvm-lib/Options.inc", + )], + tblgen = ":llvm-tblgen", + td_file = "lib/ToolDrivers/llvm-lib/Options.td", + td_srcs = ["include/llvm/Option/OptParser.td"], +) + +cc_library( + name = "LibDriver", + srcs = glob(["lib/ToolDrivers/llvm-lib/*.cpp"]), + hdrs = glob(["include/llvm/ToolDrivers/llvm-lib/*.h"]), + copts = llvm_copts, + deps = [ + ":BinaryFormat", + ":LibOptionsTableGen", + ":Object", + ":Option", + ":Support", + ], +) + +cc_library( + name = "InterfaceStub", + srcs = glob([ + "lib/InterfaceStub/*.cpp", + "lib/InterfaceStub/*.h", + ]), + hdrs = glob([ + "include/llvm/InterfaceStub/*.h", + ]), + copts = llvm_copts, + deps = [ + ":Object", + ":Support", + ":config", + ], +) + +cc_library( + name = "WindowsManifest", + srcs = glob([ + "lib/WindowsManifest/*.cpp", + ]), + hdrs = glob([ + "include/llvm/WindowsManifest/*.h", + ]), + copts = llvm_copts, + linkopts = [ + # Libxml2 is required to process Windows manifests. Without this, + # lld uses Microsoft mt.exe instead, which is not cross-platform. + "-lxml2", + ], + tags = [ + "manual", # External dependency (libxml) + "nobuildkite", # TODO(gcmn): Fix remote execution and re-enable + ], + deps = [ + ":Support", + ":config", + ], +) + +# FIXME: This library should use `textual_hdrs` instead of `hdrs` as we don't +# want to parse or build modules for them (and haven't duplicated the necessary +# dependencies), but unfortunately that doesn't work with +# `strip_include_prefix`: https://github.com/bazelbuild/bazel/issues/12424 +# +# For now, we simply disable features that might rely on the headers parsing. +cc_library( + name = "llvm-objcopy-headers", + hdrs = glob(["tools/llvm-objcopy/**/*.h"]), + features = [ + "-parse_headers", + "-header_modules", + ], + strip_include_prefix = "tools/llvm-objcopy", +) + +cc_library( + name = "MCA", + srcs = glob([ + "lib/MCA/**/*.cpp", + "lib/MCA/**/*.h", + ]), + hdrs = glob([ + "include/llvm/MCA/**/*.h", + ]), + copts = llvm_copts, + deps = [ + ":MC", + ":MCDisassembler", + ":Object", + ":Support", + ], +) + +cc_library( + name = "llvm-mca-headers", + hdrs = glob([ + "tools/llvm-mca/*.h", + "tools/llvm-mca/Views/*.h", + ]), + strip_include_prefix = "tools/llvm-mca", +) + +cc_library( + name = "XRay", + srcs = glob([ + "lib/XRay/*.cpp", + "lib/XRay/*.h", + ]), + hdrs = glob(["include/llvm/XRay/*.h"]), + copts = llvm_copts, + deps = [ + ":Object", + ":Support", + ], +) + +cc_library( + name = "Exegesis", + srcs = glob([ + "tools/llvm-exegesis/lib/*.cpp", + "tools/llvm-exegesis/lib/X86/*.cpp", + "tools/llvm-exegesis/lib/X86/*.h", + + # We have to include these headers here as well as in the `hdrs` below + # to allow the `.cpp` files to use file-relative-inclusion to find + # them, even though consumers of this library use inclusion relative to + # `tools/llvm-exegesis/lib` with the `strip_includes_prefix` of this + # library. This mixture appears to be incompatible with header modules. + "tools/llvm-exegesis/lib/*.h", + ]), + hdrs = glob(["tools/llvm-exegesis/lib/*.h"]), + copts = llvm_copts + ["-DHAVE_LIBPFM=1"], + defines = ["LLVM_EXEGESIS_INITIALIZE_NATIVE_TARGET=InitializeX86ExegesisTarget"], + features = ["-header_modules"], + strip_include_prefix = "tools/llvm-exegesis/lib", + tags = [ + "manual", # External dependency (libpfm4) + "nobuildkite", # TODO(chandlerc): Add support for fetching and building libpfm4 and enable this. + ], + deps = [ + ":AllTargetsAsmParsers", + ":AllTargetsCodeGens", + ":CodeGen", + ":Core", + ":ExecutionEngine", + ":MC", + ":MCDisassembler", + ":MCJIT", + ":Object", + ":ObjectYAML", + ":Support", + ":Target", + ":config", + ], +) + +################################################################################ +# LLVM toolchain and development binaries + +gentbl( + name = "DsymutilTableGen", + strip_include_prefix = "tools/dsymutil", + tbl_outs = [( + "-gen-opt-parser-defs", + "tools/dsymutil/Options.inc", + )], + tblgen = ":llvm-tblgen", + td_file = "tools/dsymutil/Options.td", + td_srcs = ["include/llvm/Option/OptParser.td"], +) + +cc_binary( + name = "dsymutil", + srcs = glob([ + "tools/dsymutil/*.cpp", + "tools/dsymutil/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":AllTargetsCodeGens", + ":BinaryFormat", + ":CodeGen", + ":DWARFLinker", + ":DebugInfo", + ":DebugInfoDWARF", + ":DsymutilTableGen", + ":MC", + ":Object", + ":Option", + ":Support", + ":Target", + ":config", + ":remark_linker", + ], +) + +cc_binary( + name = "llc", + srcs = glob([ + "tools/llc/*.cpp", + "tools/llc/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":AllTargetsAsmParsers", + ":AllTargetsCodeGens", + ":Analysis", + ":AsmParser", + ":BitReader", + ":CodeGen", + ":Core", + ":IRReader", + ":MC", + ":Support", + ":Target", + ":TransformUtils", + ], +) + +cc_binary( + name = "lli", + srcs = glob([ + "tools/lli/*.cpp", + "tools/lli/*.h", + ]), + copts = llvm_copts, + # ll scripts rely on symbols from dependent + # libraries being resolvable. + linkopts = select({ + "@bazel_tools//src/conditions:windows": [], + "@bazel_tools//src/conditions:darwin": [], + "//conditions:default": [ + "-Wl,--undefined=_ZTIi", + "-Wl,--export-dynamic-symbol=_ZTIi", + "-Wl,--export-dynamic-symbol=__cxa_begin_catch", + "-Wl,--export-dynamic-symbol=__cxa_end_catch", + "-Wl,--export-dynamic-symbol=__gxx_personality_v0", + "-Wl,--export-dynamic-symbol=__cxa_allocate_exception", + "-Wl,--export-dynamic-symbol=__cxa_throw", + "-Wl,--export-dynamic-symbol=llvm_orc_registerJITLoaderGDBWrapper", + "-Wl,--export-dynamic-symbol=llvm_orc_registerEHFrameSectionWrapper", + "-Wl,--export-dynamic-symbol=llvm_orc_deregisterEHFrameSectionWrapper", + ], + }), + stamp = 0, + deps = [ + ":AllTargetsAsmParsers", + ":AllTargetsCodeGens", + ":AsmParser", + ":BitReader", + ":CodeGen", + ":Core", + ":ExecutionEngine", + ":IRReader", + ":Instrumentation", + ":Interpreter", + ":MCJIT", + ":Object", + ":OrcJIT", + ":Support", + ":config", + ], +) + +cc_binary( + name = "llvm-ar", + srcs = glob([ + "tools/llvm-ar/*.cpp", + "tools/llvm-ar/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":AllTargetsAsmParsers", + ":AllTargetsCodeGens", + ":Core", + ":DlltoolDriver", + ":LibDriver", + ":Object", + ":Support", + ], +) + +# We need to run llvm-ar with different basenames to make it run with +# different behavior. +binary_alias( + name = "llvm-dlltool", + binary = ":llvm-ar", +) + +binary_alias( + name = "llvm-lib", + binary = ":llvm-ar", +) + +binary_alias( + name = "llvm-ranlib", + binary = ":llvm-ar", +) + +cc_binary( + name = "llvm-as", + srcs = glob([ + "tools/llvm-as/*.cpp", + "tools/llvm-as/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":Analysis", + ":AsmParser", + ":BitWriter", + ":Core", + ":Support", + ], +) + +cc_binary( + name = "llvm-bcanalyzer", + srcs = glob([ + "tools/llvm-bcanalyzer/*.cpp", + "tools/llvm-bcanalyzer/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":BitReader", + ":Support", + ], +) + +cc_binary( + name = "llvm-cat", + srcs = glob([ + "tools/llvm-cat/*.cpp", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":BitReader", + ":BitWriter", + ":Core", + ":IRReader", + ":Support", + ], +) + +cc_binary( + name = "llvm-cfi-verify", + srcs = glob([ + "tools/llvm-cfi-verify/*.cpp", + "tools/llvm-cfi-verify/lib/*.cpp", + "tools/llvm-cfi-verify/lib/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":AllTargetsAsmParsers", + ":AllTargetsCodeGens", + ":AllTargetsDisassemblers", + ":BinaryFormat", + ":DebugInfoDWARF", + ":MC", + ":MCDisassembler", + ":MCParser", + ":Object", + ":Support", + ":Symbolize", + ], +) + +cc_binary( + name = "llvm-cov", + srcs = glob([ + "tools/llvm-cov/*.cpp", + "tools/llvm-cov/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":Coverage", + ":Instrumentation", + ":Object", + ":ProfileData", + ":Support", + ], +) + +gentbl( + name = "CvtResTableGen", + strip_include_prefix = "tools/llvm-cvtres", + tbl_outs = [( + "-gen-opt-parser-defs", + "tools/llvm-cvtres/Opts.inc", + )], + tblgen = ":llvm-tblgen", + td_file = "tools/llvm-cvtres/Opts.td", + td_srcs = ["include/llvm/Option/OptParser.td"], +) + +cc_binary( + name = "llvm-cvtres", + srcs = glob([ + "tools/llvm-cvtres/*.cpp", + "tools/llvm-cvtres/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":CvtResTableGen", + ":Object", + ":Option", + ":Support", + ], +) + +cc_binary( + name = "llvm-cxxdump", + srcs = glob([ + "tools/llvm-cxxdump/*.cpp", + "tools/llvm-cxxdump/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":AllTargetsCodeGens", + ":BitReader", + ":Object", + ":Support", + ], +) + +cc_binary( + name = "llvm-cxxmap", + srcs = glob([ + "tools/llvm-cxxmap/*.cpp", + "tools/llvm-cxxmap/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":Support", + ], +) + +cc_binary( + name = "llvm-cxxfilt", + srcs = glob([ + "tools/llvm-cxxfilt/*.cpp", + "tools/llvm-cxxfilt/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":Demangle", + ":Support", + ], +) + +cc_binary( + name = "llvm-dis", + srcs = glob([ + "tools/llvm-dis/*.cpp", + "tools/llvm-dis/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":Analysis", + ":BitReader", + ":Core", + ":Support", + ], +) + +cc_binary( + name = "llvm-dwarfdump", + srcs = glob([ + "tools/llvm-dwarfdump/*.cpp", + "tools/llvm-dwarfdump/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":AllTargetsCodeGens", + ":BinaryFormat", + ":DebugInfo", + ":DebugInfoDWARF", + ":MC", + ":Object", + ":Support", + ], +) + +cc_binary( + name = "llvm-dwp", + srcs = glob([ + "tools/llvm-dwp/*.cpp", + "tools/llvm-dwp/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":AllTargetsCodeGens", + ":DebugInfoDWARF", + ":MC", + ":Object", + ":Support", + ":Target", + ], +) + +cc_binary( + name = "llvm-elfabi", + srcs = glob([ + "tools/llvm-elfabi/*.cpp", + "tools/llvm-elfabi/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":InterfaceStub", + ":Object", + ":Support", + ":TextAPI", + ], +) + +cc_binary( + name = "llvm-exegesis", + srcs = [ + "tools/llvm-exegesis/llvm-exegesis.cpp", + ], + copts = llvm_copts + ["-DHAVE_LIBPFM=0"], + linkopts = ["-lpfm"], + stamp = 0, + tags = [ + "manual", # External dependency (libpfm4 through Exegesis) + "nobuildkite", # TODO(chandlerc): Enable when the library builds. + ], + deps = [ + ":AllTargetsAsmParsers", + ":AllTargetsCodeGens", + ":AllTargetsDisassemblers", + ":Exegesis", + ":MC", + ":MCParser", + ":Object", + ":Support", + ":config", + ], +) + +cc_binary( + name = "llvm-extract", + srcs = glob([ + "tools/llvm-extract/*.cpp", + "tools/llvm-extract/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":AsmParser", + ":BitReader", + ":BitWriter", + ":Core", + ":IPO", + ":IRReader", + ":Support", + ], +) + +cc_binary( + name = "llvm-ifs", + srcs = glob([ + "tools/llvm-ifs/*.cpp", + "tools/llvm-ifs/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":InterfaceStub", + ":ObjectYAML", + ":Support", + ":TextAPI", + ], +) + +cc_binary( + name = "llvm-jitlink", + srcs = glob([ + "tools/llvm-jitlink/*.cpp", + "tools/llvm-jitlink/*.h", + ]), + copts = llvm_copts, + # Make symbols from the standard library dynamically resolvable. + linkopts = select({ + "@bazel_tools//src/conditions:windows": [], + "@bazel_tools//src/conditions:darwin": [], + "//conditions:default": [ + "-Wl,--undefined=_ZTIi", + "-Wl,--export-dynamic-symbol=_ZTIi", + "-Wl,--export-dynamic-symbol=__cxa_begin_catch", + "-Wl,--export-dynamic-symbol=__cxa_end_catch", + "-Wl,--export-dynamic-symbol=__gxx_personality_v0", + "-Wl,--export-dynamic-symbol=__cxa_allocate_exception", + "-Wl,--export-dynamic-symbol=__cxa_throw", + "-Wl,--export-dynamic-symbol=llvm_orc_registerJITLoaderGDBWrapper", + ], + }), + stamp = 0, + deps = [ + ":AllTargetsAsmParsers", + ":AllTargetsCodeGens", + ":AllTargetsDisassemblers", + ":AsmParser", + ":BitReader", + ":CodeGen", + ":ExecutionEngine", + ":MCJIT", + ":Object", + ":OrcJIT", + ":Support", + ":config", + ], +) + +cc_binary( + name = "llvm-libtool-darwin", + srcs = glob([ + "tools/llvm-libtool-darwin/*.cpp", + "tools/llvm-libtool-darwin/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":BinaryFormat", + ":Object", + ":Support", + ], +) + +cc_binary( + name = "llvm-link", + srcs = glob([ + "tools/llvm-link/*.cpp", + "tools/llvm-link/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":AsmParser", + ":BitReader", + ":BitWriter", + ":Core", + ":IPO", + ":IRReader", + ":Linker", + ":Object", + ":Support", + ":TransformUtils", + ], +) + +gentbl( + name = "LipoOptsTableGen", + strip_include_prefix = "tools/llvm-lipo", + tbl_outs = [( + "-gen-opt-parser-defs", + "tools/llvm-lipo/LipoOpts.inc", + )], + tblgen = ":llvm-tblgen", + td_file = "tools/llvm-lipo/LipoOpts.td", + td_srcs = ["include/llvm/Option/OptParser.td"], +) + +cc_binary( + name = "llvm-lipo", + srcs = [ + "tools/llvm-lipo/llvm-lipo.cpp", + ], + copts = llvm_copts, + stamp = 0, + deps = [ + ":LipoOptsTableGen", + ":Object", + ":Option", + ":Support", + ], +) + +cc_binary( + name = "llvm-lto", + srcs = glob([ + "tools/llvm-lto/*.cpp", + "tools/llvm-lto/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":AllTargetsAsmParsers", + ":AllTargetsCodeGens", + ":BitReader", + ":BitWriter", + ":CodeGen", + ":Core", + ":IRReader", + ":LTO", + ":Support", + ":Target", + ], +) + +cc_binary( + name = "llvm-lto2", + srcs = glob([ + "tools/llvm-lto2/*.cpp", + "tools/llvm-lto2/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":AllTargetsAsmParsers", + ":AllTargetsCodeGens", + ":BitReader", + ":CodeGen", + ":Core", + ":LTO", + ":Support", + ], +) + +cc_binary( + name = "llvm-mc", + srcs = glob([ + "tools/llvm-mc/*.cpp", + "tools/llvm-mc/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":AllTargetsAsmParsers", + ":AllTargetsCodeGens", + ":AllTargetsDisassemblers", + ":MC", + ":MCDisassembler", + ":MCParser", + ":Object", + ":Support", + ], +) + +cc_binary( + name = "llvm-mca", + srcs = glob([ + "tools/llvm-mca/*.cpp", + "tools/llvm-mca/Views/*.cpp", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":AllTargetsAsmParsers", + ":AllTargetsCodeGens", + ":AllTargetsDisassemblers", + ":MC", + ":MCA", + ":MCParser", + ":Support", + ":llvm-mca-headers", + ], +) + +gentbl( + name = "MlTableGen", + strip_include_prefix = "tools/llvm-ml", + tbl_outs = [( + "-gen-opt-parser-defs", + "tools/llvm-ml/Opts.inc", + )], + tblgen = ":llvm-tblgen", + td_file = "tools/llvm-ml/Opts.td", + td_srcs = ["include/llvm/Option/OptParser.td"], +) + +cc_binary( + name = "llvm-ml", + srcs = glob([ + "tools/llvm-ml/*.cpp", + "tools/llvm-ml/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":AllTargetsAsmParsers", + ":AllTargetsCodeGens", + ":AllTargetsDisassemblers", + ":MC", + ":MCParser", + ":MlTableGen", + ":Option", + ":Support", + ], +) + +cc_binary( + name = "llvm-modextract", + srcs = glob([ + "tools/llvm-modextract/*.cpp", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":BitReader", + ":BitWriter", + ":IRReader", + ":Support", + ], +) + +gentbl( + name = "MtTableGen", + strip_include_prefix = "tools/llvm-mt", + tbl_outs = [( + "-gen-opt-parser-defs", + "tools/llvm-mt/Opts.inc", + )], + tblgen = ":llvm-tblgen", + td_file = "tools/llvm-mt/Opts.td", + td_srcs = ["include/llvm/Option/OptParser.td"], +) + +cc_binary( + name = "llvm-mt", + srcs = glob([ + "tools/llvm-mt/*.cpp", + "tools/llvm-mt/*.h", + ]), + copts = llvm_copts, + stamp = 0, + tags = [ + "manual", # TODO(gcmn): External dependency (through WindowsManifest) + "nobuildkite", # TODO(gcmn): Re-enable when WindowsManifest builds + ], + deps = [ + ":MtTableGen", + ":Option", + ":Support", + ":WindowsManifest", + ], +) + +cc_binary( + name = "llvm-nm", + srcs = glob([ + "tools/llvm-nm/*.cpp", + "tools/llvm-nm/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":AllTargetsAsmParsers", + ":AllTargetsCodeGens", + ":BinaryFormat", + ":BitReader", + ":Core", + ":Demangle", + ":Object", + ":Support", + ], +) + +gentbl( + name = "llvm-objcopy-opts", + strip_include_prefix = "tools/llvm-objcopy", + tbl_outs = [( + "-gen-opt-parser-defs", + "tools/llvm-objcopy/ObjcopyOpts.inc", + )], + tblgen = ":llvm-tblgen", + td_file = "tools/llvm-objcopy/ObjcopyOpts.td", + td_srcs = [ + "include/llvm/Option/OptParser.td", + "tools/llvm-objcopy/CommonOpts.td", + ], +) + +gentbl( + name = "llvm-installnametool-opts", + strip_include_prefix = "tools/llvm-objcopy", + tbl_outs = [( + "-gen-opt-parser-defs", + "tools/llvm-objcopy/InstallNameToolOpts.inc", + )], + tblgen = ":llvm-tblgen", + td_file = "tools/llvm-objcopy/InstallNameToolOpts.td", + td_srcs = [ + "include/llvm/Option/OptParser.td", + "tools/llvm-objcopy/CommonOpts.td", + ], +) + +gentbl( + name = "llvm-strip-opts", + strip_include_prefix = "tools/llvm-objcopy", + tbl_outs = [( + "-gen-opt-parser-defs", + "tools/llvm-objcopy/StripOpts.inc", + )], + tblgen = ":llvm-tblgen", + td_file = "tools/llvm-objcopy/StripOpts.td", + td_srcs = [ + "include/llvm/Option/OptParser.td", + "tools/llvm-objcopy/CommonOpts.td", + ], +) + +gentbl( + name = "llvm-bitcode-strip-opts", + strip_include_prefix = "tools/llvm-objcopy", + tbl_outs = [( + "-gen-opt-parser-defs", + "tools/llvm-objcopy/BitcodeStripOpts.inc", + )], + tblgen = ":llvm-tblgen", + td_file = "tools/llvm-objcopy/BitcodeStripOpts.td", + td_srcs = [ + "include/llvm/Option/OptParser.td", + "tools/llvm-objcopy/CommonOpts.td", + ], +) + +cc_binary( + name = "llvm-objcopy", + srcs = glob([ + "tools/llvm-objcopy/**/*.cpp", + # Note that we redundantly include the headers here to allow files to + # include same-directory headers in addition to including headers via + # the `llvm-objcopy-headers` rule's stripped include prefix. + "tools/llvm-objcopy/**/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":BinaryFormat", + ":MC", + ":Object", + ":ObjectYAML", + ":Option", + ":Support", + ":Target", + ":llvm-bitcode-strip-opts", + ":llvm-installnametool-opts", + ":llvm-objcopy-headers", + ":llvm-objcopy-opts", + ":llvm-strip-opts", + ], +) + +binary_alias( + name = "llvm-strip", + binary = ":llvm-objcopy", +) + +binary_alias( + name = "llvm-bitcode-strip", + binary = ":llvm-objcopy", +) + +binary_alias( + name = "llvm-install-name-tool", + binary = ":llvm-objcopy", +) + +cc_binary( + name = "llvm-objdump", + srcs = glob([ + "tools/llvm-objdump/*.cpp", + "tools/llvm-objdump/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":AllTargetsAsmParsers", + ":AllTargetsCodeGens", + ":AllTargetsDisassemblers", + ":BinaryFormat", + ":CodeGen", + ":DebugInfo", + ":DebugInfoDWARF", + ":Demangle", + ":MC", + ":MCDisassembler", + ":ObjdumpOptsTableGen", + ":Object", + ":Option", + ":OtoolOptsTableGen", + ":Support", + ":Symbolize", + ":config", + ], +) + +gentbl( + name = "ObjdumpOptsTableGen", + strip_include_prefix = "tools/llvm-objdump", + tbl_outs = [( + "-gen-opt-parser-defs", + "tools/llvm-objdump/ObjdumpOpts.inc", + )], + tblgen = ":llvm-tblgen", + td_file = "tools/llvm-objdump/ObjdumpOpts.td", + td_srcs = ["include/llvm/Option/OptParser.td"], +) + +binary_alias( + name = "llvm-otool", + binary = ":llvm-objdump", +) + +gentbl( + name = "OtoolOptsTableGen", + strip_include_prefix = "tools/llvm-objdump", + tbl_outs = [( + "-gen-opt-parser-defs", + "tools/llvm-objdump/OtoolOpts.inc", + )], + tblgen = ":llvm-tblgen", + td_file = "tools/llvm-objdump/OtoolOpts.td", + td_srcs = ["include/llvm/Option/OptParser.td"], +) + +cc_binary( + name = "llvm-opt-report", + srcs = glob([ + "tools/llvm-opt-report/*.cpp", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":AllTargetsCodeGens", + ":Demangle", + ":Remarks", + ":Support", + ], +) + +cc_binary( + name = "llvm-pdbutil", + srcs = glob([ + "tools/llvm-pdbutil/*.cpp", + "tools/llvm-pdbutil/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":BinaryFormat", + ":DebugInfoCodeView", + ":DebugInfoMSF", + ":DebugInfoPDB", + ":Object", + ":ObjectYAML", + ":Support", + ":config", + ], +) + +cc_binary( + name = "llvm-profdata", + srcs = glob([ + "tools/llvm-profdata/*.cpp", + "tools/llvm-profdata/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":Core", + ":ProfileData", + ":Support", + ], +) + +cc_binary( + name = "llvm-profgen", + srcs = glob([ + "tools/llvm-profgen/*.cpp", + "tools/llvm-profgen/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":AllTargetsCodeGens", + ":AllTargetsDisassemblers", + ":Symbolize", + ], +) + +gentbl( + name = "RcTableGen", + strip_include_prefix = "tools/llvm-rc", + tbl_outs = [( + "-gen-opt-parser-defs", + "tools/llvm-rc/Opts.inc", + )], + tblgen = ":llvm-tblgen", + td_file = "tools/llvm-rc/Opts.td", + td_srcs = ["include/llvm/Option/OptParser.td"], +) + +gentbl( + name = "WindresTableGen", + strip_include_prefix = "tools/llvm-rc", + tbl_outs = [( + "-gen-opt-parser-defs", + "tools/llvm-rc/WindresOpts.inc", + )], + tblgen = ":llvm-tblgen", + td_file = "tools/llvm-rc/WindresOpts.td", + td_srcs = ["include/llvm/Option/OptParser.td"], +) + +# Workaround inability to put `.def` files into `srcs` with a library. +cc_library( + name = "llvm-rc-defs-lib", + textual_hdrs = glob(["tools/llvm-rc/*.def"]), +) + +cc_binary( + name = "llvm-rc", + srcs = glob([ + "tools/llvm-rc/*.cpp", + "tools/llvm-rc/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":Object", + ":Option", + ":RcTableGen", + ":Support", + ":WindresTableGen", + ":llvm-rc-defs-lib", + ], +) + +binary_alias( + name = "llvm-windres", + binary = ":llvm-rc", +) + +cc_binary( + name = "llvm-readobj", + srcs = glob([ + "tools/llvm-readobj/*.cpp", + "tools/llvm-readobj/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":AllTargetsCodeGens", + ":BinaryFormat", + ":BitReader", + ":DebugInfoCodeView", + ":DebugInfoDWARF", + ":Demangle", + ":Object", + ":Support", + ], +) + +# Create an 'llvm-readelf' named binary from the 'llvm-readobj' tool. +binary_alias( + name = "llvm-readelf", + binary = ":llvm-readobj", +) + +cc_binary( + name = "llvm-reduce", + srcs = glob([ + "tools/llvm-reduce/**/*.cpp", + "tools/llvm-reduce/**/*.h", + ]), + copts = llvm_copts, + includes = ["tools/llvm-reduce"], + stamp = 0, + deps = [ + ":AllTargetsCodeGens", + ":BitReader", + ":Core", + ], +) + +cc_binary( + name = "llvm-rtdyld", + srcs = glob([ + "tools/llvm-rtdyld/*.cpp", + "tools/llvm-rtdyld/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":AllTargetsCodeGens", + ":AllTargetsDisassemblers", + ":DebugInfo", + ":DebugInfoDWARF", + ":ExecutionEngine", + ":MC", + ":MCDisassembler", + ":Object", + ":Support", + ], +) + +cc_binary( + name = "llvm-size", + srcs = glob([ + "tools/llvm-size/*.cpp", + "tools/llvm-size/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":Object", + ":Support", + ], +) + +cc_binary( + name = "llvm-split", + srcs = glob([ + "tools/llvm-split/*.cpp", + "tools/llvm-split/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":BitWriter", + ":Core", + ":IRReader", + ":Support", + ":TransformUtils", + ], +) + +cc_binary( + name = "llvm-strings", + srcs = glob([ + "tools/llvm-strings/*.cpp", + "tools/llvm-strings/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":Object", + ":Support", + ], +) + +gentbl( + name = "SymbolizerOptsTableGen", + strip_include_prefix = "tools/llvm-symbolizer", + tbl_outs = [( + "-gen-opt-parser-defs", + "tools/llvm-symbolizer/Opts.inc", + )], + tblgen = ":llvm-tblgen", + td_file = "tools/llvm-symbolizer/Opts.td", + td_srcs = ["include/llvm/Option/OptParser.td"], +) + +cc_binary( + name = "llvm-symbolizer", + srcs = glob([ + "tools/llvm-symbolizer/*.cpp", + "tools/llvm-symbolizer/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":DebugInfoDWARF", + ":DebugInfoPDB", + ":Object", + ":Option", + ":Support", + ":Symbolize", + ":SymbolizerOptsTableGen", + ], +) + +binary_alias( + name = "llvm-addr2line", + binary = ":llvm-symbolizer", +) + +cc_binary( + name = "llvm-undname", + srcs = glob([ + "tools/llvm-undname/*.cpp", + "tools/llvm-undname/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":Demangle", + ":Support", + ], +) + +cc_binary( + name = "llvm-xray", + srcs = glob([ + "tools/llvm-xray/*.cpp", + "tools/llvm-xray/*.cc", + "tools/llvm-xray/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":DebugInfoDWARF", + ":Object", + ":Support", + ":Symbolize", + ":XRay", + ], +) + +cc_binary( + name = "opt", + srcs = glob([ + "tools/opt/*.cpp", + "tools/opt/*.h", + ]), + copts = llvm_copts, + linkopts = select({ + "@bazel_tools//src/conditions:windows": [], + "@bazel_tools//src/conditions:darwin": [], + "//conditions:default": ["-Wl,--export-dynamic"], + }), + stamp = 0, + deps = [ + ":AllTargetsAsmParsers", + ":AllTargetsCodeGens", + ":Analysis", + ":AsmParser", + ":BitReader", + ":BitWriter", + ":CodeGen", + ":Core", + ":IRReader", + ":MC", + ":Passes", + ":Support", + ":Target", + ":TransformUtils", + ":common_transforms", + ":config", + ], +) + +cc_binary( + name = "sancov", + srcs = glob([ + "tools/sancov/*.cpp", + "tools/sancov/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":AllTargetsCodeGens", + ":AllTargetsDisassemblers", + ":DebugInfoDWARF", + ":DebugInfoPDB", + ":MC", + ":MCDisassembler", + ":Object", + ":Support", + ":Symbolize", + ], +) + +cc_binary( + name = "sanstats", + srcs = glob([ + "tools/sanstats/*.cpp", + "tools/sanstats/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":Support", + ":Symbolize", + ":TransformUtils", + ], +) + +cc_binary( + name = "split-file", + srcs = glob([ + "tools/split-file/*.cpp", + "tools/split-file/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":Support", + ], +) + +################################################################################ +# Begin testonly libraries + +cc_library( + name = "FuzzMutate", + testonly = True, + srcs = glob(["lib/FuzzMutate/*.cpp"]), + hdrs = glob(["include/llvm/FuzzMutate/*.h"]), + copts = llvm_copts, + includes = ["include"], + deps = [ + ":Analysis", + ":BitReader", + ":BitWriter", + ":Core", + ":Scalar", + ":Support", + ], +) + +# A hacky library to expose some internal headers of gtest to its own +# implementation source files using a stripped include prefix rather than +# file-relative-inclusion. +# +# FIXME: This file should be in `textual_hdrs` instead of `hdrs`, but +# unfortunately that doesn't work with `strip_include_prefix`: +# https://github.com/bazelbuild/bazel/issues/12424 +# +# For now, simply disable parsing and header modules. +cc_library( + name = "gtest_internal_headers", + testonly = True, + hdrs = ["utils/unittest/googletest/src/gtest-internal-inl.h"], + features = [ + "-parse_headers", + "-header_modules", + ], + strip_include_prefix = "utils/unittest/googletest", +) + +cc_library( + name = "gtest", + testonly = True, + srcs = glob( + [ + "utils/unittest/googletest/include/**/*.h", + "utils/unittest/googletest/src/*.cc", + ], + exclude = [ + "utils/unittest/googletest/src/gtest-all.cc", + "utils/unittest/googletest/include/gtest/gtest_pred_impl.h", + ], + ) + [ + ], + hdrs = ["utils/unittest/googletest/include/gtest/gtest.h"], + copts = llvm_copts, + defines = [ + "GTEST_HAS_RTTI=0", + "__STDC_LIMIT_MACROS", + "__STDC_CONSTANT_MACROS", + ] + select({ + "@bazel_tools//src/conditions:windows": ["GTEST_USE_OWN_TR1_TUPLE=0"], + "//conditions:default": ["GTEST_USE_OWN_TR1_TUPLE=1"], + }), + includes = [ + "include", + "utils/unittest/googletest/include", + ], + textual_hdrs = [ + "utils/unittest/googletest/include/gtest/gtest_pred_impl.h", + ], + deps = [ + ":Support", + ":gtest_internal_headers", + ], +) + +cc_library( + name = "gtest_main", + testonly = True, + srcs = ["utils/unittest/UnitTestMain/TestMain.cpp"], + copts = llvm_copts, + deps = [ + ":Support", + ":gmock", + ":gtest", + ], +) + +cc_library( + name = "gmock", + testonly = True, + srcs = glob( + [ + "utils/unittest/googlemock/include/**/*.h", + "utils/unittest/googlemock/src/*.cc", + ], + exclude = ["utils/unittest/googlemock/src/gmock-all.cc"], + ), + hdrs = [ + "utils/unittest/googlemock/include/gmock/gmock.h", + "utils/unittest/googlemock/include/gmock/gmock-matchers.h", + ], + copts = llvm_copts, + includes = [ + "include", + "utils/unittest/googlemock/include", + ], + deps = [":gtest"], +) + +py_binary( + name = "lit", + testonly = True, + srcs = ["utils/lit/lit.py"] + glob(["utils/lit/lit/**/*.py"]), +) + +cc_library( + name = "TestingSupport", + testonly = True, + srcs = glob([ + "lib/Testing/Support/*.cpp", + "lib/Testing/Support/*.h", + ]), + hdrs = glob([ + "include/llvm/Testing/Support/*.h", + ]), + copts = llvm_copts, + deps = [ + ":Support", + ":config", + ":gmock", + ":gtest", + ], +) + +################################################################################ +# Begin testonly binary utilities + +cc_binary( + name = "FileCheck", + testonly = True, + srcs = glob([ + "utils/FileCheck/*.cpp", + "utils/FileCheck/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [":FileCheckLib"], +) + +cc_binary( + name = "bugpoint", + srcs = glob([ + "tools/bugpoint/*.cpp", + "tools/bugpoint/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":AllTargetsAsmParsers", + ":AllTargetsCodeGens", + ":Analysis", + ":AsmParser", + ":BitReader", + ":BitWriter", + ":CodeGen", + ":Core", + ":IRReader", + ":Linker", + ":Passes", + ":Support", + ":TransformUtils", + ":common_transforms", + ":config", + ], +) + +cc_binary( + name = "count", + testonly = True, + srcs = glob([ + "utils/count/*.c", + "utils/count/*.h", + ]), + stamp = 0, +) + +cc_binary( + name = "lli-child-target", + testonly = True, + srcs = glob([ + "tools/lli/ChildTarget/*.cpp", + "tools/lli/ChildTarget/*.h", + ]) + [ + "tools/lli/RemoteJITUtils.h", + ], + copts = llvm_copts, + # The tests load code into this binary that expect to see symbols + # from libstdc++ such as __cxa_begin_catch and _ZTIi. The latter + # isn't even used in the main binary, so we also need to force it + # to be included. + linkopts = select({ + "@bazel_tools//src/conditions:windows": [], + "@bazel_tools//src/conditions:darwin": [], + "//conditions:default": [ + "-rdynamic", + "-u_ZTIi", + ], + }), + stamp = 0, + deps = [ + ":OrcJIT", + ":Support", + ":attributes_gen", + ":config", + ":intrinsic_enums_gen", + ], +) + +cc_binary( + name = "llvm-c-test", + testonly = True, + srcs = glob([ + "tools/llvm-c-test/*.c", + "tools/llvm-c-test/*.cpp", + "tools/llvm-c-test/*.h", + ]), + stamp = 0, + deps = [ + ":AllTargetsAsmParsers", + ":AllTargetsCodeGens", + ":AllTargetsDisassemblers", + ":Analysis", + ":BitReader", + ":BitWriter", + ":Core", + ":ExecutionEngine", + ":IPO", + ":LTO", + ":Linker", + ":MCDisassembler", + ":Object", + ":OrcJIT", + ":Scalar", + ":Support", + ":Target", + ":Vectorize", + ], +) + +cc_binary( + name = "llvm-diff", + testonly = True, + srcs = glob([ + "tools/llvm-diff/*.cpp", + "tools/llvm-diff/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":AsmParser", + ":BitReader", + ":Core", + ":IRReader", + ":Support", + ], +) + +cc_binary( + name = "llvm-isel-fuzzer", + testonly = True, + srcs = glob([ + "tools/llvm-isel-fuzzer/*.cpp", + "tools/llvm-isel-fuzzer/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":AllTargetsAsmParsers", + ":AllTargetsCodeGens", + ":Analysis", + ":BitReader", + ":BitWriter", + ":CodeGen", + ":Core", + ":FuzzMutate", + ":IRReader", + ":Support", + ":Target", + ], +) + +# This is really a Python script, but call it sh_binary to ignore the hyphen in +# the path, which py_binary does not allow. +# Also, note: llvm-locstats expects llvm-dwarfdump to be in the same directory +# when executed. +sh_binary( + name = "llvm-locstats", + testonly = True, + srcs = glob([ + "utils/llvm-locstats/*.py", + ]), + # llvm-locstats is a thin wrapper around llvm-dwarfdump. + data = [":llvm-dwarfdump"], +) + +sh_binary( + name = "llvm-original-di-preservation", + testonly = True, + srcs = ["utils/llvm-original-di-preservation.py"], +) + +cc_binary( + name = "not", + testonly = True, + srcs = glob([ + "utils/not/*.cpp", + "utils/not/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [":Support"], +) + +cc_binary( + name = "llvm-opt-fuzzer", + testonly = True, + srcs = glob([ + "tools/llvm-opt-fuzzer/*.cpp", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":AllTargetsCodeGens", + ":Analysis", + ":BitReader", + ":BitWriter", + ":CodeGen", + ":Core", + ":Coroutines", + ":FuzzMutate", + ":Passes", + ":Support", + ], +) + +cc_binary( + name = "llvm-tapi-diff", + testonly = True, + srcs = glob([ + "tools/llvm-tapi-diff/*.cpp", + "tools/llvm-tapi-diff/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":Object", + ":Support", + ":TextAPI", + ], +) + +cc_binary( + name = "obj2yaml", + testonly = True, + srcs = glob([ + "tools/obj2yaml/*.cpp", + "tools/obj2yaml/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":BinaryFormat", + ":DebugInfoCodeView", + ":DebugInfoDWARF", + ":Object", + ":ObjectYAML", + ":Support", + ], +) + +cc_binary( + name = "verify-uselistorder", + srcs = glob([ + "tools/verify-uselistorder/*.cpp", + "tools/verify-uselistorder/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":AsmParser", + ":BitReader", + ":BitWriter", + ":Core", + ":IRReader", + ":Support", + ], +) + +cc_binary( + name = "yaml2obj", + testonly = True, + srcs = glob([ + "tools/yaml2obj/*.cpp", + "tools/yaml2obj/*.h", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":BinaryFormat", + ":DebugInfoCodeView", + ":MC", + ":Object", + ":ObjectYAML", + ":Support", + ], +) + +cc_binary( + name = "yaml-bench", + testonly = True, + srcs = glob([ + "utils/yaml-bench/*.cpp", + ]), + copts = llvm_copts, + stamp = 0, + deps = [ + ":Support", + ], +) diff --git a/utils/bazel/llvm-project-overlay/llvm/binary_alias.bzl b/utils/bazel/llvm-project-overlay/llvm/binary_alias.bzl new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm-project-overlay/llvm/binary_alias.bzl @@ -0,0 +1,35 @@ +# 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 + +"""Creates a copy of a binary, giving it a different basename. + +binary_alias( + name = "my_binary_other_name", + binary = ":some_cc_binary", +) +""" + +def _binary_alias_impl(ctx): + ctx.actions.symlink( + target_file = ctx.executable.binary, + output = ctx.outputs.executable, + is_executable = True, + ) + + return [DefaultInfo( + executable = ctx.outputs.executable, + runfiles = ctx.attr.binary[DefaultInfo].default_runfiles, + )] + +binary_alias = rule( + _binary_alias_impl, + attrs = { + "binary": attr.label( + mandatory = True, + executable = True, + cfg = "target", + ), + }, + executable = True, +) diff --git a/utils/bazel/llvm-project-overlay/llvm/cc_plugin_library.bzl b/utils/bazel/llvm-project-overlay/llvm/cc_plugin_library.bzl new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm-project-overlay/llvm/cc_plugin_library.bzl @@ -0,0 +1,54 @@ +# 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 + +"""A macro to produce a loadable plugin library for the target OS. + +This macro produces a `cc_binary` rule with the name `name + "_impl"`. It +forces the rule to statically link in its dependencies but to be linked as a +shared "plugin" library. It then creates binary aliases to `.so`, `.dylib` +,and `.dll` suffixed names for use on various platforms and selects between +these into a filegroup with the exact name passed to the macro. +""" + +load("@rules_cc//cc:defs.bzl", "cc_binary") +load(":binary_alias.bzl", "binary_alias") + +def cc_plugin_library(name, **kwargs): + # Neither the name of the plugin binary nor tags on whether it is built are + # configurable. Instead, we build a `cc_binary` that implements the plugin + # library using a `_impl` suffix. Bazel will use appropriate flags to cause + # this file to be a plugin library regardless of its name. We then create + # binary aliases in the different possible platform names, and select + # between these different names into a filegroup. The macro's name becomes + # the filegroup name and it contains exactly one target that is the target + # platform suffixed plugin library. + # + # All-in-all, this is a pretty poor workaround. I think this is part of the + # Bazel issue: https://github.com/bazelbuild/bazel/issues/7538 + cc_binary( + name = name + "_impl", + linkshared = True, + linkstatic = True, + **kwargs + ) + binary_alias( + name = name + ".so", + binary = ":" + name + "_impl", + ) + binary_alias( + name = name + ".dll", + binary = ":" + name + "_impl", + ) + binary_alias( + name = name + ".dylib", + binary = ":" + name + "_impl", + ) + native.filegroup( + name = name, + srcs = select({ + "@bazel_tools//src/conditions:windows": [":" + name + ".dll"], + "@bazel_tools//src/conditions:darwin": [":" + name + ".dylib"], + "//conditions:default": [":" + name + ".so"], + }), + ) diff --git a/utils/bazel/llvm-project-overlay/llvm/config.bzl b/utils/bazel/llvm-project-overlay/llvm/config.bzl new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm-project-overlay/llvm/config.bzl @@ -0,0 +1,77 @@ +# 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 + +"""Defines variables that use selects to configure LLVM based on platform.""" + +def native_arch_defines(arch, triple): + return [ + "LLVM_NATIVE_ARCH=\\\"{}\\\"".format(arch), + "LLVM_NATIVE_ASMPARSER=LLVMInitialize{}AsmParser".format(arch), + "LLVM_NATIVE_ASMPRINTER=LLVMInitialize{}AsmPrinter".format(arch), + "LLVM_NATIVE_DISASSEMBLER=LLVMInitialize{}Disassembler".format(arch), + "LLVM_NATIVE_TARGET=LLVMInitialize{}Target".format(arch), + "LLVM_NATIVE_TARGETINFO=LLVMInitialize{}TargetInfo".format(arch), + "LLVM_NATIVE_TARGETMC=LLVMInitialize{}TargetMC".format(arch), + "LLVM_HOST_TRIPLE=\\\"{}\\\"".format(triple), + "LLVM_DEFAULT_TARGET_TRIPLE=\\\"{}\\\"".format(triple), + ] + +posix_defines = [ + "LLVM_ON_UNIX=1", + "HAVE_BACKTRACE=1", + "BACKTRACE_HEADER=", + "LTDL_SHLIB_EXT=\\\".so\\\"", + "LLVM_PLUGIN_EXT=\\\".so\\\"", + "LLVM_ENABLE_THREADS=1", + "HAVE_SYSEXITS_H=1", + "HAVE_UNISTD_H=1", + "HAVE_STRERROR_R=1", + "HAVE_LIBPTHREAD=1", + "HAVE_PTHREAD_GETNAME_NP=1", + "HAVE_PTHREAD_SETNAME_NP=1", + "HAVE_PTHREAD_GETSPECIFIC=1", +] + +linux_defines = posix_defines + [ + "_GNU_SOURCE", + "HAVE_LINK_H=1", + "HAVE_LSEEK64=1", + "HAVE_MALLINFO=1", + "HAVE_POSIX_FALLOCATE=1", + "HAVE_SBRK=1", + "HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC=1", +] + +macos_defines = posix_defines + [ + "HAVE_MACH_MACH_H=1", + "HAVE_MALLOC_MALLOC_H=1", + "HAVE_MALLOC_ZONE_STATISTICS=1", + "HAVE_PROC_PID_RUSAGE=1", +] + +win32_defines = [ + # MSVC specific + "stricmp=_stricmp", + "strdup=_strdup", + + # LLVM features + "LTDL_SHLIB_EXT=\\\".dll\\\"", + "LLVM_PLUGIN_EXT=\\\".dll\\\"", +] + +# TODO: We should switch to platforms-based config settings to make this easier +# to express. +os_defines = select({ + "@bazel_tools//src/conditions:windows": win32_defines, + "@bazel_tools//src/conditions:darwin": macos_defines, + "//conditions:default": linux_defines, +}) + +# TODO: We should split out host vs. target here. +llvm_config_defines = os_defines + select({ + "@bazel_tools//src/conditions:windows": native_arch_defines("X86", "x86_64-pc-win32"), + "@bazel_tools//src/conditions:darwin": native_arch_defines("X86", "x86_64-unknown-darwin"), + "@bazel_tools//src/conditions:linux_aarch64": native_arch_defines("AArch64", "aarch64-unknown-linux-gnu"), + "//conditions:default": native_arch_defines("X86", "x86_64-unknown-linux-gnu"), +}) diff --git a/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h b/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h @@ -0,0 +1,363 @@ +/*===------- llvm/Config/config.h - llvm configuration ------------*- C -*-===*/ +/* */ +/* Part of the LLVM Project, 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 */ +/* */ +/*===----------------------------------------------------------------------===*/ + +/* This is a manual port of config.h.cmake for the symbols that do not change + based on platform. Those that do change should not be defined here and + instead use Bazel cc_library defines. Some attempt has been made to extract + such symbols that do vary based on platform (for the platforms we care about) + into Bazel defines, but it is by no means complete, so if you see something + that looks wrong, it probably is. */ + +#ifndef CONFIG_H +#define CONFIG_H + +// Include this header only under the llvm source tree. +// This is a private header. + +/* Exported configuration */ +#include "llvm/Config/llvm-config.h" + +/* Bug report URL. */ +#define BUG_REPORT_URL "https://bugs.llvm.org/" + +/* Define to 1 to enable backtraces, and to 0 otherwise. */ +#define ENABLE_BACKTRACES 1 + +/* Define to 1 to enable crash overrides, and to 0 otherwise. */ +#define ENABLE_CRASH_OVERRIDES 1 + +/* Define to 1 to enable crash memory dumps, and to 0 otherwise. */ +#define LLVM_ENABLE_CRASH_DUMPS 0 + +/* Define to 1 if you have the `backtrace' function. */ +/* HAVE_BACKTRACE defined in Bazel */ + +/* BACKTRACE_HEADER defined in Bazel */ + +/* Define to 1 if you have the header file. */ +/* HAVE_CRASHREPORTERCLIENT_H defined in Bazel */ + +/* can use __crashreporter_info__ */ +/* HAVE_CRASHREPORTER_INFO defined in Bazel */ + +/* Define to 1 if you have the declaration of `arc4random', and to 0 if you + don't. */ +#define HAVE_DECL_ARC4RANDOM 0 + +/* Define to 1 if you have the declaration of `FE_ALL_EXCEPT', and to 0 if you + don't. */ +#define HAVE_DECL_FE_ALL_EXCEPT 1 + +/* Define to 1 if you have the declaration of `FE_INEXACT', and to 0 if you + don't. */ +#define HAVE_DECL_FE_INEXACT 1 + +/* Define to 1 if you have the declaration of `strerror_s', and to 0 if you + don't. */ +#define HAVE_DECL_STRERROR_S 0 + +/* Define to 1 if you have the DIA SDK installed, and to 0 if you don't. */ +#define LLVM_ENABLE_DIA_SDK 0 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define if dlopen() is available on this platform. */ +#define HAVE_DLOPEN 1 + +/* Define if dladdr() is available on this platform. */ +/* #undef HAVE_DLADDR */ + +/* Define to 1 if we can register EH frames on this platform. */ +#define HAVE_REGISTER_FRAME 1 + +/* Define to 1 if we can deregister EH frames on this platform. */ +#define HAVE_DEREGISTER_FRAME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FENV_H 1 + +/* Define if libffi is available on this platform. */ +/* #undef HAVE_FFI_CALL */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_FFI_FFI_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_FFI_H */ + +/* Define to 1 if you have the `futimens' function. */ +#define HAVE_FUTIMENS 1 + +/* Define to 1 if you have the `futimes' function. */ +#define HAVE_FUTIMES 1 + +/* Define to 1 if you have the `getpagesize' function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define to 1 if you have the `getrlimit' function. */ +#define HAVE_GETRLIMIT 1 + +/* Define to 1 if you have the `getrusage' function. */ +#define HAVE_GETRUSAGE 1 + +/* Define to 1 if you have the `isatty' function. */ +#define HAVE_ISATTY 1 + +/* Define to 1 if you have the `edit' library (-ledit). */ +/* #undef HAVE_LIBEDIT */ + +/* Define to 1 if you have the `pfm' library (-lpfm). */ +/* #undef HAVE_LIBPFM */ + +/* Define to 1 if the `perf_branch_entry' struct has field cycles. */ +/* #undef LIBPFM_HAS_FIELD_CYCLES */ + +/* Define to 1 if you have the `psapi' library (-lpsapi). */ +/* #undef HAVE_LIBPSAPI */ + +/* Define to 1 if you have the `pthread' library (-lpthread). */ +#define HAVE_LIBPTHREAD 1 + +/* Define to 1 if you have the `pthread_getname_np' function. */ +#define HAVE_PTHREAD_GETNAME_NP 1 + +/* Define to 1 if you have the `pthread_setname_np' function. */ +#define HAVE_PTHREAD_SETNAME_NP 1 + +/* Define to 1 if you have the header file. */ +/* HAVE_LINK_H defined in Bazel */ + +/* Define to 1 if you have the `lseek64' function. */ +/* HAVE_LSEEK64 defined in Bazel */ + +/* Define to 1 if you have the header file. */ +/* HAVE_MACH_MACH_H defined in Bazel */ + +/* Define to 1 if you have the `mallctl' function. */ +/* #undef HAVE_MALLCTL */ + +/* Define to 1 if you have the `mallinfo' function. */ +/* HAVE_MALLINFO defined in Bazel */ + +/* Define to 1 if you have the header file. */ +/* HAVE_MALLOC_MALLOC_H defined in Bazel */ + +/* Define to 1 if you have the `malloc_zone_statistics' function. */ +/* HAVE_MALLOC_ZONE_STATISTICS defined in Bazel */ + +/* Define to 1 if you have the `posix_fallocate' function. */ +/* HAVE_POSIX_FALLOCATE defined in Bazel */ + +/* Define to 1 if you have the `posix_spawn' function. */ +#define HAVE_POSIX_SPAWN 1 + +/* Define to 1 if you have the `pread' function. */ +#define HAVE_PREAD 1 + +/* Have pthread_getspecific */ +#define HAVE_PTHREAD_GETSPECIFIC 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_PTHREAD_H 1 + +/* Have pthread_mutex_lock */ +#define HAVE_PTHREAD_MUTEX_LOCK 1 + +/* Have pthread_rwlock_init */ +#define HAVE_PTHREAD_RWLOCK_INIT 1 + +/* Define to 1 if you have the `sbrk' function. */ +/* HAVE_SBRK defined in Bazel */ + +/* Define to 1 if you have the `setenv' function. */ +#define HAVE_SETENV 1 + +/* Define to 1 if you have the `setrlimit' function. */ +#define HAVE_SETRLIMIT 1 + +/* Define to 1 if you have the `sigaltstack' function. */ +#define HAVE_SIGALTSTACK 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define to 1 if you have the `strerror' function. */ +#define HAVE_STRERROR 1 + +/* Define to 1 if you have the `strerror_r' function. */ +/* HAVE_STRERROR_R defined in Bazel */ + +/* Define to 1 if you have the `sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_MMAN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if stat struct has st_mtimespec member .*/ +/* #undef HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC */ + +/* Define to 1 if stat struct has st_mtim member. */ +/* HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC defined in Bazel */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define if the setupterm() function is supported this platform. */ +/* LLVM_ENABLE_TERMINFO defined in Bazel */ + +/* Define to 1 if you have the header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define to 1 if you have the header file. */ +/* HAVE_UNISTD_H defined in Bazel */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_VALGRIND_VALGRIND_H */ + +/* Have host's _alloca */ +/* #undef HAVE__ALLOCA */ + +/* Define to 1 if you have the `_chsize_s' function. */ +/* #undef HAVE__CHSIZE_S */ + +/* Define to 1 if you have the `_Unwind_Backtrace' function. */ +#define HAVE__UNWIND_BACKTRACE 1 + +/* Have host's __alloca */ +/* #undef HAVE___ALLOCA */ + +/* Have host's __ashldi3 */ +/* #undef HAVE___ASHLDI3 */ + +/* Have host's __ashrdi3 */ +/* #undef HAVE___ASHRDI3 */ + +/* Have host's __chkstk */ +/* #undef HAVE___CHKSTK */ + +/* Have host's __chkstk_ms */ +/* #undef HAVE___CHKSTK_MS */ + +/* Have host's __cmpdi2 */ +/* #undef HAVE___CMPDI2 */ + +/* Have host's __divdi3 */ +/* #undef HAVE___DIVDI3 */ + +/* Have host's __fixdfdi */ +/* #undef HAVE___FIXDFDI */ + +/* Have host's __fixsfdi */ +/* #undef HAVE___FIXSFDI */ + +/* Have host's __floatdidf */ +/* #undef HAVE___FLOATDIDF */ + +/* Have host's __lshrdi3 */ +/* #undef HAVE___LSHRDI3 */ + +/* Have host's __main */ +/* #undef HAVE___MAIN */ + +/* Have host's __moddi3 */ +/* #undef HAVE___MODDI3 */ + +/* Have host's __udivdi3 */ +/* #undef HAVE___UDIVDI3 */ + +/* Have host's __umoddi3 */ +/* #undef HAVE___UMODDI3 */ + +/* Have host's ___chkstk */ +/* #undef HAVE____CHKSTK */ + +/* Have host's ___chkstk_ms */ +/* #undef HAVE____CHKSTK_MS */ + +/* Linker version detected at compile time. */ +/* #undef HOST_LINK_VERSION */ + +/* Target triple LLVM will generate code for by default */ +/* Doesn't use `cmakedefine` because it is allowed to be empty. */ +/* LLVM_DEFAULT_TARGET_TRIPLE defined in Bazel */ + +/* Define if zlib compression is available */ +/* LLVM_ENABLE_ZLIB defined in Bazel */ + +/* Define if overriding target triple is enabled */ +/* #undef LLVM_TARGET_TRIPLE_ENV */ + +/* LLVM version information */ +/* #undef LLVM_VERSION_INFO */ + +/* Whether tools show host and target info when invoked with --version */ +#define LLVM_VERSION_PRINTER_SHOW_HOST_TARGET_INFO 1 + +/* Define if libxml2 is supported on this platform. */ +/* #undef LLVM_ENABLE_LIBXML2 */ + +/* Define to the extension used for shared libraries, say, ".so". */ +/* LTDL_SHLIB_EXT defined in Bazel */ + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "https://bugs.llvm.org/" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "LLVM" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING PACKAGE_NAME " " LLVM_VERSION_STRING + +/* Define to the version of this package. */ +#define PACKAGE_VERSION LLVM_VERSION_STRING + +/* Define to the vendor of this package. */ +/* #undef PACKAGE_VENDOR */ + +/* Define as the return type of signal handlers (`int' or `void'). */ +#define RETSIGTYPE void + +/* Define if std::is_trivially_copyable is supported */ +#define HAVE_STD_IS_TRIVIALLY_COPYABLE 1 + +/* Define to a function implementing stricmp */ +/* stricmp defined in Bazel */ + +/* Define to a function implementing strdup */ +/* strdup defined in Bazel */ + +/* Whether GlobalISel rule coverage is being collected */ +#define LLVM_GISEL_COV_ENABLED 0 + +/* Define to the default GlobalISel coverage file prefix */ +/* #undef LLVM_GISEL_COV_PREFIX */ + +#endif diff --git a/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/llvm-config.h b/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/llvm-config.h new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/llvm-config.h @@ -0,0 +1,111 @@ +/*===------- llvm/Config/llvm-config.h - llvm configuration -------*- C -*-===*/ +/* */ +/* Part of the LLVM Project, 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 */ +/* */ +/*===----------------------------------------------------------------------===*/ + +/* This is a manual port of config.h.cmake for the symbols that do not change + based on platform. Those that do change should not be defined here and + instead use Bazel cc_library defines. Some attempt has been made to extract + such symbols that do vary based on platform (for the platforms we care about) + into Bazel defines, but it is by no means complete, so if you see something + that looks wrong, it probably is. */ + + +/* This file enumerates variables from the LLVM configuration so that they + can be in exported headers and won't override package specific directives. + This is a C header that can be included in the llvm-c headers. */ + +#ifndef LLVM_CONFIG_H +#define LLVM_CONFIG_H + +/* Define if LLVM_ENABLE_DUMP is enabled */ +/* #undef LLVM_ENABLE_DUMP */ + +/* Target triple LLVM will generate code for by default */ +/* LLVM_DEFAULT_TARGET_TRIPLE defined in Bazel */ + +/* Define if threads enabled */ +#define LLVM_ENABLE_THREADS 1 + +/* Has gcc/MSVC atomic intrinsics */ +#define LLVM_HAS_ATOMICS 1 + +/* Host triple LLVM will be executed on */ +/* LLVM_HOST_TRIPLE defined in Bazel */ + +/* LLVM architecture name for the native architecture, if available */ +/* LLVM_NATIVE_ARCH defined in Bazel */ + +/* LLVM name for the native AsmParser init function, if available */ +/* LLVM_NATIVE_ASMPARSER defined in Bazel */ + +/* LLVM name for the native AsmPrinter init function, if available */ +/* LLVM_NATIVE_ASMPRINTER defined in Bazel */ + +/* LLVM name for the native Disassembler init function, if available */ +/* LLVM_NATIVE_DISASSEMBLER defined in Bazel */ + +/* LLVM name for the native Target init function, if available */ +/* LLVM_NATIVE_TARGET defined in Bazel */ + +/* LLVM name for the native TargetInfo init function, if available */ +/* LLVM_NATIVE_TARGETINFO defined in Bazel */ + +/* LLVM name for the native target MC init function, if available */ +/* LLVM_NATIVE_TARGETMC defined in Bazel */ + +/* Define if this is Unixish platform */ +/* LLVM_ON_UNIX defined in Bazel */ + +/* Define if we have the Intel JIT API runtime support library */ +#define LLVM_USE_INTEL_JITEVENTS 0 + +/* Define if we have the oprofile JIT-support library */ +#define LLVM_USE_OPROFILE 0 + +/* Define if we have the perf JIT-support library */ +#define LLVM_USE_PERF 0 + +/* Major version of the LLVM API */ +#define LLVM_VERSION_MAJOR 13 + +/* Minor version of the LLVM API */ +#define LLVM_VERSION_MINOR 0 + +/* Patch version of the LLVM API */ +#define LLVM_VERSION_PATCH 0 + +/* LLVM version string */ +#define LLVM_VERSION_STRING "13.0.0git" + +/* Whether LLVM records statistics for use with GetStatistics(), + * PrintStatistics() or PrintStatisticsJSON() + */ +#define LLVM_FORCE_ENABLE_STATS 0 + +/* Define if we have z3 and want to build it */ +/* #undef LLVM_WITH_Z3 */ + +/* Define if LLVM was built with a dependency to the libtensorflow dynamic library */ +/* #undef LLVM_HAVE_TF_API */ + +/* Define if LLVM was built with a dependency to the tensorflow compiler */ +/* #undef LLVM_HAVE_TF_AOT */ + +/* Define to 1 if you have the header file. */ +/* HAVE_SYSEXITS_H defined in Bazel */ + +/* Define to 1 to enable the experimental new pass manager by default */ +#define LLVM_ENABLE_NEW_PASS_MANAGER 0 + +/* Define if the xar_open() function is supported this platform. */ +/* #undef HAVE_LIBXAR */ + +/* Whether Timers signpost passes in Xcode Instruments */ +#define LLVM_SUPPORT_XCODE_SIGNPOSTS 0 + +#endif diff --git a/utils/bazel/llvm-project-overlay/llvm/tblgen.bzl b/utils/bazel/llvm-project-overlay/llvm/tblgen.bzl new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm-project-overlay/llvm/tblgen.bzl @@ -0,0 +1,81 @@ +# 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 + +"""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 gentbl( + name, + tblgen, + td_file, + td_srcs, + tbl_outs, + library = True, + tblgen_args = "", + **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. + tblgen_args: Extra arguments string to pass to the tblgen binary. + **kwargs: Keyword arguments to pass to subsidiary cc_library() rule. + """ + llvm_project_execroot_path = Label("//llvm:tblgen.bzl", relative_to_caller_repository = False).workspace_root + + if td_file not in td_srcs: + td_srcs += [td_file] + for (opts, out) in tbl_outs: + 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 %s/llvm/include " + + "-I %s/clang/include " + + "-I $$(dirname $(location %s)) " + + "%s $(location %s) %s -o $@") % ( + tblgen, + llvm_project_execroot_path, + llvm_project_execroot_path, + td_file, + opts, + td_file, + tblgen_args, + )), + ) + + # 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, + # FIXME: This should be `textual_hdrs` instead of `hdrs`, but + # unfortunately that doesn't work with `strip_include_prefix`: + # https://github.com/bazelbuild/bazel/issues/12424 + # + # Once that issue is fixed and released, we can switch this to + # `textual_hdrs` and remove the feature disabling the various Bazel + # features (both current and under-development) that motivated the + # distinction between these two. + hdrs = [f for (_, f) in tbl_outs], + features = ["-parse_headers", "-header_modules"], + **kwargs + ) diff --git a/utils/bazel/llvm-project-overlay/llvm/template_rule.bzl b/utils/bazel/llvm-project-overlay/llvm/template_rule.bzl new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm-project-overlay/llvm/template_rule.bzl @@ -0,0 +1,46 @@ +# 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 + +# Rule for simple expansion of template files. This performs a simple +# search over the template file for the keys in substitutions, +# and replaces them with the corresponding values. +# +# Typical usage: +# load("/tools/build_rules/template_rule", "expand_header_template") +# template_rule( +# name = "ExpandMyTemplate", +# src = "my.template", +# out = "my.txt", +# substitutions = { +# "$VAR1": "foo", +# "$VAR2": "bar", +# } +# ) +# +# Args: +# name: The name of the rule. +# template: The template file to expand +# out: The destination of the expanded file +# substitutions: A dictionary mapping strings to their substitutions + +def template_rule_impl(ctx): + ctx.actions.expand_template( + template = ctx.file.src, + output = ctx.outputs.out, + substitutions = ctx.attr.substitutions, + ) + +template_rule = rule( + attrs = { + "src": attr.label( + mandatory = True, + allow_single_file = True, + ), + "substitutions": attr.string_dict(mandatory = True), + "out": attr.output(mandatory = True), + }, + # output_to_genfiles is required for header files. + output_to_genfiles = True, + implementation = template_rule_impl, +) diff --git a/utils/bazel/llvm-project-overlay/llvm/unittests/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/unittests/BUILD.bazel new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm-project-overlay/llvm/unittests/BUILD.bazel @@ -0,0 +1,670 @@ +# 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:tblgen.bzl", "gentbl") + +package( + default_visibility = ["//visibility:public"], + licenses = ["notice"], +) + +cc_test( + name = "adt_tests", + size = "medium", + srcs = glob( + [ + "ADT/*.cpp", + "ADT/*.h", + ], + allow_empty = False, + ), + shard_count = 20, + deps = [ + "//llvm:Core", + "//llvm:Support", + "//llvm:TestingSupport", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "analysis_tests", + size = "small", + srcs = glob( + ["Analysis/*.cpp"], + allow_empty = False, + exclude = [ + # TODO: Add this file to the build. + "Analysis/TFUtilsTest.cpp", + ], + ), + deps = [ + "//llvm:Analysis", + "//llvm:AsmParser", + "//llvm:Core", + "//llvm:Support", + "//llvm:TestingSupport", + "//llvm:TransformUtils", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "asm_parser_tests", + size = "small", + srcs = glob( + ["AsmParser/*.cpp"], + allow_empty = False, + ), + deps = [ + "//llvm:AsmParser", + "//llvm:Core", + "//llvm:Support", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "bitcode_tests", + size = "small", + srcs = glob( + ["Bitcode/*.cpp"], + allow_empty = False, + ), + deps = [ + "//llvm:AsmParser", + "//llvm:BitReader", + "//llvm:BitWriter", + "//llvm:Core", + "//llvm:Support", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "bitstream_tests", + size = "small", + srcs = glob( + ["Bitstream/*.cpp"], + allow_empty = False, + ), + deps = [ + "//llvm:BitstreamReader", + "//llvm:BitstreamWriter", + "//llvm:Support", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_library( + name = "codegen_tests_includes", + textual_hdrs = glob( + ["CodeGen/*.inc"], + allow_empty = False, + ), +) + +cc_test( + name = "codegen_tests", + size = "small", + srcs = glob( + [ + "CodeGen/*.cpp", + "CodeGen/*.h", + ], + allow_empty = False, + ), + deps = [ + ":codegen_tests_includes", + "//llvm:AllTargetsAsmParsers", + "//llvm:AllTargetsCodeGens", + "//llvm:Analysis", + "//llvm:AsmParser", + "//llvm:BinaryFormat", + "//llvm:CodeGen", + "//llvm:Core", + "//llvm:MC", + "//llvm:Passes", + "//llvm:Support", + "//llvm:Target", + "//llvm:TestingSupport", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "codegen_globalisel_tests", + size = "small", + srcs = glob( + [ + "CodeGen/GlobalISel/*.cpp", + "CodeGen/GlobalISel/*.h", + ], + allow_empty = False, + ), + copts = [ + "$(STACK_FRAME_UNLIMITED)", + ], + deps = [ + "//llvm:AllTargetsAsmParsers", + "//llvm:AllTargetsCodeGens", + "//llvm:CodeGen", + "//llvm:Core", + "//llvm:FileCheckLib", + "//llvm:Support", + "//llvm:Target", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "debuginfo_tests", + size = "small", + srcs = glob( + [ + "DebugInfo/DWARF/*.cpp", + "DebugInfo/DWARF/*.h", + # TODO: Re-enable these when they stop crashing. + #"DebugInfo/PDB/*.cpp", + #"DebugInfo/PDB/*.h", + ], + allow_empty = False, + ), + args = [ + # Skip a test that relies on reading files in a way that doesn't easily + # work with Bazel. + "--gtest_filter=-NativeSymbolReuseTest.*", + ], + deps = [ + "//llvm:AllTargetsAsmParsers", + "//llvm:AllTargetsCodeGens", + "//llvm:CodeGen", + "//llvm:Core", + "//llvm:DebugInfoDWARF", + "//llvm:DebugInfoPDB", + "//llvm:ObjectYAML", + "//llvm:Support", + "//llvm:TestingSupport", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "execution_engine_tests", + size = "small", + srcs = glob( + ["ExecutionEngine/*.cpp"], + allow_empty = False, + ), + deps = [ + "//llvm:AllTargetsCodeGens", + "//llvm:AsmParser", + "//llvm:Core", + "//llvm:ExecutionEngine", + "//llvm:Interpreter", + "//llvm:Support", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "execution_engine_mcjit_tests", + size = "small", + srcs = glob( + [ + "ExecutionEngine/MCJIT/*.cpp", + "ExecutionEngine/MCJIT/*.h", + ], + allow_empty = False, + ), + copts = [ + "$(STACK_FRAME_UNLIMITED)", + ], + deps = [ + "//llvm:AllTargetsCodeGens", + "//llvm:AsmParser", + "//llvm:Core", + "//llvm:ExecutionEngine", + "//llvm:MCJIT", + "//llvm:Passes", + "//llvm:Support", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "execution_engine_orc_tests", + size = "small", + srcs = glob( + [ + "ExecutionEngine/Orc/*.cpp", + "ExecutionEngine/Orc/*.h", + ], + allow_empty = False, + ), + args = ["--gtest_filter=-ObjectLinkingLayerTest.TestSetProcessAllSections"], + deps = [ + "//llvm:AllTargetsAsmParsers", + "//llvm:AllTargetsCodeGens", + "//llvm:AsmParser", + "//llvm:Core", + "//llvm:ExecutionEngine", + "//llvm:OrcJIT", + "//llvm:Support", + "//llvm:TestingSupport", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "filecheck_tests", + size = "small", + srcs = glob( + ["FileCheck/*.cpp"], + allow_empty = False, + ), + deps = [ + "//llvm:FileCheckLib", + "//llvm:Support", + "//llvm:TestingSupport", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "ir_tests", + size = "medium", # ConstantRangeTest cases may take several seconds each. + srcs = glob( + [ + "IR/*.cpp", + "IR/*.h", + "Support/KnownBitsTest.h", + ], + allow_empty = False, + ), + shard_count = 20, + deps = [ + "//llvm:Analysis", + "//llvm:AsmParser", + "//llvm:BinaryFormat", + "//llvm:Core", + "//llvm:Passes", + "//llvm:Scalar", + "//llvm:Support", + "//llvm:TestingSupport", + "//llvm:config", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "line_editor_tests", + size = "small", + srcs = glob( + ["LineEditor/*.cpp"], + allow_empty = False, + ), + deps = [ + "//llvm:LineEditor", + "//llvm:Support", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "frontend_tests", + size = "small", + srcs = glob( + ["Frontend/*.cpp"], + allow_empty = False, + ), + deps = [ + "//llvm:Analysis", + "//llvm:FrontendOpenACC", + "//llvm:FrontendOpenMP", + "//llvm:Passes", + "//llvm:Support", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "linker_tests", + size = "small", + srcs = glob( + ["Linker/*.cpp"], + allow_empty = False, + ), + deps = [ + "//llvm:AsmParser", + "//llvm:Core", + "//llvm:Linker", + "//llvm:Support", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "mc_tests", + size = "small", + srcs = glob( + ["MC/*.cpp"], + allow_empty = False, + ), + deps = [ + "//llvm:AllTargetsCodeGens", + "//llvm:AllTargetsDisassemblers", + "//llvm:MC", + "//llvm:MCDisassembler", + "//llvm:Support", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "mi_tests", + size = "small", + srcs = glob( + ["MI/*.cpp"], + allow_empty = False, + ), + deps = [ + "//llvm:AllTargetsAsmParsers", + "//llvm:AllTargetsCodeGens", + "//llvm:CodeGen", + "//llvm:Core", + "//llvm:Support", + "//llvm:Target", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "object_tests", + size = "small", + srcs = glob( + ["Object/*.cpp"], + allow_empty = False, + ), + deps = [ + "//llvm:Object", + "//llvm:ObjectYAML", + "//llvm:TestingSupport", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "object_yaml_tests", + size = "small", + srcs = glob( + ["ObjectYAML/*.cpp"], + allow_empty = False, + ), + deps = [ + "//llvm:DebugInfoCodeView", + "//llvm:Object", + "//llvm:ObjectYAML", + "//llvm:Support", + "//llvm:TestingSupport", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +gentbl( + name = "option_tests_gen", + strip_include_prefix = "Option", + tbl_outs = [( + "-gen-opt-parser-defs", + "Option/Opts.inc", + )], + tblgen = "//llvm:llvm-tblgen", + td_file = "Option/Opts.td", + td_srcs = [ + "//llvm:include/llvm/Option/OptParser.td", + ], +) + +gentbl( + name = "automata_automata_gen", + strip_include_prefix = "TableGen", + tbl_outs = [( + "-gen-automata", + "TableGen/AutomataAutomata.inc", + )], + tblgen = "//llvm:llvm-tblgen", + td_file = "TableGen/Automata.td", + td_srcs = ["//llvm:common_target_td_sources"] + [ + "TableGen/Automata.td", + ], +) + +gentbl( + name = "automata_tables_gen", + strip_include_prefix = "TableGen", + tbl_outs = [( + "-gen-searchable-tables", + "TableGen/AutomataTables.inc", + )], + tblgen = "//llvm:llvm-tblgen", + td_file = "TableGen/Automata.td", + td_srcs = ["//llvm:common_target_td_sources"] + [ + "TableGen/Automata.td", + ], +) + +cc_test( + name = "option_tests", + size = "small", + srcs = glob( + ["Option/*.cpp"], + allow_empty = False, + ), + deps = [ + ":option_tests_gen", + "//llvm:Option", + "//llvm:Support", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "remarks_tests", + size = "small", + srcs = glob( + ["Remarks/*.cpp"], + allow_empty = False, + ), + deps = [ + "//llvm:BitReader", + "//llvm:Remarks", + "//llvm:Support", + "//llvm:gtest", + "//llvm:gtest_main", + "//llvm:remark_linker", + ], +) + +cc_test( + name = "profile_data_tests", + size = "small", + srcs = glob( + ["ProfileData/*.cpp"], + allow_empty = False, + ), + deps = [ + "//llvm:Core", + "//llvm:Coverage", + "//llvm:ProfileData", + "//llvm:Support", + "//llvm:TestingSupport", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "support_tests", + size = "small", + srcs = glob( + [ + "Support/*.cpp", + "Support/*.h", + ], + allow_empty = False, + exclude = [ + "Support/ParallelTest.cpp", + ], + ), + args = ["--gtest_filter=-ProgramTest.CreateProcessTrailingSlash"], + copts = [ + "$(STACK_FRAME_UNLIMITED)", + ], + linkstatic = 1, + tags = [ + "local", # Not compatible with the sandbox on MacOS + ], + visibility = ["//visibility:private"], + deps = [ + "//llvm:AllTargetsCodeGens", + "//llvm:BinaryFormat", + "//llvm:Core", + "//llvm:Support", + "//llvm:TestingSupport", + "//llvm:config", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "support_parallel_tests", + size = "small", + srcs = ["Support/ParallelTest.cpp"], + copts = [ + "$(STACK_FRAME_UNLIMITED)", + ], + linkstatic = 1, + deps = [ + "//llvm:AllTargetsCodeGens", + "//llvm:Support", + "//llvm:config", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "tablegen_tests", + size = "small", + srcs = glob( + [ + "TableGen/*.cpp", + ], + allow_empty = False, + ), + deps = [ + ":automata_automata_gen", + ":automata_tables_gen", + "//llvm:Support", + "//llvm:TableGen", + "//llvm:gtest", + "//llvm:gtest_main", + "//llvm:tblgen", + ], +) + +cc_test( + name = "target_aarch64_tests", + size = "small", + srcs = glob( + ["Target/AArch64/*.cpp"], + allow_empty = False, + ), + copts = [ + "$(STACK_FRAME_UNLIMITED)", + ], + deps = [ + "//llvm:AArch64CodeGen", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "transforms_tests", + size = "small", + srcs = glob( + [ + "Transforms/IPO/*.cpp", + "Transforms/IPO/*.h", + "Transforms/Utils/*.cpp", + ], + allow_empty = False, + ), + deps = [ + "//llvm:Analysis", + "//llvm:AsmParser", + "//llvm:Core", + "//llvm:IPO", + "//llvm:Support", + "//llvm:TestingSupport", + "//llvm:TransformUtils", + "//llvm:gtest", + "//llvm:gtest_main", + ], +) + +cc_test( + name = "llvm_exegesis_tests", + size = "small", + srcs = glob( + [ + "tools/llvm-exegesis/*.cpp", + "tools/llvm-exegesis/X86/*.cpp", + "tools/llvm-exegesis/X86/*.h", + ], + allow_empty = False, + ) + [ + "tools/llvm-exegesis/Common/AssemblerUtils.h", + ], + copts = ["-DHAVE_LIBPFM=1"], + linkopts = ["-lpfm"], + tags = [ + "manual", # External dependency (libpfm4) + "nobuildkite", # TODO(chandlerc): Add support for fetching and building libpfm4 and enable this. + ], + deps = [ + "//llvm:AllTargetsCodeGens", + "//llvm:AllTargetsDisassemblers", + "//llvm:MC", + "//llvm:MCDisassembler", + "//llvm:Support", + "//llvm:TestingSupport", + "//llvm:gtest", + "//llvm:gtest_main", + "//llvm:llvm-exegesis-lib", + ], +) diff --git a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel @@ -0,0 +1,6595 @@ +# 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 + +# Description: +# The MLIR "Multi-Level Intermediate Representation" Compiler Infrastructure + +load(":tblgen.bzl", "gentbl_cc_library", "td_library") +load(":linalggen.bzl", "genlinalg") +load(":build_defs.bzl", "cc_headers_only", "if_cuda_available") + +package( + default_visibility = ["//visibility:public"], + licenses = ["notice"], +) + +exports_files([ + "LICENSE.TXT", + "include/mlir/Dialect/LLVMIR/LLVMOps.td", + "run_lit.sh", +]) + +filegroup( + name = "c_headers", + srcs = glob(["include/mlir-c/**/*"]), # <== i.e. match the entire tree +) + +[ + gentbl_cc_library( + name = name + "IncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-interface-decls"], + "include/mlir/IR/" + name + ".h.inc", + ), + ( + ["-gen-op-interface-defs"], + "include/mlir/IR/" + name + ".cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/IR/" + name + ".td", + deps = [":OpBaseTdFiles"], + ) + for name in [ + "OpAsmInterface", + "RegionKindInterface", + "SymbolInterfaces", + ] +] + +gentbl_cc_library( + name = "TensorEncodingIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-attr-interface-decls"], + "include/mlir/IR/TensorEncInterfaces.h.inc", + ), + ( + ["-gen-attr-interface-defs"], + "include/mlir/IR/TensorEncInterfaces.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/IR/TensorEncoding.td", + deps = [":TensorOpsTdFiles"], +) + +td_library( + name = "SubElementInterfacesTdFiles", + srcs = ["include/mlir/IR/SubElementInterfaces.td"], + includes = ["include"], + deps = [":OpBaseTdFiles"], +) + +gentbl_cc_library( + name = "SubElementInterfacesIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-attr-interface-decls"], + "include/mlir/IR/SubElementAttrInterfaces.h.inc", + ), + ( + ["-gen-attr-interface-defs"], + "include/mlir/IR/SubElementAttrInterfaces.cpp.inc", + ), + ( + ["-gen-type-interface-decls"], + "include/mlir/IR/SubElementTypeInterfaces.h.inc", + ), + ( + ["-gen-type-interface-defs"], + "include/mlir/IR/SubElementTypeInterfaces.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/IR/SubElementInterfaces.td", + deps = [":SubElementInterfacesTdFiles"], +) + +td_library( + name = "BuiltinDialectTdFiles", + srcs = [ + "include/mlir/IR/BuiltinDialect.td", + "include/mlir/IR/BuiltinLocationAttributes.td", + "include/mlir/IR/BuiltinOps.td", + "include/mlir/IR/BuiltinTypeInterfaces.td", + "include/mlir/IR/BuiltinTypes.td", + ], + includes = ["include"], + deps = [ + ":CallInterfacesTdFiles", + ":CastInterfacesTdFiles", + ":DataLayoutInterfacesTdFiles", + ":OpBaseTdFiles", + ":SideEffectInterfacesTdFiles", + ":SubElementInterfacesTdFiles", + ], +) + +gentbl_cc_library( + name = "BuiltinDialectIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-dialect-decls"], + "include/mlir/IR/BuiltinDialect.h.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/IR/BuiltinDialect.td", + deps = [":BuiltinDialectTdFiles"], +) + +gentbl_cc_library( + name = "BuiltinAttributesIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["--gen-attrdef-decls"], + "include/mlir/IR/BuiltinAttributes.h.inc", + ), + ( + ["--gen-attrdef-defs"], + "include/mlir/IR/BuiltinAttributes.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/IR/BuiltinAttributes.td", + deps = [":BuiltinDialectTdFiles"], +) + +gentbl_cc_library( + name = "BuiltinLocationAttributesIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["--gen-attrdef-decls"], + "include/mlir/IR/BuiltinLocationAttributes.h.inc", + ), + ( + ["--gen-attrdef-defs"], + "include/mlir/IR/BuiltinLocationAttributes.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/IR/BuiltinLocationAttributes.td", + deps = [":BuiltinDialectTdFiles"], +) + +gentbl_cc_library( + name = "BuiltinOpsIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-decls"], + "include/mlir/IR/BuiltinOps.h.inc", + ), + ( + ["-gen-op-defs"], + "include/mlir/IR/BuiltinOps.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/IR/BuiltinOps.td", + deps = [":BuiltinDialectTdFiles"], +) + +gentbl_cc_library( + name = "BuiltinTypesIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["--gen-typedef-decls"], + "include/mlir/IR/BuiltinTypes.h.inc", + ), + ( + ["--gen-typedef-defs"], + "include/mlir/IR/BuiltinTypes.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/IR/BuiltinTypes.td", + deps = [":BuiltinDialectTdFiles"], +) + +gentbl_cc_library( + name = "BuiltinTypeInterfacesIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["--gen-type-interface-decls"], + "include/mlir/IR/BuiltinTypeInterfaces.h.inc", + ), + ( + ["--gen-type-interface-defs"], + "include/mlir/IR/BuiltinTypeInterfaces.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/IR/BuiltinTypeInterfaces.td", + deps = [":BuiltinDialectTdFiles"], +) + +cc_library( + name = "IR", + srcs = glob([ + "lib/IR/*.cpp", + "lib/IR/*.h", + ]), + hdrs = glob([ + "include/mlir/IR/*.h", + ]) + [ + "include/mlir/Interfaces/CallInterfaces.h", + "include/mlir/Interfaces/CastInterfaces.h", + "include/mlir/Interfaces/SideEffectInterfaces.h", + "include/mlir/Interfaces/DataLayoutInterfaces.h", + "include/mlir/Interfaces/DecodeAttributesInterfaces.h", + "include/mlir/Interfaces/FoldInterfaces.h", + ], + includes = ["include"], + deps = [ + ":BuiltinAttributesIncGen", + ":BuiltinDialectIncGen", + ":BuiltinLocationAttributesIncGen", + ":BuiltinOpsIncGen", + ":BuiltinTypeInterfacesIncGen", + ":BuiltinTypesIncGen", + ":CallOpInterfacesIncGen", + ":CastOpInterfacesIncGen", + ":DataLayoutInterfacesIncGen", + ":InferTypeOpInterfaceIncGen", + ":OpAsmInterfaceIncGen", + ":RegionKindInterfaceIncGen", + ":SideEffectInterfacesIncGen", + ":SubElementInterfacesIncGen", + ":Support", + ":SymbolInterfacesIncGen", + ":TensorEncodingIncGen", + "//llvm:Support", + ], +) + +cc_library( + name = "Pass", + srcs = glob([ + "lib/Pass/*.cpp", + "lib/Pass/*.h", + ]), + hdrs = glob([ + "include/mlir/Pass/*.h", + ]), + includes = ["include"], + deps = [ + ":IR", + ":Support", + "//llvm:Support", + ], +) + +cc_library( + name = "CAPIIR", + srcs = [ + "lib/CAPI/Dialect/Standard.cpp", + "lib/CAPI/IR/AffineExpr.cpp", + "lib/CAPI/IR/AffineMap.cpp", + "lib/CAPI/IR/BuiltinAttributes.cpp", + "lib/CAPI/IR/BuiltinTypes.cpp", + "lib/CAPI/IR/Diagnostics.cpp", + "lib/CAPI/IR/DialectHandle.cpp", + "lib/CAPI/IR/IR.cpp", + "lib/CAPI/IR/IntegerSet.cpp", + "lib/CAPI/IR/Pass.cpp", + "lib/CAPI/IR/Support.cpp", + ], + hdrs = [ + "include/mlir-c/AffineExpr.h", + "include/mlir-c/AffineMap.h", + "include/mlir-c/BuiltinAttributes.h", + "include/mlir-c/BuiltinTypes.h", + "include/mlir-c/Diagnostics.h", + "include/mlir-c/Dialect/Standard.h", + "include/mlir-c/ExecutionEngine.h", + "include/mlir-c/IR.h", + "include/mlir-c/IntegerSet.h", + "include/mlir-c/Pass.h", + "include/mlir-c/Registration.h", + "include/mlir-c/Support.h", + "include/mlir/CAPI/AffineExpr.h", + "include/mlir/CAPI/AffineMap.h", + "include/mlir/CAPI/Diagnostics.h", + "include/mlir/CAPI/IR.h", + "include/mlir/CAPI/IntegerSet.h", + "include/mlir/CAPI/Pass.h", + "include/mlir/CAPI/Registration.h", + "include/mlir/CAPI/Support.h", + "include/mlir/CAPI/Utils.h", + "include/mlir/CAPI/Wrap.h", + ], + includes = ["include"], + deps = [ + ":ConversionPassIncGen", + ":IR", + ":InferTypeOpInterface", + ":Parser", + ":Pass", + ":StandardOps", + ":Support", + "//llvm:Support", + ], +) + +cc_library( + name = "CAPIAsync", + srcs = [ + "lib/CAPI/Dialect/Async.cpp", + "lib/CAPI/Dialect/AsyncPasses.cpp", + ], + hdrs = [ + "include/mlir-c/Dialect/Async.h", + ], + includes = ["include"], + deps = [ + ":Async", + ":AsyncPassIncGen", + ":AsyncTransforms", + ":CAPIIR", + ":Pass", + ], +) + +cc_library( + name = "CAPILinalg", + srcs = [ + "lib/CAPI/Dialect/Linalg.cpp", + "lib/CAPI/Dialect/LinalgPasses.cpp", + ], + hdrs = [ + "include/mlir-c/Dialect/Linalg.h", + ], + includes = ["include"], + deps = [ + ":CAPIIR", + ":LinalgOps", + ":LinalgPassIncGen", + ":LinalgTransforms", + ":Pass", + ], +) + +cc_library( + name = "CAPIGPU", + srcs = [ + "lib/CAPI/Dialect/GPU.cpp", + "lib/CAPI/Dialect/GPUPasses.cpp", + ], + hdrs = [ + "include/mlir-c/Dialect/GPU.h", + ], + includes = ["include"], + deps = [ + ":CAPIIR", + ":GPUDialect", + ":GPUPassIncGen", + ":GPUTransforms", + ":Pass", + ], +) + +cc_library( + name = "CAPISparseTensor", + srcs = [ + "lib/CAPI/Dialect/SparseTensor.cpp", + "lib/CAPI/Dialect/SparseTensorPasses.cpp", + ], + hdrs = [ + "include/mlir-c/Dialect/SparseTensor.h", + ], + includes = ["include"], + deps = [ + ":CAPIIR", + ":Pass", + ":SparseTensor", + ":SparseTensorPassIncGen", + ":SparseTensorTransforms", + ":Support", + ], +) + +cc_library( + name = "CAPIConversion", + srcs = ["lib/CAPI/Conversion/Passes.cpp"], + hdrs = ["include/mlir-c/Conversion.h"], + includes = ["include"], + deps = [ + ":CAPIIR", + ":ConversionPassIncGen", + ":ConversionPasses", + ":Pass", + ], +) + +cc_library( + name = "CAPIDebug", + srcs = ["lib/CAPI/Debug/Debug.cpp"], + hdrs = ["include/mlir-c/Debug.h"], + includes = ["include"], + deps = [ + ":CAPIIR", + ":Support", + "//llvm:Support", + ], +) + +cc_library( + name = "CAPIExecutionEngine", + srcs = ["lib/CAPI/ExecutionEngine/ExecutionEngine.cpp"], + hdrs = [ + "include/mlir-c/ExecutionEngine.h", + "include/mlir/CAPI/ExecutionEngine.h", + ], + includes = ["include"], + deps = [ + ":CAPIIR", + ":ExecutionEngine", + ":ExecutionEngineUtils", + ":LLVMToLLVMIRTranslation", + "//llvm:OrcJIT", + "//llvm:Support", + ], +) + +cc_library( + name = "CAPITransforms", + srcs = ["lib/CAPI/Transforms/Passes.cpp"], + hdrs = ["include/mlir-c/Transforms.h"], + includes = ["include"], + deps = [ + ":CAPIIR", + ":Pass", + ":Transforms", + ":TransformsPassIncGen", + ], +) + +cc_library( + name = "CAPIRegistration", + srcs = ["lib/CAPI/Registration/Registration.cpp"], + hdrs = ["include/mlir-c/Registration.h"], + includes = ["include"], + deps = [ + ":AllPassesAndDialects", + ":CAPIIR", + ":LLVMToLLVMIRTranslation", + ], +) + +##---------------------------------------------------------------------------## +# Sources of Python bindings. +#----------------------------------------------------------------------------## + +exports_files( + glob(["lib/Bindings/Python/**/*.cpp"]), +) + +cc_library( + name = "MLIRBindingsPythonHeadersAndDeps", + includes = [ + "include", + "lib/Bindings/Python", + ], + tags = [ + "manual", # External dependency + "nobuildkite", # TODO(gcmn): Add support for this target + ], + textual_hdrs = glob([ + "lib/Bindings/Python/*.h", + "include/mlir-c/Bindings/Python/*.h", + "include/mlir/Bindings/Python/*.h", + ]), + deps = [ + ":CAPIIR", + "@pybind11", + "@python_runtime//:headers", + ], +) + +cc_library( + name = "MLIRBindingsPythonCore", + srcs = glob( + include = ["lib/Bindings/Python/*.cpp"], + exclude = ["lib/Bindings/Python/MainModule.cpp"], + ), + # These flags are needed for pybind11 to work. + copts = [ + "-fexceptions", + "-frtti", + ], + features = [ + # Cannot use header_modules (parse_headers feature fails). + "-use_header_modules", + ], + tags = [ + "manual", # External dependency + "nobuildkite", # TODO(gcmn): Add support for this target + ], + deps = [ + ":CAPIAsync", + ":CAPIDebug", + ":CAPIExecutionEngine", + ":CAPIGPU", + ":CAPIIR", + ":CAPILinalg", + ":CAPIRegistration", + ":CAPISparseTensor", + ":MLIRBindingsPythonHeadersAndDeps", + "//llvm:Support", + "@pybind11", + "@python_runtime//:headers", + ], +) + +PYBIND11_COPTS = [ + "-fexceptions", + "-frtti", +] + +PYBIND11_FEATURES = [ + # Cannot use header_modules (parse_headers feature fails). + "-use_header_modules", +] + +# Dynamic library with the MLIR Python extension. +cc_binary( + name = "_mlir.so", + srcs = ["lib/Bindings/Python/MainModule.cpp"], + # These flags are needed for pybind11 to work. + copts = PYBIND11_COPTS, + features = PYBIND11_FEATURES, + linkshared = 1, + linkstatic = 0, + tags = [ + "manual", # External dependency + "nobuildkite", # TODO(gcmn): Add support for this target + ], + deps = [ + ":MLIRBindingsPythonCore", + ":MLIRBindingsPythonHeadersAndDeps", + ], +) + +# Dynamlic library with the MLIR Conversions Python extension. +cc_binary( + name = "_mlirConversions.so", + srcs = ["lib/Bindings/Python/Conversions/Conversions.cpp"], + copts = PYBIND11_COPTS, + features = PYBIND11_FEATURES, + linkshared = 1, + linkstatic = 0, + tags = [ + "manual", # External dependency + "nobuildkite", # TODO(gcmn): Add support for this target + ], + deps = [ + ":CAPIConversion", + ":MLIRBindingsPythonHeadersAndDeps", + "@pybind11", + "@python_runtime//:headers", + ], +) + +# Dynamlic library with the MLIR Transforms Python extension. +cc_binary( + name = "_mlirTransforms.so", + srcs = ["lib/Bindings/Python/Transforms/Transforms.cpp"], + copts = PYBIND11_COPTS, + features = PYBIND11_FEATURES, + linkshared = 1, + linkstatic = 0, + tags = [ + "manual", # External dependency + "nobuildkite", # TODO(gcmn): Add support for this target + ], + deps = [ + ":CAPITransforms", + ":MLIRBindingsPythonHeadersAndDeps", + "@pybind11", + "@python_runtime//:headers", + ], +) + +# Dynamic library with the MLIR Linalg dialect+passes Python extension. +cc_binary( + name = "_mlirLinalgPasses.so", + srcs = ["lib/Bindings/Python/LinalgPasses.cpp"], + copts = PYBIND11_COPTS, + features = PYBIND11_FEATURES, + linkshared = 1, + linkstatic = 0, + tags = [ + "manual", # External dependency + "nobuildkite", # TODO(gcmn): Add support for this target + ], + deps = [ + ":CAPILinalg", + ":MLIRBindingsPythonHeadersAndDeps", + "@pybind11", + "@python_runtime//:headers", + ], +) + +##---------------------------------------------------------------------------## + +td_library( + name = "OpBaseTdFiles", + srcs = [ + "include/mlir/IR/OpAsmInterface.td", + "include/mlir/IR/OpBase.td", + "include/mlir/IR/RegionKindInterface.td", + "include/mlir/IR/SymbolInterfaces.td", + "include/mlir/IR/TensorEncoding.td", + ], + includes = ["include"], +) + +td_library( + name = "CallInterfacesTdFiles", + srcs = ["include/mlir/Interfaces/CallInterfaces.td"], + includes = ["include"], + deps = [":OpBaseTdFiles"], +) + +td_library( + name = "CastInterfacesTdFiles", + srcs = ["include/mlir/Interfaces/CastInterfaces.td"], + includes = ["include"], + deps = [":OpBaseTdFiles"], +) + +td_library( + name = "ControlFlowInterfacesTdFiles", + srcs = ["include/mlir/Interfaces/ControlFlowInterfaces.td"], + includes = ["include"], + deps = [":OpBaseTdFiles"], +) + +td_library( + name = "CopyOpInterfaceTdFiles", + srcs = ["include/mlir/Interfaces/CopyOpInterface.td"], + includes = ["include"], + deps = [":OpBaseTdFiles"], +) + +td_library( + name = "DerivedAttributeOpInterfaceTdFiles", + srcs = ["include/mlir/Interfaces/DerivedAttributeOpInterface.td"], + includes = ["include"], + deps = [":OpBaseTdFiles"], +) + +td_library( + name = "InferTypeOpInterfaceTdFiles", + srcs = ["include/mlir/Interfaces/InferTypeOpInterface.td"], + includes = ["include"], + deps = [":OpBaseTdFiles"], +) + +td_library( + name = "LoopLikeInterfaceTdFiles", + srcs = ["include/mlir/Interfaces/LoopLikeInterface.td"], + includes = ["include"], + deps = [":OpBaseTdFiles"], +) + +td_library( + name = "SideEffectInterfacesTdFiles", + srcs = [ + "include/mlir/Interfaces/SideEffectInterfaceBase.td", + "include/mlir/Interfaces/SideEffectInterfaces.td", + ], + includes = ["include"], + deps = [":OpBaseTdFiles"], +) + +alias( + name = "SideEffectTdFiles", + actual = ":SideEffectInterfacesTdFiles", +) + +td_library( + name = "VectorInterfacesTdFiles", + srcs = ["include/mlir/Interfaces/VectorInterfaces.td"], + includes = ["include"], + deps = [":OpBaseTdFiles"], +) + +td_library( + name = "ViewLikeInterfaceTdFiles", + srcs = ["include/mlir/Interfaces/ViewLikeInterface.td"], + includes = ["include"], + deps = [":OpBaseTdFiles"], +) + +td_library( + name = "ReducerTdFiles", + srcs = ["include/mlir/Reducer/Passes.td"], + includes = ["include"], + deps = [":OpBaseTdFiles"], +) + +##---------------------------------------------------------------------------## +# Affine dialect. +##---------------------------------------------------------------------------## + +td_library( + name = "PassBaseTdFiles", + srcs = ["include/mlir/Pass/PassBase.td"], + includes = ["include"], +) + +td_library( + name = "RewritePassBaseTdFiles", + srcs = ["include/mlir/Rewrite/PassUtil.td"], + includes = ["include"], +) + +td_library( + name = "AffineOpsTdFiles", + srcs = [ + "include/mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.td", + "include/mlir/Dialect/Affine/IR/AffineOps.td", + ], + includes = ["include"], + deps = [ + ":LoopLikeInterfaceTdFiles", + ":OpBaseTdFiles", + ":SideEffectInterfacesTdFiles", + ":StdOpsTdFiles", + ], +) + +gentbl_cc_library( + name = "AffineOpsIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-decls"], + "include/mlir/Dialect/Affine/IR/AffineOps.h.inc", + ), + ( + ["-gen-op-defs"], + "include/mlir/Dialect/Affine/IR/AffineOps.cpp.inc", + ), + ( + ["-gen-dialect-decls"], + "include/mlir/Dialect/Affine/IR/AffineOpsDialect.h.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/Affine/IR/AffineOps.td", + deps = [":AffineOpsTdFiles"], +) + +gentbl_cc_library( + name = "AffineMemoryOpInterfacesIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-interface-decls"], + "include/mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.h.inc", + ), + ( + ["-gen-op-interface-defs"], + "include/mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.td", + deps = [":AffineOpsTdFiles"], +) + +##---------------------------------------------------------------------------## +# EmitC dialect. +##---------------------------------------------------------------------------## + +td_library( + name = "EmitCTdFiles", + srcs = [ + "include/mlir/Dialect/EmitC/IR/EmitC.td", + "include/mlir/Dialect/EmitC/IR/EmitCAttributes.td", + "include/mlir/Dialect/EmitC/IR/EmitCBase.td", + "include/mlir/Dialect/EmitC/IR/EmitCTypes.td", + ], + includes = ["include"], + deps = [ + ":OpBaseTdFiles", + ":SideEffectInterfacesTdFiles", + ], +) + +gentbl_cc_library( + name = "EmitCAttributesIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["--gen-attrdef-decls"], + "include/mlir/Dialect/EmitC/IR/EmitCAttributes.h.inc", + ), + ( + ["--gen-attrdef-defs"], + "include/mlir/Dialect/EmitC/IR/EmitCAttributes.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/EmitC/IR/EmitCAttributes.td", + deps = [":EmitCTdFiles"], +) + +gentbl_cc_library( + name = "EmitCOpsIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-dialect-decls"], + "include/mlir/Dialect/EmitC/IR/EmitCDialect.h.inc", + ), + ( + ["-gen-op-decls"], + "include/mlir/Dialect/EmitC/IR/EmitC.h.inc", + ), + ( + ["-gen-op-defs"], + "include/mlir/Dialect/EmitC/IR/EmitC.cpp.inc", + ), + ( + ["-gen-typedef-decls"], + "include/mlir/Dialect/EmitC/IR/EmitCTypes.h.inc", + ), + ( + ["-gen-typedef-defs"], + "include/mlir/Dialect/EmitC/IR/EmitCTypes.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/EmitC/IR/EmitC.td", + deps = [":EmitCTdFiles"], +) + +##---------------------------------------------------------------------------## +# Async dialect. +##---------------------------------------------------------------------------## + +td_library( + name = "AsyncOpsTdFiles", + srcs = [ + "include/mlir/Dialect/Async/IR/AsyncDialect.td", + "include/mlir/Dialect/Async/IR/AsyncOps.td", + "include/mlir/Dialect/Async/IR/AsyncTypes.td", + ], + includes = ["include"], + deps = [ + ":ControlFlowInterfacesTdFiles", + ":OpBaseTdFiles", + ":SideEffectInterfacesTdFiles", + ], +) + +gentbl_cc_library( + name = "AsyncOpsIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-decls"], + "include/mlir/Dialect/Async/IR/AsyncOps.h.inc", + ), + ( + ["-gen-op-defs"], + "include/mlir/Dialect/Async/IR/AsyncOps.cpp.inc", + ), + ( + ["-gen-dialect-decls"], + "include/mlir/Dialect/Async/IR/AsyncOpsDialect.h.inc", + ), + ( + ["-gen-typedef-decls"], + "include/mlir/Dialect/Async/IR/AsyncOpsTypes.h.inc", + ), + ( + ["-gen-typedef-defs"], + "include/mlir/Dialect/Async/IR/AsyncOpsTypes.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/Async/IR/AsyncOps.td", + deps = [":AsyncOpsTdFiles"], +) + +gentbl_cc_library( + name = "AsyncPassIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + [ + "-gen-pass-decls", + "-name=Async", + ], + "include/mlir/Dialect/Async/Passes.h.inc", + ), + ( + [ + "-gen-pass-capi-header", + "--prefix=Async", + ], + "include/mlir/Dialect/Async/Passes.capi.h.inc", + ), + ( + [ + "-gen-pass-capi-impl", + "--prefix=Async", + ], + "include/mlir/Dialect/Async/Passes.capi.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/Async/Passes.td", + deps = [":PassBaseTdFiles"], +) + +##---------------------------------------------------------------------------## +# ArmNeon dialect. +##---------------------------------------------------------------------------## + +td_library( + name = "ArmNeonTdFiles", + srcs = ["include/mlir/Dialect/ArmNeon/ArmNeon.td"], + includes = ["include"], + deps = [ + ":LLVMOpsTdFiles", + ":OpBaseTdFiles", + ":SideEffectInterfacesTdFiles", + ], +) + +gentbl_cc_library( + name = "ArmNeonIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + [ + "-gen-dialect-decls", + "-dialect=arm_neon", + ], + "include/mlir/Dialect/ArmNeon/ArmNeonDialect.h.inc", + ), + ( + ["-gen-op-decls"], + "include/mlir/Dialect/ArmNeon/ArmNeon.h.inc", + ), + ( + ["-gen-op-defs"], + "include/mlir/Dialect/ArmNeon/ArmNeon.cpp.inc", + ), + ( + ["-gen-op-doc"], + "g3doc/Dialects/ArmNeon/ArmNeon.md", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/ArmNeon/ArmNeon.td", + deps = [":ArmNeonTdFiles"], +) + +cc_library( + name = "ArmNeon", + srcs = ["lib/Dialect/ArmNeon/IR/ArmNeonDialect.cpp"], + hdrs = ["include/mlir/Dialect/ArmNeon/ArmNeonDialect.h"], + includes = ["include"], + deps = [ + ":ArmNeonIncGen", + ":IR", + ":SideEffectInterfaces", + ":VectorOps", + "//llvm:Core", + "//llvm:Support", + ], +) + +gentbl_cc_library( + name = "ArmNeonConversionIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-llvmir-conversions"], + "include/mlir/Dialect/ArmNeon/ArmNeonConversions.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/ArmNeon/ArmNeon.td", + deps = [":ArmNeonTdFiles"], +) + +cc_library( + name = "ArmNeon2dToIntr", + srcs = glob([ + "lib/Conversion/ArmNeon2dToIntr/*.cpp", + "lib/Conversion/ArmNeon2dToIntr/*.h", + ]) + ["lib/Conversion/PassDetail.h"], + hdrs = glob([ + "include/mlir/Conversion/ArmNeon2dToIntr/*.h", + ]), + includes = ["include"], + deps = [ + ":ArmNeon", + ":ConversionPassIncGen", + ":IR", + ":MemRefDialect", + ":OpenACCDialect", + ":Pass", + ":SCFDialect", + ":StandardOps", + ":Support", + ":Transforms", + ":VectorOps", + ], +) + +##---------------------------------------------------------------------------## +# ArmSVE dialect. +##---------------------------------------------------------------------------## + +td_library( + name = "ArmSVETdFiles", + srcs = [ + "include/mlir/Dialect/ArmSVE/ArmSVE.td", + "include/mlir/Dialect/ArmSVE/ArmSVEOpBase.td", + ], + includes = ["include"], + deps = [ + ":LLVMOpsTdFiles", + ":OpBaseTdFiles", + ":SideEffectInterfacesTdFiles", + ":StdOpsTdFiles", + ], +) + +gentbl_cc_library( + name = "ArmSVEIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-decls"], + "include/mlir/Dialect/ArmSVE/ArmSVE.h.inc", + ), + ( + ["-gen-op-defs"], + "include/mlir/Dialect/ArmSVE/ArmSVE.cpp.inc", + ), + ( + ["-gen-typedef-decls"], + "include/mlir/Dialect/ArmSVE/ArmSVETypes.h.inc", + ), + ( + ["-gen-typedef-defs"], + "include/mlir/Dialect/ArmSVE/ArmSVETypes.cpp.inc", + ), + ( + [ + "-gen-dialect-decls", + "-dialect=arm_sve", + ], + "include/mlir/Dialect/ArmSVE/ArmSVEDialect.h.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/ArmSVE/ArmSVE.td", + deps = [":ArmSVETdFiles"], +) + +cc_library( + name = "ArmSVE", + srcs = ["lib/Dialect/ArmSVE/IR/ArmSVEDialect.cpp"], + hdrs = ["include/mlir/Dialect/ArmSVE/ArmSVEDialect.h"], + includes = ["include"], + deps = [ + ":ArmSVEIncGen", + ":IR", + ":LLVMDialect", + ":SideEffectInterfaces", + ":StandardOps", + ":VectorOps", + "//llvm:Core", + "//llvm:Support", + ], +) + +cc_library( + name = "ArmSVETransforms", + srcs = glob(["lib/Dialect/ArmSVE/Transforms/*.cpp"]), + hdrs = ["include/mlir/Dialect/ArmSVE/Transforms.h"], + includes = ["include"], + deps = [ + ":ArmSVE", + ":IR", + ":LLVMDialect", + ":Pass", + ":StandardOps", + ":StandardToLLVM", + ":TransformUtils", + "//llvm:Core", + "//llvm:Support", + ], +) + +gentbl_cc_library( + name = "ArmSVEConversionIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-llvmir-conversions"], + "include/mlir/Dialect/ArmSVE/ArmSVEConversions.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/ArmSVE/ArmSVE.td", + deps = [":ArmSVETdFiles"], +) + +##---------------------------------------------------------------------------## +# AMX dialect. +##---------------------------------------------------------------------------## + +td_library( + name = "AMXTdFiles", + srcs = ["include/mlir/Dialect/AMX/AMX.td"], + includes = ["include"], + deps = [ + ":LLVMOpsTdFiles", + ":SideEffectInterfacesTdFiles", + ], +) + +gentbl_cc_library( + name = "AMXIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + [ + "-gen-dialect-decls", + "-dialect=amx", + ], + "include/mlir/Dialect/AMX/AMXDialect.h.inc", + ), + ( + ["-gen-op-decls"], + "include/mlir/Dialect/AMX/AMX.h.inc", + ), + ( + ["-gen-op-defs"], + "include/mlir/Dialect/AMX/AMX.cpp.inc", + ), + ( + ["-gen-op-doc"], + "g3doc/Dialects/AMX/AMX.md", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/AMX/AMX.td", + deps = [":AMXTdFiles"], +) + +cc_library( + name = "AMX", + srcs = ["lib/Dialect/AMX/IR/AMXDialect.cpp"], + hdrs = ["include/mlir/Dialect/AMX/AMXDialect.h"], + includes = ["include"], + deps = [ + ":AMXIncGen", + ":IR", + ":LLVMDialect", + ":SideEffectInterfaces", + "//llvm:Core", + "//llvm:Support", + ], +) + +cc_library( + name = "AMXTransforms", + srcs = glob(["lib/Dialect/AMX/Transforms/*.cpp"]), + hdrs = ["include/mlir/Dialect/AMX/Transforms.h"], + includes = ["include"], + deps = [ + ":AMX", + ":IR", + ":LLVMDialect", + ":StandardOps", + ":StandardToLLVM", + "//llvm:Core", + "//llvm:Support", + ], +) + +gentbl_cc_library( + name = "AMXConversionIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-llvmir-conversions"], + "include/mlir/Dialect/AMX/AMXConversions.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/AMX/AMX.td", + deps = [":AMXTdFiles"], +) + +##---------------------------------------------------------------------------## +# X86Vector dialect. +##---------------------------------------------------------------------------## + +td_library( + name = "X86VectorTdFiles", + srcs = ["include/mlir/Dialect/X86Vector/X86Vector.td"], + includes = ["include"], + deps = [ + ":LLVMOpsTdFiles", + ":SideEffectInterfacesTdFiles", + ], +) + +gentbl_cc_library( + name = "X86VectorIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + [ + "-gen-dialect-decls", + "-dialect=x86vector", + ], + "include/mlir/Dialect/X86Vector/X86VectorDialect.h.inc", + ), + ( + ["-gen-op-decls"], + "include/mlir/Dialect/X86Vector/X86Vector.h.inc", + ), + ( + ["-gen-op-defs"], + "include/mlir/Dialect/X86Vector/X86Vector.cpp.inc", + ), + ( + ["-gen-op-doc"], + "g3doc/Dialects/X86Vector/X86Vector.md", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/X86Vector/X86Vector.td", + deps = [":X86VectorTdFiles"], +) + +cc_library( + name = "X86Vector", + srcs = ["lib/Dialect/X86Vector/IR/X86VectorDialect.cpp"], + hdrs = ["include/mlir/Dialect/X86Vector/X86VectorDialect.h"], + includes = ["include"], + deps = [ + ":IR", + ":LLVMDialect", + ":SideEffectInterfaces", + ":X86VectorIncGen", + "//llvm:Core", + "//llvm:Support", + ], +) + +cc_library( + name = "X86VectorTransforms", + srcs = glob(["lib/Dialect/X86Vector/Transforms/*.cpp"]), + hdrs = ["include/mlir/Dialect/X86Vector/Transforms.h"], + includes = ["include"], + deps = [ + ":IR", + ":LLVMDialect", + ":StandardOps", + ":StandardToLLVM", + ":X86Vector", + "//llvm:Core", + "//llvm:Support", + ], +) + +gentbl_cc_library( + name = "X86VectorConversionIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-llvmir-conversions"], + "include/mlir/Dialect/X86Vector/X86VectorConversions.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/X86Vector/X86Vector.td", + deps = [":X86VectorTdFiles"], +) + +##---------------------------------------------------------------------------## +# SCF dialect. +##---------------------------------------------------------------------------## + +td_library( + name = "SCFTdFiles", + srcs = ["include/mlir/Dialect/SCF/SCFOps.td"], + includes = ["include"], + deps = [ + ":ControlFlowInterfacesTdFiles", + ":LoopLikeInterfaceTdFiles", + ":SideEffectInterfacesTdFiles", + ], +) + +gentbl_cc_library( + name = "SCFIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-decls"], + "include/mlir/Dialect/SCF/SCFOps.h.inc", + ), + ( + ["-gen-op-defs"], + "include/mlir/Dialect/SCF/SCFOps.cpp.inc", + ), + ( + ["-gen-dialect-decls"], + "include/mlir/Dialect/SCF/SCFOpsDialect.h.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/SCF/SCFOps.td", + deps = [":SCFTdFiles"], +) + +gentbl_cc_library( + name = "SCFPassIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + [ + "-gen-pass-decls", + "-name=SCF", + ], + "include/mlir/Dialect/SCF/Passes.h.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/SCF/Passes.td", + deps = [":PassBaseTdFiles"], +) + +cc_library( + name = "SCFTransforms", + srcs = glob([ + "lib/Dialect/SCF/Transforms/*.cpp", + "lib/Dialect/SCF/Transforms/*.h", + ]), + hdrs = ["include/mlir/Dialect/SCF/Passes.h"], + includes = ["include"], + deps = [ + ":Affine", + ":IR", + ":MemRefDialect", + ":Pass", + ":SCFDialect", + ":SCFPassIncGen", + ":StandardOps", + ":Transforms", + "//llvm:Support", + ], +) + +##---------------------------------------------------------------------------## +# SparseTensor dialect. +##---------------------------------------------------------------------------## + +td_library( + name = "SparseTensorTdFiles", + srcs = [ + "include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.td", + "include/mlir/Dialect/SparseTensor/IR/SparseTensorBase.td", + "include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td", + ], + includes = ["include"], + deps = [ + ":OpBaseTdFiles", + ":SideEffectInterfacesTdFiles", + ], +) + +gentbl_cc_library( + name = "SparseTensorAttrDefsIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["--gen-attrdef-decls"], + "include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.h.inc", + ), + ( + ["--gen-attrdef-defs"], + "include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.td", + deps = [":SparseTensorTdFiles"], +) + +gentbl_cc_library( + name = "SparseTensorOpsIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + [ + "-gen-dialect-decls", + "-dialect=sparse_tensor", + ], + "include/mlir/Dialect/SparseTensor/IR/SparseTensorOpsDialect.h.inc", + ), + ( + ["-gen-op-decls"], + "include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.h.inc", + ), + ( + ["-gen-op-defs"], + "include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.cpp.inc", + ), + ( + ["-gen-op-doc"], + "g3doc/Dialects/SparseTensor/SparseTensor.md", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td", + deps = [":SparseTensorTdFiles"], +) + +gentbl_cc_library( + name = "SparseTensorPassIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + [ + "-gen-pass-decls", + "-name=SparseTensor", + ], + "include/mlir/Dialect/SparseTensor/Transforms/Passes.h.inc", + ), + ( + [ + "-gen-pass-capi-header", + "--prefix=SparseTensor", + ], + "include/mlir/Dialect/SparseTensor/Transforms/Passes.capi.h.inc", + ), + ( + [ + "-gen-pass-capi-impl", + "--prefix=SparseTensor", + ], + "include/mlir/Dialect/SparseTensor/Transforms/Passes.capi.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/SparseTensor/Transforms/Passes.td", + deps = [":PassBaseTdFiles"], +) + +cc_library( + name = "SparseTensor", + srcs = glob(["lib/Dialect/SparseTensor/IR/*.cpp"]), + hdrs = ["include/mlir/Dialect/SparseTensor/IR/SparseTensor.h"], + includes = ["include"], + deps = [ + ":IR", + ":SideEffectInterfaces", + ":SparseTensorAttrDefsIncGen", + ":SparseTensorOpsIncGen", + ":StandardOps", + "//llvm:Support", + ], +) + +cc_library( + name = "SparseTensorTransforms", + srcs = glob(["lib/Dialect/SparseTensor/Transforms/*.cpp"]), + hdrs = ["include/mlir/Dialect/SparseTensor/Transforms/Passes.h"], + includes = ["include"], + deps = [ + ":IR", + ":LLVMDialect", + ":LinalgOps", + ":LinalgTransforms", + ":MemRefDialect", + ":Pass", + ":SCFDialect", + ":SparseTensor", + ":SparseTensorPassIncGen", + ":StandardOps", + ":StandardOpsTransforms", + ":TensorDialect", + ":Transforms", + ":VectorOps", + "//llvm:Support", + ], +) + +td_library( + name = "StdOpsTdFiles", + srcs = [ + "include/mlir/Dialect/StandardOps/IR/Ops.td", + "include/mlir/Dialect/StandardOps/IR/StandardOpsBase.td", + ], + includes = ["include"], + deps = [ + ":CallInterfacesTdFiles", + ":CastInterfacesTdFiles", + ":ControlFlowInterfacesTdFiles", + ":OpBaseTdFiles", + ":SideEffectInterfacesTdFiles", + ":VectorInterfacesTdFiles", + ":ViewLikeInterfaceTdFiles", + ], +) + +gentbl_cc_library( + name = "StandardOpsIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-decls"], + "include/mlir/Dialect/StandardOps/IR/Ops.h.inc", + ), + ( + ["-gen-op-defs"], + "include/mlir/Dialect/StandardOps/IR/Ops.cpp.inc", + ), + ( + ["-gen-dialect-decls"], + "include/mlir/Dialect/StandardOps/IR/OpsDialect.h.inc", + ), + ( + ["-gen-enum-decls"], + "include/mlir/Dialect/StandardOps/IR/OpsEnums.h.inc", + ), + ( + ["-gen-enum-defs"], + "include/mlir/Dialect/StandardOps/IR/OpsEnums.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/StandardOps/IR/Ops.td", + deps = [":StdOpsTdFiles"], +) + +cc_library( + name = "Dialect", + srcs = glob([ + "lib/Dialect/*.cpp", + "lib/Dialect/*.h", + ]), + hdrs = glob([ + "include/mlir/Dialect/*.h", + ]), + includes = ["include"], + deps = [ + ":IR", + "//llvm:Support", + ], +) + +cc_library( + name = "DialectUtils", + srcs = glob([ + "lib/Dialect/Utils/*.cpp", + "lib/Dialect/Utils/*.h", + ]), + hdrs = glob([ + "include/mlir/Dialect/Utils/*.h", + ]), + includes = ["include"], + deps = [ + ":IR", + ":Support", + "//llvm:Support", + ], +) + +cc_library( + name = "Affine", + srcs = glob( + [ + "lib/Dialect/Affine/IR/*.cpp", + "lib/Dialect/Affine/IR/*.h", + ], + ) + ["include/mlir/Transforms/InliningUtils.h"], + hdrs = glob([ + "include/mlir/Dialect/Affine/IR/*.h", + ]), + includes = ["include"], + deps = [ + ":AffineMemoryOpInterfacesIncGen", + ":AffineOpsIncGen", + ":IR", + ":LoopLikeInterface", + ":MemRefDialect", + ":SideEffectInterfaces", + ":StandardOps", + ":Support", + "//llvm:Support", + ], +) + +cc_library( + name = "EmitC", + srcs = glob([ + "lib/Dialect/EmitC/IR/*.cpp", + ]), + hdrs = glob([ + "include/mlir/Dialect/EmitC/IR/*.h", + ]), + includes = ["include"], + deps = [ + ":Dialect", + ":EmitCAttributesIncGen", + ":EmitCOpsIncGen", + ":IR", + ":SideEffectInterfaces", + "//llvm:Support", + ], +) + +cc_library( + name = "Async", + srcs = glob([ + "lib/Dialect/Async/IR/*.cpp", + ]), + hdrs = glob([ + "include/mlir/Dialect/Async/IR/*.h", + ]), + includes = ["include"], + deps = [ + ":AsyncOpsIncGen", + ":ControlFlowInterfaces", + ":Dialect", + ":IR", + ":SideEffectInterfaces", + ":StandardOps", + ":Support", + "//llvm:Support", + ], +) + +cc_library( + name = "AsyncTransforms", + srcs = glob([ + "lib/Dialect/Async/Transforms/*.cpp", + "lib/Dialect/Async/Transforms/*.h", + ]), + hdrs = ["include/mlir/Dialect/Async/Passes.h"], + includes = ["include"], + deps = [ + ":Analysis", + ":Async", + ":AsyncPassIncGen", + ":IR", + ":Pass", + ":SCFDialect", + ":StandardOps", + ":Support", + ":TransformUtils", + ":Transforms", + ":TransformsPassIncGen", + "//llvm:Core", + "//llvm:Support", + ], +) + +cc_library( + name = "AffineUtils", + srcs = glob( + [ + "lib/Dialect/Affine/Utils/*.cpp", + "lib/Dialect/Affine/Utils/*.h", + ], + ), + hdrs = ["include/mlir/Dialect/Affine/Utils.h"], + includes = ["include"], + deps = [ + ":Affine", + ":Analysis", + ":IR", + ":Support", + ":TransformUtils", + "//llvm:Support", + ], +) + +gentbl_cc_library( + name = "AffinePassIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + [ + "-gen-pass-decls", + "-name=Affine", + ], + "include/mlir/Dialect/Affine/Passes.h.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/Affine/Passes.td", + deps = [":PassBaseTdFiles"], +) + +cc_library( + name = "AffineTransforms", + srcs = glob([ + "lib/Dialect/Affine/Transforms/*.cpp", + "lib/Dialect/Affine/Transforms/*.h", + ]), + hdrs = ["include/mlir/Dialect/Affine/Passes.h"], + includes = ["include"], + deps = [ + ":Affine", + ":AffinePassIncGen", + ":AffineUtils", + ":Analysis", + ":IR", + ":MemRefDialect", + ":Pass", + ":SCFDialect", + ":StandardOps", + ":Support", + ":Transforms", + ":VectorOps", + "//llvm:Support", + ], +) + +gentbl_cc_library( + name = "ConversionPassIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + [ + "-gen-pass-decls", + "-name=Conversion", + ], + "include/mlir/Conversion/Passes.h.inc", + ), + ( + [ + "-gen-pass-capi-header", + "--prefix=Conversion", + ], + "include/mlir/Conversion/Passes.capi.h.inc", + ), + ( + [ + "-gen-pass-capi-impl", + "--prefix=Conversion", + ], + "include/mlir/Conversion/Passes.capi.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Conversion/Passes.td", + deps = [":PassBaseTdFiles"], +) + +cc_library( + name = "ConversionPasses", + hdrs = ["include/mlir/Conversion/Passes.h"], + includes = ["include"], + deps = [ + ":AffineToStandard", + ":ArmNeon2dToIntr", + ":AsyncToLLVM", + ":ComplexToLLVM", + ":ComplexToStandard", + ":ConversionPassIncGen", + ":GPUToGPURuntimeTransforms", + ":GPUToNVVMTransforms", + ":GPUToROCDLTransforms", + ":GPUToSPIRV", + ":GPUToVulkanTransforms", + ":LinalgToLLVM", + ":LinalgToSPIRV", + ":LinalgToStandard", + ":MathToLibm", + ":OpenACCToLLVM", + ":OpenACCToSCF", + ":OpenMPToLLVM", + ":PDLToPDLInterp", + ":SCFToGPUPass", + ":SCFToOpenMP", + ":SCFToSPIRV", + ":SCFToStandard", + ":SPIRVToLLVM", + ":ShapeToStandard", + ":StandardToLLVM", + ":StandardToSPIRV", + ":TosaToLinalg", + ":TosaToSCF", + ":TosaToStandard", + ":VectorToGPU", + ":VectorToLLVM", + ":VectorToROCDL", + ":VectorToSCF", + ":VectorToSPIRV", + ], +) + +cc_library( + name = "AsyncToLLVM", + srcs = glob([ + "lib/Conversion/AsyncToLLVM/*.cpp", + "lib/Conversion/AsyncToLLVM/*.h", + ]) + ["lib/Conversion/PassDetail.h"], + hdrs = glob(["include/mlir/Conversion/AsyncToLLVM/*.h"]), + includes = ["include"], + deps = [ + ":Async", + ":ConversionPassIncGen", + ":IR", + ":LLVMDialect", + ":Pass", + ":StandardOps", + ":StandardOpsTransforms", + ":StandardToLLVM", + ":Support", + ":Transforms", + "//llvm:Support", + ], +) + +cc_library( + name = "AffineToStandard", + srcs = glob([ + "lib/Conversion/AffineToStandard/*.cpp", + "lib/Conversion/AffineToStandard/*.h", + ]) + ["lib/Conversion/PassDetail.h"], + hdrs = glob(["include/mlir/Conversion/AffineToStandard/*.h"]), + includes = ["include"], + deps = [ + ":Affine", + ":ConversionPassIncGen", + ":IR", + ":MemRefDialect", + ":Pass", + ":SCFDialect", + ":StandardOps", + ":Support", + ":Transforms", + ":VectorOps", + ], +) + +alias( + name = "AffineToStandardTransforms", + actual = "AffineToStandard", +) + +# SDBM dialect only contains attribute components that can be constructed given +# a dialect object, so whenever it is used it must also be registered. Therefore +# we don't split out the registration library for it. +cc_library( + name = "SDBM", + srcs = glob([ + "lib/Dialect/SDBM/*.cpp", + "lib/Dialect/SDBM/*.h", + ]), + hdrs = glob([ + "include/mlir/Dialect/SDBM/*.h", + ]), + includes = ["include"], + deps = [ + ":IR", + ":Support", + "//llvm:Support", + ], +) + +cc_library( + name = "SCFDialect", + srcs = glob( + [ + "lib/Dialect/SCF/*.cpp", + "lib/Dialect/SCF/*.h", + ], + ), + hdrs = glob([ + "include/mlir/Dialect/SCF/*.h", + ]), + includes = ["include"], + deps = [ + ":ControlFlowInterfaces", + ":IR", + ":LoopLikeInterface", + ":MemRefDialect", + ":Pass", + ":SCFIncGen", + ":SCFPassIncGen", + ":StandardOps", + ":Support", + ":TensorDialect", + "//llvm:Support", + ], +) + +cc_library( + name = "LinalgInterfaces", + srcs = ["lib/Dialect/Linalg/IR/LinalgInterfaces.cpp"], + hdrs = ["include/mlir/Dialect/Linalg/IR/LinalgInterfaces.h"], + includes = ["include"], + deps = [ + ":Affine", + ":DialectUtils", + ":IR", + ":LinalgInterfacesIncGen", + ":LinalgStructuredOpsIncGen", + ":MemRefDialect", + ":ViewLikeInterface", + "//llvm:Support", + ], +) + +cc_library( + name = "DataLayoutInterfaces", + srcs = ["lib/Interfaces/DataLayoutInterfaces.cpp"], + hdrs = ["include/mlir/Interfaces/DataLayoutInterfaces.h"], + includes = ["include"], + deps = [ + ":DataLayoutInterfacesIncGen", + ":IR", + "//llvm:Support", + ], +) + +cc_library( + name = "LoopLikeInterface", + srcs = ["lib/Interfaces/LoopLikeInterface.cpp"], + hdrs = ["include/mlir/Interfaces/LoopLikeInterface.h"], + includes = ["include"], + deps = [ + ":IR", + ":LoopLikeInterfaceIncGen", + ], +) + +cc_library( + name = "VectorInterfaces", + srcs = ["lib/Interfaces/VectorInterfaces.cpp"], + hdrs = ["include/mlir/Interfaces/VectorInterfaces.h"], + includes = ["include"], + deps = [ + ":IR", + ":VectorInterfacesIncGen", + ], +) + +cc_library( + name = "ViewLikeInterface", + srcs = ["lib/Interfaces/ViewLikeInterface.cpp"], + hdrs = ["include/mlir/Interfaces/ViewLikeInterface.h"], + includes = ["include"], + deps = [ + ":IR", + ":ViewLikeInterfaceIncGen", + ], +) + +cc_library( + name = "CopyOpInterface", + srcs = ["lib/Interfaces/CopyOpInterface.cpp"], + hdrs = ["include/mlir/Interfaces/CopyOpInterface.h"], + includes = ["include"], + deps = [ + ":CopyOpInterfaceIncGen", + ":IR", + ], +) + +td_library( + name = "ShapeOpsTdFiles", + srcs = [ + "include/mlir/Dialect/Shape/IR/ShapeBase.td", + "include/mlir/Dialect/Shape/IR/ShapeOps.td", + ], + includes = ["include"], + deps = [ + ":ControlFlowInterfacesTdFiles", + ":InferTypeOpInterfaceTdFiles", + ":SideEffectInterfacesTdFiles", + ], +) + +gentbl_cc_library( + name = "ShapeOpsIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-decls"], + "include/mlir/Dialect/Shape/IR/ShapeOps.h.inc", + ), + ( + ["-gen-op-defs"], + "include/mlir/Dialect/Shape/IR/ShapeOps.cpp.inc", + ), + ( + ["-gen-dialect-decls"], + "include/mlir/Dialect/Shape/IR/ShapeOpsDialect.h.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/Shape/IR/ShapeOps.td", + deps = [":ShapeOpsTdFiles"], +) + +gentbl_cc_library( + name = "MLIRShapeCanonicalizationIncGen", + strip_include_prefix = "include/mlir/Dialect/Shape/IR", + tbl_outs = [ + ( + ["-gen-rewriters"], + "include/mlir/Dialect/Shape/IR/ShapeCanonicalization.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "lib/Dialect/Shape/IR/ShapeCanonicalization.td", + deps = [ + ":ShapeOpsTdFiles", + ":StdOpsTdFiles", + ":TensorOpsTdFiles", + ], +) + +cc_library( + name = "Shape", + srcs = glob(["lib/Dialect/Shape/IR/*.cpp"]), + hdrs = ["include/mlir/Dialect/Shape/IR/Shape.h"], + includes = ["include"], + deps = [ + ":CallOpInterfaces", + ":CommonFolders", + ":ControlFlowInterfaces", + ":Dialect", + ":IR", + ":InferTypeOpInterface", + ":MLIRShapeCanonicalizationIncGen", + ":ShapeOpsIncGen", + ":SideEffectInterfaces", + ":StandardOps", + ":Support", + ":TensorDialect", + "//llvm:Support", + ], +) + +gentbl_cc_library( + name = "ShapeToStandardGen", + strip_include_prefix = "lib/Conversion/ShapeToStandard", + tbl_outs = [ + ( + ["-gen-rewriters"], + "lib/Conversion/ShapeToStandard/ShapeToStandard.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "lib/Conversion/ShapeToStandard/ShapeToStandard.td", + deps = [":ShapeOpsTdFiles"], +) + +cc_library( + name = "ShapeToStandard", + srcs = glob([ + "lib/Conversion/ShapeToStandard/*.cpp", + "lib/Conversion/ShapeToStandard/*.h", + ]) + ["lib/Conversion/PassDetail.h"], + hdrs = ["include/mlir/Conversion/ShapeToStandard/ShapeToStandard.h"], + includes = ["include"], + deps = [ + ":ConversionPassIncGen", + ":IR", + ":MemRefDialect", + ":Pass", + ":SCFDialect", + ":Shape", + ":ShapeToStandardGen", + ":StandardOps", + ":Support", + ":TensorDialect", + ":Transforms", + "//llvm:Support", + ], +) + +gentbl_cc_library( + name = "ShapeTransformsPassIncGen", + strip_include_prefix = "include", + tbl_outs = [( + [ + "-gen-pass-decls", + "-name=Shape", + ], + "include/mlir/Dialect/Shape/Transforms/Passes.h.inc", + )], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/Shape/Transforms/Passes.td", + deps = [":PassBaseTdFiles"], +) + +cc_library( + name = "ShapeTransforms", + srcs = glob([ + "lib/Dialect/Shape/Transforms/*.cpp", + "lib/Dialect/Shape/Transforms/*.h", + ]), + hdrs = ["include/mlir/Dialect/Shape/Transforms/Passes.h"], + includes = ["include"], + deps = [ + ":IR", + ":MemRefDialect", + ":Pass", + ":Shape", + ":ShapeTransformsPassIncGen", + ":StandardOps", + ":Transforms", + ], +) + +cc_library( + name = "StandardOps", + srcs = glob( + [ + "lib/Dialect/StandardOps/IR/*.cpp", + "lib/Dialect/StandardOps/IR/*.h", + "lib/Dialect/StandardOps/Utils/*.cpp", + ], + ), + hdrs = glob([ + "include/mlir/Dialect/StandardOps/IR/*.h", + "include/mlir/Dialect/StandardOps/Utils/*.h", + ]) + ["include/mlir/Transforms/InliningUtils.h"], + includes = ["include"], + deps = [ + ":CallOpInterfaces", + ":CastOpInterfaces", + ":CommonFolders", + ":ControlFlowInterfaces", + ":IR", + ":SideEffectInterfaces", + ":StandardOpsIncGen", + ":Support", + ":TensorDialect", + ":VectorInterfaces", + ":ViewLikeInterface", + "//llvm:Support", + ], +) + +gentbl_cc_library( + name = "StandardOpsTransformsPassIncGen", + strip_include_prefix = "include", + tbl_outs = [( + [ + "-gen-pass-decls", + "-name=Standard", + ], + "include/mlir/Dialect/StandardOps/Transforms/Passes.h.inc", + )], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/StandardOps/Transforms/Passes.td", + deps = [":PassBaseTdFiles"], +) + +cc_library( + name = "StandardOpsTransforms", + srcs = glob([ + "lib/Dialect/StandardOps/Transforms/*.cpp", + "lib/Dialect/StandardOps/Transforms/*.h", + ]), + hdrs = glob(["include/mlir/Dialect/StandardOps/Transforms/*.h"]), + includes = ["include"], + deps = [ + ":Affine", + ":IR", + ":MemRefDialect", # TODO: Remove dependency on MemRef dialect + ":Pass", + ":SCFDialect", + ":StandardOps", + ":StandardOpsTransformsPassIncGen", + ":Support", + ":Transforms", + "//llvm:Support", + ], +) + +cc_library( + name = "VectorOps", + srcs = glob( + [ + "lib/Dialect/Vector/*.cpp", + "lib/Dialect/Vector/*.h", + ], + ), + hdrs = glob([ + "include/mlir/Dialect/Vector/*.h", + ]), + includes = ["include"], + deps = [ + ":Affine", + ":AffineUtils", + ":Analysis", + ":DataLayoutInterfaces", + ":DialectUtils", + ":IR", + ":LinalgOps", + ":MemRefDialect", + ":SCFDialect", + ":SideEffectInterfaces", + ":StandardOps", + ":Support", + ":TensorDialect", + ":VectorInterfaces", + ":VectorOpsIncGen", + ":ViewLikeInterface", + "//llvm:Support", + ], +) + +cc_library( + name = "Support", + srcs = glob( + [ + "lib/Support/*.cpp", + "lib/Support/*.h", + ], + exclude = [ + # TODO(jpienaar): Move this out, else Support depends on Analysis/ + "lib/Support/MlirOptMain.cpp", + ], + ), + hdrs = glob( + ["include/mlir/Support/*.h"], + exclude = ["include/mlir/Support/MlirOptMain.h"], + ), + includes = ["include"], + deps = ["//llvm:Support"], +) + +cc_library( + name = "MlirLspServerLib", + srcs = glob( + [ + "lib/Tools/mlir-lsp-server/*.cpp", + "lib/Tools/mlir-lsp-server/*.h", + "lib/Tools/mlir-lsp-server/lsp/*.cpp", + "lib/Tools/mlir-lsp-server/lsp/*.h", + ], + ), + hdrs = glob( + ["include/mlir/Tools/mlir-lsp-server/*.h"], + ), + includes = ["include"], + deps = [ + ":IR", + ":Parser", + ":Support", + "//llvm:Support", + ], +) + +cc_library( + name = "ParserTokenKinds", + # strip_include_prefix does not apply to textual_hdrs. + hdrs = ["lib/Parser/TokenKinds.def"], + strip_include_prefix = "lib/Parser", + textual_hdrs = ["lib/Parser/TokenKinds.def"], +) + +cc_library( + name = "Parser", + srcs = glob([ + "lib/Parser/*.cpp", + "lib/Parser/*.h", + ]), + hdrs = glob([ + "include/mlir/Parser/*.h", + ]) + [ + "include/mlir/Parser.h", + ], + includes = ["include"], + deps = [ + ":IR", + ":ParserTokenKinds", + ":Support", + "//llvm:Support", + ], +) + +gentbl_cc_library( + name = "LLVMDialectInterfaceIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-interface-decls"], + "include/mlir/Dialect/LLVMIR/LLVMOpsInterfaces.h.inc", + ), + ( + ["-gen-op-interface-defs"], + "include/mlir/Dialect/LLVMIR/LLVMOpsInterfaces.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/LLVMIR/LLVMOpsInterfaces.td", + deps = [":LLVMOpsTdFiles"], +) + +gentbl_cc_library( + name = "LLVMDialectAttributesIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["--gen-attrdef-decls"], + "include/mlir/Dialect/LLVMIR/LLVMOpsAttrDefs.h.inc", + ), + ( + ["--gen-attrdef-defs"], + "include/mlir/Dialect/LLVMIR/LLVMOpsAttrDefs.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td", + deps = [":LLVMOpsTdFiles"], +) + +cc_library( + name = "LLVMDialect", + srcs = glob( + [ + "lib/Dialect/LLVMIR/IR/*.cpp", + "lib/Dialect/LLVMIR/IR/*.h", + ], + exclude = [ + "lib/Dialect/LLVMIR/IR/*AMX*.cpp", + "lib/Dialect/LLVMIR/IR/*AMX*.h", + "lib/Dialect/LLVMIR/IR/*ArmSVE*.cpp", + "lib/Dialect/LLVMIR/IR/*ArmSVE*.h", + "lib/Dialect/LLVMIR/IR/NVVM*.cpp", + "lib/Dialect/LLVMIR/IR/NVVM*.h", + "lib/Dialect/LLVMIR/IR/ROCDL*.cpp", + "lib/Dialect/LLVMIR/IR/ROCDL*.h", + "lib/Dialect/LLVMIR/IR/*X86Vector*.cpp", + "lib/Dialect/LLVMIR/IR/*X86Vector*.h", + ], + ), + hdrs = glob( + ["include/mlir/Dialect/LLVMIR/*.h"], + exclude = [ + "include/mlir/Dialect/LLVMIR/*AMX*.h", + "include/mlir/Dialect/LLVMIR/*ArmSVE*.h", + "include/mlir/Dialect/LLVMIR/NVVM*.h", + "include/mlir/Dialect/LLVMIR/ROCDL*.h", + "include/mlir/Dialect/LLVMIR/*X86Vector*.h", + ], + ), + includes = ["include"], + deps = [ + ":ControlFlowInterfaces", + ":DataLayoutInterfaces", + ":IR", + ":LLVMDialectAttributesIncGen", + ":LLVMDialectInterfaceIncGen", + ":LLVMOpsIncGen", + ":SideEffectInterfaces", + ":Support", + "//llvm:AsmParser", + "//llvm:BitReader", + "//llvm:BitWriter", + "//llvm:Core", + "//llvm:Support", + ], +) + +gentbl_cc_library( + name = "LLVMPassIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + [ + "-gen-pass-decls", + "-name=LLVM", + ], + "include/mlir/Dialect/LLVMIR/Transforms/Passes.h.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/LLVMIR/Transforms/Passes.td", + deps = [":PassBaseTdFiles"], +) + +cc_library( + name = "LLVMIRTransforms", + srcs = glob([ + "lib/Dialect/LLVMIR/Transforms/*.cpp", + "lib/Dialect/LLVMIR/Transforms/*.h", + ]), + hdrs = glob(["include/mlir/Dialect/LLVMIR/Transforms/*.h"]), + includes = ["include"], + deps = [ + ":IR", + ":LLVMDialect", + ":LLVMPassIncGen", + ":Pass", + ], +) + +td_library( + name = "GPUOpsTdFiles", + srcs = [ + "include/mlir/Dialect/GPU/GPUBase.td", + "include/mlir/Dialect/GPU/GPUOps.td", + ], + includes = ["include"], + deps = [ + ":DLTIDialectTdFiles", + ":DataLayoutInterfacesTdFiles", + ":LLVMOpsTdFiles", + ":OpBaseTdFiles", + ":SideEffectInterfacesTdFiles", + ], +) + +gentbl_cc_library( + name = "ParallelLoopMapperAttrGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-struct-attr-decls"], + "include/mlir/Dialect/GPU/ParallelLoopMapperAttr.h.inc", + ), + ( + ["-gen-struct-attr-defs"], + "include/mlir/Dialect/GPU/ParallelLoopMapperAttr.cpp.inc", + ), + ( + ["-gen-enum-decls"], + "include/mlir/Dialect/GPU/ParallelLoopMapperEnums.h.inc", + ), + ( + ["-gen-enum-defs"], + "include/mlir/Dialect/GPU/ParallelLoopMapperEnums.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/GPU/ParallelLoopMapperAttr.td", + deps = [":GPUOpsTdFiles"], +) + +gentbl_cc_library( + name = "GPUBaseIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + [ + "-gen-dialect-decls", + "-dialect=gpu", + ], + "include/mlir/Dialect/GPU/GPUOpsDialect.h.inc", + ), + ( + ["-gen-op-interface-decls"], + "include/mlir/Dialect/GPU/GPUOpInterfaces.h.inc", + ), + ( + ["-gen-op-interface-defs"], + "include/mlir/Dialect/GPU/GPUOpInterfaces.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/GPU/GPUBase.td", + deps = [":GPUOpsTdFiles"], +) + +gentbl_cc_library( + name = "GPUOpsIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-decls"], + "include/mlir/Dialect/GPU/GPUOps.h.inc", + ), + ( + ["-gen-op-defs"], + "include/mlir/Dialect/GPU/GPUOps.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/GPU/GPUOps.td", + deps = [ + ":DLTIDialectTdFiles", + ":GPUOpsTdFiles", + ], +) + +cc_library( + name = "GPUDialect", + srcs = glob( + [ + "lib/Dialect/GPU/IR/*.cpp", + "lib/Dialect/GPU/IR/*.h", + ], + ), + hdrs = ["include/mlir/Dialect/GPU/GPUDialect.h"], + includes = ["include"], + deps = [ + ":DLTIDialect", + ":GPUBaseIncGen", + ":GPUOpsIncGen", + ":IR", + ":LLVMDialect", + ":MemRefDialect", + ":SideEffectInterfaces", + ":StandardOps", + ":Support", + "//llvm:Support", + ], +) + +gentbl_cc_library( + name = "GPUPassIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + [ + "-gen-pass-decls", + "-name=GPU", + ], + "include/mlir/Dialect/GPU/Passes.h.inc", + ), + ( + [ + "-gen-pass-capi-header", + "--prefix=GPU", + ], + "include/mlir/Dialect/GPU/Passes.capi.h.inc", + ), + ( + [ + "-gen-pass-capi-impl", + "--prefix=GPU", + ], + "include/mlir/Dialect/GPU/Passes.capi.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/GPU/Passes.td", + deps = [":PassBaseTdFiles"], +) + +cc_library( + name = "GPUTransforms", + srcs = glob( + [ + "lib/Dialect/GPU/Transforms/*.cpp", + "lib/Dialect/GPU/Transforms/*.h", + ], + ), + hdrs = [ + "include/mlir/Dialect/GPU/MemoryPromotion.h", + "include/mlir/Dialect/GPU/ParallelLoopMapper.h", + "include/mlir/Dialect/GPU/Passes.h", + "include/mlir/Dialect/GPU/Utils.h", + ], + defines = if_cuda_available(["MLIR_GPU_TO_CUBIN_PASS_ENABLE"]), + includes = ["include"], + deps = [ + ":Async", + ":GPUDialect", + ":GPUPassIncGen", + ":MemRefDialect", + ":IR", + ":ParallelLoopMapperAttrGen", + ":Pass", + ":SCFDialect", + ":StandardOps", + ":Support", + ":Transforms", + ":ToLLVMIRTranslation", + ":LLVMToLLVMIRTranslation", + "//llvm:Core", + "//llvm:Support", + "//llvm:Target", + ] + if_cuda_available([ + # Dependencies for SerializeToCubin.cpp with + # -DMLIR_GPU_TO_CUBIN_PASS_ENABLE + ":NVVMToLLVMIRTranslation", + "//llvm:NVPTXCodeGen", + "@cuda//:cuda_headers", + "@cuda//:libcuda", + ]), +) + +td_library( + name = "LLVMOpsTdFiles", + srcs = [ + "include/mlir/Dialect/LLVMIR/LLVMOpBase.td", + "include/mlir/Dialect/LLVMIR/LLVMOps.td", + "include/mlir/Dialect/LLVMIR/LLVMOpsInterfaces.td", + ], + includes = ["include"], + deps = [ + ":ControlFlowInterfacesTdFiles", + ":OpBaseTdFiles", + ":SideEffectInterfacesTdFiles", + ], +) + +cc_library( + name = "GPUCommonTransforms", + srcs = [ + "lib/Conversion/GPUCommon/GPUOpsLowering.cpp", + ], + hdrs = [ + "lib/Conversion/GPUCommon/GPUOpsLowering.h", + "lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.h", + "lib/Conversion/GPUCommon/OpToFuncCallLowering.h", + ], + deps = [ + ":GPUDialect", + ":IR", + ":LLVMDialect", + ":StandardOps", + ":StandardToLLVM", + "//llvm:Support", + ], +) + +gentbl_cc_library( + name = "GPUToNVVMGen", + strip_include_prefix = "lib/Conversion/GPUToNVVM", + tbl_outs = [ + ( + ["-gen-rewriters"], + "lib/Conversion/GPUToNVVM/GPUToNVVM.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "lib/Conversion/GPUToNVVM/GPUToNVVM.td", + deps = [ + ":GPUOpsTdFiles", + ":NVVMOpsTdFiles", + ], +) + +cc_library( + name = "GPUToNVVMTransforms", + srcs = glob([ + "lib/Conversion/GPUToNVVM/*.cpp", + "lib/Conversion/GPUToNVVM/*.h", + ]) + ["lib/Conversion/PassDetail.h"], + hdrs = glob([ + "include/mlir/Conversion/GPUToNVVM/*.h", + ]), + includes = ["include"], + deps = [ + ":ConversionPassIncGen", + ":GPUCommonTransforms", + ":GPUDialect", + ":GPUToNVVMGen", + ":GPUTransforms", + ":IR", + ":LLVMDialect", + ":MathDialect", + ":MemRefDialect", + ":NVVMDialect", + ":Pass", + ":StandardToLLVM", + ":Transforms", + "//llvm:Support", + ], +) + +cc_library( + name = "VectorToROCDL", + srcs = [ + "lib/Conversion/PassDetail.h", + "lib/Conversion/VectorToROCDL/VectorToROCDL.cpp", + ], + hdrs = ["include/mlir/Conversion/VectorToROCDL/VectorToROCDL.h"], + includes = ["include"], + deps = [ + ":ConversionPassIncGen", + ":GPUDialect", + ":LLVMDialect", + ":Pass", + ":ROCDLDialect", + ":StandardOps", + ":StandardToLLVM", + ":Transforms", + ":VectorOps", + ], +) + +cc_library( + name = "VectorToSPIRV", + srcs = glob([ + "lib/Conversion/VectorToSPIRV/*.cpp", + "lib/Conversion/VectorToSPIRV/*.h", + ]) + ["lib/Conversion/PassDetail.h"], + hdrs = glob([ + "include/mlir/Conversion/VectorToSPIRV/*.h", + ]), + includes = ["include"], + deps = [ + ":ConversionPassIncGen", + ":Pass", + ":SPIRVConversion", + ":SPIRVDialect", + ":Transforms", + ":VectorOps", + ], +) + +gentbl_cc_library( + name = "GPUToROCDLTGen", + strip_include_prefix = "lib/Conversion/GPUToROCDL", + tbl_outs = [ + ( + ["-gen-rewriters"], + "lib/Conversion/GPUToROCDL/GPUToROCDL.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "lib/Conversion/GPUToROCDL/GPUToROCDL.td", + deps = [ + ":GPUOpsTdFiles", + ":ROCDLOpsTdFiles", + ], +) + +cc_library( + name = "GPUToROCDLTransforms", + srcs = [ + "lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp", + "lib/Conversion/PassDetail.h", + ], + hdrs = ["include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h"], + includes = ["include"], + deps = [ + ":ConversionPassIncGen", + ":GPUCommonTransforms", + ":GPUDialect", + ":GPUToROCDLTGen", + ":GPUTransforms", + ":MathDialect", + ":Pass", + ":ROCDLDialect", + ":StandardToLLVM", + ":Transforms", + ":VectorOps", + ":VectorToLLVM", + ":VectorToROCDL", + ":VectorToSCF", + "//llvm:Support", + ], +) + +cc_library( + name = "GPUToVulkanTransforms", + srcs = [ + "lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp", + "lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp", + "lib/Conversion/PassDetail.h", + ], + hdrs = ["include/mlir/Conversion/GPUToVulkan/ConvertGPUToVulkanPass.h"], + includes = ["include"], + deps = [ + ":ConversionPassIncGen", + ":GPUDialect", + ":IR", + ":LLVMDialect", + ":Pass", + ":SPIRVDialect", + ":SPIRVSerialization", + ":StandardOps", + ":Support", + "//llvm:Support", + ], +) + +cc_library( + name = "GPUToGPURuntimeTransforms", + srcs = [ + "lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp", + "lib/Conversion/PassDetail.h", + ], + hdrs = ["include/mlir/Conversion/GPUCommon/GPUCommonPass.h"], + includes = ["include"], + deps = [ + ":Async", + ":AsyncToLLVM", + ":ConversionPassIncGen", + ":GPUDialect", + ":GPUTransforms", + ":IR", + ":LLVMDialect", + ":NVVMToLLVMIRTranslation", + ":Pass", + ":StandardToLLVM", + ":Support", + ":VectorToLLVM", + "//llvm:Support", + ], +) + +cc_library( + name = "GPUToSPIRV", + srcs = glob([ + "lib/Conversion/GPUToSPIRV/*.cpp", + "lib/Conversion/GPUToSPIRV/*.h", + ]) + ["lib/Conversion/PassDetail.h"], + hdrs = glob([ + "include/mlir/Conversion/GPUToSPIRV/*.h", + ]), + includes = [ + "include", + "lib/Conversions/GPUToSPIRV", + ], + deps = [ + ":ConversionPassIncGen", + ":GPUDialect", + ":IR", + ":Pass", + ":SCFDialect", + ":SCFToSPIRV", + ":SPIRVConversion", + ":SPIRVDialect", + ":StandardToSPIRV", + ":Support", + ":Transforms", + ":VectorToSPIRV", + "//llvm:Support", + ], +) + +cc_library( + name = "PDLToPDLInterp", + srcs = glob([ + "lib/Conversion/PDLToPDLInterp/*.cpp", + "lib/Conversion/PDLToPDLInterp/*.h", + ]) + ["lib/Conversion/PassDetail.h"], + hdrs = ["include/mlir/Conversion/PDLToPDLInterp/PDLToPDLInterp.h"], + includes = ["include"], + deps = [ + ":ConversionPassIncGen", + ":IR", + ":InferTypeOpInterface", + ":PDLDialect", + ":PDLInterpDialect", + ":Pass", + ":Support", + "//llvm:Support", + ], +) + +cc_library( + name = "SPIRVToLLVM", + srcs = glob([ + "lib/Conversion/SPIRVToLLVM/*.cpp", + ]) + ["lib/Conversion/PassDetail.h"], + hdrs = glob([ + "include/mlir/Conversion/SPIRVToLLVM/*.h", + ]), + includes = ["include"], + deps = [ + ":ConversionPassIncGen", + ":GPUDialect", + ":IR", + ":LLVMDialect", + ":Pass", + ":SPIRVDialect", + ":SPIRVUtils", + ":StandardOps", + ":StandardToLLVM", + ":Support", + ":Transforms", + "//llvm:Support", + ], +) + +gentbl_cc_library( + name = "LLVMOpsIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-decls"], + "include/mlir/Dialect/LLVMIR/LLVMOps.h.inc", + ), + ( + ["-gen-op-defs"], + "include/mlir/Dialect/LLVMIR/LLVMOps.cpp.inc", + ), + ( + ["-gen-dialect-decls"], + "include/mlir/Dialect/LLVMIR/LLVMOpsDialect.h.inc", + ), + ( + ["-gen-enum-decls"], + "include/mlir/Dialect/LLVMIR/LLVMOpsEnums.h.inc", + ), + ( + ["-gen-enum-defs"], + "include/mlir/Dialect/LLVMIR/LLVMOpsEnums.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/LLVMIR/LLVMOps.td", + deps = [":LLVMOpsTdFiles"], +) + +gentbl_cc_library( + name = "LLVMConversionIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-llvmir-conversions"], + "include/mlir/Dialect/LLVMIR/LLVMConversions.inc", + ), + ( + ["-gen-enum-to-llvmir-conversions"], + "include/mlir/Dialect/LLVMIR/LLVMConversionEnumsToLLVM.inc", + ), + ( + ["-gen-enum-from-llvmir-conversions"], + "include/mlir/Dialect/LLVMIR/LLVMConversionEnumsFromLLVM.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/LLVMIR/LLVMOps.td", + deps = [":LLVMOpsTdFiles"], +) + +cc_library( + name = "NVVMDialect", + srcs = ["lib/Dialect/LLVMIR/IR/NVVMDialect.cpp"], + hdrs = ["include/mlir/Dialect/LLVMIR/NVVMDialect.h"], + includes = ["include"], + deps = [ + ":IR", + ":LLVMDialect", + ":NVVMOpsIncGen", + ":SideEffectInterfaces", + ":StandardOps", + ":Support", + "//llvm:AsmParser", + "//llvm:Core", + "//llvm:Support", + ], +) + +td_library( + name = "NVVMOpsTdFiles", + srcs = ["include/mlir/Dialect/LLVMIR/NVVMOps.td"], + includes = ["include"], + deps = [ + ":LLVMOpsTdFiles", + ":OpBaseTdFiles", + ":SideEffectInterfacesTdFiles", + ], +) + +gentbl_cc_library( + name = "NVVMOpsIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-decls"], + "include/mlir/Dialect/LLVMIR/NVVMOps.h.inc", + ), + ( + ["-gen-op-defs"], + "include/mlir/Dialect/LLVMIR/NVVMOps.cpp.inc", + ), + ( + [ + "-gen-dialect-decls", + "-dialect=nvvm", + ], + "include/mlir/Dialect/LLVMIR/NVVMOpsDialect.h.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/LLVMIR/NVVMOps.td", + deps = [":NVVMOpsTdFiles"], +) + +gentbl_cc_library( + name = "NVVMConversionIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-llvmir-conversions"], + "include/mlir/Dialect/LLVMIR/NVVMConversions.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/LLVMIR/NVVMOps.td", + deps = [":NVVMOpsTdFiles"], +) + +cc_library( + name = "ROCDLDialect", + srcs = ["lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp"], + hdrs = ["include/mlir/Dialect/LLVMIR/ROCDLDialect.h"], + includes = ["include"], + deps = [ + ":IR", + ":LLVMDialect", + ":ROCDLOpsIncGen", + ":SideEffectInterfaces", + ":StandardOps", + ":Support", + "//llvm:AsmParser", + "//llvm:Core", + "//llvm:Support", + ], +) + +td_library( + name = "ROCDLOpsTdFiles", + srcs = ["include/mlir/Dialect/LLVMIR/ROCDLOps.td"], + includes = ["include"], + deps = [ + ":LLVMOpsTdFiles", + ":OpBaseTdFiles", + ":SideEffectInterfacesTdFiles", + ], +) + +gentbl_cc_library( + name = "ROCDLOpsIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-decls"], + "include/mlir/Dialect/LLVMIR/ROCDLOps.h.inc", + ), + ( + ["-gen-op-defs"], + "include/mlir/Dialect/LLVMIR/ROCDLOps.cpp.inc", + ), + ( + [ + "-gen-dialect-decls", + "-dialect=rocdl", + ], + "include/mlir/Dialect/LLVMIR/ROCDLOpsDialect.h.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/LLVMIR/ROCDLOps.td", + deps = [":ROCDLOpsTdFiles"], +) + +gentbl_cc_library( + name = "ROCDLConversionIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-llvmir-conversions"], + "include/mlir/Dialect/LLVMIR/ROCDLConversions.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/LLVMIR/ROCDLOps.td", + deps = [":ROCDLOpsTdFiles"], +) + +cc_library( + name = "PDLDialect", + srcs = glob([ + "lib/Dialect/PDL/IR/*.cpp", + "lib/Dialect/PDL/IR/*.h", + ]), + hdrs = glob([ + "include/mlir/Dialect/PDL/IR/*.h", + ]), + includes = ["include"], + deps = [ + ":IR", + ":InferTypeOpInterface", + ":PDLOpsIncGen", + ":PDLTypesIncGen", + ":SideEffects", + ":Support", + "//llvm:Support", + ], +) + +td_library( + name = "PDLDialectTdFiles", + srcs = [ + "include/mlir/Dialect/PDL/IR/PDLDialect.td", + "include/mlir/Dialect/PDL/IR/PDLOps.td", + "include/mlir/Dialect/PDL/IR/PDLTypes.td", + ], + deps = [ + ":OpBaseTdFiles", + ":SideEffectInterfacesTdFiles", + ], +) + +gentbl_cc_library( + name = "PDLOpsIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-decls"], + "include/mlir/Dialect/PDL/IR/PDLOps.h.inc", + ), + ( + ["-gen-op-defs"], + "include/mlir/Dialect/PDL/IR/PDLOps.cpp.inc", + ), + ( + ["-gen-dialect-decls"], + "include/mlir/Dialect/PDL/IR/PDLOpsDialect.h.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/PDL/IR/PDLOps.td", + deps = [":PDLDialectTdFiles"], +) + +gentbl_cc_library( + name = "PDLTypesIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-typedef-decls"], + "include/mlir/Dialect/PDL/IR/PDLOpsTypes.h.inc", + ), + ( + ["-gen-typedef-defs"], + "include/mlir/Dialect/PDL/IR/PDLOpsTypes.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/PDL/IR/PDLTypes.td", + deps = [":PDLDialectTdFiles"], +) + +cc_library( + name = "PDLInterpDialect", + srcs = glob([ + "lib/Dialect/PDLInterp/IR/*.cpp", + "lib/Dialect/PDLInterp/IR/*.h", + ]), + hdrs = glob([ + "include/mlir/Dialect/PDLInterp/IR/*.h", + ]), + includes = ["include"], + deps = [ + ":IR", + ":InferTypeOpInterface", + ":PDLDialect", + ":PDLInterpOpsIncGen", + ":SideEffects", + ":Support", + "//llvm:Support", + ], +) + +td_library( + name = "PDLInterpOpsTdFiles", + srcs = ["include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td"], + includes = ["include"], + deps = [ + ":OpBaseTdFiles", + ":PDLDialectTdFiles", + ":SideEffectInterfacesTdFiles", + ], +) + +gentbl_cc_library( + name = "PDLInterpOpsIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-decls"], + "include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.h.inc", + ), + ( + ["-gen-op-defs"], + "include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.cpp.inc", + ), + ( + [ + "-gen-dialect-decls", + "-dialect=pdl_interp", + ], + "include/mlir/Dialect/PDLInterp/IR/PDLInterpOpsDialect.h.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td", + deps = [":PDLInterpOpsTdFiles"], +) + +td_library( + name = "SPIRVOpsTdFiles", + srcs = glob(["include/mlir/Dialect/SPIRV/IR/*.td"]), + includes = ["include"], + deps = [ + ":CallInterfacesTdFiles", + ":ControlFlowInterfacesTdFiles", + ":OpBaseTdFiles", + ":SideEffectInterfacesTdFiles", + ], +) + +gentbl_cc_library( + name = "SPIRVOpsIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-decls"], + "include/mlir/Dialect/SPIRV/IR/SPIRVOps.h.inc", + ), + ( + ["-gen-op-defs"], + "include/mlir/Dialect/SPIRV/IR/SPIRVOps.cpp.inc", + ), + ( + ["-gen-dialect-decls"], + "include/mlir/Dialect/SPIRV/IR/SPIRVOpsDialect.h.inc", + ), + ( + ["-gen-op-doc"], + "g3doc/Dialects/SPIRV/SPIRVOps.md", + ), + ( + ["-gen-enum-decls"], + "include/mlir/Dialect/SPIRV/IR/SPIRVEnums.h.inc", + ), + ( + ["-gen-enum-defs"], + "include/mlir/Dialect/SPIRV/IR/SPIRVEnums.cpp.inc", + ), + ( + ["-gen-spirv-enum-avail-decls"], + "include/mlir/Dialect/SPIRV/IR/SPIRVEnumAvailability.h.inc", + ), + ( + ["-gen-spirv-enum-avail-defs"], + "include/mlir/Dialect/SPIRV/IR/SPIRVEnumAvailability.cpp.inc", + ), + ( + ["-gen-spirv-capability-implication"], + "include/mlir/Dialect/SPIRV/IR/SPIRVCapabilityImplication.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/SPIRV/IR/SPIRVOps.td", + deps = [":SPIRVOpsTdFiles"], +) + +gentbl_cc_library( + name = "SPIRVCanonicalizationIncGen", + strip_include_prefix = "lib/Dialect/SPIRV/IR", + tbl_outs = [ + ( + ["-gen-rewriters"], + "lib/Dialect/SPIRV/IR/SPIRVCanonicalization.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "lib/Dialect/SPIRV/IR/SPIRVCanonicalization.td", + deps = [":SPIRVOpsTdFiles"], +) + +gentbl_cc_library( + name = "SPIRVAvailabilityIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-avail-interface-decls"], + "include/mlir/Dialect/SPIRV/IR/SPIRVAvailability.h.inc", + ), + ( + ["-gen-avail-interface-defs"], + "include/mlir/Dialect/SPIRV/IR/SPIRVAvailability.cpp.inc", + ), + ( + ["-gen-spirv-avail-impls"], + "include/mlir/Dialect/SPIRV/IR/SPIRVOpAvailabilityImpl.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/SPIRV/IR/SPIRVOps.td", + deps = [":SPIRVOpsTdFiles"], +) + +gentbl_cc_library( + name = "SPIRVTargetAndABIStructGen", + tbl_outs = [ + ( + ["-gen-struct-attr-decls"], + "include/mlir/Dialect/SPIRV/IR/TargetAndABI.h.inc", + ), + ( + ["-gen-struct-attr-defs"], + "include/mlir/Dialect/SPIRV/IR/TargetAndABI.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/SPIRV/IR/TargetAndABI.td", + deps = [":SPIRVOpsTdFiles"], +) + +gentbl_cc_library( + name = "SPIRVAttrUtilsGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-spirv-attr-utils"], + "include/mlir/Dialect/SPIRV/IR/SPIRVAttrUtils.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/SPIRV/IR/SPIRVBase.td", + deps = [":SPIRVOpsTdFiles"], +) + +gentbl_cc_library( + name = "SPIRVSerializationGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-spirv-serialization"], + "include/mlir/Dialect/SPIRV/IR/SPIRVSerialization.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/SPIRV/IR/SPIRVOps.td", + deps = [":SPIRVOpsTdFiles"], +) + +cc_library( + name = "SPIRVDialect", + srcs = glob([ + "lib/Dialect/SPIRV/IR/*.cpp", + "lib/Dialect/SPIRV/IR/*.h", + ]) + ["include/mlir/Transforms/InliningUtils.h"], + hdrs = glob([ + "include/mlir/Dialect/SPIRV/IR/*.h", + ]), + includes = ["include"], + deps = [ + ":CommonFolders", + ":ControlFlowInterfaces", + ":IR", + ":Parser", + ":Pass", + ":SPIRVAttrUtilsGen", + ":SPIRVAvailabilityIncGen", + ":SPIRVCanonicalizationIncGen", + ":SPIRVOpsIncGen", + ":SPIRVSerializationGen", + ":SPIRVTargetAndABIStructGen", + ":SideEffectInterfaces", + ":Support", + ":Transforms", + "//llvm:Support", + ], +) + +gentbl_cc_library( + name = "SPIRVPassIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + [ + "-gen-pass-decls", + "-name=SPIRV", + ], + "include/mlir/Dialect/SPIRV/Transforms/Passes.h.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/SPIRV/Transforms/Passes.td", + deps = [":PassBaseTdFiles"], +) + +cc_library( + name = "SPIRVUtils", + srcs = glob([ + "lib/Dialect/SPIRV/Utils/*.cpp", + ]), + hdrs = glob([ + "include/mlir/Dialect/SPIRV/Utils/*.h", + ]), + includes = ["include"], + deps = [ + ":SPIRVDialect", + ":Support", + "//llvm:Support", + ], +) + +cc_library( + name = "SPIRVConversion", + srcs = ["lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp"], + hdrs = ["include/mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"], + includes = ["include"], + deps = [ + ":SPIRVDialect", + ":Support", + ":TransformUtils", + "//llvm:Support", + ], +) + +cc_library( + name = "SPIRVTransforms", + srcs = glob( + [ + "lib/Dialect/SPIRV/Transforms/*.cpp", + "lib/Dialect/SPIRV/Transforms/*.h", + ], + exclude = ["lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp"], + ), + hdrs = glob( + ["include/mlir/Dialect/SPIRV/Transforms/*.h"], + exclude = ["include/mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"], + ), + includes = ["include"], + deps = [ + ":IR", + ":Pass", + ":SPIRVConversion", + ":SPIRVDialect", + ":SPIRVPassIncGen", + ":SPIRVUtils", + ":Support", + ":Transforms", + "//llvm:Support", + ], +) + +cc_library( + name = "StandardToSPIRV", + srcs = glob([ + "lib/Conversion/StandardToSPIRV/*.cpp", + "lib/Conversion/StandardToSPIRV/*.h", + ]) + ["lib/Conversion/PassDetail.h"], + hdrs = glob([ + "include/mlir/Conversion/StandardToSPIRV/*.h", + ]), + includes = [ + "include", + "lib/Conversion/StandardToSPIRV", + ], + deps = [ + ":ConversionPassIncGen", + ":IR", + ":MathDialect", + ":MemRefDialect", + ":Pass", + ":SPIRVConversion", + ":SPIRVDialect", + ":SPIRVUtils", + ":StandardOps", + ":Support", + ":TensorDialect", + ":Transforms", + ":VectorOps", + "//llvm:Support", + ], +) + +cc_library( + name = "SPIRVBinaryUtils", + srcs = ["lib/Target/SPIRV/SPIRVBinaryUtils.cpp"], + hdrs = ["include/mlir/Target/SPIRV/SPIRVBinaryUtils.h"], + includes = ["include"], + deps = [ + ":IR", + ":SPIRVAttrUtilsGen", + ":SPIRVDialect", + ":SPIRVOpsIncGen", + ":Support", + "//llvm:Support", + ], +) + +cc_library( + name = "SPIRVSerialization", + srcs = [ + "lib/Target/SPIRV/Serialization/Serialization.cpp", + "lib/Target/SPIRV/Serialization/SerializeOps.cpp", + "lib/Target/SPIRV/Serialization/Serializer.cpp", + "lib/Target/SPIRV/Serialization/Serializer.h", + ], + hdrs = ["include/mlir/Target/SPIRV/Serialization.h"], + includes = ["include"], + deps = [ + ":IR", + ":SPIRVAttrUtilsGen", + ":SPIRVBinaryUtils", + ":SPIRVDialect", + ":SPIRVOpsIncGen", + ":SPIRVSerializationGen", + ":Support", + ":Transforms", + "//llvm:Support", + ], +) + +cc_library( + name = "SPIRVDeserialization", + srcs = glob([ + "lib/Target/SPIRV/Deserialization/*.cpp", + "lib/Target/SPIRV/Deserialization/*.h", + ]), + hdrs = ["include/mlir/Target/SPIRV/Deserialization.h"], + includes = ["include"], + deps = [ + ":IR", + ":SPIRVAttrUtilsGen", + ":SPIRVBinaryUtils", + ":SPIRVDialect", + ":SPIRVOpsIncGen", + ":SPIRVSerializationGen", + ":Support", + ":Transforms", + "//llvm:Support", + ], +) + +cc_library( + name = "SPIRVModuleCombiner", + srcs = glob( + ["lib/Dialect/SPIRV/Linking/ModuleCombiner/*.cpp"], + ), + hdrs = ["include/mlir/Dialect/SPIRV/Linking/ModuleCombiner.h"], + includes = ["include"], + deps = [ + ":IR", + ":SPIRVDialect", + ":Support", + "//llvm:Support", + ], +) + +cc_library( + name = "SPIRVTranslateRegistration", + srcs = ["lib/Target/SPIRV/TranslateRegistration.cpp"], + includes = ["include"], + deps = [ + ":IR", + ":Parser", + ":SPIRVDeserialization", + ":SPIRVDialect", + ":SPIRVSerialization", + ":Support", + ":Translation", + "//llvm:Support", + ], +) + +td_library( + name = "TensorOpsTdFiles", + srcs = [ + "include/mlir/Dialect/Tensor/IR/TensorBase.td", + "include/mlir/Dialect/Tensor/IR/TensorOps.td", + ], + includes = ["include"], + deps = [ + ":CastInterfacesTdFiles", + ":ControlFlowInterfacesTdFiles", + ":OpBaseTdFiles", + ":SideEffectInterfacesTdFiles", + ], +) + +gentbl_cc_library( + name = "TensorOpsIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + [ + "-gen-dialect-decls", + "-dialect=tensor", + ], + "include/mlir/Dialect/Tensor/IR/TensorOpsDialect.h.inc", + ), + ( + ["-gen-op-decls"], + "include/mlir/Dialect/Tensor/IR/TensorOps.h.inc", + ), + ( + ["-gen-op-defs"], + "include/mlir/Dialect/Tensor/IR/TensorOps.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/Tensor/IR/TensorOps.td", + deps = [":TensorOpsTdFiles"], +) + +cc_library( + name = "TensorDialect", + srcs = glob( + [ + "lib/Dialect/Tensor/IR/*.cpp", + "lib/Dialect/Tensor/IR/*.h", + ], + ) + ["include/mlir/Transforms/InliningUtils.h"], + hdrs = ["include/mlir/Dialect/Tensor/IR/Tensor.h"], + includes = ["include"], + deps = [ + ":CastOpInterfaces", + ":ControlFlowInterfaces", + ":IR", + ":SideEffectInterfaces", + ":Support", + ":TensorOpsIncGen", + "//llvm:Support", + ], +) + +gentbl_cc_library( + name = "TensorPassIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + [ + "-gen-pass-decls", + "-name=Tensor", + ], + "include/mlir/Dialect/Tensor/Transforms/Passes.h.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/Tensor/Transforms/Passes.td", + deps = [":PassBaseTdFiles"], +) + +cc_library( + name = "TensorTransforms", + srcs = glob( + [ + "lib/Dialect/Tensor/Transforms/*.cpp", + "lib/Dialect/Tensor/Transforms/*.h", + ], + ), + hdrs = ["include/mlir/Dialect/Tensor/Transforms/Passes.h"], + includes = ["include"], + deps = [ + ":Async", + ":IR", + ":MemRefDialect", + ":ParallelLoopMapperAttrGen", + ":Pass", + ":SCFDialect", + ":StandardOps", + ":Support", + ":TensorDialect", + ":TensorPassIncGen", + ":Transforms", + "//llvm:Support", + ], +) + +cc_library( + name = "Rewrite", + srcs = glob([ + "lib/Rewrite/*.cpp", + "lib/Rewrite/*.h", + ]), + hdrs = glob(["include/mlir/Rewrite/*.h"]), + includes = ["include"], + deps = [ + ":Analysis", + ":IR", + ":PDLDialect", + ":PDLInterpDialect", + ":PDLToPDLInterp", + ":Pass", + ":SideEffectInterfaces", + "//llvm:Support", + ], +) + +cc_library( + name = "TransformUtils", + srcs = glob([ + "lib/Transforms/Utils/*.cpp", + "lib/Transforms/Utils/*.h", + ]), + hdrs = glob([ + "include/mlir/Transforms/*.h", + ]), + includes = ["include"], + deps = [ + ":Affine", + ":Analysis", + ":ControlFlowInterfaces", + ":IR", + ":MemRefDialect", + ":Pass", + ":Rewrite", + ":SCFDialect", + ":SideEffectInterfaces", + ":StandardOps", + ":Support", + ":TransformsPassIncGen", + "//llvm:Support", + ], +) + +gentbl_cc_library( + name = "DerivedAttributeOpInterfaceIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-interface-decls"], + "include/mlir/Interfaces/DerivedAttributeOpInterface.h.inc", + ), + ( + ["-gen-op-interface-defs"], + "include/mlir/Interfaces/DerivedAttributeOpInterface.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Interfaces/DerivedAttributeOpInterface.td", + deps = [":DerivedAttributeOpInterfaceTdFiles"], +) + +cc_library( + name = "DerivedAttributeOpInterface", + srcs = ["lib/Interfaces/DerivedAttributeOpInterface.cpp"], + hdrs = ["include/mlir/Interfaces/DerivedAttributeOpInterface.h"], + includes = ["include"], + deps = [ + ":DerivedAttributeOpInterfaceIncGen", + ":IR", + ":Support", + "//llvm:Support", + ], +) + +td_library( + name = "DataLayoutInterfacesTdFiles", + srcs = ["include/mlir/Interfaces/DataLayoutInterfaces.td"], + includes = ["include"], +) + +gentbl_cc_library( + name = "DataLayoutInterfacesIncGen", + tbl_outs = [ + ( + ["-gen-attr-interface-decls"], + "include/mlir/Interfaces/DataLayoutAttrInterface.h.inc", + ), + ( + ["-gen-attr-interface-defs"], + "include/mlir/Interfaces/DataLayoutAttrInterface.cpp.inc", + ), + ( + ["-gen-op-interface-decls"], + "include/mlir/Interfaces/DataLayoutOpInterface.h.inc", + ), + ( + ["-gen-op-interface-defs"], + "include/mlir/Interfaces/DataLayoutOpInterface.cpp.inc", + ), + ( + ["-gen-type-interface-decls"], + "include/mlir/Interfaces/DataLayoutTypeInterface.h.inc", + ), + ( + ["-gen-type-interface-defs"], + "include/mlir/Interfaces/DataLayoutTypeInterface.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Interfaces/DataLayoutInterfaces.td", + deps = [":OpBaseTdFiles"], +) + +gentbl_cc_library( + name = "LoopLikeInterfaceIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-interface-decls"], + "include/mlir/Interfaces/LoopLikeInterface.h.inc", + ), + ( + ["-gen-op-interface-defs"], + "include/mlir/Interfaces/LoopLikeInterface.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Interfaces/LoopLikeInterface.td", + deps = [":LoopLikeInterfaceTdFiles"], +) + +gentbl_cc_library( + name = "VectorInterfacesIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-interface-decls"], + "include/mlir/Interfaces/VectorInterfaces.h.inc", + ), + ( + ["-gen-op-interface-defs"], + "include/mlir/Interfaces/VectorInterfaces.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Interfaces/VectorInterfaces.td", + deps = [":VectorInterfacesTdFiles"], +) + +gentbl_cc_library( + name = "ViewLikeInterfaceIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-interface-decls"], + "include/mlir/Interfaces/ViewLikeInterface.h.inc", + ), + ( + ["-gen-op-interface-defs"], + "include/mlir/Interfaces/ViewLikeInterface.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Interfaces/ViewLikeInterface.td", + deps = [":ViewLikeInterfaceTdFiles"], +) + +gentbl_cc_library( + name = "CopyOpInterfaceIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-interface-decls"], + "include/mlir/Interfaces/CopyOpInterface.h.inc", + ), + ( + ["-gen-op-interface-defs"], + "include/mlir/Interfaces/CopyOpInterface.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Interfaces/CopyOpInterface.td", + deps = [":CopyOpInterfaceTdFiles"], +) + +gentbl_cc_library( + name = "TransformsPassIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + [ + "-gen-pass-decls", + "-name=Transforms", + ], + "include/mlir/Transforms/Passes.h.inc", + ), + ( + [ + "-gen-pass-capi-header", + "--prefix=Transforms", + ], + "include/mlir/Transforms/Transforms.capi.h.inc", + ), + ( + [ + "-gen-pass-capi-impl", + "--prefix=Transforms", + ], + "include/mlir/Transforms/Transforms.capi.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Transforms/Passes.td", + deps = [ + ":PassBaseTdFiles", + ":RewritePassBaseTdFiles", + ], +) + +cc_library( + name = "Transforms", + srcs = glob([ + "lib/Transforms/*.cpp", + "lib/Transforms/*.h", + ]), + hdrs = glob(["include/mlir/Transforms/*.h"]), + includes = ["include"], + deps = [ + ":Affine", + ":Analysis", + ":ControlFlowInterfaces", + ":CopyOpInterface", + ":IR", + ":LinalgOps", + ":LoopLikeInterface", + ":MemRefDialect", + ":Pass", + ":Rewrite", + ":SCFDialect", + ":SideEffectInterfaces", + ":StandardOps", + ":Support", + ":TensorDialect", + ":TransformUtils", + ":TransformsPassIncGen", + "//llvm:Support", + ], +) + +cc_library( + name = "CommonFolders", + srcs = [ + ], + hdrs = ["include/mlir/Dialect/CommonFolders.h"], + includes = ["include"], + deps = [ + ":IR", + "//llvm:Support", + ], +) + +cc_library( + name = "SCFToGPU", + srcs = ["lib/Conversion/SCFToGPU/SCFToGPU.cpp"], + hdrs = ["include/mlir/Conversion/SCFToGPU/SCFToGPU.h"], + includes = ["include"], + deps = [ + ":Affine", + ":AffineToStandard", + ":ConversionPassIncGen", + ":GPUDialect", + ":GPUTransforms", + ":IR", + ":MemRefDialect", + ":Pass", + ":SCFDialect", + ":StandardOps", + ":Support", + ":TransformUtils", + ":Transforms", + "//llvm:Support", + ], +) + +cc_library( + name = "SCFToGPUPass", + srcs = [ + "lib/Conversion/PassDetail.h", + "lib/Conversion/SCFToGPU/SCFToGPUPass.cpp", + ], + hdrs = ["include/mlir/Conversion/SCFToGPU/SCFToGPUPass.h"], + includes = ["include"], + deps = [ + ":Affine", + ":ComplexDialect", + ":ConversionPassIncGen", + ":GPUDialect", + ":Pass", + ":SCFDialect", + ":SCFToGPU", + ":StandardOps", + ":Support", + ":Transforms", + "//llvm:Support", + ], +) + +cc_library( + name = "SCFToSPIRV", + srcs = glob([ + "lib/Conversion/SCFToSPIRV/*.cpp", + "lib/Conversion/SCFToSPIRV/*.h", + ]) + ["lib/Conversion/PassDetail.h"], + hdrs = glob([ + "include/mlir/Conversion/SCFToSPIRV/*.h", + ]), + includes = ["include"], + deps = [ + ":Affine", + ":ConversionPassIncGen", + ":IR", + ":Pass", + ":SCFDialect", + ":SPIRVConversion", + ":SPIRVDialect", + ":StandardOps", + ":StandardToSPIRV", + ":Support", + ":TransformUtils", + ":Transforms", + "//llvm:Support", + ], +) + +cc_library( + name = "SCFToOpenMP", + srcs = [ + "lib/Conversion/PassDetail.h", + "lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp", + ], + hdrs = ["include/mlir/Conversion/SCFToOpenMP/SCFToOpenMP.h"], + includes = ["include"], + deps = [ + ":ConversionPassIncGen", + ":IR", + ":OpenMPDialect", + ":Pass", + ":SCFDialect", + ":Support", + ":Transforms", + ], +) + +cc_library( + name = "SCFToStandard", + srcs = [ + "lib/Conversion/PassDetail.h", + "lib/Conversion/SCFToStandard/SCFToStandard.cpp", + ], + hdrs = ["include/mlir/Conversion/SCFToStandard/SCFToStandard.h"], + includes = ["include"], + deps = [ + ":ConversionPassIncGen", + ":IR", + ":LLVMDialect", + ":Pass", + ":SCFDialect", + ":StandardOps", + ":Support", + ":TransformUtils", + ":Transforms", + ], +) + +alias( + name = "CFGTransforms", + actual = "SCFToStandard", +) + +cc_library( + name = "StandardToLLVM", + srcs = [ + "lib/Conversion/PassDetail.h", + "lib/Conversion/StandardToLLVM/StandardToLLVM.cpp", + ], + hdrs = [ + "include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h", + "include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h", + ], + includes = ["include"], + deps = [ + ":Analysis", + ":ConversionPassIncGen", + ":DataLayoutInterfaces", + ":IR", + ":LLVMDialect", + ":MathDialect", + ":MemRefDialect", + ":Parser", + ":Pass", + ":StandardOps", + ":StandardOpsTransforms", + ":Support", + ":TransformUtils", + ":Transforms", + "//llvm:Core", + "//llvm:Support", + ], +) + +alias( + name = "LLVMTransforms", + actual = "StandardToLLVM", +) + +gentbl_cc_library( + name = "CallOpInterfacesIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-interface-decls"], + "include/mlir/Interfaces/CallInterfaces.h.inc", + ), + ( + ["-gen-op-interface-defs"], + "include/mlir/Interfaces/CallInterfaces.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Interfaces/CallInterfaces.td", + deps = [":CallInterfacesTdFiles"], +) + +cc_library( + name = "CallOpInterfaces", + srcs = ["lib/Interfaces/CallInterfaces.cpp"], + hdrs = ["include/mlir/Interfaces/CallInterfaces.h"], + includes = ["include"], + deps = [ + ":CallOpInterfacesIncGen", + ":IR", + ":Support", + "//llvm:Support", + ], +) + +gentbl_cc_library( + name = "CastOpInterfacesIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-interface-decls"], + "include/mlir/Interfaces/CastInterfaces.h.inc", + ), + ( + ["-gen-op-interface-defs"], + "include/mlir/Interfaces/CastInterfaces.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Interfaces/CastInterfaces.td", + deps = [":CastInterfacesTdFiles"], +) + +cc_library( + name = "CastOpInterfaces", + srcs = ["lib/Interfaces/CastInterfaces.cpp"], + hdrs = ["include/mlir/Interfaces/CastInterfaces.h"], + includes = ["include"], + deps = [ + ":CastOpInterfacesIncGen", + ":IR", + ":Support", + "//llvm:Support", + ], +) + +gentbl_cc_library( + name = "ControlFlowInterfacesIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-interface-decls"], + "include/mlir/Interfaces/ControlFlowInterfaces.h.inc", + ), + ( + ["-gen-op-interface-defs"], + "include/mlir/Interfaces/ControlFlowInterfaces.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Interfaces/ControlFlowInterfaces.td", + deps = [":ControlFlowInterfacesTdFiles"], +) + +cc_library( + name = "ControlFlowInterfaces", + srcs = ["lib/Interfaces/ControlFlowInterfaces.cpp"], + hdrs = ["include/mlir/Interfaces/ControlFlowInterfaces.h"], + includes = ["include"], + deps = [ + ":ControlFlowInterfacesIncGen", + ":IR", + ":Support", + "//llvm:Support", + ], +) + +gentbl_cc_library( + name = "InferTypeOpInterfaceIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-interface-decls"], + "include/mlir/Interfaces/InferTypeOpInterface.h.inc", + ), + ( + ["-gen-op-interface-defs"], + "include/mlir/Interfaces/InferTypeOpInterface.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Interfaces/InferTypeOpInterface.td", + deps = [":InferTypeOpInterfaceTdFiles"], +) + +cc_library( + name = "InferTypeOpInterface", + srcs = ["lib/Interfaces/InferTypeOpInterface.cpp"], + hdrs = ["include/mlir/Interfaces/InferTypeOpInterface.h"], + includes = ["include"], + deps = [ + ":IR", + ":InferTypeOpInterfaceIncGen", + ":Support", + "//llvm:Support", + ], +) + +gentbl_cc_library( + name = "SideEffectInterfacesIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-interface-decls"], + "include/mlir/Interfaces/SideEffectInterfaces.h.inc", + ), + ( + ["-gen-op-interface-defs"], + "include/mlir/Interfaces/SideEffectInterfaces.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Interfaces/SideEffectInterfaces.td", + deps = [":SideEffectInterfacesTdFiles"], +) + +cc_library( + name = "SideEffectInterfaces", + srcs = ["lib/Interfaces/SideEffectInterfaces.cpp"], + hdrs = ["include/mlir/Interfaces/SideEffectInterfaces.h"], + includes = ["include"], + deps = [ + ":IR", + ":SideEffectInterfacesIncGen", + ":Support", + "//llvm:Support", + ], +) + +alias( + name = "SideEffects", + actual = "SideEffectInterfaces", +) + +cc_library( + name = "Analysis", + srcs = glob( + [ + "lib/Analysis/*.cpp", + "lib/Analysis/*.h", + "lib/Analysis/*/*.cpp", + "lib/Analysis/*/*.h", + ], + exclude = [ + "lib/Analysis/Vector*.cpp", + "lib/Analysis/Vector*.h", + ], + ), + hdrs = glob( + [ + "include/mlir/Analysis/*.h", + "include/mlir/Analysis/*/*.h", + ], + exclude = ["include/mlir/Analysis/Vector*.h"], + ), + includes = ["include"], + deps = [ + ":Affine", + ":CallOpInterfaces", + ":ControlFlowInterfaces", + ":DataLayoutInterfaces", + ":IR", + ":LinalgOps", + ":SCFDialect", + ":SideEffectInterfaces", + ":StandardOps", + ":Support", + ":ViewLikeInterface", + "//llvm:Support", + ], +) + +cc_library( + name = "Translation", + srcs = glob([ + "lib/Translation/*.cpp", + "lib/Translation/*.h", + ]), + hdrs = ["include/mlir/Translation.h"], + includes = ["include"], + deps = [ + ":Analysis", + ":IR", + ":Parser", + ":Support", + "//llvm:Support", + ], +) + +cc_library( + name = "ToLLVMIRTranslation", + srcs = [ + "lib/Target/LLVMIR/DebugTranslation.cpp", + "lib/Target/LLVMIR/DebugTranslation.h", + "lib/Target/LLVMIR/ModuleTranslation.cpp", + "lib/Target/LLVMIR/TypeTranslation.cpp", + ], + hdrs = [ + "include/mlir/Target/LLVMIR/Export.h", + "include/mlir/Target/LLVMIR/LLVMTranslationInterface.h", + "include/mlir/Target/LLVMIR/ModuleTranslation.h", + "include/mlir/Target/LLVMIR/TypeTranslation.h", + ], + includes = ["include"], + deps = [ + ":IR", + ":LLVMConversionIncGen", + ":LLVMDialect", + ":LLVMIRTransforms", + ":OpenMPDialect", + ":Support", + "//llvm:Core", + "//llvm:FrontendOpenMP", + "//llvm:Support", + "//llvm:TransformUtils", + ], +) + +cc_library( + name = "AMXToLLVMIRTranslation", + srcs = glob(["lib/Target/LLVMIR/Dialect/AMX/*.cpp"]), + hdrs = glob(["include/mlir/Target/LLVMIR/Dialect/AMX/*.h"]), + includes = ["include"], + deps = [ + ":AMX", + ":AMXConversionIncGen", + ":IR", + ":Support", + ":ToLLVMIRTranslation", + "//llvm:Core", + "//llvm:Support", + ], +) + +cc_library( + name = "X86VectorToLLVMIRTranslation", + srcs = glob(["lib/Target/LLVMIR/Dialect/X86Vector/*.cpp"]), + hdrs = glob(["include/mlir/Target/LLVMIR/Dialect/X86Vector/*.h"]), + includes = ["include"], + deps = [ + ":IR", + ":Support", + ":ToLLVMIRTranslation", + ":X86Vector", + ":X86VectorConversionIncGen", + "//llvm:Core", + "//llvm:Support", + ], +) + +cc_library( + name = "ArmNeonToLLVMIRTranslation", + srcs = glob(["lib/Target/LLVMIR/Dialect/ArmNeon/*.cpp"]), + hdrs = glob(["include/mlir/Target/LLVMIR/Dialect/ArmNeon/*.h"]), + includes = ["include"], + deps = [ + ":ArmNeon", + ":ArmNeonConversionIncGen", + ":ArmNeonIncGen", + ":IR", + ":Support", + ":ToLLVMIRTranslation", + "//llvm:Core", + "//llvm:Support", + ], +) + +cc_library( + name = "ArmSVEToLLVMIRTranslation", + srcs = glob(["lib/Target/LLVMIR/Dialect/ArmSVE/*.cpp"]), + hdrs = glob(["include/mlir/Target/LLVMIR/Dialect/ArmSVE/*.h"]), + includes = ["include"], + deps = [ + ":ArmSVE", + ":ArmSVEConversionIncGen", + ":IR", + ":Support", + ":ToLLVMIRTranslation", + "//llvm:Core", + "//llvm:Support", + ], +) + +cc_library( + name = "NVVMToLLVMIRTranslation", + srcs = glob(["lib/Target/LLVMIR/Dialect/NVVM/*.cpp"]), + hdrs = glob(["include/mlir/Target/LLVMIR/Dialect/NVVM/*.h"]), + includes = ["include"], + deps = [ + ":IR", + ":NVVMConversionIncGen", + ":NVVMDialect", + ":Support", + ":ToLLVMIRTranslation", + "//llvm:Core", + "//llvm:Support", + ], +) + +cc_library( + name = "ROCDLToLLVMIRTranslation", + srcs = glob(["lib/Target/LLVMIR/Dialect/ROCDL/*.cpp"]), + hdrs = glob(["include/mlir/Target/LLVMIR/Dialect/ROCDL/*.h"]), + includes = ["include"], + deps = [ + ":IR", + ":ROCDLConversionIncGen", + ":ROCDLDialect", + ":Support", + ":ToLLVMIRTranslation", + "//llvm:Core", + "//llvm:Support", + ], +) + +cc_library( + name = "LLVMToLLVMIRTranslation", + srcs = glob(["lib/Target/LLVMIR/Dialect/LLVMIR/*.cpp"]), + hdrs = glob(["include/mlir/Target/LLVMIR/Dialect/LLVMIR/*.h"]), + includes = ["include"], + deps = [ + ":IR", + ":LLVMConversionIncGen", + ":LLVMDialect", + ":Support", + ":ToLLVMIRTranslation", + "//llvm:Core", + "//llvm:Support", + ], +) + +cc_library( + name = "OpenACCToLLVMIRTranslation", + srcs = glob(["lib/Target/LLVMIR/Dialect/OpenACC/*.cpp"]), + hdrs = glob(["include/mlir/Target/LLVMIR/Dialect/OpenACC/*.h"]), + includes = ["include"], + deps = [ + ":IR", + ":LLVMDialect", + ":OpenACCDialect", + ":OpenACCToLLVM", + ":Support", + ":ToLLVMIRTranslation", + "//llvm:Core", + "//llvm:FrontendOpenMP", + "//llvm:Support", + ], +) + +cc_library( + name = "OpenMPToLLVMIRTranslation", + srcs = glob(["lib/Target/LLVMIR/Dialect/OpenMP/*.cpp"]), + hdrs = glob(["include/mlir/Target/LLVMIR/Dialect/OpenMP/*.h"]), + includes = ["include"], + deps = [ + ":IR", + ":OpenMPDialect", + ":Support", + ":ToLLVMIRTranslation", + "//llvm:Core", + "//llvm:FrontendOpenMP", + "//llvm:Support", + ], +) + +cc_library( + name = "AllToLLVMIRTranslations", + hdrs = ["include/mlir/Target/LLVMIR/Dialect/All.h"], + includes = ["include"], + deps = [ + ":AMXToLLVMIRTranslation", + ":ArmNeonToLLVMIRTranslation", + ":ArmSVEToLLVMIRTranslation", + ":LLVMToLLVMIRTranslation", + ":NVVMToLLVMIRTranslation", + ":OpenACCToLLVMIRTranslation", + ":OpenMPToLLVMIRTranslation", + ":ROCDLToLLVMIRTranslation", + ":X86VectorToLLVMIRTranslation", + ], +) + +cc_library( + name = "ToLLVMIRTranslationRegistration", + srcs = ["lib/Target/LLVMIR/ConvertToLLVMIR.cpp"], + includes = ["include"], + deps = [ + ":AllToLLVMIRTranslations", + ":IR", + ":ToLLVMIRTranslation", + ":Translation", + "//llvm:Core", + "//llvm:Support", + ], +) + +cc_library( + name = "FromLLVMIRTranslation", + srcs = [ + "lib/Target/LLVMIR/ConvertFromLLVMIR.cpp", + ], + hdrs = ["include/mlir/Target/LLVMIR/Import.h"], + includes = ["include"], + deps = [ + ":IR", + ":LLVMConversionIncGen", + ":LLVMDialect", + ":Support", + ":Translation", + "//llvm:Core", + "//llvm:IRReader", + "//llvm:Support", + ], +) + +cc_library( + name = "ExecutionEngine", + srcs = [ + "include/mlir/ExecutionEngine/CRunnerUtils.h", + "lib/ExecutionEngine/ExecutionEngine.cpp", + ], + hdrs = [ + "include/mlir/ExecutionEngine/ExecutionEngine.h", + "include/mlir/ExecutionEngine/MemRefUtils.h", + ], + includes = ["include"], + deps = [ + ":AllToLLVMIRTranslations", + ":IR", + ":LLVMDialect", + ":Support", + ":ToLLVMIRTranslation", + ":Translation", + "//llvm:BitReader", + "//llvm:BitWriter", + "//llvm:Core", + "//llvm:ExecutionEngine", + "//llvm:MC", + "//llvm:OrcJIT", + "//llvm:Support", + "//llvm:Target", # fixdeps: keep + "//llvm:TransformUtils", + "//llvm:X86CodeGen", # fixdeps: keep + "//llvm:X86Disassembler", # fixdeps: keep + ], +) + +cc_library( + name = "ExecutionEngineUtils", + srcs = ["lib/ExecutionEngine/OptUtils.cpp"], + hdrs = ["include/mlir/ExecutionEngine/OptUtils.h"], + includes = ["include"], + deps = [ + "//llvm:Analysis", + "//llvm:Core", + "//llvm:Coroutines", + "//llvm:IPO", + "//llvm:Support", + "//llvm:Target", + "//llvm:common_transforms", + ], +) + +# TODO(jpienaar): Update this. +cc_library( + name = "MlirOptLib", + srcs = ["lib/Support/MlirOptMain.cpp"], + hdrs = ["include/mlir/Support/MlirOptMain.h"], + includes = ["include"], + deps = [ + ":Analysis", + ":ConversionPasses", + ":GPUToGPURuntimeTransforms", + ":GPUToNVVMTransforms", + ":GPUToROCDLTransforms", + ":GPUToSPIRV", + ":GPUTransforms", + ":IR", + ":Parser", + ":Pass", + ":SCFTransforms", + ":ShapeToStandard", + ":ShapeTransforms", + ":StandardOpsTransforms", + ":StandardToLLVM", + ":StandardToSPIRV", + ":Support", + "//llvm:Support", + ], +) + +cc_library( + name = "AllTranslations", + hdrs = ["include/mlir/InitAllTranslations.h"], + deps = [ + ":FromLLVMIRTranslation", + ":SPIRVTranslateRegistration", + ":ToLLVMIRTranslationRegistration", + ], +) + +cc_library( + name = "MlirTranslateMain", + srcs = ["tools/mlir-translate/mlir-translate.cpp"], + deps = [ + ":AllPassesAndDialects", + ":AllTranslations", + ":IR", + ":Parser", + ":Support", + ":Translation", + "//llvm:Support", + ], +) + +cc_binary( + name = "mlir-translate", + deps = [":MlirTranslateMain"], +) + +cc_library( + name = "AllPassesAndDialects", + hdrs = [ + "include/mlir/InitAllDialects.h", + "include/mlir/InitAllPasses.h", + ], + deps = [ + ":AMX", + ":AMXTransforms", + ":Affine", + ":AffinePassIncGen", + ":AffineToStandard", + ":AffineTransforms", + ":ArmNeon", + ":ArmSVE", + ":ArmSVETransforms", + ":Async", + ":AsyncPassIncGen", + ":AsyncToLLVM", + ":AsyncTransforms", + ":ComplexDialect", + ":ComplexToLLVM", + ":ConversionPasses", + ":DLTIDialect", + ":EmitC", + ":GPUDialect", + ":GPUPassIncGen", + ":GPUToGPURuntimeTransforms", + ":GPUToNVVMTransforms", + ":GPUToROCDLTransforms", + ":GPUToSPIRV", + ":GPUToVulkanTransforms", + ":GPUTransforms", + ":IR", + ":LLVMDialect", + ":LLVMIRTransforms", + ":LLVMPassIncGen", + ":LinalgOps", + ":LinalgPassIncGen", + ":LinalgToLLVM", + ":LinalgToSPIRV", + ":LinalgToStandard", + ":LinalgTransforms", + ":MathDialect", + ":MathToLibm", + ":MathTransforms", + ":MemRefDialect", + ":MemRefTransforms", + ":NVVMDialect", + ":OpenACCDialect", + ":OpenMPDialect", + ":OpenMPToLLVM", + ":PDLDialect", + ":PDLInterpDialect", + ":PDLToPDLInterp", + ":QuantOps", + ":QuantPassIncGen", + ":ROCDLDialect", + ":SCFDialect", + ":SCFPassIncGen", + ":SCFToGPUPass", + ":SCFToStandard", + ":SCFTransforms", + ":SDBM", + ":SPIRVDialect", + ":SPIRVPassIncGen", + ":SPIRVToLLVM", + ":SPIRVTransforms", + ":Shape", + ":ShapeToStandard", + ":ShapeTransforms", + ":ShapeTransformsPassIncGen", + ":SparseTensor", + ":SparseTensorTransforms", + ":StandardOps", + ":StandardOpsTransforms", + ":StandardOpsTransformsPassIncGen", + ":StandardToLLVM", + ":StandardToSPIRV", + ":TensorDialect", + ":TensorTransforms", + ":TosaDialect", + ":TosaToLinalg", + ":Transforms", + ":TransformsPassIncGen", + ":VectorOps", + ":VectorToLLVM", + ":VectorToROCDL", + ":VectorToSCF", + ":VectorToSPIRV", + ":X86Vector", + ":X86VectorTransforms", + ], +) + +alias( + name = "AllPassesAndDialectsNoRegistration", + actual = ":AllPassesAndDialects", + deprecation = "Use AllPassesAndDialects instead", +) + +cc_binary( + name = "mlir-lsp-server", + srcs = ["tools/mlir-lsp-server/mlir-lsp-server.cpp"], + includes = ["include"], + deps = [ + ":AllPassesAndDialects", + ":IR", + ":MlirLspServerLib", + ], +) + +cc_binary( + name = "mlir-opt", + srcs = ["tools/mlir-opt/mlir-opt.cpp"], + local_defines = ["MLIR_INCLUDE_TESTS"], + deps = [ + ":AllPassesAndDialects", + ":Analysis", + ":IR", + ":MlirOptLib", + ":OpenMPDialect", + ":Pass", + ":QuantOps", + ":SCFToGPUPass", + ":Support", + ":Transforms", + "//llvm:AllTargetsCodeGens", + "//llvm:Support", + "//mlir/test:TestAffine", + "//mlir/test:TestAnalysis", + "//mlir/test:TestDLTI", + "//mlir/test:TestDialect", + "//mlir/test:TestGPU", + "//mlir/test:TestIR", + "//mlir/test:TestLinalg", + "//mlir/test:TestMath", + "//mlir/test:TestPass", + "//mlir/test:TestReducer", + "//mlir/test:TestRewrite", + "//mlir/test:TestSCF", + "//mlir/test:TestSPIRV", + "//mlir/test:TestShapeDialect", + "//mlir/test:TestStandardOps", + "//mlir/test:TestStandardToLLVM", + "//mlir/test:TestTosaDialect", + "//mlir/test:TestTransforms", + "//mlir/test:TestTypeDialect", + "//mlir/test:TestVector", + ], +) + +cc_library( + name = "MlirJitRunner", + srcs = ["lib/ExecutionEngine/JitRunner.cpp"], + hdrs = ["include/mlir/ExecutionEngine/JitRunner.h"], + includes = ["include"], + deps = [ + ":AllPassesAndDialects", + ":ExecutionEngine", + ":ExecutionEngineUtils", + ":IR", + ":LLVMDialect", + ":LLVMToLLVMIRTranslation", + ":OpenACCToLLVMIRTranslation", + ":OpenMPToLLVMIRTranslation", + ":Parser", + ":Pass", + ":SCFToStandard", + ":Support", + "//llvm:Core", + "//llvm:OrcJIT", + "//llvm:Support", + ], +) + +cc_library( + name = "mlir_c_runner_utils", + srcs = [ + "lib/ExecutionEngine/CRunnerUtils.cpp", + "lib/ExecutionEngine/SparseUtils.cpp", + ], + hdrs = ["include/mlir/ExecutionEngine/CRunnerUtils.h"], + includes = ["include"], +) + +cc_library( + name = "mlir_async_runtime_api", + hdrs = ["include/mlir/ExecutionEngine/AsyncRuntime.h"], + includes = ["include"], +) + +cc_library( + name = "mlir_async_runtime", + srcs = ["lib/ExecutionEngine/AsyncRuntime.cpp"], + copts = ["-Dmlir_async_runtime_EXPORTS"], + deps = [ + ":mlir_async_runtime_api", + "//llvm:Support", + ], +) + +cc_library( + name = "mlir_runner_utils", + srcs = ["lib/ExecutionEngine/RunnerUtils.cpp"], + hdrs = ["include/mlir/ExecutionEngine/RunnerUtils.h"], + includes = ["include"], + deps = [":mlir_c_runner_utils"], +) + +cc_binary( + name = "mlir-cpu-runner", + srcs = ["tools/mlir-cpu-runner/mlir-cpu-runner.cpp"], + deps = [ + ":AllToLLVMIRTranslations", + ":ExecutionEngineUtils", + ":IR", + ":LLVMDialect", + ":LLVMToLLVMIRTranslation", + ":MlirJitRunner", + ":OpenACCToLLVMIRTranslation", + ":OpenMPToLLVMIRTranslation", + ":ToLLVMIRTranslation", + "//llvm:AsmParser", + "//llvm:Support", + "//llvm:X86AsmParser", + ], +) + +# This target provides the headers from LLVM's Support target without any of +# the symbols. In particular, it does not contain the static registration code +# which may be executed by at most one shared library loaded by ORCJit. Direct +# dependencies need to avoid requiring symbols from LLVMSupport by adding +# copts = ["-DLLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1"]. +# +# Bazel links the dependencies' object files instead of the archives, which +# means that symbols are linked in even if none are used. The LLVM cmake build +# on the other hand links archives (or shared libraries, depending on +# BUILD_SHARED_LIBS), skipping them if none of the symbols are used. +# See also https://reviews.llvm.org/D95613. +cc_headers_only( + name = "LLVMSupportHeaders", + src = "//llvm:Support", +) + +cc_library( + name = "mlir_cuda_runtime", + srcs = ["lib/ExecutionEngine/CudaRuntimeWrappers.cpp"], + # Prevent needing EnableABIBreakingChecks symbol from LLVMSupport. + copts = ["-DLLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1"], + tags = [ + "manual", # External dependency + "nobuildkite", # TODO(gcmn): Add support for this target + ], + deps = [ + ":LLVMSupportHeaders", + ":mlir_c_runner_utils", + "@cuda//:cuda_headers", + "@cuda//:libcuda", + ], +) + +cc_library( + name = "VulkanRuntime", + srcs = ["tools/mlir-vulkan-runner/VulkanRuntime.cpp"], + hdrs = ["tools/mlir-vulkan-runner/VulkanRuntime.h"], + tags = [ + "manual", # External dependency + ], + deps = [ + ":IR", + ":Pass", + ":SPIRVDialect", + ":SideEffectInterfaces", + ":StandardOps", + ":Support", + "//llvm:Support", + "@vulkan_headers", + "@vulkan_sdk//:sdk", + ], +) + +cc_binary( + name = "tools/libvulkan-runtime-wrappers.so", + srcs = ["tools/mlir-vulkan-runner/vulkan-runtime-wrappers.cpp"], + linkshared = True, + tags = [ + "manual", # External dependency + ], + deps = [ + ":VulkanRuntime", + "//llvm:Support", + ], +) + +cc_binary( + name = "mlir-vulkan-runner", + srcs = ["tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp"], + deps = [ + ":ExecutionEngineUtils", + ":GPUDialect", + ":GPUToSPIRV", + ":GPUToVulkanTransforms", + ":GPUTransforms", + ":LLVMDialect", + ":LLVMToLLVMIRTranslation", + ":MemRefDialect", + ":MemRefTransforms", + ":MlirJitRunner", + ":Pass", + ":SPIRVDialect", + ":SPIRVTransforms", + ":StandardOps", + ":StandardToLLVM", + ":StandardToSPIRV", + ":ToLLVMIRTranslation", + "//llvm:Support", + ], +) + +cc_binary( + name = "mlir-spirv-cpu-runner", + srcs = ["tools/mlir-spirv-cpu-runner/mlir-spirv-cpu-runner.cpp"], + deps = [ + ":ExecutionEngineUtils", + ":GPUDialect", + ":GPUToSPIRV", + ":GPUTransforms", + ":IR", + ":LLVMDialect", + ":LLVMToLLVMIRTranslation", + ":MemRefDialect", + ":MlirJitRunner", + ":Pass", + ":SPIRVConversion", + ":SPIRVDialect", + ":SPIRVToLLVM", + ":SPIRVTransforms", + ":StandardOps", + ":StandardToLLVM", + ":ToLLVMIRTranslation", + "//llvm:Core", + "//llvm:Linker", + "//llvm:Support", + ], +) + +cc_library( + name = "TableGen", + srcs = glob(["lib/TableGen/*.cpp"]), + hdrs = glob(["include/mlir/TableGen/*.h"]), + includes = ["include"], + deps = [ + ":Support", + "//llvm:Support", + "//llvm:TableGen", + ], +) + +cc_library( + name = "MlirTableGenMain", + srcs = ["tools/mlir-tblgen/mlir-tblgen.cpp"], + includes = ["include"], + deps = [ + ":Support", + ":TableGen", + "//llvm:Support", + "//llvm:TableGen", + "//llvm:config", + ], +) + +cc_binary( + name = "mlir-tblgen", + srcs = glob([ + "tools/mlir-tblgen/*.h", + "tools/mlir-tblgen/*.cpp", + ]), + deps = [ + ":MlirTableGenMain", + ":Support", + ":TableGen", + "//llvm:Support", + "//llvm:TableGen", + "//llvm:config", + ], +) + +cc_binary( + name = "mlir-linalg-ods-gen", + srcs = [ + "tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp", + ], + deps = [ + ":IR", + ":Support", + "//llvm:Support", + "//llvm:TableGen", + "//llvm:config", + ], +) + +cc_binary( + name = "mlir-linalg-ods-yaml-gen", + srcs = [ + "tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp", + ], + deps = [ + ":IR", + ":Parser", + ":Support", + "//llvm:Support", + "//llvm:TableGen", + "//llvm:config", + ], +) + +## OpenACC dialect + +# TODO(gcmn): This is sticking td files in a cc_library +gentbl_cc_library( + name = "AccCommonGen", + includes = ["/llvm/include"], + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-directive-decl"], + "include/mlir/Dialect/OpenACC/AccCommon.td", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "//llvm:include/llvm/Frontend/OpenACC/ACC.td", + deps = ["//llvm:acc_td_files"], +) + +td_library( + name = "OpenAccOpsTdFiles", + srcs = [ + "include/mlir/Dialect/OpenACC/AccCommon.td", + "include/mlir/Dialect/OpenACC/OpenACCOps.td", + ], + includes = ["include"], + deps = [":OpBaseTdFiles"], +) + +gentbl_cc_library( + name = "OpenACCOpsIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + [ + "-gen-dialect-decls", + "-dialect=acc", + ], + "include/mlir/Dialect/OpenACC/OpenACCOpsDialect.h.inc", + ), + ( + ["-gen-op-decls"], + "include/mlir/Dialect/OpenACC/OpenACCOps.h.inc", + ), + ( + ["-gen-op-defs"], + "include/mlir/Dialect/OpenACC/OpenACCOps.cpp.inc", + ), + ( + ["-gen-enum-decls"], + "include/mlir/Dialect/OpenACC/OpenACCOpsEnums.h.inc", + ), + ( + ["-gen-enum-defs"], + "include/mlir/Dialect/OpenACC/OpenACCOpsEnums.cpp.inc", + ), + ( + ["-gen-op-doc"], + "g3doc/Dialects/OpenACC/OpenACCOps.md", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/OpenACC/OpenACCOps.td", + deps = [":OpenAccOpsTdFiles"], +) + +cc_library( + name = "OpenACCDialect", + srcs = glob( + [ + "lib/Dialect/OpenACC/IR/*.cpp", + "lib/Dialect/OpenACC/IR/*.h", + ], + ), + hdrs = glob([ + "include/mlir/Dialect/OpenACC/*.h", + ]), + includes = ["include"], + deps = [ + ":IR", + ":OpenACCOpsIncGen", + ":StandardOps", + ":Transforms", + "//llvm:Support", + ], +) + +## OpenMP dialect + +# TODO(gcmn): This is sticking td files in a cc_library +gentbl_cc_library( + name = "OmpCommonTdGen", + includes = ["/llvm/include"], + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-directive-decl"], + "include/mlir/Dialect/OpenMP/OmpCommon.td", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "//llvm:include/llvm/Frontend/OpenMP/OMP.td", + deps = [ + ":OpBaseTdFiles", + "//llvm:omp_td_files", + ], +) + +td_library( + name = "OpenMPOpsTdFiles", + srcs = [ + "include/mlir/Dialect/OpenMP/OmpCommon.td", + "include/mlir/Dialect/OpenMP/OpenMPOps.td", + ], + deps = [ + ":LLVMOpsTdFiles", + ":OpBaseTdFiles", + ], +) + +gentbl_cc_library( + name = "OpenMPOpsIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-decls"], + "include/mlir/Dialect/OpenMP/OpenMPOps.h.inc", + ), + ( + ["-gen-op-defs"], + "include/mlir/Dialect/OpenMP/OpenMPOps.cpp.inc", + ), + ( + ["-gen-enum-decls"], + "include/mlir/Dialect/OpenMP/OpenMPOpsEnums.h.inc", + ), + ( + ["-gen-enum-defs"], + "include/mlir/Dialect/OpenMP/OpenMPOpsEnums.cpp.inc", + ), + ( + [ + "-gen-dialect-decls", + "-dialect=omp", + ], + "include/mlir/Dialect/OpenMP/OpenMPOpsDialect.h.inc", + ), + ( + ["-gen-op-doc"], + "g3doc/Dialects/OpenMP/OpenMPOps.md", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/OpenMP/OpenMPOps.td", + deps = [":OpenMPOpsTdFiles"], +) + +cc_library( + name = "OpenMPDialect", + srcs = glob( + [ + "lib/Dialect/OpenMP/IR/*.cpp", + "lib/Dialect/OpenMP/IR/*.h", + ], + ), + hdrs = glob([ + "include/mlir/Dialect/OpenMP/*.h", + ]), + includes = ["include"], + deps = [ + ":ControlFlowInterfaces", + ":IR", + ":LLVMDialect", + ":OpenMPOpsIncGen", + ":SideEffectInterfaces", + ":StandardOps", + "//llvm:Support", + ], +) + +cc_library( + name = "OpenACCToSCF", + srcs = glob([ + "lib/Conversion/OpenACCToSCF/*.cpp", + "lib/Conversion/OpenACCToSCF/*.h", + ]) + ["lib/Conversion/PassDetail.h"], + hdrs = glob([ + "include/mlir/Conversion/OpenACCToSCF/*.h", + ]), + includes = ["include"], + deps = [ + ":ConversionPassIncGen", + ":IR", + ":OpenACCDialect", + ":Pass", + ":SCFDialect", + ":StandardOps", + ":Transforms", + ], +) + +cc_library( + name = "OpenACCToLLVM", + srcs = glob([ + "lib/Conversion/OpenACCToLLVM/*.cpp", + "lib/Conversion/OpenACCToLLVM/*.h", + ]) + ["lib/Conversion/PassDetail.h"], + hdrs = glob([ + "include/mlir/Conversion/OpenACCToLLVM/*.h", + ]), + includes = ["include"], + deps = [ + ":ConversionPassIncGen", + ":IR", + ":LLVMDialect", + ":OpenACCDialect", + ":Pass", + ":StandardOps", + ":StandardToLLVM", + ":Transforms", + "//llvm:Core", + "//llvm:Support", + ], +) + +cc_library( + name = "OpenMPToLLVM", + srcs = glob([ + "lib/Conversion/OpenMPToLLVM/*.cpp", + "lib/Conversion/OpenMPToLLVM/*.h", + ]) + ["lib/Conversion/PassDetail.h"], + hdrs = glob([ + "include/mlir/Conversion/OpenMPToLLVM/*.h", + ]), + includes = ["include"], + deps = [ + ":ConversionPassIncGen", + ":IR", + ":LLVMDialect", + ":OpenMPDialect", + ":Pass", + ":StandardOps", + ":StandardToLLVM", + ":Transforms", + "//llvm:Core", + "//llvm:Support", + ], +) + +td_library( + name = "QuantizationOpsTdFiles", + srcs = [ + "include/mlir/Dialect/Quant/QuantOps.td", + "include/mlir/Dialect/Quant/QuantOpsBase.td", + ], + includes = ["include"], + deps = [ + ":OpBaseTdFiles", + ":SideEffectInterfacesTdFiles", + ], +) + +gentbl_cc_library( + name = "QuantOpsIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-decls"], + "include/mlir/Dialect/Quant/QuantOps.h.inc", + ), + ( + ["-gen-op-defs"], + "include/mlir/Dialect/Quant/QuantOps.cpp.inc", + ), + ( + ["-gen-dialect-decls"], + "include/mlir/Dialect/Quant/QuantOpsDialect.h.inc", + ), + ( + ["-gen-op-doc"], + "g3doc/Dialects/QuantOps/QuantOps.md", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/Quant/QuantOps.td", + deps = [":QuantizationOpsTdFiles"], +) + +gentbl_cc_library( + name = "QuantPassIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + [ + "-gen-pass-decls", + "-name=Quant", + ], + "include/mlir/Dialect/Quant/Passes.h.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/Quant/Passes.td", + deps = [":PassBaseTdFiles"], +) + +cc_library( + name = "QuantOps", + srcs = [ + "lib/Dialect/Quant/IR/QuantOps.cpp", + "lib/Dialect/Quant/IR/QuantTypes.cpp", + "lib/Dialect/Quant/IR/TypeDetail.h", + "lib/Dialect/Quant/IR/TypeParser.cpp", + "lib/Dialect/Quant/Transforms/ConvertConst.cpp", + "lib/Dialect/Quant/Transforms/ConvertSimQuant.cpp", + "lib/Dialect/Quant/Transforms/PassDetail.h", + "lib/Dialect/Quant/Utils/FakeQuantSupport.cpp", + "lib/Dialect/Quant/Utils/QuantizeUtils.cpp", + "lib/Dialect/Quant/Utils/UniformSupport.cpp", + ], + hdrs = [ + "include/mlir/Dialect/Quant/FakeQuantSupport.h", + "include/mlir/Dialect/Quant/Passes.h", + "include/mlir/Dialect/Quant/QuantOps.h", + "include/mlir/Dialect/Quant/QuantTypes.h", + "include/mlir/Dialect/Quant/QuantizeUtils.h", + "include/mlir/Dialect/Quant/UniformSupport.h", + ], + includes = ["include"], + deps = [ + ":IR", + ":Pass", + ":QuantOpsIncGen", + ":QuantPassIncGen", + ":SideEffectInterfaces", + ":StandardOps", + ":TransformUtils", + "//llvm:Support", + ], +) + +td_library( + name = "LinalgOpsTdFiles", + srcs = [ + "include/mlir/Dialect/Linalg/IR/LinalgBase.td", + "include/mlir/Dialect/Linalg/IR/LinalgOps.td", + ], + includes = ["include"], + deps = [ + ":ControlFlowInterfacesTdFiles", + ":InferTypeOpInterfaceTdFiles", + ":LoopLikeInterfaceTdFiles", + ":OpBaseTdFiles", + ":SideEffectInterfacesTdFiles", + ":ViewLikeInterfaceTdFiles", + ], +) + +gentbl_cc_library( + name = "LinalgOpsIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-decls"], + "include/mlir/Dialect/Linalg/IR/LinalgOps.h.inc", + ), + ( + ["-gen-op-defs"], + "include/mlir/Dialect/Linalg/IR/LinalgOps.cpp.inc", + ), + ( + [ + "-gen-dialect-decls", + "-dialect=linalg", + ], + "include/mlir/Dialect/Linalg/IR/LinalgOpsDialect.h.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/Linalg/IR/LinalgOps.td", + deps = [":LinalgOpsTdFiles"], +) + +genlinalg( + name = "LinalgNamedStructuredOpsTcIncGen", + src = "include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOpsSpec.tc", + linalg_outs = [ + ( + "-gen-impl -o=$@", + "include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.tcgen.cpp.inc", + ), + ( + "-gen-ods-decl -o=$@", + "include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.tcgen.td", + ), + ], + linalggen = ":mlir-linalg-ods-gen", +) + +genlinalg( + name = "LinalgNamedStructuredOpsYamlIncGen", + src = "include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml", + linalg_outs = [ + ( + "-o-impl=$@", + "include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yamlgen.cpp.inc", + ), + ( + "-o-ods-decl=$@", + "include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yamlgen.td", + ), + ], + linalggen = ":mlir-linalg-ods-yaml-gen", +) + +td_library( + name = "LinalgStructuredOpsTdFiles", + srcs = [ + "include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td", + "include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.tcgen.td", + "include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yamlgen.td", + "include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td", + ], + includes = ["include"], + deps = [ + ":CopyOpInterfaceTdFiles", + ":LinalgOpsTdFiles", + ":OpBaseTdFiles", + ":SideEffectInterfacesTdFiles", + ], +) + +gentbl_cc_library( + name = "LinalgStructuredOpsIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-decls"], + "include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.h.inc", + ), + ( + ["-gen-op-defs"], + "include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td", + deps = [":LinalgStructuredOpsTdFiles"], +) + +gentbl_cc_library( + name = "LinalgInterfacesIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-interface-decls"], + "include/mlir/Dialect/Linalg/IR/LinalgInterfaces.h.inc", + ), + ( + ["-gen-op-interface-defs"], + "include/mlir/Dialect/Linalg/IR/LinalgInterfaces.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td", + deps = [":LinalgStructuredOpsTdFiles"], +) + +td_library( + name = "LinalgDocTdFiles", + srcs = ["include/mlir/Dialect/Linalg/IR/LinalgDoc.td"], + includes = ["include"], + deps = [ + ":LinalgOpsTdFiles", + ":LinalgStructuredOpsTdFiles", + ], +) + +gentbl_cc_library( + name = "LinalgDocIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-doc"], + "g3doc/Dialects/Linalg/LinalgOps.md", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/Linalg/IR/LinalgDoc.td", + deps = [":LinalgDocTdFiles"], +) + +cc_library( + name = "LinalgToLLVM", + srcs = glob([ + "lib/Conversion/LinalgToLLVM/*.cpp", + "lib/Conversion/LinalgToLLVM/*.h", + ]) + ["lib/Conversion/PassDetail.h"], + hdrs = glob([ + "include/mlir/Conversion/LinalgToLLVM/*.h", + ]), + includes = ["include"], + deps = [ + ":AffineToStandard", + ":Analysis", + ":ConversionPassIncGen", + ":IR", + ":LLVMDialect", + ":LinalgOps", + ":LinalgTransforms", + ":Pass", + ":SCFDialect", + ":SCFToStandard", + ":StandardOps", + ":StandardToLLVM", + ":Support", + ":Transforms", + ":VectorToLLVM", + ":VectorToSCF", + "//llvm:Core", + "//llvm:Support", + ], +) + +cc_library( + name = "LinalgToStandard", + srcs = glob([ + "lib/Conversion/LinalgToStandard/*.cpp", + "lib/Conversion/LinalgToStandard/*.h", + ]) + ["lib/Conversion/PassDetail.h"], + hdrs = glob([ + "include/mlir/Conversion/LinalgToStandard/*.h", + ]), + includes = ["include"], + deps = [ + ":Affine", + ":ConversionPassIncGen", + ":IR", + ":LinalgOps", + ":LinalgTransforms", + ":MemRefDialect", + ":Pass", + ":SCFDialect", + ":StandardOps", + ":Support", + ":Transforms", + "//llvm:Core", + "//llvm:Support", + ], +) + +cc_library( + name = "LinalgToSPIRV", + srcs = glob([ + "lib/Conversion/LinalgToSPIRV/*.cpp", + "lib/Conversion/LinalgToSPIRV/*.h", + ]) + ["lib/Conversion/PassDetail.h"], + hdrs = glob([ + "include/mlir/Conversion/LinalgToSPIRV/*.h", + ]), + includes = ["include"], + deps = [ + ":ConversionPassIncGen", + ":DialectUtils", + ":IR", + ":LinalgOps", + ":LinalgTransforms", + ":Pass", + ":SPIRVConversion", + ":SPIRVDialect", + ":StandardOps", + ":TransformUtils", + ], +) + +cc_library( + name = "LinalgOps", + srcs = [ + "lib/Dialect/Linalg/IR/LinalgOps.cpp", + "lib/Dialect/Linalg/IR/LinalgTypes.cpp", + ], + hdrs = [ + "include/mlir/Dialect/Linalg/IR/LinalgOps.h", + "include/mlir/Dialect/Linalg/IR/LinalgTypes.h", + ], + includes = ["include"], + deps = [ + ":Affine", + ":CopyOpInterface", + ":DialectUtils", + ":IR", + ":InferTypeOpInterface", + ":LinalgInterfaces", + ":LinalgInterfacesIncGen", + ":LinalgNamedStructuredOpsTcIncGen", + ":LinalgNamedStructuredOpsYamlIncGen", + ":LinalgOpsIncGen", + ":LinalgStructuredOpsIncGen", + ":MemRefDialect", + ":Parser", + ":SideEffectInterfaces", + ":StandardOps", + ":Support", + ":TensorDialect", + ":ViewLikeInterface", + "//llvm:Support", + ], +) + +gentbl_cc_library( + name = "LinalgPassIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + [ + "-gen-pass-decls", + "-name=Linalg", + ], + "include/mlir/Dialect/Linalg/Passes.h.inc", + ), + ( + [ + "-gen-pass-capi-header", + "--prefix=Linalg", + ], + "include/mlir/Dialect/Linalg/Passes.capi.h.inc", + ), + ( + [ + "-gen-pass-capi-impl", + "--prefix=Linalg", + ], + "include/mlir/Dialect/Linalg/Passes.capi.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/Linalg/Passes.td", + deps = [":PassBaseTdFiles"], +) + +cc_library( + name = "LinalgTransforms", + srcs = glob([ + "lib/Dialect/Linalg/Transforms/*.cpp", + "lib/Dialect/Linalg/Transforms/*.h", + ]) + [ + "lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp", + "lib/Dialect/Linalg/Utils/Utils.cpp", + ], + hdrs = [ + "include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h", + "include/mlir/Dialect/Linalg/Passes.h", + "include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h", + "include/mlir/Dialect/Linalg/Transforms/Hoisting.h", + "include/mlir/Dialect/Linalg/Transforms/Transforms.h", + "include/mlir/Dialect/Linalg/Utils/Utils.h", + ], + includes = ["include"], + deps = [ + ":Affine", + ":AffineUtils", + ":Analysis", + ":ComplexDialect", + ":DialectUtils", + ":IR", + ":LinalgOps", + ":LinalgPassIncGen", + ":LinalgStructuredOpsIncGen", + ":MathDialect", + ":MemRefDialect", + ":Pass", + ":SCFDialect", + ":SCFTransforms", + ":StandardOps", + ":StandardOpsTransforms", + ":Support", + ":TensorDialect", + ":TransformUtils", + ":VectorOps", + ":VectorToSCF", + "//llvm:Support", + ], +) + +td_library( + name = "VectorOpsTdFiles", + srcs = ["include/mlir/Dialect/Vector/VectorOps.td"], + includes = ["include"], + deps = [ + ":OpBaseTdFiles", + ":SideEffectInterfacesTdFiles", + ":VectorInterfacesTdFiles", + ":ViewLikeInterfaceTdFiles", + ], +) + +gentbl_cc_library( + name = "VectorOpsIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-decls"], + "include/mlir/Dialect/Vector/VectorOps.h.inc", + ), + ( + ["-gen-op-defs"], + "include/mlir/Dialect/Vector/VectorOps.cpp.inc", + ), + ( + [ + "-gen-dialect-decls", + "-dialect=vector", + ], + "include/mlir/Dialect/Vector/VectorOpsDialect.h.inc", + ), + ( + ["-gen-enum-decls"], + "include/mlir/Dialect/Vector/VectorOpsEnums.h.inc", + ), + ( + ["-gen-enum-defs"], + "include/mlir/Dialect/Vector/VectorOpsEnums.cpp.inc", + ), + ( + ["-gen-op-doc"], + "g3doc/Dialects/Vector/VectorOps.md", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/Vector/VectorOps.td", + deps = [":VectorOpsTdFiles"], +) + +cc_library( + name = "VectorToLLVM", + srcs = glob([ + "lib/Conversion/VectorToLLVM/*.cpp", + "lib/Conversion/VectorToLLVM/*.h", + ]) + ["lib/Conversion/PassDetail.h"], + hdrs = glob([ + "include/mlir/Conversion/VectorToLLVM/*.h", + ]), + includes = ["include"], + deps = [ + ":AMX", + ":AMXTransforms", + ":ArmNeon", + ":ArmSVE", + ":ArmSVETransforms", + ":ConversionPassIncGen", + ":DialectUtils", + ":IR", + ":LLVMDialect", + ":MemRefDialect", + ":Pass", + ":StandardOps", + ":StandardToLLVM", + ":Support", + ":ToLLVMIRTranslation", + ":Transforms", + ":VectorOps", + ":X86Vector", + ":X86VectorTransforms", + "//llvm:Core", + "//llvm:Support", + ], +) + +cc_library( + name = "VectorToGPU", + srcs = glob([ + "lib/Conversion/VectorToGPU/*.cpp", + "lib/Conversion/VectorToGPU/*.h", + ]) + ["lib/Conversion/PassDetail.h"], + hdrs = glob([ + "include/mlir/Conversion/VectorToGPU/*.h", + ]), + includes = ["include"], + deps = [ + ":Affine", + ":Analysis", + ":ConversionPassIncGen", + ":DialectUtils", + ":GPUDialect", + ":IR", + ":LLVMDialect", + ":MemRefDialect", + ":Pass", + ":SCFDialect", + ":StandardOps", + ":StandardToLLVM", + ":Support", + ":Transforms", + ":VectorOps", + "//llvm:Core", + "//llvm:Support", + ], +) + +cc_library( + name = "VectorToSCF", + srcs = glob([ + "lib/Conversion/VectorToSCF/*.cpp", + "lib/Conversion/VectorToSCF/*.h", + ]) + ["lib/Conversion/PassDetail.h"], + hdrs = glob([ + "include/mlir/Conversion/VectorToSCF/*.h", + ]), + includes = ["include"], + deps = [ + ":Affine", + ":AffineUtils", + ":ConversionPassIncGen", + ":IR", + ":LLVMDialect", + ":MemRefDialect", + ":Pass", + ":SCFDialect", + ":StandardOps", + ":StandardToLLVM", + ":Support", + ":Transforms", + ":VectorOps", + "//llvm:Core", + "//llvm:Support", + ], +) + +td_library( + name = "TosaDialectTdFiles", + srcs = glob(["include/mlir/Dialect/Tosa/IR/*.td"]), + deps = [ + ":LoopLikeInterfaceTdFiles", + ":OpBaseTdFiles", + ":SideEffectInterfacesTdFiles", + ], +) + +gentbl_cc_library( + name = "TosaDialectIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-decls"], + "include/mlir/Dialect/Tosa/IR/TosaOps.h.inc", + ), + ( + ["-gen-op-defs"], + "include/mlir/Dialect/Tosa/IR/TosaOps.cpp.inc", + ), + ( + ["-gen-struct-attr-decls"], + "include/mlir/Dialect/Tosa/IR/TosaStructs.h.inc", + ), + ( + ["-gen-struct-attr-defs"], + "include/mlir/Dialect/Tosa/IR/TosaStructs.cpp.inc", + ), + ( + ["-gen-dialect-decls"], + "include/mlir/Dialect/Tosa/IR/TosaOpsDialect.h.inc", + ), + ( + ["-gen-op-doc"], + "g3doc/Dialects/Tosa/TosaOps.md", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/Tosa/IR/TosaOps.td", + deps = [":TosaDialectTdFiles"], +) + +gentbl_cc_library( + name = "TosaInterfacesIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-interface-decls"], + "include/mlir/Dialect/Tosa/IR/TosaInterfaces.h.inc", + ), + ( + ["-gen-op-interface-defs"], + "include/mlir/Dialect/Tosa/IR/TosaInterfaces.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/Tosa/IR/TosaInterfaces.td", + deps = [":TosaDialectTdFiles"], +) + +gentbl_cc_library( + name = "TosaPassIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + [ + "-gen-pass-decls", + "-name=TosaOpt", + ], + "include/mlir/Dialect/Tosa/Transforms/Passes.h.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/Tosa/Transforms/Passes.td", + deps = [":PassBaseTdFiles"], +) + +cc_library( + name = "TosaDialect", + srcs = glob([ + "lib/Dialect/Tosa/IR/*.cpp", + "lib/Dialect/Tosa/IR/*.h", + "lib/Dialect/Tosa/Utils/*.cpp", + "lib/Dialect/Tosa/Transforms/*.cpp", + ]), + hdrs = glob([ + "include/mlir/Dialect/Tosa/IR/*.h", + "include/mlir/Dialect/Tosa/Utils/*.h", + "include/mlir/Dialect/Tosa/Transforms/*.h", + ]), + includes = ["include"], + deps = [ + ":Dialect", + ":IR", + ":LoopLikeInterface", + ":Pass", + ":QuantOps", + ":SideEffectInterfaces", + ":StandardOps", + ":TosaDialectIncGen", + ":TosaInterfacesIncGen", + ":TosaPassIncGen", + ":TransformUtils", + ], +) + +cc_library( + name = "TosaToLinalg", + srcs = glob([ + "lib/Conversion/TosaToLinalg/*.cpp", + "lib/Conversion/TosaToLinalg/*.h", + ]) + ["lib/Conversion/PassDetail.h"], + hdrs = glob([ + "include/mlir/Conversion/TosaToLinalg/*.h", + ]), + includes = [ + "include", + "lib/Conversion/TosaToLinalg", + ], + deps = [ + ":ConversionPassIncGen", + ":IR", + ":LinalgOps", + ":MathDialect", + ":MemRefDialect", + ":Pass", + ":StandardOps", + ":TensorDialect", + ":TosaDialect", + ":Transforms", + ], +) + +cc_library( + name = "TosaToSCF", + srcs = glob([ + "lib/Conversion/TosaToSCF/*.cpp", + "lib/Conversion/TosaToSCF/*.h", + ]) + ["lib/Conversion/PassDetail.h"], + hdrs = glob([ + "include/mlir/Conversion/TosaToSCF/*.h", + ]), + includes = [ + "include", + "lib/Conversion/TosaToSCF", + ], + deps = [ + ":ConversionPassIncGen", + ":IR", + ":Pass", + ":SCFDialect", + ":TensorDialect", + ":TosaDialect", + ":Transforms", + ], +) + +cc_library( + name = "TosaToStandard", + srcs = glob([ + "lib/Conversion/TosaToStandard/*.cpp", + "lib/Conversion/TosaToStandard/*.h", + ]) + ["lib/Conversion/PassDetail.h"], + hdrs = glob([ + "include/mlir/Conversion/TosaToStandard/*.h", + ]), + includes = [ + "include", + "lib/Conversion/TosaToStandard", + ], + deps = [ + ":ConversionPassIncGen", + ":IR", + ":Pass", + ":StandardOps", + ":TensorDialect", + ":TosaDialect", + ":Transforms", + ], +) + +td_library( + name = "ComplexOpsTdFiles", + srcs = [ + "include/mlir/Dialect/Complex/IR/ComplexBase.td", + "include/mlir/Dialect/Complex/IR/ComplexOps.td", + ], + includes = ["include"], + deps = [ + ":OpBaseTdFiles", + ":SideEffectInterfacesTdFiles", + ], +) + +gentbl_cc_library( + name = "ComplexBaseIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + [ + "-gen-dialect-decls", + "-dialect=complex", + ], + "include/mlir/Dialect/Complex/IR/ComplexOpsDialect.h.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/Complex/IR/ComplexBase.td", + deps = [":ComplexOpsTdFiles"], +) + +gentbl_cc_library( + name = "ComplexOpsIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-decls"], + "include/mlir/Dialect/Complex/IR/ComplexOps.h.inc", + ), + ( + ["-gen-op-defs"], + "include/mlir/Dialect/Complex/IR/ComplexOps.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/Complex/IR/ComplexOps.td", + deps = [":ComplexOpsTdFiles"], +) + +cc_library( + name = "ComplexDialect", + srcs = glob( + [ + "lib/Dialect/Complex/IR/*.cpp", + "lib/Dialect/Complex/IR/*.h", + ], + ), + hdrs = ["include/mlir/Dialect/Complex/IR/Complex.h"], + includes = ["include"], + deps = [ + ":ComplexBaseIncGen", + ":ComplexOpsIncGen", + ":IR", + ":SideEffectInterfaces", + ":Support", + ":VectorInterfaces", + "//llvm:Support", + ], +) + +cc_library( + name = "ComplexToLLVM", + srcs = glob([ + "lib/Conversion/ComplexToLLVM/*.cpp", + "lib/Conversion/ComplexToLLVM/*.h", + ]) + ["lib/Conversion/PassDetail.h"], + hdrs = glob([ + "include/mlir/Conversion/ComplexToLLVM/*.h", + ]), + includes = ["include"], + deps = [ + ":ComplexDialect", + ":ConversionPassIncGen", + ":IR", + ":LLVMDialect", + ":Pass", + ":StandardToLLVM", + ":Support", + ":Transforms", + "//llvm:Core", + "//llvm:Support", + ], +) + +cc_library( + name = "ComplexToStandard", + srcs = glob([ + "lib/Conversion/ComplexToStandard/*.cpp", + "lib/Conversion/ComplexToStandard/*.h", + ]) + ["lib/Conversion/PassDetail.h"], + hdrs = glob([ + "include/mlir/Conversion/ComplexToStandard/*.h", + ]), + includes = ["include"], + deps = [ + ":ComplexDialect", + ":ConversionPassIncGen", + ":IR", + ":MathDialect", + ":Pass", + ":StandardOps", + ":Transforms", + ], +) + +exports_files([ + "include/mlir/Bindings/Python/Attributes.td", + "include/mlir/Dialect/DLTI/DLTIBase.td", + "include/mlir/Dialect/LLVMIR/LLVMOpBase.td", + "include/mlir/Dialect/Linalg/IR/LinalgOps.td", + "include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td", + "include/mlir/Dialect/Shape/IR/ShapeBase.td", + "include/mlir/Dialect/Shape/IR/ShapeOps.td", + "include/mlir/Dialect/StandardOps/IR/Ops.td", + "include/mlir/Dialect/Vector/VectorOps.td", + "include/mlir/Dialect/X86Vector/X86Vector.td", + "include/mlir/IR/OpAsmInterface.td", + "include/mlir/IR/OpBase.td", + "include/mlir/IR/RegionKindInterface.td", + "include/mlir/IR/SymbolInterfaces.td", + "include/mlir/IR/TensorEncoding.td", + "include/mlir/Interfaces/CallInterfaces.h", + "include/mlir/Interfaces/CallInterfaces.td", + "include/mlir/Interfaces/CastInterfaces.h", + "include/mlir/Interfaces/CastInterfaces.td", + "include/mlir/Interfaces/ControlFlowInterfaces.h", + "include/mlir/Interfaces/ControlFlowInterfaces.td", + "include/mlir/Interfaces/CopyOpInterface.td", + "include/mlir/Interfaces/DataLayoutInterfaces.td", + "include/mlir/Interfaces/InferTypeOpInterface.td", + "include/mlir/Interfaces/LoopLikeInterface.td", + "include/mlir/Interfaces/SideEffectInterfaceBase.td", + "include/mlir/Interfaces/SideEffectInterfaces.td", + "include/mlir/Interfaces/VectorInterfaces.td", + "include/mlir/Interfaces/ViewLikeInterface.td", + "include/mlir/Transforms/InliningUtils.h", +]) + +td_library( + name = "MathOpsTdFiles", + srcs = [ + "include/mlir/Dialect/Math/IR/MathBase.td", + "include/mlir/Dialect/Math/IR/MathOps.td", + ], + includes = ["include"], + deps = [ + ":OpBaseTdFiles", + ":SideEffectInterfacesTdFiles", + ":VectorInterfacesTdFiles", + ], +) + +gentbl_cc_library( + name = "MathBaseIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + [ + "-gen-dialect-decls", + "-dialect=math", + ], + "include/mlir/Dialect/Math/IR/MathOpsDialect.h.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/Math/IR/MathBase.td", + deps = [":MathOpsTdFiles"], +) + +gentbl_cc_library( + name = "MathOpsIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-decls"], + "include/mlir/Dialect/Math/IR/MathOps.h.inc", + ), + ( + ["-gen-op-defs"], + "include/mlir/Dialect/Math/IR/MathOps.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/Math/IR/MathOps.td", + deps = [":MathOpsTdFiles"], +) + +cc_library( + name = "MathDialect", + srcs = glob( + [ + "lib/Dialect/Math/IR/*.cpp", + "lib/Dialect/Math/IR/*.h", + ], + ), + hdrs = [ + "include/mlir/Dialect/Math/IR/Math.h", + "include/mlir/Transforms/InliningUtils.h", + ], + includes = ["include"], + deps = [ + ":IR", + ":MathBaseIncGen", + ":MathOpsIncGen", + ":SideEffectInterfaces", + ":Support", + ":VectorInterfaces", + "//llvm:Support", + ], +) + +cc_library( + name = "MathTransforms", + srcs = glob([ + "lib/Dialect/Math/Transforms/*.cpp", + "lib/Dialect/Math/Transforms/*.h", + ]), + hdrs = glob(["include/mlir/Dialect/Math/Transforms/*.h"]), + includes = ["include"], + deps = [ + ":IR", + ":LLVMDialect", + ":MathDialect", + ":Pass", + ":SCFDialect", + ":StandardOps", + ":Support", + ":Transforms", + ":VectorOps", + "//llvm:Support", + ], +) + +cc_library( + name = "MathToLibm", + srcs = glob([ + "lib/Conversion/MathToLibm/*.cpp", + "lib/Conversion/MathToLibm/*.h", + ]) + ["lib/Conversion/PassDetail.h"], + hdrs = glob([ + "include/mlir/Conversion/MathToLibm/*.h", + ]), + includes = ["include"], + deps = [ + ":ConversionPassIncGen", + ":IR", + ":LLVMDialect", + ":MathDialect", + ":Pass", + ":StandardOps", + ":Support", + ":Transforms", + ":VectorOps", + "//llvm:Core", + "//llvm:Support", + ], +) + +td_library( + name = "MemRefOpsTdFiles", + srcs = [ + "include/mlir/Dialect/MemRef/IR/MemRefBase.td", + "include/mlir/Dialect/MemRef/IR/MemRefOps.td", + ], + includes = ["include"], + deps = [ + ":CastInterfacesTdFiles", + ":ControlFlowInterfacesTdFiles", + ":CopyOpInterfaceTdFiles", + ":OpBaseTdFiles", + ":SideEffectInterfacesTdFiles", + ":ViewLikeInterfaceTdFiles", + ], +) + +gentbl_cc_library( + name = "MemRefBaseIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + [ + "-gen-dialect-decls", + "-dialect=memref", + ], + "include/mlir/Dialect/MemRef/IR/MemRefOpsDialect.h.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/MemRef/IR/MemRefBase.td", + deps = [":MemRefOpsTdFiles"], +) + +gentbl_cc_library( + name = "MemRefOpsIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + ["-gen-op-decls"], + "include/mlir/Dialect/MemRef/IR/MemRefOps.h.inc", + ), + ( + ["-gen-op-defs"], + "include/mlir/Dialect/MemRef/IR/MemRefOps.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/MemRef/IR/MemRefOps.td", + deps = [":MemRefOpsTdFiles"], +) + +cc_library( + name = "MemRefDialect", + srcs = glob( + [ + "lib/Dialect/MemRef/IR/*.cpp", + "lib/Dialect/MemRef/IR/*.h", + "lib/Dialect/MemRef/Utils/*.cpp", + ], + ), + hdrs = [ + "include/mlir/Dialect/MemRef/IR/MemRef.h", + "include/mlir/Dialect/MemRef/Utils/MemRefUtils.h", + ], + includes = ["include"], + deps = [ + ":ControlFlowInterfaces", + ":CopyOpInterface", + ":IR", + ":InferTypeOpInterface", + ":MemRefBaseIncGen", + ":MemRefOpsIncGen", + ":StandardOps", + ":TensorDialect", + ":ViewLikeInterface", + "//llvm:Support", + ], +) + +gentbl_cc_library( + name = "MemRefPassIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + [ + "-gen-pass-decls", + "-name=MemRef", + ], + "include/mlir/Dialect/MemRef/Transforms/Passes.h.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/MemRef/Transforms/Passes.td", + deps = [":PassBaseTdFiles"], +) + +cc_library( + name = "MemRefTransforms", + srcs = glob( + [ + "lib/Dialect/MemRef/Transforms/*.cpp", + "lib/Dialect/MemRef/Transforms/*.h", + ], + ), + hdrs = glob(["include/mlir/Dialect/MemRef/Transforms/*.h"]), + includes = ["include"], + deps = [ + ":Affine", + ":IR", + ":InferTypeOpInterface", + ":MemRefDialect", + ":MemRefPassIncGen", + ":Pass", + ":StandardOps", + ":Support", + ":TensorDialect", + ":Transforms", + ":VectorOps", + "//llvm:Support", + ], +) + +td_library( + name = "DLTIDialectTdFiles", + srcs = [ + "include/mlir/Dialect/DLTI/DLTI.td", + "include/mlir/Dialect/DLTI/DLTIBase.td", + ], + includes = ["include"], + deps = [":OpBaseTdFiles"], +) + +gentbl_cc_library( + name = "DLTIBaseIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + [ + "-gen-dialect-decls", + "-dialect=dlti", + ], + "include/mlir/Dialect/DLTI/DLTIDialect.h.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/DLTI/DLTIBase.td", + deps = [":OpBaseTdFiles"], +) + +cc_library( + name = "DLTIDialect", + srcs = glob(["lib/Dialect/DLTI/*.cpp"]), + hdrs = glob(["include/mlir/Dialect/DLTI/*.h"]), + includes = ["include"], + deps = [ + ":DLTIBaseIncGen", + ":DataLayoutInterfaces", + ":IR", + "//llvm:Support", + ], +) + +gentbl_cc_library( + name = "ReducerIncGen", + strip_include_prefix = "include", + tbl_outs = [ + ( + [ + "-gen-pass-decls", + "-name=Reducer", + ], + "include/mlir/Reducer/Passes.h.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Reducer/Passes.td", + deps = [ + ":PassBaseTdFiles", + ":ReducerTdFiles", + ], +) + +cc_library( + name = "Reducer", + srcs = glob(["lib/Reducer/*.cpp"]), + hdrs = glob(["include/mlir/Reducer/*.h"]), + includes = ["include"], + deps = [ + ":IR", + ":Pass", + ":ReducerIncGen", + ":Rewrite", + ":Support", + ":TransformUtils", + "//llvm:Support", + ], +) + +cc_library( + name = "MlirReduceLib", + srcs = ["lib/Tools/mlir-reduce/MlirReduceMain.cpp"], + hdrs = ["include/mlir/Tools/mlir-reduce/MlirReduceMain.h"], + includes = ["include"], + deps = [ + ":IR", + ":Parser", + ":Pass", + ":Reducer", + ":Rewrite", + ":Support", + "//llvm:Support", + ], +) + +cc_binary( + name = "mlir-reduce", + srcs = ["tools/mlir-reduce/mlir-reduce.cpp"], + includes = ["include"], + local_defines = ["MLIR_INCLUDE_TESTS"], + stamp = 0, + deps = [ + ":AllPassesAndDialects", + ":IR", + ":MlirReduceLib", + ":Pass", + "//llvm:Support", + "//mlir/test:TestDialect", + ], +) diff --git a/utils/bazel/llvm-project-overlay/mlir/build_defs.bzl b/utils/bazel/llvm-project-overlay/mlir/build_defs.bzl new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm-project-overlay/mlir/build_defs.bzl @@ -0,0 +1,26 @@ +# 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], +) diff --git a/utils/bazel/llvm-project-overlay/mlir/linalggen.bzl b/utils/bazel/llvm-project-overlay/mlir/linalggen.bzl new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm-project-overlay/mlir/linalggen.bzl @@ -0,0 +1,43 @@ +# 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)), + ) + + # List of opts that do not generate cc files. + hdrs = [f for (opts, f) in linalg_outs] + native.cc_library( + name = name, + hdrs = hdrs, + textual_hdrs = hdrs, + ) diff --git a/utils/bazel/llvm-project-overlay/mlir/tblgen.bzl b/utils/bazel/llvm-project-overlay/mlir/tblgen.bzl new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm-project-overlay/mlir/tblgen.bzl @@ -0,0 +1,480 @@ +# 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.""" + +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(ctx.genfiles_dir.path + "/" + include) + prefixed_includes.append(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 not include.startswith("/"): + include = "/" + package + "/" + include + include = 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, + ) + return [ + DefaultInfo(files = trans_srcs), + 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 we have two types of includes here. The deprecated ones expanded + # only by "_prefix_roots" are already relative to the execution root, i.e. + # may contain an `external/` prefix if the current workspace + # is not the main workspace (where workspace_name is something configured + # per-project and therefore generally not known). Note that dirname also + # already includes this prefix. The new style of includes have it prepended + # automatically by `_resolve_includes` to avoid BUILD files having to depend + # on project specific configurations and Bazel implementation details. + trans_includes = _get_transitive_includes( + _resolve_includes(ctx, ctx.attr.includes + ["/"]) + + _prefix_roots(ctx, ctx.attr.td_includes + [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.", + ), + "td_includes": attr.string_list( + doc = "Include paths to add to the TableGen invocation. Paths are" + + " interpreted as relative to the current label's workspace" + + " root and applied from all roots available in the" + + " execution environment (source, genfiles, and bin" + + " directories). Deprecated. Use `includes` instead.", + ), + }, +) + +# TODO(gcmn): Figure out how to reduce duplication with _gentbl_rule_impl +def _gentbl_test_impl(ctx): + td_file = ctx.file.td_file + + trans_srcs = _get_transitive_srcs( + ctx.files.td_srcs + [td_file], + ctx.attr.deps, + ) + + # Note that we have two types of includes here. The deprecated ones expanded + # only by "_prefix_roots" are already relative to the execution root, i.e. + # may contain an `external/` prefix if the current workspace + # is not the main workspace (where workspace_name is something configured + # per-project and therefore generally not known). Note that dirname also + # already includes this prefix. The new style of includes have it prepended + # automatically by `_resolve_includes` to avoid BUILD files having to depend + # on project specific configurations and Bazel implementation details. + trans_includes = _get_transitive_includes( + _resolve_includes(ctx, ctx.attr.includes + ["/"]) + + _prefix_roots(ctx, ctx.attr.td_includes + [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, + ) + + return [DefaultInfo( + runfiles = ctx.runfiles( + [ctx.executable.tblgen], + transitive_files = trans_srcs, + ), + )] + +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)", + # Match genrule behavior + output_to_genfiles = True, + 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"), + "td_includes": attr.string_list(doc = "See gentbl_rule.td_includes"), + }, +) + +def gentbl_filegroup( + name, + tblgen, + td_file, + tbl_outs, + td_srcs = [], + td_includes = [], + 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 + td_includes: See gentbl_rule.td_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. + """ + + llvm_project_execroot_path = Label("//mlir:tblgen.bzl", relative_to_caller_repository = False).workspace_root + + # TODO(gcmn): Update callers to td_library and explicit includes and drop + # this hardcoded include. + hardcoded_includes = [ + "%s/mlir/include" % llvm_project_execroot_path, + ] + + 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, + td_includes = td_includes + hardcoded_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, + td_includes = td_includes + hardcoded_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 = [], + td_includes = [], + includes = [], + td_relative_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 + td_includes: See gentbl_rule.td_includes + td_relative_includes: An alias for "includes". Deprecated. Use includes + instead. + 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, + td_includes = td_includes, + includes = includes + td_relative_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 + ) + +def gentbl( + name, + tblgen, + td_file, + tbl_outs, + td_srcs = [], + td_includes = [], + includes = [], + td_relative_includes = [], + deps = [], + test = False, + **kwargs): + """Deprecated version of gentbl_cc_library. + + Accepts tbl_outs as list of pairs with the first element of the pair being + a whitespace-separated string of options rather than a list of options. + """ + + split_opts = [] + for (opts_string, out) in tbl_outs: + opts = opts_string.split(" ") if opts_string else [] + + # Filter out empty options + opts = [opt for opt in opts if opt] + + split_opts.append((opts, out)) + + gentbl_cc_library( + name = name, + tblgen = tblgen, + td_file = td_file, + tbl_outs = split_opts, + td_srcs = td_srcs, + td_includes = td_includes, + includes = includes, + td_relative_includes = td_relative_includes, + deps = deps, + test = test, + deprecation = "generated by gentbl; use gentbl_cc_library or gentbl_filegroup instead", + **kwargs + ) diff --git a/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel @@ -0,0 +1,516 @@ +# 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("//mlir:tblgen.bzl", "gentbl_cc_library", "td_library") + +package( + default_visibility = ["//visibility:public"], + licenses = ["notice"], +) + +cc_library( + name = "IRProducingAPITest", + hdrs = ["APITest.h"], + includes = ["."], +) + +cc_library( + name = "TestAnalysis", + srcs = glob(["lib/Analysis/*.cpp"]), + includes = ["lib/Dialect/Test"], + deps = [ + ":TestDialect", + "//llvm:Support", + "//mlir:Affine", + "//mlir:Analysis", + "//mlir:IR", + "//mlir:MemRefDialect", + "//mlir:Pass", + "//mlir:Support", + ], +) + +td_library( + name = "TestOpTdFiles", + srcs = [ + "lib/Dialect/Test/TestInterfaces.td", + "lib/Dialect/Test/TestOps.td", + "//mlir:include/mlir/Dialect/DLTI/DLTIBase.td", + "//mlir:include/mlir/IR/OpAsmInterface.td", + "//mlir:include/mlir/IR/RegionKindInterface.td", + "//mlir:include/mlir/IR/SymbolInterfaces.td", + "//mlir:include/mlir/Interfaces/CallInterfaces.td", + "//mlir:include/mlir/Interfaces/ControlFlowInterfaces.td", + "//mlir:include/mlir/Interfaces/CopyOpInterface.td", + "//mlir:include/mlir/Interfaces/DataLayoutInterfaces.td", + "//mlir:include/mlir/Interfaces/InferTypeOpInterface.td", + ], + deps = [ + "//mlir:OpBaseTdFiles", + "//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-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 = "//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 = "//mlir:mlir-tblgen", + td_file = "lib/Dialect/Test/TestInterfaces.td", + test = True, + deps = [ + "//mlir:OpBaseTdFiles", + "//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 = "//mlir:mlir-tblgen", + td_file = "lib/Dialect/Test/TestAttrDefs.td", + td_srcs = [ + ":TestOpTdFiles", + ], + test = True, +) + +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 = "//mlir:mlir-tblgen", + td_file = "lib/Dialect/Test/TestTypeDefs.td", + test = True, + deps = [ + ":TestOpTdFiles", + "//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:Support", + "//mlir:ControlFlowInterfaces", + "//mlir:CopyOpInterface", + "//mlir:DLTIDialect", + "//mlir:DataLayoutInterfaces", + "//mlir:DerivedAttributeOpInterface", + "//mlir:Dialect", + "//mlir:IR", + "//mlir:InferTypeOpInterface", + "//mlir:MemRefDialect", + "//mlir:Pass", + "//mlir:Reducer", + "//mlir:SideEffects", + "//mlir:StandardOps", + "//mlir:StandardOpsTransforms", + "//mlir:TensorDialect", + "//mlir:TransformUtils", + "//mlir:Transforms", + ], +) + +cc_library( + name = "TestIR", + srcs = glob(["lib/IR/*.cpp"]), + deps = [ + ":TestDialect", + "//llvm:Support", + "//mlir:Analysis", + "//mlir:IR", + "//mlir:LinalgOps", + "//mlir:Pass", + "//mlir:StandardOps", + "//mlir:Support", + ], +) + +cc_library( + name = "TestPass", + srcs = glob(["lib/Pass/*.cpp"]), + deps = [ + "//llvm:Support", + "//mlir:IR", + "//mlir:Pass", + "//mlir:Support", + ], +) + +cc_library( + name = "TestRewrite", + srcs = [ + "lib/Rewrite/TestPDLByteCode.cpp", + ], + deps = [ + "//mlir:IR", + "//mlir:Pass", + "//mlir:Support", + "//mlir:TransformUtils", + ], +) + +cc_library( + name = "TestReducer", + srcs = [ + "lib/Reducer/MLIRTestReducer.cpp", + ], + deps = [ + "//mlir:IR", + "//mlir:Pass", + "//mlir:Support", + ], +) + +cc_library( + name = "TestTransforms", + srcs = glob(["lib/Transforms/*.cpp"]), + defines = ["MLIR_CUDA_CONVERSIONS_ENABLED"], + includes = ["lib/Dialect/Test"], + deps = [ + ":TestDialect", + "//llvm:Support", + "//mlir:Affine", + "//mlir:Analysis", + "//mlir:IR", + "//mlir:MathDialect", + "//mlir:Pass", + "//mlir:SCFDialect", + "//mlir:SPIRVDialect", + "//mlir:StandardOps", + "//mlir:TransformUtils", + ], +) + +cc_library( + name = "TestStandardToLLVM", + srcs = glob(["lib/Conversion/StandardToLLVM/*.cpp"]), + defines = ["MLIR_CUDA_CONVERSIONS_ENABLED"], + includes = ["lib/Dialect/Test"], + deps = [ + ":TestDialect", + "//mlir:LLVMDialect", + "//mlir:LLVMTransforms", + "//mlir:Pass", + "//mlir:StandardOps", + ], +) + +cc_library( + name = "TestAffine", + srcs = glob([ + "lib/Dialect/Affine/*.cpp", + ]), + deps = [ + "//llvm:Support", + "//mlir:Affine", + "//mlir:AffineTransforms", + "//mlir:AffineUtils", + "//mlir:Analysis", + "//mlir:IR", + "//mlir:MemRefDialect", + "//mlir:Pass", + "//mlir:Support", + "//mlir:Transforms", + "//mlir:VectorOps", + ], +) + +cc_library( + name = "TestDLTI", + srcs = glob(["lib/Dialect/DLTI/*.cpp"]), + defines = ["MLIR_CUDA_CONVERSIONS_ENABLED"], + includes = ["lib/Dialect/Test"], + deps = [ + ":TestDialect", + "//mlir:Analysis", + "//mlir:DLTIDialect", + "//mlir:IR", + "//mlir:Pass", + ], +) + +cc_library( + name = "TestGPU", + srcs = glob(["lib/Dialect/GPU/*.cpp"]), + defines = ["MLIR_CUDA_CONVERSIONS_ENABLED"], + includes = ["lib/Dialect/Test"], + deps = [ + "//llvm:NVPTXCodeGen", + "//llvm:Support", + "//mlir:Affine", + "//mlir:GPUDialect", + "//mlir:GPUTransforms", + "//mlir:IR", + "//mlir:MemRefDialect", + "//mlir:NVVMToLLVMIRTranslation", + "//mlir:Pass", + "//mlir:ROCDLToLLVMIRTranslation", + "//mlir:SCFDialect", + "//mlir:SPIRVDialect", + "//mlir:StandardOps", + "//mlir:ToLLVMIRTranslation", + "//mlir:TransformUtils", + ], +) + +cc_library( + name = "TestLinalg", + srcs = glob(["lib/Dialect/Linalg/*.cpp"]), + defines = ["MLIR_CUDA_CONVERSIONS_ENABLED"], + includes = ["lib/Dialect/Test"], + deps = [ + "//llvm:Support", + "//mlir:Affine", + "//mlir:GPUDialect", + "//mlir:IR", + "//mlir:LinalgOps", + "//mlir:LinalgTransforms", + "//mlir:Pass", + "//mlir:StandardOps", + "//mlir:TransformUtils", + "//mlir:VectorOps", + "//mlir:VectorToSCF", + ], +) + +cc_library( + name = "TestMath", + srcs = glob(["lib/Dialect/Math/*.cpp"]), + defines = ["MLIR_CUDA_CONVERSIONS_ENABLED"], + includes = ["lib/Dialect/Test"], + deps = [ + "//mlir:LLVMDialect", + "//mlir:MathDialect", + "//mlir:MathTransforms", + "//mlir:Pass", + "//mlir:TransformUtils", + "//mlir:VectorOps", + ], +) + +cc_library( + name = "TestSCF", + srcs = glob(["lib/Dialect/SCF/*.cpp"]), + defines = ["MLIR_CUDA_CONVERSIONS_ENABLED"], + includes = ["lib/Dialect/Test"], + deps = [ + "//llvm:Support", + "//mlir:IR", + "//mlir:Pass", + "//mlir:SCFDialect", + "//mlir:TransformUtils", + ], +) + +cc_library( + name = "TestShapeDialect", + srcs = [ + "lib/Dialect/Shape/TestShapeFunctions.cpp", + ], + deps = [ + "//llvm:Support", + "//mlir:IR", + "//mlir:InferTypeOpInterface", + "//mlir:Pass", + "//mlir:Shape", + ], +) + +cc_library( + name = "TestSPIRV", + srcs = glob([ + "lib/Dialect/SPIRV/*.cpp", + ]), + deps = [ + "//mlir:GPUDialect", + "//mlir:IR", + "//mlir:Pass", + "//mlir:SPIRVConversion", + "//mlir:SPIRVDialect", + "//mlir:SPIRVModuleCombiner", + "//mlir:Transforms", + ], +) + +cc_library( + name = "TestStandardOps", + srcs = glob(["lib/Dialect/StandardOps/*.cpp"]), + defines = ["MLIR_CUDA_CONVERSIONS_ENABLED"], + includes = ["lib/Dialect/Test"], + deps = [ + ":TestDialect", + "//mlir:Affine", + "//mlir:IR", + "//mlir:Pass", + "//mlir:StandardOps", + "//mlir:StandardOpsTransforms", + "//mlir:TransformUtils", + ], +) + +cc_library( + name = "TestVector", + srcs = glob(["lib/Dialect/Vector/*.cpp"]), + defines = ["MLIR_CUDA_CONVERSIONS_ENABLED"], + includes = ["lib/Dialect/Test"], + deps = [ + "//mlir:Affine", + "//mlir:Analysis", + "//mlir:LinalgOps", + "//mlir:MemRefDialect", + "//mlir:Pass", + "//mlir:SCFDialect", + "//mlir:StandardOps", + "//mlir:TransformUtils", + "//mlir:VectorOps", + "//mlir:VectorToSCF", + ], +) + +cc_library( + name = "TestTypeDialect", + srcs = glob([ + "lib/Dialect/LLVMIR/*.cpp", + ]), + deps = [ + ":TestDialect", + "//mlir:IR", + "//mlir:LLVMDialect", + ], +) + +cc_library( + name = "TestTosaDialect", + srcs = glob([ + "lib/Dialect/Tosa/*.cpp", + ]), + deps = [ + "//mlir:IR", + "//mlir:Pass", + "//mlir:StandardOps", + "//mlir:TosaDialect", + "//mlir:Transforms", + ], +) diff --git a/utils/bazel/llvm_configs/BUILD.bazel b/utils/bazel/llvm_configs/BUILD.bazel new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm_configs/BUILD.bazel @@ -0,0 +1,29 @@ +# 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 + +# We perform diff testing here to avoid any in-tree BUILD files depending on +# bazel_sklyib. These diff tests ensure that the current Bazel configuration +# does not drift from the configuration in the .cmake files, since we don't +# alway use them directly (and even if we did we wouldn't necessarily pick up +# changes there). These are literal change-detector tests. + +load("@bazel_skylib//rules:diff_test.bzl", "diff_test") + +diff_test( + name = "diff_config.h.cmake", + file1 = "@llvm-project//llvm:include/llvm/Config/config.h.cmake", + file2 = "config.h.cmake", +) + +diff_test( + name = "diff_llvm-config.h.cmake", + file1 = "@llvm-project//llvm:include/llvm/Config/llvm-config.h.cmake", + file2 = "llvm-config.h.cmake", +) + +diff_test( + name = "diff_abi-breaking.h.cmake", + file1 = "@llvm-project//llvm:include/llvm/Config/abi-breaking.h.cmake", + file2 = "abi-breaking.h.cmake", +) diff --git a/utils/bazel/llvm_configs/abi-breaking.h.cmake b/utils/bazel/llvm_configs/abi-breaking.h.cmake new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm_configs/abi-breaking.h.cmake @@ -0,0 +1,62 @@ +/*===------- llvm/Config/abi-breaking.h - llvm configuration -------*- C -*-===*/ +/* */ +/* Part of the LLVM Project, 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 */ +/* */ +/*===----------------------------------------------------------------------===*/ + +/* This file controls the C++ ABI break introduced in LLVM public header. */ + +#ifndef LLVM_ABI_BREAKING_CHECKS_H +#define LLVM_ABI_BREAKING_CHECKS_H + +/* Define to enable checks that alter the LLVM C++ ABI */ +#cmakedefine01 LLVM_ENABLE_ABI_BREAKING_CHECKS + +/* Define to enable reverse iteration of unordered llvm containers */ +#cmakedefine01 LLVM_ENABLE_REVERSE_ITERATION + +/* Allow selectively disabling link-time mismatch checking so that header-only + ADT content from LLVM can be used without linking libSupport. */ +#if !defined(LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING) || !LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING + +// ABI_BREAKING_CHECKS protection: provides link-time failure when clients build +// mismatch with LLVM +#if defined(_MSC_VER) +// Use pragma with MSVC +#define LLVM_XSTR(s) LLVM_STR(s) +#define LLVM_STR(s) #s +#pragma detect_mismatch("LLVM_ENABLE_ABI_BREAKING_CHECKS", LLVM_XSTR(LLVM_ENABLE_ABI_BREAKING_CHECKS)) +#undef LLVM_XSTR +#undef LLVM_STR +#elif defined(_WIN32) || defined(__CYGWIN__) // Win32 w/o #pragma detect_mismatch +// FIXME: Implement checks without weak. +#elif defined(__cplusplus) +#if !(defined(_AIX) && defined(__GNUC__) && !defined(__clang__)) +#define LLVM_HIDDEN_VISIBILITY __attribute__ ((visibility("hidden"))) +#else +// GCC on AIX does not support visibility attributes. Symbols are not +// exported by default on AIX. +#define LLVM_HIDDEN_VISIBILITY +#endif +namespace llvm { +#if LLVM_ENABLE_ABI_BREAKING_CHECKS +extern int EnableABIBreakingChecks; +LLVM_HIDDEN_VISIBILITY +__attribute__((weak)) int *VerifyEnableABIBreakingChecks = + &EnableABIBreakingChecks; +#else +extern int DisableABIBreakingChecks; +LLVM_HIDDEN_VISIBILITY +__attribute__((weak)) int *VerifyDisableABIBreakingChecks = + &DisableABIBreakingChecks; +#endif +} +#undef LLVM_HIDDEN_VISIBILITY +#endif // _MSC_VER + +#endif // LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING + +#endif diff --git a/utils/bazel/llvm_configs/config.h.cmake b/utils/bazel/llvm_configs/config.h.cmake new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm_configs/config.h.cmake @@ -0,0 +1,355 @@ +#ifndef CONFIG_H +#define CONFIG_H + +// Include this header only under the llvm source tree. +// This is a private header. + +/* Exported configuration */ +#include "llvm/Config/llvm-config.h" + +/* Bug report URL. */ +#define BUG_REPORT_URL "${BUG_REPORT_URL}" + +/* Define to 1 to enable backtraces, and to 0 otherwise. */ +#cmakedefine01 ENABLE_BACKTRACES + +/* Define to 1 to enable crash overrides, and to 0 otherwise. */ +#cmakedefine01 ENABLE_CRASH_OVERRIDES + +/* Define to 1 to enable crash memory dumps, and to 0 otherwise. */ +#cmakedefine01 LLVM_ENABLE_CRASH_DUMPS + +/* Define to 1 if you have the `backtrace' function. */ +#cmakedefine HAVE_BACKTRACE ${HAVE_BACKTRACE} + +#define BACKTRACE_HEADER <${BACKTRACE_HEADER}> + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_CRASHREPORTERCLIENT_H + +/* can use __crashreporter_info__ */ +#cmakedefine01 HAVE_CRASHREPORTER_INFO + +/* Define to 1 if you have the declaration of `arc4random', and to 0 if you + don't. */ +#cmakedefine01 HAVE_DECL_ARC4RANDOM + +/* Define to 1 if you have the declaration of `FE_ALL_EXCEPT', and to 0 if you + don't. */ +#cmakedefine01 HAVE_DECL_FE_ALL_EXCEPT + +/* Define to 1 if you have the declaration of `FE_INEXACT', and to 0 if you + don't. */ +#cmakedefine01 HAVE_DECL_FE_INEXACT + +/* Define to 1 if you have the declaration of `strerror_s', and to 0 if you + don't. */ +#cmakedefine01 HAVE_DECL_STRERROR_S + +/* Define to 1 if you have the DIA SDK installed, and to 0 if you don't. */ +#cmakedefine01 LLVM_ENABLE_DIA_SDK + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_DLFCN_H ${HAVE_DLFCN_H} + +/* Define if dlopen() is available on this platform. */ +#cmakedefine HAVE_DLOPEN ${HAVE_DLOPEN} + +/* Define if dladdr() is available on this platform. */ +#cmakedefine HAVE_DLADDR ${HAVE_DLADDR} + +/* Define to 1 if we can register EH frames on this platform. */ +#cmakedefine HAVE_REGISTER_FRAME ${HAVE_REGISTER_FRAME} + +/* Define to 1 if we can deregister EH frames on this platform. */ +#cmakedefine HAVE_DEREGISTER_FRAME ${HAVE_DEREGISTER_FRAME} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_ERRNO_H ${HAVE_ERRNO_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_FCNTL_H ${HAVE_FCNTL_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_FENV_H ${HAVE_FENV_H} + +/* Define if libffi is available on this platform. */ +#cmakedefine HAVE_FFI_CALL ${HAVE_FFI_CALL} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_FFI_FFI_H ${HAVE_FFI_FFI_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_FFI_H ${HAVE_FFI_H} + +/* Define to 1 if you have the `futimens' function. */ +#cmakedefine HAVE_FUTIMENS ${HAVE_FUTIMENS} + +/* Define to 1 if you have the `futimes' function. */ +#cmakedefine HAVE_FUTIMES ${HAVE_FUTIMES} + +/* Define to 1 if you have the `getpagesize' function. */ +#cmakedefine HAVE_GETPAGESIZE ${HAVE_GETPAGESIZE} + +/* Define to 1 if you have the `getrlimit' function. */ +#cmakedefine HAVE_GETRLIMIT ${HAVE_GETRLIMIT} + +/* Define to 1 if you have the `getrusage' function. */ +#cmakedefine HAVE_GETRUSAGE ${HAVE_GETRUSAGE} + +/* Define to 1 if you have the `isatty' function. */ +#cmakedefine HAVE_ISATTY 1 + +/* Define to 1 if you have the `edit' library (-ledit). */ +#cmakedefine HAVE_LIBEDIT ${HAVE_LIBEDIT} + +/* Define to 1 if you have the `pfm' library (-lpfm). */ +#cmakedefine HAVE_LIBPFM ${HAVE_LIBPFM} + +/* Define to 1 if the `perf_branch_entry' struct has field cycles. */ +#cmakedefine LIBPFM_HAS_FIELD_CYCLES ${LIBPFM_HAS_FIELD_CYCLES} + +/* Define to 1 if you have the `psapi' library (-lpsapi). */ +#cmakedefine HAVE_LIBPSAPI ${HAVE_LIBPSAPI} + +/* Define to 1 if you have the `pthread' library (-lpthread). */ +#cmakedefine HAVE_LIBPTHREAD ${HAVE_LIBPTHREAD} + +/* Define to 1 if you have the `pthread_getname_np' function. */ +#cmakedefine HAVE_PTHREAD_GETNAME_NP ${HAVE_PTHREAD_GETNAME_NP} + +/* Define to 1 if you have the `pthread_setname_np' function. */ +#cmakedefine HAVE_PTHREAD_SETNAME_NP ${HAVE_PTHREAD_SETNAME_NP} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_LINK_H ${HAVE_LINK_H} + +/* Define to 1 if you have the `lseek64' function. */ +#cmakedefine HAVE_LSEEK64 ${HAVE_LSEEK64} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_MACH_MACH_H ${HAVE_MACH_MACH_H} + +/* Define to 1 if you have the `mallctl' function. */ +#cmakedefine HAVE_MALLCTL ${HAVE_MALLCTL} + +/* Define to 1 if you have the `mallinfo' function. */ +#cmakedefine HAVE_MALLINFO ${HAVE_MALLINFO} + +/* Define to 1 if you have the `mallinfo2' function. */ +#cmakedefine HAVE_MALLINFO2 ${HAVE_MALLINFO2} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_MALLOC_MALLOC_H ${HAVE_MALLOC_MALLOC_H} + +/* Define to 1 if you have the `malloc_zone_statistics' function. */ +#cmakedefine HAVE_MALLOC_ZONE_STATISTICS ${HAVE_MALLOC_ZONE_STATISTICS} + +/* Define to 1 if you have the `posix_fallocate' function. */ +#cmakedefine HAVE_POSIX_FALLOCATE ${HAVE_POSIX_FALLOCATE} + +/* Define to 1 if you have the `posix_spawn' function. */ +#cmakedefine HAVE_POSIX_SPAWN ${HAVE_POSIX_SPAWN} + +/* Define to 1 if you have the `pread' function. */ +#cmakedefine HAVE_PREAD ${HAVE_PREAD} + +/* Have pthread_getspecific */ +#cmakedefine HAVE_PTHREAD_GETSPECIFIC ${HAVE_PTHREAD_GETSPECIFIC} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_PTHREAD_H ${HAVE_PTHREAD_H} + +/* Have pthread_mutex_lock */ +#cmakedefine HAVE_PTHREAD_MUTEX_LOCK ${HAVE_PTHREAD_MUTEX_LOCK} + +/* Have pthread_rwlock_init */ +#cmakedefine HAVE_PTHREAD_RWLOCK_INIT ${HAVE_PTHREAD_RWLOCK_INIT} + +/* Define to 1 if you have the `sbrk' function. */ +#cmakedefine HAVE_SBRK ${HAVE_SBRK} + +/* Define to 1 if you have the `setenv' function. */ +#cmakedefine HAVE_SETENV ${HAVE_SETENV} + +/* Define to 1 if you have the `setrlimit' function. */ +#cmakedefine HAVE_SETRLIMIT ${HAVE_SETRLIMIT} + +/* Define to 1 if you have the `sigaltstack' function. */ +#cmakedefine HAVE_SIGALTSTACK ${HAVE_SIGALTSTACK} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SIGNAL_H ${HAVE_SIGNAL_H} + +/* Define to 1 if you have the `strerror' function. */ +#cmakedefine HAVE_STRERROR ${HAVE_STRERROR} + +/* Define to 1 if you have the `strerror_r' function. */ +#cmakedefine HAVE_STRERROR_R ${HAVE_STRERROR_R} + +/* Define to 1 if you have the `sysconf' function. */ +#cmakedefine HAVE_SYSCONF ${HAVE_SYSCONF} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_IOCTL_H ${HAVE_SYS_IOCTL_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_MMAN_H ${HAVE_SYS_MMAN_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_PARAM_H ${HAVE_SYS_PARAM_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_RESOURCE_H ${HAVE_SYS_RESOURCE_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_STAT_H ${HAVE_SYS_STAT_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_TIME_H ${HAVE_SYS_TIME_H} + +/* Define to 1 if stat struct has st_mtimespec member .*/ +#cmakedefine HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC ${HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC} + +/* Define to 1 if stat struct has st_mtim member. */ +#cmakedefine HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC ${HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_TYPES_H ${HAVE_SYS_TYPES_H} + +/* Define if the setupterm() function is supported this platform. */ +#cmakedefine LLVM_ENABLE_TERMINFO ${LLVM_ENABLE_TERMINFO} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_TERMIOS_H ${HAVE_TERMIOS_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_UNISTD_H ${HAVE_UNISTD_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_VALGRIND_VALGRIND_H ${HAVE_VALGRIND_VALGRIND_H} + +/* Have host's _alloca */ +#cmakedefine HAVE__ALLOCA ${HAVE__ALLOCA} + +/* Define to 1 if you have the `_chsize_s' function. */ +#cmakedefine HAVE__CHSIZE_S ${HAVE__CHSIZE_S} + +/* Define to 1 if you have the `_Unwind_Backtrace' function. */ +#cmakedefine HAVE__UNWIND_BACKTRACE ${HAVE__UNWIND_BACKTRACE} + +/* Have host's __alloca */ +#cmakedefine HAVE___ALLOCA ${HAVE___ALLOCA} + +/* Have host's __ashldi3 */ +#cmakedefine HAVE___ASHLDI3 ${HAVE___ASHLDI3} + +/* Have host's __ashrdi3 */ +#cmakedefine HAVE___ASHRDI3 ${HAVE___ASHRDI3} + +/* Have host's __chkstk */ +#cmakedefine HAVE___CHKSTK ${HAVE___CHKSTK} + +/* Have host's __chkstk_ms */ +#cmakedefine HAVE___CHKSTK_MS ${HAVE___CHKSTK_MS} + +/* Have host's __cmpdi2 */ +#cmakedefine HAVE___CMPDI2 ${HAVE___CMPDI2} + +/* Have host's __divdi3 */ +#cmakedefine HAVE___DIVDI3 ${HAVE___DIVDI3} + +/* Have host's __fixdfdi */ +#cmakedefine HAVE___FIXDFDI ${HAVE___FIXDFDI} + +/* Have host's __fixsfdi */ +#cmakedefine HAVE___FIXSFDI ${HAVE___FIXSFDI} + +/* Have host's __floatdidf */ +#cmakedefine HAVE___FLOATDIDF ${HAVE___FLOATDIDF} + +/* Have host's __lshrdi3 */ +#cmakedefine HAVE___LSHRDI3 ${HAVE___LSHRDI3} + +/* Have host's __main */ +#cmakedefine HAVE___MAIN ${HAVE___MAIN} + +/* Have host's __moddi3 */ +#cmakedefine HAVE___MODDI3 ${HAVE___MODDI3} + +/* Have host's __udivdi3 */ +#cmakedefine HAVE___UDIVDI3 ${HAVE___UDIVDI3} + +/* Have host's __umoddi3 */ +#cmakedefine HAVE___UMODDI3 ${HAVE___UMODDI3} + +/* Have host's ___chkstk */ +#cmakedefine HAVE____CHKSTK ${HAVE____CHKSTK} + +/* Have host's ___chkstk_ms */ +#cmakedefine HAVE____CHKSTK_MS ${HAVE____CHKSTK_MS} + +/* Linker version detected at compile time. */ +#cmakedefine HOST_LINK_VERSION "${HOST_LINK_VERSION}" + +/* Target triple LLVM will generate code for by default */ +/* Doesn't use `cmakedefine` because it is allowed to be empty. */ +#define LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}" + +/* Define if zlib compression is available */ +#cmakedefine01 LLVM_ENABLE_ZLIB + +/* Define if overriding target triple is enabled */ +#cmakedefine LLVM_TARGET_TRIPLE_ENV "${LLVM_TARGET_TRIPLE_ENV}" + +/* LLVM version information */ +#cmakedefine LLVM_VERSION_INFO "${LLVM_VERSION_INFO}" + +/* Whether tools show host and target info when invoked with --version */ +#cmakedefine01 LLVM_VERSION_PRINTER_SHOW_HOST_TARGET_INFO + +/* Define if libxml2 is supported on this platform. */ +#cmakedefine LLVM_ENABLE_LIBXML2 ${LLVM_ENABLE_LIBXML2} + +/* Define to the extension used for shared libraries, say, ".so". */ +#cmakedefine LTDL_SHLIB_EXT "${LTDL_SHLIB_EXT}" + +/* Define to the extension used for plugin libraries, say, ".so". */ +#cmakedefine LLVM_PLUGIN_EXT "${LLVM_PLUGIN_EXT}" + +/* Define to the address where bug reports for this package should be sent. */ +#cmakedefine PACKAGE_BUGREPORT "${PACKAGE_BUGREPORT}" + +/* Define to the full name of this package. */ +#cmakedefine PACKAGE_NAME "${PACKAGE_NAME}" + +/* Define to the full name and version of this package. */ +#cmakedefine PACKAGE_STRING "${PACKAGE_STRING}" + +/* Define to the version of this package. */ +#cmakedefine PACKAGE_VERSION "${PACKAGE_VERSION}" + +/* Define to the vendor of this package. */ +#cmakedefine PACKAGE_VENDOR "${PACKAGE_VENDOR}" + +/* Define as the return type of signal handlers (`int' or `void'). */ +#cmakedefine RETSIGTYPE ${RETSIGTYPE} + +/* Define if std::is_trivially_copyable is supported */ +#cmakedefine HAVE_STD_IS_TRIVIALLY_COPYABLE ${HAVE_STD_IS_TRIVIALLY_COPYABLE} + +/* Define to a function implementing stricmp */ +#cmakedefine stricmp ${stricmp} + +/* Define to a function implementing strdup */ +#cmakedefine strdup ${strdup} + +/* Whether GlobalISel rule coverage is being collected */ +#cmakedefine01 LLVM_GISEL_COV_ENABLED + +/* Define to the default GlobalISel coverage file prefix */ +#cmakedefine LLVM_GISEL_COV_PREFIX "${LLVM_GISEL_COV_PREFIX}" + +#cmakedefine HAVE_PROC_PID_RUSAGE 1 + +#endif diff --git a/utils/bazel/llvm_configs/llvm-config.h.cmake b/utils/bazel/llvm_configs/llvm-config.h.cmake new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm_configs/llvm-config.h.cmake @@ -0,0 +1,104 @@ +/*===------- llvm/Config/llvm-config.h - llvm configuration -------*- C -*-===*/ +/* */ +/* Part of the LLVM Project, 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 */ +/* */ +/*===----------------------------------------------------------------------===*/ + +/* This file enumerates variables from the LLVM configuration so that they + can be in exported headers and won't override package specific directives. + This is a C header that can be included in the llvm-c headers. */ + +#ifndef LLVM_CONFIG_H +#define LLVM_CONFIG_H + +/* Define if LLVM_ENABLE_DUMP is enabled */ +#cmakedefine LLVM_ENABLE_DUMP + +/* Target triple LLVM will generate code for by default */ +#cmakedefine LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}" + +/* Define if threads enabled */ +#cmakedefine01 LLVM_ENABLE_THREADS + +/* Has gcc/MSVC atomic intrinsics */ +#cmakedefine01 LLVM_HAS_ATOMICS + +/* Host triple LLVM will be executed on */ +#cmakedefine LLVM_HOST_TRIPLE "${LLVM_HOST_TRIPLE}" + +/* LLVM architecture name for the native architecture, if available */ +#cmakedefine LLVM_NATIVE_ARCH ${LLVM_NATIVE_ARCH} + +/* LLVM name for the native AsmParser init function, if available */ +#cmakedefine LLVM_NATIVE_ASMPARSER LLVMInitialize${LLVM_NATIVE_ARCH}AsmParser + +/* LLVM name for the native AsmPrinter init function, if available */ +#cmakedefine LLVM_NATIVE_ASMPRINTER LLVMInitialize${LLVM_NATIVE_ARCH}AsmPrinter + +/* LLVM name for the native Disassembler init function, if available */ +#cmakedefine LLVM_NATIVE_DISASSEMBLER LLVMInitialize${LLVM_NATIVE_ARCH}Disassembler + +/* LLVM name for the native Target init function, if available */ +#cmakedefine LLVM_NATIVE_TARGET LLVMInitialize${LLVM_NATIVE_ARCH}Target + +/* LLVM name for the native TargetInfo init function, if available */ +#cmakedefine LLVM_NATIVE_TARGETINFO LLVMInitialize${LLVM_NATIVE_ARCH}TargetInfo + +/* LLVM name for the native target MC init function, if available */ +#cmakedefine LLVM_NATIVE_TARGETMC LLVMInitialize${LLVM_NATIVE_ARCH}TargetMC + +/* Define if this is Unixish platform */ +#cmakedefine LLVM_ON_UNIX ${LLVM_ON_UNIX} + +/* Define if we have the Intel JIT API runtime support library */ +#cmakedefine01 LLVM_USE_INTEL_JITEVENTS + +/* Define if we have the oprofile JIT-support library */ +#cmakedefine01 LLVM_USE_OPROFILE + +/* Define if we have the perf JIT-support library */ +#cmakedefine01 LLVM_USE_PERF + +/* Major version of the LLVM API */ +#define LLVM_VERSION_MAJOR ${LLVM_VERSION_MAJOR} + +/* Minor version of the LLVM API */ +#define LLVM_VERSION_MINOR ${LLVM_VERSION_MINOR} + +/* Patch version of the LLVM API */ +#define LLVM_VERSION_PATCH ${LLVM_VERSION_PATCH} + +/* LLVM version string */ +#define LLVM_VERSION_STRING "${PACKAGE_VERSION}" + +/* Whether LLVM records statistics for use with GetStatistics(), + * PrintStatistics() or PrintStatisticsJSON() + */ +#cmakedefine01 LLVM_FORCE_ENABLE_STATS + +/* Define if we have z3 and want to build it */ +#cmakedefine LLVM_WITH_Z3 ${LLVM_WITH_Z3} + +/* Define if LLVM was built with a dependency to the libtensorflow dynamic library */ +#cmakedefine LLVM_HAVE_TF_API + +/* Define if LLVM was built with a dependency to the tensorflow compiler */ +#cmakedefine LLVM_HAVE_TF_AOT + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYSEXITS_H ${HAVE_SYSEXITS_H} + +/* Define to 1 to enable the experimental new pass manager by default */ +#cmakedefine01 LLVM_ENABLE_NEW_PASS_MANAGER + +/* Define if the xar_open() function is supported on this platform. */ +#cmakedefine LLVM_HAVE_LIBXAR ${LLVM_HAVE_LIBXAR} + +/* Whether Timers signpost passes in Xcode Instruments */ +#cmakedefine01 LLVM_SUPPORT_XCODE_SIGNPOSTS + + +#endif diff --git a/utils/bazel/overlay_directories.py b/utils/bazel/overlay_directories.py new file mode 100755 --- /dev/null +++ b/utils/bazel/overlay_directories.py @@ -0,0 +1,92 @@ +#!/bin/python3 + +# 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 +"""Overlays two directories into a target directory using symlinks. + +Tries to minimize the number of symlinks created (that is, does not symlink +every single file). Symlinks every file in the overlay directory. Only symlinks +individual files in the source directory if their parent directory is also +contained in the overlay directory tree. +""" + +import argparse +import errno +import os +import sys + + +def _check_python_version(): + if sys.version_info[0] < 3: + raise RuntimeError( + "Must be invoked with a python 3 interpreter but was %s" % + sys.executable) + + +def _check_dir_exists(path): + if not os.path.isdir(path): + raise OSError(errno.ENOENT, os.strerror(errno.ENOENT), path) + + +def parse_arguments(): + parser = argparse.ArgumentParser(description=""" + Overlays two directories into a target directory using symlinks. + + Tries to minimize the number of symlinks created (that is, does not symlink + every single file). Symlinks every file in the overlay directory. Only + symlinks individual files in the source directory if their parent directory + is also contained in the overlay directory tree. + """) + parser.add_argument( + "--src", + required=True, + help="Directory that contains most of the content to symlink.") + parser.add_argument( + "--overlay", + required=True, + help="Directory to overlay on top of the source directory.") + parser.add_argument( + "--target", + required=True, + help="Directory in which to place the fused symlink directories.") + + args = parser.parse_args() + + _check_dir_exists(args.target) + _check_dir_exists(args.overlay) + _check_dir_exists(args.src) + + return args + + +def _symlink_abs(from_path, to_path): + os.symlink(os.path.abspath(from_path), os.path.abspath(to_path)) + + +def main(args): + for root, dirs, files in os.walk(args.overlay): + # We could do something more intelligent here and only symlink individual + # files if the directory is present in both overlay and src. This could also + # be generalized to an arbitrary number of directories without any + # "src/overlay" distinction. In the current use case we only have two and + # the overlay directory is always small, so putting that off for now. + rel_root = os.path.relpath(root, start=args.overlay) + if rel_root != ".": + os.mkdir(os.path.join(args.target, rel_root)) + + for file in files: + relpath = os.path.join(rel_root, file) + _symlink_abs(os.path.join(args.overlay, relpath), + os.path.join(args.target, relpath)) + + for src_entry in os.listdir(os.path.join(args.src, rel_root)): + if src_entry not in dirs: + relpath = os.path.join(rel_root, src_entry) + _symlink_abs(os.path.join(args.src, relpath), + os.path.join(args.target, relpath)) + + +if __name__ == "__main__": + _check_python_version() + main(parse_arguments()) diff --git a/utils/bazel/terminfo.bzl b/utils/bazel/terminfo.bzl new file mode 100644 --- /dev/null +++ b/utils/bazel/terminfo.bzl @@ -0,0 +1,202 @@ +# 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 + +"""Repository rules to configure the terminfo used by LLVM. + +Most users should pick one of the explicit rules to configure their use of terminfo +with LLVM: +- `llvm_terminfo_system` will detect and link against a terminfo-implementing + system library (non-hermetically). +- 'llvm_terminfo_disable` will disable terminfo completely. + +If you would like to make your build configurable, you can use +`llvm_terminfo_from_env`. By default, this will disable terminfo, but will +inspect the environment variable (most easily set with a `--repo_env` flag to +the Bazel invocation) `BAZEL_LLVM_TERMINFO_STRATEGY`. If it is set to +`system` then it will behave the same as `llvm_terminfo_system`. Any other +setting will disable terminfo the same as not setting it at all. +""" + +def _llvm_terminfo_disable_impl(repository_ctx): + repository_ctx.template( + "BUILD", + repository_ctx.attr._disable_build_template, + executable = False, + ) + +_terminfo_disable_attrs = { + "_disable_build_template": attr.label( + default = Label("//deps_impl:terminfo_disable.BUILD"), + allow_single_file = True, + ), +} + +llvm_terminfo_disable = repository_rule( + implementation = _llvm_terminfo_disable_impl, + attrs = _terminfo_disable_attrs, +) + +def _find_c_compiler(repository_ctx): + """Returns the path to a plausible C compiler. + + This routine will only reliably work on roughly POSIX-y systems as it + ultimately falls back on the `cc` binary. Fortunately, the thing we are + trying to use it for (detecting if a trivial source file can compile and + link against a particular library) requires very little. + """ + cc_env = repository_ctx.os.environ.get("CC") + cc = None + if cc_env: + if "/" in cc_env: + return repository_ctx.path(cc_env) + else: + return repository_ctx.which(cc_env) + + # Look for Clang, GCC, and the POSIX / UNIX specified C compiler + # binaries. + for compiler in ["clang", "gcc", "c99", "c89", "cc"]: + cc = repository_ctx.which(compiler) + if cc: + return cc + + return None + +def _try_link(repository_ctx, cc, source, linker_flags): + """Returns `True` if able to link the source with the linker flag. + + Given a source file that contains references to library routines, this + will check that when linked with the provided linker flag, those + references are successfully resolved. This routine assumes a generally + POSIX-y and GCC-ish compiler and environment and shouldn't be expected to + work outside of that. + """ + cmd = [ + cc, + # Force discard the linked executable. + "-o", + "/dev/null", + # Leave language detection to the compiler. + source, + ] + + # The linker flag must be valid for a compiler invocation of the link step, + # so just append them to the command. + cmd += linker_flags + exec_result = repository_ctx.execute(cmd, timeout = 20) + return exec_result.return_code == 0 + +def _llvm_terminfo_system_impl(repository_ctx): + # LLVM doesn't need terminfo support on Windows, so just disable it. + if repository_ctx.os.name.lower().find("windows") != -1: + _llvm_terminfo_disable_impl(repository_ctx) + return + + if len(repository_ctx.attr.system_linkopts) > 0: + linkopts = repository_ctx.attr.system_linkopts + else: + required = repository_ctx.attr.system_required + + # Find a C compiler we can use to detect viable linkopts on this system. + cc = _find_c_compiler(repository_ctx) + if not cc: + if required: + fail("Failed to find a C compiler executable") + else: + _llvm_terminfo_disable_impl(repository_ctx) + return + + # Get the source file we use to detect successful linking of terminfo. + source = repository_ctx.path(repository_ctx.attr._terminfo_test_source) + + # Collect the candidate linkopts and wrap them into a list. Ideally, + # these would be provided as lists, but Bazel doesn't currently + # support that. See: https://github.com/bazelbuild/bazel/issues/12178 + linkopts_candidates = [[x] for x in repository_ctx.attr.candidate_system_linkopts] + + # For each candidate, try to use it to link our test source file. + for linkopts_candidate in linkopts_candidates: + if _try_link(repository_ctx, cc, source, linkopts_candidate): + linkopts = linkopts_candidate + break + + # If we never found a viable linkopts candidate, either error or disable + # terminfo for LLVM. + if not linkopts: + if required: + fail("Failed to detect which linkopt would successfully provide the " + + "necessary terminfo functionality") + else: + _llvm_terminfo_disable_impl(repository_ctx) + return + + repository_ctx.template( + "BUILD", + repository_ctx.attr._system_build_template, + substitutions = { + "{TERMINFO_LINKOPTS}": str(linkopts), + }, + executable = False, + ) + +def _merge_attrs(attrs_list): + attrs = {} + for input_attrs in attrs_list: + attrs.update(input_attrs) + return attrs + +_terminfo_system_attrs = _merge_attrs([_terminfo_disable_attrs, { + "_system_build_template": attr.label( + default = Label("//deps_impl:terminfo_system.BUILD"), + allow_single_file = True, + ), + "_terminfo_test_source": attr.label( + default = Label("//deps_impl:terminfo_test.c"), + allow_single_file = True, + ), + "candidate_system_linkopts": attr.string_list( + default = [ + "-lterminfo", + "-ltinfo", + "-lcurses", + "-lncurses", + "-lncursesw", + ], + doc = "Candidate linkopts to test and see if they can link " + + "successfully.", + ), + "system_required": attr.bool( + default = False, + doc = "Require that one of the candidates is detected successfully on POSIX platforms where it is needed.", + ), + "system_linkopts": attr.string_list( + default = [], + doc = "If non-empty, a specific array of linkopts to use to " + + "successfully link against the terminfo library. No " + + "detection is performed if this option is provided, it " + + "directly forces the use of these link options. No test is " + + "run to determine if they are valid or work correctly either.", + ), +}]) + +llvm_terminfo_system = repository_rule( + implementation = _llvm_terminfo_system_impl, + configure = True, + local = True, + attrs = _terminfo_system_attrs, +) + +def _llvm_terminfo_from_env_impl(repository_ctx): + terminfo_strategy = repository_ctx.os.environ.get("BAZEL_LLVM_TERMINFO_STRATEGY") + if terminfo_strategy == "system": + _llvm_terminfo_system_impl(repository_ctx) + else: + _llvm_terminfo_disable_impl(repository_ctx) + +llvm_terminfo_from_env = repository_rule( + implementation = _llvm_terminfo_from_env_impl, + configure = True, + local = True, + attrs = _merge_attrs([_terminfo_disable_attrs, _terminfo_system_attrs]), + environ = ["BAZEL_LLVM_TERMINFO_STRATEGY", "CC"], +) diff --git a/utils/bazel/third_party_build/BUILD b/utils/bazel/third_party_build/BUILD new file mode 100644 --- /dev/null +++ b/utils/bazel/third_party_build/BUILD @@ -0,0 +1,5 @@ +# 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 + +licenses(["notice"]) diff --git a/utils/bazel/third_party_build/vulkan_headers.BUILD b/utils/bazel/third_party_build/vulkan_headers.BUILD new file mode 100644 --- /dev/null +++ b/utils/bazel/third_party_build/vulkan_headers.BUILD @@ -0,0 +1,30 @@ +# 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 + +package( + default_visibility = ["//visibility:public"], + licenses = ["notice"], +) + +# Exports all headers but defining VK_NO_PROTOTYPES to disable the +# inclusion of C function prototypes. Useful if dynamically loading +# all symbols via dlopen/etc. +# Not all headers are hermetic, so they are just included as textual +# headers to disable additional validation. +cc_library( + name = "vulkan_headers_no_prototypes", + defines = ["VK_NO_PROTOTYPES"], + includes = ["include"], + textual_hdrs = glob(["include/vulkan/*.h"]), +) + +# Exports all headers, including C function prototypes. Useful if statically +# linking against the Vulkan SDK. +# Not all headers are hermetic, so they are just included as textual +# headers to disable additional validation. +cc_library( + name = "vulkan_headers", + includes = ["include"], + textual_hdrs = glob(["include/vulkan/*.h"]), +) diff --git a/utils/bazel/third_party_build/zlib.BUILD b/utils/bazel/third_party_build/zlib.BUILD new file mode 100644 --- /dev/null +++ b/utils/bazel/third_party_build/zlib.BUILD @@ -0,0 +1,46 @@ +# 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 + +package( + default_visibility = ["//visibility:public"], + # BSD/MIT-like license (for zlib) + licenses = ["notice"], +) + +cc_library( + name = "zlib", + srcs = [ + "adler32.c", + "compress.c", + "crc32.c", + "crc32.h", + "deflate.c", + "deflate.h", + "gzclose.c", + "gzguts.h", + "gzlib.c", + "gzread.c", + "gzwrite.c", + "infback.c", + "inffast.c", + "inffast.h", + "inffixed.h", + "inflate.c", + "inflate.h", + "inftrees.c", + "inftrees.h", + "trees.c", + "trees.h", + "uncompr.c", + "zconf.h", + "zutil.c", + "zutil.h", + ], + hdrs = ["zlib.h"], + copts = [ + "-Wno-shift-negative-value", + "-DZ_HAVE_UNISTD_H", + ], + includes = ["."], +) diff --git a/utils/bazel/vulkan_sdk.bzl b/utils/bazel/vulkan_sdk.bzl new file mode 100644 --- /dev/null +++ b/utils/bazel/vulkan_sdk.bzl @@ -0,0 +1,43 @@ +# 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 + +"""Repository rule to statically link against the Vulkan SDK. + +Requires installing the Vulkan SDK from https://vulkan.lunarg.com/. + +If the Vulkan SDK is not installed, this generates an empty rule and you may +encounter linker errors like `error: undefined reference to 'vkCreateInstance'`. +""" + +def _impl(repository_ctx): + if "VULKAN_SDK" in repository_ctx.os.environ: + sdk_path = repository_ctx.os.environ["VULKAN_SDK"] + repository_ctx.symlink(sdk_path, "vulkan-sdk") + + repository_ctx.file("BUILD", """ +cc_library( + name = "sdk", + srcs = select({ + "@bazel_tools//src/conditions:windows": [ + "vulkan-sdk/Lib/vulkan-1.lib" + ], + "//conditions:default": [ + "vulkan-sdk/lib/libvulkan.so.1", + ], + }), + visibility = ["//visibility:public"], +)""") + else: + # Empty rule. Will fail to link for just targets that use Vulkan. + repository_ctx.file("BUILD", """ +cc_library( + name = "sdk", + srcs = [], + visibility = ["//visibility:public"], +)""") + +vulkan_sdk_setup = repository_rule( + implementation = _impl, + local = True, +) diff --git a/utils/bazel/zlib.bzl b/utils/bazel/zlib.bzl new file mode 100644 --- /dev/null +++ b/utils/bazel/zlib.bzl @@ -0,0 +1,112 @@ +# 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 + +"""Repository rules to configure the zlib used by LLVM. + +Most users should pick one of the explicit rules to configure their use of zlib +with LLVM: +- `llvm_zlib_external` will link against an external Bazel zlib repository. +- `llvm_zlib_system` will link against the system zlib (non-hermetically). +- 'llvm_zlib_disable` will disable zlib completely. + +If you would like to make your build configurable, you can use +`llvm_zlib_from_env`. By default, this will disable zlib, but will inspect +the environment variable (most easily set with a `--repo_env` flag to the +Bazel invocation) `BAZEL_LLVM_ZLIB_STRATEGY`. If it is set to `external`, +then it will behave the same as `llvm_zlib_external`. If it is set to +`system` then it will behave the same as `llvm_zlib_system`. Any other +setting will disable zlib the same as not setting it at all. +""" + +def _llvm_zlib_external_impl(repository_ctx): + repository_ctx.template( + "BUILD", + repository_ctx.attr._external_build_template, + substitutions = { + "@external_zlib_repo//:zlib_rule": str(repository_ctx.attr.external_zlib), + }, + executable = False, + ) + +llvm_zlib_external = repository_rule( + implementation = _llvm_zlib_external_impl, + attrs = { + "_external_build_template": attr.label( + default = Label("//deps_impl:zlib_external.BUILD"), + allow_single_file = True, + ), + "external_zlib": attr.label( + doc = "The dependency that should be used for the external zlib library.", + mandatory = True, + ), + }, +) + +def _llvm_zlib_system_impl(repository_ctx): + repository_ctx.template( + "BUILD", + repository_ctx.attr._system_build_template, + executable = False, + ) + +# While it may seem like this needs to be local, it doesn't actually inspect +# any local state, it just configures to build against that local state. +llvm_zlib_system = repository_rule( + implementation = _llvm_zlib_system_impl, + attrs = { + "_system_build_template": attr.label( + default = Label("//deps_impl:zlib_system.BUILD"), + allow_single_file = True, + ), + }, +) + +def _llvm_zlib_disable_impl(repository_ctx): + repository_ctx.template( + "BUILD", + repository_ctx.attr._disable_build_template, + executable = False, + ) + +llvm_zlib_disable = repository_rule( + implementation = _llvm_zlib_disable_impl, + attrs = { + "_disable_build_template": attr.label( + default = Label("//deps_impl:zlib_disable.BUILD"), + allow_single_file = True, + ), + }, +) + +def _llvm_zlib_from_env_impl(repository_ctx): + zlib_strategy = repository_ctx.os.environ.get("BAZEL_LLVM_ZLIB_STRATEGY") + if zlib_strategy == "external": + _llvm_zlib_external_impl(repository_ctx) + elif zlib_strategy == "system": + _llvm_zlib_system_impl(repository_ctx) + else: + _llvm_zlib_disable_impl(repository_ctx) + +llvm_zlib_from_env = repository_rule( + implementation = _llvm_zlib_from_env_impl, + attrs = { + "_disable_build_template": attr.label( + default = Label("//deps_impl:zlib_disable.BUILD"), + allow_single_file = True, + ), + "_external_build_template": attr.label( + default = Label("//deps_impl:zlib_external.BUILD"), + allow_single_file = True, + ), + "_system_build_template": attr.label( + default = Label("//deps_impl:zlib_system.BUILD"), + allow_single_file = True, + ), + "external_zlib": attr.label( + doc = "The dependency that should be used for the external zlib library.", + mandatory = True, + ), + }, + environ = ["BAZEL_LLVM_ZLIB_STRATEGY"], +)