pub fn emit_function<CS, EI>(func: &Function, emit_inst: EI, sink: &mut CS, isa: &dyn TargetIsa)
where
    CS: CodeSink,
    EI: Fn(&Function, Inst, &mut RegDiversions, &mut CS, &dyn TargetIsa),
{
    let mut divert = RegDiversions::new();
    for block in func.layout.blocks() {
        divert.at_block(&func.entry_diversions, block);
        debug_assert_eq!(func.offsets[block], sink.offset());
        for inst in func.layout.block_insts(block) {
            emit_inst(func, inst, &mut divert, sink, isa);
        }
    }

    sink.begin_jumptables();

    // Output jump tables.
    for (jt, jt_data) in func.jump_tables.iter() {
        let jt_offset = func.jt_offsets[jt];
        for block in jt_data.iter() {
            let rel_offset: i32 = func.offsets[*block] as i32 - jt_offset as i32;
            sink.put4(rel_offset as u32)
        }
    }

    sink.begin_rodata();

    // Output constants.
    for (_, constant_data) in func.dfg.constants.iter() {
        for byte in constant_data.iter() {
            sink.put1(*byte)
        }
    }

    sink.end_codegen();
}
/// Emit a function to `sink`, given an instruction emitter function.
///
/// This function is called from the `TargetIsa::emit_function()` implementations with the
/// appropriate instruction emitter.
Emit a function to `sink`, given an instruction emitter function.
This function is called from the `TargetIsa::emit_function()` implementations with the
appropriate instruction emitter.
Emit a function to ` sink ` given an instruction emitter function . This function is called from the ` TargetIsa :: emit_function () ` implementations with the appropriate instruction emitter .
pub fn emit_function<CS, EI>(func: &Function, emit_inst: EI, sink: &mut CS, isa: &dyn TargetIsa)
where
    CS: CodeSink,
    EI: Fn(&Function, Inst, &mut RegDiversions, &mut CS, &dyn TargetIsa),
{
    let mut divert = RegDiversions::new();
    for block in func.layout.blocks() {
        divert.at_block(&func.entry_diversions, block);
        debug_assert_eq!(func.offsets[block], sink.offset());
        for inst in func.layout.block_insts(block) {
            emit_inst(func, inst, &mut divert, sink, isa);
        }
    }
    sink.begin_jumptables();
    // Output jump tables.
    for (jt, jt_data) in func.jump_tables.iter() {
        let jt_offset = func.jt_offsets[jt];
        for block in jt_data.iter() {
            let rel_offset: i32 = func.offsets[*block] as i32 - jt_offset as i32;
            sink.put4(rel_offset as u32)
        }
    }
    sink.begin_rodata();
    // Output constants.
    for (_, constant_data) in func.dfg.constants.iter() {
        for byte in constant_data.iter() {
            sink.put1(*byte)
        }
    }
    sink.end_codegen();
}
pub fn emit_function < CS , EI > ( func : & Function , emit_inst : EI , sink : & mut CS , isa : & dyn TargetIsa ) where CS : CodeSink , EI : Fn ( & Function , Inst , & mut RegDiversions , & mut CS , & dyn TargetIsa ) , { let mut divert = RegDiversions :: new ( ) ; for block in func . layout . blocks ( ) { divert . at_block ( & func . entry_diversions , block ) ; debug_assert_eq ! ( func offsets [ block ] sink offset ( ) ) ; for inst in func . layout . block_insts ( block ) { emit_inst ( func , inst , & mut divert , sink , isa ) ; } } sink . begin_jumptables ( ) ; // Output jump tables. for ( jt , jt_data ) in func . jump_tables . iter ( ) { let jt_offset = func . jt_offsets [ jt ] ; for block in jt_data . iter ( ) { let rel_offset : i32 = func . offsets [ * block ] as i32 - jt_offset as i32 ; sink . put4 ( rel_offset as u32 ) } } sink . begin_rodata ( ) ; // Output constants. for ( _ , constant_data ) in func . dfg . constants . iter ( ) { for byte in constant_data . iter ( ) { sink . put1 ( * byte ) } } sink . end_codegen ( ) ; }
Emit a function to `sink`, given an instruction emitter function.
Emit a function to ` sink ` given an instruction emitter function .
func
&Function
emit_inst
EI
sink
&mut CS
isa
&dyn TargetIsa