On 07/07/2023 00:27, André Albergaria Coelho via Gcc wrote:
What if the user chooses in own ABI, say specifying a config file like
My abi
" Parameters = pushed in stack"
say
gcc -abi "My abi" some.c -o some
what would be the problems of specifying an ABI?? would that improve the
usage of user? less complex / more
simpler for user (say user is used to code asm in a way)
You can fiddle things a bit, using the -ffixed-reg, -fcall-used-reg and
-fcall-saved-reg flags:
<https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html>
This is almost certainly a bad idea for most situations - you really
have to have a special niche case to make it worth doing. The register
allocation algorithms in GCC are complex, and I would expect changing
these settings would give you less efficient results. And of course it
will mess up all calls to any code compiled with different settings -
such as library code.
A far better solution is for the user who is used to coding in assembly,
to get used to coding in C, C++, or other languages supported by GCC.
If you really need some assembly, as happens occasionally, then learn
about GCC's extended syntax inline assembly. That lets GCC worry about
details such as register allocation and operands, so that your assembly
is minimal, and allows the assembly to work well along with the compiler
optimisation.
If you have legacy assembly functions that are written to a non-standard
calling convention, write a thunk to translate as necessary.