use super::*;
#[repr(transparent)]
#[allow(non_camel_case_types)]
pub struct m128(pub __m128);
#[cfg(feature = "bytemuck")]
unsafe impl bytemuck::Zeroable for m128 {}
#[cfg(feature = "bytemuck")]
unsafe impl bytemuck::Pod for m128 {}
#[cfg(feature = "bytemuck")]
unsafe impl bytemuck::TransparentWrapper<__m128> for m128 {}
impl m128 {
#[must_use]
#[inline(always)]
pub fn to_array(self) -> [f32; 4] {
self.into()
}
#[must_use]
#[inline(always)]
pub fn from_array(f: [f32; 4]) -> Self {
f.into()
}
#[must_use]
#[inline(always)]
pub fn to_bits(self) -> [u32; 4] {
unsafe { core::mem::transmute(self) }
}
#[must_use]
#[inline(always)]
pub fn from_bits(bits: [u32; 4]) -> Self {
unsafe { core::mem::transmute(bits) }
}
}
impl Clone for m128 {
#[must_use]
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}
impl Copy for m128 {}
impl Default for m128 {
#[must_use]
#[inline(always)]
fn default() -> Self {
unsafe { core::mem::zeroed() }
}
}
impl From<[f32; 4]> for m128 {
#[must_use]
#[inline(always)]
fn from(arr: [f32; 4]) -> Self {
unsafe { core::mem::transmute(arr) }
}
}
impl From<m128> for [f32; 4] {
#[must_use]
#[inline(always)]
fn from(m: m128) -> Self {
unsafe { core::mem::transmute(m) }
}
}
impl Debug for m128 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
write!(f, "m128(")?;
for (i, float) in self.to_array().iter().enumerate() {
if i != 0 {
write!(f, ", ")?;
}
Debug::fmt(float, f)?;
}
write!(f, ")")
}
}
impl Display for m128 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
write!(f, "(")?;
for (i, float) in self.to_array().iter().enumerate() {
if i != 0 {
write!(f, ", ")?;
}
Display::fmt(float, f)?;
}
write!(f, ")")
}
}
impl Binary for m128 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
write!(f, "(")?;
for (i, float) in self.to_array().iter().enumerate() {
if i != 0 {
write!(f, ", ")?;
}
Binary::fmt(&float.to_bits(), f)?;
}
write!(f, ")")
}
}
impl LowerExp for m128 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
write!(f, "(")?;
for (i, float) in self.to_array().iter().enumerate() {
if i != 0 {
write!(f, ", ")?;
}
LowerExp::fmt(float, f)?;
}
write!(f, ")")
}
}
impl UpperExp for m128 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
write!(f, "(")?;
for (i, float) in self.to_array().iter().enumerate() {
if i != 0 {
write!(f, ", ")?;
}
UpperExp::fmt(float, f)?;
}
write!(f, ")")
}
}
impl LowerHex for m128 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
write!(f, "(")?;
for (i, float) in self.to_array().iter().enumerate() {
if i != 0 {
write!(f, ", ")?;
}
LowerHex::fmt(&float.to_bits(), f)?;
}
write!(f, ")")
}
}
impl UpperHex for m128 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
write!(f, "(")?;
for (i, float) in self.to_array().iter().enumerate() {
if i != 0 {
write!(f, ", ")?;
}
UpperHex::fmt(&float.to_bits(), f)?;
}
write!(f, ")")
}
}
impl Octal for m128 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
write!(f, "(")?;
for (i, float) in self.to_array().iter().enumerate() {
if i != 0 {
write!(f, ", ")?;
}
Octal::fmt(&float.to_bits(), f)?;
}
write!(f, ")")
}
}