diff --git a/tensorflow/workspace.bzl b/tensorflow/workspace.bzl index 06e16cdb044c0238d317cf210a2c860e4d792f5d..0afa5d53469f29ad9558f836d2e2335362b5270c 100644 --- a/tensorflow/workspace.bzl +++ b/tensorflow/workspace.bzl @@ -193,6 +193,16 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""): build_file = str(Label("//:linenoise.BUILD")), ) + # TODO(phawkins): currently, this rule uses an unofficial LLVM mirror. + # Switch to an official source of snapshots if/when possible. + native.new_http_archive( + name = "llvm", + url = "http://github.com/llvm-mirror/llvm/archive/ad27fdae895df1b9ad11a93102de6622f63e1220.tar.gz", + sha256 = "ce7abf076586f2ef13dcd1c4e7ba13604a0826a0f44fe0a6faceeb9bdffc8544", + strip_prefix = "llvm-ad27fdae895df1b9ad11a93102de6622f63e1220", + build_file = str(Label("//third_party/llvm:llvm.BUILD")), + ) + native.new_http_archive( name = "jsoncpp_git", url = "http://github.com/open-source-parsers/jsoncpp/archive/11086dd6a7eba04289944367ca82cea71299ed70.tar.gz", diff --git a/third_party/llvm/BUILD b/third_party/llvm/BUILD new file mode 100644 index 0000000000000000000000000000000000000000..5b9ec0f8fd57338c5def8ee86af3c5ab2e64dcc1 --- /dev/null +++ b/third_party/llvm/BUILD @@ -0,0 +1,7 @@ +licenses(["notice"]) + +py_binary( + name = "expand_cmake_vars", + srcs = ["expand_cmake_vars.py"], + visibility = ["@llvm//:__subpackages__"], +) diff --git "a/third_party/llvm/expand_cmake_vars.py\"" "b/third_party/llvm/expand_cmake_vars.py\"" new file mode 100644 index 0000000000000000000000000000000000000000..51e668428f6646a64b2417e5695eb364fca190ff --- /dev/null +++ "b/third_party/llvm/expand_cmake_vars.py\"" @@ -0,0 +1,88 @@ +# Copyright 2016 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================== + +"""Expands CMake variables in a text file.""" + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import re +import sys + +_CMAKE_DEFINE_REGEX = re.compile(r"\s*#cmakedefine\s+([A-Za-z_0-9]*)(\s.*)?$") +_CMAKE_DEFINE01_REGEX = re.compile(r"\s*#cmakedefine01\s+([A-Za-z_0-9]*)") +_CMAKE_VAR_REGEX = re.compile(r"\${([A-Za-z_0-9]*)}") + + +def _parse_args(argv): + """Parses arguments with the form KEY=VALUE into a dictionary.""" + result = {} + for arg in argv: + k, v = arg.split("=") + result[k] = v + return result + + +def _expand_variables(input_str, cmake_vars): + """Expands ${VARIABLE}s in 'input_str', using dictionary 'cmake_vars'. + + Args: + input_str: the string containing ${VARIABLE} expressions to expand. + cmake_vars: a dictionary mapping variable names to their values. + + Returns: + The expanded string. + """ + def replace(match): + if cmake_vars.has_key(match.group(1)): + return cmake_vars[match.group(1)] + return "" + return _CMAKE_VAR_REGEX.sub(replace, input_str) + + +def _expand_cmakedefines(line, cmake_vars): + """Expands #cmakedefine declarations, using a dictionary 'cmake_vars'.""" + + # Handles #cmakedefine lines + match = _CMAKE_DEFINE_REGEX.match(line) + if match: + name = match.group(1) + suffix = match.group(2) or "" + if name in cmake_vars: + return "#define {}{}\n".format(name, + _expand_variables(suffix, cmake_vars)) + else: + return "/* #undef {} */\n".format(name) + + # Handles #cmakedefine01 lines + match = _CMAKE_DEFINE01_REGEX.match(line) + if match: + name = match.group(1) + value = cmake_vars.get(name, "0") + return "#define {} {}\n".format(name, value) + + # Otherwise return the line unchanged. + return _expand_variables(line, cmake_vars) + + +def main(): + cmake_vars = _parse_args(sys.argv[1:]) + for line in sys.stdin: + sys.stdout.write(_expand_cmakedefines(line, cmake_vars)) + + +if __name__ == "__main__": + main() diff --git a/third_party/llvm/llvm.BUILD b/third_party/llvm/llvm.BUILD new file mode 100644 index 0000000000000000000000000000000000000000..6238430cc90e353b5fdbbb5ae0558fcf77dad290 --- /dev/null +++ b/third_party/llvm/llvm.BUILD @@ -0,0 +1,1908 @@ +# Bazel BUILD file for LLVM. +# +# This BUILD file is auto-generated; do not edit! + +licenses(["notice"]) + +load( + "@//third_party/llvm:llvm.bzl", + "gentbl", + "expand_cmake_vars", + "expand_header_template", + "llvm_target_cmake_vars", + "cmake_var_string", +) + +llvm_host_triple = "x86_64-unknown-linux_gnu" + +llvm_targets = [ + "AArch64", + "ARM", + "NVPTX", + "PowerPC", + "X86", +] + +llvm_target_asm_parsers = [ + "AArch64", + "ARM", + "PowerPC", + "X86", +] + +llvm_target_asm_printers = llvm_target_asm_parsers + +llvm_target_disassemblers = llvm_target_asm_parsers + +# TODO(phawkins): the set of CMake variables was hardcoded for expediency. +# However, we should really detect many of these via configure-time tests. + +# The set of CMake variables common to all targets. +cmake_vars = { + # Headers + "HAVE_DIRENT_H": 1, + "HAVE_DLFCN_H": 1, + "HAVE_ERRNO_H": 1, + "HAVE_EXECINFO_H": 1, + "HAVE_FCNTL_H": 1, + "HAVE_INTTYPES_H": 1, + "HAVE_PTHREAD_H": 1, + "HAVE_SIGNAL_H": 1, + "HAVE_STDINT_H": 1, + "HAVE_SYS_IOCTL_H": 1, + "HAVE_SYS_MMAN_H": 1, + "HAVE_SYS_PARAM_H": 1, + "HAVE_SYS_RESOURCE_H": 1, + "HAVE_SYS_STAT_H": 1, + "HAVE_SYS_TIME_H": 1, + "HAVE_SYS_TYPES_H": 1, + "HAVE_TERMIOS_H": 1, + "HAVE_UNISTD_H": 1, + "HAVE_ZLIB_H": 1, + + # Features + "HAVE_BACKTRACE": 1, + "HAVE_DLOPEN": 1, + "HAVE_FUTIMES": 1, + "HAVE_GETCWD": 1, + "HAVE_GETPAGESIZE": 1, + "HAVE_GETRLIMIT": 1, + "HAVE_GETRUSAGE": 1, + "HAVE_GETTIMEOFDAY": 1, + "HAVE_INT64_T": 1, + "HAVE_ISATTY": 1, + "HAVE_LIBEDIT": 1, + "HAVE_LIBPTHREAD": 1, + "HAVE_LIBZ": 1, + "HAVE_MKDTEMP": 1, + "HAVE_MKSTEMP": 1, + "HAVE_MKTEMP": 1, + "HAVE_PREAD": 1, + "HAVE_PTHREAD_GETSPECIFIC": 1, + "HAVE_PTHREAD_MUTEX_LOCK": 1, + "HAVE_PTHREAD_RWLOCK_INIT": 1, + "HAVE_REALPATH": 1, + "HAVE_SBRK": 1, + "HAVE_SETENV": 1, + "HAVE_SETRLIMIT": 1, + "HAVE_SIGALTSTACK": 1, + "HAVE_STRERROR": 1, + "HAVE_STRERROR_R": 1, + "HAVE_STRTOLL": 1, + "HAVE_SYSCONF": 1, + "HAVE_UINT64_T": 1, + "HAVE__UNWIND_BACKTRACE": 1, + + # LLVM features + "ENABLE_BACKTRACES": 1, + "LLVM_BINDIR": "/dev/null", + "LLVM_ENABLE_THREADS": 1, + "LLVM_ENABLE_ZLIB": 1, + "LLVM_HAS_ATOMICS": 1, + "LLVM_INCLUDEDIR": "/dev/null", + "LLVM_INFODIR": "/dev/null", + "LLVM_MANDIR": "/dev/null", + "LLVM_NATIVE_TARGET": 1, + "LLVM_NATIVE_TARGETINFO": 1, + "LLVM_NATIVE_TARGETMC": 1, + "LLVM_NATIVE_ASMPRINTER": 1, + "LLVM_NATIVE_ASMPARSER": 1, + "LLVM_NATIVE_DISASSEMBLER": 1, + "LLVM_ON_UNIX": 1, + "LLVM_PREFIX": "/dev/null", + "LLVM_VERSION_MAJOR": 0, + "LLVM_VERSION_MINOR": 0, + "LLVM_VERSION_PATCH": 0, + "LTDL_SHLIB_EXT": ".so", + "PACKAGE_NAME": "llvm", + "PACKAGE_STRING": "llvm tensorflow-trunk", + "PACKAGE_VERSION": "tensorflow-trunk", + "RETSIGTYPE": "void", +} + +# CMake variables specific to the Linux platform +linux_cmake_vars = { + "HAVE_MALLOC_H": 1, + "HAVE_LINK_H": 1, + "HAVE_MALLINFO": 1, + "HAVE_FUTIMENS": 1, +} + +# CMake variables specific to the Darwin (Mac OS X) platform. +darwin_cmake_vars = { + "HAVE_MALLOC_MALLOC_H": 1, +} + +# Select a set of CMake variables based on the platform. +# TODO(phawkins): use a better method to select the right host triple, rather +# than hardcoding x86_64. +all_cmake_vars = select({ + "@//tensorflow:darwin": cmake_var_string( + cmake_vars + llvm_target_cmake_vars("X86", "x86_64-apple-darwin") + + darwin_cmake_vars, + ), + "//conditions:default": cmake_var_string( + cmake_vars + + llvm_target_cmake_vars("X86", "x86_64-unknown-linux_gnu") + + linux_cmake_vars, + ), +}) + +# Performs CMake variable substitutions on configuration header files. +expand_cmake_vars( + name = "datatypes_gen", + src = "include/llvm/Support/DataTypes.h.cmake", + cmake_vars = all_cmake_vars, + dst = "include/llvm/Support/DataTypes.h", +) + +expand_cmake_vars( + name = "config_gen", + src = "include/llvm/Config/config.h.cmake", + cmake_vars = all_cmake_vars, + dst = "include/llvm/Config/config.h", +) + +expand_cmake_vars( + name = "llvm_config_gen", + src = "include/llvm/Config/llvm-config.h.cmake", + cmake_vars = all_cmake_vars, + dst = "include/llvm/Config/llvm-config.h", +) + +# Performs macro expansions on .def.in files +expand_header_template( + name = "targets_def_gen", + out = "include/llvm/Config/Targets.def", + substitutions = { + "@LLVM_ENUM_TARGETS@": "\n".join( + ["LLVM_TARGET({})".format(t) for t in llvm_targets], + ), + }, + template = "include/llvm/Config/Targets.def.in", +) + +expand_header_template( + name = "asm_parsers_def_gen", + 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], + ), + }, + template = "include/llvm/Config/AsmParsers.def.in", +) + +expand_header_template( + name = "asm_printers_def_gen", + out = "include/llvm/Config/AsmPrinters.def", + substitutions = { + "@LLVM_ENUM_ASM_PRINTERS@": "\n".join( + ["LLVM_ASM_PRINTER({})".format(t) for t in llvm_target_asm_printers], + ), + }, + template = "include/llvm/Config/AsmPrinters.def.in", +) + +expand_header_template( + name = "disassemblers_def_gen", + out = "include/llvm/Config/Disassemblers.def", + substitutions = { + "@LLVM_ENUM_DISASSEMBLERS@": "\n".join( + ["LLVM_DISASSEMBLER({})".format(t) for t in llvm_target_disassemblers], + ), + }, + template = "include/llvm/Config/Disassemblers.def.in", +) + +# A common library that all LLVM targets depend on. +cc_library( + name = "config", + hdrs = [ + "include/llvm/Config/AsmParsers.def", + "include/llvm/Config/AsmPrinters.def", + "include/llvm/Config/Disassemblers.def", + "include/llvm/Config/Targets.def", + "include/llvm/Config/config.h", + "include/llvm/Config/llvm-config.h", + ], + defines = [ + "LLVM_ENABLE_STATS", + "__STDC_LIMIT_MACROS", + "__STDC_CONSTANT_MACROS", + "_DEBUG", + "LLVM_BUILD_GLOBAL_ISEL", + ], + includes = ["include"], +) + +# Rules that apply the LLVM tblgen tool. +gentbl( + name = "intrinsics_gen", + tbl_outs = [("-gen-intrinsic", "include/llvm/IR/Intrinsics.gen")], + tblgen = ":llvm-tblgen", + td_file = "include/llvm/IR/Intrinsics.td", + td_srcs = glob([ + "include/llvm/CodeGen/*.td", + "include/llvm/IR/Intrinsics*.td", + ]), +) + +gentbl( + name = "attributes_gen", + tbl_outs = [("-gen-attrs", "include/llvm/IR/Attributes.gen")], + tblgen = ":llvm-tblgen", + td_file = "include/llvm/IR/Attributes.td", + td_srcs = ["include/llvm/IR/Attributes.td"], +) + +gentbl( + name = "attributes_compat_gen", + tbl_outs = [("-gen-attrs", "lib/IR/AttributesCompatFunc.inc")], + tblgen = ":llvm-tblgen", + td_file = "lib/IR/AttributesCompatFunc.td", + td_srcs = [ + "lib/IR/AttributesCompatFunc.td", + "include/llvm/IR/Attributes.td", + ], +) + +# Binary targets used by Tensorflow. +cc_binary( + name = "llvm-tblgen", + srcs = glob([ + "utils/TableGen/*.cpp", + "utils/TableGen/*.h", + ]) + [ + "lib/Target/X86/Disassembler/X86DisassemblerDecoderCommon.h", + ], + linkopts = [ + "-ldl", + "-lpthread", + ], + stamp = 0, + deps = [ + ":config", + ":support", + ":table_gen", + ], +) + +cc_binary( + name = "FileCheck", + testonly = 1, + srcs = glob([ + "utils/FileCheck/*.cpp", + "utils/FileCheck/*.h", + ]), + linkopts = [ + "-ldl", + "-lpthread", + ], + stamp = 0, + deps = [":support"], +) + +llvm_target_list = [ + { + "name": "AArch64", + "lower_name": "aarch64", + "short_name": "AArch64", + "tbl_outs": [ + ("-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-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", + "lower_name": "arm", + "short_name": "ARM", + "tbl_outs": [ + ("-gen-register-info", "lib/Target/ARM/ARMGenRegisterInfo.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-callingconv", "lib/Target/ARM/ARMGenCallingConv.inc"), + ("-gen-subtarget", "lib/Target/ARM/ARMGenSubtargetInfo.inc"), + ("-gen-disassembler", "lib/Target/ARM/ARMGenDisassemblerTables.inc"), + ], + }, + { + "name": "NVPTX", + "lower_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", + "lower_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"), + ], + }, + { + "name": "X86", + "lower_name": "x86", + "short_name": "X86", + "tbl_outs": [ + ("-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-callingconv", "lib/Target/X86/X86GenCallingConv.inc"), + ("-gen-subtarget", "lib/Target/X86/X86GenSubtargetInfo.inc"), + ], + }, +] + +[ + gentbl( + name = target["lower_name"] + "_target_gen", + tbl_outs = target["tbl_outs"], + tblgen = ":llvm-tblgen", + td_file = ("lib/Target/" + target["name"] + "/" + target["short_name"] + + ".td"), + td_srcs = glob([ + "lib/Target/" + target["name"] + "/*.td", + "include/llvm/CodeGen/*.td", + "include/llvm/IR/Intrinsics*.td", + "include/llvm/TableGen/*.td", + "include/llvm/Target/*.td", + ]), + ) + for target in llvm_target_list +] + +cc_library( + name = "aarch64_asm_parser", + srcs = glob([ + "lib/Target/AArch64/AsmParser/*.c", + "lib/Target/AArch64/AsmParser/*.cpp", + "lib/Target/AArch64/AsmParser/*.inc", + ]), + hdrs = glob([ + "include/llvm/Target/AArch64/AsmParser/*.h", + "include/llvm/Target/AArch64/AsmParser/*.def", + "include/llvm/Target/AArch64/AsmParser/*.inc", + "lib/Target/AArch64/AsmParser/*.h", + ]), + copts = ["-Iexternal/llvm/lib/Target/AArch64"], + deps = [ + ":aarch64_desc", + ":aarch64_info", + ":aarch64_utils", + ":config", + ":mc", + ":mc_parser", + ":support", + ], +) + +cc_library( + name = "aarch64_asm_printer", + srcs = glob([ + "lib/Target/AArch64/InstPrinter/*.c", + "lib/Target/AArch64/InstPrinter/*.cpp", + "lib/Target/AArch64/InstPrinter/*.inc", + ]), + hdrs = glob([ + "include/llvm/Target/AArch64/InstPrinter/*.h", + "include/llvm/Target/AArch64/InstPrinter/*.def", + "include/llvm/Target/AArch64/InstPrinter/*.inc", + "lib/Target/AArch64/InstPrinter/*.h", + ]), + copts = ["-Iexternal/llvm/lib/Target/AArch64"], + deps = [ + ":aarch64_target_gen", + ":aarch64_utils", + ":config", + ":mc", + ":support", + ], +) + +cc_library( + name = "aarch64_code_gen", + srcs = glob([ + "lib/Target/AArch64/*.c", + "lib/Target/AArch64/*.cpp", + "lib/Target/AArch64/*.inc", + ]), + hdrs = glob([ + "include/llvm/Target/AArch64/*.h", + "include/llvm/Target/AArch64/*.def", + "include/llvm/Target/AArch64/*.inc", + "lib/Target/AArch64/*.h", + ]), + copts = ["-Iexternal/llvm/lib/Target/AArch64"], + deps = [ + ":aarch64_asm_printer", + ":aarch64_desc", + ":aarch64_info", + ":aarch64_utils", + ":analysis", + ":asm_printer", + ":code_gen", + ":config", + ":core", + ":global_i_sel", + ":mc", + ":scalar", + ":selection_dag", + ":support", + ":target", + ], +) + +cc_library( + name = "aarch64_desc", + srcs = glob([ + "lib/Target/AArch64/MCTargetDesc/*.c", + "lib/Target/AArch64/MCTargetDesc/*.cpp", + "lib/Target/AArch64/MCTargetDesc/*.inc", + ]), + hdrs = glob([ + "include/llvm/Target/AArch64/MCTargetDesc/*.h", + "include/llvm/Target/AArch64/MCTargetDesc/*.def", + "include/llvm/Target/AArch64/MCTargetDesc/*.inc", + "lib/Target/AArch64/MCTargetDesc/*.h", + ]), + copts = ["-Iexternal/llvm/lib/Target/AArch64"], + deps = [ + ":aarch64_asm_printer", + ":aarch64_info", + ":aarch64_target_gen", + ":attributes_gen", + ":config", + ":intrinsics_gen", + ":mc", + ":support", + ], +) + +cc_library( + name = "aarch64_disassembler", + srcs = glob([ + "lib/Target/AArch64/Disassembler/*.c", + "lib/Target/AArch64/Disassembler/*.cpp", + "lib/Target/AArch64/Disassembler/*.inc", + ]), + hdrs = glob([ + "include/llvm/Target/AArch64/Disassembler/*.h", + "include/llvm/Target/AArch64/Disassembler/*.def", + "include/llvm/Target/AArch64/Disassembler/*.inc", + "lib/Target/AArch64/Disassembler/*.h", + ]), + copts = ["-Iexternal/llvm/lib/Target/AArch64"], + deps = [ + ":aarch64_desc", + ":aarch64_info", + ":aarch64_utils", + ":config", + ":mc", + ":mc_disassembler", + ":support", + ], +) + +cc_library( + name = "aarch64_info", + srcs = glob([ + "lib/Target/AArch64/TargetInfo/*.c", + "lib/Target/AArch64/TargetInfo/*.cpp", + "lib/Target/AArch64/TargetInfo/*.inc", + "lib/Target/AArch64/MCTargetDesc/*.h", + ]), + hdrs = glob([ + "include/llvm/Target/AArch64/TargetInfo/*.h", + "include/llvm/Target/AArch64/TargetInfo/*.def", + "include/llvm/Target/AArch64/TargetInfo/*.inc", + "lib/Target/AArch64/*.def", + "lib/Target/AArch64/AArch64*.h", + "lib/Target/AArch64/TargetInfo/*.h", + ]), + copts = ["-Iexternal/llvm/lib/Target/AArch64"], + deps = [ + ":code_gen", + ":config", + ":support", + ":target", + ], +) + +cc_library( + name = "aarch64_utils", + srcs = glob([ + "lib/Target/AArch64/Utils/*.c", + "lib/Target/AArch64/Utils/*.cpp", + "lib/Target/AArch64/Utils/*.inc", + "lib/Target/AArch64/MCTargetDesc/*.h", + ]), + hdrs = glob([ + "include/llvm/Target/AArch64/Utils/*.h", + "include/llvm/Target/AArch64/Utils/*.def", + "include/llvm/Target/AArch64/Utils/*.inc", + "lib/Target/AArch64/Utils/*.h", + ]), + copts = ["-Iexternal/llvm/lib/Target/AArch64"], + deps = [ + ":aarch64_target_gen", + ":config", + ":mc", + ":support", + ], +) + +cc_library( + name = "analysis", + srcs = glob([ + "lib/Analysis/*.c", + "lib/Analysis/*.cpp", + "lib/Analysis/*.inc", + "include/llvm/Transforms/Utils/Local.h", + "lib/Analysis/*.h", + ]), + hdrs = glob([ + "include/llvm/Analysis/*.h", + "include/llvm/Analysis/*.def", + "include/llvm/Analysis/*.inc", + ]), + deps = [ + ":config", + ":core", + ":object", + ":profile_data", + ":support", + ], +) + +cc_library( + name = "arm_asm_parser", + srcs = glob([ + "lib/Target/ARM/AsmParser/*.c", + "lib/Target/ARM/AsmParser/*.cpp", + "lib/Target/ARM/AsmParser/*.inc", + ]), + hdrs = glob([ + "include/llvm/Target/ARM/AsmParser/*.h", + "include/llvm/Target/ARM/AsmParser/*.def", + "include/llvm/Target/ARM/AsmParser/*.inc", + "lib/Target/ARM/AsmParser/*.h", + ]), + copts = ["-Iexternal/llvm/lib/Target/ARM"], + deps = [ + ":arm_desc", + ":arm_info", + ":config", + ":mc", + ":mc_parser", + ":support", + ], +) + +cc_library( + name = "arm_asm_printer", + srcs = glob([ + "lib/Target/ARM/InstPrinter/*.c", + "lib/Target/ARM/InstPrinter/*.cpp", + "lib/Target/ARM/InstPrinter/*.inc", + ]), + hdrs = glob([ + "include/llvm/Target/ARM/InstPrinter/*.h", + "include/llvm/Target/ARM/InstPrinter/*.def", + "include/llvm/Target/ARM/InstPrinter/*.inc", + "lib/Target/ARM/InstPrinter/*.h", + ]), + copts = ["-Iexternal/llvm/lib/Target/ARM"], + deps = [ + ":arm_info", + ":arm_target_gen", + ":config", + ":mc", + ":support", + ], +) + +cc_library( + name = "arm_code_gen", + srcs = glob([ + "lib/Target/ARM/*.c", + "lib/Target/ARM/*.cpp", + "lib/Target/ARM/*.inc", + ]), + hdrs = glob([ + "include/llvm/Target/ARM/*.h", + "include/llvm/Target/ARM/*.def", + "include/llvm/Target/ARM/*.inc", + "lib/Target/ARM/*.h", + ]), + copts = ["-Iexternal/llvm/lib/Target/ARM"], + deps = [ + ":analysis", + ":arm_asm_printer", + ":arm_desc", + ":arm_info", + ":asm_printer", + ":code_gen", + ":config", + ":core", + ":global_i_sel", + ":mc", + ":scalar", + ":selection_dag", + ":support", + ":target", + ], +) + +cc_library( + name = "arm_desc", + srcs = glob([ + "lib/Target/ARM/MCTargetDesc/*.c", + "lib/Target/ARM/MCTargetDesc/*.cpp", + "lib/Target/ARM/MCTargetDesc/*.inc", + "lib/Target/ARM/*.h", + ]), + hdrs = glob([ + "include/llvm/Target/ARM/MCTargetDesc/*.h", + "include/llvm/Target/ARM/MCTargetDesc/*.def", + "include/llvm/Target/ARM/MCTargetDesc/*.inc", + "lib/Target/ARM/MCTargetDesc/*.h", + ]), + copts = ["-Iexternal/llvm/lib/Target/ARM"], + deps = [ + ":arm_asm_printer", + ":arm_info", + ":arm_target_gen", + ":attributes_gen", + ":config", + ":intrinsics_gen", + ":mc", + ":mc_disassembler", + ":support", + ], +) + +cc_library( + name = "arm_disassembler", + srcs = glob([ + "lib/Target/ARM/Disassembler/*.c", + "lib/Target/ARM/Disassembler/*.cpp", + "lib/Target/ARM/Disassembler/*.inc", + ]), + hdrs = glob([ + "include/llvm/Target/ARM/Disassembler/*.h", + "include/llvm/Target/ARM/Disassembler/*.def", + "include/llvm/Target/ARM/Disassembler/*.inc", + "lib/Target/ARM/Disassembler/*.h", + ]), + copts = ["-Iexternal/llvm/lib/Target/ARM"], + deps = [ + ":arm_desc", + ":arm_info", + ":config", + ":mc_disassembler", + ":support", + ], +) + +cc_library( + name = "arm_info", + srcs = glob([ + "lib/Target/ARM/TargetInfo/*.c", + "lib/Target/ARM/TargetInfo/*.cpp", + "lib/Target/ARM/TargetInfo/*.inc", + "lib/Target/ARM/MCTargetDesc/*.h", + ]), + hdrs = glob([ + "include/llvm/Target/ARM/TargetInfo/*.h", + "include/llvm/Target/ARM/TargetInfo/*.def", + "include/llvm/Target/ARM/TargetInfo/*.inc", + "lib/Target/ARM/TargetInfo/*.h", + ]), + copts = ["-Iexternal/llvm/lib/Target/ARM"], + deps = [ + ":arm_target_gen", + ":config", + ":support", + ":target", + ], +) + +cc_library( + name = "asm_parser", + srcs = glob([ + "lib/AsmParser/*.c", + "lib/AsmParser/*.cpp", + "lib/AsmParser/*.inc", + "lib/AsmParser/*.h", + ]), + hdrs = glob([ + "include/llvm/AsmParser/*.h", + "include/llvm/AsmParser/*.def", + "include/llvm/AsmParser/*.inc", + ]), + deps = [ + ":config", + ":core", + ":support", + ], +) + +cc_library( + name = "asm_printer", + srcs = glob([ + "lib/CodeGen/AsmPrinter/*.c", + "lib/CodeGen/AsmPrinter/*.cpp", + "lib/CodeGen/AsmPrinter/*.inc", + "lib/CodeGen/AsmPrinter/*.h", + ]), + hdrs = glob([ + "include/llvm/CodeGen/AsmPrinter/*.h", + "include/llvm/CodeGen/AsmPrinter/*.def", + "include/llvm/CodeGen/AsmPrinter/*.inc", + ]), + deps = [ + ":analysis", + ":code_gen", + ":config", + ":core", + ":debug_info_code_view", + ":debug_info_msf", + ":mc", + ":mc_parser", + ":support", + ":target", + ":transform_utils", + ], +) + +cc_library( + name = "bit_reader", + srcs = glob([ + "lib/Bitcode/Reader/*.c", + "lib/Bitcode/Reader/*.cpp", + "lib/Bitcode/Reader/*.inc", + "lib/Bitcode/Reader/*.h", + ]), + hdrs = glob([ + "include/llvm/Bitcode/Reader/*.h", + "include/llvm/Bitcode/Reader/*.def", + "include/llvm/Bitcode/Reader/*.inc", + "include/llvm/Bitcode/BitstreamReader.h", + ]), + deps = [ + ":config", + ":core", + ":support", + ], +) + +cc_library( + name = "bit_writer", + srcs = glob([ + "lib/Bitcode/Writer/*.c", + "lib/Bitcode/Writer/*.cpp", + "lib/Bitcode/Writer/*.inc", + "lib/Bitcode/Writer/*.h", + ]), + hdrs = glob([ + "include/llvm/Bitcode/Writer/*.h", + "include/llvm/Bitcode/Writer/*.def", + "include/llvm/Bitcode/Writer/*.inc", + "include/llvm/Bitcode/BitcodeWriter.h", + "include/llvm/Bitcode/BitcodeWriterPass.h", + "include/llvm/Bitcode/BitstreamWriter.h", + ]), + deps = [ + ":analysis", + ":config", + ":core", + ":support", + ], +) + +cc_library( + name = "code_gen", + srcs = glob([ + "lib/CodeGen/*.c", + "lib/CodeGen/*.cpp", + "lib/CodeGen/*.inc", + "lib/CodeGen/*.h", + ]), + hdrs = glob([ + "include/llvm/CodeGen/*.h", + "include/llvm/CodeGen/*.def", + "include/llvm/CodeGen/*.inc", + "include/llvm/CodeGen/**/*.h", + ]), + deps = [ + ":analysis", + ":bit_reader", + ":bit_writer", + ":config", + ":core", + ":instrumentation", + ":mc", + ":profile_data", + ":scalar", + ":support", + ":target", + ":transform_utils", + ], +) + +cc_library( + name = "core", + srcs = glob([ + "lib/IR/*.c", + "lib/IR/*.cpp", + "lib/IR/*.inc", + "include/llvm/Analysis/*.h", + "include/llvm/Bitcode/BitcodeReader.h", + "include/llvm/Bitcode/BitCodes.h", + "include/llvm/Bitcode/LLVMBitCodes.h", + "include/llvm/CodeGen/MachineValueType.h", + "include/llvm/CodeGen/ValueTypes.h", + "lib/IR/*.h", + ]), + hdrs = glob([ + "include/llvm/IR/*.h", + "include/llvm/IR/*.def", + "include/llvm/IR/*.inc", + "include/llvm/*.h", + ]), + deps = [ + ":attributes_compat_gen", + ":attributes_gen", + ":config", + ":intrinsics_gen", + ":support", + ], +) + +cc_library( + name = "debug_info_code_view", + srcs = glob([ + "lib/DebugInfo/CodeView/*.c", + "lib/DebugInfo/CodeView/*.cpp", + "lib/DebugInfo/CodeView/*.inc", + "lib/DebugInfo/CodeView/*.h", + ]), + hdrs = glob([ + "include/llvm/DebugInfo/CodeView/*.h", + "include/llvm/DebugInfo/CodeView/*.def", + "include/llvm/DebugInfo/CodeView/*.inc", + ]), + deps = [ + ":config", + ":debug_info_msf", + ":support", + ], +) + +cc_library( + name = "debug_info_msf", + srcs = glob([ + "lib/DebugInfo/MSF/*.c", + "lib/DebugInfo/MSF/*.cpp", + "lib/DebugInfo/MSF/*.inc", + "lib/DebugInfo/MSF/*.h", + ]), + hdrs = glob([ + "include/llvm/DebugInfo/MSF/*.h", + "include/llvm/DebugInfo/MSF/*.def", + "include/llvm/DebugInfo/MSF/*.inc", + ]), + deps = [ + ":config", + ":support", + ], +) + +cc_library( + name = "demangle", + srcs = glob([ + "lib/Demangle/*.c", + "lib/Demangle/*.cpp", + "lib/Demangle/*.inc", + "lib/Demangle/*.h", + ]), + hdrs = glob([ + "include/llvm/Demangle/*.h", + "include/llvm/Demangle/*.def", + "include/llvm/Demangle/*.inc", + ]), + deps = [":config"], +) + +cc_library( + name = "execution_engine", + srcs = glob([ + "lib/ExecutionEngine/*.c", + "lib/ExecutionEngine/*.cpp", + "lib/ExecutionEngine/*.inc", + "lib/ExecutionEngine/*.h", + ]), + hdrs = glob([ + "include/llvm/ExecutionEngine/*.h", + "include/llvm/ExecutionEngine/*.def", + "include/llvm/ExecutionEngine/*.inc", + ]), + deps = [ + ":config", + ":core", + ":mc", + ":object", + ":runtime_dyld", + ":support", + ":target", + ], +) + +cc_library( + name = "global_i_sel", + srcs = glob([ + "lib/CodeGen/GlobalISel/*.c", + "lib/CodeGen/GlobalISel/*.cpp", + "lib/CodeGen/GlobalISel/*.inc", + "lib/CodeGen/GlobalISel/*.h", + ]), + hdrs = glob([ + "include/llvm/CodeGen/GlobalISel/*.h", + "include/llvm/CodeGen/GlobalISel/*.def", + "include/llvm/CodeGen/GlobalISel/*.inc", + ]), + deps = [ + ":analysis", + ":code_gen", + ":config", + ":core", + ":mc", + ":support", + ":target", + ":transform_utils", + ], +) + +cc_library( + name = "instrumentation", + srcs = glob([ + "lib/Transforms/Instrumentation/*.c", + "lib/Transforms/Instrumentation/*.cpp", + "lib/Transforms/Instrumentation/*.inc", + "lib/Transforms/Instrumentation/*.h", + ]), + hdrs = glob([ + "include/llvm/Transforms/Instrumentation/*.h", + "include/llvm/Transforms/Instrumentation/*.def", + "include/llvm/Transforms/Instrumentation/*.inc", + "include/llvm/Transforms/GCovProfiler.h", + "include/llvm/Transforms/Instrumentation.h", + "include/llvm/Transforms/InstrProfiling.h", + "include/llvm/Transforms/PGOInstrumentation.h", + ]), + deps = [ + ":analysis", + ":config", + ":core", + ":mc", + ":profile_data", + ":support", + ":transform_utils", + ], +) + +cc_library( + name = "inst_combine", + srcs = glob([ + "lib/Transforms/InstCombine/*.c", + "lib/Transforms/InstCombine/*.cpp", + "lib/Transforms/InstCombine/*.inc", + "lib/Transforms/InstCombine/*.h", + ]), + hdrs = glob([ + "include/llvm/Transforms/InstCombine/*.h", + "include/llvm/Transforms/InstCombine/*.def", + "include/llvm/Transforms/InstCombine/*.inc", + ]), + deps = [ + ":analysis", + ":config", + ":core", + ":support", + ":transform_utils", + ], +) + +cc_library( + name = "ipo", + srcs = glob([ + "lib/Transforms/IPO/*.c", + "lib/Transforms/IPO/*.cpp", + "lib/Transforms/IPO/*.inc", + "lib/Transforms/IPO/*.h", + ]), + hdrs = glob([ + "include/llvm/Transforms/IPO/*.h", + "include/llvm/Transforms/IPO/*.def", + "include/llvm/Transforms/IPO/*.inc", + ]), + deps = [ + ":analysis", + ":config", + ":core", + ":inst_combine", + ":instrumentation", + ":ir_reader", + ":linker", + ":object", + ":profile_data", + ":scalar", + ":support", + ":transform_utils", + ":vectorize", + ], +) + +cc_library( + name = "ir_reader", + srcs = glob([ + "lib/IRReader/*.c", + "lib/IRReader/*.cpp", + "lib/IRReader/*.inc", + "lib/IRReader/*.h", + ]), + hdrs = glob([ + "include/llvm/IRReader/*.h", + "include/llvm/IRReader/*.def", + "include/llvm/IRReader/*.inc", + ]), + deps = [ + ":asm_parser", + ":bit_reader", + ":config", + ":core", + ":support", + ], +) + +cc_library( + name = "linker", + srcs = glob([ + "lib/Linker/*.c", + "lib/Linker/*.cpp", + "lib/Linker/*.inc", + "lib/Linker/*.h", + ]), + hdrs = glob([ + "include/llvm/Linker/*.h", + "include/llvm/Linker/*.def", + "include/llvm/Linker/*.inc", + ]), + deps = [ + ":config", + ":core", + ":support", + ":transform_utils", + ], +) + +cc_library( + name = "mc", + srcs = glob([ + "lib/MC/*.c", + "lib/MC/*.cpp", + "lib/MC/*.inc", + "lib/MC/*.h", + ]), + hdrs = glob([ + "include/llvm/MC/*.h", + "include/llvm/MC/*.def", + "include/llvm/MC/*.inc", + ]), + deps = [ + ":config", + ":debug_info_code_view", + ":support", + ], +) + +cc_library( + name = "mc_disassembler", + srcs = glob([ + "lib/MC/MCDisassembler/*.c", + "lib/MC/MCDisassembler/*.cpp", + "lib/MC/MCDisassembler/*.inc", + "lib/MC/MCDisassembler/*.h", + ]), + hdrs = glob([ + "include/llvm/MC/MCDisassembler/*.h", + "include/llvm/MC/MCDisassembler/*.def", + "include/llvm/MC/MCDisassembler/*.inc", + ]), + deps = [ + ":config", + ":mc", + ":support", + ], +) + +cc_library( + name = "mc_parser", + srcs = glob([ + "lib/MC/MCParser/*.c", + "lib/MC/MCParser/*.cpp", + "lib/MC/MCParser/*.inc", + "lib/MC/MCParser/*.h", + ]), + hdrs = glob([ + "include/llvm/MC/MCParser/*.h", + "include/llvm/MC/MCParser/*.def", + "include/llvm/MC/MCParser/*.inc", + ]), + deps = [ + ":config", + ":mc", + ":support", + ], +) + +cc_library( + name = "nvptx_asm_printer", + srcs = glob([ + "lib/Target/NVPTX/InstPrinter/*.c", + "lib/Target/NVPTX/InstPrinter/*.cpp", + "lib/Target/NVPTX/InstPrinter/*.inc", + ]), + hdrs = glob([ + "include/llvm/Target/NVPTX/InstPrinter/*.h", + "include/llvm/Target/NVPTX/InstPrinter/*.def", + "include/llvm/Target/NVPTX/InstPrinter/*.inc", + "lib/Target/NVPTX/InstPrinter/*.h", + ]), + copts = ["-Iexternal/llvm/lib/Target/NVPTX"], + deps = [ + "nvptx_target_gen", + ":attributes_gen", + ":config", + ":mc", + ":nvptx_info", + ":support", + ], +) + +cc_library( + name = "nvptx_code_gen", + srcs = glob([ + "lib/Target/NVPTX/*.c", + "lib/Target/NVPTX/*.cpp", + "lib/Target/NVPTX/*.inc", + ]), + hdrs = glob([ + "include/llvm/Target/NVPTX/*.h", + "include/llvm/Target/NVPTX/*.def", + "include/llvm/Target/NVPTX/*.inc", + "lib/Target/NVPTX/*.h", + ]), + copts = ["-Iexternal/llvm/lib/Target/NVPTX"], + deps = [ + ":analysis", + ":asm_printer", + ":code_gen", + ":config", + ":core", + ":mc", + ":nvptx_asm_printer", + ":nvptx_desc", + ":nvptx_info", + ":scalar", + ":selection_dag", + ":support", + ":target", + ":transform_utils", + ":vectorize", + ], +) + +cc_library( + name = "nvptx_desc", + srcs = glob([ + "lib/Target/NVPTX/MCTargetDesc/*.c", + "lib/Target/NVPTX/MCTargetDesc/*.cpp", + "lib/Target/NVPTX/MCTargetDesc/*.inc", + ]), + hdrs = glob([ + "include/llvm/Target/NVPTX/MCTargetDesc/*.h", + "include/llvm/Target/NVPTX/MCTargetDesc/*.def", + "include/llvm/Target/NVPTX/MCTargetDesc/*.inc", + "lib/Target/NVPTX/MCTargetDesc/*.h", + ]), + copts = ["-Iexternal/llvm/lib/Target/NVPTX"], + deps = [ + "nvptx_target_gen", + ":config", + ":mc", + ":nvptx_asm_printer", + ":nvptx_info", + ":support", + ], +) + +cc_library( + name = "nvptx_info", + srcs = glob([ + "lib/Target/NVPTX/TargetInfo/*.c", + "lib/Target/NVPTX/TargetInfo/*.cpp", + "lib/Target/NVPTX/TargetInfo/*.inc", + "lib/Target/NVPTX/MCTargetDesc/*.h", + ]), + hdrs = glob([ + "include/llvm/Target/NVPTX/TargetInfo/*.h", + "include/llvm/Target/NVPTX/TargetInfo/*.def", + "include/llvm/Target/NVPTX/TargetInfo/*.inc", + "lib/Target/NVPTX/NVPTX.h", + "lib/Target/NVPTX/TargetInfo/*.h", + ]), + copts = ["-Iexternal/llvm/lib/Target/NVPTX"], + deps = [ + "nvptx_target_gen", + ":attributes_gen", + ":config", + ":core", + ":support", + ":target", + ], +) + +cc_library( + name = "object", + srcs = glob([ + "lib/Object/*.c", + "lib/Object/*.cpp", + "lib/Object/*.inc", + "lib/Object/*.h", + ]), + hdrs = glob([ + "include/llvm/Object/*.h", + "include/llvm/Object/*.def", + "include/llvm/Object/*.inc", + ]), + deps = [ + ":bit_reader", + ":config", + ":core", + ":mc", + ":mc_parser", + ":support", + ], +) + +cc_library( + name = "orc_jit", + srcs = glob([ + "lib/ExecutionEngine/Orc/*.c", + "lib/ExecutionEngine/Orc/*.cpp", + "lib/ExecutionEngine/Orc/*.inc", + "lib/ExecutionEngine/Orc/*.h", + ]), + hdrs = glob([ + "include/llvm/ExecutionEngine/Orc/*.h", + "include/llvm/ExecutionEngine/Orc/*.def", + "include/llvm/ExecutionEngine/Orc/*.inc", + ]), + deps = [ + ":config", + ":core", + ":execution_engine", + ":object", + ":runtime_dyld", + ":support", + ":transform_utils", + ], +) + +cc_library( + name = "powerpc_asm_parser", + srcs = glob([ + "lib/Target/PowerPC/AsmParser/*.c", + "lib/Target/PowerPC/AsmParser/*.cpp", + "lib/Target/PowerPC/AsmParser/*.inc", + ]), + hdrs = glob([ + "include/llvm/Target/PowerPC/AsmParser/*.h", + "include/llvm/Target/PowerPC/AsmParser/*.def", + "include/llvm/Target/PowerPC/AsmParser/*.inc", + "lib/Target/PowerPC/AsmParser/*.h", + ]), + copts = ["-Iexternal/llvm/lib/Target/PowerPC"], + deps = [ + ":config", + ":mc", + ":mc_parser", + ":powerpc_desc", + ":powerpc_info", + ":support", + ], +) + +cc_library( + name = "powerpc_asm_printer", + srcs = glob([ + "lib/Target/PowerPC/InstPrinter/*.c", + "lib/Target/PowerPC/InstPrinter/*.cpp", + "lib/Target/PowerPC/InstPrinter/*.inc", + ]), + hdrs = glob([ + "include/llvm/Target/PowerPC/InstPrinter/*.h", + "include/llvm/Target/PowerPC/InstPrinter/*.def", + "include/llvm/Target/PowerPC/InstPrinter/*.inc", + "lib/Target/PowerPC/InstPrinter/*.h", + ]), + copts = ["-Iexternal/llvm/lib/Target/PowerPC"], + deps = [ + ":attributes_gen", + ":config", + ":intrinsics_gen", + ":mc", + ":powerpc_info", + ":powerpc_target_gen", + ":support", + ], +) + +cc_library( + name = "powerpc_code_gen", + srcs = glob([ + "lib/Target/PowerPC/*.c", + "lib/Target/PowerPC/*.cpp", + "lib/Target/PowerPC/*.inc", + ]), + hdrs = glob([ + "include/llvm/Target/PowerPC/*.h", + "include/llvm/Target/PowerPC/*.def", + "include/llvm/Target/PowerPC/*.inc", + "lib/Target/PowerPC/*.h", + ]), + copts = ["-Iexternal/llvm/lib/Target/PowerPC"], + deps = [ + ":analysis", + ":asm_printer", + ":code_gen", + ":config", + ":core", + ":mc", + ":powerpc_asm_printer", + ":powerpc_desc", + ":powerpc_info", + ":scalar", + ":selection_dag", + ":support", + ":target", + ":transform_utils", + ], +) + +cc_library( + name = "powerpc_desc", + srcs = glob([ + "lib/Target/PowerPC/MCTargetDesc/*.c", + "lib/Target/PowerPC/MCTargetDesc/*.cpp", + "lib/Target/PowerPC/MCTargetDesc/*.inc", + ]), + hdrs = glob([ + "include/llvm/Target/PowerPC/MCTargetDesc/*.h", + "include/llvm/Target/PowerPC/MCTargetDesc/*.def", + "include/llvm/Target/PowerPC/MCTargetDesc/*.inc", + "lib/Target/PowerPC/MCTargetDesc/*.h", + ]), + copts = ["-Iexternal/llvm/lib/Target/PowerPC"], + deps = [ + ":attributes_gen", + ":config", + ":intrinsics_gen", + ":mc", + ":powerpc_asm_printer", + ":powerpc_info", + ":powerpc_target_gen", + ":support", + ], +) + +cc_library( + name = "powerpc_disassembler", + srcs = glob([ + "lib/Target/PowerPC/Disassembler/*.c", + "lib/Target/PowerPC/Disassembler/*.cpp", + "lib/Target/PowerPC/Disassembler/*.inc", + ]), + hdrs = glob([ + "include/llvm/Target/PowerPC/Disassembler/*.h", + "include/llvm/Target/PowerPC/Disassembler/*.def", + "include/llvm/Target/PowerPC/Disassembler/*.inc", + "lib/Target/PowerPC/Disassembler/*.h", + ]), + copts = ["-Iexternal/llvm/lib/Target/PowerPC"], + deps = [ + ":config", + ":mc_disassembler", + ":powerpc_info", + ":support", + ], +) + +cc_library( + name = "powerpc_info", + srcs = glob([ + "lib/Target/PowerPC/TargetInfo/*.c", + "lib/Target/PowerPC/TargetInfo/*.cpp", + "lib/Target/PowerPC/TargetInfo/*.inc", + "lib/Target/PowerPC/MCTargetDesc/*.h", + ]), + hdrs = glob([ + "include/llvm/Target/PowerPC/TargetInfo/*.h", + "include/llvm/Target/PowerPC/TargetInfo/*.def", + "include/llvm/Target/PowerPC/TargetInfo/*.inc", + "lib/Target/PowerPC/PPC*.h", + "lib/Target/PowerPC/TargetInfo/*.h", + ]), + copts = ["-Iexternal/llvm/lib/Target/PowerPC"], + deps = [ + ":attributes_gen", + ":config", + ":core", + ":intrinsics_gen", + ":powerpc_target_gen", + ":support", + ":target", + ], +) + +cc_library( + name = "profile_data", + srcs = glob([ + "lib/ProfileData/*.c", + "lib/ProfileData/*.cpp", + "lib/ProfileData/*.inc", + "lib/ProfileData/*.h", + ]), + hdrs = glob([ + "include/llvm/ProfileData/*.h", + "include/llvm/ProfileData/*.def", + "include/llvm/ProfileData/*.inc", + ]), + deps = [ + ":config", + ":core", + ":support", + ], +) + +cc_library( + name = "runtime_dyld", + srcs = glob([ + "lib/ExecutionEngine/RuntimeDyld/*.c", + "lib/ExecutionEngine/RuntimeDyld/*.cpp", + "lib/ExecutionEngine/RuntimeDyld/*.inc", + "include/llvm/ExecutionEngine/JITSymbol.h", + "include/llvm/ExecutionEngine/RTDyldMemoryManager.h", + "lib/ExecutionEngine/RuntimeDyld/*.h", + "lib/ExecutionEngine/RuntimeDyld/Targets/*.h", + "lib/ExecutionEngine/RuntimeDyld/*.h", + ]), + hdrs = glob([ + "include/llvm/ExecutionEngine/RuntimeDyld/*.h", + "include/llvm/ExecutionEngine/RuntimeDyld/*.def", + "include/llvm/ExecutionEngine/RuntimeDyld/*.inc", + "include/llvm/DebugInfo/DIContext.h", + "include/llvm/ExecutionEngine/RTDyldMemoryManager.h", + "include/llvm/ExecutionEngine/RuntimeDyld*.h", + ]), + deps = [ + ":config", + ":mc", + ":mc_disassembler", + ":object", + ":support", + ], +) + +cc_library( + name = "scalar", + srcs = glob([ + "lib/Transforms/Scalar/*.c", + "lib/Transforms/Scalar/*.cpp", + "lib/Transforms/Scalar/*.inc", + "include/llvm-c/Transforms/Scalar.h", + "include/llvm/Transforms/Scalar.h", + "include/llvm/Target/TargetMachine.h", + "lib/Transforms/Scalar/*.h", + ]), + hdrs = glob([ + "include/llvm/Transforms/Scalar/*.h", + "include/llvm/Transforms/Scalar/*.def", + "include/llvm/Transforms/Scalar/*.inc", + "include/llvm/Transforms/IPO.h", + "include/llvm/Transforms/IPO/SCCP.h", + ]), + deps = [ + ":analysis", + ":config", + ":core", + ":inst_combine", + ":support", + ":target", + ":transform_utils", + ], +) + +cc_library( + name = "selection_dag", + srcs = glob([ + "lib/CodeGen/SelectionDAG/*.c", + "lib/CodeGen/SelectionDAG/*.cpp", + "lib/CodeGen/SelectionDAG/*.inc", + "lib/CodeGen/SelectionDAG/*.h", + ]), + hdrs = glob([ + "include/llvm/CodeGen/SelectionDAG/*.h", + "include/llvm/CodeGen/SelectionDAG/*.def", + "include/llvm/CodeGen/SelectionDAG/*.inc", + ]), + deps = [ + ":analysis", + ":code_gen", + ":config", + ":core", + ":mc", + ":support", + ":target", + ":transform_utils", + ], +) + +cc_library( + name = "support", + srcs = glob([ + "lib/Support/*.c", + "lib/Support/*.cpp", + "lib/Support/*.inc", + "lib/Support/Unix/*.inc", + "lib/Support/Unix/*.h", + "include/llvm-c/*.h", + "lib/Support/*.h", + ]), + hdrs = glob([ + "include/llvm/Support/*.h", + "include/llvm/Support/*.def", + "include/llvm/Support/*.inc", + "include/llvm/ADT/*.h", + "include/llvm/Support/ELFRelocs/*.def", + ]) + ["include/llvm/Support/DataTypes.h"], + deps = [ + ":config", + ":demangle", + ], +) + +cc_library( + name = "table_gen", + srcs = glob([ + "lib/TableGen/*.c", + "lib/TableGen/*.cpp", + "lib/TableGen/*.inc", + "include/llvm/CodeGen/*.h", + "lib/TableGen/*.h", + ]), + hdrs = glob([ + "include/llvm/TableGen/*.h", + "include/llvm/TableGen/*.def", + "include/llvm/TableGen/*.inc", + "include/llvm/Target/*.def", + ]), + deps = [ + ":config", + ":mc", + ":support", + ], +) + +cc_library( + name = "target", + srcs = glob([ + "lib/Target/*.c", + "lib/Target/*.cpp", + "lib/Target/*.inc", + "include/llvm/CodeGen/*.h", + "include/llvm-c/Initialization.h", + "include/llvm-c/Target.h", + "lib/Target/*.h", + ]), + hdrs = glob([ + "include/llvm/Target/*.h", + "include/llvm/Target/*.def", + "include/llvm/Target/*.inc", + ]), + deps = [ + ":analysis", + ":config", + ":core", + ":mc", + ":support", + ], +) + +cc_library( + name = "transform_utils", + srcs = glob([ + "lib/Transforms/Utils/*.c", + "lib/Transforms/Utils/*.cpp", + "lib/Transforms/Utils/*.inc", + "include/llvm/Transforms/IPO.h", + "include/llvm/Transforms/Scalar.h", + "lib/Transforms/Utils/*.h", + ]), + hdrs = glob([ + "include/llvm/Transforms/Utils/*.h", + "include/llvm/Transforms/Utils/*.def", + "include/llvm/Transforms/Utils/*.inc", + ]), + deps = [ + ":analysis", + ":config", + ":core", + ":support", + ], +) + +cc_library( + name = "vectorize", + srcs = glob([ + "lib/Transforms/Vectorize/*.c", + "lib/Transforms/Vectorize/*.cpp", + "lib/Transforms/Vectorize/*.inc", + "include/llvm-c/Transforms/Vectorize.h", + "lib/Transforms/Vectorize/*.h", + ]), + hdrs = glob([ + "include/llvm/Transforms/Vectorize/*.h", + "include/llvm/Transforms/Vectorize/*.def", + "include/llvm/Transforms/Vectorize/*.inc", + "include/llvm/Transforms/Vectorize.h", + ]), + deps = [ + ":analysis", + ":config", + ":core", + ":support", + ":transform_utils", + ], +) + +cc_library( + name = "x86_asm_parser", + srcs = glob([ + "lib/Target/X86/AsmParser/*.c", + "lib/Target/X86/AsmParser/*.cpp", + "lib/Target/X86/AsmParser/*.inc", + ]), + hdrs = glob([ + "include/llvm/Target/X86/AsmParser/*.h", + "include/llvm/Target/X86/AsmParser/*.def", + "include/llvm/Target/X86/AsmParser/*.inc", + "lib/Target/X86/AsmParser/*.h", + ]), + copts = ["-Iexternal/llvm/lib/Target/X86"], + deps = [ + ":config", + ":mc", + ":mc_parser", + ":support", + ":x86_desc", + ":x86_info", + ], +) + +cc_library( + name = "x86_asm_printer", + srcs = glob([ + "lib/Target/X86/InstPrinter/*.c", + "lib/Target/X86/InstPrinter/*.cpp", + "lib/Target/X86/InstPrinter/*.inc", + ]), + hdrs = glob([ + "include/llvm/Target/X86/InstPrinter/*.h", + "include/llvm/Target/X86/InstPrinter/*.def", + "include/llvm/Target/X86/InstPrinter/*.inc", + "lib/Target/X86/InstPrinter/*.h", + ]), + copts = ["-Iexternal/llvm/lib/Target/X86"], + deps = [ + ":config", + ":mc", + ":support", + ":x86_info", + ":x86_target_gen", + ":x86_utils", + ], +) + +cc_library( + name = "x86_code_gen", + srcs = glob([ + "lib/Target/X86/*.c", + "lib/Target/X86/*.cpp", + "lib/Target/X86/*.inc", + ]), + hdrs = glob([ + "include/llvm/Target/X86/*.h", + "include/llvm/Target/X86/*.def", + "include/llvm/Target/X86/*.inc", + "lib/Target/X86/*.h", + ]), + copts = ["-Iexternal/llvm/lib/Target/X86"], + deps = [ + ":analysis", + ":asm_printer", + ":code_gen", + ":config", + ":core", + ":global_i_sel", + ":mc", + ":selection_dag", + ":support", + ":target", + ":x86_asm_printer", + ":x86_desc", + ":x86_info", + ":x86_utils", + ], +) + +cc_library( + name = "x86_desc", + srcs = glob([ + "lib/Target/X86/MCTargetDesc/*.c", + "lib/Target/X86/MCTargetDesc/*.cpp", + "lib/Target/X86/MCTargetDesc/*.inc", + ]), + hdrs = glob([ + "include/llvm/Target/X86/MCTargetDesc/*.h", + "include/llvm/Target/X86/MCTargetDesc/*.def", + "include/llvm/Target/X86/MCTargetDesc/*.inc", + "lib/Target/X86/MCTargetDesc/*.h", + ]), + copts = ["-Iexternal/llvm/lib/Target/X86"], + deps = [ + ":config", + ":mc", + ":mc_disassembler", + ":object", + ":support", + ":x86_asm_printer", + ":x86_info", + ], +) + +cc_library( + name = "x86_disassembler", + srcs = glob([ + "lib/Target/X86/Disassembler/*.c", + "lib/Target/X86/Disassembler/*.cpp", + "lib/Target/X86/Disassembler/*.inc", + ]), + hdrs = glob([ + "include/llvm/Target/X86/Disassembler/*.h", + "include/llvm/Target/X86/Disassembler/*.def", + "include/llvm/Target/X86/Disassembler/*.inc", + "lib/Target/X86/Disassembler/*.h", + ]), + copts = ["-Iexternal/llvm/lib/Target/X86"], + deps = [ + ":config", + ":mc_disassembler", + ":support", + ":x86_info", + ], +) + +cc_library( + name = "x86_info", + srcs = glob([ + "lib/Target/X86/TargetInfo/*.c", + "lib/Target/X86/TargetInfo/*.cpp", + "lib/Target/X86/TargetInfo/*.inc", + "lib/Target/X86/MCTargetDesc/*.h", + ]), + hdrs = glob([ + "include/llvm/Target/X86/TargetInfo/*.h", + "include/llvm/Target/X86/TargetInfo/*.def", + "include/llvm/Target/X86/TargetInfo/*.inc", + "lib/Target/X86/TargetInfo/*.h", + ]), + copts = ["-Iexternal/llvm/lib/Target/X86"], + deps = [ + ":config", + ":mc", + ":support", + ":x86_target_gen", + ], +) + +cc_library( + name = "x86_utils", + srcs = glob([ + "lib/Target/X86/Utils/*.c", + "lib/Target/X86/Utils/*.cpp", + "lib/Target/X86/Utils/*.inc", + ]), + hdrs = glob([ + "include/llvm/Target/X86/Utils/*.h", + "include/llvm/Target/X86/Utils/*.def", + "include/llvm/Target/X86/Utils/*.inc", + "lib/Target/X86/Utils/*.h", + ]), + copts = ["-Iexternal/llvm/lib/Target/X86"], + deps = [ + ":code_gen", + ":config", + ":core", + ":support", + ], +) + diff --git a/third_party/llvm/llvm.bzl b/third_party/llvm/llvm.bzl new file mode 100644 index 0000000000000000000000000000000000000000..1d6bf1c7065a7c4734c9723b9c9e8b1c1439a737 --- /dev/null +++ b/third_party/llvm/llvm.bzl @@ -0,0 +1,149 @@ +"""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, **kwargs): + """gentbl() generates tabular code from a table definition file. + + Args: + name: The name of the build rule for use in dependencies. + tblgen: The binary used to produce the output. + td_file: The primary table definitions file. + td_srcs: A list of table definition files included transitively. + tbl_outs: A list of tuples (opts, out), where each opts is a string of + options passed to tblgen, and the out is the corresponding output file + produced. + library: Whether to bundle the generated files into a library. + **kwargs: Keyword arguments to pass to subsidiary cc_library() rule. + """ + if td_file not in td_srcs: + td_srcs += [td_file] + includes = [] + for (opts, out) in tbl_outs: + outdir = out[:out.rindex("/")] + if outdir not in includes: + includes.append(outdir) + rule_suffix = "_".join(opts.replace("-", "_").replace("=", "_").split(" ")) + native.genrule( + name="%s_%s_genrule" % (name, rule_suffix), + srcs=td_srcs, + outs=[out], + tools=[tblgen], + message="Generating code from table: %s" % td_file, + cmd=(("$(location %s) " + "-I external/llvm/include " + + "-I external/llvm/tools/clang/include " + + "-I $$(dirname $(location %s)) " + "%s $(location %s) -o $@") % ( + tblgen, td_file, opts, td_file))) + # For now, all generated files can be assumed to comprise public interfaces. + # If this is not true, you should specify library = False + # and list the generated '.inc' files in "srcs". + if library: + native.cc_library(name=name, textual_hdrs=[f for (_, f) in tbl_outs], + includes=includes, **kwargs) + + +# 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/expand_header_template", "expand_header_template") +# expand_header_template( +# name = "ExpandMyTemplate", +# template = "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 expand_header_template_impl(ctx): + ctx.template_action( + template = ctx.file.template, + output = ctx.outputs.out, + substitutions = ctx.attr.substitutions, + ) + +expand_header_template = rule( + implementation = expand_header_template_impl, + attrs = { + "template": attr.label(mandatory=True, allow_files=True, 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, +) + + +def llvm_target_cmake_vars(native_arch, target_triple): + return { + "LLVM_HOST_TRIPLE": target_triple, + "LLVM_DEFAULT_TARGET_TRIPLE": target_triple, + "LLVM_NATIVE_ARCH": native_arch, + } + +def _quote(s): + """Quotes the given string for use in a shell command. + + This function double-quotes the given string (in case it contains spaces or + other special characters) and escapes any special characters (dollar signs, + double-quotes, and backslashes) that may be present. + + Args: + s: The string to quote. + Returns: + An escaped and quoted version of the string that can be passed to a shell + command. + """ + return ('"' + + s.replace("\\", "\\\\").replace("$", "\\$").replace('"', '\\"') + + '"') + +def cmake_var_string(cmake_vars): + """Converts a dictionary to an input suitable for expand_cmake_vars. + + Ideally we would jist stringify in the expand_cmake_vars() rule, but select() + interacts badly with genrules. + + TODO(phawkins): replace the genrule() with native rule and delete this rule. + + Args: + cmake_vars: a dictionary with string keys and values that are convertable to + strings. + """ + return " ".join([_quote("{}={}".format(k, str(v))) + for (k, v) in cmake_vars.items()]) + +def expand_cmake_vars(name, src, dst, cmake_vars): + """Expands #cmakedefine, #cmakedefine01, and CMake variables in a text file. + + Args: + name: the name of the rule + src: the input of the rule + dst: the output of the rule + cmake_vars: a string containing the CMake variables, as generated by + cmake_var_string. + """ + expand_cmake_vars_tool = "@//third_party/llvm:expand_cmake_vars" + native.genrule( + name = name, + srcs = [src], + tools = [expand_cmake_vars_tool], + outs = [dst], + cmd = ("$(location {}) ".format(expand_cmake_vars_tool) + cmake_vars + + "< $< > $@") + ) +