[AMDGPU] Make v8i16/v8f16 legal
[llvm-project.git] / utils / bazel / llvm-project-overlay / libc / BUILD.bazel
blobb709565b148309e6390bbb025b2ac12509b5e84d
1 # This file is licensed under the Apache License v2.0 with LLVM Exceptions.
2 # See https://llvm.org/LICENSE.txt for license information.
3 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5 # LLVM libc project.
6 load(":libc_build_rules.bzl", "libc_function", "libc_math_function")
7 load(":platforms.bzl", "PLATFORM_CPU_ARM64", "PLATFORM_CPU_X86_64")
8 load("@bazel_skylib//lib:selects.bzl", "selects")
10 package(
11     default_visibility = ["//visibility:public"],
12     licenses = ["notice"],
15 # This empty root library helps us add an include path to this directory
16 # using the 'includes' attribute. The strings listed in the includes attribute
17 # are relative paths wrt this library but are inherited by the dependents
18 # appropriately. Hence, using this as a root dependency avoids adding include
19 # paths of the kind "../../" to other libc targets.
20 cc_library(
21     name = "libc_root",
22     includes = ["."],
25 ############################## Support libraries #############################
27 cc_library(
28     name = "__support_common",
29     hdrs = [
30         "src/__support/architectures.h",
31         "src/__support/common.h",
32         "src/__support/endian.h",
33         "src/__support/sanitizer.h",
34     ],
37 cc_library(
38     name = "__support_standalone_cpp",
39     hdrs = [
40         "src/__support/CPP/Array.h",
41         "src/__support/CPP/ArrayRef.h",
42         "src/__support/CPP/Bitset.h",
43         "src/__support/CPP/Functional.h",
44         "src/__support/CPP/Limits.h",
45         "src/__support/CPP/StringView.h",
46         "src/__support/CPP/TypeTraits.h",
47     ],
48     deps = [":libc_root"],
51 cc_library(
52     name = "__support_integer_operations",
53     hdrs = ["src/__support/integer_operations.h"],
54     deps = [":__support_standalone_cpp"],
57 cc_library(
58     name = "__support_ctype_utils",
59     hdrs = ["src/__support/ctype_utils.h"],
62 cc_library(
63     name = "__support_str_to_integer",
64     hdrs = ["src/__support/str_to_integer.h"],
65     deps = [
66         ":__support_ctype_utils",
67         ":__support_standalone_cpp",
68     ],
71 fputil_common_hdrs = [
72     "src/__support/FPUtil/BasicOperations.h",
73     "src/__support/FPUtil/DivisionAndRemainderOperations.h",
74     "src/__support/FPUtil/FEnvImpl.h",
75     "src/__support/FPUtil/FEnvUtils.h",
76     "src/__support/FPUtil/FPBits.h",
77     "src/__support/FPUtil/FloatProperties.h",
78     "src/__support/FPUtil/Hypot.h",
79     "src/__support/FPUtil/ManipulationFunctions.h",
80     "src/__support/FPUtil/NearestIntegerOperations.h",
81     "src/__support/FPUtil/NormalFloat.h",
82     "src/__support/FPUtil/PlatformDefs.h",
83     "src/__support/FPUtil/Sqrt.h",
86 fputil_hdrs = selects.with_or({
87     "//conditions:default": fputil_common_hdrs,
88     PLATFORM_CPU_X86_64: fputil_common_hdrs + [
89         "src/__support/FPUtil/x86_64/LongDoubleBits.h",
90         "src/__support/FPUtil/x86_64/NextAfterLongDouble.h",
91         "src/__support/FPUtil/x86_64/SqrtLongDouble.h",
92         "src/__support/FPUtil/x86_64/FEnvImpl.h",
93     ],
94     PLATFORM_CPU_ARM64: fputil_common_hdrs + [
95         "src/__support/FPUtil/aarch64/FEnvImpl.h",
96     ],
99 cc_library(
100     name = "__support_fputil",
101     hdrs = fputil_hdrs,
102     deps = [
103         ":__support_common",
104         ":__support_standalone_cpp",
105         ":libc_root",
106     ],
109 ################################ fenv targets ################################
111 libc_function(
112     name = "fetestexcept",
113     srcs = ["src/fenv/fetestexcept.cpp"],
114     hdrs = ["src/fenv/fetestexcept.h"],
115     deps = [
116         ":__support_common",
117         ":__support_fputil",
118     ],
121 libc_function(
122     name = "feclearexcept",
123     srcs = ["src/fenv/feclearexcept.cpp"],
124     hdrs = ["src/fenv/feclearexcept.h"],
125     deps = [
126         ":__support_common",
127         ":__support_fputil",
128     ],
131 libc_function(
132     name = "feraiseexcept",
133     srcs = ["src/fenv/feraiseexcept.cpp"],
134     hdrs = ["src/fenv/feraiseexcept.h"],
135     deps = [
136         ":__support_common",
137         ":__support_fputil",
138     ],
141 libc_function(
142     name = "fegetround",
143     srcs = ["src/fenv/fegetround.cpp"],
144     hdrs = ["src/fenv/fegetround.h"],
145     deps = [
146         ":__support_common",
147         ":__support_fputil",
148     ],
151 libc_function(
152     name = "fesetround",
153     srcs = ["src/fenv/fesetround.cpp"],
154     hdrs = ["src/fenv/fesetround.h"],
155     deps = [
156         ":__support_common",
157         ":__support_fputil",
158     ],
161 libc_function(
162     name = "fedisableexcept",
163     srcs = ["src/fenv/fedisableexcept.cpp"],
164     hdrs = ["src/fenv/fedisableexcept.h"],
165     deps = [
166         ":__support_common",
167         ":__support_fputil",
168     ],
171 libc_function(
172     name = "feenableexcept",
173     srcs = ["src/fenv/feenableexcept.cpp"],
174     hdrs = ["src/fenv/feenableexcept.h"],
175     deps = [
176         ":__support_common",
177         ":__support_fputil",
178     ],
181 libc_function(
182     name = "fegetexcept",
183     srcs = ["src/fenv/fegetexcept.cpp"],
184     hdrs = ["src/fenv/fegetexcept.h"],
185     deps = [
186         ":__support_common",
187         ":__support_fputil",
188     ],
191 libc_function(
192     name = "fegetenv",
193     srcs = ["src/fenv/fegetenv.cpp"],
194     hdrs = ["src/fenv/fegetenv.h"],
195     deps = [
196         ":__support_common",
197         ":__support_fputil",
198     ],
201 libc_function(
202     name = "fesetenv",
203     srcs = ["src/fenv/fesetenv.cpp"],
204     hdrs = ["src/fenv/fesetenv.h"],
205     deps = [
206         ":__support_common",
207         ":__support_fputil",
208     ],
211 libc_function(
212     name = "feupdateenv",
213     srcs = ["src/fenv/feupdateenv.cpp"],
214     hdrs = ["src/fenv/feupdateenv.h"],
215     deps = [
216         ":__support_common",
217         ":__support_fputil",
218     ],
221 libc_function(
222     name = "fegetexceptflag",
223     srcs = ["src/fenv/fegetexceptflag.cpp"],
224     hdrs = ["src/fenv/fegetexceptflag.h"],
225     deps = [
226         ":__support_common",
227         ":__support_fputil",
228     ],
231 libc_function(
232     name = "fesetexceptflag",
233     srcs = ["src/fenv/fesetexceptflag.cpp"],
234     hdrs = ["src/fenv/fesetexceptflag.h"],
235     deps = [
236         ":__support_common",
237         ":__support_fputil",
238     ],
241 libc_function(
242     name = "feholdexcept",
243     srcs = ["src/fenv/feholdexcept.cpp"],
244     hdrs = ["src/fenv/feholdexcept.h"],
245     deps = [
246         ":__support_common",
247         ":__support_fputil",
248     ],
251 ################################ math targets ################################
253 cc_library(
254     name = "math_utils",
255     srcs = ["src/math/generic/math_utils.cpp"],
256     hdrs = ["src/math/generic/math_utils.h"],
257     deps = [
258         ":__support_common",
259         ":__support_standalone_cpp",
260         ":libc_root",
261     ],
264 cc_library(
265     name = "sincosf_utils",
266     srcs = ["src/math/generic/sincosf_data.cpp"],
267     hdrs = ["src/math/generic/sincosf_utils.h"],
268     deps = [
269         ":libc_root",
270         ":math_utils",
271     ],
274 libc_math_function(name = "fabs")
276 libc_math_function(name = "fabsf")
278 libc_math_function(name = "fabsl")
280 libc_math_function(name = "fdim")
282 libc_math_function(name = "fdimf")
284 libc_math_function(name = "fdiml")
286 libc_math_function(
287     name = "ceil",
288     specializations = [
289         "aarch64",
290         "generic",
291     ],
294 libc_math_function(
295     name = "ceilf",
296     specializations = [
297         "aarch64",
298         "generic",
299     ],
302 libc_math_function(
303     name = "ceill",
304     specializations = [
305         "generic",
306     ],
309 libc_math_function(
310     name = "floor",
311     specializations = [
312         "aarch64",
313         "generic",
314     ],
317 libc_math_function(
318     name = "floorf",
319     specializations = [
320         "aarch64",
321         "generic",
322     ],
325 libc_math_function(name = "floorl")
327 libc_math_function(name = "ldexp")
329 libc_math_function(name = "ldexpf")
331 libc_math_function(name = "ldexpl")
333 libc_math_function(
334     name = "trunc",
335     specializations = [
336         "aarch64",
337         "generic",
338     ],
341 libc_math_function(
342     name = "truncf",
343     specializations = [
344         "aarch64",
345         "generic",
346     ],
349 libc_math_function(name = "truncl")
351 libc_math_function(
352     name = "round",
353     specializations = [
354         "aarch64",
355         "generic",
356     ],
359 libc_math_function(
360     name = "roundf",
361     specializations = [
362         "aarch64",
363         "generic",
364     ],
367 libc_math_function(name = "roundl")
369 libc_math_function(name = "frexp")
371 libc_math_function(name = "frexpf")
373 libc_math_function(name = "frexpl")
375 libc_math_function(name = "hypot")
377 libc_math_function(name = "hypotf")
379 libc_math_function(name = "logb")
381 libc_math_function(name = "logbf")
383 libc_math_function(name = "logbl")
385 libc_math_function(name = "modf")
387 libc_math_function(name = "modff")
389 libc_math_function(name = "modfl")
391 libc_math_function(name = "remquo")
393 libc_math_function(name = "remquof")
395 libc_math_function(name = "remquol")
397 libc_math_function(name = "remainder")
399 libc_math_function(name = "remainderf")
401 libc_math_function(name = "remainderl")
403 libc_math_function(name = "fmin")
405 libc_math_function(name = "fminf")
407 libc_math_function(name = "fminl")
409 libc_math_function(name = "fmax")
411 libc_math_function(name = "fmaxf")
413 libc_math_function(name = "fmaxl")
415 libc_math_function(
416     name = "cosf",
417     additional_deps = [
418         ":math_utils",
419         ":sincosf_utils",
420     ],
423 libc_math_function(
424     name = "sincosf",
425     additional_deps = [
426         ":math_utils",
427         ":sincosf_utils",
428     ],
431 libc_math_function(
432     name = "sinf",
433     additional_deps = [
434         ":math_utils",
435         ":sincosf_utils",
436     ],
439 libc_math_function(
440     name = "sqrt",
441     specializations = [
442         "aarch64",
443         "generic",
444         "x86_64",
445     ],
448 libc_math_function(
449     name = "sqrtf",
450     specializations = [
451         "aarch64",
452         "generic",
453         "x86_64",
454     ],
457 libc_math_function(
458     name = "sqrtl",
459     specializations = [
460         "generic",
461         "x86_64",
462     ],
465 libc_math_function(name = "copysign")
467 libc_math_function(name = "copysignf")
469 libc_math_function(name = "copysignl")
471 libc_math_function(name = "ilogb")
473 libc_math_function(name = "ilogbf")
475 libc_math_function(name = "ilogbl")
477 libc_math_function(name = "rint")
479 libc_math_function(name = "rintf")
481 libc_math_function(name = "rintl")
483 libc_math_function(name = "lrint")
485 libc_math_function(name = "lrintf")
487 libc_math_function(name = "lrintl")
489 libc_math_function(name = "llrint")
491 libc_math_function(name = "llrintf")
493 libc_math_function(name = "llrintl")
495 libc_math_function(name = "lround")
497 libc_math_function(name = "lroundf")
499 libc_math_function(name = "lroundl")
501 libc_math_function(name = "llround")
503 libc_math_function(name = "llroundf")
505 libc_math_function(name = "llroundl")
507 libc_math_function(name = "nearbyint")
509 libc_math_function(name = "nearbyintf")
511 libc_math_function(name = "nearbyintl")
513 libc_math_function(name = "nextafter")
515 libc_math_function(name = "nextafterf")
517 libc_math_function(name = "nextafterl")
519 ############################### stdlib targets ###############################
521 libc_function(
522     name = "atoi",
523     srcs = ["src/stdlib/atoi.cpp"],
524     hdrs = ["src/stdlib/atoi.h"],
525     deps = [
526         ":__support_common",
527         ":__support_str_to_integer",
528     ],
531 libc_function(
532     name = "atol",
533     srcs = ["src/stdlib/atol.cpp"],
534     hdrs = ["src/stdlib/atol.h"],
535     deps = [
536         ":__support_common",
537         ":__support_str_to_integer",
538     ],
541 libc_function(
542     name = "atoll",
543     srcs = ["src/stdlib/atoll.cpp"],
544     hdrs = ["src/stdlib/atoll.h"],
545     deps = [
546         ":__support_common",
547         ":__support_str_to_integer",
548     ],
551 libc_function(
552     name = "bsearch",
553     srcs = ["src/stdlib/bsearch.cpp"],
554     hdrs = ["src/stdlib/bsearch.h"],
555     deps = [
556         ":__support_common",
557     ],
560 libc_function(
561     name = "qsort",
562     srcs = ["src/stdlib/qsort.cpp"],
563     hdrs = ["src/stdlib/qsort.h"],
564     deps = [
565         ":__support_common",
566     ],
569 libc_function(
570     name = "strtol",
571     srcs = ["src/stdlib/strtol.cpp"],
572     hdrs = ["src/stdlib/strtol.h"],
573     deps = [
574         ":__support_common",
575         ":__support_str_to_integer",
576     ],
579 libc_function(
580     name = "strtoll",
581     srcs = ["src/stdlib/strtoll.cpp"],
582     hdrs = ["src/stdlib/strtoll.h"],
583     deps = [
584         ":__support_common",
585         ":__support_str_to_integer",
586     ],
589 libc_function(
590     name = "strtoul",
591     srcs = ["src/stdlib/strtoul.cpp"],
592     hdrs = ["src/stdlib/strtoul.h"],
593     deps = [
594         ":__support_common",
595         ":__support_str_to_integer",
596     ],
599 libc_function(
600     name = "strtoull",
601     srcs = ["src/stdlib/strtoull.cpp"],
602     hdrs = ["src/stdlib/strtoull.h"],
603     deps = [
604         ":__support_common",
605         ":__support_str_to_integer",
606     ],
609 ############################### string targets ###############################
611 no_sanitize_features = [
612     "-asan",
613     "-msan",
614     "-tsan",
615     "-ubsan",
618 cc_library(
619     name = "string_utils",
620     hdrs = ["src/string/string_utils.h"],
621     deps = [
622         ":__support_common",
623         ":__support_standalone_cpp",
624         ":libc_root",
625     ],
628 cc_library(
629     name = "string_memory_utils",
630     hdrs = [
631         "src/string/memory_utils/elements.h",
632         "src/string/memory_utils/elements_aarch64.h",
633         "src/string/memory_utils/elements_x86.h",
634         "src/string/memory_utils/utils.h",
635     ],
636     textual_hdrs = [
637         "src/string/memory_utils/bcmp_implementations.h",
638         "src/string/memory_utils/memcmp_implementations.h",
639         "src/string/memory_utils/memcpy_implementations.h",
640         "src/string/memory_utils/memset_implementations.h",
641     ],
642     deps = [
643         ":__support_common",
644         ":libc_root",
645     ],
648 libc_function(
649     name = "memchr",
650     srcs = ["src/string/memchr.cpp"],
651     hdrs = ["src/string/memchr.h"],
652     deps = [
653         ":__support_common",
654         ":string_utils",
655     ],
658 libc_function(
659     name = "memcpy",
660     srcs = ["src/string/memcpy.cpp"],
661     hdrs = ["src/string/memcpy.h"],
662     copts = [
663         "-fno-builtin-memcpy",
664         "-fno-builtin-memmove",
665         "-mllvm -combiner-global-alias-analysis",
666         "-mllvm --tail-merge-threshold=0",
667     ],
668     features = no_sanitize_features,
669     deps = [
670         ":__support_common",
671         ":string_memory_utils",
672     ],
675 libc_function(
676     name = "memset",
677     srcs = ["src/string/memset.cpp"],
678     hdrs = ["src/string/memset.h"],
679     copts = [
680         "-fno-builtin-memset",
681         "-mllvm -combiner-global-alias-analysis",
682     ],
683     features = no_sanitize_features,
684     deps = [
685         ":__support_common",
686         ":string_memory_utils",
687     ],
690 libc_function(
691     name = "memmove",
692     srcs = ["src/string/memmove.cpp"],
693     hdrs = ["src/string/memmove.h"],
694     copts = [
695         "-fno-builtin-memmove",
696         "-mllvm -combiner-global-alias-analysis",
697     ],
698     features = no_sanitize_features,
699     deps = [
700         ":__support_common",
701         ":__support_integer_operations",
702         ":memcpy",
703         ":string_memory_utils",
704     ],
707 libc_function(
708     name = "memcmp",
709     srcs = ["src/string/memcmp.cpp"],
710     hdrs = ["src/string/memcmp.h"],
711     copts = [
712         "-fno-builtin-memcmp",
713         "-mllvm -combiner-global-alias-analysis",
714     ],
715     features = no_sanitize_features,
716     deps = [
717         ":__support_common",
718         ":__support_integer_operations",
719         ":string_memory_utils",
720     ],
723 libc_function(
724     name = "bcmp",
725     srcs = ["src/string/bcmp.cpp"],
726     hdrs = ["src/string/bcmp.h"],
727     copts = [
728         "-fno-builtin-bcmp",
729         "-fno-builtin-memcmp",
730     ],
731     features = no_sanitize_features,
732     deps = [
733         ":__support_common",
734         ":string_memory_utils",
735     ],
738 libc_function(
739     name = "bzero",
740     srcs = ["src/string/bzero.cpp"],
741     hdrs = ["src/string/bzero.h"],
742     copts = [
743         "-fno-builtin-bzero",
744         "-fno-builtin-memset",
745         "-mllvm -combiner-global-alias-analysis",
746     ],
747     features = no_sanitize_features,
748     deps = [
749         ":__support_common",
750         ":string_memory_utils",
751     ],
754 libc_function(
755     name = "memrchr",
756     srcs = ["src/string/memrchr.cpp"],
757     hdrs = ["src/string/memrchr.h"],
758     deps = [
759         ":__support_common",
760         ":string_utils",
761     ],
764 libc_function(
765     name = "strlen",
766     srcs = ["src/string/strlen.cpp"],
767     hdrs = ["src/string/strlen.h"],
768     features = no_sanitize_features,
769     deps = [
770         ":__support_common",
771         ":string_utils",
772     ],
775 libc_function(
776     name = "strcpy",
777     srcs = ["src/string/strcpy.cpp"],
778     hdrs = ["src/string/strcpy.h"],
779     features = no_sanitize_features,
780     deps = [
781         ":__support_common",
782         ":memcpy",
783         ":string_memory_utils",
784         ":string_utils",
785     ],
788 # A sanitizer instrumented flavor of strcpy to be used with unittests.
789 libc_function(
790     name = "strcpy_sanitized",
791     testonly = 1,
792     srcs = ["src/string/strcpy.cpp"],
793     hdrs = ["src/string/strcpy.h"],
794     deps = [
795         ":__support_common",
796         ":memcpy",
797         ":string_memory_utils",
798         ":string_utils",
799     ],
802 libc_function(
803     name = "strcmp",
804     srcs = ["src/string/strcmp.cpp"],
805     hdrs = ["src/string/strcmp.h"],
806     deps = [
807         ":__support_common",
808         ":string_utils",
809     ],
812 libc_function(
813     name = "strchr",
814     srcs = ["src/string/strchr.cpp"],
815     hdrs = ["src/string/strchr.h"],
816     deps = [
817         ":__support_common",
818         ":string_utils",
819     ],
822 libc_function(
823     name = "strrchr",
824     srcs = ["src/string/strrchr.cpp"],
825     hdrs = ["src/string/strrchr.h"],
826     deps = [
827         ":__support_common",
828         ":string_utils",
829     ],
832 libc_function(
833     name = "strstr",
834     srcs = ["src/string/strstr.cpp"],
835     hdrs = ["src/string/strstr.h"],
836     deps = [
837         ":__support_common",
838         ":string_utils",
839     ],
842 libc_function(
843     name = "strnlen",
844     srcs = ["src/string/strnlen.cpp"],
845     hdrs = ["src/string/strnlen.h"],
846     deps = [
847         ":__support_common",
848         ":string_utils",
849     ],
852 libc_function(
853     name = "strcspn",
854     srcs = ["src/string/strcspn.cpp"],
855     hdrs = ["src/string/strcspn.h"],
856     deps = [
857         ":__support_common",
858         ":string_utils",
859     ],
862 libc_function(
863     name = "strspn",
864     srcs = ["src/string/strspn.cpp"],
865     hdrs = ["src/string/strspn.h"],
866     deps = [
867         ":__support_common",
868         ":__support_standalone_cpp",
869         ":string_utils",
870     ],
873 libc_function(
874     name = "strpbrk",
875     srcs = ["src/string/strpbrk.cpp"],
876     hdrs = ["src/string/strpbrk.h"],
877     deps = [
878         ":__support_common",
879         ":string_utils",
880     ],
883 libc_function(
884     name = "strtok",
885     srcs = ["src/string/strtok.cpp"],
886     hdrs = ["src/string/strtok.h"],
887     deps = [
888         ":__support_common",
889         ":string_utils",
890     ],