[LLVMdev] Pass and return of large objects

Russell Wallace russell.wallace at gmail.com
Tue Mar 2 01:03:21 PST 2010


Oh!

Hmm. I've already decided to implement complex numbers basically the
classic C++ way, as a template. On the bright side, hopefully that
means the LLVM code generators will end up putting them in pairs of
registers. On the downside, I suppose that means I'll be honoring the
x86-64 ABI for complex numbers in the breach rather than the
observance. Is that going to have any horribly bad consequences?

I would be inclined to guess no, the ABI mostly matters when you're
calling libraries to do various kinds of IO/protocol translation, and
those wouldn't normally use complex numbers.

Graphics libraries do use things most other kinds of libraries don't.
Are complex numbers among them? Not that I can remember hearing; I'm
not an expert in that domain.

If I'm painting myself into a corner here - or if it's the case that
this is fine for what I'm doing, but a big potential pitfall for other
people generating x86-64 code in other contexts - someone please point
it out?

On Tue, Mar 2, 2010 at 8:49 AM, Duncan Sands <baldrick at free.fr> wrote:
> Hi Reid,
>
>>> I hadn't realized that, I would've expected complex numbers to be
>>> doable as just a pair of scalar values. What's the fly in the ointment
>>> with C99 complex numbers?
>
> the x86-64 ABI requires complex numbers to be passed *differently* to
> a pair of scalar values.  So if the LLVM code generators were to do the
> lowering, then there would need to be a way to say: this pair of scalars
> is just a pair of scalars - pass it normally; but this other pair of scalars
> is really a complex number - pass it using a different method.  If you take
> a
> pessimistic view, then in order for LLVM to do the lowering then the entire
> C
> type system would somehow have to be injected into the LLVM IR.
>
> Ciao,
>
> Duncan.
>




More information about the llvm-dev mailing list