Skip to content

Commit 7a888fb

Browse files
committed
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
1 parent 051615e commit 7a888fb

File tree

3 files changed

+16
-42
lines changed

3 files changed

+16
-42
lines changed

compiler/rustc_codegen_gcc/messages.ftl

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
codegen_gcc_invalid_minimum_alignment =
22
invalid minimum global alignment: {$err}
33
4-
codegen_gcc_invalid_monomorphization_expected_simd =
5-
invalid monomorphization of `{$name}` intrinsic: expected SIMD {$expected_ty} type, found non-SIMD `{$found_ty}`
6-
74
codegen_gcc_lto_not_supported =
85
LTO is not supported. You may get a linker error.
96

compiler/rustc_codegen_gcc/src/errors.rs

+1-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg};
22
use rustc_macros::Diagnostic;
3-
use rustc_middle::ty::Ty;
4-
use rustc_span::{Span, Symbol};
3+
use rustc_span::Span;
54
use std::borrow::Cow;
65

76
struct ExitCode(Option<i32>);
@@ -16,16 +15,6 @@ impl IntoDiagnosticArg for ExitCode {
1615
}
1716
}
1817

19-
#[derive(Diagnostic)]
20-
#[diag(codegen_gcc_invalid_monomorphization_expected_simd, code = "E0511")]
21-
pub(crate) struct InvalidMonomorphizationExpectedSimd<'a> {
22-
#[primary_span]
23-
pub span: Span,
24-
pub name: Symbol,
25-
pub position: &'a str,
26-
pub found_ty: Ty<'a>,
27-
}
28-
2918
#[derive(Diagnostic)]
3019
#[diag(codegen_gcc_lto_not_supported)]
3120
pub(crate) struct LTONotSupported;

compiler/rustc_codegen_gcc/src/intrinsic/simd.rs

+15-27
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ use rustc_target::abi::Align;
2121
use crate::builder::Builder;
2222
#[cfg(feature="master")]
2323
use crate::context::CodegenCx;
24-
#[cfg(feature="master")]
25-
use crate::errors::{
26-
InvalidMonomorphizationExpectedSimd,
27-
};
2824

2925
pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
3026
bx: &mut Builder<'a, 'gcc, 'tcx>,
@@ -50,16 +46,8 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
5046
};
5147
}
5248
macro_rules! require_simd {
53-
($ty: expr, $position: expr) => {
54-
require!(
55-
$ty.is_simd(),
56-
InvalidMonomorphizationExpectedSimd {
57-
span,
58-
name,
59-
position: $position,
60-
found_ty: $ty
61-
}
62-
)
49+
($ty: expr, $diag: expr) => {
50+
require!($ty.is_simd(), $diag)
6351
};
6452
}
6553

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

7159
if name == sym::simd_select_bitmask {
72-
require_simd!(arg_tys[1], "argument");
60+
require_simd!(arg_tys[1], InvalidMonomorphization::SimdArgument { span, name, ty: arg_tys[1] });
7361
let (len, _) = arg_tys[1].simd_size_and_type(bx.tcx());
7462

7563
let expected_int_bits = (len.max(8) - 1).next_power_of_two();
@@ -122,7 +110,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
122110
}
123111

124112
// every intrinsic below takes a SIMD vector as its first argument
125-
require_simd!(arg_tys[0], "input");
113+
require_simd!(arg_tys[0], InvalidMonomorphization::SimdInput { span, name, ty: arg_tys[0] });
126114
let in_ty = arg_tys[0];
127115

128116
let comparison = match name {
@@ -137,7 +125,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
137125

138126
let (in_len, in_elem) = arg_tys[0].simd_size_and_type(bx.tcx());
139127
if let Some(cmp_op) = comparison {
140-
require_simd!(ret_ty, "return");
128+
require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty });
141129

142130
let (out_len, out_ty) = ret_ty.simd_size_and_type(bx.tcx());
143131
require!(
@@ -193,7 +181,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
193181
})
194182
};
195183

196-
require_simd!(ret_ty, "return");
184+
require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty });
197185

198186
let (out_len, out_ty) = ret_ty.simd_size_and_type(bx.tcx());
199187
require!(
@@ -240,7 +228,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
240228
if name == sym::simd_select {
241229
let m_elem_ty = in_elem;
242230
let m_len = in_len;
243-
require_simd!(arg_tys[1], "argument");
231+
require_simd!(arg_tys[1], InvalidMonomorphization::SimdArgument { span, name, ty: arg_tys[1] });
244232
let (v_len, _) = arg_tys[1].simd_size_and_type(bx.tcx());
245233
require!(
246234
m_len == v_len,
@@ -255,7 +243,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
255243

256244
#[cfg(feature="master")]
257245
if name == sym::simd_cast || name == sym::simd_as {
258-
require_simd!(ret_ty, "return");
246+
require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty });
259247
let (out_len, out_elem) = ret_ty.simd_size_and_type(bx.tcx());
260248
require!(
261249
in_len == out_len,
@@ -557,10 +545,10 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
557545
// * M: any integer width is supported, will be truncated to i1
558546

559547
// All types must be simd vector types
560-
require_simd!(in_ty, "first");
561-
require_simd!(arg_tys[1], "second");
562-
require_simd!(arg_tys[2], "third");
563-
require_simd!(ret_ty, "return");
548+
require_simd!(in_ty, InvalidMonomorphization::SimdFirst { span, name, ty: in_ty });
549+
require_simd!(arg_tys[1], InvalidMonomorphization::SimdSecond { span, name, ty: arg_tys[1] });
550+
require_simd!(arg_tys[2], InvalidMonomorphization::SimdThird { span, name, ty: arg_tys[2] });
551+
require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty });
564552

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

667655
// All types must be simd vector types
668-
require_simd!(in_ty, "first");
669-
require_simd!(arg_tys[1], "second");
670-
require_simd!(arg_tys[2], "third");
656+
require_simd!(in_ty, InvalidMonomorphization::SimdFirst { span, name, ty: in_ty });
657+
require_simd!(arg_tys[1], InvalidMonomorphization::SimdSecond { span, name, ty: arg_tys[1] });
658+
require_simd!(arg_tys[2], InvalidMonomorphization::SimdThird { span, name, ty: arg_tys[2] });
671659

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

0 commit comments

Comments
 (0)