fn emit_const_uninterned(
        &mut self,
        value: Value<'gcx>,
        env: ParamEnv,
        span: Span,
    ) -> Result<HybridValue> {
        if value.ty.is_error() {
            return Err(());
        }
        match value.kind {
            ValueKind::Int(ref k, ..) => {
                let size = value.ty.simple_bit_vector(self.cx, span).size;
                Ok((
                    self.builder.ins().const_int((size, k.clone())),
                    circt::hw::ConstantOp::new(self.mlir_builder, std::cmp::max(size, 1), k).into(),
                ))
            }
            ValueKind::Time(ref k) => Ok((
                self.builder
                    .ins()
                    .const_time(llhd::value::TimeValue::new(k.clone(), 0, 0)),
                circt::llhd::ConstantTimeOp::with_seconds(self.mlir_builder, k).into(),
            )),
            ValueKind::StructOrArray(ref v) => {
                let ty = self.emit_type_both(value.ty)?;
                let mut ll_fields = vec![];
                let mut mlir_fields = vec![];
                for field in v {
                    let field = self.emit_const(field, env, span)?;
                    ll_fields.push(field.0);
                    mlir_fields.push(field.1);
                }
                if let Some(_dim) = value.ty.outermost_dim() {
                    Ok((
                        self.builder.ins().array(ll_fields),
                        circt::hw::ArrayCreateOp::new(self.mlir_builder, ty.1, mlir_fields).into(),
                    ))
                } else if let Some(_strukt) = value.ty.get_struct() {
                    Ok((
                        self.builder.ins().strukt(ll_fields),
                        circt::hw::StructCreateOp::new(self.mlir_builder, ty.1, mlir_fields).into(),
                    ))
                } else {
                    panic!(
                        "invalid type `{}` for const struct/array value {:#?}",
                        value.ty, value
                    );
                }
            }
            ValueKind::Error => Err(()),
            _ => panic!(
                "invalid combination of type `{}` and value {:#?}",
                value.ty, value
            ),
        }
    }
/// Map a value to an LLHD constant.
Map a value to an LLHD constant.
Map a value to an LLHD constant .
fn emit_const_uninterned(
        &mut self,
        value: Value<'gcx>,
        env: ParamEnv,
        span: Span,
    ) -> Result<HybridValue> {
        if value.ty.is_error() {
            return Err(());
        }
        match value.kind {
            ValueKind::Int(ref k, ..) => {
                let size = value.ty.simple_bit_vector(self.cx, span).size;
                Ok((
                    self.builder.ins().const_int((size, k.clone())),
                    circt::hw::ConstantOp::new(self.mlir_builder, std::cmp::max(size, 1), k).into(),
                ))
            }
            ValueKind::Time(ref k) => Ok((
                self.builder
                    .ins()
                    .const_time(llhd::value::TimeValue::new(k.clone(), 0, 0)),
                circt::llhd::ConstantTimeOp::with_seconds(self.mlir_builder, k).into(),
            )),
            ValueKind::StructOrArray(ref v) => {
                let ty = self.emit_type_both(value.ty)?;
                let mut ll_fields = vec![];
                let mut mlir_fields = vec![];
                for field in v {
                    let field = self.emit_const(field, env, span)?;
                    ll_fields.push(field.0);
                    mlir_fields.push(field.1);
                }
                if let Some(_dim) = value.ty.outermost_dim() {
                    Ok((
                        self.builder.ins().array(ll_fields),
                        circt::hw::ArrayCreateOp::new(self.mlir_builder, ty.1, mlir_fields).into(),
                    ))
                } else if let Some(_strukt) = value.ty.get_struct() {
                    Ok((
                        self.builder.ins().strukt(ll_fields),
                        circt::hw::StructCreateOp::new(self.mlir_builder, ty.1, mlir_fields).into(),
                    ))
                } else {
                    panic!(
                        "invalid type `{}` for const struct/array value {:#?}",
                        value.ty, value
                    );
                }
            }
            ValueKind::Error => Err(()),
            _ => panic!(
                "invalid combination of type `{}` and value {:#?}",
                value.ty, value
            ),
        }
    }
fn emit_const_uninterned ( & mut self , value : Value < ' gcx > , env : ParamEnv , span : Span , ) -> Result < HybridValue > { if value . ty . is_error ( ) { return Err ( ( ) ) ; } match value . kind { ValueKind :: Int ( ref k , .. ) => { let size = value . ty . simple_bit_vector ( self . cx , span ) . size ; Ok ( ( self . builder . ins ( ) . const_int ( ( size , k . clone ( ) ) ) , circt :: hw :: ConstantOp :: new ( self . mlir_builder , std :: cmp :: max ( size , 1 ) , k ) . into ( ) , ) ) } ValueKind :: Time ( ref k ) => Ok ( ( self . builder . ins ( ) . const_time ( llhd :: value :: TimeValue :: new ( k . clone ( ) , 0 , 0 ) ) , circt :: llhd :: ConstantTimeOp :: with_seconds ( self . mlir_builder , k ) . into ( ) , ) ) , ValueKind :: StructOrArray ( ref v ) => { let ty = self . emit_type_both ( value . ty ) ? ; let mut ll_fields = vec ! [ ] ; let mut mlir_fields = vec ! [ ] ; for field in v { let field = self . emit_const ( field , env , span ) ? ; ll_fields . push ( field . 0 ) ; mlir_fields . push ( field . 1 ) ; } if let Some ( _dim ) = value . ty . outermost_dim ( ) { Ok ( ( self . builder . ins ( ) . array ( ll_fields ) , circt :: hw :: ArrayCreateOp :: new ( self . mlir_builder , ty . 1 , mlir_fields ) . into ( ) , ) ) } else if let Some ( _strukt ) = value . ty . get_struct ( ) { Ok ( ( self . builder . ins ( ) . strukt ( ll_fields ) , circt :: hw :: StructCreateOp :: new ( self . mlir_builder , ty . 1 , mlir_fields ) . into ( ) , ) ) } else { panic ! ( " " value ty value ) ; } } ValueKind :: Error => Err ( ( ) ) , _ => panic ! ( " " value ty value ) , } }
Map a value to an LLHD constant.
Map a value to an LLHD constant .
&mut self
value
Value<'gcx>
env
ParamEnv
span
Span
&mut self
value
Value<'gcx>
env
ParamEnv
span
Span