use crate::ast::{Bits128, PolydatNode, PortType};
#[crate::polydat_node(category = Conversions)]
fn __reg_view_raw(r: Bits128) -> Bits128 {
r
}
#[crate::polydat_node(category = Conversions)]
fn __reg_view_i8x16(r: Bits128) -> [i8; 16] {
r.lanes_i8()
}
#[crate::polydat_node(category = Conversions)]
fn __reg_view_i16x8(r: Bits128) -> [i16; 8] {
r.lanes_i16()
}
#[crate::polydat_node(category = Conversions)]
fn __reg_view_i32x4(r: Bits128) -> [i32; 4] {
r.lanes_i32()
}
#[crate::polydat_node(category = Conversions)]
fn __reg_view_i64x2(r: Bits128) -> [i64; 2] {
r.lanes_i64()
}
#[crate::polydat_node(category = Conversions)]
fn __reg_view_f16x8(r: Bits128) -> [half::f16; 8] {
r.lanes_f16()
}
#[crate::polydat_node(category = Conversions)]
fn __reg_view_f32x4(r: Bits128) -> [f32; 4] {
r.lanes_f32()
}
#[crate::polydat_node(category = Conversions)]
fn __reg_view_f64x2(r: Bits128) -> [f64; 2] {
r.lanes_f64()
}
pub fn reg_view(to: PortType) -> Option<Box<dyn PolydatNode>> {
Some(match to {
PortType::Reg128 => Box::new(RegViewRaw::new()),
PortType::RegI8x16 => Box::new(RegViewI8x16::new()),
PortType::RegI16x8 => Box::new(RegViewI16x8::new()),
PortType::RegI32x4 => Box::new(RegViewI32x4::new()),
PortType::RegI64x2 => Box::new(RegViewI64x2::new()),
PortType::RegF16x8 => Box::new(RegViewF16x8::new()),
PortType::RegF32x4 => Box::new(RegViewF32x4::new()),
PortType::RegF64x2 => Box::new(RegViewF64x2::new()),
_ => return None,
})
}
pub fn is_reg_port(t: PortType) -> bool {
matches!(
t,
PortType::Reg128
| PortType::RegI8x16
| PortType::RegI16x8
| PortType::RegI32x4
| PortType::RegI64x2
| PortType::RegF16x8
| PortType::RegF32x4
| PortType::RegF64x2
)
}