cranelift: introduce a new WasmtimeAppleAarch64 calling convention
The previous choice to use the WasmtimeSystemV calling convention for apple-aarch64 devices was incorrect: padding of arguments was incorrectly computed. So we have to use some flavor of the apple-aarch64 ABI there. Since we want to support the wasmtime custom convention for multiple returns on apple-aarch64 too, a new custom Wasmtime calling convention was introduced to support this.
This commit is contained in:
@@ -183,7 +183,7 @@ impl ABIMachineSpec for AArch64MachineDeps {
|
|||||||
args_or_rets: ArgsOrRets,
|
args_or_rets: ArgsOrRets,
|
||||||
add_ret_area_ptr: bool,
|
add_ret_area_ptr: bool,
|
||||||
) -> CodegenResult<(Vec<ABIArg>, i64, Option<usize>)> {
|
) -> CodegenResult<(Vec<ABIArg>, i64, Option<usize>)> {
|
||||||
let is_apple_cc = call_conv == isa::CallConv::AppleAarch64;
|
let is_apple_cc = call_conv.extends_apple_aarch64();
|
||||||
let is_baldrdash = call_conv.extends_baldrdash();
|
let is_baldrdash = call_conv.extends_baldrdash();
|
||||||
let has_baldrdash_tls = call_conv == isa::CallConv::Baldrdash2020;
|
let has_baldrdash_tls = call_conv == isa::CallConv::Baldrdash2020;
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ pub enum CallConv {
|
|||||||
SystemV,
|
SystemV,
|
||||||
/// Windows "fastcall" convention, also used for x64 and ARM.
|
/// Windows "fastcall" convention, also used for x64 and ARM.
|
||||||
WindowsFastcall,
|
WindowsFastcall,
|
||||||
/// Mac aarch64 calling convention, which is a tweak aarch64 ABI.
|
/// Mac aarch64 calling convention, which is a tweaked aarch64 ABI.
|
||||||
AppleAarch64,
|
AppleAarch64,
|
||||||
/// SpiderMonkey WebAssembly convention on systems using natively SystemV.
|
/// SpiderMonkey WebAssembly convention on systems using natively SystemV.
|
||||||
BaldrdashSystemV,
|
BaldrdashSystemV,
|
||||||
@@ -39,6 +39,10 @@ pub enum CallConv {
|
|||||||
///
|
///
|
||||||
/// Differs from fastcall in the same way as `WasmtimeSystemV`.
|
/// Differs from fastcall in the same way as `WasmtimeSystemV`.
|
||||||
WasmtimeFastcall,
|
WasmtimeFastcall,
|
||||||
|
/// Wasmtime equivalent of AppleAarch64, not ABI-stable.
|
||||||
|
///
|
||||||
|
/// Differs from apple-aarch64 in the same way as `WasmtimeSystemV`.
|
||||||
|
WasmtimeAppleAarch64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CallConv {
|
impl CallConv {
|
||||||
@@ -78,6 +82,14 @@ impl CallConv {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Is the calling convention extending the Apple aarch64 ABI?
|
||||||
|
pub fn extends_apple_aarch64(self) -> bool {
|
||||||
|
match self {
|
||||||
|
Self::AppleAarch64 | Self::WasmtimeAppleAarch64 => true,
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Is the calling convention extending the Baldrdash ABI?
|
/// Is the calling convention extending the Baldrdash ABI?
|
||||||
pub fn extends_baldrdash(self) -> bool {
|
pub fn extends_baldrdash(self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
@@ -89,7 +101,7 @@ impl CallConv {
|
|||||||
/// Is the calling convention extending the Wasmtime ABI?
|
/// Is the calling convention extending the Wasmtime ABI?
|
||||||
pub fn extends_wasmtime(self) -> bool {
|
pub fn extends_wasmtime(self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Self::WasmtimeSystemV | Self::WasmtimeFastcall => true,
|
Self::WasmtimeSystemV | Self::WasmtimeFastcall | Self::WasmtimeAppleAarch64 => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -109,6 +121,7 @@ impl fmt::Display for CallConv {
|
|||||||
Self::Probestack => "probestack",
|
Self::Probestack => "probestack",
|
||||||
Self::WasmtimeSystemV => "wasmtime_system_v",
|
Self::WasmtimeSystemV => "wasmtime_system_v",
|
||||||
Self::WasmtimeFastcall => "wasmtime_fastcall",
|
Self::WasmtimeFastcall => "wasmtime_fastcall",
|
||||||
|
Self::WasmtimeAppleAarch64 => "wasmtime_apple_aarch64",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,6 +141,7 @@ impl str::FromStr for CallConv {
|
|||||||
"probestack" => Ok(Self::Probestack),
|
"probestack" => Ok(Self::Probestack),
|
||||||
"wasmtime_system_v" => Ok(Self::WasmtimeSystemV),
|
"wasmtime_system_v" => Ok(Self::WasmtimeSystemV),
|
||||||
"wasmtime_fastcall" => Ok(Self::WasmtimeFastcall),
|
"wasmtime_fastcall" => Ok(Self::WasmtimeFastcall),
|
||||||
|
"wasmtime_apple_aarch64" => Ok(Self::WasmtimeAppleAarch64),
|
||||||
_ => Err(()),
|
_ => Err(()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -906,7 +906,7 @@ fn get_intreg_for_retval(
|
|||||||
_ => None,
|
_ => None,
|
||||||
},
|
},
|
||||||
CallConv::BaldrdashWindows | CallConv::Probestack => todo!(),
|
CallConv::BaldrdashWindows | CallConv::Probestack => todo!(),
|
||||||
CallConv::AppleAarch64 => unreachable!(),
|
CallConv::AppleAarch64 | CallConv::WasmtimeAppleAarch64 => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -936,7 +936,7 @@ fn get_fltreg_for_retval(
|
|||||||
_ => None,
|
_ => None,
|
||||||
},
|
},
|
||||||
CallConv::BaldrdashWindows | CallConv::Probestack => todo!(),
|
CallConv::BaldrdashWindows | CallConv::Probestack => todo!(),
|
||||||
CallConv::AppleAarch64 => unreachable!(),
|
CallConv::AppleAarch64 | CallConv::WasmtimeAppleAarch64 => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1005,7 +1005,7 @@ fn get_callee_saves(call_conv: &CallConv, regs: &Set<Writable<RealReg>>) -> Vec<
|
|||||||
.filter(|r| is_callee_save_fastcall(r.to_reg()))
|
.filter(|r| is_callee_save_fastcall(r.to_reg()))
|
||||||
.collect(),
|
.collect(),
|
||||||
CallConv::Probestack => todo!("probestack?"),
|
CallConv::Probestack => todo!("probestack?"),
|
||||||
CallConv::AppleAarch64 => unreachable!(),
|
CallConv::AppleAarch64 | CallConv::WasmtimeAppleAarch64 => unreachable!(),
|
||||||
};
|
};
|
||||||
// Sort registers for deterministic code output. We can do an unstable sort because the
|
// Sort registers for deterministic code output. We can do an unstable sort because the
|
||||||
// registers will be unique (there are no dups).
|
// registers will be unique (there are no dups).
|
||||||
|
|||||||
@@ -514,7 +514,7 @@ pub fn prologue_epilogue(func: &mut ir::Function, isa: &dyn TargetIsa) -> Codege
|
|||||||
}
|
}
|
||||||
CallConv::Probestack => unimplemented!("probestack calling convention"),
|
CallConv::Probestack => unimplemented!("probestack calling convention"),
|
||||||
CallConv::Baldrdash2020 => unimplemented!("Baldrdash ABI 2020"),
|
CallConv::Baldrdash2020 => unimplemented!("Baldrdash ABI 2020"),
|
||||||
CallConv::AppleAarch64 => unreachable!(),
|
CallConv::AppleAarch64 | CallConv::WasmtimeAppleAarch64 => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -652,7 +652,8 @@ impl<M: ABIMachineSpec> ABICalleeImpl<M> {
|
|||||||
|| call_conv.extends_baldrdash()
|
|| call_conv.extends_baldrdash()
|
||||||
|| call_conv.extends_windows_fastcall()
|
|| call_conv.extends_windows_fastcall()
|
||||||
|| call_conv == isa::CallConv::AppleAarch64
|
|| call_conv == isa::CallConv::AppleAarch64
|
||||||
|| call_conv == isa::CallConv::WasmtimeSystemV,
|
|| call_conv == isa::CallConv::WasmtimeSystemV
|
||||||
|
|| call_conv == isa::CallConv::WasmtimeAppleAarch64,
|
||||||
"Unsupported calling convention: {:?}",
|
"Unsupported calling convention: {:?}",
|
||||||
call_conv
|
call_conv
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -468,9 +468,8 @@ pub fn blank_sig(isa: &dyn TargetIsa, call_conv: CallConv) -> ir::Signature {
|
|||||||
|
|
||||||
pub fn wasmtime_call_conv(isa: &dyn TargetIsa) -> CallConv {
|
pub fn wasmtime_call_conv(isa: &dyn TargetIsa) -> CallConv {
|
||||||
match isa.triple().default_calling_convention() {
|
match isa.triple().default_calling_convention() {
|
||||||
Ok(CallingConvention::SystemV) | Ok(CallingConvention::AppleAarch64) | Err(()) => {
|
Ok(CallingConvention::AppleAarch64) => CallConv::WasmtimeAppleAarch64,
|
||||||
CallConv::WasmtimeSystemV
|
Ok(CallingConvention::SystemV) | Err(()) => CallConv::WasmtimeSystemV,
|
||||||
}
|
|
||||||
Ok(CallingConvention::WindowsFastcall) => CallConv::WasmtimeFastcall,
|
Ok(CallingConvention::WindowsFastcall) => CallConv::WasmtimeFastcall,
|
||||||
Ok(unimp) => unimplemented!("calling convention: {:?}", unimp),
|
Ok(unimp) => unimplemented!("calling convention: {:?}", unimp),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user