On Mon, Mar 1, 2010 at 7:39 PM, Reid Kleckner <rnk at mit.edu> wrote:> IIRC they lower it themselves, doing whatever the ABI says they > should, which is usually adding a hidden sret parameter to the > function once you get beyond small structs.Okay, so we seem to be saying sret or suchlike is how you pass and return large objects by value in LLVM. What exactly counts as large? As I understand it, the largest integers correctly handled as first-class values are the size of two pointers, i.e. usually either 64 or 128 bits. Is the same true of structs?> It'd be nice to move some > of that logic back into LLVM, but it's tricky because C99 says things > about complex numbers which requires special frontend type knowledge > that LLVM doesn't have.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?> I'm just echoing previous discussion, and you can probably get a more > reliable answer by finding the original discussion in the archives.I don't suppose you've any idea what search keywords might work?
On Mon, Mar 1, 2010 at 8:34 PM, Russell Wallace <russell.wallace at gmail.com> wrote:>> It'd be nice to move some >> of that logic back into LLVM, but it's tricky because C99 says things >> about complex numbers which requires special frontend type knowledge >> that LLVM doesn't have. > > 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?I don't really know, I've just remember that it's been brought out before as one of the difficulties of fully supporting passing and returning large structs by value. Hopefully someone more knowledgeable can answer this question?>> I'm just echoing previous discussion, and you can probably get a more >> reliable answer by finding the original discussion in the archives. > > I don't suppose you've any idea what search keywords might work?I searched "sret" which found most of the discussion. Kenneth Uildricks wrote the support for lowering large struct returns on x86 to a hidden sret parameter in accordance with the x86 ABI, but no one has stepped forward to add support for other targets. Reid
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.