Prepares arguments for emitting a replace lane operation.
(
&mut self,
masm: &mut M,
kind: ReplaceLaneKind,
emit: F,
)
| 591 | |
| 592 | /// Prepares arguments for emitting a replace lane operation. |
| 593 | pub fn replace_lane_op<F, M>( |
| 594 | &mut self, |
| 595 | masm: &mut M, |
| 596 | kind: ReplaceLaneKind, |
| 597 | emit: F, |
| 598 | ) -> Result<()> |
| 599 | where |
| 600 | F: FnOnce(&mut M, RegImm, WritableReg, ReplaceLaneKind) -> Result<()>, |
| 601 | M: MacroAssembler, |
| 602 | { |
| 603 | let src = match kind { |
| 604 | ReplaceLaneKind::I8x16 | ReplaceLaneKind::I16x8 | ReplaceLaneKind::I32x4 => { |
| 605 | self.pop_i32_const().map(RegImm::i32) |
| 606 | } |
| 607 | ReplaceLaneKind::I64x2 => self.pop_i64_const().map(RegImm::i64), |
| 608 | ReplaceLaneKind::F32x4 => self.pop_f32_const().map(|v| RegImm::f32(v.bits())), |
| 609 | ReplaceLaneKind::F64x2 => self.pop_f64_const().map(|v| RegImm::f64(v.bits())), |
| 610 | } |
| 611 | .map_or_else( |
| 612 | || Ok(RegImm::reg(self.pop_to_reg(masm, None)?.into())), |
| 613 | Ok::<_, crate::Error>, |
| 614 | )?; |
| 615 | |
| 616 | let dst = self.pop_to_reg(masm, None)?; |
| 617 | |
| 618 | emit(masm, src, writable!(dst.into()), kind)?; |
| 619 | |
| 620 | if let RegImm::Reg(reg) = src { |
| 621 | self.free_reg(reg); |
| 622 | } |
| 623 | self.stack.push(dst.into()); |
| 624 | |
| 625 | Ok(()) |
| 626 | } |
| 627 | |
| 628 | /// Drops the last `n` elements of the stack, calling the provided |
| 629 | /// function for each `n` stack value. |
no test coverage detected