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;
|
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;
|
|
|
|
|
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
|
|
|
|
pub(crate) fn simd_shuffle2<T, U>(x: T, y: T, idx: [u32; 2]) -> U;
|
|
|
|
pub(crate) fn simd_shuffle4<T, U>(x: T, y: T, idx: [u32; 4]) -> U;
|
|
|
|
pub(crate) fn simd_shuffle8<T, U>(x: T, y: T, idx: [u32; 8]) -> U;
|
|
|
|
pub(crate) fn simd_shuffle16<T, U>(x: T, y: T, idx: [u32; 16]) -> U;
|
|
|
|
pub(crate) fn simd_shuffle32<T, U>(x: T, y: T, idx: [u32; 32]) -> U;
|
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;
|
|
|
|
pub(crate) fn simd_reduce_all<T>(x: T) -> bool;
|
|
|
|
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;
|
2020-10-01 21:50:15 -05:00
|
|
|
}
|
2021-04-25 17:01:05 -05:00
|
|
|
|
|
|
|
#[cfg(feature = "std")]
|
|
|
|
mod std {
|
|
|
|
extern "platform-intrinsic" {
|
|
|
|
// ceil
|
|
|
|
pub(crate) fn simd_ceil<T>(x: T) -> T;
|
|
|
|
|
|
|
|
// floor
|
|
|
|
pub(crate) fn simd_floor<T>(x: T) -> T;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(feature = "std")]
|
|
|
|
pub(crate) use crate::intrinsics::std::*;
|