How do I access mir?

I want to try to translate mir -> spirv but I have a few problems accessing mir. I currently have a toy compiler that translates hir -> spirv and hir is very easy to access.

But where is the entry point for mir?

My first though was to create a PassHook

But I have no idea where the execute the passes. My next idea was to build my own version of phase_3_run_analysis_passes but too many things are private.

My next idea was to build mir manually but the build module is private.

I am currently reading though miri to find out how it accesses the mir.

Maybe I am just misunderstanding how mir looks like. I thought it would be similar to hir.

It seems that I access the mir when I visit the hir like this for example:

    let def_id = self.map.local_def_id(id);
    let mir_fn = self.ty_ctx.maybe_optimized_mir(def_id);
    println!("mir_fn = {:#?}", mir_fn);

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.