`in` parameters made useful
Petar
Petar
Fri Aug 21 13:59:30 UTC 2020
On Thursday, 20 August 2020 at 20:29:31 UTC, Araq wrote:
> On Thursday, 20 August 2020 at 17:31:17 UTC, IGotD- wrote:
>> This is interesting on a general level as well and true for
>> several programming languages. Let the compiler optimize the
>> parameter passing unless the programmer explicitly ask for a
>> certain way (copy object, pointer/reference etc.). This is
>> very unusual and if you have a language that optimizes the
>> parameter passing by default, please mention it because it
>> would be interesting.
>>
>
> Nim does this and I took the feature from Ada. You can override
> the behavior with pragmas but I've only seen that done for C
> interop, not for optimizations as the compiler always seems to
> get it right.
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`)?
More information about the Digitalmars-d
mailing list