Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b8005bf

Browse files
committedApr 20, 2025
Auto merge of rust-lang#140079 - ChrisDenton:rollup-2h5cg94, r=ChrisDenton
Rollup of 5 pull requests Successful merges: - rust-lang#137953 (simd intrinsics with mask: accept unsigned integer masks, and fix some of the errors) - rust-lang#139990 (transmutability: remove NFA intermediate representation) - rust-lang#140044 (rustc-dev-guide subtree update) - rust-lang#140051 (Switch exploit mitigations to mdbook footnotes) - rust-lang#140054 (docs: fix typo change from inconstants to invariants) r? `@ghost` `@rustbot` modify labels: rollup
2 parents b8c54d6 + d3fab38 commit b8005bf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+898
-598
lines changed
 

‎compiler/rustc_codegen_gcc/src/intrinsic/simd.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,14 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
447447
m_len == v_len,
448448
InvalidMonomorphization::MismatchedLengths { span, name, m_len, v_len }
449449
);
450+
// TODO: also support unsigned integers.
450451
match *m_elem_ty.kind() {
451452
ty::Int(_) => {}
452-
_ => return_error!(InvalidMonomorphization::MaskType { span, name, ty: m_elem_ty }),
453+
_ => return_error!(InvalidMonomorphization::MaskWrongElementType {
454+
span,
455+
name,
456+
ty: m_elem_ty
457+
}),
453458
}
454459
return Ok(bx.vector_select(args[0].immediate(), args[1].immediate(), args[2].immediate()));
455460
}
@@ -991,19 +996,15 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
991996
assert_eq!(pointer_count - 1, ptr_count(element_ty0));
992997
assert_eq!(underlying_ty, non_ptr(element_ty0));
993998

994-
// The element type of the third argument must be a signed integer type of any width:
999+
// The element type of the third argument must be an integer type of any width:
1000+
// TODO: also support unsigned integers.
9951001
let (_, element_ty2) = arg_tys[2].simd_size_and_type(bx.tcx());
9961002
match *element_ty2.kind() {
9971003
ty::Int(_) => (),
9981004
_ => {
9991005
require!(
10001006
false,
1001-
InvalidMonomorphization::ThirdArgElementType {
1002-
span,
1003-
name,
1004-
expected_element: element_ty2,
1005-
third_arg: arg_tys[2]
1006-
}
1007+
InvalidMonomorphization::MaskWrongElementType { span, name, ty: element_ty2 }
10071008
);
10081009
}
10091010
}
@@ -1109,17 +1110,13 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
11091110
assert_eq!(underlying_ty, non_ptr(element_ty0));
11101111

11111112
// The element type of the third argument must be a signed integer type of any width:
1113+
// TODO: also support unsigned integers.
11121114
match *element_ty2.kind() {
11131115
ty::Int(_) => (),
11141116
_ => {
11151117
require!(
11161118
false,
1117-
InvalidMonomorphization::ThirdArgElementType {
1118-
span,
1119-
name,
1120-
expected_element: element_ty2,
1121-
third_arg: arg_tys[2]
1122-
}
1119+
InvalidMonomorphization::MaskWrongElementType { span, name, ty: element_ty2 }
11231120
);
11241121
}
11251122
}

‎compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 12 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,18 +1184,6 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
11841184
}};
11851185
}
11861186

