xref: /freebsd/lib/libcompiler_rt/Makefile.inc (revision f276adc148433d009d198c2ebccdd3303377e237)
14c983a28SDimitry Andric.include <bsd.compiler.mk>
2040b3049SEd Maste
3cb14a3feSDimitry AndricCRTARCH=	${MACHINE_CPUARCH:C/amd64/x86_64/:C/powerpc/ppc/}
4040b3049SEd Maste
50b57cec5SDimitry AndricCRTSRC=		${SRCTOP}/contrib/llvm-project/compiler-rt/lib/builtins
6040b3049SEd Maste
7040b3049SEd Maste.PATH:		${CRTSRC}/${CRTARCH}
8040b3049SEd Maste.PATH:		${CRTSRC}
9040b3049SEd Maste
10040b3049SEd MasteSRCF+=		absvdi2
11040b3049SEd MasteSRCF+=		absvsi2
12040b3049SEd MasteSRCF+=		absvti2
13040b3049SEd MasteSRCF+=		addvdi3
14040b3049SEd MasteSRCF+=		addvsi3
15040b3049SEd MasteSRCF+=		addvti3
16040b3049SEd MasteSRCF+=		apple_versioning
17040b3049SEd MasteSRCF+=		ashldi3
18040b3049SEd MasteSRCF+=		ashlti3
19040b3049SEd MasteSRCF+=		ashrdi3
20040b3049SEd MasteSRCF+=		ashrti3
2146c8c554SDimitry AndricSRCF+=		bswapdi2
2246c8c554SDimitry AndricSRCF+=		bswapsi2
23040b3049SEd MasteSRCF+=		clear_cache
24040b3049SEd MasteSRCF+=		clzdi2
25040b3049SEd MasteSRCF+=		clzsi2
26040b3049SEd MasteSRCF+=		clzti2
27040b3049SEd MasteSRCF+=		cmpdi2
28040b3049SEd MasteSRCF+=		cmpti2
29040b3049SEd MasteSRCF+=		ctzdi2
30040b3049SEd MasteSRCF+=		ctzsi2
31040b3049SEd MasteSRCF+=		ctzti2
32040b3049SEd MasteSRCF+=		divdc3
33040b3049SEd MasteSRCF+=		divdi3
34040b3049SEd MasteSRCF+=		divmoddi4
35040b3049SEd MasteSRCF+=		divmodsi4
366e75b2fbSDimitry AndricSRCF+=		divmodti4
37040b3049SEd MasteSRCF+=		divsc3
3804a91333SJohn BaldwinSRCF+=		divsi3
39040b3049SEd MasteSRCF+=		divti3
40040b3049SEd MasteSRCF+=		enable_execute_stack
41040b3049SEd MasteSRCF+=		extendhfsf2
42040b3049SEd MasteSRCF+=		ffsdi2
43289fa303SDimitry AndricSRCF+=		ffssi2
44040b3049SEd MasteSRCF+=		ffsti2
45040b3049SEd MasteSRCF+=		fixdfdi
46040b3049SEd MasteSRCF+=		fixdfti
47040b3049SEd MasteSRCF+=		fixsfdi
48040b3049SEd MasteSRCF+=		fixsfti
49040b3049SEd MasteSRCF+=		fixunsdfdi
50040b3049SEd MasteSRCF+=		fixunsdfsi
51040b3049SEd MasteSRCF+=		fixunsdfti
52040b3049SEd MasteSRCF+=		fixunssfdi
53040b3049SEd MasteSRCF+=		fixunssfsi
54040b3049SEd MasteSRCF+=		fixunssfti
55040b3049SEd MasteSRCF+=		floattidf
56040b3049SEd MasteSRCF+=		floattisf
57040b3049SEd MasteSRCF+=		floatunsidf
58040b3049SEd MasteSRCF+=		floatunsisf
59040b3049SEd MasteSRCF+=		floatuntidf
60040b3049SEd MasteSRCF+=		floatuntisf
61040b3049SEd MasteSRCF+=		int_util
62040b3049SEd MasteSRCF+=		lshrdi3
63040b3049SEd MasteSRCF+=		lshrti3
64040b3049SEd MasteSRCF+=		moddi3
6504a91333SJohn BaldwinSRCF+=		modsi3
66040b3049SEd MasteSRCF+=		modti3
67040b3049SEd MasteSRCF+=		muldc3
68040b3049SEd MasteSRCF+=		muldi3
69040b3049SEd MasteSRCF+=		mulodi4
70040b3049SEd MasteSRCF+=		mulosi4
71040b3049SEd MasteSRCF+=		muloti4
72040b3049SEd MasteSRCF+=		mulsc3
73040b3049SEd MasteSRCF+=		multi3
74040b3049SEd MasteSRCF+=		mulvdi3
75040b3049SEd MasteSRCF+=		mulvsi3
76040b3049SEd MasteSRCF+=		mulvti3
77040b3049SEd MasteSRCF+=		negdf2
78040b3049SEd MasteSRCF+=		negdi2
79040b3049SEd MasteSRCF+=		negsf2
80040b3049SEd MasteSRCF+=		negti2
81040b3049SEd MasteSRCF+=		negvdi2
82040b3049SEd MasteSRCF+=		negvsi2
83040b3049SEd MasteSRCF+=		negvti2
84040b3049SEd MasteSRCF+=		paritydi2
85040b3049SEd MasteSRCF+=		paritysi2
86040b3049SEd MasteSRCF+=		parityti2
87040b3049SEd MasteSRCF+=		popcountdi2
88040b3049SEd MasteSRCF+=		popcountsi2
89040b3049SEd MasteSRCF+=		popcountti2
90040b3049SEd MasteSRCF+=		powidf2
91040b3049SEd MasteSRCF+=		powisf2
92040b3049SEd MasteSRCF+=		subvdi3
93040b3049SEd MasteSRCF+=		subvsi3
94040b3049SEd MasteSRCF+=		subvti3
95040b3049SEd MasteSRCF+=		trampoline_setup
96040b3049SEd MasteSRCF+=		truncdfhf2
97040b3049SEd MasteSRCF+=		truncsfhf2
98040b3049SEd MasteSRCF+=		ucmpdi2
99040b3049SEd MasteSRCF+=		ucmpti2
100040b3049SEd MasteSRCF+=		udivdi3
101040b3049SEd MasteSRCF+=		udivmoddi4
102040b3049SEd MasteSRCF+=		udivmodsi4
103040b3049SEd MasteSRCF+=		udivmodti4
10404a91333SJohn BaldwinSRCF+=		udivsi3
105040b3049SEd MasteSRCF+=		udivti3
106040b3049SEd MasteSRCF+=		umoddi3
10704a91333SJohn BaldwinSRCF+=		umodsi3
108040b3049SEd MasteSRCF+=		umodti3
109040b3049SEd Maste
110c90cb435SDimitry Andric# Enable compiler-rt's atomic implementation only for clang, as it uses clang
111c90cb435SDimitry Andric# specific builtins, and gcc packages usually come with their own libatomic.
11218ed63b8SDimitry Andric# Exclude arm which has its own implementations of atomic functions, below.
11318ed63b8SDimitry Andric.if "${COMPILER_TYPE}" == "clang" && ${MACHINE_CPUARCH} != "arm"
114c90cb435SDimitry AndricSRCF+=		atomic
115c90cb435SDimitry Andric.endif
116c90cb435SDimitry Andric
1172b12718bSDimitry Andric# Avoid using SSE2 instructions on i386, if unsupported.
1182b12718bSDimitry Andric.if ${MACHINE_CPUARCH} == "i386" && empty(MACHINE_CPU:Msse2)
119e1ca2b88SDimitry AndricSRCS+=		floatdidf.c
120e1ca2b88SDimitry AndricSRCS+=		floatdisf.c
121e1ca2b88SDimitry AndricSRCS+=		floatundidf.c
122e1ca2b88SDimitry AndricSRCS+=		floatundisf.c
123e1ca2b88SDimitry Andric.else
124e1ca2b88SDimitry AndricSRCF+=		floatdidf
125e1ca2b88SDimitry AndricSRCF+=		floatdisf
126e1ca2b88SDimitry AndricSRCF+=		floatundidf
127e1ca2b88SDimitry AndricSRCF+=		floatundisf
128cb14a3feSDimitry Andric.endif
129cb14a3feSDimitry Andric
130cb14a3feSDimitry Andric#
131cb14a3feSDimitry Andric# 80-bit long double functions, only used on x86.
132cb14a3feSDimitry Andric#
133cb14a3feSDimitry Andric.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
134cb14a3feSDimitry AndricSRCF+=		divxc3
135cb14a3feSDimitry AndricSRCF+=		extendxftf2
136cb14a3feSDimitry AndricSRCF+=		fixxfdi
137cb14a3feSDimitry AndricSRCF+=		fixxfti
138cb14a3feSDimitry AndricSRCF+=		fixunsxfdi
139cb14a3feSDimitry AndricSRCF+=		fixunsxfsi
140cb14a3feSDimitry AndricSRCF+=		fixunsxfti
141cb14a3feSDimitry AndricSRCF+=		floattixf
142cb14a3feSDimitry AndricSRCF+=		floatuntixf
143cb14a3feSDimitry AndricSRCF+=		mulxc3
144cb14a3feSDimitry AndricSRCF+=		powixf2
145cb14a3feSDimitry AndricSRCF+=		trunctfxf2
146cb14a3feSDimitry Andric
147cb14a3feSDimitry Andric# Avoid using SSE2 instructions on i386, if unsupported.
148cb14a3feSDimitry Andric.if ${MACHINE_CPUARCH} == "i386" && empty(MACHINE_CPU:Msse2)
149cb14a3feSDimitry AndricSRCS+=		floatdixf.c
150cb14a3feSDimitry AndricSRCS+=		floatundixf.c
151cb14a3feSDimitry Andric.else
152cb14a3feSDimitry AndricSRCF+=		floatdixf
153e1ca2b88SDimitry AndricSRCF+=		floatundixf
154e1ca2b88SDimitry Andric.endif
155cb14a3feSDimitry Andric.endif
156e1ca2b88SDimitry Andric
157efe67f33SDimitry Andric# __cpu_model support, only used on aarch64 and x86
158cb14a3feSDimitry Andric.if ${MACHINE_CPUARCH} == "aarch64"
159cb14a3feSDimitry AndricSRCS+=		cpu_model/aarch64.c
160cb14a3feSDimitry Andric.elif ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
161cb14a3feSDimitry AndricSRCS+=		cpu_model/x86.c
162335bcabeSEd Maste.endif
163335bcabeSEd Maste
164a92579cfSDimitry Andric# The fp_mode implementation for amd64 and i386 is shared, while other
165a92579cfSDimitry Andric# architectures use the regular approach.
166a92579cfSDimitry Andric.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
167a92579cfSDimitry AndricSRCS+=		i386/fp_mode.c
168a92579cfSDimitry Andric.else
169a92579cfSDimitry AndricSRCF+=		fp_mode
170a92579cfSDimitry Andric.endif
171a92579cfSDimitry Andric
1722ad1d09fSRuslan Bukin#
1732ad1d09fSRuslan Bukin# 128-bit quad precision long double support,
1747804dd52SRuslan Bukin# only used on some architectures.
1752ad1d09fSRuslan Bukin#
1765f757f3fSDimitry Andric.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \
1775f757f3fSDimitry Andric    ${MACHINE_CPUARCH} == "riscv"
178040b3049SEd MasteSRCF+=		addtf3
179040b3049SEd MasteSRCF+=		comparetf2
180cb14a3feSDimitry AndricSRCF+=		divtc3
181040b3049SEd MasteSRCF+=		divtf3
182040b3049SEd MasteSRCF+=		extenddftf2
1836e75b2fbSDimitry AndricSRCF+=		extendhftf2
184040b3049SEd MasteSRCF+=		extendsftf2
185040b3049SEd MasteSRCF+=		fixtfdi
186040b3049SEd MasteSRCF+=		fixtfsi
187040b3049SEd MasteSRCF+=		fixtfti
188040b3049SEd MasteSRCF+=		fixunstfdi
189040b3049SEd MasteSRCF+=		fixunstfsi
190040b3049SEd MasteSRCF+=		fixunstfti
191cb14a3feSDimitry AndricSRCF+=		floatditf
19291baa744SDimitry AndricSRCF+=		floatsitf
19391baa744SDimitry AndricSRCF+=		floattitf
194cb14a3feSDimitry AndricSRCF+=		floatunditf
195040b3049SEd MasteSRCF+=		floatunsitf
19691baa744SDimitry AndricSRCF+=		floatuntitf
197cb14a3feSDimitry AndricSRCF+=		multc3
198040b3049SEd MasteSRCF+=		multf3
199cb14a3feSDimitry AndricSRCF+=		powitf2
200040b3049SEd MasteSRCF+=		subtf3
201040b3049SEd MasteSRCF+=		trunctfdf2
2026e75b2fbSDimitry AndricSRCF+=		trunctfhf2
203040b3049SEd MasteSRCF+=		trunctfsf2
204040b3049SEd Maste.endif
205040b3049SEd Maste
2067804dd52SRuslan Bukin# These are already shipped by libc.a on some architectures.
2071ab9996fSJohn Baldwin.if ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "riscv"
208040b3049SEd MasteSRCF+=		adddf3
209040b3049SEd MasteSRCF+=		addsf3
210040b3049SEd MasteSRCF+=		divdf3
211040b3049SEd MasteSRCF+=		divsf3
212040b3049SEd MasteSRCF+=		extendsfdf2
213040b3049SEd MasteSRCF+=		fixdfsi
214040b3049SEd MasteSRCF+=		fixsfsi
215040b3049SEd MasteSRCF+=		floatsidf
216040b3049SEd MasteSRCF+=		floatsisf
217040b3049SEd MasteSRCF+=		muldf3
218040b3049SEd MasteSRCF+=		mulsf3
219040b3049SEd MasteSRCF+=		subdf3
220040b3049SEd MasteSRCF+=		subsf3
221040b3049SEd MasteSRCF+=		truncdfsf2
222040b3049SEd Maste.endif
223040b3049SEd Maste
2241ab9996fSJohn Baldwin.if ${MACHINE_CPUARCH} != "arm"
225040b3049SEd MasteSRCF+=		comparedf2
226040b3049SEd MasteSRCF+=		comparesf2
227040b3049SEd Maste.endif
228040b3049SEd Maste
229*f276adc1SDimitry Andric# Helper to reduce complexity of _Float16 and __bf16 statements below.
230*f276adc1SDimitry Andric.if ${MACHINE_CPUARCH} == "aarch64" || \
231*f276adc1SDimitry Andric    ${MACHINE_CPUARCH} == "amd64" || \
232*f276adc1SDimitry Andric    ${MACHINE_CPUARCH} == "arm" || \
233*f276adc1SDimitry Andric    (${MACHINE_CPUARCH} == "i386" && !empty(MACHINE_CPU:Msse2))
234*f276adc1SDimitry AndricCRT_COMMON_F16_ARCH=t
235*f276adc1SDimitry Andric.endif
236*f276adc1SDimitry Andric
2375f757f3fSDimitry Andric#
238*f276adc1SDimitry Andric# _Float16 support, only on some architectures, and with certain compiler
239*f276adc1SDimitry Andric# versions.
2405f757f3fSDimitry Andric#
241*f276adc1SDimitry Andric.if ((${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 150000) && \
242*f276adc1SDimitry Andric     (defined(CRT_COMMON_F16_ARCH) || ${MACHINE_CPUARCH} == "riscv")) || \
243*f276adc1SDimitry Andric    ((${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 120000) && \
244*f276adc1SDimitry Andric     (defined(CRT_COMMON_F16_ARCH)))
245*f276adc1SDimitry AndricCFLAGS+=	-DCOMPILER_RT_HAS_FLOAT16
246*f276adc1SDimitry Andric.endif
247*f276adc1SDimitry Andric
248*f276adc1SDimitry Andric#
249*f276adc1SDimitry Andric# __bf16 support, only on some architectures, and with certain compiler
250*f276adc1SDimitry Andric# versions.
251*f276adc1SDimitry Andric#
252*f276adc1SDimitry Andric.if ((${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 150000) && \
253*f276adc1SDimitry Andric     (defined(CRT_COMMON_F16_ARCH))) || \
254*f276adc1SDimitry Andric    ((${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 180000) && \
255*f276adc1SDimitry Andric     ${MACHINE_CPUARCH} == "riscv") || \
256*f276adc1SDimitry Andric    ((${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 130000) && \
257*f276adc1SDimitry Andric     (defined(CRT_COMMON_F16_ARCH)))
258*f276adc1SDimitry AndricCFLAGS+=	-DCOMPILER_RT_HAS_BFLOAT16
2595f757f3fSDimitry AndricSRCF+=		truncdfbf2
2605f757f3fSDimitry AndricSRCF+=		truncsfbf2
2615f757f3fSDimitry Andric.endif
2625f757f3fSDimitry Andric
263040b3049SEd Maste# FreeBSD-specific atomic intrinsics.
264b53a8df3SWarner Losh.if ${MACHINE_CPUARCH} == "arm"
265040b3049SEd Maste.PATH:		${SRCTOP}/sys/arm/arm
266040b3049SEd Maste
267040b3049SEd MasteSRCF+=		stdatomic
268040b3049SEd MasteCFLAGS+=	-DEMIT_SYNC_ATOMICS
269040b3049SEd Maste.endif
270040b3049SEd Maste
271040b3049SEd Maste.for file in ${SRCF}
272ae902a5bSWarner Losh.if ${MACHINE_CPUARCH} == "arm" && (!defined(CPUTYPE) || ${CPUTYPE:M*soft*} == "") \
273040b3049SEd Maste    && exists(${CRTSRC}/${CRTARCH}/${file}vfp.S)
274040b3049SEd MasteSRCS+=		${file}vfp.S
275040b3049SEd Maste. elif exists(${CRTSRC}/${CRTARCH}/${file}.S)
276040b3049SEd MasteSRCS+=		${file}.S
277040b3049SEd Maste. else
278040b3049SEd MasteSRCS+=		${file}.c
279040b3049SEd Maste. endif
280040b3049SEd Maste.endfor
281040b3049SEd Maste
282040b3049SEd Maste.if ${MACHINE_CPUARCH} == "arm"
283040b3049SEd MasteSRCS+=		aeabi_div0.c
284040b3049SEd MasteSRCS+=		aeabi_idivmod.S
285040b3049SEd MasteSRCS+=		aeabi_ldivmod.S
286040b3049SEd MasteSRCS+=		aeabi_memcmp.S
287040b3049SEd MasteSRCS+=		aeabi_memcpy.S
288040b3049SEd MasteSRCS+=		aeabi_memmove.S
289040b3049SEd MasteSRCS+=		aeabi_memset.S
290040b3049SEd MasteSRCS+=		aeabi_uidivmod.S
291040b3049SEd MasteSRCS+=		aeabi_uldivmod.S
292040b3049SEd MasteSRCS+=		switch16.S
293040b3049SEd MasteSRCS+=		switch32.S
294040b3049SEd MasteSRCS+=		switch8.S
295040b3049SEd MasteSRCS+=		switchu8.S
296040b3049SEd MasteSRCS+=		sync_synchronize.S
297040b3049SEd Maste.endif
298