summary refs log tree commit diff
path: root/test/abi3.ssa
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2016-03-27 15:00:45 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2016-03-27 15:00:45 -0400
commit36635660b40573f6a0c19d50dfdd9277589030de (patch)
treea1b4463f7260462c314bd8d7cb35b3d199143f33 /test/abi3.ssa
parentaad52241c88ad5327a8488c66dc906c8393c9c92 (diff)
downloadroux-36635660b40573f6a0c19d50dfdd9277589030de.tar.gz
extract tests out of src
Diffstat (limited to 'test/abi3.ssa')
-rw-r--r--test/abi3.ssa43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/abi3.ssa b/test/abi3.ssa
new file mode 100644
index 0000000..608d1db
--- /dev/null
+++ b/test/abi3.ssa
@@ -0,0 +1,43 @@
+type :four = {l, b, w}
+
+data $z = { w 0 }
+
+function $test() {
+ @start
+	%a  =w loadw $z
+	%y  =w add %a, %a
+
+	%s  =l alloc8 16   # allocate a :four struct
+	%s1 =l add %s, 12  # get address of the w
+	storel 4, %s       # set the l
+	storew 5, %s1      # set the w
+
+	# only the last argument should be on the stack
+	%f  =l add $F, %y
+	%x  =w call %f(w %y, w 1, w 2, w 3, :four %s, w 6)
+
+	# store the result in the
+	# global variable a
+
+	%x1 =w add %y, %x
+	storew %x1, $a
+	ret
+}
+
+# >>> driver
+# #include <stdio.h>
+# struct four { long l; char c; int i; };
+# extern void test(void);
+# int F(int a0, int a1, int a2, int a3, struct four s, int a6) {
+# 	printf("%d %d %d %d %d %d %d\n",
+# 		a0, a1, a2, a3, (int)s.l, s.i, a6);
+# 	return 42;
+# }
+# int a;
+# int main() { test(); printf("%d\n", a); return 0; }
+# <<<
+
+# >>> output
+# 0 1 2 3 4 5 6
+# 42
+# <<<