blob: 1d02e11085241741f83bacadaceab00277106a1a [file] [log] [blame]
Alexey Samsonova6b264b2014-02-14 09:20:33 +00001# This directory contains a large amount of C code which provides
2# generic implementations of the core runtime library along with optimized
3# architecture-specific code in various subdirectories.
4
5set(GENERIC_SOURCES
6 absvdi2.c
7 absvsi2.c
8 absvti2.c
9 adddf3.c
10 addsf3.c
Joerg Sonnenberger361519f2014-06-19 20:24:49 +000011 addtf3.c
Alexey Samsonova6b264b2014-02-14 09:20:33 +000012 addvdi3.c
13 addvsi3.c
14 addvti3.c
15 apple_versioning.c
16 ashldi3.c
17 ashlti3.c
18 ashrdi3.c
19 ashrti3.c
20 # FIXME: atomic.c may only be compiled if host compiler understands _Atomic
21 # atomic.c
22 clear_cache.c
23 clzdi2.c
24 clzsi2.c
25 clzti2.c
26 cmpdi2.c
27 cmpti2.c
28 comparedf2.c
29 comparesf2.c
30 ctzdi2.c
31 ctzsi2.c
32 ctzti2.c
33 divdc3.c
34 divdf3.c
35 divdi3.c
36 divmoddi4.c
37 divmodsi4.c
38 divsc3.c
39 divsf3.c
40 divsi3.c
41 divti3.c
Joerg Sonnenberger361519f2014-06-19 20:24:49 +000042 divtf3.c
Alexey Samsonova6b264b2014-02-14 09:20:33 +000043 divxc3.c
44 enable_execute_stack.c
45 eprintf.c
46 extendsfdf2.c
Ahmed Bougachaf1ac8502015-05-12 18:33:42 +000047 extendhfsf2.c
Alexey Samsonova6b264b2014-02-14 09:20:33 +000048 ffsdi2.c
49 ffsti2.c
50 fixdfdi.c
51 fixdfsi.c
52 fixdfti.c
53 fixsfdi.c
54 fixsfsi.c
55 fixsfti.c
56 fixunsdfdi.c
57 fixunsdfsi.c
58 fixunsdfti.c
59 fixunssfdi.c
60 fixunssfsi.c
61 fixunssfti.c
62 fixunsxfdi.c
63 fixunsxfsi.c
64 fixunsxfti.c
65 fixxfdi.c
66 fixxfti.c
67 floatdidf.c
68 floatdisf.c
69 floatdixf.c
70 floatsidf.c
71 floatsisf.c
72 floattidf.c
73 floattisf.c
74 floattixf.c
75 floatundidf.c
76 floatundisf.c
77 floatundixf.c
78 floatunsidf.c
79 floatunsisf.c
80 floatuntidf.c
81 floatuntisf.c
82 floatuntixf.c
Alexey Samsonova6b264b2014-02-14 09:20:33 +000083 int_util.c
84 lshrdi3.c
85 lshrti3.c
86 moddi3.c
87 modsi3.c
88 modti3.c
89 muldc3.c
90 muldf3.c
91 muldi3.c
92 mulodi4.c
93 mulosi4.c
94 muloti4.c
95 mulsc3.c
96 mulsf3.c
97 multi3.c
Joerg Sonnenberger61d5d382014-06-19 20:34:03 +000098 multf3.c
Alexey Samsonova6b264b2014-02-14 09:20:33 +000099 mulvdi3.c
100 mulvsi3.c
101 mulvti3.c
102 mulxc3.c
103 negdf2.c
104 negdi2.c
105 negsf2.c
106 negti2.c
107 negvdi2.c
108 negvsi2.c
109 negvti2.c
110 paritydi2.c
111 paritysi2.c
112 parityti2.c
113 popcountdi2.c
114 popcountsi2.c
115 popcountti2.c
116 powidf2.c
117 powisf2.c
118 powitf2.c
119 powixf2.c
120 subdf3.c
121 subsf3.c
122 subvdi3.c
123 subvsi3.c
124 subvti3.c
Joerg Sonnenberger361519f2014-06-19 20:24:49 +0000125 subtf3.c
Alexey Samsonova6b264b2014-02-14 09:20:33 +0000126 trampoline_setup.c
Ahmed Bougachaf1ac8502015-05-12 18:33:42 +0000127 truncdfhf2.c
Alexey Samsonova6b264b2014-02-14 09:20:33 +0000128 truncdfsf2.c
Ahmed Bougachaf1ac8502015-05-12 18:33:42 +0000129 truncsfhf2.c
Alexey Samsonova6b264b2014-02-14 09:20:33 +0000130 ucmpdi2.c
131 ucmpti2.c
132 udivdi3.c
133 udivmoddi4.c
134 udivmodsi4.c
135 udivmodti4.c
136 udivsi3.c
137 udivti3.c
138 umoddi3.c
139 umodsi3.c
140 umodti3.c)
141
Chih-Hung Hsieh4814b9c2015-08-31 17:14:07 +0000142if(NOT WIN32)
143 set(GENERIC_SOURCES
144 ${GENERIC_SOURCES}
145 emutls.c)
146endif()
147
Saleem Abdulrasoola7452e42015-01-14 15:55:17 +0000148if (HAVE_UNWIND_H)
149 set(GENERIC_SOURCES
150 ${GENERIC_SOURCES}
151 gcc_personality_v0.c)
152endif ()
153
Alexey Samsonova6b264b2014-02-14 09:20:33 +0000154set(x86_64_SOURCES
155 x86_64/floatdidf.c
156 x86_64/floatdisf.c
157 x86_64/floatdixf.c
158 x86_64/floatundidf.S
159 x86_64/floatundisf.S
160 x86_64/floatundixf.S
161 ${GENERIC_SOURCES})
Chris Bienemanb38affa2015-08-31 21:24:50 +0000162set(x86_64h_SOURCES ${x86_64_SOURCES})
Alexey Samsonova6b264b2014-02-14 09:20:33 +0000163
Reid Klecknerfbfed862015-07-17 16:23:05 +0000164if(WIN32)
165 set(x86_64_SOURCES
166 ${x86_64_SOURCES}
167 x86_64/chkstk.S)
168endif()
169
Alexey Samsonova6b264b2014-02-14 09:20:33 +0000170set(i386_SOURCES
171 i386/ashldi3.S
172 i386/ashrdi3.S
173 i386/divdi3.S
174 i386/floatdidf.S
175 i386/floatdisf.S
176 i386/floatdixf.S
177 i386/floatundidf.S
178 i386/floatundisf.S
179 i386/floatundixf.S
180 i386/lshrdi3.S
181 i386/moddi3.S
182 i386/muldi3.S
183 i386/udivdi3.S
184 i386/umoddi3.S
185 ${GENERIC_SOURCES})
186
Reid Klecknerfbfed862015-07-17 16:23:05 +0000187if(WIN32)
188 set(i386_SOURCES
189 ${i386_SOURCES}
190 i386/chkstk.S)
191endif()
192
Evgeniy Stepanov0f7ab592014-10-01 12:55:06 +0000193set(i686_SOURCES
194 ${i386_SOURCES})
195
Alexey Samsonova6b264b2014-02-14 09:20:33 +0000196set(arm_SOURCES
197 arm/adddf3vfp.S
198 arm/addsf3vfp.S
Josh Gao1108ae02015-08-21 00:25:37 +0000199 arm/aeabi_cdcmp.S
200 arm/aeabi_cdcmpeq_check_nan.c
201 arm/aeabi_cfcmp.S
202 arm/aeabi_cfcmpeq_check_nan.c
Alexey Samsonova6b264b2014-02-14 09:20:33 +0000203 arm/aeabi_dcmp.S
Saleem Abdulrasoola0a58732014-09-06 21:34:02 +0000204 arm/aeabi_div0.c
Dan Albertb5226572015-08-18 18:10:33 +0000205 arm/aeabi_drsub.c
Alexey Samsonova6b264b2014-02-14 09:20:33 +0000206 arm/aeabi_fcmp.S
Dan Albertb5226572015-08-18 18:10:33 +0000207 arm/aeabi_frsub.c
Alexey Samsonova6b264b2014-02-14 09:20:33 +0000208 arm/aeabi_idivmod.S
209 arm/aeabi_ldivmod.S
210 arm/aeabi_memcmp.S
211 arm/aeabi_memcpy.S
212 arm/aeabi_memmove.S
213 arm/aeabi_memset.S
214 arm/aeabi_uidivmod.S
215 arm/aeabi_uldivmod.S
216 arm/bswapdi2.S
217 arm/bswapsi2.S
218 arm/comparesf2.S
219 arm/divdf3vfp.S
220 arm/divmodsi4.S
221 arm/divsf3vfp.S
222 arm/divsi3.S
223 arm/eqdf2vfp.S
224 arm/eqsf2vfp.S
225 arm/extendsfdf2vfp.S
226 arm/fixdfsivfp.S
227 arm/fixsfsivfp.S
228 arm/fixunsdfsivfp.S
229 arm/fixunssfsivfp.S
230 arm/floatsidfvfp.S
231 arm/floatsisfvfp.S
232 arm/floatunssidfvfp.S
233 arm/floatunssisfvfp.S
234 arm/gedf2vfp.S
235 arm/gesf2vfp.S
236 arm/gtdf2vfp.S
237 arm/gtsf2vfp.S
238 arm/ledf2vfp.S
239 arm/lesf2vfp.S
240 arm/ltdf2vfp.S
241 arm/ltsf2vfp.S
242 arm/modsi3.S
243 arm/muldf3vfp.S
244 arm/mulsf3vfp.S
245 arm/nedf2vfp.S
246 arm/negdf2vfp.S
247 arm/negsf2vfp.S
248 arm/nesf2vfp.S
249 arm/restore_vfp_d8_d15_regs.S
250 arm/save_vfp_d8_d15_regs.S
251 arm/subdf3vfp.S
252 arm/subsf3vfp.S
253 arm/switch16.S
254 arm/switch32.S
255 arm/switch8.S
256 arm/switchu8.S
Tim Northover1683caa2014-03-04 10:10:17 +0000257 arm/sync_fetch_and_add_4.S
258 arm/sync_fetch_and_add_8.S
259 arm/sync_fetch_and_and_4.S
260 arm/sync_fetch_and_and_8.S
261 arm/sync_fetch_and_max_4.S
262 arm/sync_fetch_and_max_8.S
263 arm/sync_fetch_and_min_4.S
264 arm/sync_fetch_and_min_8.S
265 arm/sync_fetch_and_nand_4.S
266 arm/sync_fetch_and_nand_8.S
267 arm/sync_fetch_and_or_4.S
268 arm/sync_fetch_and_or_8.S
269 arm/sync_fetch_and_sub_4.S
270 arm/sync_fetch_and_sub_8.S
271 arm/sync_fetch_and_umax_4.S
272 arm/sync_fetch_and_umax_8.S
273 arm/sync_fetch_and_umin_4.S
274 arm/sync_fetch_and_umin_8.S
275 arm/sync_fetch_and_xor_4.S
276 arm/sync_fetch_and_xor_8.S
Alexey Samsonova6b264b2014-02-14 09:20:33 +0000277 arm/sync_synchronize.S
278 arm/truncdfsf2vfp.S
279 arm/udivmodsi4.S
280 arm/udivsi3.S
281 arm/umodsi3.S
282 arm/unorddf2vfp.S
283 arm/unordsf2vfp.S
284 ${GENERIC_SOURCES})
285
Sergey Dmitroukd5a00e82015-08-18 13:43:37 +0000286set(aarch64_SOURCES
287 comparetf2.c
288 extenddftf2.c
289 extendsftf2.c
290 fixtfdi.c
291 fixtfsi.c
292 fixtfti.c
293 fixunstfdi.c
294 fixunstfsi.c
295 fixunstfti.c
296 floatditf.c
297 floatsitf.c
298 floatunditf.c
299 floatunsitf.c
300 multc3.c
301 trunctfdf2.c
302 trunctfsf2.c
303 ${GENERIC_SOURCES})
304
Chris Bienemanb38affa2015-08-31 21:24:50 +0000305set(armv7_SOURCES ${arm_SOURCES})
306set(armv7s_SOURCES ${arm_SOURCES})
307set(arm64_SOURCES ${aarch64_SOURCES})
308
Alexey Samsonov63a4af72014-02-18 09:33:45 +0000309add_custom_target(builtins)
310
Chris Bienemanb38affa2015-08-31 21:24:50 +0000311if (APPLE)
312 foreach (os osx)
313 list_union(DARWIN_BUILTIN_ARCHS DARWIN_${os}_ARCHS BUILTIN_SUPPORTED_ARCH)
314 set(${os}_builtin_libs)
315 set(${os}_builtin_lipo_flags)
316 foreach (arch ${DARWIN_BUILTIN_ARCHS})
317 # Filter out generic versions of routines that are re-implemented in
318 # architecture specific manner. This prevents multiple definitions of the
319 # same symbols, making the symbol selection non-deterministic.
320 foreach (_file ${${arch}_SOURCES})
321 if (${_file} MATCHES ${arch}/*)
322 get_filename_component(_name ${_file} NAME)
323 string(REPLACE ".S" ".c" _cname "${_name}")
324 list(REMOVE_ITEM ${arch}_SOURCES ${_cname})
325 endif ()
326 endforeach ()
Chris Bienemand1602602015-08-25 19:53:09 +0000327
Chris Bienemanb38affa2015-08-31 21:24:50 +0000328 add_compiler_rt_runtime(clang_rt.builtins_${arch} STATIC
329 OS ${os}
330 ARCHS ${arch}
331 SOURCES ${${arch}_SOURCES}
332 CFLAGS "-std=c99" ${DARWIN_${os}_CFLAGS} -arch ${arch}
333 PARENT_TARGET builtins)
334 list(APPEND ${os}_builtin_libs clang_rt.builtins_${arch}_${os})
335 list(APPEND ${os}_builtin_lipo_flags -arch ${arch}
336 ${COMPILER_RT_LIBRARY_OUTPUT_DIR}/libclang_rt.builtins_${arch}_${os}.a)
337 endforeach()
338
339 if(${os}_builtin_libs)
340 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/clang_rt.builtins_${os}.a
341 COMMAND lipo -output
342 ${COMPILER_RT_LIBRARY_OUTPUT_DIR}/clang_rt.builtins_${os}.a
343 -create ${${os}_builtin_lipo_flags}
344 DEPENDS ${${os}_builtin_libs}
345 )
346 add_custom_target(clang_rt.builtins_${os}
347 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/clang_rt.builtins_${os}.a)
348 add_dependencies(builtins clang_rt.builtins_${os})
349 endif()
350 endforeach()
351elseif (NOT WIN32 OR MINGW)
352 foreach (arch ${BUILTIN_SUPPORTED_ARCH})
Saleem Abdulrasoolb72a2fd2014-07-26 23:44:22 +0000353 if (CAN_TARGET_${arch})
354 # Filter out generic versions of routines that are re-implemented in
355 # architecture specific manner. This prevents multiple definitions of the
356 # same symbols, making the symbol selection non-deterministic.
357 foreach (_file ${${arch}_SOURCES})
358 if (${_file} MATCHES ${arch}/*)
359 get_filename_component(_name ${_file} NAME)
360 string(REPLACE ".S" ".c" _cname "${_name}")
361 list(REMOVE_ITEM ${arch}_SOURCES ${_cname})
362 endif ()
363 endforeach ()
364
Chris Bienemand1602602015-08-25 19:53:09 +0000365 add_compiler_rt_runtime(clang_rt.builtins
366 STATIC
Chris Bienemanb38affa2015-08-31 21:24:50 +0000367 ARCHS ${arch}
Saleem Abdulrasoolb72a2fd2014-07-26 23:44:22 +0000368 SOURCES ${${arch}_SOURCES}
Chris Bienemand1602602015-08-25 19:53:09 +0000369 CFLAGS "-std=c99"
370 PARENT_TARGET builtins)
Saleem Abdulrasoolb72a2fd2014-07-26 23:44:22 +0000371 endif ()
372 endforeach ()
373endif ()
Alexey Samsonov63a4af72014-02-18 09:33:45 +0000374
375add_dependencies(compiler-rt builtins)