Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

winch: Reclassify unsupported immediate error (#13889)

Saúl Cabreraeecb6490b80f
diff --git a/winch/codegen/src/codegen/error.rs b/winch/codegen/src/codegen/error.rs
index f459442930..254f5b3354 100644
--- a/winch/codegen/src/codegen/error.rs
+++ b/winch/codegen/src/codegen/error.rs
@@ -35,6 +35,9 @@ pub(crate) enum CodeGenError {
/// Unsupported eager initialization of tables.
#[error("Unsupported eager initialization of tables")]
UnsupportedTableEagerInit,
+ /// Unsupported immediate for instruction.
+ #[error("Unsupported immediate")]
+ UnsupportedImm,
/// An internal error.
///
/// This error means that an internal invariant was not met and usually
@@ -91,9 +94,6 @@ pub(crate) enum InternalError {
/// Invalid local offset.
#[error("Invalid local offset")]
InvalidLocalOffset,
- /// Unsupported immediate for instruction.
- #[error("Unsupported immediate")]
- UnsupportedImm,
/// Invalid operand combination.
#[error("Invalid operand combination")]
InvalidOperandCombination,
@@ -180,7 +180,7 @@ impl CodeGenError {
}
pub(crate) const fn unsupported_imm() -> Self {
- Self::Internal(InternalError::UnsupportedImm)
+ Self::UnsupportedImm
}
pub(crate) const fn invalid_two_arg_form() -> Self {
diff --git a/winch/codegen/src/isa/aarch64/masm.rs b/winch/codegen/src/isa/aarch64/masm.rs
index 4cb8c45167..ac1b6376ee 100644
--- a/winch/codegen/src/isa/aarch64/masm.rs
+++ b/winch/codegen/src/isa/aarch64/masm.rs
@@ -6,7 +6,7 @@ use super::{
regs::{self, scratch_fpr_bitset, scratch_gpr_bitset},
};
use crate::{
- Result,
+ Context, Result,
abi::{self, align_to, calculate_frame_adjustment, local::LocalSlot, vmctx},
bail,
codegen::{CodeGenContext, CodeGenError, Emission, FuncEnv, ptr_type_from_ptr_size},
@@ -521,7 +521,10 @@ impl Masm for MacroAssembler {
self.asm.mov_ir(dst, imm, imm.size());
Ok(())
}
- I::V128(_) => bail!(CodeGenError::unsupported_imm()),
+ I::V128(_) => Err(CodeGenError::unsupported_imm()).context(
+ "v128 immediates are not supported in winch+aarch64; the SIMD and \
+ relaxed-SIMD proposals are unimplemented for this target",
+ ),
},
(RegImm::Reg(rs), rd) => match (rs.class(), rd.to_reg().class()) {
(RegClass::Int, RegClass::Int) => Ok(self.asm.mov_rr(rs, rd, size)),