[LLVMdev] Implementing a complicated VAARG

Andrew Lenharth andrewl at lenharth.org
Tue Apr 3 12:19:37 PDT 2007


On 4/3/07, Nicolas Geoffray <nicolas.geoffray at lip6.fr> wrote:
> A VAARG call requires a lot of computation. Typically the C code for
> va_arg(ap, int)
> is:
>
> int va_arg_gpr(ap_list ap) {
>     int idx = ap->gpr;
>     if (idx < 8) {
>         ap->gpr = idx + 1;
>         return ap->reg_save_area[idx];
>     }
>     else {
>       int res = ap->overflow_arg_area[0];
>       ap->gpr = idx + 1;
>       ap->overflow_arg_area += 4;
>       return res;
>     }
> }

This isn't much more (any more?) complex than Alpha's vaargs.  You can
do it without introducing any new branches with some selects and
generate DAG code directly.

Andrew



More information about the llvm-dev mailing list