p.rs - source
Description: Source of the Rust file `library/core/src/../../stdarch/crates/core_arch/src/riscv_shared/p.rs`.

#
core/stdarch/crates/core_arch/src/riscv_shared/
p.rs

    1//! RISC-V Packed SIMD intrinsics; shared part.
    2//!
    3//! RV64 only part is placed in riscv64 folder.
    4use crate::arch::asm;
    5#[cfg(test)]
    6use stdarch_test::assert_instr;
    7
    8// FIXME: Currently the P extension is still unratified, so there is no support
    9// for it in the upstream LLVM for now, and thus no LLVM built-in functions or
    10// serialization of instructions are provided.
    11//
    12// We add `assert_instr(unknown)` to each function so that we can at least make
    13// sure they compile. Since there is no serialization yet, we can only write
    14// "unknown" here, so that if LLVM upstream provides support for the P extension
    15// at some point in the future, we can know in time and then update our
    16// implementation.
    17
    18/// Adds packed 16-bit signed numbers, discarding overflow bits
    19#[inline]
    20#[cfg_attr(test, assert_instr(unknown))]
    21#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    22pub fn add16(a: usize, b: usize) -> usize {
    23    let value: usize;
    24    unsafe {
    25        asm!(".insn r 0x77, 0x0, 0x20, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    26    }
    27    value
    28}
    29
    30/// Halves the sum of packed 16-bit signed numbers, dropping least bits
    31#[inline]
    32#[cfg_attr(test, assert_instr(unknown))]
    33#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    34pub fn radd16(a: usize, b: usize) -> usize {
    35    let value: usize;
    36    unsafe {
    37        asm!(".insn r 0x77, 0x0, 0x00, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    38    }
    39    value
    40}
    41
    42/// Halves the sum of packed 16-bit unsigned numbers, dropping least bits
    43#[inline]
    44#[cfg_attr(test, assert_instr(unknown))]
    45#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    46pub fn uradd16(a: usize, b: usize) -> usize {
    47    let value: usize;
    48    unsafe {
    49        asm!(".insn r 0x77, 0x0, 0x10, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    50    }
    51    value
    52}
    53
    54/// Adds packed 16-bit signed numbers, saturating at the numeric bounds
    55#[inline]
    56#[cfg_attr(test, assert_instr(unknown))]
    57#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    58pub fn kadd16(a: usize, b: usize) -> usize {
    59    let value: usize;
    60    unsafe {
    61        asm!(".insn r 0x77, 0x0, 0x08, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    62    }
    63    value
    64}
    65
    66/// Adds packed 16-bit unsigned numbers, saturating at the numeric bounds
    67#[inline]
    68#[cfg_attr(test, assert_instr(unknown))]
    69#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    70pub fn ukadd16(a: usize, b: usize) -> usize {
    71    let value: usize;
    72    unsafe {
    73        asm!(".insn r 0x77, 0x0, 0x18, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    74    }
    75    value
    76}
    77
    78/// Subtracts packed 16-bit signed numbers, discarding overflow bits
    79#[inline]
    80#[cfg_attr(test, assert_instr(unknown))]
    81#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    82pub fn sub16(a: usize, b: usize) -> usize {
    83    let value: usize;
    84    unsafe {
    85        asm!(".insn r 0x77, 0x0, 0x21, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    86    }
    87    value
    88}
    89
    90/// Halves the subtraction result of packed 16-bit signed numbers, dropping least bits
    91#[inline]
    92#[cfg_attr(test, assert_instr(unknown))]
    93#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    94pub fn rsub16(a: usize, b: usize) -> usize {
    95    let value: usize;
    96    unsafe {
    97        asm!(".insn r 0x77, 0x0, 0x01, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    98    }
    99    value
    100}
    101
    102/// Halves the subtraction result of packed 16-bit unsigned numbers, dropping least bits
    103#[inline]
    104#[cfg_attr(test, assert_instr(unknown))]
    105#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    106pub fn ursub16(a: usize, b: usize) -> usize {
    107    let value: usize;
    108    unsafe {
    109        asm!(".insn r 0x77, 0x0, 0x11, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    110    }
    111    value
    112}
    113
    114/// Subtracts packed 16-bit signed numbers, saturating at the numeric bounds
    115#[inline]
    116#[cfg_attr(test, assert_instr(unknown))]
    117#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    118pub fn ksub16(a: usize, b: usize) -> usize {
    119    let value: usize;
    120    unsafe {
    121        asm!(".insn r 0x77, 0x0, 0x09, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    122    }
    123    value
    124}
    125
    126/// Subtracts packed 16-bit unsigned numbers, saturating at the numeric bounds
    127#[inline]
    128#[cfg_attr(test, assert_instr(unknown))]
    129#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    130pub fn uksub16(a: usize, b: usize) -> usize {
    131    let value: usize;
    132    unsafe {
    133        asm!(".insn r 0x77, 0x0, 0x19, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    134    }
    135    value
    136}
    137
    138/// Cross adds and subtracts packed 16-bit signed numbers, discarding overflow bits
    139#[inline]
    140#[cfg_attr(test, assert_instr(unknown))]
    141#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    142pub fn cras16(a: usize, b: usize) -> usize {
    143    let value: usize;
    144    unsafe {
    145        asm!(".insn r 0x77, 0x0, 0x22, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    146    }
    147    value
    148}
    149
    150/// Cross halves of adds and subtracts packed 16-bit signed numbers, dropping least bits
    151#[inline]
    152#[cfg_attr(test, assert_instr(unknown))]
    153#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    154pub fn rcras16(a: usize, b: usize) -> usize {
    155    let value: usize;
    156    unsafe {
    157        asm!(".insn r 0x77, 0x0, 0x02, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    158    }
    159    value
    160}
    161
    162/// Cross halves of adds and subtracts packed 16-bit unsigned numbers, dropping least bits
    163#[inline]
    164#[cfg_attr(test, assert_instr(unknown))]
    165#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    166pub fn urcras16(a: usize, b: usize) -> usize {
    167    let value: usize;
    168    unsafe {
    169        asm!(".insn r 0x77, 0x0, 0x12, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    170    }
    171    value
    172}
    173
    174/// Cross adds and subtracts packed 16-bit signed numbers, saturating at the numeric bounds
    175#[inline]
    176#[cfg_attr(test, assert_instr(unknown))]
    177#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    178pub fn kcras16(a: usize, b: usize) -> usize {
    179    let value: usize;
    180    unsafe {
    181        asm!(".insn r 0x77, 0x0, 0x0A, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    182    }
    183    value
    184}
    185
    186/// Cross adds and subtracts packed 16-bit unsigned numbers, saturating at the numeric bounds
    187#[inline]
    188#[cfg_attr(test, assert_instr(unknown))]
    189#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    190pub fn ukcras16(a: usize, b: usize) -> usize {
    191    let value: usize;
    192    unsafe {
    193        asm!(".insn r 0x77, 0x0, 0x1A, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    194    }
    195    value
    196}
    197
    198/// Cross subtracts and adds packed 16-bit signed numbers, discarding overflow bits
    199#[inline]
    200#[cfg_attr(test, assert_instr(unknown))]
    201#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    202pub fn crsa16(a: usize, b: usize) -> usize {
    203    let value: usize;
    204    unsafe {
    205        asm!(".insn r 0x77, 0x0, 0x23, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    206    }
    207    value
    208}
    209
    210/// Cross halves of subtracts and adds packed 16-bit signed numbers, dropping least bits
    211#[inline]
    212#[cfg_attr(test, assert_instr(unknown))]
    213#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    214pub fn rcrsa16(a: usize, b: usize) -> usize {
    215    let value: usize;
    216    unsafe {
    217        asm!(".insn r 0x77, 0x0, 0x03, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    218    }
    219    value
    220}
    221
    222/// Cross halves of subtracts and adds packed 16-bit unsigned numbers, dropping least bits
    223#[inline]
    224#[cfg_attr(test, assert_instr(unknown))]
    225#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    226pub fn urcrsa16(a: usize, b: usize) -> usize {
    227    let value: usize;
    228    unsafe {
    229        asm!(".insn r 0x77, 0x0, 0x13, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    230    }
    231    value
    232}
    233
    234/// Cross subtracts and adds packed 16-bit signed numbers, saturating at the numeric bounds
    235#[inline]
    236#[cfg_attr(test, assert_instr(unknown))]
    237#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    238pub fn kcrsa16(a: usize, b: usize) -> usize {
    239    let value: usize;
    240    unsafe {
    241        asm!(".insn r 0x77, 0x0, 0x0B, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    242    }
    243    value
    244}
    245
    246/// Cross subtracts and adds packed 16-bit unsigned numbers, saturating at the numeric bounds
    247#[inline]
    248#[cfg_attr(test, assert_instr(unknown))]
    249#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    250pub fn ukcrsa16(a: usize, b: usize) -> usize {
    251    let value: usize;
    252    unsafe {
    253        asm!(".insn r 0x77, 0x0, 0x1B, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    254    }
    255    value
    256}
    257
    258/// Straight adds and subtracts packed 16-bit signed numbers, discarding overflow bits
    259#[inline]
    260#[cfg_attr(test, assert_instr(unknown))]
    261#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    262pub fn stas16(a: usize, b: usize) -> usize {
    263    let value: usize;
    264    unsafe {
    265        asm!(".insn r 0x77, 0x0, 0x7A, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    266    }
    267    value
    268}
    269
    270/// Straight halves of adds and subtracts packed 16-bit signed numbers, dropping least bits
    271#[inline]
    272#[cfg_attr(test, assert_instr(unknown))]
    273#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    274pub fn rstas16(a: usize, b: usize) -> usize {
    275    let value: usize;
    276    unsafe {
    277        asm!(".insn r 0x77, 0x0, 0x5A, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    278    }
    279    value
    280}
    281
    282/// Straight halves of adds and subtracts packed 16-bit unsigned numbers, dropping least bits
    283#[inline]
    284#[cfg_attr(test, assert_instr(unknown))]
    285#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    286pub fn urstas16(a: usize, b: usize) -> usize {
    287    let value: usize;
    288    unsafe {
    289        asm!(".insn r 0x77, 0x0, 0x6A, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    290    }
    291    value
    292}
    293
    294/// Straight adds and subtracts packed 16-bit signed numbers, saturating at the numeric bounds
    295#[inline]
    296#[cfg_attr(test, assert_instr(unknown))]
    297#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    298pub fn kstas16(a: usize, b: usize) -> usize {
    299    let value: usize;
    300    unsafe {
    301        asm!(".insn r 0x77, 0x0, 0x62, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    302    }
    303    value
    304}
    305
    306/// Straight adds and subtracts packed 16-bit unsigned numbers, saturating at the numeric bounds
    307#[inline]
    308#[cfg_attr(test, assert_instr(unknown))]
    309#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    310pub fn ukstas16(a: usize, b: usize) -> usize {
    311    let value: usize;
    312    unsafe {
    313        asm!(".insn r 0x77, 0x0, 0x72, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    314    }
    315    value
    316}
    317
    318/// Straight subtracts and adds packed 16-bit signed numbers, discarding overflow bits
    319#[inline]
    320#[cfg_attr(test, assert_instr(unknown))]
    321#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    322pub fn stsa16(a: usize, b: usize) -> usize {
    323    let value: usize;
    324    unsafe {
    325        asm!(".insn r 0x77, 0x0, 0x7B, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    326    }
    327    value
    328}
    329
    330/// Straight halves of subtracts and adds packed 16-bit signed numbers, dropping least bits
    331#[inline]
    332#[cfg_attr(test, assert_instr(unknown))]
    333#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    334pub fn rstsa16(a: usize, b: usize) -> usize {
    335    let value: usize;
    336    unsafe {
    337        asm!(".insn r 0x77, 0x0, 0x5B, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    338    }
    339    value
    340}
    341
    342/// Straight halves of subtracts and adds packed 16-bit unsigned numbers, dropping least bits
    343#[inline]
    344#[cfg_attr(test, assert_instr(unknown))]
    345#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    346pub fn urstsa16(a: usize, b: usize) -> usize {
    347    let value: usize;
    348    unsafe {
    349        asm!(".insn r 0x77, 0x0, 0x6B, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    350    }
    351    value
    352}
    353
    354/// Straight subtracts and adds packed 16-bit signed numbers, saturating at the numeric bounds
    355#[inline]
    356#[cfg_attr(test, assert_instr(unknown))]
    357#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    358pub fn kstsa16(a: usize, b: usize) -> usize {
    359    let value: usize;
    360    unsafe {
    361        asm!(".insn r 0x77, 0x0, 0x63, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    362    }
    363    value
    364}
    365
    366/// Straight subtracts and adds packed 16-bit unsigned numbers, saturating at the numeric bounds
    367#[inline]
    368#[cfg_attr(test, assert_instr(unknown))]
    369#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    370pub fn ukstsa16(a: usize, b: usize) -> usize {
    371    let value: usize;
    372    unsafe {
    373        asm!(".insn r 0x77, 0x0, 0x73, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    374    }
    375    value
    376}
    377
    378/// Adds packed 8-bit signed numbers, discarding overflow bits
    379#[inline]
    380#[cfg_attr(test, assert_instr(unknown))]
    381#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    382pub fn add8(a: usize, b: usize) -> usize {
    383    let value: usize;
    384    unsafe {
    385        asm!(".insn r 0x77, 0x0, 0x24, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    386    }
    387    value
    388}
    389
    390/// Halves the sum of packed 8-bit signed numbers, dropping least bits
    391#[inline]
    392#[cfg_attr(test, assert_instr(unknown))]
    393#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    394pub fn radd8(a: usize, b: usize) -> usize {
    395    let value: usize;
    396    unsafe {
    397        asm!(".insn r 0x77, 0x0, 0x04, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    398    }
    399    value
    400}
    401
    402/// Halves the sum of packed 8-bit unsigned numbers, dropping least bits
    403#[inline]
    404#[cfg_attr(test, assert_instr(unknown))]
    405#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    406pub fn uradd8(a: usize, b: usize) -> usize {
    407    let value: usize;
    408    unsafe {
    409        asm!(".insn r 0x77, 0x0, 0x14, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    410    }
    411    value
    412}
    413
    414/// Adds packed 8-bit signed numbers, saturating at the numeric bounds
    415#[inline]
    416#[cfg_attr(test, assert_instr(unknown))]
    417#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    418pub fn kadd8(a: usize, b: usize) -> usize {
    419    let value: usize;
    420    unsafe {
    421        asm!(".insn r 0x77, 0x0, 0x0C, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    422    }
    423    value
    424}
    425
    426/// Adds packed 8-bit unsigned numbers, saturating at the numeric bounds
    427#[inline]
    428#[cfg_attr(test, assert_instr(unknown))]
    429#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    430pub fn ukadd8(a: usize, b: usize) -> usize {
    431    let value: usize;
    432    unsafe {
    433        asm!(".insn r 0x77, 0x0, 0x1C, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    434    }
    435    value
    436}
    437
    438/// Subtracts packed 8-bit signed numbers, discarding overflow bits
    439#[inline]
    440#[cfg_attr(test, assert_instr(unknown))]
    441#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    442pub fn sub8(a: usize, b: usize) -> usize {
    443    let value: usize;
    444    unsafe {
    445        asm!(".insn r 0x77, 0x0, 0x25, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    446    }
    447    value
    448}
    449
    450/// Halves the subtraction result of packed 8-bit signed numbers, dropping least bits
    451#[inline]
    452#[cfg_attr(test, assert_instr(unknown))]
    453#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    454pub fn rsub8(a: usize, b: usize) -> usize {
    455    let value: usize;
    456    unsafe {
    457        asm!(".insn r 0x77, 0x0, 0x05, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    458    }
    459    value
    460}
    461
    462/// Halves the subtraction result of packed 8-bit unsigned numbers, dropping least bits
    463#[inline]
    464#[cfg_attr(test, assert_instr(unknown))]
    465#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    466pub fn ursub8(a: usize, b: usize) -> usize {
    467    let value: usize;
    468    unsafe {
    469        asm!(".insn r 0x77, 0x0, 0x15, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    470    }
    471    value
    472}
    473
    474/// Subtracts packed 8-bit signed numbers, saturating at the numeric bounds
    475#[inline]
    476#[cfg_attr(test, assert_instr(unknown))]
    477#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    478pub fn ksub8(a: usize, b: usize) -> usize {
    479    let value: usize;
    480    unsafe {
    481        asm!(".insn r 0x77, 0x0, 0x0D, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    482    }
    483    value
    484}
    485
    486/// Subtracts packed 8-bit unsigned numbers, saturating at the numeric bounds
    487#[inline]
    488#[cfg_attr(test, assert_instr(unknown))]
    489#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    490pub fn uksub8(a: usize, b: usize) -> usize {
    491    let value: usize;
    492    unsafe {
    493        asm!(".insn r 0x77, 0x0, 0x1D, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    494    }
    495    value
    496}
    497
    498/// Arithmetic right shift packed 16-bit elements without rounding up
    499#[inline]
    500#[cfg_attr(test, assert_instr(unknown))]
    501#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    502pub fn sra16(a: usize, b: u32) -> usize {
    503    let value: usize;
    504    unsafe {
    505        asm!(".insn r 0x77, 0x0, 0x28, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    506    }
    507    value
    508}
    509
    510/// Arithmetic right shift packed 16-bit elements with rounding up
    511#[inline]
    512#[cfg_attr(test, assert_instr(unknown))]
    513#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    514pub fn sra16u(a: usize, b: u32) -> usize {
    515    let value: usize;
    516    unsafe {
    517        asm!(".insn r 0x77, 0x0, 0x30, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    518    }
    519    value
    520}
    521
    522/// Logical right shift packed 16-bit elements without rounding up
    523#[inline]
    524#[cfg_attr(test, assert_instr(unknown))]
    525#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    526pub fn srl16(a: usize, b: u32) -> usize {
    527    let value: usize;
    528    unsafe {
    529        asm!(".insn r 0x77, 0x0, 0x29, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    530    }
    531    value
    532}
    533
    534/// Logical right shift packed 16-bit elements with rounding up
    535#[inline]
    536#[cfg_attr(test, assert_instr(unknown))]
    537#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    538pub fn srl16u(a: usize, b: u32) -> usize {
    539    let value: usize;
    540    unsafe {
    541        asm!(".insn r 0x77, 0x0, 0x31, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    542    }
    543    value
    544}
    545
    546/// Logical left shift packed 16-bit elements, discarding overflow bits
    547#[inline]
    548#[cfg_attr(test, assert_instr(unknown))]
    549#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    550pub fn sll16(a: usize, b: u32) -> usize {
    551    let value: usize;
    552    unsafe {
    553        asm!(".insn r 0x77, 0x0, 0x2A, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    554    }
    555    value
    556}
    557
    558/// Logical left shift packed 16-bit elements, saturating at the numeric bounds
    559#[inline]
    560#[cfg_attr(test, assert_instr(unknown))]
    561#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    562pub fn ksll16(a: usize, b: u32) -> usize {
    563    let value: usize;
    564    unsafe {
    565        asm!(".insn r 0x77, 0x0, 0x32, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    566    }
    567    value
    568}
    569
    570/// Logical saturating left then arithmetic right shift packed 16-bit elements
    571#[inline]
    572#[cfg_attr(test, assert_instr(unknown))]
    573#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    574pub fn kslra16(a: usize, b: i32) -> usize {
    575    let value: usize;
    576    unsafe {
    577        asm!(".insn r 0x77, 0x0, 0x2B, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    578    }
    579    value
    580}
    581
    582/// Logical saturating left then arithmetic right shift packed 16-bit elements
    583#[inline]
    584#[cfg_attr(test, assert_instr(unknown))]
    585#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    586pub fn kslra16u(a: usize, b: i32) -> usize {
    587    let value: usize;
    588    unsafe {
    589        asm!(".insn r 0x77, 0x0, 0x33, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    590    }
    591    value
    592}
    593
    594/// Arithmetic right shift packed 8-bit elements without rounding up
    595#[inline]
    596#[cfg_attr(test, assert_instr(unknown))]
    597#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    598pub fn sra8(a: usize, b: u32) -> usize {
    599    let value: usize;
    600    unsafe {
    601        asm!(".insn r 0x77, 0x0, 0x2C, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    602    }
    603    value
    604}
    605
    606/// Arithmetic right shift packed 8-bit elements with rounding up
    607#[inline]
    608#[cfg_attr(test, assert_instr(unknown))]
    609#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    610pub fn sra8u(a: usize, b: u32) -> usize {
    611    let value: usize;
    612    unsafe {
    613        asm!(".insn r 0x77, 0x0, 0x34, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    614    }
    615    value
    616}
    617
    618/// Logical right shift packed 8-bit elements without rounding up
    619#[inline]
    620#[cfg_attr(test, assert_instr(unknown))]
    621#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    622pub fn srl8(a: usize, b: u32) -> usize {
    623    let value: usize;
    624    unsafe {
    625        asm!(".insn r 0x77, 0x0, 0x2D, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    626    }
    627    value
    628}
    629
    630/// Logical right shift packed 8-bit elements with rounding up
    631#[inline]
    632#[cfg_attr(test, assert_instr(unknown))]
    633#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    634pub fn srl8u(a: usize, b: u32) -> usize {
    635    let value: usize;
    636    unsafe {
    637        asm!(".insn r 0x77, 0x0, 0x35, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    638    }
    639    value
    640}
    641
    642/// Logical left shift packed 8-bit elements, discarding overflow bits
    643#[inline]
    644#[cfg_attr(test, assert_instr(unknown))]
    645#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    646pub fn sll8(a: usize, b: u32) -> usize {
    647    let value: usize;
    648    unsafe {
    649        asm!(".insn r 0x77, 0x0, 0x2E, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    650    }
    651    value
    652}
    653
    654/// Logical left shift packed 8-bit elements, saturating at the numeric bounds
    655#[inline]
    656#[cfg_attr(test, assert_instr(unknown))]
    657#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    658pub fn ksll8(a: usize, b: u32) -> usize {
    659    let value: usize;
    660    unsafe {
    661        asm!(".insn r 0x77, 0x0, 0x36, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    662    }
    663    value
    664}
    665
    666/// Logical saturating left then arithmetic right shift packed 8-bit elements
    667#[inline]
    668#[cfg_attr(test, assert_instr(unknown))]
    669#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    670pub fn kslra8(a: usize, b: i32) -> usize {
    671    let value: usize;
    672    unsafe {
    673        asm!(".insn r 0x77, 0x0, 0x2F, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    674    }
    675    value
    676}
    677
    678/// Logical saturating left then arithmetic right shift packed 8-bit elements
    679#[inline]
    680#[cfg_attr(test, assert_instr(unknown))]
    681#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    682pub fn kslra8u(a: usize, b: i32) -> usize {
    683    let value: usize;
    684    unsafe {
    685        asm!(".insn r 0x77, 0x0, 0x37, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    686    }
    687    value
    688}
    689
    690/// Compare equality for packed 16-bit elements
    691#[inline]
    692#[cfg_attr(test, assert_instr(unknown))]
    693#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    694pub fn cmpeq16(a: usize, b: usize) -> usize {
    695    let value: usize;
    696    unsafe {
    697        asm!(".insn r 0x77, 0x0, 0x26, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    698    }
    699    value
    700}
    701
    702/// Compare whether 16-bit packed signed integers are less than the others
    703#[inline]
    704#[cfg_attr(test, assert_instr(unknown))]
    705#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    706pub fn scmplt16(a: usize, b: usize) -> usize {
    707    let value: usize;
    708    unsafe {
    709        asm!(".insn r 0x77, 0x0, 0x06, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    710    }
    711    value
    712}
    713
    714/// Compare whether 16-bit packed signed integers are less than or equal to the others
    715#[inline]
    716#[cfg_attr(test, assert_instr(unknown))]
    717#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    718pub fn scmple16(a: usize, b: usize) -> usize {
    719    let value: usize;
    720    unsafe {
    721        asm!(".insn r 0x77, 0x0, 0x0E, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    722    }
    723    value
    724}
    725
    726/// Compare whether 16-bit packed unsigned integers are less than the others
    727#[inline]
    728#[cfg_attr(test, assert_instr(unknown))]
    729#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    730pub fn ucmplt16(a: usize, b: usize) -> usize {
    731    let value: usize;
    732    unsafe {
    733        asm!(".insn r 0x77, 0x0, 0x16, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    734    }
    735    value
    736}
    737
    738/// Compare whether 16-bit packed unsigned integers are less than or equal to the others
    739#[inline]
    740#[cfg_attr(test, assert_instr(unknown))]
    741#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    742pub fn ucmple16(a: usize, b: usize) -> usize {
    743    let value: usize;
    744    unsafe {
    745        asm!(".insn r 0x77, 0x0, 0x1E, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    746    }
    747    value
    748}
    749
    750/// Compare equality for packed 8-bit elements
    751#[inline]
    752#[cfg_attr(test, assert_instr(unknown))]
    753#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    754pub fn cmpeq8(a: usize, b: usize) -> usize {
    755    let value: usize;
    756    unsafe {
    757        asm!(".insn r 0x77, 0x0, 0x27, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    758    }
    759    value
    760}
    761
    762/// Compare whether 8-bit packed signed integers are less than the others
    763#[inline]
    764#[cfg_attr(test, assert_instr(unknown))]
    765#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    766pub fn scmplt8(a: usize, b: usize) -> usize {
    767    let value: usize;
    768    unsafe {
    769        asm!(".insn r 0x77, 0x0, 0x07, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    770    }
    771    value
    772}
    773
    774/// Compare whether 8-bit packed signed integers are less than or equal to the others
    775#[inline]
    776#[cfg_attr(test, assert_instr(unknown))]
    777#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    778pub fn scmple8(a: usize, b: usize) -> usize {
    779    let value: usize;
    780    unsafe {
    781        asm!(".insn r 0x77, 0x0, 0x0F, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    782    }
    783    value
    784}
    785
    786/// Compare whether 8-bit packed unsigned integers are less than the others
    787#[inline]
    788#[cfg_attr(test, assert_instr(unknown))]
    789#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    790pub fn ucmplt8(a: usize, b: usize) -> usize {
    791    let value: usize;
    792    unsafe {
    793        asm!(".insn r 0x77, 0x0, 0x17, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    794    }
    795    value
    796}
    797
    798/// Compare whether 8-bit packed unsigned integers are less than or equal to the others
    799#[inline]
    800#[cfg_attr(test, assert_instr(unknown))]
    801#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    802pub fn ucmple8(a: usize, b: usize) -> usize {
    803    let value: usize;
    804    unsafe {
    805        asm!(".insn r 0x77, 0x0, 0x1F, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    806    }
    807    value
    808}
    809
    810/// Get minimum values from 16-bit packed signed integers
    811#[inline]
    812#[cfg_attr(test, assert_instr(unknown))]
    813#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    814pub fn smin16(a: usize, b: usize) -> usize {
    815    let value: usize;
    816    unsafe {
    817        asm!(".insn r 0x77, 0x0, 0x40, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    818    }
    819    value
    820}
    821
    822/// Get minimum values from 16-bit packed unsigned integers
    823#[inline]
    824#[cfg_attr(test, assert_instr(unknown))]
    825#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    826pub fn umin16(a: usize, b: usize) -> usize {
    827    let value: usize;
    828    unsafe {
    829        asm!(".insn r 0x77, 0x0, 0x48, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    830    }
    831    value
    832}
    833
    834/// Get maximum values from 16-bit packed signed integers
    835#[inline]
    836#[cfg_attr(test, assert_instr(unknown))]
    837#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    838pub fn smax16(a: usize, b: usize) -> usize {
    839    let value: usize;
    840    unsafe {
    841        asm!(".insn r 0x77, 0x0, 0x41, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    842    }
    843    value
    844}
    845
    846/// Get maximum values from 16-bit packed unsigned integers
    847#[inline]
    848#[cfg_attr(test, assert_instr(unknown))]
    849#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    850pub fn umax16(a: usize, b: usize) -> usize {
    851    let value: usize;
    852    unsafe {
    853        asm!(".insn r 0x77, 0x0, 0x49, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    854    }
    855    value
    856}
    857
    858/* todo: sclip16, uclip16 */
    859
    860/// Compute the absolute value of packed 16-bit signed integers
    861#[inline]
    862#[cfg_attr(test, assert_instr(unknown))]
    863#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    864pub fn kabs16(a: usize) -> usize {
    865    let value: usize;
    866    unsafe {
    867        asm!(".insn i 0x77, 0x0, {}, {}, %lo(0xAD1)", lateout(reg) value, in(reg) a, options(pure, nomem, nostack))
    868    }
    869    value
    870}
    871
    872/// Count the number of redundant sign bits of the packed 16-bit elements
    873#[inline]
    874#[cfg_attr(test, assert_instr(unknown))]
    875#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    876pub fn clrs16(a: usize) -> usize {
    877    let value: usize;
    878    unsafe {
    879        asm!(".insn i 0x77, 0x0, {}, {}, %lo(0xAE8)", lateout(reg) value, in(reg) a, options(pure, nomem, nostack))
    880    }
    881    value
    882}
    883
    884/// Count the number of leading zero bits of the packed 16-bit elements
    885#[inline]
    886#[cfg_attr(test, assert_instr(unknown))]
    887#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    888pub fn clz16(a: usize) -> usize {
    889    let value: usize;
    890    unsafe {
    891        asm!(".insn i 0x77, 0x0, {}, {}, %lo(0xAE9)", lateout(reg) value, in(reg) a, options(pure, nomem, nostack))
    892    }
    893    value
    894}
    895
    896/// Swap the 16-bit halfwords within each 32-bit word of a register
    897#[inline]
    898#[cfg_attr(test, assert_instr(unknown))]
    899#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    900pub fn swap16(a: usize) -> usize {
    901    let value: usize;
    902    // this instruction is an alias for `pkbt rd, rs1, rs1`.
    903    unsafe {
    904        asm!(".insn r 0x77, 0x0, 0x0F, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) a, options(pure, nomem, nostack))
    905    }
    906    value
    907}
    908
    909/// Get minimum values from 8-bit packed signed integers
    910#[inline]
    911#[cfg_attr(test, assert_instr(unknown))]
    912#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    913pub fn smin8(a: usize, b: usize) -> usize {
    914    let value: usize;
    915    unsafe {
    916        asm!(".insn r 0x77, 0x0, 0x44, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    917    }
    918    value
    919}
    920
    921/// Get minimum values from 8-bit packed unsigned integers
    922#[inline]
    923#[cfg_attr(test, assert_instr(unknown))]
    924#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    925pub fn umin8(a: usize, b: usize) -> usize {
    926    let value: usize;
    927    unsafe {
    928        asm!(".insn r 0x77, 0x0, 0x4C, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    929    }
    930    value
    931}
    932
    933/// Get maximum values from 8-bit packed signed integers
    934#[inline]
    935#[cfg_attr(test, assert_instr(unknown))]
    936#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    937pub fn smax8(a: usize, b: usize) -> usize {
    938    let value: usize;
    939    unsafe {
    940        asm!(".insn r 0x77, 0x0, 0x45, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    941    }
    942    value
    943}
    944
    945/// Get maximum values from 8-bit packed unsigned integers
    946#[inline]
    947#[cfg_attr(test, assert_instr(unknown))]
    948#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    949pub fn umax8(a: usize, b: usize) -> usize {
    950    let value: usize;
    951    unsafe {
    952        asm!(".insn r 0x77, 0x0, 0x4D, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    953    }
    954    value
    955}
    956
    957/* todo: sclip8, uclip8 */
    958
    959/// Compute the absolute value of packed 8-bit signed integers
    960#[inline]
    961#[cfg_attr(test, assert_instr(unknown))]
    962#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    963pub fn kabs8(a: usize) -> usize {
    964    let value: usize;
    965    unsafe {
    966        asm!(".insn i 0x77, 0x0, {}, {}, %lo(0xAD0)", lateout(reg) value, in(reg) a, options(pure, nomem, nostack))
    967    }
    968    value
    969}
    970
    971/// Count the number of redundant sign bits of the packed 8-bit elements
    972#[inline]
    973#[cfg_attr(test, assert_instr(unknown))]
    974#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    975pub fn clrs8(a: usize) -> usize {
    976    let value: usize;
    977    unsafe {
    978        asm!(".insn i 0x77, 0x0, {}, {}, %lo(0xAE0)", lateout(reg) value, in(reg) a, options(pure, nomem, nostack))
    979    }
    980    value
    981}
    982
    983/// Count the number of leading zero bits of the packed 8-bit elements
    984#[inline]
    985#[cfg_attr(test, assert_instr(unknown))]
    986#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    987pub fn clz8(a: usize) -> usize {
    988    let value: usize;
    989    unsafe {
    990        asm!(".insn i 0x77, 0x0, {}, {}, %lo(0xAE1)", lateout(reg) value, in(reg) a, options(pure, nomem, nostack))
    991    }
    992    value
    993}
    994
    995/// Swap the 8-bit bytes within each 16-bit halfword of a register.
    996#[inline]
    997#[cfg_attr(test, assert_instr(unknown))]
    998#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    999pub fn swap8(a: usize) -> usize {
    1000    let value: usize;
    1001    unsafe {
    1002        asm!(".insn i 0x77, 0x0, {}, {}, %lo(0xAD8)", lateout(reg) value, in(reg) a, options(pure, nomem, nostack))
    1003    }
    1004    value
    1005}
    1006
    1007/// Unpack first and zeroth into two 16-bit signed halfwords in each 32-bit chunk
    1008#[inline]
    1009#[cfg_attr(test, assert_instr(unknown))]
    1010#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    1011pub fn sunpkd810(a: usize) -> usize {
    1012    let value: usize;
    1013    unsafe {
    1014        asm!(".insn i 0x77, 0x0, {}, {}, %lo(0xAC8)", lateout(reg) value, in(reg) a, options(pure, nomem, nostack))
    1015    }
    1016    value
    1017}
    1018
    1019/// Unpack second and zeroth into two 16-bit signed halfwords in each 32-bit chunk
    1020#[inline]
    1021#[cfg_attr(test, assert_instr(unknown))]
    1022#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    1023pub fn sunpkd820(a: usize) -> usize {
    1024    let value: usize;
    1025    unsafe {
    1026        asm!(".insn i 0x77, 0x0, {}, {}, %lo(0xAC9)", lateout(reg) value, in(reg) a, options(pure, nomem, nostack))
    1027    }
    1028    value
    1029}
    1030
    1031/// Unpack third and zeroth into two 16-bit signed halfwords in each 32-bit chunk
    1032#[inline]
    1033#[cfg_attr(test, assert_instr(unknown))]
    1034#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    1035pub fn sunpkd830(a: usize) -> usize {
    1036    let value: usize;
    1037    unsafe {
    1038        asm!(".insn i 0x77, 0x0, {}, {}, %lo(0xACA)", lateout(reg) value, in(reg) a, options(pure, nomem, nostack))
    1039    }
    1040    value
    1041}
    1042
    1043/// Unpack third and first into two 16-bit signed halfwords in each 32-bit chunk
    1044#[inline]
    1045#[cfg_attr(test, assert_instr(unknown))]
    1046#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    1047pub fn sunpkd831(a: usize) -> usize {
    1048    let value: usize;
    1049    unsafe {
    1050        asm!(".insn i 0x77, 0x0, {}, {}, %lo(0xACB)", lateout(reg) value, in(reg) a, options(pure, nomem, nostack))
    1051    }
    1052    value
    1053}
    1054
    1055/// Unpack third and second into two 16-bit signed halfwords in each 32-bit chunk
    1056#[inline]
    1057#[cfg_attr(test, assert_instr(unknown))]
    1058#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    1059pub fn sunpkd832(a: usize) -> usize {
    1060    let value: usize;
    1061    unsafe {
    1062        asm!(".insn i 0x77, 0x0, {}, {}, %lo(0xAD3)", lateout(reg) value, in(reg) a, options(pure, nomem, nostack))
    1063    }
    1064    value
    1065}
    1066
    1067/// Unpack first and zeroth into two 16-bit unsigned halfwords in each 32-bit chunk
    1068#[inline]
    1069#[cfg_attr(test, assert_instr(unknown))]
    1070#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    1071pub fn zunpkd810(a: usize) -> usize {
    1072    let value: usize;
    1073    unsafe {
    1074        asm!(".insn i 0x77, 0x0, {}, {}, %lo(0xACC)", lateout(reg) value, in(reg) a, options(pure, nomem, nostack))
    1075    }
    1076    value
    1077}
    1078
    1079/// Unpack second and zeroth into two 16-bit unsigned halfwords in each 32-bit chunk
    1080#[inline]
    1081#[cfg_attr(test, assert_instr(unknown))]
    1082#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    1083pub fn zunpkd820(a: usize) -> usize {
    1084    let value: usize;
    1085    unsafe {
    1086        asm!(".insn i 0x77, 0x0, {}, {}, %lo(0xACD)", lateout(reg) value, in(reg) a, options(pure, nomem, nostack))
    1087    }
    1088    value
    1089}
    1090
    1091/// Unpack third and zeroth into two 16-bit unsigned halfwords in each 32-bit chunk
    1092#[inline]
    1093#[cfg_attr(test, assert_instr(unknown))]
    1094#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    1095pub fn zunpkd830(a: usize) -> usize {
    1096    let value: usize;
    1097    unsafe {
    1098        asm!(".insn i 0x77, 0x0, {}, {}, %lo(0xACE)", lateout(reg) value, in(reg) a, options(pure, nomem, nostack))
    1099    }
    1100    value
    1101}
    1102
    1103/// Unpack third and first into two 16-bit unsigned halfwords in each 32-bit chunk
    1104#[inline]
    1105#[cfg_attr(test, assert_instr(unknown))]
    1106#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    1107pub fn zunpkd831(a: usize) -> usize {
    1108    let value: usize;
    1109    unsafe {
    1110        asm!(".insn i 0x77, 0x0, {}, {}, %lo(0xACF)", lateout(reg) value, in(reg) a, options(pure, nomem, nostack))
    1111    }
    1112    value
    1113}
    1114
    1115/// Unpack third and second into two 16-bit unsigned halfwords in each 32-bit chunk
    1116#[inline]
    1117#[cfg_attr(test, assert_instr(unknown))]
    1118#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    1119pub fn zunpkd832(a: usize) -> usize {
    1120    let value: usize;
    1121    unsafe {
    1122        asm!(".insn i 0x77, 0x0, {}, {}, %lo(0xAD7)", lateout(reg) value, in(reg) a, options(pure, nomem, nostack))
    1123    }
    1124    value
    1125}
    1126
    1127// todo: pkbb16, pktt16
    1128
    1129/// Pack two 16-bit data from bottom and top half from 32-bit chunks
    1130#[inline]
    1131#[cfg_attr(test, assert_instr(unknown))]
    1132#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    1133pub fn pkbt16(a: usize, b: usize) -> usize {
    1134    let value: usize;
    1135    unsafe {
    1136        asm!(".insn r 0x77, 0x1, 0x0F, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    1137    }
    1138    value
    1139}
    1140
    1141/// Pack two 16-bit data from top and bottom half from 32-bit chunks
    1142#[inline]
    1143#[cfg_attr(test, assert_instr(unknown))]
    1144#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    1145pub fn pktb16(a: usize, b: usize) -> usize {
    1146    let value: usize;
    1147    unsafe {
    1148        asm!(".insn r 0x77, 0x1, 0x1F, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    1149    }
    1150    value
    1151}
    1152
    1153/// Count the number of redundant sign bits of the packed 32-bit elements
    1154#[inline]
    1155#[cfg_attr(test, assert_instr(unknown))]
    1156#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    1157pub fn clrs32(a: usize) -> usize {
    1158    let value: usize;
    1159    unsafe {
    1160        asm!(".insn i 0x77, 0x0, {}, {}, %lo(0xAF8)", lateout(reg) value, in(reg) a, options(pure, nomem, nostack))
    1161    }
    1162    value
    1163}
    1164
    1165/// Count the number of leading zero bits of the packed 32-bit elements
    1166#[inline]
    1167#[cfg_attr(test, assert_instr(unknown))]
    1168#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    1169pub fn clz32(a: usize) -> usize {
    1170    let value: usize;
    1171    unsafe {
    1172        asm!(".insn i 0x77, 0x0, {}, {}, %lo(0xAF9)", lateout(reg) value, in(reg) a, options(pure, nomem, nostack))
    1173    }
    1174    value
    1175}
    1176
    1177/// Calculate the sum of absolute difference of unsigned 8-bit data elements
    1178#[inline]
    1179#[cfg_attr(test, assert_instr(unknown))]
    1180#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    1181pub fn pbsad(a: usize, b: usize) -> usize {
    1182    let value: usize;
    1183    unsafe {
    1184        asm!(".insn r 0x77, 0x0, 0x7E, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    1185    }
    1186    value
    1187}
    1188
    1189/// Calculate and accumulate the sum of absolute difference of unsigned 8-bit data elements
    1190#[inline]
    1191#[cfg_attr(test, assert_instr(unknown))]
    1192#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    1193pub fn pbsada(t: usize, a: usize, b: usize) -> usize {
    1194    let mut value: usize;
    1195    unsafe {
    1196        asm!(".insn r 0x77, 0x0, 0x7F, {}, {}, {}", inlateout(reg) t => value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    1197    }
    1198    value
    1199}
    1200
    1201/// Multiply signed 8-bit elements and add 16-bit elements on results for packed 32-bit chunks
    1202#[inline]
    1203#[cfg_attr(test, assert_instr(unknown))]
    1204#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    1205pub fn smaqa(t: usize, a: usize, b: usize) -> usize {
    1206    let mut value: usize;
    1207    unsafe {
    1208        asm!(".insn r 0x77, 0x0, 0x64, {}, {}, {}", inlateout(reg) t => value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    1209    }
    1210    value
    1211}
    1212
    1213/// Multiply unsigned 8-bit elements and add 16-bit elements on results for packed 32-bit chunks
    1214#[inline]
    1215#[cfg_attr(test, assert_instr(unknown))]
    1216#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    1217pub fn umaqa(t: usize, a: usize, b: usize) -> usize {
    1218    let mut value: usize;
    1219    unsafe {
    1220        asm!(".insn r 0x77, 0x0, 0x66, {}, {}, {}", inlateout(reg) t => value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    1221    }
    1222    value
    1223}
    1224
    1225/// Multiply signed to unsigned 8-bit and add 16-bit elements on results for packed 32-bit chunks
    1226#[inline]
    1227#[cfg_attr(test, assert_instr(unknown))]
    1228#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    1229pub fn smaqasu(t: usize, a: usize, b: usize) -> usize {
    1230    let mut value: usize;
    1231    unsafe {
    1232        asm!(".insn r 0x77, 0x0, 0x65, {}, {}, {}", inlateout(reg) t => value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    1233    }
    1234    value
    1235}
    1236
    1237/// Adds signed lower 16-bit content of two registers with Q15 saturation
    1238#[inline]
    1239#[cfg_attr(test, assert_instr(unknown))]
    1240#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    1241pub fn kaddh(a: usize, b: usize) -> usize {
    1242    let value: usize;
    1243    unsafe {
    1244        asm!(".insn r 0x77, 0x1, 0x02, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    1245    }
    1246    value
    1247}
    1248
    1249/// Subtracts signed lower 16-bit content of two registers with Q15 saturation
    1250#[inline]
    1251#[cfg_attr(test, assert_instr(unknown))]
    1252#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    1253pub fn ksubh(a: usize, b: usize) -> usize {
    1254    let value: usize;
    1255    unsafe {
    1256        asm!(".insn r 0x77, 0x1, 0x03, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    1257    }
    1258    value
    1259}
    1260
    1261/// Adds signed lower 16-bit content of two registers with U16 saturation
    1262#[inline]
    1263#[cfg_attr(test, assert_instr(unknown))]
    1264#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    1265pub fn ukaddh(a: usize, b: usize) -> usize {
    1266    let value: usize;
    1267    unsafe {
    1268        asm!(".insn r 0x77, 0x1, 0x0A, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    1269    }
    1270    value
    1271}
    1272
    1273/// Subtracts signed lower 16-bit content of two registers with U16 saturation
    1274#[inline]
    1275#[cfg_attr(test, assert_instr(unknown))]
    1276#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")]
    1277pub fn uksubh(a: usize, b: usize) -> usize {
    1278    let value: usize;
    1279    unsafe {
    1280        asm!(".insn r 0x77, 0x1, 0x0B, {}, {}, {}", lateout(reg) value, in(reg) a, in(reg) b, options(pure, nomem, nostack))
    1281    }
    1282    value
    1283}