code generation for variadic function

Hi All,

I am trying to understand how a back-end generates code for a function that has variable number of arguments. I would also to like to know what changes do i have to do to the corresponding ISAs when a call to such a function is made? Any pointers or documentation in this regard is greatly appreciated.

Usually, calling a variadic function doesn't require doing anything
special; you can use CCIfNotVarArg etc. in the for most
of that sort of thing, although a few targets require doing a bit more
(like x86-64 requires setting AL depending on the number of FP
registers used by the call).

For defining a vararg function, you'll probably need to mess with the
frontend hooks for va_arg (lib/CodeGen/TargetInfo.cpp for clang), and
you'll need to implement custom hooks for ISD::VASTART. Beyond that,
it's very dependent on how your target actually defines the constructs
in question.