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+= fixxfdi 136cb14a3feSDimitry AndricSRCF+= fixxfti 137cb14a3feSDimitry AndricSRCF+= fixunsxfdi 138cb14a3feSDimitry AndricSRCF+= fixunsxfsi 139cb14a3feSDimitry AndricSRCF+= fixunsxfti 140cb14a3feSDimitry AndricSRCF+= floattixf 141cb14a3feSDimitry AndricSRCF+= floatuntixf 142cb14a3feSDimitry AndricSRCF+= mulxc3 143cb14a3feSDimitry AndricSRCF+= powixf2 144cb14a3feSDimitry Andric 145cb14a3feSDimitry Andric# Avoid using SSE2 instructions on i386, if unsupported. 146cb14a3feSDimitry Andric.if ${MACHINE_CPUARCH} == "i386" && empty(MACHINE_CPU:Msse2) 147cb14a3feSDimitry AndricSRCS+= floatdixf.c 148cb14a3feSDimitry AndricSRCS+= floatundixf.c 149cb14a3feSDimitry Andric.else 150cb14a3feSDimitry AndricSRCF+= floatdixf 151e1ca2b88SDimitry AndricSRCF+= floatundixf 152e1ca2b88SDimitry Andric.endif 153cb14a3feSDimitry Andric.endif 154e1ca2b88SDimitry Andric 155723e60a2SBrooks Davis# 128-bit float is an amd64 feature 156723e60a2SBrooks Davis.if ${MACHINE_CPUARCH} == "amd64" 157723e60a2SBrooks DavisSRCF+= extendxftf2 158723e60a2SBrooks DavisSRCF+= trunctfxf2 159723e60a2SBrooks Davis.endif 160723e60a2SBrooks Davis 161efe67f33SDimitry Andric# __cpu_model support, only used on aarch64 and x86 162cb14a3feSDimitry Andric.if ${MACHINE_CPUARCH} == "aarch64" 163cb14a3feSDimitry AndricSRCS+= cpu_model/aarch64.c 164cb14a3feSDimitry Andric.elif ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" 165cb14a3feSDimitry AndricSRCS+= cpu_model/x86.c 166335bcabeSEd Maste.endif 167335bcabeSEd Maste 168a92579cfSDimitry Andric# The fp_mode implementation for amd64 and i386 is shared, while other 169a92579cfSDimitry Andric# architectures use the regular approach. 170a92579cfSDimitry Andric.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" 171a92579cfSDimitry AndricSRCS+= i386/fp_mode.c 172a92579cfSDimitry Andric.else 173a92579cfSDimitry AndricSRCF+= fp_mode 174a92579cfSDimitry Andric.endif 175a92579cfSDimitry Andric 1762ad1d09fSRuslan Bukin# 1772ad1d09fSRuslan Bukin# 128-bit quad precision long double support, 1787804dd52SRuslan Bukin# only used on some architectures. 1792ad1d09fSRuslan Bukin# 1805f757f3fSDimitry Andric.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \ 1815f757f3fSDimitry Andric ${MACHINE_CPUARCH} == "riscv" 182040b3049SEd MasteSRCF+= addtf3 183040b3049SEd MasteSRCF+= comparetf2 184cb14a3feSDimitry AndricSRCF+= divtc3 185040b3049SEd MasteSRCF+= divtf3 186040b3049SEd MasteSRCF+= extenddftf2 1876e75b2fbSDimitry AndricSRCF+= extendhftf2 188040b3049SEd MasteSRCF+= extendsftf2 189040b3049SEd MasteSRCF+= fixtfdi 190040b3049SEd MasteSRCF+= fixtfsi 191040b3049SEd MasteSRCF+= fixtfti 192040b3049SEd MasteSRCF+= fixunstfdi 193040b3049SEd MasteSRCF+= fixunstfsi 194040b3049SEd MasteSRCF+= fixunstfti 195cb14a3feSDimitry AndricSRCF+= floatditf 19691baa744SDimitry AndricSRCF+= floatsitf 19791baa744SDimitry AndricSRCF+= floattitf 198cb14a3feSDimitry AndricSRCF+= floatunditf 199040b3049SEd MasteSRCF+= floatunsitf 20091baa744SDimitry AndricSRCF+= floatuntitf 201cb14a3feSDimitry AndricSRCF+= multc3 202040b3049SEd MasteSRCF+= multf3 203cb14a3feSDimitry AndricSRCF+= powitf2 204040b3049SEd MasteSRCF+= subtf3 205040b3049SEd MasteSRCF+= trunctfdf2 2066e75b2fbSDimitry AndricSRCF+= trunctfhf2 207040b3049SEd MasteSRCF+= trunctfsf2 208040b3049SEd Maste.endif 209040b3049SEd Maste 2107804dd52SRuslan Bukin# These are already shipped by libc.a on some architectures. 2111ab9996fSJohn Baldwin.if ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "riscv" 212040b3049SEd MasteSRCF+= adddf3 213040b3049SEd MasteSRCF+= addsf3 214040b3049SEd MasteSRCF+= divdf3 215040b3049SEd MasteSRCF+= divsf3 216040b3049SEd MasteSRCF+= extendsfdf2 217040b3049SEd MasteSRCF+= fixdfsi 218040b3049SEd MasteSRCF+= fixsfsi 219040b3049SEd MasteSRCF+= floatsidf 220040b3049SEd MasteSRCF+= floatsisf 221040b3049SEd MasteSRCF+= muldf3 222040b3049SEd MasteSRCF+= mulsf3 223040b3049SEd MasteSRCF+= subdf3 224040b3049SEd MasteSRCF+= subsf3 225040b3049SEd MasteSRCF+= truncdfsf2 226040b3049SEd Maste.endif 227040b3049SEd Maste 2281ab9996fSJohn Baldwin.if ${MACHINE_CPUARCH} != "arm" 229040b3049SEd MasteSRCF+= comparedf2 230040b3049SEd MasteSRCF+= comparesf2 231040b3049SEd Maste.endif 232040b3049SEd Maste 233f276adc1SDimitry Andric# Helper to reduce complexity of _Float16 and __bf16 statements below. 234f276adc1SDimitry Andric.if ${MACHINE_CPUARCH} == "aarch64" || \ 235f276adc1SDimitry Andric ${MACHINE_CPUARCH} == "amd64" || \ 236f276adc1SDimitry Andric (${MACHINE_CPUARCH} == "i386" && !empty(MACHINE_CPU:Msse2)) 237f276adc1SDimitry AndricCRT_COMMON_F16_ARCH=t 238f276adc1SDimitry Andric.endif 239f276adc1SDimitry Andric 2405f757f3fSDimitry Andric# 241f276adc1SDimitry Andric# _Float16 support, only on some architectures, and with certain compiler 242f276adc1SDimitry Andric# versions. 2435f757f3fSDimitry Andric# 244f276adc1SDimitry Andric.if ((${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 150000) && \ 245fcc5fa09SBrooks Davis (defined(CRT_COMMON_F16_ARCH) || \ 246fcc5fa09SBrooks Davis ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "riscv")) || \ 247f276adc1SDimitry Andric ((${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 120000) && \ 248f276adc1SDimitry Andric (defined(CRT_COMMON_F16_ARCH))) 249f276adc1SDimitry AndricCFLAGS+= -DCOMPILER_RT_HAS_FLOAT16 250f276adc1SDimitry Andric.endif 251f276adc1SDimitry Andric 252f276adc1SDimitry Andric# 253f276adc1SDimitry Andric# __bf16 support, only on some architectures, and with certain compiler 254f276adc1SDimitry Andric# versions. 255f276adc1SDimitry Andric# 256f276adc1SDimitry Andric.if ((${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 150000) && \ 257f276adc1SDimitry Andric (defined(CRT_COMMON_F16_ARCH))) || \ 258f276adc1SDimitry Andric ((${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 180000) && \ 259f276adc1SDimitry Andric ${MACHINE_CPUARCH} == "riscv") || \ 260f276adc1SDimitry Andric ((${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 130000) && \ 261f276adc1SDimitry Andric (defined(CRT_COMMON_F16_ARCH))) 262f276adc1SDimitry AndricCFLAGS+= -DCOMPILER_RT_HAS_BFLOAT16 263*0fca6ea1SDimitry AndricSRCF+= extendbfsf2 2645f757f3fSDimitry AndricSRCF+= truncdfbf2 2655f757f3fSDimitry AndricSRCF+= truncsfbf2 2665f757f3fSDimitry Andric.endif 2675f757f3fSDimitry Andric 268040b3049SEd Maste# FreeBSD-specific atomic intrinsics. 269b53a8df3SWarner Losh.if ${MACHINE_CPUARCH} == "arm" 270040b3049SEd Maste.PATH: ${SRCTOP}/sys/arm/arm 271040b3049SEd Maste 272040b3049SEd MasteSRCF+= stdatomic 273040b3049SEd MasteCFLAGS+= -DEMIT_SYNC_ATOMICS 274040b3049SEd Maste.endif 275040b3049SEd Maste 276040b3049SEd Maste.for file in ${SRCF} 277ae902a5bSWarner Losh.if ${MACHINE_CPUARCH} == "arm" && (!defined(CPUTYPE) || ${CPUTYPE:M*soft*} == "") \ 278040b3049SEd Maste && exists(${CRTSRC}/${CRTARCH}/${file}vfp.S) 279040b3049SEd MasteSRCS+= ${file}vfp.S 280040b3049SEd Maste. elif exists(${CRTSRC}/${CRTARCH}/${file}.S) 281040b3049SEd MasteSRCS+= ${file}.S 282040b3049SEd Maste. else 283040b3049SEd MasteSRCS+= ${file}.c 284040b3049SEd Maste. endif 285040b3049SEd Maste.endfor 286040b3049SEd Maste 287040b3049SEd Maste.if ${MACHINE_CPUARCH} == "arm" 288040b3049SEd MasteSRCS+= aeabi_div0.c 289040b3049SEd MasteSRCS+= aeabi_idivmod.S 290040b3049SEd MasteSRCS+= aeabi_ldivmod.S 291040b3049SEd MasteSRCS+= aeabi_memcmp.S 292040b3049SEd MasteSRCS+= aeabi_memcpy.S 293040b3049SEd MasteSRCS+= aeabi_memmove.S 294040b3049SEd MasteSRCS+= aeabi_memset.S 295040b3049SEd MasteSRCS+= aeabi_uidivmod.S 296040b3049SEd MasteSRCS+= aeabi_uldivmod.S 297040b3049SEd MasteSRCS+= switch16.S 298040b3049SEd MasteSRCS+= switch32.S 299040b3049SEd MasteSRCS+= switch8.S 300040b3049SEd MasteSRCS+= switchu8.S 301040b3049SEd MasteSRCS+= sync_synchronize.S 302040b3049SEd Maste.endif 303