summary refs log tree commit diff
path: root/test
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin@c9x.me>2022-12-10 23:16:21 +0100
committerQuentin Carbonneaux <quentin@c9x.me>2022-12-14 23:18:26 +0100
commit26c1c30b7d96d2170195970a8cdb3b024ba7421a (patch)
tree79c45ec28d63619fbe2a88ec2195f8fe4a95a8a5 /test
parent15e25a61b38b250c7543437a093a9efe076cce0a (diff)
downloadroux-26c1c30b7d96d2170195970a8cdb3b024ba7421a.tar.gz
new blit instruction
Diffstat (limited to 'test')
-rw-r--r--test/load2.ssa75
-rw-r--r--test/mem1.ssa35
2 files changed, 110 insertions, 0 deletions
diff --git a/test/load2.ssa b/test/load2.ssa
new file mode 100644
index 0000000..05c12a6
--- /dev/null
+++ b/test/load2.ssa
@@ -0,0 +1,75 @@
+# blit & load elimination
+
+export
+function $f() {
+@start
+        %x =l alloc4 12
+        %y =l alloc4 12
+
+	%x1 =l add 1, %x
+	%x2 =l add 1, %x1
+	%x3 =l add 1, %x2
+	%x4 =l add 1, %x3
+	%x5 =l add 1, %x4
+	%x6 =l add 1, %x5
+	%x7 =l add 1, %x6
+	%x8 =l add 1, %x7
+	%x9 =l add 1, %x8
+	%xa =l add 1, %x9
+	%xb =l add 1, %xa
+
+	%y1 =l add 1, %y
+	%y4 =l add 4, %y
+	
+	storew 287454020, %x4   # 0x11223344
+	storew 1432778632, %y   # 0x55667788
+	blit %y, %x5, 1
+	%n =w load %x4
+	call $px(w %n)          # 0x11228844
+
+	storew 287454020, %x4   # 0x11223344
+	storew 1432778632, %y   # 0x55667788
+	blit %y, %x5, 2
+	%n =w load %x4
+	call $px(w %n)          # 0x11778844
+
+	storew 287454020, %x4   # 0x11223344
+	storew 1432778632, %y   # 0x55667788
+	blit %y, %x5, 4
+	%n =w load %x4
+	call $px(w %n)          # 0x66778844
+
+	storew 287454020, %x4   # 0x11223344
+	storew 1432778632, %y   # 0x55667788
+	blit %y, %x2, 4
+	%n =w load %x4
+	call $px(w %n)          # 0x11225566
+
+	storew 287454020, %x4   # 0x11223344
+	storew 0, %y
+	storew 1432778632, %y4  # 0x55667788
+	blit %y1, %x2, 7
+	%n =w load %x4
+	call $px(w %n)          # 0x66778800
+
+	ret
+}
+
+# >>> driver
+# #include <stdio.h>
+# void px(unsigned n) {
+# 	printf("0x%08x\n", n);
+# }
+# int main() {
+# 	extern void f(void);
+# 	f();
+# }
+# <<<
+
+# >>> output
+# 0x11228844
+# 0x11778844
+# 0x66778844
+# 0x11225566
+# 0x66778800
+# <<<
diff --git a/test/mem1.ssa b/test/mem1.ssa
new file mode 100644
index 0000000..b7045a6
--- /dev/null
+++ b/test/mem1.ssa
@@ -0,0 +1,35 @@
+type :i3 = { w 3 } 
+
+export
+function :i3 $blit() {
+@start
+	%l0 =l alloc4 12
+	%l1 =l alloc4 12
+
+	storew 287454020, %l0
+	%l04 =l add %l0, 4
+	storew 1432778632, %l04
+	%l08 =l add %l0, 8
+	storew 2578103244, %l08
+
+	# we expect that %l0 and %l1
+	# are coalesced and the blit
+	# goes backwards
+	%l11 =l add %l1, 1
+	blit %l0, %l11, 11
+
+	storeb 221, %l1
+
+	ret %l1
+}
+
+# >>> driver
+# struct i3 { int a, b, c; };
+# extern struct i3 blit();
+# int main() {
+# 	struct i3 s = blit();
+# 	return !(s.a == 0x223344dd
+# 	      && s.b == 0x66778811
+# 	      && s.c == 0xaabbcc55);
+# }
+# <<<