From 5c35f60732a90c412a9bbec0a50d5b28763c0132 Mon Sep 17 00:00:00 2001 From: Quentin Carbonneaux Date: Thu, 23 Feb 2017 11:37:26 -0500 Subject: add simple idiomatic c test --- test/strcmp.ssa | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 test/strcmp.ssa diff --git a/test/strcmp.ssa b/test/strcmp.ssa new file mode 100644 index 0000000..4956871 --- /dev/null +++ b/test/strcmp.ssa @@ -0,0 +1,63 @@ +# the C strcmp function generated by scc + +export function w $strcmp(l %s1.3.val,l %s2.5.val) +{ +@.37 + %s1.3 =l alloc8 8 + %s2.5 =l alloc8 8 + storel %s1.3.val,%s1.3 + storel %s2.5.val,%s2.5 + jmp @.5 +@.6 + %.9 =l loadl %s1.3 + %.10 =l add %.9,1 + storel %.10,%s1.3 + %.11 =l loadl %s2.5 + %.12 =l add %.11,1 + storel %.12,%s2.5 +@.5 + %.15 =l loadl %s1.3 + %.16 =w loadsb %.15 + %.17 =w extsb %.16 + %.18 =w cnew %.17,0 + jnz %.18,@.14,@.8 +@.14 + %.19 =l loadl %s2.5 + %.20 =w loadsb %.19 + %.21 =w extsb %.20 + %.22 =w cnew %.21,0 + jnz %.22,@.13,@.8 +@.13 + %.23 =l loadl %s1.3 + %.24 =w loadsb %.23 + %.25 =w extsb %.24 + %.26 =l loadl %s2.5 + %.27 =w loadsb %.26 + %.28 =w extsb %.27 + %.29 =w ceqw %.25,%.28 + jnz %.29,@.6,@.8 +@.8 +@.7 + %.30 =l loadl %s1.3 + %.31 =w loadub %.30 + %.32 =w extub %.31 + %.33 =l loadl %s2.5 + %.34 =w loadub %.33 + %.35 =w extub %.34 + %.36 =w sub %.32,%.35 + ret %.36 +} + +# >>> driver +# extern int strcmp(const char *, const char *); +# int main() { +# char a[] = "Hello world"; +# return !( +# strcmp(a, a) == 0 && +# strcmp("aaa", "aab") < 0 && +# strcmp("..cnn", "..bbc") > 0 && +# strcmp(a, "Hellp ...") < 0 && +# strcmp(a, "Hello vorld") > 0 +# ); +# } +# <<< -- cgit 1.4.1