mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
remove platform-intrinsics ABI; make SIMD intrinsics be regular intrinsics
This commit is contained in:
parent
e9f9594913
commit
cc3df0af7b
@ -4,14 +4,14 @@
|
||||
|
||||
// Test that the simd_f{min,max} intrinsics produce the correct results.
|
||||
|
||||
#![feature(repr_simd, platform_intrinsics)]
|
||||
#![feature(repr_simd, intrinsics)]
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
#[repr(simd)]
|
||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||
struct f32x4(pub f32, pub f32, pub f32, pub f32);
|
||||
|
||||
extern "platform-intrinsic" {
|
||||
extern "intrinsic" {
|
||||
fn simd_fmin<T>(x: T, y: T) -> T;
|
||||
fn simd_fmax<T>(x: T, y: T) -> T;
|
||||
}
|
||||
|
@ -3,9 +3,9 @@ Invalid monomorphization of an intrinsic function was used.
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0511
|
||||
#![feature(platform_intrinsics)]
|
||||
#![feature(intrinsics)]
|
||||
|
||||
extern "platform-intrinsic" {
|
||||
extern "rust-intrinsic" {
|
||||
fn simd_add<T>(a: T, b: T) -> T;
|
||||
}
|
||||
|
||||
@ -19,13 +19,13 @@ The generic type has to be a SIMD type. Example:
|
||||
|
||||
```
|
||||
#![feature(repr_simd)]
|
||||
#![feature(platform_intrinsics)]
|
||||
#![feature(intrinsics)]
|
||||
|
||||
#[repr(simd)]
|
||||
#[derive(Copy, Clone)]
|
||||
struct i32x2(i32, i32);
|
||||
|
||||
extern "platform-intrinsic" {
|
||||
extern "rust-intrinsic" {
|
||||
fn simd_add<T>(a: T, b: T) -> T;
|
||||
}
|
||||
|
||||
|
@ -156,6 +156,9 @@ declare_features! (
|
||||
Some("removed in favor of `#![feature(marker_trait_attr)]`")),
|
||||
(removed, panic_implementation, "1.28.0", Some(44489),
|
||||
Some("subsumed by `#[panic_handler]`")),
|
||||
/// Allows `extern "platform-intrinsic" { ... }`.
|
||||
(removed, platform_intrinsics, "1.4.0", Some(27731),
|
||||
Some("SIMD intrinsics use the regular intrinsics ABI now")),
|
||||
/// Allows using `#![plugin(myplugin)]`.
|
||||
(removed, plugin, "1.75.0", Some(29597),
|
||||
Some("plugins are no longer supported")),
|
||||
|
@ -259,8 +259,6 @@ declare_features! (
|
||||
(internal, needs_panic_runtime, "1.10.0", Some(32837)),
|
||||
/// Allows using the `#![panic_runtime]` attribute.
|
||||
(internal, panic_runtime, "1.10.0", Some(32837)),
|
||||
/// Allows `extern "platform-intrinsic" { ... }`.
|
||||
(internal, platform_intrinsics, "1.4.0", Some(27731)),
|
||||
/// Allows using `#[rustc_allow_const_fn_unstable]`.
|
||||
/// This is an attribute on `const fn` for the same
|
||||
/// purpose as `#[allow_internal_unstable]`.
|
||||
|
@ -612,17 +612,6 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
||||
}
|
||||
}
|
||||
|
||||
Abi::PlatformIntrinsic => {
|
||||
for item in items {
|
||||
intrinsic::check_platform_intrinsic_type(
|
||||
tcx,
|
||||
item.id.owner_id.def_id,
|
||||
item.span,
|
||||
item.ident.name,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
_ => {
|
||||
for item in items {
|
||||
let def_id = item.id.owner_id.def_id;
|
||||
|
@ -510,41 +510,12 @@ pub fn check_intrinsic_type(
|
||||
|
||||
sym::debug_assertions => (0, 1, Vec::new(), tcx.types.bool),
|
||||
|
||||
other => {
|
||||
tcx.dcx().emit_err(UnrecognizedIntrinsicFunction { span, name: other });
|
||||
return;
|
||||
}
|
||||
};
|
||||
(n_tps, 0, n_cts, inputs, output, unsafety)
|
||||
};
|
||||
let sig = tcx.mk_fn_sig(inputs, output, false, unsafety, abi);
|
||||
let sig = ty::Binder::bind_with_vars(sig, bound_vars);
|
||||
equate_intrinsic_type(tcx, span, intrinsic_id, n_tps, n_lts, n_cts, sig)
|
||||
}
|
||||
|
||||
/// Type-check `extern "platform-intrinsic" { ... }` functions.
|
||||
pub fn check_platform_intrinsic_type(
|
||||
tcx: TyCtxt<'_>,
|
||||
intrinsic_id: LocalDefId,
|
||||
span: Span,
|
||||
name: Symbol,
|
||||
) {
|
||||
let generics = tcx.generics_of(intrinsic_id);
|
||||
let param = |n| {
|
||||
if let Some(&ty::GenericParamDef {
|
||||
name, kind: ty::GenericParamDefKind::Type { .. }, ..
|
||||
}) = generics.opt_param_at(n as usize, tcx)
|
||||
{
|
||||
Ty::new_param(tcx, n, name)
|
||||
} else {
|
||||
Ty::new_error_with_message(tcx, span, "expected param")
|
||||
}
|
||||
};
|
||||
|
||||
let (n_tps, n_cts, inputs, output) = match name {
|
||||
sym::simd_eq | sym::simd_ne | sym::simd_lt | sym::simd_le | sym::simd_gt | sym::simd_ge => {
|
||||
(2, 0, vec![param(0), param(0)], param(1))
|
||||
}
|
||||
sym::simd_eq
|
||||
| sym::simd_ne
|
||||
| sym::simd_lt
|
||||
| sym::simd_le
|
||||
| sym::simd_gt
|
||||
| sym::simd_ge => (2, 0, vec![param(0), param(0)], param(1)),
|
||||
sym::simd_add
|
||||
| sym::simd_sub
|
||||
| sym::simd_mul
|
||||
@ -609,14 +580,15 @@ pub fn check_platform_intrinsic_type(
|
||||
| sym::simd_reduce_max => (2, 0, vec![param(0)], param(1)),
|
||||
sym::simd_shuffle => (3, 0, vec![param(0), param(0), param(1)], param(2)),
|
||||
sym::simd_shuffle_generic => (2, 1, vec![param(0), param(0)], param(1)),
|
||||
_ => {
|
||||
let msg = format!("unrecognized platform-specific intrinsic function: `{name}`");
|
||||
tcx.dcx().span_err(span, msg);
|
||||
|
||||
other => {
|
||||
tcx.dcx().emit_err(UnrecognizedIntrinsicFunction { span, name: other });
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let sig = tcx.mk_fn_sig(inputs, output, false, hir::Unsafety::Unsafe, Abi::PlatformIntrinsic);
|
||||
let sig = ty::Binder::dummy(sig);
|
||||
equate_intrinsic_type(tcx, span, intrinsic_id, n_tps, 0, n_cts, sig)
|
||||
(n_tps, 0, n_cts, inputs, output, unsafety)
|
||||
};
|
||||
let sig = tcx.mk_fn_sig(inputs, output, false, unsafety, abi);
|
||||
let sig = ty::Binder::bind_with_vars(sig, bound_vars);
|
||||
equate_intrinsic_type(tcx, span, intrinsic_id, n_tps, n_lts, n_cts, sig)
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ fn get_owner_return_paths(
|
||||
/// as they must always be defined by the compiler.
|
||||
// FIXME: Move this to a more appropriate place.
|
||||
pub fn forbid_intrinsic_abi(tcx: TyCtxt<'_>, sp: Span, abi: Abi) {
|
||||
if let Abi::RustIntrinsic | Abi::PlatformIntrinsic = abi {
|
||||
if let Abi::RustIntrinsic = abi {
|
||||
tcx.dcx().span_err(sp, "intrinsic must be in `extern \"rust-intrinsic\" { ... }` block");
|
||||
}
|
||||
}
|
||||
|
@ -1677,10 +1677,7 @@ fn compute_sig_of_foreign_fn_decl<'tcx>(
|
||||
|
||||
// Feature gate SIMD types in FFI, since I am not sure that the
|
||||
// ABIs are handled at all correctly. -huonw
|
||||
if abi != abi::Abi::RustIntrinsic
|
||||
&& abi != abi::Abi::PlatformIntrinsic
|
||||
&& !tcx.features().simd_ffi
|
||||
{
|
||||
if abi != abi::Abi::RustIntrinsic && !tcx.features().simd_ffi {
|
||||
let check = |ast_ty: &hir::Ty<'_>, ty: Ty<'_>| {
|
||||
if ty.is_simd() {
|
||||
let snip = tcx
|
||||
|
@ -1173,11 +1173,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
};
|
||||
if let (Some(a_sig), Some(b_sig)) = (a_sig, b_sig) {
|
||||
// Intrinsics are not coercible to function pointers.
|
||||
if a_sig.abi() == Abi::RustIntrinsic
|
||||
|| a_sig.abi() == Abi::PlatformIntrinsic
|
||||
|| b_sig.abi() == Abi::RustIntrinsic
|
||||
|| b_sig.abi() == Abi::PlatformIntrinsic
|
||||
{
|
||||
if a_sig.abi() == Abi::RustIntrinsic || b_sig.abi() == Abi::RustIntrinsic {
|
||||
return Err(TypeError::IntrinsicCast);
|
||||
}
|
||||
// The signature must match.
|
||||
|
@ -1587,10 +1587,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn is_internal_abi(&self, abi: SpecAbi) -> bool {
|
||||
matches!(
|
||||
abi,
|
||||
SpecAbi::Rust | SpecAbi::RustCall | SpecAbi::RustIntrinsic | SpecAbi::PlatformIntrinsic
|
||||
)
|
||||
matches!(abi, SpecAbi::Rust | SpecAbi::RustCall | SpecAbi::RustIntrinsic)
|
||||
}
|
||||
|
||||
/// Find any fn-ptr types with external ABIs in `ty`.
|
||||
|
@ -99,7 +99,7 @@ impl<'tcx> Collector<'tcx> {
|
||||
|
||||
let sess = self.tcx.sess;
|
||||
|
||||
if matches!(abi, Abi::Rust | Abi::RustIntrinsic | Abi::PlatformIntrinsic) {
|
||||
if matches!(abi, Abi::Rust | Abi::RustIntrinsic) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1244,7 +1244,6 @@ pub fn fn_can_unwind(tcx: TyCtxt<'_>, fn_def_id: Option<DefId>, abi: SpecAbi) ->
|
||||
| RiscvInterruptS
|
||||
| CCmseNonSecureCall
|
||||
| Wasm
|
||||
| PlatformIntrinsic
|
||||
| Unadjusted => false,
|
||||
Rust | RustCall | RustCold | RustIntrinsic => {
|
||||
tcx.sess.panic_strategy() == PanicStrategy::Unwind
|
||||
|
@ -1643,7 +1643,7 @@ pub fn is_doc_notable_trait(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
||||
|
||||
/// Determines whether an item is an intrinsic by Abi. or by whether it has a `rustc_intrinsic` attribute
|
||||
pub fn intrinsic(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<Symbol> {
|
||||
if matches!(tcx.fn_sig(def_id).skip_binder().abi(), Abi::RustIntrinsic | Abi::PlatformIntrinsic)
|
||||
if matches!(tcx.fn_sig(def_id).skip_binder().abi(), Abi::RustIntrinsic)
|
||||
|| tcx.has_attr(def_id, sym::rustc_intrinsic)
|
||||
{
|
||||
Some(tcx.item_name(def_id.into()))
|
||||
|
@ -34,7 +34,6 @@ fn abi_can_unwind(abi: Abi) -> bool {
|
||||
| CCmseNonSecureCall
|
||||
| Wasm
|
||||
| RustIntrinsic
|
||||
| PlatformIntrinsic
|
||||
| Unadjusted => false,
|
||||
Rust | RustCall | RustCold => true,
|
||||
}
|
||||
|
@ -1389,7 +1389,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
||||
if target == Target::ForeignMod
|
||||
&& let hir::Node::Item(item) = self.tcx.hir_node(hir_id)
|
||||
&& let Item { kind: ItemKind::ForeignMod { abi, .. }, .. } = item
|
||||
&& !matches!(abi, Abi::Rust | Abi::RustIntrinsic | Abi::PlatformIntrinsic)
|
||||
&& !matches!(abi, Abi::Rust | Abi::RustIntrinsic)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -2071,7 +2071,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
||||
) -> bool {
|
||||
if let Target::ForeignFn = target
|
||||
&& let hir::Node::Item(Item {
|
||||
kind: ItemKind::ForeignMod { abi: Abi::RustIntrinsic | Abi::PlatformIntrinsic, .. },
|
||||
kind: ItemKind::ForeignMod { abi: Abi::RustIntrinsic, .. },
|
||||
..
|
||||
}) = self.tcx.parent_hir_node(hir_id)
|
||||
{
|
||||
|
@ -173,10 +173,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
|
||||
// If the current node is a function, has const stability attributes and if it doesn not have an intrinsic ABI,
|
||||
// check if the function/method is const or the parent impl block is const
|
||||
if let (Some(const_span), Some(fn_sig)) = (const_span, fn_sig) {
|
||||
if fn_sig.header.abi != Abi::RustIntrinsic
|
||||
&& fn_sig.header.abi != Abi::PlatformIntrinsic
|
||||
&& !fn_sig.header.is_const()
|
||||
{
|
||||
if fn_sig.header.abi != Abi::RustIntrinsic && !fn_sig.header.is_const() {
|
||||
if !self.in_trait_impl
|
||||
|| (self.in_trait_impl && !self.tcx.is_const_fn_raw(def_id.to_def_id()))
|
||||
{
|
||||
|
@ -457,7 +457,6 @@ impl RustcInternal for Abi {
|
||||
Abi::System { unwind } => rustc_target::spec::abi::Abi::System { unwind },
|
||||
Abi::RustIntrinsic => rustc_target::spec::abi::Abi::RustIntrinsic,
|
||||
Abi::RustCall => rustc_target::spec::abi::Abi::RustCall,
|
||||
Abi::PlatformIntrinsic => rustc_target::spec::abi::Abi::PlatformIntrinsic,
|
||||
Abi::Unadjusted => rustc_target::spec::abi::Abi::Unadjusted,
|
||||
Abi::RustCold => rustc_target::spec::abi::Abi::RustCold,
|
||||
Abi::RiscvInterruptM => rustc_target::spec::abi::Abi::RiscvInterruptM,
|
||||
|
@ -833,7 +833,6 @@ impl<'tcx> Stable<'tcx> for rustc_target::spec::abi::Abi {
|
||||
abi::Abi::System { unwind } => Abi::System { unwind },
|
||||
abi::Abi::RustIntrinsic => Abi::RustIntrinsic,
|
||||
abi::Abi::RustCall => Abi::RustCall,
|
||||
abi::Abi::PlatformIntrinsic => Abi::PlatformIntrinsic,
|
||||
abi::Abi::Unadjusted => Abi::Unadjusted,
|
||||
abi::Abi::RustCold => Abi::RustCold,
|
||||
abi::Abi::RiscvInterruptM => Abi::RiscvInterruptM,
|
||||
|
@ -54,7 +54,6 @@ pub enum Abi {
|
||||
},
|
||||
RustIntrinsic,
|
||||
RustCall,
|
||||
PlatformIntrinsic,
|
||||
Unadjusted,
|
||||
/// For things unlikely to be called, where reducing register pressure in
|
||||
/// `extern "Rust"` callers is worth paying extra cost in the callee.
|
||||
@ -129,7 +128,6 @@ const AbiDatas: &[AbiData] = &[
|
||||
AbiData { abi: Abi::System { unwind: true }, name: "system-unwind" },
|
||||
AbiData { abi: Abi::RustIntrinsic, name: "rust-intrinsic" },
|
||||
AbiData { abi: Abi::RustCall, name: "rust-call" },
|
||||
AbiData { abi: Abi::PlatformIntrinsic, name: "platform-intrinsic" },
|
||||
AbiData { abi: Abi::Unadjusted, name: "unadjusted" },
|
||||
AbiData { abi: Abi::RustCold, name: "rust-cold" },
|
||||
AbiData { abi: Abi::RiscvInterruptM, name: "riscv-interrupt-m" },
|
||||
@ -199,10 +197,6 @@ pub fn is_stable(name: &str) -> Result<(), AbiDisabled> {
|
||||
feature: sym::intrinsics,
|
||||
explain: "intrinsics are subject to change",
|
||||
}),
|
||||
"platform-intrinsic" => Err(AbiDisabled::Unstable {
|
||||
feature: sym::platform_intrinsics,
|
||||
explain: "platform intrinsics are experimental and possibly buggy",
|
||||
}),
|
||||
"vectorcall" => Err(AbiDisabled::Unstable {
|
||||
feature: sym::abi_vectorcall,
|
||||
explain: "vectorcall is experimental and subject to change",
|
||||
@ -299,11 +293,10 @@ impl Abi {
|
||||
System { unwind: true } => 28,
|
||||
RustIntrinsic => 29,
|
||||
RustCall => 30,
|
||||
PlatformIntrinsic => 31,
|
||||
Unadjusted => 32,
|
||||
RustCold => 33,
|
||||
RiscvInterruptM => 34,
|
||||
RiscvInterruptS => 35,
|
||||
Unadjusted => 31,
|
||||
RustCold => 32,
|
||||
RiscvInterruptM => 33,
|
||||
RiscvInterruptS => 34,
|
||||
};
|
||||
debug_assert!(
|
||||
AbiDatas
|
||||
|
@ -2448,7 +2448,6 @@ impl Target {
|
||||
| System { .. }
|
||||
| RustIntrinsic
|
||||
| RustCall
|
||||
| PlatformIntrinsic
|
||||
| Unadjusted
|
||||
| Cdecl { .. }
|
||||
| RustCold => true,
|
||||
|
@ -312,7 +312,7 @@ fn fn_sig_for_fn_abi<'tcx>(
|
||||
fn conv_from_spec_abi(tcx: TyCtxt<'_>, abi: SpecAbi, c_variadic: bool) -> Conv {
|
||||
use rustc_target::spec::abi::Abi::*;
|
||||
match tcx.sess.target.adjust_abi(abi, c_variadic) {
|
||||
RustIntrinsic | PlatformIntrinsic | Rust | RustCall => Conv::Rust,
|
||||
RustIntrinsic | Rust | RustCall => Conv::Rust,
|
||||
|
||||
// This is intentionally not using `Conv::Cold`, as that has to preserve
|
||||
// even SIMD registers, which is generally not a good trade-off.
|
||||
@ -605,7 +605,7 @@ fn fn_abi_new_uncached<'tcx>(
|
||||
let linux_powerpc_gnu_like =
|
||||
target.os == "linux" && target.arch == "powerpc" && target_env_gnu_like;
|
||||
use SpecAbi::*;
|
||||
let rust_abi = matches!(sig.abi, RustIntrinsic | PlatformIntrinsic | Rust | RustCall);
|
||||
let rust_abi = matches!(sig.abi, RustIntrinsic | Rust | RustCall);
|
||||
|
||||
let is_drop_in_place =
|
||||
fn_def_id.is_some() && fn_def_id == cx.tcx.lang_items().drop_in_place_fn();
|
||||
@ -713,11 +713,7 @@ fn fn_abi_adjust_for_abi<'tcx>(
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if abi == SpecAbi::Rust
|
||||
|| abi == SpecAbi::RustCall
|
||||
|| abi == SpecAbi::RustIntrinsic
|
||||
|| abi == SpecAbi::PlatformIntrinsic
|
||||
{
|
||||
if abi == SpecAbi::Rust || abi == SpecAbi::RustCall || abi == SpecAbi::RustIntrinsic {
|
||||
// Look up the deduced parameter attributes for this function, if we have its def ID and
|
||||
// we're optimizing in non-incremental mode. We'll tag its parameters with those attributes
|
||||
// as appropriate.
|
||||
@ -753,12 +749,11 @@ fn fn_abi_adjust_for_abi<'tcx>(
|
||||
// target feature sets. Some more information about this
|
||||
// issue can be found in #44367.
|
||||
//
|
||||
// Note that the platform intrinsic ABI is exempt here as
|
||||
// Note that the intrinsic ABI is exempt here as
|
||||
// that's how we connect up to LLVM and it's unstable
|
||||
// anyway, we control all calls to it in libstd.
|
||||
Abi::Vector { .. }
|
||||
if abi != SpecAbi::PlatformIntrinsic
|
||||
&& cx.tcx.sess.target.simd_types_indirect =>
|
||||
if abi != SpecAbi::RustIntrinsic && cx.tcx.sess.target.simd_types_indirect =>
|
||||
{
|
||||
arg.make_indirect();
|
||||
return;
|
||||
|
@ -906,7 +906,6 @@ pub enum Abi {
|
||||
System { unwind: bool },
|
||||
RustIntrinsic,
|
||||
RustCall,
|
||||
PlatformIntrinsic,
|
||||
Unadjusted,
|
||||
RustCold,
|
||||
RiscvInterruptM,
|
||||
|
@ -2,7 +2,11 @@
|
||||
//!
|
||||
//! In this module, a "vector" is any `repr(simd)` type.
|
||||
|
||||
extern "platform-intrinsic" {
|
||||
// Temporary macro while we switch the ABI from "platform-intrinsics" to "intrinsics".
|
||||
#[rustfmt::skip]
|
||||
macro_rules! declare_intrinsics {
|
||||
($abi:tt) => {
|
||||
extern $abi {
|
||||
/// Insert an element into a vector, returning the updated vector.
|
||||
///
|
||||
/// `T` must be a vector with element type `U`.
|
||||
@ -10,6 +14,7 @@ extern "platform-intrinsic" {
|
||||
/// # Safety
|
||||
///
|
||||
/// `idx` must be in-bounds of the vector.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_insert<T, U>(x: T, idx: u32, val: U) -> T;
|
||||
|
||||
/// Extract an element from a vector.
|
||||
@ -19,21 +24,25 @@ extern "platform-intrinsic" {
|
||||
/// # Safety
|
||||
///
|
||||
/// `idx` must be in-bounds of the vector.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_extract<T, U>(x: T, idx: u32) -> U;
|
||||
|
||||
/// Add two simd vectors elementwise.
|
||||
///
|
||||
/// `T` must be a vector of integer or floating point primitive types.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_add<T>(x: T, y: T) -> T;
|
||||
|
||||
/// Subtract `rhs` from `lhs` elementwise.
|
||||
///
|
||||
/// `T` must be a vector of integer or floating point primitive types.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_sub<T>(lhs: T, rhs: T) -> T;
|
||||
|
||||
/// Multiply two simd vectors elementwise.
|
||||
///
|
||||
/// `T` must be a vector of integer or floating point primitive types.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_mul<T>(x: T, y: T) -> T;
|
||||
|
||||
/// Divide `lhs` by `rhs` elementwise.
|
||||
@ -43,6 +52,7 @@ extern "platform-intrinsic" {
|
||||
/// # Safety
|
||||
/// For integers, `rhs` must not contain any zero elements.
|
||||
/// Additionally for signed integers, `<int>::MIN / -1` is undefined behavior.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_div<T>(lhs: T, rhs: T) -> T;
|
||||
|
||||
/// Remainder of two vectors elementwise
|
||||
@ -52,6 +62,7 @@ extern "platform-intrinsic" {
|
||||
/// # Safety
|
||||
/// For integers, `rhs` must not contain any zero elements.
|
||||
/// Additionally for signed integers, `<int>::MIN / -1` is undefined behavior.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_rem<T>(lhs: T, rhs: T) -> T;
|
||||
|
||||
/// Elementwise vector left shift, with UB on overflow.
|
||||
@ -63,6 +74,7 @@ extern "platform-intrinsic" {
|
||||
/// # Safety
|
||||
///
|
||||
/// Each element of `rhs` must be less than `<int>::BITS`.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_shl<T>(lhs: T, rhs: T) -> T;
|
||||
|
||||
/// Elementwise vector right shift, with UB on overflow.
|
||||
@ -74,21 +86,25 @@ extern "platform-intrinsic" {
|
||||
/// # Safety
|
||||
///
|
||||
/// Each element of `rhs` must be less than `<int>::BITS`.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_shr<T>(lhs: T, rhs: T) -> T;
|
||||
|
||||
/// Elementwise vector "and".
|
||||
///
|
||||
/// `T` must be a vector of integer primitive types.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_and<T>(x: T, y: T) -> T;
|
||||
|
||||
/// Elementwise vector "or".
|
||||
///
|
||||
/// `T` must be a vector of integer primitive types.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_or<T>(x: T, y: T) -> T;
|
||||
|
||||
/// Elementwise vector "exclusive or".
|
||||
///
|
||||
/// `T` must be a vector of integer primitive types.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_xor<T>(x: T, y: T) -> T;
|
||||
|
||||
/// Numerically cast a vector, elementwise.
|
||||
@ -109,6 +125,7 @@ extern "platform-intrinsic" {
|
||||
/// * Not be `NaN`
|
||||
/// * Not be infinite
|
||||
/// * Be representable in the return type, after truncating off its fractional part
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_cast<T, U>(x: T) -> U;
|
||||
|
||||
/// Numerically cast a vector, elementwise.
|
||||
@ -122,6 +139,7 @@ extern "platform-intrinsic" {
|
||||
/// When casting floats to integers, the result is truncated.
|
||||
/// When casting integers to floats, the result is rounded.
|
||||
/// Otherwise, truncates or extends the value, maintaining the sign for signed integers.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_as<T, U>(x: T) -> U;
|
||||
|
||||
/// Elementwise negation of a vector.
|
||||
@ -129,11 +147,13 @@ extern "platform-intrinsic" {
|
||||
/// `T` must be a vector of integer or floating-point primitive types.
|
||||
///
|
||||
/// Rust panics for `-<int>::Min` due to overflow, but it is not UB with this intrinsic.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_neg<T>(x: T) -> T;
|
||||
|
||||
/// Elementwise absolute value of a vector.
|
||||
///
|
||||
/// `T` must be a vector of floating-point primitive types.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_fabs<T>(x: T) -> T;
|
||||
|
||||
/// Elementwise minimum of a vector.
|
||||
@ -141,6 +161,7 @@ extern "platform-intrinsic" {
|
||||
/// `T` must be a vector of floating-point primitive types.
|
||||
///
|
||||
/// Follows IEEE-754 `minNum` semantics.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_fmin<T>(x: T, y: T) -> T;
|
||||
|
||||
/// Elementwise maximum of a vector.
|
||||
@ -148,6 +169,7 @@ extern "platform-intrinsic" {
|
||||
/// `T` must be a vector of floating-point primitive types.
|
||||
///
|
||||
/// Follows IEEE-754 `maxNum` semantics.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_fmax<T>(x: T, y: T) -> T;
|
||||
|
||||
/// Tests elementwise equality of two vectors.
|
||||
@ -157,6 +179,7 @@ extern "platform-intrinsic" {
|
||||
/// `U` must be a vector of integers with the same number of elements and element size as `T`.
|
||||
///
|
||||
/// Returns `0` for false and `!0` for true.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_eq<T, U>(x: T, y: T) -> U;
|
||||
|
||||
/// Tests elementwise inequality equality of two vectors.
|
||||
@ -166,6 +189,7 @@ extern "platform-intrinsic" {
|
||||
/// `U` must be a vector of integers with the same number of elements and element size as `T`.
|
||||
///
|
||||
/// Returns `0` for false and `!0` for true.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_ne<T, U>(x: T, y: T) -> U;
|
||||
|
||||
/// Tests if `x` is less than `y`, elementwise.
|
||||
@ -175,6 +199,7 @@ extern "platform-intrinsic" {
|
||||
/// `U` must be a vector of integers with the same number of elements and element size as `T`.
|
||||
///
|
||||
/// Returns `0` for false and `!0` for true.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_lt<T, U>(x: T, y: T) -> U;
|
||||
|
||||
/// Tests if `x` is less than or equal to `y`, elementwise.
|
||||
@ -184,6 +209,7 @@ extern "platform-intrinsic" {
|
||||
/// `U` must be a vector of integers with the same number of elements and element size as `T`.
|
||||
///
|
||||
/// Returns `0` for false and `!0` for true.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_le<T, U>(x: T, y: T) -> U;
|
||||
|
||||
/// Tests if `x` is greater than `y`, elementwise.
|
||||
@ -193,6 +219,7 @@ extern "platform-intrinsic" {
|
||||
/// `U` must be a vector of integers with the same number of elements and element size as `T`.
|
||||
///
|
||||
/// Returns `0` for false and `!0` for true.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_gt<T, U>(x: T, y: T) -> U;
|
||||
|
||||
/// Tests if `x` is greater than or equal to `y`, elementwise.
|
||||
@ -202,6 +229,7 @@ extern "platform-intrinsic" {
|
||||
/// `U` must be a vector of integers with the same number of elements and element size as `T`.
|
||||
///
|
||||
/// Returns `0` for false and `!0` for true.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_ge<T, U>(x: T, y: T) -> U;
|
||||
|
||||
/// Shuffle two vectors by const indices.
|
||||
@ -216,6 +244,7 @@ extern "platform-intrinsic" {
|
||||
/// Returns a new vector such that element `i` is selected from `xy[idx[i]]`, where `xy`
|
||||
/// is the concatenation of `x` and `y`. It is a compile-time error if `idx[i]` is out-of-bounds
|
||||
/// of `xy`.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_shuffle<T, U, V>(x: T, y: T, idx: U) -> V;
|
||||
|
||||
/// Shuffle two vectors by const indices.
|
||||
@ -227,6 +256,7 @@ extern "platform-intrinsic" {
|
||||
/// Returns a new vector such that element `i` is selected from `xy[IDX[i]]`, where `xy`
|
||||
/// is the concatenation of `x` and `y`. It is a compile-time error if `IDX[i]` is out-of-bounds
|
||||
/// of `xy`.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_shuffle_generic<T, U, const IDX: &'static [u32]>(x: T, y: T) -> U;
|
||||
|
||||
/// Read a vector of pointers.
|
||||
@ -249,6 +279,7 @@ extern "platform-intrinsic" {
|
||||
/// type).
|
||||
///
|
||||
/// `mask` must only contain `0` or `!0` values.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_gather<T, U, V>(val: T, ptr: U, mask: V) -> T;
|
||||
|
||||
/// Write to a vector of pointers.
|
||||
@ -271,6 +302,7 @@ extern "platform-intrinsic" {
|
||||
/// type).
|
||||
///
|
||||
/// `mask` must only contain `0` or `!0` values.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_scatter<T, U, V>(val: T, ptr: U, mask: V);
|
||||
|
||||
/// Read a vector of pointers.
|
||||
@ -292,6 +324,7 @@ extern "platform-intrinsic" {
|
||||
/// type).
|
||||
///
|
||||
/// `mask` must only contain `0` or `!0` values.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_masked_load<V, U, T>(mask: V, ptr: U, val: T) -> T;
|
||||
|
||||
/// Write to a vector of pointers.
|
||||
@ -312,11 +345,13 @@ extern "platform-intrinsic" {
|
||||
/// type).
|
||||
///
|
||||
/// `mask` must only contain `0` or `!0` values.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_masked_store<V, U, T>(mask: V, ptr: U, val: T);
|
||||
|
||||
/// Add two simd vectors elementwise, with saturation.
|
||||
///
|
||||
/// `T` must be a vector of integer primitive types.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_saturating_add<T>(x: T, y: T) -> T;
|
||||
|
||||
/// Subtract two simd vectors elementwise, with saturation.
|
||||
@ -324,6 +359,7 @@ extern "platform-intrinsic" {
|
||||
/// `T` must be a vector of integer primitive types.
|
||||
///
|
||||
/// Subtract `rhs` from `lhs`.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_saturating_sub<T>(lhs: T, rhs: T) -> T;
|
||||
|
||||
/// Add elements within a vector from left to right.
|
||||
@ -333,6 +369,7 @@ extern "platform-intrinsic" {
|
||||
/// `U` must be the element type of `T`.
|
||||
///
|
||||
/// Starting with the value `y`, add the elements of `x` and accumulate.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_reduce_add_ordered<T, U>(x: T, y: U) -> U;
|
||||
|
||||
/// Add elements within a vector in arbitrary order. May also be re-associated with
|
||||
@ -341,6 +378,7 @@ extern "platform-intrinsic" {
|
||||
/// `T` must be a vector of integer or floating-point primitive types.
|
||||
///
|
||||
/// `U` must be the element type of `T`.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_reduce_add_unordered<T, U>(x: T) -> U;
|
||||
|
||||
/// Multiply elements within a vector from left to right.
|
||||
@ -350,6 +388,7 @@ extern "platform-intrinsic" {
|
||||
/// `U` must be the element type of `T`.
|
||||
///
|
||||
/// Starting with the value `y`, multiply the elements of `x` and accumulate.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_reduce_mul_ordered<T, U>(x: T, y: U) -> U;
|
||||
|
||||
/// Add elements within a vector in arbitrary order. May also be re-associated with
|
||||
@ -358,6 +397,7 @@ extern "platform-intrinsic" {
|
||||
/// `T` must be a vector of integer or floating-point primitive types.
|
||||
///
|
||||
/// `U` must be the element type of `T`.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_reduce_mul_unordered<T, U>(x: T) -> U;
|
||||
|
||||
/// Check if all mask values are true.
|
||||
@ -366,6 +406,7 @@ extern "platform-intrinsic" {
|
||||
///
|
||||
/// # Safety
|
||||
/// `x` must contain only `0` or `!0`.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_reduce_all<T>(x: T) -> bool;
|
||||
|
||||
/// Check if all mask values are true.
|
||||
@ -374,6 +415,7 @@ extern "platform-intrinsic" {
|
||||
///
|
||||
/// # Safety
|
||||
/// `x` must contain only `0` or `!0`.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_reduce_any<T>(x: T) -> bool;
|
||||
|
||||
/// Return the maximum element of a vector.
|
||||
@ -383,6 +425,7 @@ extern "platform-intrinsic" {
|
||||
/// `U` must be the element type of `T`.
|
||||
///
|
||||
/// For floating-point values, uses IEEE-754 `maxNum`.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_reduce_max<T, U>(x: T) -> U;
|
||||
|
||||
/// Return the minimum element of a vector.
|
||||
@ -392,6 +435,7 @@ extern "platform-intrinsic" {
|
||||
/// `U` must be the element type of `T`.
|
||||
///
|
||||
/// For floating-point values, uses IEEE-754 `minNum`.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_reduce_min<T, U>(x: T) -> U;
|
||||
|
||||
/// Logical "and" all elements together.
|
||||
@ -399,6 +443,7 @@ extern "platform-intrinsic" {
|
||||
/// `T` must be a vector of integer or floating-point primitive types.
|
||||
///
|
||||
/// `U` must be the element type of `T`.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_reduce_and<T, U>(x: T) -> U;
|
||||
|
||||
/// Logical "or" all elements together.
|
||||
@ -406,6 +451,7 @@ extern "platform-intrinsic" {
|
||||
/// `T` must be a vector of integer or floating-point primitive types.
|
||||
///
|
||||
/// `U` must be the element type of `T`.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_reduce_or<T, U>(x: T) -> U;
|
||||
|
||||
/// Logical "exclusive or" all elements together.
|
||||
@ -413,6 +459,7 @@ extern "platform-intrinsic" {
|
||||
/// `T` must be a vector of integer or floating-point primitive types.
|
||||
///
|
||||
/// `U` must be the element type of `T`.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_reduce_xor<T, U>(x: T) -> U;
|
||||
|
||||
/// Truncate an integer vector to a bitmask.
|
||||
@ -441,6 +488,7 @@ extern "platform-intrinsic" {
|
||||
///
|
||||
/// # Safety
|
||||
/// `x` must contain only `0` and `!0`.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_bitmask<T, U>(x: T) -> U;
|
||||
|
||||
/// Select elements from a mask.
|
||||
@ -455,6 +503,7 @@ extern "platform-intrinsic" {
|
||||
///
|
||||
/// # Safety
|
||||
/// `mask` must only contain `0` and `!0`.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_select<M, T>(mask: M, if_true: T, if_false: T) -> T;
|
||||
|
||||
/// Select elements from a bitmask.
|
||||
@ -471,6 +520,7 @@ extern "platform-intrinsic" {
|
||||
///
|
||||
/// # Safety
|
||||
/// Padding bits must be all zero.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_select_bitmask<M, T>(m: M, yes: T, no: T) -> T;
|
||||
|
||||
/// Elementwise calculates the offset from a pointer vector, potentially wrapping.
|
||||
@ -480,11 +530,13 @@ extern "platform-intrinsic" {
|
||||
/// `U` must be a vector of `isize` or `usize` with the same number of elements as `T`.
|
||||
///
|
||||
/// Operates as if by `<ptr>::wrapping_offset`.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_arith_offset<T, U>(ptr: T, offset: U) -> T;
|
||||
|
||||
/// Cast a vector of pointers.
|
||||
///
|
||||
/// `T` and `U` must be vectors of pointers with the same number of elements.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_cast_ptr<T, U>(ptr: T) -> U;
|
||||
|
||||
/// Expose a vector of pointers as a vector of addresses.
|
||||
@ -492,6 +544,7 @@ extern "platform-intrinsic" {
|
||||
/// `T` must be a vector of pointers.
|
||||
///
|
||||
/// `U` must be a vector of `usize` with the same length as `T`.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_expose_addr<T, U>(ptr: T) -> U;
|
||||
|
||||
/// Create a vector of pointers from a vector of addresses.
|
||||
@ -499,92 +552,117 @@ extern "platform-intrinsic" {
|
||||
/// `T` must be a vector of `usize`.
|
||||
///
|
||||
/// `U` must be a vector of pointers, with the same length as `T`.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_from_exposed_addr<T, U>(addr: T) -> U;
|
||||
|
||||
/// Swap bytes of each element.
|
||||
///
|
||||
/// `T` must be a vector of integers.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_bswap<T>(x: T) -> T;
|
||||
|
||||
/// Reverse bits of each element.
|
||||
///
|
||||
/// `T` must be a vector of integers.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_bitreverse<T>(x: T) -> T;
|
||||
|
||||
/// Count the leading zeros of each element.
|
||||
///
|
||||
/// `T` must be a vector of integers.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_ctlz<T>(x: T) -> T;
|
||||
|
||||
/// Count the trailing zeros of each element.
|
||||
///
|
||||
/// `T` must be a vector of integers.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_cttz<T>(x: T) -> T;
|
||||
|
||||
/// Round up each element to the next highest integer-valued float.
|
||||
///
|
||||
/// `T` must be a vector of floats.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_ceil<T>(x: T) -> T;
|
||||
|
||||
/// Round down each element to the next lowest integer-valued float.
|
||||
///
|
||||
/// `T` must be a vector of floats.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_floor<T>(x: T) -> T;
|
||||
|
||||
/// Round each element to the closest integer-valued float.
|
||||
/// Ties are resolved by rounding away from 0.
|
||||
///
|
||||
/// `T` must be a vector of floats.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_round<T>(x: T) -> T;
|
||||
|
||||
/// Return the integer part of each element as an integer-valued float.
|
||||
/// In other words, non-integer values are truncated towards zero.
|
||||
///
|
||||
/// `T` must be a vector of floats.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_trunc<T>(x: T) -> T;
|
||||
|
||||
/// Takes the square root of each element.
|
||||
///
|
||||
/// `T` must be a vector of floats.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_fsqrt<T>(x: T) -> T;
|
||||
|
||||
/// Computes `(x*y) + z` for each element, but without any intermediate rounding.
|
||||
///
|
||||
/// `T` must be a vector of floats.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_fma<T>(x: T, y: T, z: T) -> T;
|
||||
|
||||
// Computes the sine of each element.
|
||||
///
|
||||
/// `T` must be a vector of floats.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_fsin<T>(a: T) -> T;
|
||||
|
||||
// Computes the cosine of each element.
|
||||
///
|
||||
/// `T` must be a vector of floats.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_fcos<T>(a: T) -> T;
|
||||
|
||||
// Computes the exponential function of each element.
|
||||
///
|
||||
/// `T` must be a vector of floats.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_fexp<T>(a: T) -> T;
|
||||
|
||||
// Computes 2 raised to the power of each element.
|
||||
///
|
||||
/// `T` must be a vector of floats.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_fexp2<T>(a: T) -> T;
|
||||
|
||||
// Computes the base 10 logarithm of each element.
|
||||
///
|
||||
/// `T` must be a vector of floats.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_flog10<T>(a: T) -> T;
|
||||
|
||||
// Computes the base 2 logarithm of each element.
|
||||
///
|
||||
/// `T` must be a vector of floats.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_flog2<T>(a: T) -> T;
|
||||
|
||||
// Computes the natural logarithm of each element.
|
||||
///
|
||||
/// `T` must be a vector of floats.
|
||||
#[rustc_nounwind]
|
||||
pub fn simd_flog<T>(a: T) -> T;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(bootstrap)]
|
||||
declare_intrinsics!("platform-intrinsic");
|
||||
#[cfg(not(bootstrap))]
|
||||
declare_intrinsics!("rust-intrinsic");
|
||||
|
@ -202,6 +202,7 @@
|
||||
//
|
||||
// Language features:
|
||||
// tidy-alphabetical-start
|
||||
#![cfg_attr(bootstrap, feature(platform_intrinsics))]
|
||||
#![feature(abi_unadjusted)]
|
||||
#![feature(adt_const_params)]
|
||||
#![feature(allow_internal_unsafe)]
|
||||
@ -246,7 +247,6 @@
|
||||
#![feature(never_type)]
|
||||
#![feature(no_core)]
|
||||
#![feature(no_sanitize)]
|
||||
#![feature(platform_intrinsics)]
|
||||
#![feature(prelude_import)]
|
||||
#![feature(repr_simd)]
|
||||
#![feature(rustc_allow_const_fn_unstable)]
|
||||
|
@ -270,6 +270,7 @@
|
||||
//
|
||||
// Language features:
|
||||
// tidy-alphabetical-start
|
||||
#![cfg_attr(bootstrap, feature(platform_intrinsics))]
|
||||
#![feature(alloc_error_handler)]
|
||||
#![feature(allocator_internals)]
|
||||
#![feature(allow_internal_unsafe)]
|
||||
@ -301,7 +302,6 @@
|
||||
#![feature(negative_impls)]
|
||||
#![feature(never_type)]
|
||||
#![feature(no_sanitize)]
|
||||
#![feature(platform_intrinsics)]
|
||||
#![feature(prelude_import)]
|
||||
#![feature(rustc_attrs)]
|
||||
#![feature(rustdoc_internals)]
|
||||
|
Loading…
Reference in New Issue
Block a user