1import("//compiler-rt/target.gni") 2import("//llvm/utils/gn/build/buildflags.gni") 3 4declare_args() { 5 # Skip the atomic builtin (should normally be provided by a shared library). 6 compiler_rt_exclude_atomic_builtin = true 7} 8 9lse_targets = [] 10 11if (current_cpu == "x86" || current_cpu == "x64") { 12 # long double is not 80 bits on Android or MSVC. 13 long_double_is_80_bits = current_os != "android" && current_os != "win" 14} 15 16if (current_cpu == "arm64") { 17 foreach(pat, 18 [ 19 "cas", 20 "swp", 21 "ldadd", 22 "ldclr", 23 "ldeor", 24 "ldset", 25 ]) { 26 foreach(size, 27 [ 28 "1", 29 "2", 30 "4", 31 "8", 32 "16", 33 ]) { 34 foreach(model, 35 [ 36 "1", 37 "2", 38 "3", 39 "4", 40 ]) { 41 if (pat == "cas" || size != "16") { 42 source_set("lse_${pat}_${size}_${model}") { 43 # Assign to sources like this to hide from 44 # sync_source_lists_from_cmake.py which won't find the source file 45 # on the CMake side. 46 lse_file = "aarch64/lse.S" 47 sources = [ lse_file ] 48 include_dirs = [ "." ] 49 defines = [ 50 "L_$pat", 51 "SIZE=$size", 52 "MODEL=$model", 53 ] 54 } 55 lse_targets += [ ":lse_${pat}_${size}_${model}" ] 56 } 57 } 58 } 59 } 60} 61 62static_library("builtins") { 63 output_dir = crt_current_out_dir 64 if (current_os == "mac") { 65 output_name = "clang_rt.osx" 66 } else if (current_os == "ios" && current_cpu == "arm64") { 67 output_name = "clang_rt.ios" 68 } else if (current_os == "ios" && current_cpu == "x64") { 69 output_name = "clang_rt.iossim" 70 } else { 71 output_name = "clang_rt.builtins$crt_current_target_suffix" 72 } 73 74 complete_static_lib = true 75 configs -= [ "//llvm/utils/gn/build:thin_archive" ] 76 77 cflags = [] 78 if (current_os != "win") { 79 cflags = [ 80 "-fPIC", 81 "-fno-builtin", 82 ] 83 if (current_os != "android") { 84 cflags += [ "-fvisibility=hidden" ] 85 } 86 if (!is_debug) { 87 cflags += [ "-fomit-frame-pointer" ] 88 } 89 cflags_c = [ "-std=c11" ] 90 } 91 92 sources = [ 93 "absvdi2.c", 94 "absvsi2.c", 95 "absvti2.c", 96 "adddf3.c", 97 "addsf3.c", 98 "addvdi3.c", 99 "addvsi3.c", 100 "addvti3.c", 101 "apple_versioning.c", 102 "ashldi3.c", 103 "ashlti3.c", 104 "ashrdi3.c", 105 "ashrti3.c", 106 "bswapdi2.c", 107 "bswapsi2.c", 108 "clzdi2.c", 109 "clzsi2.c", 110 "clzti2.c", 111 "cmpdi2.c", 112 "cmpti2.c", 113 "comparedf2.c", 114 "comparesf2.c", 115 "ctzdi2.c", 116 "ctzsi2.c", 117 "ctzti2.c", 118 "divdc3.c", 119 "divdf3.c", 120 "divdi3.c", 121 "divmoddi4.c", 122 "divmodsi4.c", 123 "divmodti4.c", 124 "divsc3.c", 125 "divsf3.c", 126 "divsi3.c", 127 "divti3.c", 128 "extendhfsf2.c", 129 "extendsfdf2.c", 130 "ffsdi2.c", 131 "ffssi2.c", 132 "ffsti2.c", 133 "fixdfdi.c", 134 "fixdfsi.c", 135 "fixdfti.c", 136 "fixsfdi.c", 137 "fixsfsi.c", 138 "fixsfti.c", 139 "fixunsdfdi.c", 140 "fixunsdfsi.c", 141 "fixunsdfti.c", 142 "fixunssfdi.c", 143 "fixunssfsi.c", 144 "fixunssfti.c", 145 "floatdidf.c", 146 "floatdisf.c", 147 "floatsidf.c", 148 "floatsisf.c", 149 "floattidf.c", 150 "floattisf.c", 151 "floatundidf.c", 152 "floatundisf.c", 153 "floatunsidf.c", 154 "floatunsisf.c", 155 "floatuntidf.c", 156 "floatuntisf.c", 157 "fp_mode.c", 158 "int_util.c", 159 "lshrdi3.c", 160 "lshrti3.c", 161 "moddi3.c", 162 "modsi3.c", 163 "modti3.c", 164 "muldc3.c", 165 "muldf3.c", 166 "muldi3.c", 167 "mulodi4.c", 168 "mulosi4.c", 169 "muloti4.c", 170 "mulsc3.c", 171 "mulsf3.c", 172 "multi3.c", 173 "mulvdi3.c", 174 "mulvsi3.c", 175 "mulvti3.c", 176 "negdf2.c", 177 "negdi2.c", 178 "negsf2.c", 179 "negti2.c", 180 "negvdi2.c", 181 "negvsi2.c", 182 "negvti2.c", 183 "os_version_check.c", 184 "paritydi2.c", 185 "paritysi2.c", 186 "parityti2.c", 187 "popcountdi2.c", 188 "popcountsi2.c", 189 "popcountti2.c", 190 "powidf2.c", 191 "powisf2.c", 192 "subdf3.c", 193 "subsf3.c", 194 "subvdi3.c", 195 "subvsi3.c", 196 "subvti3.c", 197 "trampoline_setup.c", 198 "truncdfhf2.c", 199 "truncdfsf2.c", 200 "truncsfhf2.c", 201 "ucmpdi2.c", 202 "ucmpti2.c", 203 "udivdi3.c", 204 "udivmoddi4.c", 205 "udivmodsi4.c", 206 "udivmodti4.c", 207 "udivsi3.c", 208 "udivti3.c", 209 "umoddi3.c", 210 "umodsi3.c", 211 "umodti3.c", 212 213 # This depends on unwind.h which is present in Clang headers. We should 214 # reconsider this if we ever decide to support building builtins with 215 # other compilers. 216 "gcc_personality_v0.c", 217 ] 218 219 if (current_os != "fuchsia") { 220 sources += [ "clear_cache.c" ] 221 } 222 223 if (current_os != "fuchsia" && current_os != "baremetal") { 224 sources += [ 225 "emutls.c", 226 "enable_execute_stack.c", 227 "eprintf.c", 228 ] 229 } 230 231 if (current_os == "mac" || current_os == "ios") { 232 sources += [ 233 "atomic_flag_clear.c", 234 "atomic_flag_clear_explicit.c", 235 "atomic_flag_test_and_set.c", 236 "atomic_flag_test_and_set_explicit.c", 237 "atomic_signal_fence.c", 238 "atomic_thread_fence.c", 239 ] 240 } 241 242 if ((current_cpu == "x64" && current_os != "win") || current_cpu == "arm64") { 243 # GENERIC_TF_SOURCES 244 sources += [ 245 "addtf3.c", 246 "comparetf2.c", 247 "divtc3.c", 248 "divtf3.c", 249 "extenddftf2.c", 250 "extendhftf2.c", 251 "extendsftf2.c", 252 "fixtfdi.c", 253 "fixtfsi.c", 254 "fixtfti.c", 255 "fixunstfdi.c", 256 "fixunstfsi.c", 257 "fixunstfti.c", 258 "floatditf.c", 259 "floatsitf.c", 260 "floattitf.c", 261 "floatunditf.c", 262 "floatunsitf.c", 263 "floatuntitf.c", 264 "multc3.c", 265 "multf3.c", 266 "powitf2.c", 267 "subtf3.c", 268 "trunctfdf2.c", 269 "trunctfhf2.c", 270 "trunctfsf2.c", 271 ] 272 } 273 274 if (current_cpu == "x86" || current_cpu == "x64") { 275 sources -= [ "fp_mode.c" ] 276 sources += [ 277 "cpu_model/x86.c", 278 "extendbfsf2.c", 279 "i386/fp_mode.c", 280 "truncdfbf2.c", 281 "truncsfbf2.c", 282 "trunctfbf2.c", 283 "truncxfbf2.c", 284 ] 285 if (long_double_is_80_bits) { 286 sources += [ 287 "divxc3.c", 288 "extendhfxf2.c", 289 "extendxftf2.c", 290 "fixunsxfdi.c", 291 "fixunsxfsi.c", 292 "fixunsxfti.c", 293 "fixxfdi.c", 294 "fixxfti.c", 295 "floatdixf.c", 296 "floattixf.c", 297 "floatundixf.c", 298 "floatuntixf.c", 299 "mulxc3.c", 300 "powixf2.c", 301 "trunctfxf2.c", 302 "truncxfhf2.c", 303 ] 304 } 305 } 306 if (current_cpu == "x86") { 307 sources -= [ 308 "ashldi3.c", 309 "ashrdi3.c", 310 "divdi3.c", 311 "floatdidf.c", 312 "floatdisf.c", 313 "floatundidf.c", 314 "floatundisf.c", 315 "lshrdi3.c", 316 "moddi3.c", 317 "muldi3.c", 318 "udivdi3.c", 319 "umoddi3.c", 320 ] 321 sources += [ 322 "i386/ashldi3.S", 323 "i386/ashrdi3.S", 324 "i386/divdi3.S", 325 "i386/floatdidf.S", 326 "i386/floatdisf.S", 327 "i386/floatundidf.S", 328 "i386/floatundisf.S", 329 "i386/lshrdi3.S", 330 "i386/moddi3.S", 331 "i386/muldi3.S", 332 "i386/udivdi3.S", 333 "i386/umoddi3.S", 334 ] 335 if (long_double_is_80_bits) { 336 sources -= [ 337 "floatdixf.c", 338 "floatundixf.c", 339 ] 340 sources += [ 341 "i386/floatdixf.S", 342 "i386/floatundixf.S", 343 ] 344 } 345 if (current_os == "win") { 346 sources += [ "i386/chkstk.S" ] 347 } 348 } else if (current_cpu == "x64") { 349 sources -= [ 350 "floatdidf.c", 351 "floatdisf.c", 352 "floatundidf.c", 353 "floatundisf.c", 354 ] 355 sources += [ 356 "x86_64/floatdidf.c", 357 "x86_64/floatdisf.c", 358 "x86_64/floatundidf.S", 359 "x86_64/floatundisf.S", 360 ] 361 if (long_double_is_80_bits) { 362 sources -= [ 363 "floatdixf.c", 364 "floatundixf.c", 365 ] 366 sources += [ 367 "x86_64/floatdixf.c", 368 "x86_64/floatundixf.S", 369 ] 370 } 371 if (current_os == "win") { 372 sources += [ "x86_64/chkstk.S" ] 373 } 374 } 375 376 if (current_cpu == "arm") { 377 if (current_os != "mingw") { 378 sources -= [ 379 "bswapdi2.c", 380 "bswapsi2.c", 381 "clzdi2.c", 382 "clzsi2.c", 383 "comparesf2.c", 384 "divmodsi4.c", 385 "divsi3.c", 386 "fp_mode.c", 387 "modsi3.c", 388 "udivmodsi4.c", 389 "udivsi3.c", 390 "umodsi3.c", 391 ] 392 sources += [ 393 "arm/aeabi_cdcmp.S", 394 "arm/aeabi_cdcmpeq_check_nan.c", 395 "arm/aeabi_cfcmp.S", 396 "arm/aeabi_cfcmpeq_check_nan.c", 397 "arm/aeabi_dcmp.S", 398 "arm/aeabi_div0.c", 399 "arm/aeabi_drsub.c", 400 "arm/aeabi_fcmp.S", 401 "arm/aeabi_frsub.c", 402 "arm/aeabi_idivmod.S", 403 "arm/aeabi_ldivmod.S", 404 "arm/aeabi_memcmp.S", 405 "arm/aeabi_memcpy.S", 406 "arm/aeabi_memmove.S", 407 "arm/aeabi_memset.S", 408 "arm/aeabi_uidivmod.S", 409 "arm/aeabi_uldivmod.S", 410 "arm/bswapdi2.S", 411 "arm/bswapsi2.S", 412 "arm/clzdi2.S", 413 "arm/clzsi2.S", 414 "arm/comparesf2.S", 415 "arm/divmodsi4.S", 416 "arm/divsi3.S", 417 "arm/fp_mode.c", 418 "arm/modsi3.S", 419 "arm/switch16.S", 420 "arm/switch32.S", 421 "arm/switch8.S", 422 "arm/switchu8.S", 423 "arm/sync_fetch_and_add_4.S", 424 "arm/sync_fetch_and_add_8.S", 425 "arm/sync_fetch_and_and_4.S", 426 "arm/sync_fetch_and_and_8.S", 427 "arm/sync_fetch_and_max_4.S", 428 "arm/sync_fetch_and_max_8.S", 429 "arm/sync_fetch_and_min_4.S", 430 "arm/sync_fetch_and_min_8.S", 431 "arm/sync_fetch_and_nand_4.S", 432 "arm/sync_fetch_and_nand_8.S", 433 "arm/sync_fetch_and_or_4.S", 434 "arm/sync_fetch_and_or_8.S", 435 "arm/sync_fetch_and_sub_4.S", 436 "arm/sync_fetch_and_sub_8.S", 437 "arm/sync_fetch_and_umax_4.S", 438 "arm/sync_fetch_and_umax_8.S", 439 "arm/sync_fetch_and_umin_4.S", 440 "arm/sync_fetch_and_umin_8.S", 441 "arm/sync_fetch_and_xor_4.S", 442 "arm/sync_fetch_and_xor_8.S", 443 "arm/sync_synchronize.S", 444 "arm/udivmodsi4.S", 445 "arm/udivsi3.S", 446 "arm/umodsi3.S", 447 ] 448 449 if (current_os == "android") { 450 sources += [ 451 "arm/adddf3vfp.S", 452 "arm/addsf3vfp.S", 453 "arm/divdf3vfp.S", 454 "arm/divsf3vfp.S", 455 "arm/eqdf2vfp.S", 456 "arm/eqsf2vfp.S", 457 "arm/extendsfdf2vfp.S", 458 "arm/fixdfsivfp.S", 459 "arm/fixsfsivfp.S", 460 "arm/fixunsdfsivfp.S", 461 "arm/fixunssfsivfp.S", 462 "arm/floatsidfvfp.S", 463 "arm/floatsisfvfp.S", 464 "arm/floatunssidfvfp.S", 465 "arm/floatunssisfvfp.S", 466 "arm/gedf2vfp.S", 467 "arm/gesf2vfp.S", 468 "arm/gtdf2vfp.S", 469 "arm/gtsf2vfp.S", 470 "arm/ledf2vfp.S", 471 "arm/lesf2vfp.S", 472 "arm/ltdf2vfp.S", 473 "arm/ltsf2vfp.S", 474 "arm/muldf3vfp.S", 475 "arm/mulsf3vfp.S", 476 "arm/nedf2vfp.S", 477 "arm/negdf2vfp.S", 478 "arm/negsf2vfp.S", 479 "arm/nesf2vfp.S", 480 "arm/restore_vfp_d8_d15_regs.S", 481 "arm/save_vfp_d8_d15_regs.S", 482 "arm/subdf3vfp.S", 483 "arm/subsf3vfp.S", 484 "arm/truncdfsf2vfp.S", 485 "arm/unorddf2vfp.S", 486 "arm/unordsf2vfp.S", 487 ] 488 } 489 } else { 490 sources += [ 491 "arm/aeabi_idivmod.S", 492 "arm/aeabi_ldivmod.S", 493 "arm/aeabi_uidivmod.S", 494 "arm/aeabi_uldivmod.S", 495 "arm/chkstk.S", 496 ] 497 } 498 } 499 500 if (current_cpu == "arm64") { 501 sources -= [ "fp_mode.c" ] 502 sources += [ 503 "aarch64/fp_mode.c", 504 "cpu_model/aarch64.c", 505 ] 506 if (current_os == "mingw") { 507 sources += [ "aarch64/chkstk.S" ] 508 } 509 } 510 511 if (current_cpu == "avr") { 512 sources += [ 513 "avr/divmodhi4.S", 514 "avr/divmodqi4.S", 515 "avr/exit.S", 516 "avr/mulhi3.S", 517 "avr/mulqi3.S", 518 "avr/udivmodhi4.S", 519 "avr/udivmodqi4.S", 520 ] 521 } 522 523 if (current_cpu == "hexagon") { 524 sources += [ 525 "hexagon/common_entry_exit_abi1.S", 526 "hexagon/common_entry_exit_abi2.S", 527 "hexagon/common_entry_exit_legacy.S", 528 "hexagon/dfaddsub.S", 529 "hexagon/dfdiv.S", 530 "hexagon/dffma.S", 531 "hexagon/dfminmax.S", 532 "hexagon/dfmul.S", 533 "hexagon/dfsqrt.S", 534 "hexagon/divdi3.S", 535 "hexagon/divsi3.S", 536 "hexagon/fastmath2_dlib_asm.S", 537 "hexagon/fastmath2_ldlib_asm.S", 538 "hexagon/fastmath_dlib_asm.S", 539 "hexagon/memcpy_forward_vp4cp4n2.S", 540 "hexagon/memcpy_likely_aligned.S", 541 "hexagon/moddi3.S", 542 "hexagon/modsi3.S", 543 "hexagon/sfdiv_opt.S", 544 "hexagon/sfsqrt_opt.S", 545 "hexagon/udivdi3.S", 546 "hexagon/udivmoddi4.S", 547 "hexagon/udivmodsi4.S", 548 "hexagon/udivsi3.S", 549 "hexagon/umoddi3.S", 550 "hexagon/umodsi3.S", 551 ] 552 } 553 if (current_cpu == "loongarch" || current_cpu == "loongarch64") { 554 sources -= [ "fp_mode.c" ] 555 sources += [ "loongarch/fp_mode.c" ] 556 } 557 558 if (current_cpu == "ppc64") { 559 sources += [ 560 "ppc/divtc3.c", 561 "ppc/fixtfdi.c", 562 "ppc/fixtfti.c", 563 "ppc/fixunstfdi.c", 564 "ppc/fixunstfti.c", 565 "ppc/floatditf.c", 566 "ppc/floattitf.c", 567 "ppc/floatunditf.c", 568 "ppc/gcc_qadd.c", 569 "ppc/gcc_qdiv.c", 570 "ppc/gcc_qmul.c", 571 "ppc/gcc_qsub.c", 572 "ppc/multc3.c", 573 ] 574 } 575 576 if (current_cpu == "riscv" || current_cpu == "riscv64") { 577 sources += [ 578 "cpu_model/riscv.c", 579 "riscv/fp_mode.c", 580 "riscv/restore.S", 581 "riscv/save.S", 582 ] 583 } 584 if (current_cpu == "riscv") { 585 sources += [ "riscv/mulsi3.S" ] 586 } 587 588 if (current_cpu == "riscv64") { 589 sources += [ "riscv/muldi3.S" ] 590 } 591 592 if (current_cpu == "ve") { 593 sources += [ 594 "ve/grow_stack.S", 595 "ve/grow_stack_align.S", 596 ] 597 } 598 599 if (!compiler_rt_exclude_atomic_builtin) { 600 sources += [ "atomic.c" ] 601 } 602 603 deps = lse_targets 604} 605 606# Currently unused but necessary to make sync_source_lists_from_cmake.py happy. 607source_set("_unused") { 608 sources = [ 609 # Thumb1 610 "arm/addsf3.S", 611 "arm/comparesf2.S", 612 "arm/divsi3.S", 613 "arm/udivsi3.S", 614 ] 615} 616