Skip to content

Config: Move LLVM_HAS_*_TARGET definitions to a new header. #136388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion llvm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1163,13 +1163,16 @@ if (NOT TENSORFLOW_AOT_PATH STREQUAL "")

endif()

# Configure the three LLVM configuration header files.
# Configure the LLVM configuration header files.
configure_file(
${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/config.h.cmake
${LLVM_INCLUDE_DIR}/llvm/Config/config.h)
configure_file(
${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/llvm-config.h.cmake
${LLVM_INCLUDE_DIR}/llvm/Config/llvm-config.h)
configure_file(
${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/Targets.h.cmake
${LLVM_INCLUDE_DIR}/llvm/Config/Targets.h)
configure_file(
${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/abi-breaking.h.cmake
${LLVM_INCLUDE_DIR}/llvm/Config/abi-breaking.h)
Expand Down
90 changes: 90 additions & 0 deletions llvm/include/llvm/Config/Targets.h.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*===------- llvm/Config/Targets.h - LLVM target checks -----------*- 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 enables clients to know whether specific targets are enabled. */

#ifndef LLVM_CONFIG_TARGETS_H
#define LLVM_CONFIG_TARGETS_H

/* Define if the AArch64 target is built in */
#cmakedefine01 LLVM_HAS_AARCH64_TARGET

/* Define if the AMDGPU target is built in */
#cmakedefine01 LLVM_HAS_AMDGPU_TARGET

/* Define if the ARC target is built in */
#cmakedefine01 LLVM_HAS_ARC_TARGET

/* Define if the ARM target is built in */
#cmakedefine01 LLVM_HAS_ARM_TARGET

/* Define if the AVR target is built in */
#cmakedefine01 LLVM_HAS_AVR_TARGET

/* Define if the BPF target is built in */
#cmakedefine01 LLVM_HAS_BPF_TARGET

/* Define if the CSKY target is built in */
#cmakedefine01 LLVM_HAS_CSKY_TARGET

/* Define if the DirectX target is built in */
#cmakedefine01 LLVM_HAS_DIRECTX_TARGET

/* Define if the Hexagon target is built in */
#cmakedefine01 LLVM_HAS_HEXAGON_TARGET

/* Define if the Lanai target is built in */
#cmakedefine01 LLVM_HAS_LANAI_TARGET

/* Define if the LoongArch target is built in */
#cmakedefine01 LLVM_HAS_LOONGARCH_TARGET

/* Define if the M68k target is built in */
#cmakedefine01 LLVM_HAS_M68K_TARGET

/* Define if the Mips target is built in */
#cmakedefine01 LLVM_HAS_MIPS_TARGET

/* Define if the MSP430 target is built in */
#cmakedefine01 LLVM_HAS_MSP430_TARGET

/* Define if the NVPTX target is built in */
#cmakedefine01 LLVM_HAS_NVPTX_TARGET

/* Define if the PowerPC target is built in */
#cmakedefine01 LLVM_HAS_POWERPC_TARGET

/* Define if the RISCV target is built in */
#cmakedefine01 LLVM_HAS_RISCV_TARGET

/* Define if the Sparc target is built in */
#cmakedefine01 LLVM_HAS_SPARC_TARGET

/* Define if the SPIRV target is built in */
#cmakedefine01 LLVM_HAS_SPIRV_TARGET

/* Define if the SystemZ target is built in */
#cmakedefine01 LLVM_HAS_SYSTEMZ_TARGET

/* Define if the VE target is built in */
#cmakedefine01 LLVM_HAS_VE_TARGET

/* Define if the WebAssembly target is built in */
#cmakedefine01 LLVM_HAS_WEBASSEMBLY_TARGET

/* Define if the X86 target is built in */
#cmakedefine01 LLVM_HAS_X86_TARGET

/* Define if the XCore target is built in */
#cmakedefine01 LLVM_HAS_XCORE_TARGET

/* Define if the Xtensa target is built in */
#cmakedefine01 LLVM_HAS_XTENSA_TARGET

#endif
75 changes: 0 additions & 75 deletions llvm/include/llvm/Config/llvm-config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -54,81 +54,6 @@
/* LLVM name for the native target MCA init function, if available */
#cmakedefine LLVM_NATIVE_TARGETMCA LLVMInitialize${LLVM_NATIVE_ARCH}TargetMCA

/* Define if the AArch64 target is built in */
#cmakedefine01 LLVM_HAS_AARCH64_TARGET

/* Define if the AMDGPU target is built in */
#cmakedefine01 LLVM_HAS_AMDGPU_TARGET

/* Define if the ARC target is built in */
#cmakedefine01 LLVM_HAS_ARC_TARGET

/* Define if the ARM target is built in */
#cmakedefine01 LLVM_HAS_ARM_TARGET

/* Define if the AVR target is built in */
#cmakedefine01 LLVM_HAS_AVR_TARGET

/* Define if the BPF target is built in */
#cmakedefine01 LLVM_HAS_BPF_TARGET

/* Define if the CSKY target is built in */
#cmakedefine01 LLVM_HAS_CSKY_TARGET

/* Define if the DirectX target is built in */
#cmakedefine01 LLVM_HAS_DIRECTX_TARGET

/* Define if the Hexagon target is built in */
#cmakedefine01 LLVM_HAS_HEXAGON_TARGET

/* Define if the Lanai target is built in */
#cmakedefine01 LLVM_HAS_LANAI_TARGET

/* Define if the LoongArch target is built in */
#cmakedefine01 LLVM_HAS_LOONGARCH_TARGET

/* Define if the M68k target is built in */
#cmakedefine01 LLVM_HAS_M68K_TARGET

/* Define if the Mips target is built in */
#cmakedefine01 LLVM_HAS_MIPS_TARGET

/* Define if the MSP430 target is built in */
#cmakedefine01 LLVM_HAS_MSP430_TARGET

/* Define if the NVPTX target is built in */
#cmakedefine01 LLVM_HAS_NVPTX_TARGET

/* Define if the PowerPC target is built in */
#cmakedefine01 LLVM_HAS_POWERPC_TARGET

/* Define if the RISCV target is built in */
#cmakedefine01 LLVM_HAS_RISCV_TARGET

/* Define if the Sparc target is built in */
#cmakedefine01 LLVM_HAS_SPARC_TARGET

/* Define if the SPIRV target is built in */
#cmakedefine01 LLVM_HAS_SPIRV_TARGET

/* Define if the SystemZ target is built in */
#cmakedefine01 LLVM_HAS_SYSTEMZ_TARGET

/* Define if the VE target is built in */
#cmakedefine01 LLVM_HAS_VE_TARGET

/* Define if the WebAssembly target is built in */
#cmakedefine01 LLVM_HAS_WEBASSEMBLY_TARGET

/* Define if the X86 target is built in */
#cmakedefine01 LLVM_HAS_X86_TARGET

/* Define if the XCore target is built in */
#cmakedefine01 LLVM_HAS_XCORE_TARGET

/* Define if the Xtensa target is built in */
#cmakedefine01 LLVM_HAS_XTENSA_TARGET

/* Define if this is Unixish platform */
#cmakedefine LLVM_ON_UNIX ${LLVM_ON_UNIX}

Expand Down
11 changes: 10 additions & 1 deletion llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ write_cmake_config("abi-breaking") {
}

write_cmake_config("config") {
public_deps = [ ":llvm-config" ]
public_deps = [
":Targets",
":llvm-config",
]

input = "config.h.cmake"
output = "$target_gen_dir/config.h"
Expand Down Expand Up @@ -384,6 +387,12 @@ write_cmake_config("llvm-config") {
} else {
values += [ "LLVM_FORCE_ENABLE_STATS=" ]
}
}

write_cmake_config("Targets") {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nico @aeubanks Alternatively we could just remove this build target; nothing that GN is currently capable of building needs it.

input = "Targets.h.cmake"
output = "$target_gen_dir/Targets.h"
values = []

if (llvm_build_AArch64) {
values += [ "LLVM_HAS_AARCH64_TARGET=1" ]
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Target/LLVM/NVVM/Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "mlir/Target/LLVMIR/Export.h"

#include "llvm/ADT/ScopeExit.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/Config/Targets.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/FormatVariadic.h"
Expand Down
2 changes: 1 addition & 1 deletion mlir/unittests/Target/LLVM/SerializeNVVMTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "mlir/Target/LLVMIR/Dialect/NVVM/NVVMToLLVMIRTranslation.h"

#include "llvm/Bitcode/BitcodeWriter.h"
#include "llvm/Config/llvm-config.h" // for LLVM_HAS_NVPTX_TARGET
#include "llvm/Config/Targets.h" // for LLVM_HAS_NVPTX_TARGET
#include "llvm/IRReader/IRReader.h"
#include "llvm/Support/MemoryBufferRef.h"
#include "llvm/Support/Process.h"
Expand Down
Loading