From fcdef10dae54d7124aca9ccbefe53baa8e67267d Mon Sep 17 00:00:00 2001 From: Quentin Carbonneaux Date: Mon, 18 Oct 2021 21:04:10 +0200 Subject: make variadic args explicit Some abis, like the riscv one, treat arguments differently depending on whether they are variadic or not. To prepare for the upcomming riscv target, we change the variadic call syntax and give meaning to the location of the '...' marker. # new syntax %ret =w call $f(w %regular, ..., w %variadic) By nature of their abis, the change is backwards compatible for existing targets. --- test/_slow.qbe | 10 +++++----- test/abi5.ssa | 18 +++++++++--------- test/abi6.ssa | 4 ++-- test/echo.ssa | 2 +- test/vararg2.ssa | 28 ++++++++++++++-------------- 5 files changed, 31 insertions(+), 31 deletions(-) (limited to 'test') diff --git a/test/_slow.qbe b/test/_slow.qbe index 2d107ae..a411e41 100644 --- a/test/_slow.qbe +++ b/test/_slow.qbe @@ -3408,7 +3408,7 @@ function $transparent_crc(l %.1, l %.3, w %.5) { %.9 =l copy $.Lstring.93 %.10 =l loadl %.4 %.11 =l loadl %.2 - %.12 =w call $printf(l %.9, l %.10, l %.11, ...) + %.12 =w call $printf(l %.9, ..., l %.10, l %.11) @if_false.679 %.13 =l loadl $crc32_context %.14 =l loadl %.2 @@ -3461,7 +3461,7 @@ function $transparent_crc_bytes(l %.1, w %.3, l %.5, w %.7) { %.28 =l loadl $crc32_context %.29 =l copy 4294967295 %.30 =l xor %.28, %.29 - %.31 =w call $printf(l %.26, l %.27, l %.30, ...) + %.31 =w call $printf(l %.26, ..., l %.27, l %.30) @if_false.687 ret } @@ -3480,7 +3480,7 @@ function $platform_main_end(l %.1, w %.3) { @if_true.690 %.8 =l copy $.Lstring.97 %.9 =l loadl %.2 - %.10 =w call $printf(l %.8, l %.9, ...) + %.10 =w call $printf(l %.8, ..., l %.9) @if_false.691 ret } @@ -35219,7 +35219,7 @@ function w $main(w %.1, l %.3) { %.53 =w loadsw %.5 %.54 =w loadsw %.6 %.55 =w loadsw %.7 - %.56 =w call $printf(l %.52, w %.53, w %.54, w %.55, ...) + %.56 =w call $printf(l %.52, ..., w %.53, w %.54, w %.55) @if_false.1519 @for_cont.1516 %.57 =w loadsw %.7 @@ -35338,7 +35338,7 @@ function w $main(w %.1, l %.3) { @if_true.1524 %.138 =l copy $.Lstring.129 %.139 =w loadsw %.5 - %.140 =w call $printf(l %.138, w %.139, ...) + %.140 =w call $printf(l %.138, ..., w %.139) @if_false.1525 @for_cont.1522 %.141 =w loadsw %.5 diff --git a/test/abi5.ssa b/test/abi5.ssa index edfda4e..1d823b1 100644 --- a/test/abi5.ssa +++ b/test/abi5.ssa @@ -25,41 +25,41 @@ export function $test() { @start %r1 =:st1 call $t1() - %i1 =w call $printf(l $fmt1, l %r1, ...) + %i1 =w call $printf(l $fmt1, ..., l %r1) %r2 =:st2 call $t2() %w2 =w loadw %r2 - %i2 =w call $printf(l $fmt2, w %w2, ...) + %i2 =w call $printf(l $fmt2, ..., w %w2) %r3 =:st3 call $t3() %s3 =s loads %r3 %r34 =l add %r3, 4 %w3 =w loadw %r34 %p3 =d exts %s3 - %i3 =w call $printf(l $fmt3, d %p3, w %w3, ...) + %i3 =w call $printf(l $fmt3, ..., d %p3, w %w3) %r4 =:st4 call $t4() %w4 =w loadw %r4 %r48 =l add 8, %r4 %d4 =d loadd %r48 - %i4 =w call $printf(l $fmt4, w %w4, d %d4, ...) + %i4 =w call $printf(l $fmt4, ..., w %w4, d %d4) %r5 =:st5 call $t5() %s5 =s loads %r5 %d5 =d exts %s5 %r58 =l add %r5, 8 %l5 =l loadl %r58 - %i5 =w call $printf(l $fmt5, d %d5, l %l5, ...) + %i5 =w call $printf(l $fmt5, ..., d %d5, l %l5) %r6 =:st6 call $t6() - %i6 =w call $printf(l $fmt6, l %r6, ...) + %i6 =w call $printf(l $fmt6, ..., l %r6) %r7 =:st7 call $t7() %s7 =s loads %r7 %d71 =d exts %s7 %r78 =l add %r7, 8 %d72 =d loadd %r78 - %i7 =w call $printf(l $fmt7, d %d71, d %d72, ...) + %i7 =w call $printf(l $fmt7, ..., d %d71, d %d72) %r8 =:st8 call $t8() %r84 =l add 4, %r8 @@ -69,14 +69,14 @@ function $test() { %w82 =w loadw %r84 %w83 =w loadw %r88 %w84 =w loadw %r812 - %i8 =w call $printf(l $fmt8, w %w81, w %w82, w %w83, w %w84, ...) + %i8 =w call $printf(l $fmt8, ..., w %w81, w %w82, w %w83, w %w84) %r9 =:st9 call $t9() %r94 =l add 4, %r9 %w9 =w loadw %r9 %s9 =s loads %r94 %d9 =d exts %s9 - %i9 =w call $printf(l $fmt9, w %w9, d %d9, ...) + %i9 =w call $printf(l $fmt9, ..., w %w9, d %d9) ret } diff --git a/test/abi6.ssa b/test/abi6.ssa index 0870031..da2370c 100644 --- a/test/abi6.ssa +++ b/test/abi6.ssa @@ -13,8 +13,8 @@ function $f(:hfa3 %h1, :hfa3 %h2, d %d1, :hfa3 %h3, d %d2) { call $phfa3(:hfa3 %h1) call $phfa3(:hfa3 %h2) call $phfa3(:hfa3 %h3) - call $printf(l $dfmt, d %d1, ...) - call $printf(l $dfmt, d %d2, ...) + call $printf(l $dfmt, ..., d %d1) + call $printf(l $dfmt, ..., d %d2) ret } diff --git a/test/echo.ssa b/test/echo.ssa index 6010986..5e48b0e 100644 --- a/test/echo.ssa +++ b/test/echo.ssa @@ -20,7 +20,7 @@ function w $main(w %argc, l %argv) { @loop2 %sep =w phi @last 10, @nolast 32 %arg =l loadl %av - %r =w call $printf(l %fmt, l %arg, w %sep, ...) + %r =w call $printf(l %fmt, ..., l %arg, w %sep) %av1 =l add %av, 8 %ac1 =w sub %ac, 1 jmp @loop diff --git a/test/vararg2.ssa b/test/vararg2.ssa index 7e85774..0b2eb53 100644 --- a/test/vararg2.ssa +++ b/test/vararg2.ssa @@ -19,11 +19,11 @@ export function $qbeprint0(l %fmt, ...) { jnz %isg, @casef, @cased @casef %dbl =d vaarg %vp - %r =w call $printf(l %fmtdbl, d %dbl, ...) + %r =w call $printf(l %fmtdbl, ..., d %dbl) jmp @loop @cased %int =w vaarg %vp - %r =w call $printf(l %fmtint, w %int, ...) + %r =w call $printf(l %fmtint, ..., w %int) jmp @loop @end %r =w call $puts(l %emptys) @@ -59,11 +59,11 @@ export function $qbeprint1(w %argw0, l %fmt, ...) { jnz %isg, @casef, @cased @casef %dbl =d vaarg %vp - %r =w call $printf(l %fmtdbl, d %dbl, ...) + %r =w call $printf(l %fmtdbl, ..., d %dbl) jmp @loop @cased %int =w vaarg %vp - %r =w call $printf(l %fmtint, w %int, ...) + %r =w call $printf(l %fmtint, ..., w %int) jmp @loop @end %r =w call $puts(l %emptys) @@ -99,11 +99,11 @@ export function $qbeprint2(d %argd0, l %fmt, ...) { jnz %isg, @casef, @cased @casef %dbl =d vaarg %vp - %r =w call $printf(l %fmtdbl, d %dbl, ...) + %r =w call $printf(l %fmtdbl, ..., d %dbl) jmp @loop @cased %int =w vaarg %vp - %r =w call $printf(l %fmtint, w %int, ...) + %r =w call $printf(l %fmtint, ..., w %int) jmp @loop @end %r =w call $puts(l %emptys) @@ -139,11 +139,11 @@ export function $qbeprint3(w %argw0, w %argw1, w %argw2, w %argw3, l %fmt, ...) jnz %isg, @casef, @cased @casef %dbl =d vaarg %vp - %r =w call $printf(l %fmtdbl, d %dbl, ...) + %r =w call $printf(l %fmtdbl, ..., d %dbl) jmp @loop @cased %int =w vaarg %vp - %r =w call $printf(l %fmtint, w %int, ...) + %r =w call $printf(l %fmtint, ..., w %int) jmp @loop @end %r =w call $puts(l %emptys) @@ -179,11 +179,11 @@ export function $qbeprint4(d %argd0, d %argd1, d %argd2, d %argd3, d %argd4, d % jnz %isg, @casef, @cased @casef %dbl =d vaarg %vp - %r =w call $printf(l %fmtdbl, d %dbl, ...) + %r =w call $printf(l %fmtdbl, ..., d %dbl) jmp @loop @cased %int =w vaarg %vp - %r =w call $printf(l %fmtint, w %int, ...) + %r =w call $printf(l %fmtint, ..., w %int) jmp @loop @end %r =w call $puts(l %emptys) @@ -219,11 +219,11 @@ export function $qbeprint5(w %argw0, w %argw1, w %argw2, w %argw3, w %argw4, d % jnz %isg, @casef, @cased @casef %dbl =d vaarg %vp - %r =w call $printf(l %fmtdbl, d %dbl, ...) + %r =w call $printf(l %fmtdbl, ..., d %dbl) jmp @loop @cased %int =w vaarg %vp - %r =w call $printf(l %fmtint, w %int, ...) + %r =w call $printf(l %fmtint, ..., w %int) jmp @loop @end %r =w call $puts(l %emptys) @@ -259,11 +259,11 @@ export function $qbeprint6(w %argw0, w %argw1, w %argw2, w %argw3, w %argw4, w % jnz %isg, @casef, @cased @casef %dbl =d vaarg %vp - %r =w call $printf(l %fmtdbl, d %dbl, ...) + %r =w call $printf(l %fmtdbl, ..., d %dbl) jmp @loop @cased %int =w vaarg %vp - %r =w call $printf(l %fmtint, w %int, ...) + %r =w call $printf(l %fmtint, ..., w %int) jmp @loop @end %r =w call $puts(l %emptys) -- cgit 1.4.1