2020-10-01 21:50:15 -05:00
|
|
|
//! 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>
|
2020-10-01 21:50:15 -05:00
|
|
|
|
|
|
|
/// 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;
|
2022-01-27 13:23:40 -06:00
|
|
|
/// 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;
|
2020-11-30 14:52:30 -06:00
|
|
|
|
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;
|
2021-06-15 16:38:34 -05:00
|
|
|
|
2022-01-27 13:23:40 -06:00
|
|
|
// 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;
|
2021-02-04 16:39:15 -06:00
|
|
|
|
|
|
|
// shufflevector
|
2021-09-14 23:59:03 -05:00
|
|
|
pub(crate) fn simd_shuffle<T, U, V>(x: T, y: T, idx: U) -> V;
|
2021-03-28 20:44:16 -05:00
|
|
|
|
2021-06-15 16:38:34 -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-06-15 16:38:34 -05:00
|
|
|
|
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;
|
2021-04-28 21:41:09 -05:00
|
|
|
|
|
|
|
// select
|
2021-09-18 20:31:49 -05:00
|
|
|
pub(crate) fn simd_select<M, T>(m: M, a: T, b: T) -> T;
|
2021-05-07 19:07:07 -05:00
|
|
|
#[allow(unused)]
|
2021-09-18 20:31:49 -05:00
|
|
|
pub(crate) fn simd_select_bitmask<M, T>(m: M, a: T, b: T) -> T;
|
2020-10-01 21:50:15 -05:00
|
|
|
}
|