zingen/masm/
integer.rs

1// Integer instructions
2
3use crate::{wasm::ToLSBytes, MacroAssembler, Result};
4use wasmparser::{Ieee32, Ieee64};
5
6impl MacroAssembler {
7    /// Sub two numbers.
8    pub fn _sub(&mut self) -> Result<()> {
9        self._swap1()?;
10        self.asm._sub()
11    }
12
13    /// Push a 32-bit integer value on the stack.
14    pub fn _i32_const(&mut self, value: i32) -> Result<()> {
15        if value == 0 {
16            self._push0()
17        } else {
18            self.push(value.to_ls_bytes().as_ref())
19        }
20    }
21
22    /// Push a 64-bit integer value on the stack.
23    pub fn _i64_const(&mut self, value: i64) -> Result<()> {
24        if value == 0 {
25            self._push0()
26        } else {
27            self.push(value.to_ls_bytes().as_ref())
28        }
29    }
30
31    /// Push a 32-bit float value on the stack.
32    pub fn _f32_const(&mut self, _value: Ieee32) -> Result<()> {
33        todo!()
34    }
35
36    /// Push a 64-bit float value on the stack.
37    pub fn _f64_const(&mut self, _value: Ieee64) -> Result<()> {
38        todo!()
39    }
40
41    /// wrap a 64-bit integer to a 32-bit integer.
42    pub fn _i32_wrap_i64(&mut self) -> Result<()> {
43        todo!()
44    }
45
46    /// Extend a signed 32-bit integer to a 64-bit integer.
47    pub fn _i64_extend_i32_s(&mut self) -> Result<()> {
48        todo!()
49    }
50
51    /// Extend an unsigned 32-bit integer to a 64-bit integer.
52    pub fn _i64_extend_i32_u(&mut self) -> Result<()> {
53        todo!()
54    }
55
56    /// Truncate a 64-bit float to a signed 32-bit integer.
57    pub fn _f32_demote_f64(&mut self) -> Result<()> {
58        todo!()
59    }
60
61    /// Truncate a 64-bit float to an unsigned 32-bit integer.
62    pub fn _f64_promote_f32(&mut self) -> Result<()> {
63        todo!()
64    }
65
66    /// Convert a signed 32-bit integer to a 32-bit float.
67    pub fn _i32_reinterpret_f32(&mut self) -> Result<()> {
68        todo!()
69    }
70
71    /// Convert a signed 64-bit integer to a 64-bit float.
72    pub fn _i64_reinterpret_f64(&mut self) -> Result<()> {
73        todo!()
74    }
75
76    /// Convert a 32-bit float to a signed 32-bit integer.
77    pub fn _f32_reinterpret_i32(&mut self) -> Result<()> {
78        todo!()
79    }
80
81    /// Convert a 64-bit float to a signed 64-bit integer.
82    pub fn _f64_reinterpret_i64(&mut self) -> Result<()> {
83        todo!()
84    }
85
86    /// sign-agnostic rotate left
87    ///
88    /// Return the result of rotating i1 left by k bits.
89    pub fn _rotl(&mut self) -> Result<()> {
90        todo!()
91    }
92
93    /// sign-agnostic rotate right
94    ///
95    /// Return the result of rotating i1 right by k bits.
96    pub fn _rotr(&mut self) -> Result<()> {
97        todo!()
98    }
99
100    /// sign-agnostic count leading zero bits
101    ///
102    /// Return the number of leading zero bits in i, all zero bits
103    /// are considered leading if the value is zero.
104    pub fn _clz(&mut self) -> Result<()> {
105        todo!()
106    }
107
108    /// sign-agnostic count leading zero bits
109    ///
110    /// Return the number of leading zero bits in i, all zero bits
111    /// are considered trailing if the value is zero.
112    pub fn _ctz(&mut self) -> Result<()> {
113        todo!()
114    }
115
116    /// sign-agnostic count number of one bits
117    ///
118    /// Return the count of no zero bits in i.
119    pub fn _popcnt(&mut self) -> Result<()> {
120        todo!()
121    }
122
123    /// Truncate a 32-bit float to an integer
124    pub fn _trunc_f32(&mut self) -> Result<()> {
125        todo!()
126    }
127
128    /// Truncate a 64-bit float to an integer
129    pub fn _trunc_f64(&mut self) -> Result<()> {
130        todo!()
131    }
132}