1set(files
2  adxintrin.h
3  altivec.h
4  ammintrin.h
5  amxintrin.h
6  arm_acle.h
7  arm_cmse.h
8  armintr.h
9  arm64intr.h
10  avx2intrin.h
11  avx512bf16intrin.h
12  avx512bwintrin.h
13  avx512bitalgintrin.h
14  avx512vlbitalgintrin.h
15  avx512cdintrin.h
16  avx512vpopcntdqintrin.h
17  avx512dqintrin.h
18  avx512erintrin.h
19  avx512fintrin.h
20  avx512ifmaintrin.h
21  avx512ifmavlintrin.h
22  avx512pfintrin.h
23  avx512vbmiintrin.h
24  avx512vbmivlintrin.h
25  avx512vbmi2intrin.h
26  avx512vlvbmi2intrin.h
27  avx512vlbf16intrin.h
28  avx512vlbwintrin.h
29  avx512vlcdintrin.h
30  avx512vldqintrin.h
31  avx512vlintrin.h
32  avx512vp2intersectintrin.h
33  avx512vlvp2intersectintrin.h
34  avx512vpopcntdqvlintrin.h
35  avx512vnniintrin.h
36  avx512vlvnniintrin.h
37  avxintrin.h
38  avxvnniintrin.h
39  bmi2intrin.h
40  bmiintrin.h
41  __clang_cuda_builtin_vars.h
42  __clang_cuda_math.h
43  __clang_cuda_cmath.h
44  __clang_cuda_complex_builtins.h
45  __clang_cuda_device_functions.h
46  __clang_cuda_intrinsics.h
47  __clang_cuda_libdevice_declares.h
48  __clang_cuda_math_forward_declares.h
49  __clang_cuda_runtime_wrapper.h
50  __clang_hip_libdevice_declares.h
51  __clang_hip_cmath.h
52  __clang_hip_math.h
53  __clang_hip_runtime_wrapper.h
54  cetintrin.h
55  cet.h
56  cldemoteintrin.h
57  clzerointrin.h
58  cpuid.h
59  clflushoptintrin.h
60  clwbintrin.h
61  emmintrin.h
62  enqcmdintrin.h
63  f16cintrin.h
64  float.h
65  fma4intrin.h
66  fmaintrin.h
67  fxsrintrin.h
68  gfniintrin.h
69  hresetintrin.h
70  htmintrin.h
71  htmxlintrin.h
72  ia32intrin.h
73  immintrin.h
74  intrin.h
75  inttypes.h
76  invpcidintrin.h
77  iso646.h
78  keylockerintrin.h
79  limits.h
80  lwpintrin.h
81  lzcntintrin.h
82  mm3dnow.h
83  mmintrin.h
84  mm_malloc.h
85  module.modulemap
86  movdirintrin.h
87  msa.h
88  mwaitxintrin.h
89  nmmintrin.h
90  opencl-c.h
91  opencl-c-base.h
92  pkuintrin.h
93  pmmintrin.h
94  pconfigintrin.h
95  popcntintrin.h
96  prfchwintrin.h
97  ptwriteintrin.h
98  rdseedintrin.h
99  rtmintrin.h
100  serializeintrin.h
101  sgxintrin.h
102  s390intrin.h
103  shaintrin.h
104  smmintrin.h
105  stdalign.h
106  stdarg.h
107  stdatomic.h
108  stdbool.h
109  stddef.h
110  __stddef_max_align_t.h
111  stdint.h
112  stdnoreturn.h
113  tbmintrin.h
114  tgmath.h
115  tmmintrin.h
116  tsxldtrkintrin.h
117  uintrintrin.h
118  unwind.h
119  vadefs.h
120  vaesintrin.h
121  varargs.h
122  vecintrin.h
123  vpclmulqdqintrin.h
124  waitpkgintrin.h
125  wasm_simd128.h
126  wbnoinvdintrin.h
127  wmmintrin.h
128  __wmmintrin_aes.h
129  __wmmintrin_pclmul.h
130  x86gprintrin.h
131  x86intrin.h
132  xmmintrin.h
133  xopintrin.h
134  xsavecintrin.h
135  xsaveintrin.h
136  xsaveoptintrin.h
137  xsavesintrin.h
138  xtestintrin.h
139  )
140
141set(cuda_wrapper_files
142  cuda_wrappers/algorithm
143  cuda_wrappers/complex
144  cuda_wrappers/new
145)
146
147set(ppc_wrapper_files
148  ppc_wrappers/mmintrin.h
149  ppc_wrappers/xmmintrin.h
150  ppc_wrappers/mm_malloc.h
151  ppc_wrappers/emmintrin.h
152  ppc_wrappers/pmmintrin.h
153  ppc_wrappers/tmmintrin.h
154  ppc_wrappers/smmintrin.h
155)
156
157set(openmp_wrapper_files
158  openmp_wrappers/math.h
159  openmp_wrappers/cmath
160  openmp_wrappers/complex.h
161  openmp_wrappers/complex
162  openmp_wrappers/__clang_openmp_device_functions.h
163  openmp_wrappers/complex_cmath.h
164  openmp_wrappers/new
165)
166
167set(output_dir ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/include)
168set(out_files)
169set(generated_files)
170
171function(copy_header_to_output_dir src_dir file)
172  set(src ${src_dir}/${file})
173  set(dst ${output_dir}/${file})
174  add_custom_command(OUTPUT ${dst}
175    DEPENDS ${src}
176    COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
177    COMMENT "Copying clang's ${file}...")
178  list(APPEND out_files ${dst})
179  set(out_files ${out_files} PARENT_SCOPE)
180endfunction(copy_header_to_output_dir)
181
182function(clang_generate_header td_option td_file out_file)
183  clang_tablegen(${out_file} ${td_option}
184  -I ${CLANG_SOURCE_DIR}/include/clang/Basic/
185  SOURCE ${CLANG_SOURCE_DIR}/include/clang/Basic/${td_file})
186
187  copy_header_to_output_dir(${CMAKE_CURRENT_BINARY_DIR} ${out_file})
188  set(out_files ${out_files} PARENT_SCOPE)
189  list(APPEND generated_files "${CMAKE_CURRENT_BINARY_DIR}/${out_file}")
190  set(generated_files ${generated_files} PARENT_SCOPE)
191endfunction(clang_generate_header)
192
193
194# Copy header files from the source directory to the build directory
195foreach( f ${files} ${cuda_wrapper_files} ${ppc_wrapper_files} ${openmp_wrapper_files})
196  copy_header_to_output_dir(${CMAKE_CURRENT_SOURCE_DIR} ${f})
197endforeach( f )
198
199# Generate header files and copy them to the build directory
200# Generate arm_neon.h
201clang_generate_header(-gen-arm-neon arm_neon.td arm_neon.h)
202# Generate arm_fp16.h
203clang_generate_header(-gen-arm-fp16 arm_fp16.td arm_fp16.h)
204# Generate arm_sve.h
205clang_generate_header(-gen-arm-sve-header arm_sve.td arm_sve.h)
206# Generate arm_bf16.h
207clang_generate_header(-gen-arm-bf16 arm_bf16.td arm_bf16.h)
208# Generate arm_mve.h
209clang_generate_header(-gen-arm-mve-header arm_mve.td arm_mve.h)
210# Generate arm_cde.h
211clang_generate_header(-gen-arm-cde-header arm_cde.td arm_cde.h)
212
213add_custom_target(clang-resource-headers ALL DEPENDS ${out_files})
214set_target_properties(clang-resource-headers PROPERTIES
215  FOLDER "Misc"
216  RUNTIME_OUTPUT_DIRECTORY "${output_dir}")
217
218set(header_install_dir lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include)
219
220install(
221  FILES ${files} ${generated_files}
222  DESTINATION ${header_install_dir}
223  COMPONENT clang-resource-headers)
224
225install(
226  FILES ${cuda_wrapper_files}
227  DESTINATION ${header_install_dir}/cuda_wrappers
228  COMPONENT clang-resource-headers)
229
230install(
231  FILES ${ppc_wrapper_files}
232  DESTINATION ${header_install_dir}/ppc_wrappers
233  COMPONENT clang-resource-headers)
234
235install(
236  FILES ${openmp_wrapper_files}
237  DESTINATION ${header_install_dir}/openmp_wrappers
238  COMPONENT clang-resource-headers)
239
240if (NOT LLVM_ENABLE_IDE)
241  add_llvm_install_targets(install-clang-resource-headers
242                           DEPENDS clang-resource-headers
243                           COMPONENT clang-resource-headers)
244endif()
245