mirror of
https://github.com/allankoechke/rust.git
synced 2026-12-02 09:47:57 +00:00
add core::arch::powerpc::ppcf128
This commit is contained in:
@@ -39,7 +39,8 @@
|
||||
maybe_uninit_as_bytes,
|
||||
movrs_target_feature,
|
||||
clflushopt_target_feature,
|
||||
min_adt_const_params
|
||||
min_adt_const_params,
|
||||
lang_items,
|
||||
)]
|
||||
#![cfg_attr(
|
||||
test,
|
||||
|
||||
@@ -2,6 +2,47 @@
|
||||
|
||||
pub(crate) mod macros;
|
||||
|
||||
/// The IBM extended-precision (double-double) floating-point type.
|
||||
// FIXME(ppcf128) improve the docs.
|
||||
#[lang = "ppcf128"]
|
||||
#[doc(alias = "__ibm128")]
|
||||
#[doc(alias = "doubledouble")]
|
||||
#[doc(alias = "f64f64")]
|
||||
#[unstable(feature = "powerpc_ppcf128", issue = "163323")]
|
||||
#[allow(non_camel_case_types)]
|
||||
#[doc(cfg(any(target_arch = "powerpc", target_arch = "powerpc64")))]
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct ppcf128(u128);
|
||||
|
||||
#[unstable(feature = "powerpc_ppcf128", issue = "163323")]
|
||||
impl crate::fmt::Debug for ppcf128 {
|
||||
fn fmt(&self, f: &mut crate::fmt::Formatter<'_>) -> crate::fmt::Result {
|
||||
let (hi, lo) = self.to_components();
|
||||
write!(f, "ppcf128({hi:?}, {lo:?})")
|
||||
}
|
||||
}
|
||||
|
||||
impl ppcf128 {
|
||||
/// Returns the memory representation of this floating point number as a byte array in
|
||||
/// native byte order.
|
||||
#[unstable(feature = "powerpc_ppcf128", issue = "163323")]
|
||||
#[inline]
|
||||
pub const fn to_ne_bytes(self) -> [u8; 16] {
|
||||
// SAFETY: every bit pattern of a `ppcf128` is a valid `[u8; 16]`.
|
||||
unsafe { crate::mem::transmute::<ppcf128, [u8; 16]>(self) }
|
||||
}
|
||||
|
||||
/// Returns the large and small component of this floating point number.
|
||||
#[unstable(feature = "powerpc_ppcf128", issue = "163323")]
|
||||
#[rustc_const_unstable(feature = "powerpc_ppcf128", issue = "163323")]
|
||||
#[inline]
|
||||
pub const fn to_components(self) -> (f64, f64) {
|
||||
// SAFETY: every bit pattern of a `ppcf128` is a valid `[f64; 2]`.
|
||||
let [large, small] = unsafe { crate::mem::transmute::<ppcf128, [f64; 2]>(self) };
|
||||
(large, small)
|
||||
}
|
||||
}
|
||||
|
||||
mod altivec;
|
||||
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
|
||||
pub use self::altivec::*;
|
||||
|
||||
@@ -115,6 +115,24 @@ impl<T: PointeeSized> Copy for *const T {}
|
||||
impl<T: PointeeSized> Copy for *mut T {}
|
||||
impl<T: Copy, const N: usize> Copy for [T; N] {}
|
||||
|
||||
pub mod arch {
|
||||
#[cfg(target_arch = "powerpc")]
|
||||
pub mod powerpc {
|
||||
#[lang = "ppcf128"]
|
||||
pub struct ppcf128(u128);
|
||||
|
||||
impl crate::Copy for ppcf128 {}
|
||||
}
|
||||
|
||||
#[cfg(any(target_arch = "powerpc64"))]
|
||||
pub mod powerpc64 {
|
||||
#[lang = "ppcf128"]
|
||||
pub struct ppcf128(u128);
|
||||
|
||||
impl crate::Copy for ppcf128 {}
|
||||
}
|
||||
}
|
||||
|
||||
#[lang = "phantom_data"]
|
||||
pub struct PhantomData<T: PointeeSized>;
|
||||
impl<T: PointeeSized> Copy for PhantomData<T> {}
|
||||
|
||||
Reference in New Issue
Block a user