1
Fork 0

vectorcall ABI: error if sse2 is not available

This commit is contained in:
Ralf Jung 2025-02-18 17:17:16 +01:00
parent 79b2360d98
commit 83fd16f625
12 changed files with 102 additions and 74 deletions

View file

@ -90,3 +90,16 @@ pub(crate) struct AbiErrorUnsupportedVectorType<'a> {
/// Whether this is a problem at a call site or at a declaration.
pub is_call: bool,
}
#[derive(Diagnostic)]
#[diag(monomorphize_abi_required_target_feature)]
#[help]
pub(crate) struct AbiRequiredTargetFeature<'a> {
#[primary_span]
#[label]
pub span: Span,
pub required_feature: &'a str,
pub abi: &'a str,
/// Whether this is a problem at a call site or at a declaration.
pub is_call: bool,
}

View file

@ -29,12 +29,12 @@ fn uses_vector_registers(mode: &PassMode, repr: &BackendRepr) -> bool {
fn do_check_abi<'tcx>(
tcx: TyCtxt<'tcx>,
abi: &FnAbi<'tcx, Ty<'tcx>>,
target_feature_def: DefId,
def_id: DefId,
is_call: bool,
span: impl Fn() -> Span,
) {
let feature_def = tcx.sess.target.features_for_correct_vector_abi();
let codegen_attrs = tcx.codegen_fn_attrs(target_feature_def);
let codegen_attrs = tcx.codegen_fn_attrs(def_id);
let have_feature = |feat: Symbol| {
tcx.sess.unstable_target_features.contains(&feat)
|| codegen_attrs.target_features.iter().any(|x| x.name == feat)
@ -77,6 +77,15 @@ fn do_check_abi<'tcx>(
}
}
}
// The `vectorcall` ABI is special in that it requires SSE2 no matter which types are being passed.
if abi.conv == Conv::X86VectorCall && !have_feature(sym::sse2) {
tcx.dcx().emit_err(errors::AbiRequiredTargetFeature {
span: span(),
required_feature: "sse2",
abi: "vectorcall",
is_call,
});
}
}
/// Checks that the ABI of a given instance of a function does not contain vector-passed arguments