Skip to content

Commit 3fe69ba

Browse files
authored
Improve llvm-config.h to record which target is configured or not (#71164)
These macro can help guarding some tests and other section of code which rely on detecting if a particular target is available. This is common the MLIR codegeneration for GPU targets for example.
1 parent af59938 commit 3fe69ba

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed

llvm/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,8 @@ foreach(t ${LLVM_TARGETS_TO_BUILD})
955955
endif()
956956
else()
957957
set(LLVM_ENUM_TARGETS "${LLVM_ENUM_TARGETS}LLVM_TARGET(${t})\n")
958+
string(TOUPPER ${t} T_UPPER)
959+
set(LLVM_HAS_${T_UPPER}_TARGET 1)
958960
endif()
959961

960962
file(GLOB asmp_file "${td}/*AsmPrinter.cpp")

llvm/include/llvm/Config/llvm-config.h.cmake

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,81 @@
5454
/* LLVM name for the native target MCA init function, if available */
5555
#cmakedefine LLVM_NATIVE_TARGETMCA LLVMInitialize${LLVM_NATIVE_ARCH}TargetMCA
5656

57+
/* Define if the AArch64 target is built in */
58+
#cmakedefine01 LLVM_HAS_AARCH64_TARGET
59+
60+
/* Define if the AMDGPU target is built in */
61+
#cmakedefine01 LLVM_HAS_AMDGPU_TARGET
62+
63+
/* Define if the ARC target is built in */
64+
#cmakedefine01 LLVM_HAS_ARC_TARGET
65+
66+
/* Define if the ARM target is built in */
67+
#cmakedefine01 LLVM_HAS_ARM_TARGET
68+
69+
/* Define if the AVR target is built in */
70+
#cmakedefine01 LLVM_HAS_AVR_TARGET
71+
72+
/* Define if the BPF target is built in */
73+
#cmakedefine01 LLVM_HAS_BPF_TARGET
74+
75+
/* Define if the CSKY target is built in */
76+
#cmakedefine01 LLVM_HAS_CSKY_TARGET
77+
78+
/* Define if the DirectX target is built in */
79+
#cmakedefine01 LLVM_HAS_DIRECTX_TARGET
80+
81+
/* Define if the Hexagon target is built in */
82+
#cmakedefine01 LLVM_HAS_HEXAGON_TARGET
83+
84+
/* Define if the Lanai target is built in */
85+
#cmakedefine01 LLVM_HAS_LANAI_TARGET
86+
87+
/* Define if the LoongArch target is built in */
88+
#cmakedefine01 LLVM_HAS_LOONGARCH_TARGET
89+
90+
/* Define if the M68k target is built in */
91+
#cmakedefine01 LLVM_HAS_M68K_TARGET
92+
93+
/* Define if the Mips target is built in */
94+
#cmakedefine01 LLVM_HAS_MIPS_TARGET
95+
96+
/* Define if the MSP430 target is built in */
97+
#cmakedefine01 LLVM_HAS_MSP430_TARGET
98+
99+
/* Define if the NVPTX target is built in */
100+
#cmakedefine01 LLVM_HAS_NVPTX_TARGET
101+
102+
/* Define if the PowerPC target is built in */
103+
#cmakedefine01 LLVM_HAS_POWERPC_TARGET
104+
105+
/* Define if the RISCV target is built in */
106+
#cmakedefine01 LLVM_HAS_RISCV_TARGET
107+
108+
/* Define if the Sparc target is built in */
109+
#cmakedefine01 LLVM_HAS_SPARC_TARGET
110+
111+
/* Define if the SPIRV target is built in */
112+
#cmakedefine01 LLVM_HAS_SPIRV_TARGET
113+
114+
/* Define if the SystemZ target is built in */
115+
#cmakedefine01 LLVM_HAS_SYSTEMZ_TARGET
116+
117+
/* Define if the VE target is built in */
118+
#cmakedefine01 LLVM_HAS_VE_TARGET
119+
120+
/* Define if the WebAssembly target is built in */
121+
#cmakedefine01 LLVM_HAS_WEBASSEMBLY_TARGET
122+
123+
/* Define if the X86 target is built in */
124+
#cmakedefine01 LLVM_HAS_X86_TARGET
125+
126+
/* Define if the XCore target is built in */
127+
#cmakedefine01 LLVM_HAS_XCORE_TARGET
128+
129+
/* Define if the Xtensa target is built in */
130+
#cmakedefine01 LLVM_HAS_XTENSA_TARGET
131+
57132
/* Define if this is Unixish platform */
58133
#cmakedefine LLVM_ON_UNIX ${LLVM_ON_UNIX}
59134

0 commit comments

Comments
 (0)