Pops the value stack top and stores it at the specified address.
(&mut self, masm: &mut M, addr: M::Address)
| 274 | |
| 275 | /// Pops the value stack top and stores it at the specified address. |
| 276 | pub fn pop_to_addr<M: MacroAssembler>(&mut self, masm: &mut M, addr: M::Address) -> Result<()> { |
| 277 | let val = self.stack.pop().expect("a value at stack top"); |
| 278 | let ty = val.ty(); |
| 279 | let size: OperandSize = ty.try_into()?; |
| 280 | match val { |
| 281 | Val::Reg(tr) => { |
| 282 | masm.store(tr.reg.into(), addr, size)?; |
| 283 | self.free_reg(tr.reg); |
| 284 | } |
| 285 | Val::I32(v) => masm.store(RegImm::i32(v), addr, size)?, |
| 286 | Val::I64(v) => masm.store(RegImm::i64(v), addr, size)?, |
| 287 | Val::F32(v) => masm.store(RegImm::f32(v.bits()), addr, size)?, |
| 288 | Val::F64(v) => masm.store(RegImm::f64(v.bits()), addr, size)?, |
| 289 | Val::V128(v) => masm.store(RegImm::v128(v), addr, size)?, |
| 290 | Val::Local(local) => { |
| 291 | let slot = self.frame.get_wasm_local(local.index); |
| 292 | let local_addr = masm.local_address(&slot)?; |
| 293 | masm.with_scratch::<IntScratch, _>(|masm, scratch| { |
| 294 | masm.load(local_addr, scratch.writable(), size)?; |
| 295 | masm.store(scratch.inner().into(), addr, size) |
| 296 | })?; |
| 297 | } |
| 298 | Val::Memory(_) => { |
| 299 | masm.with_scratch_for(ty, |masm, scratch| { |
| 300 | masm.pop(scratch.writable(), size)?; |
| 301 | masm.store(scratch.inner().into(), addr, size) |
| 302 | })?; |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | Ok(()) |
| 307 | } |
| 308 | |
| 309 | /// Move a stack value to the given register. |
| 310 | pub fn move_val_to_reg<M: MacroAssembler>( |
no test coverage detected