]> git.proxmox.com Git - rustc.git/blame - src/binaryen/test/spec/stack.wast
New upstream version 1.25.0+dfsg1
[rustc.git] / src / binaryen / test / spec / stack.wast
CommitLineData
abe05a73
XL
1(module
2 (func (export "fac-expr") (param $n i64) (result i64)
3 (local $i i64)
4 (local $res i64)
5 (set_local $i (get_local $n))
6 (set_local $res (i64.const 1))
7 (block $done
8 (loop $loop
9 (if
10 (i64.eq (get_local $i) (i64.const 0))
11 (br $done)
12 (block
13 (set_local $res (i64.mul (get_local $i) (get_local $res)))
14 (set_local $i (i64.sub (get_local $i) (i64.const 1)))
15 )
16 )
17 (br $loop)
18 )
19 )
20 (get_local $res)
21 )
22
23 (func (export "fac-stack") (param $n i64) (result i64)
24 (local $i i64)
25 (local $res i64)
26 (get_local $n)
27 (set_local $i)
28 (i64.const 1)
29 (set_local $res)
30 (block $done
31 (loop $loop
32 (get_local $i)
33 (i64.const 0)
34 (i64.eq)
35 (if
36 (then (br $done))
37 (else
38 (get_local $i)
39 (get_local $res)
40 (i64.mul)
41 (set_local $res)
42 (get_local $i)
43 (i64.const 1)
44 (i64.sub)
45 (set_local $i)
46 )
47 )
48 (br $loop)
49 )
50 )
51 (get_local $res)
52 )
53
54 (func (export "fac-stack-raw") (param $n i64) (result i64)
55 (local $i i64)
56 (local $res i64)
57 get_local $n
58 set_local $i
59 i64.const 1
60 set_local $res
61 block $done
62 loop $loop
63 get_local $i
64 i64.const 0
65 i64.eq
66 if
67 br $done
68 else
69 get_local $i
70 get_local $res
71 i64.mul
72 set_local $res
73 get_local $i
74 i64.const 1
75 i64.sub
76 set_local $i
77 end
78 br $loop
79 end
80 end
81 get_local $res
82 )
83
84 (func (export "fac-mixed") (param $n i64) (result i64)
85 (local $i i64)
86 (local $res i64)
87 (set_local $i (get_local $n))
88 (set_local $res (i64.const 1))
89 (block $done
90 (loop $loop
91 (i64.eq (get_local $i) (i64.const 0))
92 (if
93 (then (br $done))
94 (else
95 (i64.mul (get_local $i) (get_local $res))
96 (set_local $res)
97 (i64.sub (get_local $i) (i64.const 1))
98 (set_local $i)
99 )
100 )
101 (br $loop)
102 )
103 )
104 (get_local $res)
105 )
106
107 (func (export "fac-mixed-raw") (param $n i64) (result i64)
108 (local $i i64)
109 (local $res i64)
110 (set_local $i (get_local $n))
111 (set_local $res (i64.const 1))
112 block $done
113 loop $loop
114 (i64.eq (get_local $i) (i64.const 0))
115 if
116 br $done
117 else
118 (i64.mul (get_local $i) (get_local $res))
119 set_local $res
120 (i64.sub (get_local $i) (i64.const 1))
121 set_local $i
122 end
123 br $loop
124 end
125 end
126 get_local $res
127 )
128)
129
130(assert_return (invoke "fac-expr" (i64.const 25)) (i64.const 7034535277573963776))
131(assert_return (invoke "fac-stack" (i64.const 25)) (i64.const 7034535277573963776))
132(assert_return (invoke "fac-mixed" (i64.const 25)) (i64.const 7034535277573963776))
133
134;; from br_table.wast
135(module (func $type-arg-num-vs-void
136 (block (br_table 0 (i32.const 0) (i32.const 1)))
137))
138