arm-trusted-firmware/lib/libc
Boyan Karatotev 34d7f196b4 perf(libc): use builtin implementations where possible
When conditions are right, eg a small memcpy of a known size and
alignment, the compiler may know of a sequence that is optimal for the
given constraints and inline it. If the compiler doesn't find one, it
will emit a call to the generic function (in the libc) which will
implement this in the most generic and unconstrained manner. That
generic function is rarely the most optimal when constraints are known.

So give the compiler a chance to do this. Replace calls to libc
functions that have builtins to the builtin and keep the generic
implementation if it decides to emit a call anyway.

And example of this in action is usage of FEAT_MOPS. When the compiler
is aware of the feature (-march=armv8.8-a) then it will emit the 3 MOPS
instructions instead of calls to our memcpy() and memset()
implementations.

Change-Id: I9860cfada1d941b613ebd4da068e9992c387952e
Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com>
2025-04-04 09:27:33 +01:00
..
aarch32 plat/arm: Introduce and use libc_asm.mk makefile 2020-09-02 16:21:34 +00:00
aarch64 chore: update to use Arm word across TF-A 2023-08-08 15:12:30 +01:00
abort.c chore: update to use Arm word across TF-A 2023-08-08 15:12:30 +01:00
assert.c chore: update to use Arm word across TF-A 2023-08-08 15:12:30 +01:00
exit.c chore: update to use Arm word across TF-A 2023-08-08 15:12:30 +01:00
libc.mk fix(libc): memset inclusion to libc makefiles 2024-02-02 09:49:01 +01:00
libc_asm.mk fix(libc): add memcpy_s source file to libc_asm mk 2024-01-30 12:15:15 +01:00
libc_common.mk feat(lib): implement strnlen secure and strcpy secure function 2025-03-19 12:57:35 +08:00
memchr.c perf(libc): use builtin implementations where possible 2025-04-04 09:27:33 +01:00
memcmp.c perf(libc): use builtin implementations where possible 2025-04-04 09:27:33 +01:00
memcpy.c perf(libc): use builtin implementations where possible 2025-04-04 09:27:33 +01:00
memcpy_s.c perf(libc): use builtin implementations where possible 2025-04-04 09:27:33 +01:00
memmove.c chore: update to use Arm word across TF-A 2023-08-08 15:12:30 +01:00
memrchr.c libc: add memrchr 2019-12-11 08:51:26 +01:00
memset.c perf(libc): use builtin implementations where possible 2025-04-04 09:27:33 +01:00
printf.c feat(libc): add printf support for space padding 2023-11-29 12:48:42 -06:00
putchar.c chore: update to use Arm word across TF-A 2023-08-08 15:12:30 +01:00
puts.c chore: update to use Arm word across TF-A 2023-08-08 15:12:30 +01:00
qsort.c feat(libc): import qsort implementation 2025-02-10 15:21:00 +00:00
snprintf.c feat(libc): add %c to printf/snprintf 2023-05-11 10:32:28 +01:00
strchr.c perf(libc): use builtin implementations where possible 2025-04-04 09:27:33 +01:00
strcmp.c perf(libc): use builtin implementations where possible 2025-04-04 09:27:33 +01:00
strcpy_secure.c feat(lib): implement strnlen secure and strcpy secure function 2025-03-19 12:57:35 +08:00
strlcat.c libc: Import strlcat from FreeBSD project 2020-09-09 13:48:04 -05:00
strlcpy.c libc: Adapt strlcpy to this codebase 2018-11-02 13:41:33 +00:00
strlen.c perf(libc): use builtin implementations where possible 2025-04-04 09:27:33 +01:00
strncmp.c perf(libc): use builtin implementations where possible 2025-04-04 09:27:33 +01:00
strnlen.c chore: update to use Arm word across TF-A 2023-08-08 15:12:30 +01:00
strnlen_secure.c feat(lib): implement strnlen secure and strcpy secure function 2025-03-19 12:57:35 +08:00
strrchr.c perf(libc): use builtin implementations where possible 2025-04-04 09:27:33 +01:00
strtok.c libc: Import strtok_r from FreeBSD project 2020-09-18 11:58:41 -05:00
strtol.c libc: Import strtol from FreeBSD project 2021-02-03 10:36:33 -06:00
strtoll.c libc: Import strtoll from FreeBSD project 2021-02-03 10:36:33 -06:00
strtoul.c libc: Import strtoul from FreeBSD project 2021-02-03 10:36:33 -06:00
strtoull.c libc: Import strtoull from FreeBSD project 2021-02-03 10:36:33 -06:00