xref: /freebsd/lib/libcompiler_rt/Makefile.inc (revision 5036d9652a5701d00e9e40ea942c278e9f77d33d)
1.include <bsd.compiler.mk>
2
3CRTARCH=	${MACHINE_CPUARCH:C/amd64/x86_64/:C/powerpc/ppc/}
4
5CRTSRC=		${SRCTOP}/contrib/llvm-project/compiler-rt/lib/builtins
6
7.PATH:		${CRTSRC}/${CRTARCH}
8.PATH:		${CRTSRC}
9
10SRCF+=		absvdi2
11SRCF+=		absvsi2
12SRCF+=		absvti2
13SRCF+=		addvdi3
14SRCF+=		addvsi3
15SRCF+=		addvti3
16SRCF+=		apple_versioning
17SRCF+=		ashldi3
18SRCF+=		ashlti3
19SRCF+=		ashrdi3
20SRCF+=		ashrti3
21SRCF+=		bswapdi2
22SRCF+=		bswapsi2
23SRCF+=		clear_cache
24SRCF+=		clzdi2
25SRCF+=		clzsi2
26SRCF+=		clzti2
27SRCF+=		cmpdi2
28SRCF+=		cmpti2
29SRCF+=		ctzdi2
30SRCF+=		ctzsi2
31SRCF+=		ctzti2
32SRCF+=		divdc3
33SRCF+=		divdi3
34SRCF+=		divmoddi4
35SRCF+=		divmodsi4
36SRCF+=		divmodti4
37SRCF+=		divsc3
38SRCF+=		divsi3
39SRCF+=		divti3
40SRCF+=		enable_execute_stack
41SRCF+=		extendhfsf2
42SRCF+=		ffsdi2
43SRCF+=		ffssi2
44SRCF+=		ffsti2
45SRCF+=		fixdfdi
46SRCF+=		fixdfti
47SRCF+=		fixsfdi
48SRCF+=		fixsfti
49SRCF+=		fixunsdfdi
50SRCF+=		fixunsdfsi
51SRCF+=		fixunsdfti
52SRCF+=		fixunssfdi
53SRCF+=		fixunssfsi
54SRCF+=		fixunssfti
55SRCF+=		floattidf
56SRCF+=		floattisf
57SRCF+=		floatunsidf
58SRCF+=		floatunsisf
59SRCF+=		floatuntidf
60SRCF+=		floatuntisf
61SRCF+=		int_util
62SRCF+=		lshrdi3
63SRCF+=		lshrti3
64SRCF+=		moddi3
65SRCF+=		modsi3
66SRCF+=		modti3
67SRCF+=		muldc3
68SRCF+=		muldi3
69SRCF+=		mulodi4
70SRCF+=		mulosi4
71SRCF+=		muloti4
72SRCF+=		mulsc3
73SRCF+=		multi3
74SRCF+=		mulvdi3
75SRCF+=		mulvsi3
76SRCF+=		mulvti3
77SRCF+=		negdf2
78SRCF+=		negdi2
79SRCF+=		negsf2
80SRCF+=		negti2
81SRCF+=		negvdi2
82SRCF+=		negvsi2
83SRCF+=		negvti2
84SRCF+=		paritydi2
85SRCF+=		paritysi2
86SRCF+=		parityti2
87SRCF+=		popcountdi2
88SRCF+=		popcountsi2
89SRCF+=		popcountti2
90SRCF+=		powidf2
91SRCF+=		powisf2
92SRCF+=		subvdi3
93SRCF+=		subvsi3
94SRCF+=		subvti3
95SRCF+=		trampoline_setup
96SRCF+=		truncdfhf2
97SRCF+=		truncsfhf2
98SRCF+=		ucmpdi2
99SRCF+=		ucmpti2
100SRCF+=		udivdi3
101SRCF+=		udivmoddi4
102SRCF+=		udivmodsi4
103SRCF+=		udivmodti4
104SRCF+=		udivsi3
105SRCF+=		udivti3
106SRCF+=		umoddi3
107SRCF+=		umodsi3
108SRCF+=		umodti3
109
110# Enable compiler-rt's atomic implementation only for clang, as it uses clang
111# specific builtins, and gcc packages usually come with their own libatomic.
112# Exclude arm which has its own implementations of atomic functions, below.
113.if "${COMPILER_TYPE}" == "clang" && ${MACHINE_CPUARCH} != "arm"
114SRCF+=		atomic
115.endif
116
117# Avoid using SSE2 instructions on i386, if unsupported.
118.if ${MACHINE_CPUARCH} == "i386" && empty(MACHINE_CPU:Msse2)
119SRCS+=		floatdidf.c
120SRCS+=		floatdisf.c
121SRCS+=		floatundidf.c
122SRCS+=		floatundisf.c
123.else
124SRCF+=		floatdidf
125SRCF+=		floatdisf
126SRCF+=		floatundidf
127SRCF+=		floatundisf
128.endif
129
130#
131# 80-bit long double functions, only used on x86.
132#
133.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
134SRCF+=		divxc3
135SRCF+=		fixxfdi
136SRCF+=		fixxfti
137SRCF+=		fixunsxfdi
138SRCF+=		fixunsxfsi
139SRCF+=		fixunsxfti
140SRCF+=		floattixf
141SRCF+=		floatuntixf
142SRCF+=		mulxc3
143SRCF+=		powixf2
144
145# Avoid using SSE2 instructions on i386, if unsupported.
146.if ${MACHINE_CPUARCH} == "i386" && empty(MACHINE_CPU:Msse2)
147SRCS+=		floatdixf.c
148SRCS+=		floatundixf.c
149.else
150SRCF+=		floatdixf
151SRCF+=		floatundixf
152.endif
153.endif
154
155# 128-bit float is an amd64 feature
156.if ${MACHINE_CPUARCH} == "amd64"
157SRCF+=		extendxftf2
158SRCF+=		trunctfxf2
159.endif
160
161# __cpu_model support, only used on aarch64 and x86
162.if ${MACHINE_CPUARCH} == "aarch64"
163SRCS+=		cpu_model/aarch64.c
164.elif ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
165SRCS+=		cpu_model/x86.c
166.endif
167
168# The fp_mode implementation for amd64 and i386 is shared, while other
169# architectures use the regular approach.
170.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
171SRCS+=		i386/fp_mode.c
172.else
173SRCF+=		fp_mode
174.endif
175
176#
177# 128-bit quad precision long double support,
178# only used on some architectures.
179#
180.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \
181    ${MACHINE_CPUARCH} == "riscv"
182SRCF+=		addtf3
183SRCF+=		comparetf2
184SRCF+=		divtc3
185SRCF+=		divtf3
186SRCF+=		extenddftf2
187SRCF+=		extendhftf2
188SRCF+=		extendsftf2
189SRCF+=		fixtfdi
190SRCF+=		fixtfsi
191SRCF+=		fixtfti
192SRCF+=		fixunstfdi
193SRCF+=		fixunstfsi
194SRCF+=		fixunstfti
195SRCF+=		floatditf
196SRCF+=		floatsitf
197SRCF+=		floattitf
198SRCF+=		floatunditf
199SRCF+=		floatunsitf
200SRCF+=		floatuntitf
201SRCF+=		multc3
202SRCF+=		multf3
203SRCF+=		powitf2
204SRCF+=		subtf3
205SRCF+=		trunctfdf2
206SRCF+=		trunctfhf2
207SRCF+=		trunctfsf2
208.endif
209
210# These are already shipped by libc.a on some architectures.
211.if ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "riscv"
212SRCF+=		adddf3
213SRCF+=		addsf3
214SRCF+=		divdf3
215SRCF+=		divsf3
216SRCF+=		extendsfdf2
217SRCF+=		fixdfsi
218SRCF+=		fixsfsi
219SRCF+=		floatsidf
220SRCF+=		floatsisf
221SRCF+=		muldf3
222SRCF+=		mulsf3
223SRCF+=		subdf3
224SRCF+=		subsf3
225SRCF+=		truncdfsf2
226.endif
227
228.if ${MACHINE_CPUARCH} != "arm"
229SRCF+=		comparedf2
230SRCF+=		comparesf2
231.endif
232
233# Helper to reduce complexity of _Float16 and __bf16 statements below.
234.if ${MACHINE_CPUARCH} == "aarch64" || \
235    ${MACHINE_CPUARCH} == "amd64" || \
236    (${MACHINE_CPUARCH} == "i386" && !empty(MACHINE_CPU:Msse2))
237CRT_COMMON_F16_ARCH=t
238.endif
239
240#
241# _Float16 support, only on some architectures, and with certain compiler
242# versions.
243#
244.if ((${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 150000) && \
245     (defined(CRT_COMMON_F16_ARCH) || \
246      ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "riscv")) || \
247    ((${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 120000) && \
248     (defined(CRT_COMMON_F16_ARCH)))
249CFLAGS+=	-DCOMPILER_RT_HAS_FLOAT16
250.endif
251
252#
253# __bf16 support, only on some architectures, and with certain compiler
254# versions.
255#
256.if ((${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 150000) && \
257     (defined(CRT_COMMON_F16_ARCH))) || \
258    ((${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 180000) && \
259     ${MACHINE_CPUARCH} == "riscv") || \
260    ((${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 130000) && \
261     (defined(CRT_COMMON_F16_ARCH)))
262CFLAGS+=	-DCOMPILER_RT_HAS_BFLOAT16
263SRCF+=		extendbfsf2
264SRCF+=		truncdfbf2
265SRCF+=		truncsfbf2
266.endif
267
268# FreeBSD-specific atomic intrinsics.
269.if ${MACHINE_CPUARCH} == "arm"
270.PATH:		${SRCTOP}/sys/arm/arm
271
272SRCF+=		stdatomic
273CFLAGS+=	-DEMIT_SYNC_ATOMICS
274.endif
275
276.for file in ${SRCF}
277.if ${MACHINE_CPUARCH} == "arm" && (!defined(CPUTYPE) || ${CPUTYPE:M*soft*} == "") \
278    && exists(${CRTSRC}/${CRTARCH}/${file}vfp.S)
279SRCS+=		${file}vfp.S
280. elif exists(${CRTSRC}/${CRTARCH}/${file}.S)
281SRCS+=		${file}.S
282. else
283SRCS+=		${file}.c
284. endif
285.endfor
286
287.if ${MACHINE_CPUARCH} == "arm"
288SRCS+=		aeabi_div0.c
289SRCS+=		aeabi_idivmod.S
290SRCS+=		aeabi_ldivmod.S
291SRCS+=		aeabi_memcmp.S
292SRCS+=		aeabi_memcpy.S
293SRCS+=		aeabi_memmove.S
294SRCS+=		aeabi_memset.S
295SRCS+=		aeabi_uidivmod.S
296SRCS+=		aeabi_uldivmod.S
297SRCS+=		switch16.S
298SRCS+=		switch32.S
299SRCS+=		switch8.S
300SRCS+=		switchu8.S
301SRCS+=		sync_synchronize.S
302.endif
303