[cfe-dev] Struct parameters being converted to other types

Tim Northover t.p.northover at gmail.com
Tue Jan 15 10:35:27 PST 2013


> Is there any documentation on implementing an ABI?

Not really. Mostly you have a document which lays down precisely which
registers and stack slots any type should be passed in (for example
the AArch64 one is at
http://infocenter.arm.com/help/topic/com.arm.doc.ihi0055a/IHI0055A_aapcs64.pdf).
You then hammer out a compromise where Clang sends enough information
along with the arguments that the LLVM code can make the right choices
without itself being too complicated.

Your situation is a little different though. It sounds like your goal
is to make these ABI bits as simple as possible and cope with the
fallout elsewhere. In fact, it looks like you might be able to make
use of the existing definitions in the DefaultABIInfo class. It seems
to take care of the places I know dragons exist.

> Would an ABI have to be implemented for each supported
> OS / architecture? I'm trying to estimate how long this would take.

In principle just one could work, and then be reused. You'd have to
work through any backend bugs coming from emitting slightly odd code
in each case, of course.

I'll just point out again that taking route will divorce you from any
support the OS or its libraries could provide: there will be no
printf, no fopen, no nothing unless you carefully wrap them up in
functions that use your new ABI.

Tim.



More information about the cfe-dev mailing list