commit 5c35f60732a90c412a9bbec0a50d5b28763c0132
parent 06899861874b50f9abb3a59ed5b56af98f451111
Author: Quentin Carbonneaux <quentin.carbonneaux@yale.edu>
Date: Thu, 23 Feb 2017 11:37:26 -0500
add simple idiomatic c test
Diffstat:
A | test/strcmp.ssa | | | 63 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 63 insertions(+), 0 deletions(-)
diff --git a/test/strcmp.ssa 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
+# );
+# }
+# <<<