add core::arch::powerpc::ppcf128

This commit is contained in:
Folkert de Vries
2026-08-14 20:02:11 +02:00
parent 3f3f4f05d3
commit 96399615cf
3 changed files with 61 additions and 1 deletions

View File

@@ -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,

View File

@@ -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::*;

View File

@@ -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> {}