I'm working on making an AngelScript binding for D with support for D types and functions. D's documentation says that it follows the C ABI for function calls, but in reality the int registers are reversed.
I made a really ugly hack to as_callfunc_x64_gcc.cpp which consists of reversing the order of int register arguments if a DDECL ABI is specified ( https://github.com/KitsunebiGames/angelscript-ddecl/blob/main/source/as_callfunc_x64_gcc.cpp#L449 )
if (callConv == ICC_DDECL ||
callConv == ICC_DDECL_RETURNINMEM ||
callConv == ICC_DDECL_OBJFIRST ||
callConv == ICC_DDECL_OBJFIRST_RETURNINMEM ||
callConv == ICC_DDECL_OBJLAST ||
callConv == ICC_DDECL_OBJLAST_RETURNINMEM) {
// Handle DDECL arguments in a really cursed way
// Can someone fix the D ABI, please????
for ( n = totalArgumentCount-1; ( n >= 0 ) && ( used_int_regs < MAX_CALL_INT_REGISTERS ); n-- )
{
if ( argsType[n] == x64INTARG )
{
argsSet[n] = 1;
tempBuff[idx++] = paramBuffer[n];
used_int_regs++;
}
}
} else {
// The normal way any sane ABI spec would do
for ( n = 0; ( n < totalArgumentCount ) && ( used_int_regs < MAX_CALL_INT_REGISTERS ); n++ )
{
if ( argsType[n] == x64INTARG )
{
argsSet[n] = 1;
tempBuff[idx++] = paramBuffer[n];
used_int_regs++;
}
}
}
Does AngelScript support a less hacky way to add support for these reversed int registers?