Skip to content

Commit 451a211

Browse files
authored
Convert vsli_n_* neon methods to const generics (#1027)
1 parent c0cca91 commit 451a211

File tree

3 files changed

+201
-201
lines changed

3 files changed

+201
-201
lines changed

crates/core_arch/src/aarch64/neon/mod.rs

Lines changed: 100 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -2317,182 +2317,182 @@ pub unsafe fn vcvtq_u32_f32(a: float32x4_t) -> uint32x4_t {
23172317
/// Shift Left and Insert (immediate)
23182318
#[inline]
23192319
#[target_feature(enable = "neon")]
2320-
#[cfg_attr(test, assert_instr(sli, n = 1))]
2321-
#[rustc_args_required_const(2)]
2322-
pub unsafe fn vsli_n_s8(a: int8x8_t, b: int8x8_t, n: i32) -> int8x8_t {
2323-
assert!(0 <= n && n <= 7, "must have 0 ≤ n ≤ 7, but n = {}", n);
2324-
vsli_n_s8_(a, b, n)
2320+
#[cfg_attr(test, assert_instr(sli, N = 1))]
2321+
#[rustc_legacy_const_generics(2)]
2322+
pub unsafe fn vsli_n_s8<const N: i32>(a: int8x8_t, b: int8x8_t) -> int8x8_t {
2323+
static_assert_imm3!(N);
2324+
vsli_n_s8_(a, b, N)
23252325
}
23262326
/// Shift Left and Insert (immediate)
23272327
#[inline]
23282328
#[target_feature(enable = "neon")]
2329-
#[cfg_attr(test, assert_instr(sli, n = 1))]
2330-
#[rustc_args_required_const(2)]
2331-
pub unsafe fn vsliq_n_s8(a: int8x16_t, b: int8x16_t, n: i32) -> int8x16_t {
2332-
assert!(0 <= n && n <= 7, "must have 0 ≤ n ≤ 7, but n = {}", n);
2333-
vsliq_n_s8_(a, b, n)
2329+
#[cfg_attr(test, assert_instr(sli, N = 1))]
2330+
#[rustc_legacy_const_generics(2)]
2331+
pub unsafe fn vsliq_n_s8<const N: i32>(a: int8x16_t, b: int8x16_t) -> int8x16_t {
2332+
static_assert_imm3!(N);
2333+
vsliq_n_s8_(a, b, N)
23342334
}
23352335
/// Shift Left and Insert (immediate)
23362336
#[inline]
23372337
#[target_feature(enable = "neon")]
2338-
#[cfg_attr(test, assert_instr(sli, n = 1))]
2339-
#[rustc_args_required_const(2)]
2340-
pub unsafe fn vsli_n_s16(a: int16x4_t, b: int16x4_t, n: i32) -> int16x4_t {
2341-
assert!(0 <= n && n <= 15, "must have 0 ≤ n ≤ 15, but n = {}", n);
2342-
vsli_n_s16_(a, b, n)
2338+
#[cfg_attr(test, assert_instr(sli, N = 1))]
2339+
#[rustc_legacy_const_generics(2)]
2340+
pub unsafe fn vsli_n_s16<const N: i32>(a: int16x4_t, b: int16x4_t) -> int16x4_t {
2341+
static_assert_imm4!(N);
2342+
vsli_n_s16_(a, b, N)
23432343
}
23442344
/// Shift Left and Insert (immediate)
23452345
#[inline]
23462346
#[target_feature(enable = "neon")]
2347-
#[cfg_attr(test, assert_instr(sli, n = 1))]
2348-
#[rustc_args_required_const(2)]
2349-
pub unsafe fn vsliq_n_s16(a: int16x8_t, b: int16x8_t, n: i32) -> int16x8_t {
2350-
assert!(0 <= n && n <= 15, "must have 0 ≤ n ≤ 15, but n = {}", n);
2351-
vsliq_n_s16_(a, b, n)
2347+
#[cfg_attr(test, assert_instr(sli, N = 1))]
2348+
#[rustc_legacy_const_generics(2)]
2349+
pub unsafe fn vsliq_n_s16<const N: i32>(a: int16x8_t, b: int16x8_t) -> int16x8_t {
2350+
static_assert_imm4!(N);
2351+
vsliq_n_s16_(a, b, N)
23522352
}
23532353
/// Shift Left and Insert (immediate)
23542354
#[inline]
23552355
#[target_feature(enable = "neon")]
2356-
#[cfg_attr(test, assert_instr(sli, n = 1))]
2357-
#[rustc_args_required_const(2)]
2358-
pub unsafe fn vsli_n_s32(a: int32x2_t, b: int32x2_t, n: i32) -> int32x2_t {
2359-
assert!(0 <= n && n <= 31, "must have 0 ≤ n ≤ 31, but n = {}", n);
2360-
vsli_n_s32_(a, b, n)
2356+
#[cfg_attr(test, assert_instr(sli, N = 1))]
2357+
#[rustc_legacy_const_generics(2)]
2358+
pub unsafe fn vsli_n_s32<const N: i32>(a: int32x2_t, b: int32x2_t) -> int32x2_t {
2359+
static_assert!(N: i32 where N >= 0 && N <= 31);
2360+
vsli_n_s32_(a, b, N)
23612361
}
23622362
/// Shift Left and Insert (immediate)
23632363
#[inline]
23642364
#[target_feature(enable = "neon")]
2365-
#[cfg_attr(test, assert_instr(sli, n = 1))]
2366-
#[rustc_args_required_const(2)]
2367-
pub unsafe fn vsliq_n_s32(a: int32x4_t, b: int32x4_t, n: i32) -> int32x4_t {
2368-
assert!(0 <= n && n <= 31, "must have 0 ≤ n ≤ 31, but n = {}", n);
2369-
vsliq_n_s32_(a, b, n)
2365+
#[cfg_attr(test, assert_instr(sli, N = 1))]
2366+
#[rustc_legacy_const_generics(2)]
2367+
pub unsafe fn vsliq_n_s32<const N: i32>(a: int32x4_t, b: int32x4_t) -> int32x4_t {
2368+
static_assert!(N: i32 where N >= 0 && N <= 31);
2369+
vsliq_n_s32_(a, b, N)
23702370
}
23712371
/// Shift Left and Insert (immediate)
23722372
#[inline]
23732373
#[target_feature(enable = "neon")]
2374-
#[cfg_attr(test, assert_instr(sli, n = 1))]
2375-
#[rustc_args_required_const(2)]
2376-
pub unsafe fn vsli_n_s64(a: int64x1_t, b: int64x1_t, n: i32) -> int64x1_t {
2377-
assert!(0 <= n && n <= 63, "must have 0 ≤ n ≤ 63, but n = {}", n);
2378-
vsli_n_s64_(a, b, n)
2374+
#[cfg_attr(test, assert_instr(sli, N = 1))]
2375+
#[rustc_legacy_const_generics(2)]
2376+
pub unsafe fn vsli_n_s64<const N: i32>(a: int64x1_t, b: int64x1_t) -> int64x1_t {
2377+
static_assert!(N: i32 where N >= 0 && N <= 63);
2378+
vsli_n_s64_(a, b, N)
23792379
}
23802380
/// Shift Left and Insert (immediate)
23812381
#[inline]
23822382
#[target_feature(enable = "neon")]
2383-
#[cfg_attr(test, assert_instr(sli, n = 1))]
2384-
#[rustc_args_required_const(2)]
2385-
pub unsafe fn vsliq_n_s64(a: int64x2_t, b: int64x2_t, n: i32) -> int64x2_t {
2386-
assert!(0 <= n && n <= 63, "must have 0 ≤ n ≤ 63, but n = {}", n);
2387-
vsliq_n_s64_(a, b, n)
2383+
#[cfg_attr(test, assert_instr(sli, N = 1))]
2384+
#[rustc_legacy_const_generics(2)]
2385+
pub unsafe fn vsliq_n_s64<const N: i32>(a: int64x2_t, b: int64x2_t) -> int64x2_t {
2386+
static_assert!(N: i32 where N >= 0 && N <= 63);
2387+
vsliq_n_s64_(a, b, N)
23882388
}
23892389
/// Shift Left and Insert (immediate)
23902390
#[inline]
23912391
#[target_feature(enable = "neon")]
2392-
#[cfg_attr(test, assert_instr(sli, n = 1))]
2393-
#[rustc_args_required_const(2)]
2394-
pub unsafe fn vsli_n_u8(a: uint8x8_t, b: uint8x8_t, n: i32) -> uint8x8_t {
2395-
assert!(0 <= n && n <= 7, "must have 0 ≤ n ≤ 7, but n = {}", n);
2396-
transmute(vsli_n_s8_(transmute(a), transmute(b), n))
2392+
#[cfg_attr(test, assert_instr(sli, N = 1))]
2393+
#[rustc_legacy_const_generics(2)]
2394+
pub unsafe fn vsli_n_u8<const N: i32>(a: uint8x8_t, b: uint8x8_t) -> uint8x8_t {
2395+
static_assert_imm3!(N);
2396+
transmute(vsli_n_s8_(transmute(a), transmute(b), N))
23972397
}
23982398
/// Shift Left and Insert (immediate)
23992399
#[inline]
24002400
#[target_feature(enable = "neon")]
2401-
#[cfg_attr(test, assert_instr(sli, n = 1))]
2402-
#[rustc_args_required_const(2)]
2403-
pub unsafe fn vsliq_n_u8(a: uint8x16_t, b: uint8x16_t, n: i32) -> uint8x16_t {
2404-
assert!(0 <= n && n <= 7, "must have 0 ≤ n ≤ 7, but n = {}", n);
2405-
transmute(vsliq_n_s8_(transmute(a), transmute(b), n))
2401+
#[cfg_attr(test, assert_instr(sli, N = 1))]
2402+
#[rustc_legacy_const_generics(2)]
2403+
pub unsafe fn vsliq_n_u8<const N: i32>(a: uint8x16_t, b: uint8x16_t) -> uint8x16_t {
2404+
static_assert_imm3!(N);
2405+
transmute(vsliq_n_s8_(transmute(a), transmute(b), N))
24062406
}
24072407
/// Shift Left and Insert (immediate)
24082408
#[inline]
24092409
#[target_feature(enable = "neon")]
2410-
#[cfg_attr(test, assert_instr(sli, n = 1))]
2411-
#[rustc_args_required_const(2)]
2412-
pub unsafe fn vsli_n_u16(a: uint16x4_t, b: uint16x4_t, n: i32) -> uint16x4_t {
2413-
assert!(0 <= n && n <= 15, "must have 0 ≤ n ≤ 15, but n = {}", n);
2414-
transmute(vsli_n_s16_(transmute(a), transmute(b), n))
2410+
#[cfg_attr(test, assert_instr(sli, N = 1))]
2411+
#[rustc_legacy_const_generics(2)]
2412+
pub unsafe fn vsli_n_u16<const N: i32>(a: uint16x4_t, b: uint16x4_t) -> uint16x4_t {
2413+
static_assert_imm4!(N);
2414+
transmute(vsli_n_s16_(transmute(a), transmute(b), N))
24152415
}
24162416
/// Shift Left and Insert (immediate)
24172417
#[inline]
24182418
#[target_feature(enable = "neon")]
2419-
#[cfg_attr(test, assert_instr(sli, n = 1))]
2420-
#[rustc_args_required_const(2)]
2421-
pub unsafe fn vsliq_n_u16(a: uint16x8_t, b: uint16x8_t, n: i32) -> uint16x8_t {
2422-
assert!(0 <= n && n <= 15, "must have 0 ≤ n ≤ 15, but n = {}", n);
2423-
transmute(vsliq_n_s16_(transmute(a), transmute(b), n))
2419+
#[cfg_attr(test, assert_instr(sli, N = 1))]
2420+
#[rustc_legacy_const_generics(2)]
2421+
pub unsafe fn vsliq_n_u16<const N: i32>(a: uint16x8_t, b: uint16x8_t) -> uint16x8_t {
2422+
static_assert_imm4!(N);
2423+
transmute(vsliq_n_s16_(transmute(a), transmute(b), N))
24242424
}
24252425
/// Shift Left and Insert (immediate)
24262426
#[inline]
24272427
#[target_feature(enable = "neon")]
2428-
#[cfg_attr(test, assert_instr(sli, n = 1))]
2429-
#[rustc_args_required_const(2)]
2430-
pub unsafe fn vsli_n_u32(a: uint32x2_t, b: uint32x2_t, n: i32) -> uint32x2_t {
2431-
assert!(0 <= n && n <= 31, "must have 0 ≤ n ≤ 31, but n = {}", n);
2432-
transmute(vsli_n_s32_(transmute(a), transmute(b), n))
2428+
#[cfg_attr(test, assert_instr(sli, N = 1))]
2429+
#[rustc_legacy_const_generics(2)]
2430+
pub unsafe fn vsli_n_u32<const N: i32>(a: uint32x2_t, b: uint32x2_t) -> uint32x2_t {
2431+
static_assert!(N: i32 where N >= 0 && N <= 31);
2432+
transmute(vsli_n_s32_(transmute(a), transmute(b), N))
24332433
}
24342434
/// Shift Left and Insert (immediate)
24352435
#[inline]
24362436
#[target_feature(enable = "neon")]
2437-
#[cfg_attr(test, assert_instr(sli, n = 1))]
2438-
#[rustc_args_required_const(2)]
2439-
pub unsafe fn vsliq_n_u32(a: uint32x4_t, b: uint32x4_t, n: i32) -> uint32x4_t {
2440-
assert!(0 <= n && n <= 31, "must have 0 ≤ n ≤ 31, but n = {}", n);
2441-
transmute(vsliq_n_s32_(transmute(a), transmute(b), n))
2437+
#[cfg_attr(test, assert_instr(sli, N = 1))]
2438+
#[rustc_legacy_const_generics(2)]
2439+
pub unsafe fn vsliq_n_u32<const N: i32>(a: uint32x4_t, b: uint32x4_t) -> uint32x4_t {
2440+
static_assert!(N: i32 where N >= 0 && N <= 31);
2441+
transmute(vsliq_n_s32_(transmute(a), transmute(b), N))
24422442
}
24432443
/// Shift Left and Insert (immediate)
24442444
#[inline]
24452445
#[target_feature(enable = "neon")]
2446-
#[cfg_attr(test, assert_instr(sli, n = 1))]
2447-
#[rustc_args_required_const(2)]
2448-
pub unsafe fn vsli_n_u64(a: uint64x1_t, b: uint64x1_t, n: i32) -> uint64x1_t {
2449-
assert!(0 <= n && n <= 63, "must have 0 ≤ n ≤ 63, but n = {}", n);
2450-
transmute(vsli_n_s64_(transmute(a), transmute(b), n))
2446+
#[cfg_attr(test, assert_instr(sli, N = 1))]
2447+
#[rustc_legacy_const_generics(2)]
2448+
pub unsafe fn vsli_n_u64<const N: i32>(a: uint64x1_t, b: uint64x1_t) -> uint64x1_t {
2449+
static_assert!(N: i32 where N >= 0 && N <= 63);
2450+
transmute(vsli_n_s64_(transmute(a), transmute(b), N))
24512451
}
24522452
/// Shift Left and Insert (immediate)
24532453
#[inline]
24542454
#[target_feature(enable = "neon")]
2455-
#[cfg_attr(test, assert_instr(sli, n = 1))]
2456-
#[rustc_args_required_const(2)]
2457-
pub unsafe fn vsliq_n_u64(a: uint64x2_t, b: uint64x2_t, n: i32) -> uint64x2_t {
2458-
assert!(0 <= n && n <= 63, "must have 0 ≤ n ≤ 63, but n = {}", n);
2459-
transmute(vsliq_n_s64_(transmute(a), transmute(b), n))
2455+
#[cfg_attr(test, assert_instr(sli, N = 1))]
2456+
#[rustc_legacy_const_generics(2)]
2457+
pub unsafe fn vsliq_n_u64<const N: i32>(a: uint64x2_t, b: uint64x2_t) -> uint64x2_t {
2458+
static_assert!(N: i32 where N >= 0 && N <= 63);
2459+
transmute(vsliq_n_s64_(transmute(a), transmute(b), N))
24602460
}
24612461
/// Shift Left and Insert (immediate)
24622462
#[inline]
24632463
#[target_feature(enable = "neon")]
2464-
#[cfg_attr(test, assert_instr(sli, n = 1))]
2465-
#[rustc_args_required_const(2)]
2466-
pub unsafe fn vsli_n_p8(a: poly8x8_t, b: poly8x8_t, n: i32) -> poly8x8_t {
2467-
assert!(0 <= n && n <= 7, "must have 0 ≤ n ≤ 7, but n = {}", n);
2468-
transmute(vsli_n_s8_(transmute(a), transmute(b), n))
2464+
#[cfg_attr(test, assert_instr(sli, N = 1))]
2465+
#[rustc_legacy_const_generics(2)]
2466+
pub unsafe fn vsli_n_p8<const N: i32>(a: poly8x8_t, b: poly8x8_t) -> poly8x8_t {
2467+
static_assert_imm3!(N);
2468+
transmute(vsli_n_s8_(transmute(a), transmute(b), N))
24692469
}
24702470
/// Shift Left and Insert (immediate)
24712471
#[inline]
24722472
#[target_feature(enable = "neon")]
2473-
#[cfg_attr(test, assert_instr(sli, n = 1))]
2474-
#[rustc_args_required_const(2)]
2475-
pub unsafe fn vsliq_n_p8(a: poly8x16_t, b: poly8x16_t, n: i32) -> poly8x16_t {
2476-
assert!(0 <= n && n <= 7, "must have 0 ≤ n ≤ 7, but n = {}", n);
2477-
transmute(vsliq_n_s8_(transmute(a), transmute(b), n))
2473+
#[cfg_attr(test, assert_instr(sli, N = 1))]
2474+
#[rustc_legacy_const_generics(2)]
2475+
pub unsafe fn vsliq_n_p8<const N: i32>(a: poly8x16_t, b: poly8x16_t) -> poly8x16_t {
2476+
static_assert_imm3!(N);
2477+
transmute(vsliq_n_s8_(transmute(a), transmute(b), N))
24782478
}
24792479
/// Shift Left and Insert (immediate)
24802480
#[inline]
24812481
#[target_feature(enable = "neon")]
2482-
#[cfg_attr(test, assert_instr(sli, n = 1))]
2483-
#[rustc_args_required_const(2)]
2484-
pub unsafe fn vsli_n_p16(a: poly16x4_t, b: poly16x4_t, n: i32) -> poly16x4_t {
2485-
assert!(0 <= n && n <= 15, "must have 0 ≤ n ≤ 15, but n = {}", n);
2486-
transmute(vsli_n_s16_(transmute(a), transmute(b), n))
2482+
#[cfg_attr(test, assert_instr(sli, N = 1))]
2483+
#[rustc_legacy_const_generics(2)]
2484+
pub unsafe fn vsli_n_p16<const N: i32>(a: poly16x4_t, b: poly16x4_t) -> poly16x4_t {
2485+
static_assert_imm4!(N);
2486+
transmute(vsli_n_s16_(transmute(a), transmute(b), N))
24872487
}
24882488
/// Shift Left and Insert (immediate)
24892489
#[inline]
24902490
#[target_feature(enable = "neon")]
2491-
#[cfg_attr(test, assert_instr(sli, n = 1))]
2492-
#[rustc_args_required_const(2)]
2493-
pub unsafe fn vsliq_n_p16(a: poly16x8_t, b: poly16x8_t, n: i32) -> poly16x8_t {
2494-
assert!(0 <= n && n <= 15, "must have 0 ≤ n ≤ 15, but n = {}", n);
2495-
transmute(vsliq_n_s16_(transmute(a), transmute(b), n))
2491+
#[cfg_attr(test, assert_instr(sli, N = 1))]
2492+
#[rustc_legacy_const_generics(2)]
2493+
pub unsafe fn vsliq_n_p16<const N: i32>(a: poly16x8_t, b: poly16x8_t) -> poly16x8_t {
2494+
static_assert_imm4!(N);
2495+
transmute(vsliq_n_s16_(transmute(a), transmute(b), N))
24962496
}
24972497

24982498
/// Shift Right and Insert (immediate)

0 commit comments

Comments
 (0)