Skip to content

Commit

Permalink
UPDATE - replace expected_simd error with one from codegen_ssa
Browse files Browse the repository at this point in the history
Here I am assuming we want to treat these parameters (input, first, second, third, return) as translatable
  • Loading branch information
JhonnyBillM committed Jul 20, 2023
1 parent 051615e commit 7a888fb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 42 deletions.
3 changes: 0 additions & 3 deletions compiler/rustc_codegen_gcc/messages.ftl
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
codegen_gcc_invalid_minimum_alignment =
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 =
LTO is not supported. You may get a linker error.
Expand Down
13 changes: 1 addition & 12 deletions compiler/rustc_codegen_gcc/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg};
use rustc_macros::Diagnostic;
use rustc_middle::ty::Ty;
use rustc_span::{Span, Symbol};
use rustc_span::Span;
use std::borrow::Cow;

struct ExitCode(Option<i32>);
Expand All @@ -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)]
#[diag(codegen_gcc_lto_not_supported)]
pub(crate) struct LTONotSupported;
Expand Down
42 changes: 15 additions & 27 deletions compiler/rustc_codegen_gcc/src/intrinsic/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ use rustc_target::abi::Align;
use crate::builder::Builder;
#[cfg(feature="master")]
use crate::context::CodegenCx;
#[cfg(feature="master")]
use crate::errors::{
InvalidMonomorphizationExpectedSimd,
};

pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
bx: &mut Builder<'a, 'gcc, 'tcx>,
Expand All @@ -50,16 +46,8 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
};
}
macro_rules! require_simd {
($ty: expr, $position: expr) => {
require!(
$ty.is_simd(),
InvalidMonomorphizationExpectedSimd {
span,
name,
position: $position,
found_ty: $ty
}
)
($ty: expr, $diag: expr) => {
require!($ty.is_simd(), $diag)
};
}

Expand All @@ -69,7 +57,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
let arg_tys = sig.inputs();

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 expected_int_bits = (len.max(8) - 1).next_power_of_two();
Expand Down Expand Up @@ -122,7 +110,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
}

// 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 comparison = match name {
Expand All @@ -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());
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());
require!(
Expand Down Expand Up @@ -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());
require!(
Expand Down Expand Up @@ -240,7 +228,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
if name == sym::simd_select {
let m_elem_ty = in_elem;
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());
require!(
m_len == v_len,
Expand All @@ -255,7 +243,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(

#[cfg(feature="master")]
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());
require!(
in_len == out_len,
Expand Down Expand Up @@ -557,10 +545,10 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
// * M: any integer width is supported, will be truncated to i1

// All types must be simd vector types
require_simd!(in_ty, "first");
require_simd!(arg_tys[1], "second");
require_simd!(arg_tys[2], "third");
require_simd!(ret_ty, "return");
require_simd!(in_ty, InvalidMonomorphization::SimdFirst { span, name, ty: in_ty });
require_simd!(arg_tys[1], InvalidMonomorphization::SimdSecond { span, name, ty: arg_tys[1] });
require_simd!(arg_tys[2], InvalidMonomorphization::SimdThird { span, name, ty: arg_tys[2] });
require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty });

// Of the same length:
let (out_len, _) = arg_tys[1].simd_size_and_type(bx.tcx());
Expand Down Expand Up @@ -665,9 +653,9 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
// * M: any integer width is supported, will be truncated to i1

// All types must be simd vector types
require_simd!(in_ty, "first");
require_simd!(arg_tys[1], "second");
require_simd!(arg_tys[2], "third");
require_simd!(in_ty, InvalidMonomorphization::SimdFirst { span, name, ty: in_ty });
require_simd!(arg_tys[1], InvalidMonomorphization::SimdSecond { span, name, ty: arg_tys[1] });
require_simd!(arg_tys[2], InvalidMonomorphization::SimdThird { span, name, ty: arg_tys[2] });

// Of the same length:
let (element_len1, _) = arg_tys[1].simd_size_and_type(bx.tcx());
Expand Down

0 comments on commit 7a888fb

Please sign in to comment.