1187-
/// Returns the bitwidth of the `$ty` argument if it is an `Int` type.
1188-
macro_rules! require_int_ty {
1189-
($ty: expr, $diag: expr) => {
1190-
match $ty {
1191-
ty::Int(i) => i.bit_width().unwrap_or_else(|| bx.data_layout().pointer_size.bits()),
1192-
_ => {
1193-
return_error!($diag);
1194-
}
1195-
}
1196-
};
1197-
}
1198-
11991187
/// Returns the bitwidth of the `$ty` argument if it is an `Int` or `Uint` type.
12001188
macro_rules! require_int_or_uint_ty {
12011189
($ty: expr, $diag: expr) => {
@@ -1485,9 +1473,9 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
14851473
m_len == v_len,
14861474
InvalidMonomorphization::MismatchedLengths { span, name, m_len, v_len }
14871475
);
1488-
let in_elem_bitwidth = require_int_ty!(
1476+
let in_elem_bitwidth = require_int_or_uint_ty!(
14891477
m_elem_ty.kind(),
1490-
InvalidMonomorphization::MaskType { span, name, ty: m_elem_ty }
1478+
InvalidMonomorphization::MaskWrongElementType { span, name, ty: m_elem_ty }
14911479
);
14921480
let m_i1s = vector_mask_to_bitmask(bx, args[0].immediate(), in_elem_bitwidth, m_len);
14931481
return Ok(bx.select(m_i1s, args[1].immediate(), args[2].immediate()));
@@ -1508,7 +1496,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
15081496
// Integer vector <i{in_bitwidth} x in_len>:
15091497
let in_elem_bitwidth = require_int_or_uint_ty!(
15101498
in_elem.kind(),
1511-
InvalidMonomorphization::VectorArgument { span, name, in_ty, in_elem }
1499+
InvalidMonomorphization::MaskWrongElementType { span, name, ty: in_elem }
15121500
);
15131501

15141502
let i1xn = vector_mask_to_bitmask(bx, args[0].immediate(), in_elem_bitwidth, in_len);
@@ -1732,14 +1720,9 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
17321720
}
17331721
);
17341722

1735-
let mask_elem_bitwidth = require_int_ty!(
1723+
let mask_elem_bitwidth = require_int_or_uint_ty!(
17361724
element_ty2.kind(),
1737-
InvalidMonomorphization::ThirdArgElementType {
1738-
span,
1739-
name,
1740-
expected_element: element_ty2,
1741-
third_arg: arg_tys[2]
1742-
}
1725+
InvalidMonomorphization::MaskWrongElementType { span, name, ty: element_ty2 }
17431726
);
17441727

17451728
// Alignment of T, must be a constant integer value:
@@ -1834,14 +1817,9 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
18341817
}
18351818
);
18361819

1837-
let m_elem_bitwidth = require_int_ty!(
1820+
let m_elem_bitwidth = require_int_or_uint_ty!(
18381821
mask_elem.kind(),
1839-
InvalidMonomorphization::ThirdArgElementType {
1840-
span,
1841-
name,
1842-
expected_element: values_elem,
1843-
third_arg: mask_ty,
1844-
}
1822+
InvalidMonomorphization::MaskWrongElementType { span, name, ty: mask_elem }
18451823
);
18461824

18471825
let mask = vector_mask_to_bitmask(bx, args[0].immediate(), m_elem_bitwidth, mask_len);
@@ -1924,14 +1902,9 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
19241902
}
19251903
);
19261904

1927-
let m_elem_bitwidth = require_int_ty!(
1905+
let m_elem_bitwidth = require_int_or_uint_ty!(
19281906
mask_elem.kind(),
1929-
InvalidMonomorphization::ThirdArgElementType {
1930-
span,
1931-
name,
1932-
expected_element: values_elem,
1933-
third_arg: mask_ty,
1934-
}
1907+
InvalidMonomorphization::MaskWrongElementType { span, name, ty: mask_elem }
19351908
);
19361909

19371910
let mask = vector_mask_to_bitmask(bx, args[0].immediate(), m_elem_bitwidth, mask_len);
@@ -2019,15 +1992,10 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
20191992
}
20201993
);
20211994

2022-
// The element type of the third argument must be a signed integer type of any width:
2023-
let mask_elem_bitwidth = require_int_ty!(
1995+
// The element type of the third argument must be an integer type of any width:
1996+
let mask_elem_bitwidth = require_int_or_uint_ty!(
20241997
element_ty2.kind(),
2025-
InvalidMonomorphization::ThirdArgElementType {
2026-
span,
2027-
name,
2028-
expected_element: element_ty2,
2029-
third_arg: arg_tys[2]
2030-
}
1998+
InvalidMonomorphization::MaskWrongElementType { span, name, ty: element_ty2 }
20311999
);
20322000

20332001
// Alignment of T, must be a constant integer value:

0 commit comments

Comments
 (0)
Please sign in to comment.