aboutsummaryrefslogtreecommitdiff
path: root/test/builtin-vaarg-vm.qbe
diff options
context:
space:
mode:
Diffstat (limited to 'test/builtin-vaarg-vm.qbe')
-rw-r--r--test/builtin-vaarg-vm.qbe37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/builtin-vaarg-vm.qbe b/test/builtin-vaarg-vm.qbe
new file mode 100644
index 0000000..814e3d0
--- /dev/null
+++ b/test/builtin-vaarg-vm.qbe
@@ -0,0 +1,37 @@
+export
+function w $f(w %.1, ...) {
+@start.1
+ %.2 =l alloc4 4
+ storew %.1, %.2
+ %.3 =l alloc4 4
+ %.4 =l alloc4 4
+ %.5 =l alloc8 24
+@body.2
+ storew 0, %.4
+ vastart %.5
+ %.6 =w loadw %.2
+ %.7 =w add %.6, 1
+ storew %.7, %.2
+ %.8 =l extsw %.7
+ %.9 =l mul %.8, 4
+ %.10 =l vaarg %.5
+ %.11 =w loadw %.10
+ storew %.11, %.3
+ %.12 =w loadw %.3
+ %.13 =w loadw %.2
+ %.14 =w add %.12, %.13
+ ret %.14
+}
+export
+function w $main() {
+@start.3
+ %.1 =l alloc4 12
+@body.4
+ %.2 =l extsw 0
+ %.3 =l mul %.2, 4
+ %.4 =l add %.1, %.3
+ storew 123, %.4
+ %.5 =w call $f(w 3, ..., l %.1)
+ %.6 =w cnew %.5, 127
+ ret %.6
+}