Add monomorphization errors
This commit is contained in:
parent
6fdfcb3547
commit
249e46bfba
@ -1,6 +1,7 @@
|
||||
use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg};
|
||||
use rustc_macros::SessionDiagnostic;
|
||||
use rustc_span::Span;
|
||||
use rustc_middle::ty::Ty;
|
||||
use rustc_span::{Span, Symbol};
|
||||
use std::borrow::Cow;
|
||||
|
||||
struct ExitCode {
|
||||
@ -29,6 +30,201 @@ pub fn new(exit_code: Option<i32>) -> Self {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[diag(codegen_gcc::invalid_monomorphization_basic_integer, code = "E0511")]
|
||||
pub(crate) struct InvalidMonomorphizationBasicInteger<'a> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub name: Symbol,
|
||||
pub ty: Ty<'a>,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[diag(codegen_gcc::invalid_monomorphization_invalid_float_vector, code = "E0511")]
|
||||
pub(crate) struct InvalidMonomorphizationInvalidFloatVector<'a> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub name: Symbol,
|
||||
pub elem_ty: &'a str,
|
||||
pub vec_ty: Ty<'a>,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[diag(codegen_gcc::invalid_monomorphization_not_float, code = "E0511")]
|
||||
pub(crate) struct InvalidMonomorphizationNotFloat<'a> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub name: Symbol,
|
||||
pub ty: Ty<'a>,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[diag(codegen_gcc::invalid_monomorphization_unrecognized, code = "E0511")]
|
||||
pub(crate) struct InvalidMonomorphizationUnrecognized {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub name: Symbol,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[diag(codegen_gcc::invalid_monomorphization_expected_signed_unsigned, code = "E0511")]
|
||||
pub(crate) struct InvalidMonomorphizationExpectedSignedUnsigned<'a> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub name: Symbol,
|
||||
pub elem_ty: Ty<'a>,
|
||||
pub vec_ty: Ty<'a>,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[diag(codegen_gcc::invalid_monomorphization_unsupported_element, code = "E0511")]
|
||||
pub(crate) struct InvalidMonomorphizationUnsupportedElement<'a> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub name: Symbol,
|
||||
pub in_ty: Ty<'a>,
|
||||
pub elem_ty: Ty<'a>,
|
||||
pub ret_ty: Ty<'a>,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[diag(codegen_gcc::invalid_monomorphization_invalid_bitmask, code = "E0511")]
|
||||
pub(crate) struct InvalidMonomorphizationInvalidBitmask<'a> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub name: Symbol,
|
||||
pub ty: Ty<'a>,
|
||||
pub expected_int_bits: u64,
|
||||
pub expected_bytes: u64,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[diag(codegen_gcc::invalid_monomorphization_simd_shuffle, code = "E0511")]
|
||||
pub(crate) struct InvalidMonomorphizationSimdShuffle<'a> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub name: Symbol,
|
||||
pub ty: Ty<'a>,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[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(SessionDiagnostic)]
|
||||
#[diag(codegen_gcc::invalid_monomorphization_mask_type, code = "E0511")]
|
||||
pub(crate) struct InvalidMonomorphizationMaskType<'a> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub name: Symbol,
|
||||
pub ty: Ty<'a>,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[diag(codegen_gcc::invalid_monomorphization_return_length, code = "E0511")]
|
||||
pub(crate) struct InvalidMonomorphizationReturnLength<'a> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub name: Symbol,
|
||||
pub in_len: u64,
|
||||
pub ret_ty: Ty<'a>,
|
||||
pub out_len: u64,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[diag(codegen_gcc::invalid_monomorphization_return_length_input_type, code = "E0511")]
|
||||
pub(crate) struct InvalidMonomorphizationReturnLengthInputType<'a> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub name: Symbol,
|
||||
pub in_len: u64,
|
||||
pub in_ty: Ty<'a>,
|
||||
pub ret_ty: Ty<'a>,
|
||||
pub out_len: u64,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[diag(codegen_gcc::invalid_monomorphization_return_element, code = "E0511")]
|
||||
pub(crate) struct InvalidMonomorphizationReturnElement<'a> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub name: Symbol,
|
||||
pub in_elem: Ty<'a>,
|
||||
pub in_ty: Ty<'a>,
|
||||
pub ret_ty: Ty<'a>,
|
||||
pub out_ty: Ty<'a>,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[diag(codegen_gcc::invalid_monomorphization_return_type, code = "E0511")]
|
||||
pub(crate) struct InvalidMonomorphizationReturnType<'a> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub name: Symbol,
|
||||
pub in_elem: Ty<'a>,
|
||||
pub in_ty: Ty<'a>,
|
||||
pub ret_ty: Ty<'a>,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[diag(codegen_gcc::invalid_monomorphization_inserted_type, code = "E0511")]
|
||||
pub(crate) struct InvalidMonomorphizationInsertedType<'a> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub name: Symbol,
|
||||
pub in_elem: Ty<'a>,
|
||||
pub in_ty: Ty<'a>,
|
||||
pub out_ty: Ty<'a>,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[diag(codegen_gcc::invalid_monomorphization_return_integer_type, code = "E0511")]
|
||||
pub(crate) struct InvalidMonomorphizationReturnIntegerType<'a> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub name: Symbol,
|
||||
pub ret_ty: Ty<'a>,
|
||||
pub out_ty: Ty<'a>,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[diag(codegen_gcc::invalid_monomorphization_mismatched_lengths, code = "E0511")]
|
||||
pub(crate) struct InvalidMonomorphizationMismatchedLengths {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub name: Symbol,
|
||||
pub m_len: u64,
|
||||
pub v_len: u64,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[diag(codegen_gcc::invalid_monomorphization_unsupported_cast, code = "E0511")]
|
||||
pub(crate) struct InvalidMonomorphizationUnsupportedCast<'a> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub name: Symbol,
|
||||
pub in_ty: Ty<'a>,
|
||||
pub in_elem: Ty<'a>,
|
||||
pub ret_ty: Ty<'a>,
|
||||
pub out_elem: Ty<'a>,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[diag(codegen_gcc::invalid_monomorphization_unsupported_operation, code = "E0511")]
|
||||
pub(crate) struct InvalidMonomorphizationUnsupportedOperation<'a> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub name: Symbol,
|
||||
pub in_ty: Ty<'a>,
|
||||
pub in_elem: Ty<'a>,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[diag(codegen_gcc::layout_size_overflow)]
|
||||
pub(crate) struct LayoutSizeOverflow {
|
||||
|
@ -4,7 +4,7 @@
|
||||
use gccjit::{ComparisonOp, Function, RValue, ToRValue, Type, UnaryOp, FunctionType};
|
||||
use rustc_codegen_ssa::MemFlags;
|
||||
use rustc_codegen_ssa::base::wants_msvc_seh;
|
||||
use rustc_codegen_ssa::common::{IntPredicate, span_invalid_monomorphization_error};
|
||||
use rustc_codegen_ssa::common::IntPredicate;
|
||||
use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
|
||||
use rustc_codegen_ssa::mir::place::PlaceRef;
|
||||
use rustc_codegen_ssa::traits::{ArgAbiMethods, BaseTypeMethods, BuilderMethods, ConstMethods, IntrinsicCallMethods};
|
||||
@ -20,6 +20,7 @@
|
||||
use crate::builder::Builder;
|
||||
use crate::common::{SignType, TypeReflection};
|
||||
use crate::context::CodegenCx;
|
||||
use crate::errors::InvalidMonomorphizationBasicInteger;
|
||||
use crate::type_of::LayoutGccExt;
|
||||
use crate::intrinsic::simd::generic_simd_intrinsic;
|
||||
|
||||
@ -242,15 +243,7 @@ fn codegen_intrinsic_call(&mut self, instance: Instance<'tcx>, fn_abi: &FnAbi<'t
|
||||
_ => bug!(),
|
||||
},
|
||||
None => {
|
||||
span_invalid_monomorphization_error(
|
||||
tcx.sess,
|
||||
span,
|
||||
&format!(
|
||||
"invalid monomorphization of `{}` intrinsic: \
|
||||
expected basic integer type, found `{}`",
|
||||
name, ty
|
||||
),
|
||||
);
|
||||
tcx.sess.emit_err(InvalidMonomorphizationBasicInteger { span, name, ty });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use gccjit::{BinaryOp, RValue, Type, ToRValue};
|
||||
use rustc_codegen_ssa::base::compare_simd_types;
|
||||
use rustc_codegen_ssa::common::{TypeKind, span_invalid_monomorphization_error};
|
||||
use rustc_codegen_ssa::common::TypeKind;
|
||||
use rustc_codegen_ssa::mir::operand::OperandRef;
|
||||
use rustc_codegen_ssa::mir::place::PlaceRef;
|
||||
use rustc_codegen_ssa::traits::{BaseTypeMethods, BuilderMethods};
|
||||
@ -14,43 +14,48 @@
|
||||
use rustc_target::abi::Align;
|
||||
|
||||
use crate::builder::Builder;
|
||||
use crate::errors::{
|
||||
InvalidMonomorphizationInvalidFloatVector,
|
||||
InvalidMonomorphizationNotFloat,
|
||||
InvalidMonomorphizationUnrecognized,
|
||||
InvalidMonomorphizationExpectedSignedUnsigned,
|
||||
InvalidMonomorphizationUnsupportedElement,
|
||||
InvalidMonomorphizationInvalidBitmask,
|
||||
InvalidMonomorphizationSimdShuffle,
|
||||
InvalidMonomorphizationExpectedSimd,
|
||||
InvalidMonomorphizationMaskType,
|
||||
InvalidMonomorphizationReturnLength,
|
||||
InvalidMonomorphizationReturnLengthInputType,
|
||||
InvalidMonomorphizationReturnElement,
|
||||
InvalidMonomorphizationReturnType,
|
||||
InvalidMonomorphizationInsertedType,
|
||||
InvalidMonomorphizationReturnIntegerType,
|
||||
InvalidMonomorphizationMismatchedLengths,
|
||||
InvalidMonomorphizationUnsupportedCast,
|
||||
InvalidMonomorphizationUnsupportedOperation
|
||||
};
|
||||
use crate::intrinsic;
|
||||
|
||||
pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(bx: &mut Builder<'a, 'gcc, 'tcx>, name: Symbol, callee_ty: Ty<'tcx>, args: &[OperandRef<'tcx, RValue<'gcc>>], ret_ty: Ty<'tcx>, llret_ty: Type<'gcc>, span: Span) -> Result<RValue<'gcc>, ()> {
|
||||
// macros for error handling:
|
||||
#[allow(unused_macro_rules)]
|
||||
macro_rules! emit_error {
|
||||
($msg: tt) => {
|
||||
emit_error!($msg, )
|
||||
};
|
||||
($msg: tt, $($fmt: tt)*) => {
|
||||
span_invalid_monomorphization_error(
|
||||
bx.sess(), span,
|
||||
&format!(concat!("invalid monomorphization of `{}` intrinsic: ", $msg),
|
||||
name, $($fmt)*));
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! return_error {
|
||||
($($fmt: tt)*) => {
|
||||
($err:expr) => {
|
||||
{
|
||||
emit_error!($($fmt)*);
|
||||
bx.sess().emit_err($err);
|
||||
return Err(());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! require {
|
||||
($cond: expr, $($fmt: tt)*) => {
|
||||
($cond:expr, $err:expr) => {
|
||||
if !$cond {
|
||||
return_error!($($fmt)*);
|
||||
return_error!($err);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! require_simd {
|
||||
($ty: expr, $position: expr) => {
|
||||
require!($ty.is_simd(), "expected SIMD {} type, found non-SIMD `{}`", $position, $ty)
|
||||
require!($ty.is_simd(), InvalidMonomorphizationExpectedSimd { span, name, position: $position, found_ty: $ty })
|
||||
};
|
||||
}
|
||||
|
||||
@ -82,10 +87,7 @@ macro_rules! require_simd {
|
||||
bx.load(int_ty, ptr, Align::ONE)
|
||||
}
|
||||
_ => return_error!(
|
||||
"invalid bitmask `{}`, expected `u{}` or `[u8; {}]`",
|
||||
mask_ty,
|
||||
expected_int_bits,
|
||||
expected_bytes
|
||||
InvalidMonomorphizationInvalidBitmask { span, name, ty: mask_ty, expected_int_bits, expected_bytes }
|
||||
),
|
||||
};
|
||||
|
||||
@ -127,18 +129,11 @@ macro_rules! require_simd {
|
||||
let (out_len, out_ty) = ret_ty.simd_size_and_type(bx.tcx());
|
||||
require!(
|
||||
in_len == out_len,
|
||||
"expected return type with length {} (same as input type `{}`), \
|
||||
found `{}` with length {}",
|
||||
in_len,
|
||||
in_ty,
|
||||
ret_ty,
|
||||
out_len
|
||||
InvalidMonomorphizationReturnLengthInputType { span, name, in_len, in_ty, ret_ty, out_len }
|
||||
);
|
||||
require!(
|
||||
bx.type_kind(bx.element_type(llret_ty)) == TypeKind::Integer,
|
||||
"expected return type with integer elements, found `{}` with non-integer `{}`",
|
||||
ret_ty,
|
||||
out_ty
|
||||
InvalidMonomorphizationReturnIntegerType {span, name, ret_ty, out_ty}
|
||||
);
|
||||
|
||||
return Ok(compare_simd_types(
|
||||
@ -163,8 +158,7 @@ macro_rules! require_simd {
|
||||
})
|
||||
}
|
||||
_ => return_error!(
|
||||
"simd_shuffle index must be an array of `u32`, got `{}`",
|
||||
args[2].layout.ty
|
||||
InvalidMonomorphizationSimdShuffle { span, name, ty: args[2].layout.ty }
|
||||
),
|
||||
}
|
||||
}
|
||||
@ -179,19 +173,11 @@ macro_rules! require_simd {
|
||||
let (out_len, out_ty) = ret_ty.simd_size_and_type(bx.tcx());
|
||||
require!(
|
||||
out_len == n,
|
||||
"expected return type of length {}, found `{}` with length {}",
|
||||
n,
|
||||
ret_ty,
|
||||
out_len
|
||||
InvalidMonomorphizationReturnLength { span, name, in_len: n, ret_ty, out_len }
|
||||
);
|
||||
require!(
|
||||
in_elem == out_ty,
|
||||
"expected return element type `{}` (element of input `{}`), \
|
||||
found `{}` with element type `{}`",
|
||||
in_elem,
|
||||
in_ty,
|
||||
ret_ty,
|
||||
out_ty
|
||||
InvalidMonomorphizationReturnElement { span, name, in_elem, in_ty, ret_ty, out_ty }
|
||||
);
|
||||
|
||||
let vector = args[2].immediate();
|
||||
@ -207,10 +193,7 @@ macro_rules! require_simd {
|
||||
if name == sym::simd_insert {
|
||||
require!(
|
||||
in_elem == arg_tys[2],
|
||||
"expected inserted type `{}` (element of input `{}`), found `{}`",
|
||||
in_elem,
|
||||
in_ty,
|
||||
arg_tys[2]
|
||||
InvalidMonomorphizationInsertedType { span, name, in_elem, in_ty, out_ty: arg_tys[2] }
|
||||
);
|
||||
let vector = args[0].immediate();
|
||||
let index = args[1].immediate();
|
||||
@ -263,10 +246,7 @@ macro_rules! require_simd {
|
||||
if name == sym::simd_extract {
|
||||
require!(
|
||||
ret_ty == in_elem,
|
||||
"expected return type `{}` (element of input `{}`), found `{}`",
|
||||
in_elem,
|
||||
in_ty,
|
||||
ret_ty
|
||||
InvalidMonomorphizationReturnType { span, name, in_elem, in_ty, ret_ty }
|
||||
);
|
||||
let vector = args[0].immediate();
|
||||
return Ok(bx.context.new_vector_access(None, vector, args[1].immediate()).to_rvalue());
|
||||
@ -279,13 +259,11 @@ macro_rules! require_simd {
|
||||
let (v_len, _) = arg_tys[1].simd_size_and_type(bx.tcx());
|
||||
require!(
|
||||
m_len == v_len,
|
||||
"mismatched lengths: mask length `{}` != other vector length `{}`",
|
||||
m_len,
|
||||
v_len
|
||||
InvalidMonomorphizationMismatchedLengths { span, name, m_len, v_len }
|
||||
);
|
||||
match m_elem_ty.kind() {
|
||||
ty::Int(_) => {}
|
||||
_ => return_error!("mask element type is `{}`, expected `i_`", m_elem_ty),
|
||||
_ => return_error!(InvalidMonomorphizationMaskType { span, name, ty: m_elem_ty }),
|
||||
}
|
||||
return Ok(bx.vector_select(args[0].immediate(), args[1].immediate(), args[2].immediate()));
|
||||
}
|
||||
@ -295,12 +273,7 @@ macro_rules! require_simd {
|
||||
let (out_len, out_elem) = ret_ty.simd_size_and_type(bx.tcx());
|
||||
require!(
|
||||
in_len == out_len,
|
||||
"expected return type with length {} (same as input type `{}`), \
|
||||
found `{}` with length {}",
|
||||
in_len,
|
||||
in_ty,
|
||||
ret_ty,
|
||||
out_len
|
||||
InvalidMonomorphizationReturnLengthInputType { span, name, in_len, in_ty, ret_ty, out_len }
|
||||
);
|
||||
// casting cares about nominal type, not just structural type
|
||||
if in_elem == out_elem {
|
||||
@ -412,13 +385,8 @@ enum Style {
|
||||
}
|
||||
_ => { /* Unsupported. Fallthrough. */ }
|
||||
}
|
||||
require!(
|
||||
false,
|
||||
"unsupported cast from `{}` with element `{}` to `{}` with element `{}`",
|
||||
in_ty,
|
||||
in_elem,
|
||||
ret_ty,
|
||||
out_elem
|
||||
return_error!(
|
||||
InvalidMonomorphizationUnsupportedCast { span, name, in_ty, in_elem, ret_ty, out_elem }
|
||||
);
|
||||
}
|
||||
|
||||
@ -431,10 +399,7 @@ macro_rules! arith_binary {
|
||||
})*
|
||||
_ => {},
|
||||
}
|
||||
require!(false,
|
||||
"unsupported operation on `{}` with element `{}`",
|
||||
in_ty,
|
||||
in_elem)
|
||||
return_error!(InvalidMonomorphizationUnsupportedOperation { span, name, in_ty, in_elem })
|
||||
})*
|
||||
}
|
||||
}
|
||||
@ -448,23 +413,14 @@ fn simd_simple_float_intrinsic<'gcc, 'tcx>(
|
||||
span: Span,
|
||||
args: &[OperandRef<'tcx, RValue<'gcc>>],
|
||||
) -> Result<RValue<'gcc>, ()> {
|
||||
macro_rules! emit_error {
|
||||
($msg: tt, $($fmt: tt)*) => {
|
||||
span_invalid_monomorphization_error(
|
||||
bx.sess(), span,
|
||||
&format!(concat!("invalid monomorphization of `{}` intrinsic: ", $msg),
|
||||
name, $($fmt)*));
|
||||
}
|
||||
}
|
||||
macro_rules! return_error {
|
||||
($($fmt: tt)*) => {
|
||||
($err:expr) => {
|
||||
{
|
||||
emit_error!($($fmt)*);
|
||||
bx.sess().emit_err($err);
|
||||
return Err(());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let (elem_ty_str, elem_ty) =
|
||||
if let ty::Float(f) = in_elem.kind() {
|
||||
let elem_ty = bx.cx.type_float_from_ty(*f);
|
||||
@ -472,16 +428,13 @@ macro_rules! return_error {
|
||||
32 => ("f32", elem_ty),
|
||||
64 => ("f64", elem_ty),
|
||||
_ => {
|
||||
return_error!(
|
||||
"unsupported element type `{}` of floating-point vector `{}`",
|
||||
f.name_str(),
|
||||
in_ty
|
||||
);
|
||||
// Can we pass elem_ty directly?
|
||||
return_error!(InvalidMonomorphizationInvalidFloatVector { span, name, elem_ty: f.name_str(), vec_ty: in_ty });
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
return_error!("`{}` is not a floating-point type", in_ty);
|
||||
return_error!(InvalidMonomorphizationNotFloat { span, name, ty: in_ty });
|
||||
};
|
||||
|
||||
let vec_ty = bx.cx.type_vector(elem_ty, in_len);
|
||||
@ -504,7 +457,7 @@ macro_rules! return_error {
|
||||
sym::simd_fsqrt => ("sqrt", bx.type_func(&[vec_ty], vec_ty)),
|
||||
sym::simd_round => ("round", bx.type_func(&[vec_ty], vec_ty)),
|
||||
sym::simd_trunc => ("trunc", bx.type_func(&[vec_ty], vec_ty)),
|
||||
_ => return_error!("unrecognized intrinsic `{}`", name),
|
||||
_ => return_error!(InvalidMonomorphizationUnrecognized { span, name })
|
||||
};
|
||||
let llvm_name = &format!("llvm.{0}.v{1}{2}", intr_name, in_len, elem_ty_str);
|
||||
let function = intrinsic::llvm::intrinsic(llvm_name, &bx.cx);
|
||||
@ -557,10 +510,7 @@ macro_rules! arith_unary {
|
||||
})*
|
||||
_ => {},
|
||||
}
|
||||
require!(false,
|
||||
"unsupported operation on `{}` with element `{}`",
|
||||
in_ty,
|
||||
in_elem)
|
||||
return_error!(InvalidMonomorphizationUnsupportedOperation { span, name, in_ty, in_elem })
|
||||
})*
|
||||
}
|
||||
}
|
||||
@ -579,12 +529,12 @@ macro_rules! arith_unary {
|
||||
ty::Int(i) => (true, i.bit_width().unwrap_or(ptr_bits), bx.cx.type_int_from_ty(i)),
|
||||
ty::Uint(i) => (false, i.bit_width().unwrap_or(ptr_bits), bx.cx.type_uint_from_ty(i)),
|
||||
_ => {
|
||||
return_error!(
|
||||
"expected element type `{}` of vector type `{}` \
|
||||
to be a signed or unsigned integer type",
|
||||
arg_tys[0].simd_size_and_type(bx.tcx()).1,
|
||||
arg_tys[0]
|
||||
);
|
||||
return_error!(InvalidMonomorphizationExpectedSignedUnsigned {
|
||||
span,
|
||||
name,
|
||||
elem_ty: arg_tys[0].simd_size_and_type(bx.tcx()).1,
|
||||
vec_ty: arg_tys[0],
|
||||
});
|
||||
}
|
||||
};
|
||||
let builtin_name =
|
||||
@ -617,10 +567,7 @@ macro_rules! arith_red {
|
||||
if name == sym::$name {
|
||||
require!(
|
||||
ret_ty == in_elem,
|
||||
"expected return type `{}` (element of input `{}`), found `{}`",
|
||||
in_elem,
|
||||
in_ty,
|
||||
ret_ty
|
||||
InvalidMonomorphizationReturnType { span, name, in_elem, in_ty, ret_ty }
|
||||
);
|
||||
return match in_elem.kind() {
|
||||
ty::Int(_) | ty::Uint(_) => {
|
||||
@ -644,13 +591,7 @@ macro_rules! arith_red {
|
||||
Ok(bx.vector_reduce_op(args[0].immediate(), $vec_op))
|
||||
}
|
||||
}
|
||||
_ => return_error!(
|
||||
"unsupported {} from `{}` with element `{}` to `{}`",
|
||||
sym::$name,
|
||||
in_ty,
|
||||
in_elem,
|
||||
ret_ty
|
||||
),
|
||||
_ => return_error!(InvalidMonomorphizationUnsupportedElement { span, name, in_ty, elem_ty: in_elem, ret_ty }),
|
||||
};
|
||||
}
|
||||
};
|
||||
@ -676,20 +617,11 @@ macro_rules! minmax_red {
|
||||
if name == sym::$name {
|
||||
require!(
|
||||
ret_ty == in_elem,
|
||||
"expected return type `{}` (element of input `{}`), found `{}`",
|
||||
in_elem,
|
||||
in_ty,
|
||||
ret_ty
|
||||
InvalidMonomorphizationReturnType { span, name, in_elem, in_ty, ret_ty }
|
||||
);
|
||||
return match in_elem.kind() {
|
||||
ty::Int(_) | ty::Uint(_) | ty::Float(_) => Ok(bx.$reduction(args[0].immediate())),
|
||||
_ => return_error!(
|
||||
"unsupported {} from `{}` with element `{}` to `{}`",
|
||||
sym::$name,
|
||||
in_ty,
|
||||
in_elem,
|
||||
ret_ty
|
||||
),
|
||||
_ => return_error!(InvalidMonomorphizationUnsupportedElement { span, name, in_ty, elem_ty: in_elem, ret_ty }),
|
||||
};
|
||||
}
|
||||
};
|
||||
@ -704,22 +636,13 @@ macro_rules! bitwise_red {
|
||||
let input = if !$boolean {
|
||||
require!(
|
||||
ret_ty == in_elem,
|
||||
"expected return type `{}` (element of input `{}`), found `{}`",
|
||||
in_elem,
|
||||
in_ty,
|
||||
ret_ty
|
||||
InvalidMonomorphizationReturnType { span, name, in_elem, in_ty, ret_ty }
|
||||
);
|
||||
args[0].immediate()
|
||||
} else {
|
||||
match in_elem.kind() {
|
||||
ty::Int(_) | ty::Uint(_) => {}
|
||||
_ => return_error!(
|
||||
"unsupported {} from `{}` with element `{}` to `{}`",
|
||||
sym::$name,
|
||||
in_ty,
|
||||
in_elem,
|
||||
ret_ty
|
||||
),
|
||||
_ => return_error!(InvalidMonomorphizationUnsupportedElement { span, name, in_ty, elem_ty: in_elem, ret_ty }),
|
||||
}
|
||||
|
||||
// boolean reductions operate on vectors of i1s:
|
||||
@ -733,11 +656,7 @@ macro_rules! bitwise_red {
|
||||
Ok(if !$boolean { r } else { bx.zext(r, bx.type_bool()) })
|
||||
}
|
||||
_ => return_error!(
|
||||
"unsupported {} from `{}` with element `{}` to `{}`",
|
||||
sym::$name,
|
||||
in_ty,
|
||||
in_elem,
|
||||
ret_ty
|
||||
InvalidMonomorphizationUnsupportedElement { span, name, in_ty, elem_ty: in_elem, ret_ty }
|
||||
),
|
||||
};
|
||||
}
|
||||
|
@ -12,3 +12,60 @@ codegen_gcc_unwinding_inline_asm =
|
||||
|
||||
codegen_gcc_lto_not_supported =
|
||||
LTO is not supported. You may get a linker error.
|
||||
|
||||
codegen_gcc_invalid_monomorphization_basic_integer =
|
||||
invalid monomorphization of `{$name}` intrinsic: expected basic integer type, found `{$ty}`
|
||||
|
||||
codegen_gcc_invalid_monomorphization_invalid_float_vector =
|
||||
invalid monomorphization of `{$name}` intrinsic: unsupported element type `{$elem_ty}` of floating-point vector `{$vec_ty}`
|
||||
|
||||
codegen_gcc_invalid_monomorphization_not_float =
|
||||
invalid monomorphization of `{$name}` intrinsic: `{$ty}` is not a floating-point type
|
||||
|
||||
codegen_gcc_invalid_monomorphization_unrecognized =
|
||||
invalid monomorphization of `{$name}` intrinsic: unrecognized intrinsic `{$name}`
|
||||
|
||||
codegen_gcc_invalid_monomorphization_expected_signed_unsigned =
|
||||
invalid monomorphization of `{$name}` intrinsic: expected element type `{$elem_ty}` of vector type `{$vec_ty}` to be a signed or unsigned integer type
|
||||
|
||||
codegen_gcc_invalid_monomorphization_unsupported_element =
|
||||
invalid monomorphization of `{$name}` intrinsic: unsupported {$name} from `{$in_ty}` with element `{$elem_ty}` to `{$ret_ty}`
|
||||
|
||||
codegen_gcc_invalid_monomorphization_invalid_bitmask =
|
||||
invalid monomorphization of `{$name}` intrinsic: invalid bitmask `{ty}`, expected `u{$expected_int_bits}` or `[u8; {$expected_bytes}]`
|
||||
|
||||
codegen_gcc_invalid_monomorphization_simd_shuffle =
|
||||
invalid monomorphization of `{$name}` intrinsic: simd_shuffle index must be an array of `u32`, got `{$ty}`
|
||||
|
||||
codegen_gcc_invalid_monomorphization_expected_simd =
|
||||
invalid monomorphization of `{$name}` intrinsic: expected SIMD {$expected_ty} type, found non-SIMD `{$found_ty}`
|
||||
|
||||
codegen_gcc_invalid_monomorphization_mask_type =
|
||||
invalid monomorphization of `{$name}` intrinsic: mask element type is `{$ty}`, expected `i_`
|
||||
|
||||
codegen_gcc_invalid_monomorphization_return_length =
|
||||
invalid monomorphization of `{$name}` intrinsic: expected return type of length {$in_len}, found `{$ret_ty}` with length {$out_len}
|
||||
|
||||
codegen_gcc_invalid_monomorphization_return_length_input_type =
|
||||
invalid monomorphization of `{$name}` intrinsic: expected return type with length {$in_len} (same as input type `{$in_ty}`), found `{$ret_ty}` with length {$out_len}
|
||||
|
||||
codegen_gcc_invalid_monomorphization_return_element =
|
||||
invalid monomorphization of `{$name}` intrinsic: expected return element type `{$in_elem}` (element of input `{$in_ty}`), found `{$ret_ty}` with element type `{$out_ty}`
|
||||
|
||||
codegen_gcc_invalid_monomorphization_return_type =
|
||||
invalid monomorphization of `{$name}` intrinsic: expected return type `{$in_elem}` (element of input `{$in_ty}`), found `{$ret_ty}`
|
||||
|
||||
codegen_gcc_invalid_monomorphization_inserted_type =
|
||||
invalid monomorphization of `{$name}` intrinsic: expected inserted type `{$in_elem}` (element of input `{$in_ty}`), found `{$out_ty}`
|
||||
|
||||
codegen_gcc_invalid_monomorphization_return_integer_type =
|
||||
invalid monomorphization of `{$name}` intrinsic: expected return type with integer elements, found `{$ret_ty}` with non-integer `{$out_ty}`
|
||||
|
||||
codegen_gcc_invalid_monomorphization_mismatched_lengths =
|
||||
invalid monomorphization of `{$name}` intrinsic: mismatched lengths: mask length `{$m_len}` != other vector length `{$v_len}`
|
||||
|
||||
codegen_gcc_invalid_monomorphization_unsupported_cast =
|
||||
invalid monomorphization of `{$name}` intrinsic: unsupported cast from `{$in_ty}` with element `{$in_elem}` to `{$ret_ty}` with element `{$out_elem}`
|
||||
|
||||
codegen_gcc_invalid_monomorphization_unsupported_operation =
|
||||
invalid monomorphization of `{$name}` intrinsic: unsupported operation on `{$in_ty}` with element `{$in_elem}`
|
||||
|
Loading…
Reference in New Issue
Block a user