Skip to content

Commit 7f945b2

Browse files
committed
add simd_arith_offset intrinsics
1 parent de392c7 commit 7f945b2

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

compiler/rustc_codegen_llvm/src/intrinsic.rs

+21
Original file line numberDiff line numberDiff line change
@@ -1839,6 +1839,27 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#,
18391839
simd_neg: Int => neg, Float => fneg;
18401840
}
18411841

1842+
if name == sym::simd_arith_offset {
1843+
// This also checks that the first operand is a ptr type.
1844+
let pointee = in_elem.builtin_deref(true).unwrap_or_else(|| {
1845+
span_bug!(span, "must be called with a vector of pointer types as first argument")
1846+
});
1847+
let layout = bx.layout_of(pointee.ty);
1848+
let ptrs = args[0].immediate();
1849+
// The second argument must be a ptr-sized integer.
1850+
// (We don't care about the signedness, this is wrapping anyway.)
1851+
let (_offsets_len, offsets_elem) = arg_tys[1].simd_size_and_type(bx.tcx());
1852+
if !matches!(offsets_elem.kind(), ty::Int(ty::IntTy::Isize) | ty::Uint(ty::UintTy::Usize)) {
1853+
span_bug!(
1854+
span,
1855+
"must be called with a vector of pointer-sized integers as second argument"
1856+
);
1857+
}
1858+
let offsets = args[1].immediate();
1859+
1860+
return Ok(bx.gep(bx.backend_type(layout), ptrs, &[offsets]));
1861+
}
1862+
18421863
if name == sym::simd_saturating_add || name == sym::simd_saturating_sub {
18431864
let lhs = args[0].immediate();
18441865
let rhs = args[1].immediate();

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,7 @@ symbols! {
12451245
simd,
12461246
simd_add,
12471247
simd_and,
1248+
simd_arith_offset,
12481249
simd_as,
12491250
simd_bitmask,
12501251
simd_cast,

compiler/rustc_typeck/src/check/intrinsic.rs

+1
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ pub fn check_platform_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>)
437437
| sym::simd_fpow
438438
| sym::simd_saturating_add
439439
| sym::simd_saturating_sub => (1, vec![param(0), param(0)], param(0)),
440+
sym::simd_arith_offset => (2, vec![param(0), param(1)], param(0)),
440441
sym::simd_neg
441442
| sym::simd_fsqrt
442443
| sym::simd_fsin

0 commit comments

Comments
 (0)