summary refs log tree commit diff
path: root/test/strcmp.ssa
diff options
context:
space:
mode:
Diffstat (limited to 'test/strcmp.ssa')
-rw-r--r--test/strcmp.ssa63
1 files changed, 63 insertions, 0 deletions
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
+# 	);
+# }
+# <<<