From 67f611fbef3cf16162867bdf83cb9c8a051dac4a Mon Sep 17 00:00:00 2001 From: Quentin Carbonneaux Date: Thu, 3 Mar 2016 11:55:13 -0500 Subject: testbed is now functional I would like to make sure some _ tests are passing, however I have to think of a nice way to grab debug output and compare it nicely. Some require NReg == 3, that is a pain in the ass. Maybe they can be changed to work for the full register set. --- lisc/Makefile | 4 +++- lisc/test/_alt.ssa | 25 +++++++++++++++++++++++++ lisc/test/_dragon.ssa | 33 +++++++++++++++++++++++++++++++++ lisc/test/_fix1.ssa | 15 +++++++++++++++ lisc/test/_fix2.ssa | 15 +++++++++++++++ lisc/test/_fix3.ssa | 20 ++++++++++++++++++++ lisc/test/_fix4.ssa | 27 +++++++++++++++++++++++++++ lisc/test/_live.ssa | 21 +++++++++++++++++++++ lisc/test/_rpo.ssa | 12 ++++++++++++ lisc/test/_spill1.ssa | 22 ++++++++++++++++++++++ lisc/test/_spill2.ssa | 22 ++++++++++++++++++++++ lisc/test/_spill3.ssa | 24 ++++++++++++++++++++++++ lisc/test/align.ssa | 6 ++++++ lisc/test/alt.ssa | 25 ------------------------- lisc/test/collatz.ssa | 6 ++++++ lisc/test/cprime.ssa | 10 ++++------ lisc/test/cup.ssa | 2 +- lisc/test/dark.ssa | 6 ++++++ lisc/test/double.ssa | 6 ++++++ lisc/test/dragon.ssa | 33 --------------------------------- lisc/test/echo.ssa | 4 ++++ lisc/test/eucl.ssa | 6 ++++++ lisc/test/euclc.ssa | 4 ++++ lisc/test/fix1.ssa | 15 --------------- lisc/test/fix2.ssa | 15 --------------- lisc/test/fix3.ssa | 20 -------------------- lisc/test/fix4.ssa | 27 --------------------------- lisc/test/go.sh | 13 +++++-------- lisc/test/live.ssa | 21 --------------------- lisc/test/loop.ssa | 11 +++++++++-- lisc/test/max.ssa | 6 ++++++ lisc/test/prime.ssa | 6 ++++++ lisc/test/puts10.ssa | 15 ++++++++++++++- lisc/test/rpo.ssa | 12 ------------ lisc/test/spill.ssa | 22 ---------------------- lisc/test/spill1.ssa | 22 ---------------------- lisc/test/spill2.ssa | 24 ------------------------ lisc/test/sum.ssa | 11 +++++++++++ 38 files changed, 333 insertions(+), 255 deletions(-) create mode 100644 lisc/test/_alt.ssa create mode 100644 lisc/test/_dragon.ssa create mode 100644 lisc/test/_fix1.ssa create mode 100644 lisc/test/_fix2.ssa create mode 100644 lisc/test/_fix3.ssa create mode 100644 lisc/test/_fix4.ssa create mode 100644 lisc/test/_live.ssa create mode 100644 lisc/test/_rpo.ssa create mode 100644 lisc/test/_spill1.ssa create mode 100644 lisc/test/_spill2.ssa create mode 100644 lisc/test/_spill3.ssa delete mode 100644 lisc/test/alt.ssa delete mode 100644 lisc/test/dragon.ssa delete mode 100644 lisc/test/fix1.ssa delete mode 100644 lisc/test/fix2.ssa delete mode 100644 lisc/test/fix3.ssa delete mode 100644 lisc/test/fix4.ssa delete mode 100644 lisc/test/live.ssa delete mode 100644 lisc/test/rpo.ssa delete mode 100644 lisc/test/spill.ssa delete mode 100644 lisc/test/spill1.ssa delete mode 100644 lisc/test/spill2.ssa diff --git a/lisc/Makefile b/lisc/Makefile index 560fd4f..b9c3c0b 100644 --- a/lisc/Makefile +++ b/lisc/Makefile @@ -8,8 +8,10 @@ $(BIN): $(OBJ) $(OBJ): lisc.h -.PHONY: clean syndoc +.PHONY: clean test syndoc clean: rm -f $(BIN) $(OBJ) +test: $(BIN) + test/go.sh all syndoc: unison -auto doc ssh://qcar@h/data/d/ssa-doc diff --git a/lisc/test/_alt.ssa b/lisc/test/_alt.ssa new file mode 100644 index 0000000..3f89e5e --- /dev/null +++ b/lisc/test/_alt.ssa @@ -0,0 +1,25 @@ +# an example with reducible control +# flow graph that exposes poor +# handling of looping constructs + +function $test() { +@start + %ten =w copy 10 + %dum =w copy 0 # dummy live-through temporary +@loop + %alt =w phi @start 0, @left %alt1, @right %alt1 + %cnt =w phi @start 100, @left %cnt, @right %cnt1 + %alt1 =w sub 1, %alt + jnz %alt1, @right, @left +@left + %x =w phi @loop 10, @left %x1 + %x1 =w sub %x, 1 + %z =w copy %x + jnz %z, @left, @loop +@right + %cnt1 =w sub %cnt, %ten + jnz %cnt1, @loop, @end +@end + %ret =w add %cnt, %dum + ret +} diff --git a/lisc/test/_dragon.ssa b/lisc/test/_dragon.ssa new file mode 100644 index 0000000..b169e1b --- /dev/null +++ b/lisc/test/_dragon.ssa @@ -0,0 +1,33 @@ +# a moderately complex test for +# dominators computation from +# the dragon book +# because branching is limited to +# two, I had to split some blocks + +function $dragon() { +@start +@b1 + jnz 0, @b2, @b3 +@b2 + jmp @b3 +@b3 + jmp @b4.1 +@b4.1 + jnz 0, @b3, @b4.2 +@b4.2 + jnz 0, @b5, @b6 +@b5 + jmp @b7 +@b6 + jmp @b7 +@b7 + jnz 0, @b8.1, @b4.1 +@b8.1 + jnz 0, @b3, @b8.2 +@b8.2 + jnz 0, @b9, @b10 +@b9 + jmp @b1 +@b10 + jmp @b7 +} diff --git a/lisc/test/_fix1.ssa b/lisc/test/_fix1.ssa new file mode 100644 index 0000000..e89307f --- /dev/null +++ b/lisc/test/_fix1.ssa @@ -0,0 +1,15 @@ +function $test() { +@start + %x =w copy 1 +@loop + jnz %x, @noz, @isz +@noz + %x =w copy 0 + jmp @end +@isz + %x =w copy 1 + jmp @loop +@end + %z =w add 10, %x + ret +} diff --git a/lisc/test/_fix2.ssa b/lisc/test/_fix2.ssa new file mode 100644 index 0000000..89f236d --- /dev/null +++ b/lisc/test/_fix2.ssa @@ -0,0 +1,15 @@ +function $test() { +@start + %x =w copy 1 +@loop + jnz %x, @noz, @isz +@noz + %x =w copy 0 + jnz %x, @loop, @end +@isz + %x =w copy 1 + jmp @loop +@end + %z =w add 10, %x + ret +} diff --git a/lisc/test/_fix3.ssa b/lisc/test/_fix3.ssa new file mode 100644 index 0000000..283e5a1 --- /dev/null +++ b/lisc/test/_fix3.ssa @@ -0,0 +1,20 @@ +function w $test() { +@start + %x =w copy 100 + %s =w copy 0 +@l + %c =w cslew %x, 10 + jnz %c, @a, @b +@a + %s =w add %s, %x + %x =w sub %x, 1 + jmp @c +@b + %s =w sub %s, %x + jmp @c +@c + %x =w sub %x, 1 + jnz %x, @l, @end +@end + ret %s +} diff --git a/lisc/test/_fix4.ssa b/lisc/test/_fix4.ssa new file mode 100644 index 0000000..181768d --- /dev/null +++ b/lisc/test/_fix4.ssa @@ -0,0 +1,27 @@ +function $test() { +@start + %x =w copy 3 + %n =w copy 2 +@loop + %c =w ceqw %n, 10000 + jnz %c, @end, @next +@next + %t =w copy 3 + %x =w add %x, 2 +@tloop + %s =w mul %t, %t + %c =w csgtw %s, %x + jnz %c, @prime, @test +@test + %r =w rem %x, %t + jnz %r, @tnext, @loop +@tnext + %t =w add %t, 2 + jmp @tloop +@prime + %n =w add %n, 1 + jmp @loop +@end + storew %x, $a + ret +} diff --git a/lisc/test/_live.ssa b/lisc/test/_live.ssa new file mode 100644 index 0000000..fce4cb9 --- /dev/null +++ b/lisc/test/_live.ssa @@ -0,0 +1,21 @@ +# this control flow graph is irreducible +# yet, we expecet the liveness analysis +# to work properly and make %x live in +# the block @left +# +# nothing should ever be live at the entry + +function $test() { +@start + %b =w copy 0 + %x =w copy 10 + jnz 0, @loop, @left +@left + jmp @inloop +@loop + %x1 =w add %x, 1 +@inloop + %b1 =w add %b, 1 +@endloop + jmp @loop +} diff --git a/lisc/test/_rpo.ssa b/lisc/test/_rpo.ssa new file mode 100644 index 0000000..a10c6b1 --- /dev/null +++ b/lisc/test/_rpo.ssa @@ -0,0 +1,12 @@ +function $test() { +@start + jmp @foo +@baz + jnz 1, @end, @foo +@bar + jmp @end +@foo + jnz 0, @bar, @baz +@end + ret +} diff --git a/lisc/test/_spill1.ssa b/lisc/test/_spill1.ssa new file mode 100644 index 0000000..df5e4c2 --- /dev/null +++ b/lisc/test/_spill1.ssa @@ -0,0 +1,22 @@ +# test with NReg == 3 +# there must be a spill +# happening on %c +# +# if you replace the sub +# by an add or comment +# the two marked lines +# there should be no +# spill +# + +function $test() { +@start + %f =w copy 0 # here + %b =w copy 1 + %c =w copy 2 + %a =w sub %b, %c + %d =w copy %b + %e =w copy %f # and there + %g =w copy %a + ret +} diff --git a/lisc/test/_spill2.ssa b/lisc/test/_spill2.ssa new file mode 100644 index 0000000..d462d0b --- /dev/null +++ b/lisc/test/_spill2.ssa @@ -0,0 +1,22 @@ +# stupid spilling test + +function $test() { +@start + %x1 =w copy 10 + %x2 =w add %x1, %x1 + %x3 =w sub %x2, %x1 + %x4 =w add %x3, %x1 + %x5 =w sub %x4, %x1 + %x6 =w add %x5, %x1 + %x7 =w sub %x6, %x1 + %x8 =w add %x7, %x1 + %x9 =w sub %x8, %x8 + %x10 =w add %x9, %x7 + %x11 =w sub %x10, %x6 + %x12 =w add %x11, %x5 + %x13 =w sub %x12, %x4 + %x14 =w add %x13, %x3 + %x15 =w sub %x14, %x2 + %x16 =w add %x15, %x1 + ret +} diff --git a/lisc/test/_spill3.ssa b/lisc/test/_spill3.ssa new file mode 100644 index 0000000..cdfda2d --- /dev/null +++ b/lisc/test/_spill3.ssa @@ -0,0 +1,24 @@ +# make sure comparisons +# never get their two +# operands in memory +# run with NReg == 3, or +# adapt it! + +function $test() { +@start + %a =w loadw $a + %b =w loadw $a + +@loop + %c =w phi @start 0, @loop %f + %d =w phi @start 0, @loop %g + %e =w phi @start 0, @loop %h + %f =w add %c, %d + %g =w add %c, %e + %h =w add %e, %d + %x =w cslew %a, %b + jnz %x, @loop, @end + +@end + ret +} diff --git a/lisc/test/align.ssa b/lisc/test/align.ssa index 9ac3f60..84d1fb9 100644 --- a/lisc/test/align.ssa +++ b/lisc/test/align.ssa @@ -8,3 +8,9 @@ function $test() { storew %n, $a ret } + +# >>> driver +# extern void test(void); +# int a; +# int main() { test(); return !(a == 8 || a == -8); } +# <<< diff --git a/lisc/test/alt.ssa b/lisc/test/alt.ssa deleted file mode 100644 index 3f89e5e..0000000 --- a/lisc/test/alt.ssa +++ /dev/null @@ -1,25 +0,0 @@ -# an example with reducible control -# flow graph that exposes poor -# handling of looping constructs - -function $test() { -@start - %ten =w copy 10 - %dum =w copy 0 # dummy live-through temporary -@loop - %alt =w phi @start 0, @left %alt1, @right %alt1 - %cnt =w phi @start 100, @left %cnt, @right %cnt1 - %alt1 =w sub 1, %alt - jnz %alt1, @right, @left -@left - %x =w phi @loop 10, @left %x1 - %x1 =w sub %x, 1 - %z =w copy %x - jnz %z, @left, @loop -@right - %cnt1 =w sub %cnt, %ten - jnz %cnt1, @loop, @end -@end - %ret =w add %cnt, %dum - ret -} diff --git a/lisc/test/collatz.ssa b/lisc/test/collatz.ssa index 3e9dc41..373ecac 100644 --- a/lisc/test/collatz.ssa +++ b/lisc/test/collatz.ssa @@ -53,3 +53,9 @@ function $test() { storew %cmax, $a ret } + +# >>> driver +# extern void test(void); +# int a; +# int main() { test(); return !(a == 178); } +# <<< diff --git a/lisc/test/cprime.ssa b/lisc/test/cprime.ssa index adc5e8a..af0f652 100644 --- a/lisc/test/cprime.ssa +++ b/lisc/test/cprime.ssa @@ -2,7 +2,7 @@ # compiler from the C program # following in comments -function $test() { +function w $main() { @start %v0 =l alloc8 4 %v1 =l alloc8 4 @@ -64,13 +64,11 @@ function $test() { %v26 =w cnew %v25, 104743 jnz %v26, @L13, @L7 @L13 - storew 1, $a - ret + ret 1 @L7 - storew 0, $a - ret + ret 0 @end - ret + ret 0 } # int diff --git a/lisc/test/cup.ssa b/lisc/test/cup.ssa index 96649e6..013394f 100644 --- a/lisc/test/cup.ssa +++ b/lisc/test/cup.ssa @@ -12,6 +12,6 @@ function $test() { } # >>> driver -# extern void test(); +# extern void test(void); # int main() { test(); return 0; } # <<< diff --git a/lisc/test/dark.ssa b/lisc/test/dark.ssa index b9ee038..5046af3 100644 --- a/lisc/test/dark.ssa +++ b/lisc/test/dark.ssa @@ -22,3 +22,9 @@ function $test(:magic %p) { @fin ret } + +# >>> driver +# extern void test(void); +# int a = 2; +# int main() { test(); return !(a == 5); } +# <<< diff --git a/lisc/test/double.ssa b/lisc/test/double.ssa index 576ed04..d885d28 100644 --- a/lisc/test/double.ssa +++ b/lisc/test/double.ssa @@ -16,3 +16,9 @@ function $test() { storew %i2, $a ret } + +# >>> driver +# extern void test(void); +# int a; +# int main() { test(); return !(a == 55); } +# <<< diff --git a/lisc/test/dragon.ssa b/lisc/test/dragon.ssa deleted file mode 100644 index b169e1b..0000000 --- a/lisc/test/dragon.ssa +++ /dev/null @@ -1,33 +0,0 @@ -# a moderately complex test for -# dominators computation from -# the dragon book -# because branching is limited to -# two, I had to split some blocks - -function $dragon() { -@start -@b1 - jnz 0, @b2, @b3 -@b2 - jmp @b3 -@b3 - jmp @b4.1 -@b4.1 - jnz 0, @b3, @b4.2 -@b4.2 - jnz 0, @b5, @b6 -@b5 - jmp @b7 -@b6 - jmp @b7 -@b7 - jnz 0, @b8.1, @b4.1 -@b8.1 - jnz 0, @b3, @b8.2 -@b8.2 - jnz 0, @b9, @b10 -@b9 - jmp @b1 -@b10 - jmp @b7 -} diff --git a/lisc/test/echo.ssa b/lisc/test/echo.ssa index c67434f..d3c8a25 100644 --- a/lisc/test/echo.ssa +++ b/lisc/test/echo.ssa @@ -26,3 +26,7 @@ function w $main(w %argc, l %argv) { @end ret 0 } + +# >>> output +# a b c +# <<< diff --git a/lisc/test/eucl.ssa b/lisc/test/eucl.ssa index 527cfcf..f50fd2c 100644 --- a/lisc/test/eucl.ssa +++ b/lisc/test/eucl.ssa @@ -16,3 +16,9 @@ function $test() { storew %a, $a ret } + +# >>> driver +# extern void test(void); +# int a; +# int main() { test(); return !(a == 1); } +# <<< diff --git a/lisc/test/euclc.ssa b/lisc/test/euclc.ssa index b684fe7..c76db2f 100644 --- a/lisc/test/euclc.ssa +++ b/lisc/test/euclc.ssa @@ -23,3 +23,7 @@ function w $test() { ret %t13 } +# >>> driver +# extern int test(void); +# int main() { return !(test() == 1); } +# <<< diff --git a/lisc/test/fix1.ssa b/lisc/test/fix1.ssa deleted file mode 100644 index e89307f..0000000 --- a/lisc/test/fix1.ssa +++ /dev/null @@ -1,15 +0,0 @@ -function $test() { -@start - %x =w copy 1 -@loop - jnz %x, @noz, @isz -@noz - %x =w copy 0 - jmp @end -@isz - %x =w copy 1 - jmp @loop -@end - %z =w add 10, %x - ret -} diff --git a/lisc/test/fix2.ssa b/lisc/test/fix2.ssa deleted file mode 100644 index 89f236d..0000000 --- a/lisc/test/fix2.ssa +++ /dev/null @@ -1,15 +0,0 @@ -function $test() { -@start - %x =w copy 1 -@loop - jnz %x, @noz, @isz -@noz - %x =w copy 0 - jnz %x, @loop, @end -@isz - %x =w copy 1 - jmp @loop -@end - %z =w add 10, %x - ret -} diff --git a/lisc/test/fix3.ssa b/lisc/test/fix3.ssa deleted file mode 100644 index 283e5a1..0000000 --- a/lisc/test/fix3.ssa +++ /dev/null @@ -1,20 +0,0 @@ -function w $test() { -@start - %x =w copy 100 - %s =w copy 0 -@l - %c =w cslew %x, 10 - jnz %c, @a, @b -@a - %s =w add %s, %x - %x =w sub %x, 1 - jmp @c -@b - %s =w sub %s, %x - jmp @c -@c - %x =w sub %x, 1 - jnz %x, @l, @end -@end - ret %s -} diff --git a/lisc/test/fix4.ssa b/lisc/test/fix4.ssa deleted file mode 100644 index 181768d..0000000 --- a/lisc/test/fix4.ssa +++ /dev/null @@ -1,27 +0,0 @@ -function $test() { -@start - %x =w copy 3 - %n =w copy 2 -@loop - %c =w ceqw %n, 10000 - jnz %c, @end, @next -@next - %t =w copy 3 - %x =w add %x, 2 -@tloop - %s =w mul %t, %t - %c =w csgtw %s, %x - jnz %c, @prime, @test -@test - %r =w rem %x, %t - jnz %r, @tnext, @loop -@tnext - %t =w add %t, 2 - jmp @tloop -@prime - %n =w add %n, 1 - jmp @loop -@end - storew %x, $a - ret -} diff --git a/lisc/test/go.sh b/lisc/test/go.sh index 7082db0..7326ecc 100755 --- a/lisc/test/go.sh +++ b/lisc/test/go.sh @@ -1,8 +1,5 @@ #!/bin/sh -QBE=./lisc -CC=cc - TMP=/tmp/qbe.zzzz DRV=$TMP.c @@ -44,7 +41,7 @@ once() { printf "$T... " - if ! $QBE $T -o $ASM 2> /dev/null + if ! ./lisc $T -o $ASM 2> /dev/null then echo "[qbe fail]" return 1 @@ -60,7 +57,7 @@ once() { LNK="$ASM" fi - if ! $CC -o $BIN $LNK + if ! cc -o $BIN $LNK then echo "[cc fail]" return 1 @@ -68,11 +65,11 @@ once() { if test -s $OUT then - $BIN | diff - $OUT > /dev/null + $BIN a b c | diff - $OUT > /dev/null RET=$? REASON="output" else - $BIN + $BIN a b c RET=$? REASON="return" fi @@ -92,7 +89,7 @@ once() { case $1 in "all") F=0 - for T in test/* + for T in test/[!_]*.ssa do once $T F=`expr $F + $?` diff --git a/lisc/test/live.ssa b/lisc/test/live.ssa deleted file mode 100644 index fce4cb9..0000000 --- a/lisc/test/live.ssa +++ /dev/null @@ -1,21 +0,0 @@ -# this control flow graph is irreducible -# yet, we expecet the liveness analysis -# to work properly and make %x live in -# the block @left -# -# nothing should ever be live at the entry - -function $test() { -@start - %b =w copy 0 - %x =w copy 10 - jnz 0, @loop, @left -@left - jmp @inloop -@loop - %x1 =w add %x, 1 -@inloop - %b1 =w add %b, 1 -@endloop - jmp @loop -} diff --git a/lisc/test/loop.ssa b/lisc/test/loop.ssa index 876b1b0..4877db9 100644 --- a/lisc/test/loop.ssa +++ b/lisc/test/loop.ssa @@ -5,12 +5,19 @@ function $test() { @start @loop - %s =w phi @start 100, @loop %s1 - %n =w phi @start 0, @loop %n1 + %s =w phi @start 0, @loop %s1 + %n =w phi @start 100, @loop %n1 %n1 =w sub %n, 1 %s1 =w add %s, %n jnz %n1, @loop, @end @end + storew %s1, $a ret } + +# >>> driver +# extern void test(void); +# int a; +# int main() { test(); return !(a == 5050); } +# <<< diff --git a/lisc/test/max.ssa b/lisc/test/max.ssa index 91d4358..547e9d4 100644 --- a/lisc/test/max.ssa +++ b/lisc/test/max.ssa @@ -25,3 +25,9 @@ function $test() { storew %max, $a ret } + +# >>> driver +# extern void test(void); +# int a; +# int main() { test(); return !(a == 200); } +# <<< diff --git a/lisc/test/prime.ssa b/lisc/test/prime.ssa index 03580eb..12d0273 100644 --- a/lisc/test/prime.ssa +++ b/lisc/test/prime.ssa @@ -24,3 +24,9 @@ function $test() { storew %p, $a ret } + +# >>> driver +# extern void test(void); +# int a; +# int main() { test(); return !(a == 104743); } +# <<< diff --git a/lisc/test/puts10.ssa b/lisc/test/puts10.ssa index dad4f82..1dcf227 100644 --- a/lisc/test/puts10.ssa +++ b/lisc/test/puts10.ssa @@ -1,4 +1,4 @@ -function $test() { +function $main() { @start %y =l alloc4 4 %y1 =l add %y, 1 @@ -14,3 +14,16 @@ function $test() { @end ret } + +# >>> output +# 0 +# 1 +# 2 +# 3 +# 4 +# 5 +# 6 +# 7 +# 8 +# 9 +# <<< diff --git a/lisc/test/rpo.ssa b/lisc/test/rpo.ssa deleted file mode 100644 index a10c6b1..0000000 --- a/lisc/test/rpo.ssa +++ /dev/null @@ -1,12 +0,0 @@ -function $test() { -@start - jmp @foo -@baz - jnz 1, @end, @foo -@bar - jmp @end -@foo - jnz 0, @bar, @baz -@end - ret -} diff --git a/lisc/test/spill.ssa b/lisc/test/spill.ssa deleted file mode 100644 index df5e4c2..0000000 --- a/lisc/test/spill.ssa +++ /dev/null @@ -1,22 +0,0 @@ -# test with NReg == 3 -# there must be a spill -# happening on %c -# -# if you replace the sub -# by an add or comment -# the two marked lines -# there should be no -# spill -# - -function $test() { -@start - %f =w copy 0 # here - %b =w copy 1 - %c =w copy 2 - %a =w sub %b, %c - %d =w copy %b - %e =w copy %f # and there - %g =w copy %a - ret -} diff --git a/lisc/test/spill1.ssa b/lisc/test/spill1.ssa deleted file mode 100644 index d462d0b..0000000 --- a/lisc/test/spill1.ssa +++ /dev/null @@ -1,22 +0,0 @@ -# stupid spilling test - -function $test() { -@start - %x1 =w copy 10 - %x2 =w add %x1, %x1 - %x3 =w sub %x2, %x1 - %x4 =w add %x3, %x1 - %x5 =w sub %x4, %x1 - %x6 =w add %x5, %x1 - %x7 =w sub %x6, %x1 - %x8 =w add %x7, %x1 - %x9 =w sub %x8, %x8 - %x10 =w add %x9, %x7 - %x11 =w sub %x10, %x6 - %x12 =w add %x11, %x5 - %x13 =w sub %x12, %x4 - %x14 =w add %x13, %x3 - %x15 =w sub %x14, %x2 - %x16 =w add %x15, %x1 - ret -} diff --git a/lisc/test/spill2.ssa b/lisc/test/spill2.ssa deleted file mode 100644 index cdfda2d..0000000 --- a/lisc/test/spill2.ssa +++ /dev/null @@ -1,24 +0,0 @@ -# make sure comparisons -# never get their two -# operands in memory -# run with NReg == 3, or -# adapt it! - -function $test() { -@start - %a =w loadw $a - %b =w loadw $a - -@loop - %c =w phi @start 0, @loop %f - %d =w phi @start 0, @loop %g - %e =w phi @start 0, @loop %h - %f =w add %c, %d - %g =w add %c, %e - %h =w add %e, %d - %x =w cslew %a, %b - jnz %x, @loop, @end - -@end - ret -} diff --git a/lisc/test/sum.ssa b/lisc/test/sum.ssa index aa05da8..266054e 100644 --- a/lisc/test/sum.ssa +++ b/lisc/test/sum.ssa @@ -18,3 +18,14 @@ function w $sum(l %arr, w %num) { @end ret %s0 } + +# >>> driver +# extern int sum(int *, int); +# int arr[] = { 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21 }; +# #define N sizeof arr / sizeof arr[0] +# int main() { +# int i, s; +# for (s=i=0; i