ffi #foreign: C-variadic tail via args: ..T
Trailing `args: ..T` on a #foreign declaration now lowers to the C calling convention's `...` instead of sx-side slice-packing. Drops the per-arity #foreign-shim workaround for callers of variadic C APIs (__android_log_print, printf-family, etc.). Closes issue-0043. - IR: Function.is_variadic on inst.Function; declareFunction drops the variadic param from the IR signature for foreign+variadic decls. - emit_llvm: LLVMFunctionType receives is_var_arg=1 when the flag is set; call lowering passes extras through unchanged. - Lowering: packVariadicCallArgs early-outs for foreign+variadic (no slice-pack); new promoteCVariadicArgs applies C default argument promotion (bool/s8/s16/u8/u16 -> s32, f32 -> f64) to extras past the fixed param count. - Test: examples/ffi-foreign-cvariadic.sx + .c exercise s64/f64/s32 returns through C va_arg over s32/f64/*u8 element types. 134 host + 6 cross tests pass on the WIP-less baseline.
This commit is contained in:
1
tests/expected/ffi-foreign-cvariadic.exit
Normal file
1
tests/expected/ffi-foreign-cvariadic.exit
Normal file
@@ -0,0 +1 @@
|
||||
0
|
||||
5
tests/expected/ffi-foreign-cvariadic.txt
Normal file
5
tests/expected/ffi-foreign-cvariadic.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
sum_ints(3, 10, 20, 30) = 60
|
||||
sum_ints(0) = 0
|
||||
avg_doubles(2) = 2.000000
|
||||
avg_doubles(3) = 2.000000
|
||||
count_args(3 strs) = 3
|
||||
Reference in New Issue
Block a user