summary refs log tree commit diff
path: root/test/cprime.ssa
diff options
context:
space:
mode:
Diffstat (limited to 'test/cprime.ssa')
-rw-r--r--test/cprime.ssa103
1 files changed, 103 insertions, 0 deletions
diff --git a/test/cprime.ssa b/test/cprime.ssa
new file mode 100644
index 0000000..1ca60e1
--- /dev/null
+++ b/test/cprime.ssa
@@ -0,0 +1,103 @@
+# generated by Andrew Chambers'
+# compiler from the C program
+# following in comments
+
+function w $main() {
+@start
+	%v0 =l alloc8 4
+	%v1 =l alloc8 4
+	%v2 =l alloc8 4
+	%v3 =l alloc8 4
+	%v4 =l alloc8 4
+	storew 5, %v1
+	storew 11, %v2
+	storew 12, %v3
+@L0
+	%v5 =w loadw %v1
+	%v6 =w cnew %v5, 201
+	jnz %v6, @L8, @L1
+@L8
+	storew 1, %v4
+	%v7 =w loadw %v3
+	%v8 =w rem %v7, 2
+	%v9 =w ceqw %v8, 0
+	jnz %v9, @L9, @L5
+@L9
+	storew 0, %v4
+@L5
+	storew 3, %v0
+@L2
+	%v10 =w loadw %v0
+	%v11 =w loadw %v3
+	%v12 =w csltw %v10, %v11
+	jnz %v12, @L10, @L3
+@L10
+	%v13 =w loadw %v3
+	%v14 =w loadw %v0
+	%v15 =w rem %v13, %v14
+	%v16 =w ceqw %v15, 0
+	jnz %v16, @L11, @L4
+@L11
+	storew 0, %v4
+	jmp @L3
+@L4
+	%v17 =w loadw %v0
+	%v18 =w add %v17, 2
+	storew %v18, %v0
+	jmp @L2
+@L3
+	%v19 =w loadw %v4
+	jnz %v19, @L12, @L6
+@L12
+	%v20 =w loadw %v3
+	storew %v20, %v2
+	%v21 =w loadw %v1
+	%v22 =w add %v21, 1
+	storew %v22, %v1
+@L6
+	%v23 =w loadw %v3
+	%v24 =w add %v23, 1
+	storew %v24, %v3
+	jmp @L0
+@L1
+	%v25 =w loadw %v2
+	%v26 =w cnew %v25, 1229
+	jnz %v26, @L13, @L7
+@L13
+	ret 1
+@L7
+	ret 0
+@end
+	ret 0
+}
+
+# int
+# main()
+# {
+#         int i, n, p, next, isprime;
+#
+#         n = 5;
+#         p = 11;
+#         next = 12;
+#         while(n != 201) {
+#                 isprime = 1;
+#                 if(next % 2 == 0) {
+#                         isprime = 0;
+#                 } else {
+#                         for(i = 3; i < next; i = i + 2) {
+#                                 if(next % i == 0) {
+#                                         isprime = 0;
+#                                         break;
+#                                 }
+#                         }
+#                 }
+#                 if(isprime) {
+#                         p = next;
+#                         n = n + 1;
+#                 }
+#                 next = next + 1;
+#         }
+#         if(p != 1229)
+#                 return 1;
+#         return 0;
+# }