zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.92k stars 6.65k forks source link

xtensa: optimize syscall helper functions #81739

Open dcpleung opened 15 hours ago

dcpleung commented 15 hours ago

The original idea of the syscall helpers is to workaround an issue where the compiler could not correctly model register usage with inline functions. It was supposed to be only used when there are more then 3 arguments to syscalls. However, during the original MMU code development, the helper got expanded to cover "less then 2 arguments syscalls" as a way for debugging syscall handling code and was never removed. So fix that now by limiting the helper for syscalls with more than 3 arguments.

Moreover, instead of using one helper with 6 arguments, now we have separate implementations for both 4 and 5 arguments syscall helpers. Now the compiler does not have to generate code to always handle 6 arguments which saves a few code bytes as there is no need to pass extra zeroes as arguments.

This has been verified to work with xt-clang RI-2022.10.