`in` parameters made useful
Araq
rumpf_a at web.de
Fri Aug 21 18:10:02 UTC 2020
On Friday, 21 August 2020 at 13:59:30 UTC, Petar Kirov
[ZombineDev] wrote:
> Interesting, how does it work? As mentioned previously, the
> issue with choosing by-val vs by-ref passing solely based on
> the type is that it doesn't take into consideration the ABI and
> how many registers are available. E.g. if you have more than X
> parameters some will need to be spilled on the stack anyway
> (even if they can fit in a GPR).
>
> Can the Nim compiler (I'm guessing `extccomp`) query the C/C++
> compiler backend for e.g. the number of registers available for
> parameters? Or you have this logic built into the frontend (say
> `ccgtypes`)?
It's built into cctypes indeed. The logic is mostly "pass by
pointer if sizeof(T) > 3 machine words". ABI and registers are
not relevant all that much, what you want to prevent are copies
of large sizes.
More information about the Digitalmars-d
mailing list