Inline assembler in D and LDC, round 2

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Fri Feb 6 05:58:48 PST 2009


Lionello Lunesu wrote:
> 
> "Frits van Bommel" <fvbommel at REMwOVExCAPSs.nl> wrote in message 
> news:gmeqbr$1377$1 at digitalmars.com...
>> LDC on the other hand needs to emit LLVM asm, which requires it to 
>> specify an explicit return value. My approach is a way to extract that 
>> return value from the inline asm, allowing it to emulate DMD behavior 
>> within the LLVM IR.
> 
> Sorry, perhaps I'm missing something: Why should you have to deduct that 
> from the asm? Doesn't the function prototype give enough information? If 
> the function returns "int/uint/...", assume "eax"; if it returns 
> "float/double/..." assume "st(0)", etc....

LLVM IR doesn't know about hardware registers, except when dealing with 
inline asm. So if you need to know the value a hardware register has at 
the end of some inline asm, you need to tell that asm to "return" it 
into a virtual register that you can actually use in regular IR (such as 
returning it from a function).



More information about the Digitalmars-d mailing list