|
| 1 | +#[cfg(test)] |
| 2 | +use stdsimd_test::assert_instr; |
| 3 | + |
| 4 | +#[allow(improper_ctypes)] |
| 5 | +extern "unadjusted" { |
| 6 | + #[link_name = "llvm.x86.addcarry.u32"] |
| 7 | + fn llvm_addcarry_u32(a: u8, b: u32, c: u32) -> (u8, u32); |
| 8 | + #[link_name = "llvm.x86.subborrow.u32"] |
| 9 | + fn llvm_subborrow_u32(a: u8, b: u32, c: u32) -> (u8, u32); |
| 10 | +} |
| 11 | + |
| 12 | +/// Add unsigned 32-bit integers a and b with unsigned 8-bit carry-in c_in |
| 13 | +/// (carry flag), and store the unsigned 32-bit result in out, and the carry-out |
| 14 | +/// is returned (carry or overflow flag). |
| 15 | +#[inline] |
| 16 | +#[cfg_attr(test, assert_instr(adc))] |
| 17 | +#[stable(feature = "simd_x86_adx", since = "1.33.0")] |
| 18 | +pub unsafe fn _addcarry_u32(c_in: u8, a: u32, b: u32, out: &mut u32) -> u8 { |
| 19 | + let (a, b) = llvm_addcarry_u32(c_in, a, b); |
| 20 | + *out = b; |
| 21 | + a |
| 22 | +} |
| 23 | + |
| 24 | +/// Add unsigned 32-bit integers a and b with unsigned 8-bit carry-in c_in |
| 25 | +/// (carry or overflow flag), and store the unsigned 32-bit result in out, and |
| 26 | +/// the carry-out is returned (carry or overflow flag). |
| 27 | +#[inline] |
| 28 | +#[target_feature(enable = "adx")] |
| 29 | +#[cfg_attr(test, assert_instr(adc))] |
| 30 | +#[stable(feature = "simd_x86_adx", since = "1.33.0")] |
| 31 | +#[cfg(not(stage0))] |
| 32 | +pub unsafe fn _addcarryx_u32(c_in: u8, a: u32, b: u32, out: &mut u32) -> u8 { |
| 33 | + _addcarry_u32(c_in, a, b, out) |
| 34 | +} |
| 35 | + |
| 36 | +/// Add unsigned 32-bit integers a and b with unsigned 8-bit carry-in c_in |
| 37 | +/// (carry or overflow flag), and store the unsigned 32-bit result in out, and |
| 38 | +/// the carry-out is returned (carry or overflow flag). |
| 39 | +#[inline] |
| 40 | +#[cfg_attr(test, assert_instr(sbb))] |
| 41 | +#[stable(feature = "simd_x86_adx", since = "1.33.0")] |
| 42 | +pub unsafe fn _subborrow_u32(c_in: u8, a: u32, b: u32, out: &mut u32) -> u8 { |
| 43 | + let (a, b) = llvm_subborrow_u32(c_in, a, b); |
| 44 | + *out = b; |
| 45 | + a |
| 46 | +} |
0 commit comments