[LLVMdev] struct passing on X86-64

Nick Lewycky nicholas at mxc.ca
Sun Jun 12 13:17:54 PDT 2011


David A. Greene wrote:
> Duncan Sands<baldrick at free.fr>  writes:
>
>>> Yep.  There are lots of corner cases that the frontend MUST handle
>>> because LLVM does not have the necessary infrastructure.
>>
>> I think it's more like: because LLVM doesn't have the necessary information.
>
> True.
>
>> Due to LLVM using structural equivalence, all kinds of types that are
>> different in the original language end up being the same type in LLVM.
>> Chris once explained to me, IIRC, that the ABI is defined in terms of
>> the original language types, and unfortunately some ABI's require
>> different handling for types that are structurally equivalent.
>
> Just so I understand this better, for which ABIs is this the case?  It's
> not for x86_64.  ARM, perhaps?
>
>> See PR4246 for a plan to have generic helper codes for ABI lowering.
>
> It seems a bit complicated to me.  Wouldn't it be simpler to just encode
> the language type information in metadata, or, if metadata isn't
> appropriate because it can be dropped, in some language information
> piece within Type?  Then the target ABI stuff can know exactly what to
> do and we won't have various other pieces all trying to figure out the
> same stuff.

Why should the backends know about the frontend language? It seems 
sensible to me that if I create a new language and a new ABI for my 
language then I can expect to need to teach the backend about my new ABI.

We already have the default ABI for a target and the per-function 
calling conventions. Let's assume that neither of those are good choices 
for solving my problem because the ABI matches the default with only a 
few special cases. We could add ABI notes to the llvm::Function which 
specify that parameter 3 is an arm-abi-name "foo-style-passing", and the 
ARM backend would have to be taught how to handle that. (It would also 
be nice if TargetData could tell you whether a given ABI note applies to 
your current target.)

What's nice about this is that separates the concerns of lowering the IR 
and the workings of the ABI. What's not so hot is that now we'll have to 
standardize these notes in LangRef.

That's orthogonal to the concern of PR4246 which talks about providing a 
generic layer for lowering from the C type system to the ABI.

Does this sound like a sensible start?

Nick



More information about the llvm-dev mailing list