D on lm32-CPU: string argument on stack instead of register

Johan j at j.nl
Fri Jul 31 15:30:10 UTC 2020


On Friday, 31 July 2020 at 10:22:20 UTC, Michael Reese wrote:
>
> My question: Is there a way I can tell the D compiler to use 
> registers instead of stack for string arguments, or any other 
> trick to reduce code size while maintaining an ideomatic D 
> codestyle?

A D string is a "slice", which is a struct (pointer + length). 
Depending on the function call ABI, structs are passed in 
registers or on the stack.
On x86, the D calling convention is to put small POD structs in 
registers, similar to the C++ calling convention.
I don't know whether GDC has attributes to change the calling 
convention of functions (besides extern(C/C++/Windows/etc.)), but 
that's where you'd need to look.
Otherwise, file a bug with GDC. Slice arguments are common enough 
to require enregistering them in the D calling convention on your 
lm32 platform.

-Johan



More information about the Digitalmars-d-learn mailing list