-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathunary.py
More file actions
21 lines (14 loc) · 690 Bytes
/
unary.py
File metadata and controls
21 lines (14 loc) · 690 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import binaryen
mod = binaryen.Module()
# f_sub = mod.unary(binaryen.operations.NegFloat32(), mod.f32(6.7))
f_sub = mod.unary(
binaryen.operations.NegFloat32(), mod.local_get(0, binaryen.type.Float32)
)
mod.add_function(b"float_test", binaryen.type.Float32, binaryen.type.Float32, [], f_sub)
mod.add_function_export(b"float_test", b"float_test")
# i_sub = mod.binary(binaryen.operations.SubInt32(), mod.i32(0), mod.i32(10))
# i_sub = mod.binary(binaryen.operations.S, mod.i32(0), mod.local_get(0, binaryen.type.Int32))
mod.add_function(b"int_test", binaryen.type.Int32, binaryen.type.Int32, [], i_sub)
mod.add_function_export(b"int_test", b"int_test")
mod.optimize()
mod.print()