Skip to main content

core/stdarch/crates/core_arch/src/powerpc/
mod.rs

1//! PowerPC intrinsics
2
3pub(crate) mod macros;
4
5/// The IBM extended-precision (double-double) floating-point type.
6// FIXME(ppcf128) improve the docs.
7#[lang = "ppcf128"]
8#[doc(alias = "__ibm128")]
9#[doc(alias = "doubledouble")]
10#[doc(alias = "f64f64")]
11#[unstable(feature = "powerpc_ppcf128", issue = "163323")]
12#[allow(non_camel_case_types)]
13#[doc(cfg(any(target_arch = "powerpc", target_arch = "powerpc64")))]
14#[derive(Clone, Copy)]
15pub struct ppcf128(u128);
16
17#[unstable(feature = "powerpc_ppcf128", issue = "163323")]
18impl crate::fmt::Debug for ppcf128 {
19    fn fmt(&self, f: &mut crate::fmt::Formatter<'_>) -> crate::fmt::Result {
20        let (hi, lo) = self.to_components();
21        write!(f, "ppcf128({hi:?}, {lo:?})")
22    }
23}
24
25impl ppcf128 {
26    /// Returns the memory representation of this floating point number as a byte array in
27    /// native byte order.
28    #[unstable(feature = "powerpc_ppcf128", issue = "163323")]
29    #[inline]
30    pub const fn to_ne_bytes(self) -> [u8; 16] {
31        // SAFETY: every bit pattern of a `ppcf128` is a valid `[u8; 16]`.
32        unsafe { crate::mem::transmute::<ppcf128, [u8; 16]>(self) }
33    }
34
35    /// Returns the large and small component of this floating point number.
36    #[unstable(feature = "powerpc_ppcf128", issue = "163323")]
37    #[rustc_const_unstable(feature = "powerpc_ppcf128", issue = "163323")]
38    #[inline]
39    pub const fn to_components(self) -> (f64, f64) {
40        // SAFETY: every bit pattern of a `ppcf128` is a valid `[f64; 2]`.
41        let [large, small] = unsafe { crate::mem::transmute::<ppcf128, [f64; 2]>(self) };
42        (large, small)
43    }
44}
45
46mod altivec;
47#[unstable(feature = "stdarch_powerpc", issue = "111145")]
48pub use self::altivec::*;
49
50mod vsx;
51#[unstable(feature = "stdarch_powerpc", issue = "111145")]
52pub use self::vsx::*;
53
54#[cfg(test)]
55use stdarch_test::assert_instr;
56
57/// Generates the trap instruction `TRAP`
58#[cfg_attr(test, assert_instr(trap))]
59#[inline]
60#[unstable(feature = "stdarch_powerpc", issue = "111145")]
61pub unsafe fn trap() -> ! {
62    crate::intrinsics::abort_immediate()
63}