2003-05-08 03:46:51 +00:00
|
|
|
; Demonstrate all of the variable argument handling intrinsic functions plus
|
|
|
|
; the va_arg instruction.
|
2003-05-08 02:39:37 +00:00
|
|
|
|
2003-05-08 03:46:51 +00:00
|
|
|
implementation
|
|
|
|
declare void %llvm.va_start(sbyte**, ...)
|
|
|
|
declare void %llvm.va_copy(sbyte**, sbyte*)
|
|
|
|
declare void %llvm.va_end(sbyte**)
|
2003-05-08 02:39:37 +00:00
|
|
|
|
|
|
|
int %test(int %X, ...) {
|
|
|
|
%ap = alloca sbyte*
|
2003-05-08 03:46:51 +00:00
|
|
|
%aq = alloca sbyte*
|
|
|
|
call void (sbyte**, ...)* %llvm.va_start(sbyte** %ap, int %X)
|
|
|
|
%apv = load sbyte** %ap
|
|
|
|
call void %llvm.va_copy(sbyte** %aq, sbyte* %apv)
|
|
|
|
call void %llvm.va_end(sbyte** %aq)
|
|
|
|
|
2003-05-08 02:39:37 +00:00
|
|
|
%tmp = va_arg sbyte** %ap, int
|
2003-05-08 03:46:51 +00:00
|
|
|
|
|
|
|
call void %llvm.va_end(sbyte** %ap)
|
2003-05-08 02:39:37 +00:00
|
|
|
ret int %tmp
|
|
|
|
}
|