UPDATE - replace expected_simd error with one from codegen_ssa

Here I am assuming we want to treat these parameters (input, first, second, third, return) as translatable
This commit is contained in:
Jhonny Bill Mena 2023-07-20 00:20:00 -04:00
parent 051615e198
commit 7a888fb56e
3 changed files with 16 additions and 42 deletions

View file

@ -1,9 +1,6 @@
codegen_gcc_invalid_minimum_alignment = codegen_gcc_invalid_minimum_alignment =
invalid minimum global alignment: {$err} invalid minimum global alignment: {$err}
codegen_gcc_invalid_monomorphization_expected_simd =
invalid monomorphization of `{$name}` intrinsic: expected SIMD {$expected_ty} type, found non-SIMD `{$found_ty}`
codegen_gcc_lto_not_supported = codegen_gcc_lto_not_supported =
LTO is not supported. You may get a linker error. LTO is not supported. You may get a linker error.

View file

@ -1,7 +1,6 @@
use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg}; use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg};
use rustc_macros::Diagnostic; use rustc_macros::Diagnostic;
use rustc_middle::ty::Ty; use rustc_span::Span;
use rustc_span::{Span, Symbol};
use std::borrow::Cow; use std::borrow::Cow;
struct ExitCode(Option<i32>); struct ExitCode(Option<i32>);
@ -16,16 +15,6 @@ impl IntoDiagnosticArg for ExitCode {
} }
} }
#[derive(Diagnostic)]
#[diag(codegen_gcc_invalid_monomorphization_expected_simd, code = "E0511")]
pub(crate) struct InvalidMonomorphizationExpectedSimd<'a> {
#[primary_span]
pub span: Span,
pub name: Symbol,
pub position: &'a str,
pub found_ty: Ty<'a>,
}
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(codegen_gcc_lto_not_supported)] #[diag(codegen_gcc_lto_not_supported)]
pub(crate) struct LTONotSupported; pub(crate) struct LTONotSupported;

View file

