/// Map a type to an LLHD type.
Map a type to an LLHD type.
Map a type to an LLHD type .
fn emit_type_uninterned(&mut self, ty: &'gcx UnpackedType<'gcx>) -> Result<HybridType> {
        if ty.is_error() {
            return Err(());
        }
        let ty = ty.resolve_full();
        // Handle things that coalesce easily to scalars.
        if ty.coalesces_to_llhd_scalar() {
            let bits = ty.get_bit_size().unwrap();
            return Ok((llhd::int_ty(bits), mlir::get_integer_type(self.mcx, bits)));
        }
        // Handle arrays.
        if let Some(dim) = ty.outermost_dim() {
            let size = match dim.get_size() {
                Some(size) => size,
                None => panic!("cannot map unsized array `{}` to LLHD", ty),
            };
            let inner = ty.pop_dim(self.cx).unwrap();
            let (llty, mty) = self.emit_type_both(inner)?;
            return Ok((
                llhd::array_ty(size, llty),
                circt::hw::get_array_type(mty, size),
            ));
        }
        // Handle structs.
        if let Some(strukt) = ty.get_struct() {
            let mut types = vec![];
            let mut mtypes: Vec<(crate::common::name::RcStr, mlir::Type)> = vec![];
            for member in &strukt.members {
                let (llty, mty) = self.emit_type_both(member.ty)?;
                types.push(llty);
                mtypes.push((member.name.value.as_str(), mty));
            }
            return Ok((
                llhd::struct_ty(types),
                circt::hw::get_struct_type(self.mcx, mtypes),
            ));
        }
        // Handle packed types.
        if let Some(packed) = ty.get_packed() {
            let packed = packed.resolve_full();
            return match packed.core {
                // CAVEAT: We just use an empty HW dialect struct type as a
                // stand-in for an error or void type.
                ty::PackedCore::Void | ty::PackedCore::Error => Ok((
                    llhd::void_ty(),
                    circt::hw::get_struct_type(self.mcx, Option::<(String, mlir::Type)>::None),
                )),
                ty::PackedCore::IntAtom(ty::IntAtomType::Time) => {
                    Ok((llhd::time_ty(), circt::llhd::get_time_type(self.mcx)))
                }
                ty::PackedCore::Enum(ref enm) => self.emit_type_both(enm.base.to_unpacked(self.cx)),
                _ => unreachable!("emitting `{}` should have been handled above", packed),
            };
        }
        // Everything else we cannot do.
        error!("Cannot map type {:#?}", ty);
        panic!("cannot map `{}` to LLHD", ty);
    }
fn emit_type_uninterned ( & mut self , ty : & ' gcx UnpackedType < ' gcx > ) -> Result < HybridType > { if ty . is_error ( ) { return Err ( ( ) ) ; } let ty = ty . resolve_full ( ) ; // Handle things that coalesce easily to scalars. if ty . coalesces_to_llhd_scalar ( ) { let bits = ty . get_bit_size ( ) . unwrap ( ) ; return Ok ( ( llhd :: int_ty ( bits ) , mlir :: get_integer_type ( self . mcx , bits ) ) ) ; } // Handle arrays. if let Some ( dim ) = ty . outermost_dim ( ) { let size = match dim . get_size ( ) { Some ( size ) => size , None => panic ! ( " " ty ) , } ; let inner = ty . pop_dim ( self . cx ) . unwrap ( ) ; let ( llty , mty ) = self . emit_type_both ( inner ) ? ; return Ok ( ( llhd :: array_ty ( size , llty ) , circt :: hw :: get_array_type ( mty , size ) , ) ) ; } // Handle structs. if let Some ( strukt ) = ty . get_struct ( ) { let mut types = vec ! [ ] ; let mut mtypes : Vec < ( crate :: common :: name :: RcStr , mlir :: Type ) > = vec ! [ ] ; for member in & strukt . members { let ( llty , mty ) = self . emit_type_both ( member . ty ) ? ; types . push ( llty ) ; mtypes . push ( ( member . name . value . as_str ( ) , mty ) ) ; } return Ok ( ( llhd :: struct_ty ( types ) , circt :: hw :: get_struct_type ( self . mcx , mtypes ) , ) ) ; } // Handle packed types. if let Some ( packed ) = ty . get_packed ( ) { let packed = packed . resolve_full ( ) ; return match packed . core { // CAVEAT: We just use an empty HW dialect struct type as a // stand-in for an error or void type. ty :: PackedCore :: Void | ty :: PackedCore :: Error => Ok ( ( llhd :: void_ty ( ) , circt :: hw :: get_struct_type ( self . mcx , Option :: < ( String , mlir :: Type ) > :: None ) , ) ) , ty :: PackedCore :: IntAtom ( ty :: IntAtomType :: Time ) => { Ok ( ( llhd :: time_ty ( ) , circt :: llhd :: get_time_type ( self . mcx ) ) ) } ty :: PackedCore :: Enum ( ref enm ) => self . emit_type_both ( enm . base . to_unpacked ( self . cx ) ) , _ => unreachable ! ( " " packed ) , } ; } // Everything else we cannot do. error ! ( " " ty ) ; panic ! ( " " ty ) ; }
Map a type to an LLHD type.
Map a type to an LLHD type .
&mut self
ty
&'gcx UnpackedType<'gcx>