Calling Conventions, function prologs and epilogs.

How/where are function prologs and epilogs generated, is it bespoke C++ code or TableGen generated ?

If someone could point me in the right direction please.

Many thanks in advance,

Aaron

Aaron Gray wrote:

How/where are function prologs and epilogs generated, is it bespoke C++ code or TableGen generated ?

Each target seems to define a RegisterInfo::emitPrologue and RegisterInfo::emitEpilog function that is called by the lib/CodeGen/PrologueEpilogueInserter.cpp transformation.

Hope this helps,
Luke

Hello, Aaron

How/where are function prologs and epilogs generated, is it bespoke C++ code
or TableGen generated ?

If someone could point me in the right direction please.

Calling convention is really-really far from prologue/epilogue emission :slight_smile: So:

1. Calling conventions
Partly tablegen / partly C++ code. Look for
CodeGen/SelectionDAG/CallingConvLower.cpp,
Target/X86/X86CallingConv.td and around. Usually this code is run
during different phases of sdag lowering.

2. Prologue / epilogue.
Pure C++ code. Look into CodeGen/PrologEpilogInserter.cpp (quite
obviously, right?) with bunch of target-specialized hooks, for
example, ones located in Target/X86/X86RegisterInfo.cpp. Information
about this is needed on different stages, some - even before regalloc,
some - in the late end of the codegen.

Hope this will help.

Yes, great. One other question. AFAICS this does not allow specialization say for a new Windows platform (Not MinGW or Cygwin) /Target to produce different code from X86 Linux.

Thanks,

Aaron

You would add a new Subtarget to do this. That will affect a fair amount of code but it should all be in Target/X86.

Yes, I see now. Thanks,

Aaron