Skip to content

Commit

Permalink
test:conv:hltohlbi: Add test for vararg builtins.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jezurko committed Mar 11, 2024
1 parent 0815eb4 commit ad5d04f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/vast/Conversion/FromHL/ToHLBI/varargs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// RUN: %vast-front -vast-emit-mlir=hl %s -o - | %vast-opt --vast-hl-to-hl-builtin | %file-check %s

#include <stdarg.h>

double average(int count, ...)
{
va_list ap;
int j;
double tot = 0;
// CHECK: hlbi.va_start
va_start(ap, count); //Requires the last fixed parameter (to get the address)
for(j=0; j<count; j++)
// CHECK: hl.va_arg_expr
tot+=va_arg(ap, double); //Requires the type to cast to. Increments ap to the next argument.
// CHECK: hlbi.va_end
va_end(ap);
return tot/count;
}

0 comments on commit ad5d04f

Please sign in to comment.