rust/crates/core_simd/src/intrinsics.rs

98 lines
3.1 KiB
Rust
Raw Normal View History

//! This module contains the LLVM intrinsics bindings that provide the functionality for this
//! crate.
//!
2020-12-13 22:58:33 -06:00
//! The LLVM assembly language is documented here: <https://llvm.org/docs/LangRef.html>
/// These intrinsics aren't linked directly from LLVM and are mostly undocumented, however they are
/// simply lowered to the matching LLVM instructions by the compiler. The associated instruction
/// is documented alongside each intrinsic.
extern "platform-intrinsic" {
/// add/fadd
pub(crate) fn simd_add<T>(x: T, y: T) -> T;
/// sub/fsub
pub(crate) fn simd_sub<T>(x: T, y: T) -> T;
/// mul/fmul
pub(crate) fn simd_mul<T>(x: T, y: T) -> T;
/// udiv/sdiv/fdiv
pub(crate) fn simd_div<T>(x: T, y: T) -> T;
/// urem/srem/frem
pub(crate) fn simd_rem<T>(x: T, y: T) -> T;
/// shl
pub(crate) fn simd_shl<T>(x: T, y: T) -> T;
/// lshr/ashr
pub(crate) fn simd_shr<T>(x: T, y: T) -> T;
/// and
pub(crate) fn simd_and<T>(x: T, y: T) -> T;
/// or
pub(crate) fn simd_or<T>(x: T, y: T) -> T;
/// xor
pub(crate) fn simd_xor<T>(x: T, y: T) -> T;
2020-10-11 13:32:46 -05:00
/// fptoui/fptosi/uitofp/sitofp
pub(crate) fn simd_cast<T, U>(x: T) -> U;
/// follows Rust's `T as U` semantics, including saturating float casts
/// which amounts to the same as `simd_cast` for many cases
#[cfg(not(bootstrap))]
pub(crate) fn simd_as<T, U>(x: T) -> U;
2021-04-08 17:11:20 -05:00
/// neg/fneg
pub(crate) fn simd_neg<T>(x: T) -> T;
2021-04-13 21:24:20 -05:00
/// fabs
pub(crate) fn simd_fabs<T>(x: T) -> T;
// minnum/maxnum
pub(crate) fn simd_fmin<T>(x: T, y: T) -> T;
pub(crate) fn simd_fmax<T>(x: T, y: T) -> T;
2020-10-28 15:27:15 -05:00
pub(crate) fn simd_eq<T, U>(x: T, y: T) -> U;
pub(crate) fn simd_ne<T, U>(x: T, y: T) -> U;
pub(crate) fn simd_lt<T, U>(x: T, y: T) -> U;
pub(crate) fn simd_le<T, U>(x: T, y: T) -> U;
pub(crate) fn simd_gt<T, U>(x: T, y: T) -> U;
pub(crate) fn simd_ge<T, U>(x: T, y: T) -> U;
// shufflevector
pub(crate) fn simd_shuffle<T, U, V>(x: T, y: T, idx: U) -> V;
2021-03-28 20:44:16 -05:00
pub(crate) fn simd_gather<T, U, V>(val: T, ptr: U, mask: V) -> T;
2021-06-21 20:04:39 -05:00
pub(crate) fn simd_scatter<T, U, V>(val: T, ptr: U, mask: V);
2021-03-28 20:44:16 -05:00
// {s,u}add.sat
pub(crate) fn simd_saturating_add<T>(x: T, y: T) -> T;
// {s,u}sub.sat
pub(crate) fn simd_saturating_sub<T>(x: T, y: T) -> T;
2021-03-07 18:45:31 -06:00
// reductions
pub(crate) fn simd_reduce_add_ordered<T, U>(x: T, y: U) -> U;
pub(crate) fn simd_reduce_mul_ordered<T, U>(x: T, y: U) -> U;
2021-11-09 23:06:38 -06:00
#[allow(unused)]
2021-03-07 18:45:31 -06:00
pub(crate) fn simd_reduce_all<T>(x: T) -> bool;
2021-11-09 23:06:38 -06:00
#[allow(unused)]
2021-03-07 18:45:31 -06:00
pub(crate) fn simd_reduce_any<T>(x: T) -> bool;
pub(crate) fn simd_reduce_max<T, U>(x: T) -> U;
pub(crate) fn simd_reduce_min<T, U>(x: T) -> U;
pub(crate) fn simd_reduce_and<T, U>(x: T) -> U;
pub(crate) fn simd_reduce_or<T, U>(x: T) -> U;
pub(crate) fn simd_reduce_xor<T, U>(x: T) -> U;
2021-04-18 23:31:43 -05:00
// truncate integer vector to bitmask
2021-11-09 23:06:38 -06:00
#[allow(unused)]
2021-04-18 23:31:43 -05:00
pub(crate) fn simd_bitmask<T, U>(x: T) -> U;
// select
pub(crate) fn simd_select<M, T>(m: M, a: T, b: T) -> T;
2021-05-07 19:07:07 -05:00
#[allow(unused)]
pub(crate) fn simd_select_bitmask<M, T>(m: M, a: T, b: T) -> T;
}