diff options
author | Quentin Carbonneaux <quentin@c9x.me> | 2022-08-26 10:15:33 +0200 |
---|---|---|
committer | Quentin Carbonneaux <quentin@c9x.me> | 2022-08-31 17:16:29 +0200 |
commit | f5ad580886b2fd759c9d1790268964b3399ee3e2 (patch) | |
tree | cd34517beab16be69f7a79e5606d332453744c88 /tools | |
parent | c8cd2824eae0137505fe46530c3a8e9788ab9a63 (diff) | |
download | roux-f5ad580886b2fd759c9d1790268964b3399ee3e2.tar.gz |
regenerate test/vararg2.ssa
- update the test generation script to match some manual changes - fix some variadic calls to printf - add a test case where an odd number of slots is used on the stack before varargs
Diffstat (limited to 'tools')
-rw-r--r-- | tools/vatest.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/tools/vatest.py b/tools/vatest.py index c9b1bbd..1a1f199 100644 --- a/tools/vatest.py +++ b/tools/vatest.py @@ -7,7 +7,7 @@ from struct import unpack I, D = 'd', 'g' formats = [ - # list of format to tests + # list of formats to test [I], [D], [I,D], @@ -25,7 +25,7 @@ generate = [ # floating point arguments to # test (0, 0), (1, 0), (0, 1), (4, 0), - (0, 6), (5, 7), (10, 10), + (0, 6), (5, 7), (10, 10), (9, 0), ] def mkargs(nargs, type, name): @@ -63,6 +63,7 @@ def genssa(qbeprint, qbecall): def gendriver(): print('# >>> driver') + print('# #include <stdarg.h>') print('# #include <stdio.h>') for fnum, (nia, nfa) in enumerate(generate): @@ -76,6 +77,9 @@ def gendriver(): ) output = '' + print('# int print(char *fmt, va_list *ap) {') + print('# return vprintf(fmt, *ap);'); + print('# }') print('# int main() {') for fnum, (nia, nfa) in enumerate(generate): @@ -113,7 +117,7 @@ qbeprint="""{{ storew {}, %fmtint storew {}, %fmtdbl storew 0, %emptys - %vp =l alloc8 24 + %vp =l alloc8 32 %fmt1 =l add 1, %fmt vastart %vp @loop @@ -126,14 +130,14 @@ qbeprint="""{{ jnz %isg, @casef, @cased @casef %dbl =d vaarg %vp - call $printf(l %fmtdbl, d %dbl, ...) + %r =w call $printf(l %fmtdbl, ..., d %dbl) jmp @loop @cased %int =w vaarg %vp - call $printf(l %fmtint, w %int, ...) + %r =w call $printf(l %fmtint, ..., w %int) jmp @loop @end - call $puts(l %emptys) + %r =w call $puts(l %emptys) ret }} """.format( @@ -143,9 +147,9 @@ qbeprint="""{{ qbecall="""{ @start - %vp =l alloc8 24 + %vp =l alloc8 32 vastart %vp - call $vprintf(l %fmt, l %vp) + %r =w call $print(l %fmt, l %vp) ret } """ |