xref: /freebsd/lib/libcompiler_rt/Makefile.inc (revision e1c4c8dd8d2d10b6104f06856a77bd5b4813a801)
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+=		extendxftf2
136SRCF+=		fixxfdi
137SRCF+=		fixxfti
138SRCF+=		fixunsxfdi
139SRCF+=		fixunsxfsi
140SRCF+=		fixunsxfti
141SRCF+=		floattixf
142SRCF+=		floatuntixf
143SRCF+=		mulxc3
144SRCF+=		powixf2
145SRCF+=		trunctfxf2
146
147# Avoid using SSE2 instructions on i386, if unsupported.
148.if ${MACHINE_CPUARCH} == "i386" && empty(MACHINE_CPU:Msse2)
149SRCS+=		floatdixf.c
150SRCS+=		floatundixf.c
151.else
152SRCF+=		floatdixf
153SRCF+=		floatundixf
154.endif
155.endif
156
157# __cpu_model support, only used on aarch64 and x86
158.if ${MACHINE_CPUARCH} == "aarch64"
159SRCS+=		cpu_model/aarch64.c
160.elif ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
161SRCS+=		cpu_model/x86.c
162.endif
163
164# The fp_mode implementation for amd64 and i386 is shared, while other
165# architectures use the regular approach.
166.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
167SRCS+=		i386/fp_mode.c
168.else
169SRCF+=		fp_mode
170.endif
171
172#
173# 128-bit quad precision long double support,
174# only used on some architectures.
175#
176.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \
177    ${MACHINE_CPUARCH} == "riscv"
178SRCF+=		addtf3
179SRCF+=		comparetf2
180SRCF+=		divtc3
181SRCF+=		divtf3
182SRCF+=		extenddftf2
183SRCF+=		extendhftf2
184SRCF+=		extendsftf2
185SRCF+=		fixtfdi
186SRCF+=		fixtfsi
187SRCF+=		fixtfti
188SRCF+=		fixunstfdi
189SRCF+=		fixunstfsi
190SRCF+=		fixunstfti
191SRCF+=		floatditf
192SRCF+=		floatsitf
193SRCF+=		floattitf
194SRCF+=		floatunditf
195SRCF+=		floatunsitf
196SRCF+=		floatuntitf
197SRCF+=		multc3
198SRCF+=		multf3
199SRCF+=		powitf2
200SRCF+=		subtf3
201SRCF+=		trunctfdf2
202SRCF+=		trunctfhf2
203SRCF+=		trunctfsf2
204.endif
205
206# These are already shipped by libc.a on some architectures.
207.if ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "riscv"
208SRCF+=		adddf3
209SRCF+=		addsf3
210SRCF+=		divdf3
211SRCF+=		divsf3
212SRCF+=		extendsfdf2
213SRCF+=		fixdfsi
214SRCF+=		fixsfsi
215SRCF+=		floatsidf
216SRCF+=		floatsisf
217SRCF+=		muldf3
218SRCF+=		mulsf3
219SRCF+=		subdf3
220SRCF+=		subsf3
221SRCF+=		truncdfsf2
222.endif
223
224.if ${MACHINE_CPUARCH} != "arm"
225SRCF+=		comparedf2
226SRCF+=		comparesf2
227.endif
228
229#
230# bfloat16 support, only used on some architectures.
231#
232.if (${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \
233     ${MACHINE_CPUARCH} == "arm" || (${MACHINE_CPUARCH} == "i386" && \
234     !empty(MACHINE_CPU:Msse2)) || ${MACHINE_CPUARCH} == "riscv") && \
235    !(${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} < 130000)
236SRCF+=		truncdfbf2
237SRCF+=		truncsfbf2
238.endif
239
240# FreeBSD-specific atomic intrinsics.
241.if ${MACHINE_CPUARCH} == "arm"
242.PATH:		${SRCTOP}/sys/arm/arm
243
244SRCF+=		stdatomic
245CFLAGS+=	-DEMIT_SYNC_ATOMICS
246.endif
247
248.for file in ${SRCF}
249.if ${MACHINE_CPUARCH} == "arm" && (!defined(CPUTYPE) || ${CPUTYPE:M*soft*} == "") \
250    && exists(${CRTSRC}/${CRTARCH}/${file}vfp.S)
251SRCS+=		${file}vfp.S
252. elif exists(${CRTSRC}/${CRTARCH}/${file}.S)
253SRCS+=		${file}.S
254. else
255SRCS+=		${file}.c
256. endif
257.endfor
258
259.if ${MACHINE_CPUARCH} == "arm"
260SRCS+=		aeabi_div0.c
261SRCS+=		aeabi_idivmod.S
262SRCS+=		aeabi_ldivmod.S
263SRCS+=		aeabi_memcmp.S
264SRCS+=		aeabi_memcpy.S
265SRCS+=		aeabi_memmove.S
266SRCS+=		aeabi_memset.S
267SRCS+=		aeabi_uidivmod.S
268SRCS+=		aeabi_uldivmod.S
269SRCS+=		switch16.S
270SRCS+=		switch32.S
271SRCS+=		switch8.S
272SRCS+=		switchu8.S
273SRCS+=		sync_synchronize.S
274.endif
275