@ -21,10 +21,6 @@ use rustc_target::abi::Align;
use crate::builder::Builder; use crate::builder::Builder;
#[cfg(feature="master")] #[cfg(feature="master")]
use crate::context::CodegenCx; use crate::context::CodegenCx;
#[cfg(feature="master")]
use crate::errors::{
InvalidMonomorphizationExpectedSimd,
};
pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>( pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
bx: &mut Builder<'a, 'gcc, 'tcx>, bx: &mut Builder<'a, 'gcc, 'tcx>,
@ -50,16 +46,8 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
}; };
} }
macro_rules! require_simd { macro_rules! require_simd {
($ty: expr, $position: expr) => { ($ty: expr, $diag: expr) => {
require!( require!($ty.is_simd(), $diag)
$ty.is_simd(),
InvalidMonomorphizationExpectedSimd {
span,
name,
position: $position,
found_ty: $ty
}
)
}; };
} }
@ -69,7 +57,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
let arg_tys = sig.inputs(); let arg_tys = sig.inputs();
if name == sym::simd_select_bitmask { if name == sym::simd_select_bitmask {
require_simd!(arg_tys[1], "argument"); require_simd!(arg_tys[1], InvalidMonomorphization::SimdArgument { span, name, ty: arg_tys[1] });
let (len, _) = arg_tys[1].simd_size_and_type(bx.tcx()); let (len, _) = arg_tys[1].simd_size_and_type(bx.tcx());
let expected_int_bits = (len.max(8) - 1).next_power_of_two(); let expected_int_bits = (len.max(8) - 1).next_power_of_two();
@ -122,7 +110,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
} }
// every intrinsic below takes a SIMD vector as its first argument // every intrinsic below takes a SIMD vector as its first argument
require_simd!(arg_tys[0], "input"); require_simd!(arg_tys[0], InvalidMonomorphization::SimdInput { span, name, ty: arg_tys[0] });
let in_ty = arg_tys[0]; let in_ty = arg_tys[0];
let comparison = match name { let comparison = match name {
@ -137,7 +125,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
let (in_len, in_elem) = arg_tys[0].simd_size_and_type(bx.tcx()); let (in_len, in_elem) = arg_tys[0].simd_size_and_type(bx.tcx());
if let Some(cmp_op) = comparison { if let Some(cmp_op) = comparison {
require_simd!(ret_ty, "return"); require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty });
let (out_len, out_ty) = ret_ty.simd_size_and_type(bx.tcx()); let (out_len, out_ty) = ret_ty.simd_size_and_type(bx.tcx());
require!( require!(
@ -193,7 +181,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
}) })
}; };
require_simd!(ret_ty, "return"); require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty });
let (out_len, out_ty) = ret_ty.simd_size_and_type(bx.tcx()); let (out_len, out_ty) = ret_ty.simd_size_and_type(bx.tcx());
require!( require!(
@ -240,7 +228,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
if name == sym::simd_select { if name == sym::simd_select {
let m_elem_ty = in_elem; let m_elem_ty = in_elem;
let m_len = in_len; let m_len = in_len;
require_simd!(arg_tys[1], "argument"); require_simd!(arg_tys[1], InvalidMonomorphization::SimdArgument { span, name, ty: arg_tys[1] });
let (v_len, _) = arg_tys[1].simd_size_and_type(bx.tcx()); let (v_len, _) = arg_tys[1].simd_size_and_type(bx.tcx());
require!( require!(
m_len == v_len, m_len == v_len,
@ -255,7 +243,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
#[cfg(feature="master")] #[cfg(feature="master")]
if name == sym::simd_cast || name == sym::simd_as { if name == sym::simd_cast || name == sym::simd_as {
require_simd!(ret_ty, "return"); require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty });
let (out_len, out_elem) = ret_ty.simd_size_and_type(bx.tcx()); let (out_len, out_elem) = ret_ty.simd_size_and_type(bx.tcx());
require!( require!(
in_len == out_len, in_len == out_len,
@ -557,10 +545,10 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
// * M: any integer width is supported, will be truncated to i1 // * M: any integer width is supported, will be truncated to i1
// All types must be simd vector types // All types must be simd vector types
require_simd!(in_ty, "first"); require_simd!(in_ty, InvalidMonomorphization::SimdFirst { span, name, ty: in_ty });
require_simd!(arg_tys[1], "second"); require_simd!(arg_tys[1], InvalidMonomorphization::SimdSecond { span, name, ty: arg_tys[1] });
require_simd!(arg_tys[2], "third"); require_simd!(arg_tys[2], InvalidMonomorphization::SimdThird { span, name, ty: arg_tys[2] });
require_simd!(ret_ty, "return"); require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty });
// Of the same length: // Of the same length:
let (out_len, _) = arg_tys[1].simd_size_and_type(bx.tcx()); let (out_len, _) = arg_tys[1].simd_size_and_type(bx.tcx());
@ -665,9 +653,9 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
// * M: any integer width is supported, will be truncated to i1 // * M: any integer width is supported, will be truncated to i1
// All types must be simd vector types // All types must be simd vector types
require_simd!(in_ty, "first"); require_simd!(in_ty, InvalidMonomorphization::SimdFirst { span, name, ty: in_ty });
require_simd!(arg_tys[1], "second"); require_simd!(arg_tys[1], InvalidMonomorphization::SimdSecond { span, name, ty: arg_tys[1] });
require_simd!(arg_tys[2], "third"); require_simd!(arg_tys[2], InvalidMonomorphization::SimdThird { span, name, ty: arg_tys[2] });
// Of the same length: // Of the same length:
let (element_len1, _) = arg_tys[1].simd_size_and_type(bx.tcx()); let (element_len1, _) = arg_tys[1].simd_size_and_type(bx.tcx());