Prepares arguments for emitting a convert operation.
(&mut self, masm: &mut M, dst_ty: WasmValType, emit: F)
| 496 | |
| 497 | /// Prepares arguments for emitting a convert operation. |
| 498 | pub fn convert_op<F, M>(&mut self, masm: &mut M, dst_ty: WasmValType, emit: F) -> Result<()> |
| 499 | where |
| 500 | F: FnOnce(&mut M, Reg, Reg, OperandSize) -> Result<()>, |
| 501 | M: MacroAssembler, |
| 502 | { |
| 503 | let src = self.pop_to_reg(masm, None)?; |
| 504 | let dst = self.reg_for_type(dst_ty, masm)?; |
| 505 | let dst_size = match dst_ty { |
| 506 | WasmValType::I32 => OperandSize::S32, |
| 507 | WasmValType::I64 => OperandSize::S64, |
| 508 | WasmValType::F32 => OperandSize::S32, |
| 509 | WasmValType::F64 => OperandSize::S64, |
| 510 | WasmValType::V128 => bail!(CodeGenError::unsupported_wasm_type()), |
| 511 | WasmValType::Ref(_) => bail!(CodeGenError::unsupported_wasm_type()), |
| 512 | }; |
| 513 | |
| 514 | emit(masm, dst, src.into(), dst_size)?; |
| 515 | |
| 516 | self.free_reg(src); |
| 517 | self.stack.push(TypedReg::new(dst_ty, dst).into()); |
| 518 | Ok(()) |
| 519 | } |
| 520 | |
| 521 | /// Prepares arguments for emitting a convert operation with a temporary |
| 522 | /// register. |
no test coverage detected