Walter Bright wrote:
Frits van Bommel wrote:
His approach depends on DMD directly emitting x86 machine code, so it can just emit 'RET' and be done with it.

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.

Ok, so why not, for a function that returns an int, simply have the compiler silently tack on the LLVM equivalent of "return EAX"?

Because LLVM doesn't allow specification of hardware registers in the IR. Everything must be a virtual register. The way I proposed LDC implement this is basically to tell the inline-asm IR "Put EAX in %virtual-eax" and to then return that register. It will in all likelyhood have the same effect though, assuming a tiny bit of optimization and a minimally competent register allocator.

Reply via email to