questions about x86-64 sys-v abi

@sebastian@jittr.click

Content warning: questions about x86-64 sys-v abi

what's the rationale for the parameter / return value passing registers they chose? more specifically:

- why is rax a return register, but not a parameter register? why not make parameters rax, rdi, rsi, rdx, etc? that way 7 qwords could fit in registers instead of 6. they did it with rdx, so why not rax?

- why only 2 return registers? actually, why not just use the same registers for returns as for params? so the return value would also go rax, rdi, rsi, rdx, etc. is there a downside to that?

i know a lot of the decisions are arbitrary, like exactly which registers are saved and which are clobbered, the order of the parameter registers, etc.. but to me the abi they ended up with feels simultaneously overcomplicated and less powerful than it could be. but i might be might be missing something