/// Emit the code for an MIR rvalue.
Emit the code for an MIR rvalue.
Emit the code for an MIR rvalue .
fn emit_mir_rvalue_mode(
        &mut self,
        mir: &'gcx mir::Rvalue<'gcx>,
        mode: Mode,
    ) -> Result<HybridValue> {
        let (value, actual_mode) = if let Some(x) = self.interned_rvalues.get(&(mir.id, mode)) {
            x.clone()?
        } else {
            let x = self.emit_mir_rvalue_uninterned(mir, mode);
            self.interned_rvalues.insert((mir.id, mode), x);
            x?
        };
        match (mode, actual_mode) {
            (Mode::Signal, Mode::Value) => {
                let ty = self.value_type(value);
                let init = self.emit_zero_for_type_both(ty);
                let sig = (
                    self.builder.ins().sig(init.0),
                    circt::llhd::SignalOp::new(
                        self.mlir_builder,
                        &self.unique_names.add_tmp(),
                        init.1,
                    )
                    .into(),
                );
                let delay = self.mk_const_time(&num::zero(), 1, 0);
                self.mk_drv(sig, value, delay);
                Ok(sig)
            }
            (Mode::Value, Mode::Signal) => unreachable!(),
            _ => Ok(value),
        }
    }
fn emit_mir_rvalue_mode ( & mut self , mir : & ' gcx mir :: Rvalue < ' gcx > , mode : Mode , ) -> Result < HybridValue > { let ( value , actual_mode ) = if let Some ( x ) = self . interned_rvalues . get ( & ( mir . id , mode ) ) { x . clone ( ) ? } else { let x = self . emit_mir_rvalue_uninterned ( mir , mode ) ; self . interned_rvalues . insert ( ( mir . id , mode ) , x ) ; x ? } ; match ( mode , actual_mode ) { ( Mode :: Signal , Mode :: Value ) => { let ty = self . value_type ( value ) ; let init = self . emit_zero_for_type_both ( ty ) ; let sig = ( self . builder . ins ( ) . sig ( init . 0 ) , circt :: llhd :: SignalOp :: new ( self . mlir_builder , & self . unique_names . add_tmp ( ) , init . 1 , ) . into ( ) , ) ; let delay = self . mk_const_time ( & num :: zero ( ) , 1 , 0 ) ; self . mk_drv ( sig , value , delay ) ; Ok ( sig ) } ( Mode :: Value , Mode :: Signal ) => unreachable ! ( ) , _ => Ok ( value ) , } }
Emit the code for an MIR rvalue.
Emit the code for an MIR rvalue .
&mut self
mir
&'gcx mir::Rvalue<'gcx>
mode
Mode