change smir to StableMir
This commit is contained in:
parent
c821603484
commit
3883645a9b
3 changed files with 35 additions and 23 deletions
|
@ -326,7 +326,7 @@ pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) {
|
||||||
write_mir_graphviz(ex.tcx(), None, &mut out).unwrap();
|
write_mir_graphviz(ex.tcx(), None, &mut out).unwrap();
|
||||||
String::from_utf8(out).unwrap()
|
String::from_utf8(out).unwrap()
|
||||||
}
|
}
|
||||||
Smir => {
|
StableMir => {
|
||||||
let mut out = Vec::new();
|
let mut out = Vec::new();
|
||||||
write_smir_pretty(ex.tcx(), &mut out).unwrap();
|
write_smir_pretty(ex.tcx(), &mut out).unwrap();
|
||||||
String::from_utf8(out).unwrap()
|
String::from_utf8(out).unwrap()
|
||||||
|
|
|
@ -2926,13 +2926,13 @@ fn parse_pretty(handler: &EarlyErrorHandler, unstable_opts: &UnstableOptions) ->
|
||||||
"thir-tree" => ThirTree,
|
"thir-tree" => ThirTree,
|
||||||
"thir-flat" => ThirFlat,
|
"thir-flat" => ThirFlat,
|
||||||
"mir" => Mir,
|
"mir" => Mir,
|
||||||
"smir" => Smir,
|
"stable-mir" => StableMir,
|
||||||
"mir-cfg" => MirCFG,
|
"mir-cfg" => MirCFG,
|
||||||
name => handler.early_error(format!(
|
name => handler.early_error(format!(
|
||||||
"argument to `unpretty` must be one of `normal`, `identified`, \
|
"argument to `unpretty` must be one of `normal`, `identified`, \
|
||||||
`expanded`, `expanded,identified`, `expanded,hygiene`, \
|
`expanded`, `expanded,identified`, `expanded,hygiene`, \
|
||||||
`ast-tree`, `ast-tree,expanded`, `hir`, `hir,identified`, \
|
`ast-tree`, `ast-tree,expanded`, `hir`, `hir,identified`, \
|
||||||
`hir,typed`, `hir-tree`, `thir-tree`, `thir-flat`, `mir` or \
|
`hir,typed`, `hir-tree`, `thir-tree`, `thir-flat`, `mir`, `stable-mir`, or \
|
||||||
`mir-cfg`; got {name}"
|
`mir-cfg`; got {name}"
|
||||||
)),
|
)),
|
||||||
};
|
};
|
||||||
|
@ -3107,8 +3107,8 @@ pub enum PpMode {
|
||||||
Mir,
|
Mir,
|
||||||
/// `-Zunpretty=mir-cfg`
|
/// `-Zunpretty=mir-cfg`
|
||||||
MirCFG,
|
MirCFG,
|
||||||
/// `-Zunpretty=smir`
|
/// `-Zunpretty=stable-mir`
|
||||||
Smir,
|
StableMir,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PpMode {
|
impl PpMode {
|
||||||
|
@ -3126,7 +3126,7 @@ impl PpMode {
|
||||||
| ThirFlat
|
| ThirFlat
|
||||||
| Mir
|
| Mir
|
||||||
| MirCFG
|
| MirCFG
|
||||||
| Smir => true,
|
| StableMir => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn needs_hir(&self) -> bool {
|
pub fn needs_hir(&self) -> bool {
|
||||||
|
@ -3134,13 +3134,13 @@ impl PpMode {
|
||||||
match *self {
|
match *self {
|
||||||
Source(_) | AstTree | AstTreeExpanded => false,
|
Source(_) | AstTree | AstTreeExpanded => false,
|
||||||
|
|
||||||
Hir(_) | HirTree | ThirTree | ThirFlat | Mir | MirCFG | Smir => true,
|
Hir(_) | HirTree | ThirTree | ThirFlat | Mir | MirCFG | StableMir => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn needs_analysis(&self) -> bool {
|
pub fn needs_analysis(&self) -> bool {
|
||||||
use PpMode::*;
|
use PpMode::*;
|
||||||
matches!(*self, Hir(PpHirMode::Typed) | Mir | Smir | MirCFG | ThirTree | ThirFlat)
|
matches!(*self, Hir(PpHirMode::Typed) | Mir | StableMir | MirCFG | ThirTree | ThirFlat)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,22 +15,34 @@ pub fn write_smir_pretty<'tcx>(tcx: TyCtxt<'tcx>, w: &mut dyn io::Write) -> io::
|
||||||
|
|
||||||
run(tcx, || {
|
run(tcx, || {
|
||||||
let items = stable_mir::all_local_items();
|
let items = stable_mir::all_local_items();
|
||||||
let _ = items.iter().map(|item| -> io::Result<()> {
|
let _ = items
|
||||||
// Because we can't return a Result from a closure, we have to unwrap here.
|
.iter()
|
||||||
writeln!(w, "{}", function_name(*item, tcx))?;
|
.map(|item| -> io::Result<()> {
|
||||||
writeln!(w, "{}", function_body(*item, tcx))?;
|
// Because we can't return a Result from a closure, we have to unwrap here.
|
||||||
let _ = item.body().blocks.iter().enumerate().map(|(index, block)| -> io::Result<()> {
|
writeln!(w, "{}", function_name(*item, tcx))?;
|
||||||
writeln!(w, " bb{}: {{", index)?;
|
writeln!(w, "{}", function_body(*item, tcx))?;
|
||||||
let _ = block.statements.iter().map(|statement| -> io::Result<()> {
|
let _ = item
|
||||||
writeln!(w, "{}", pretty_statement(&statement.kind, tcx))?;
|
.body()
|
||||||
Ok(())
|
.blocks
|
||||||
}).collect::<Vec<_>>();
|
.iter()
|
||||||
writeln!(w, " }}").unwrap();
|
.enumerate()
|
||||||
|
.map(|(index, block)| -> io::Result<()> {
|
||||||
|
writeln!(w, " bb{}: {{", index)?;
|
||||||
|
let _ = block
|
||||||
|
.statements
|
||||||
|
.iter()
|
||||||
|
.map(|statement| -> io::Result<()> {
|
||||||
|
writeln!(w, "{}", pretty_statement(&statement.kind, tcx))?;
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
writeln!(w, " }}").unwrap();
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>();
|
||||||
Ok(())
|
Ok(())
|
||||||
}).collect::<Vec<_>>();
|
})
|
||||||
Ok(())
|
.collect::<Vec<_>>();
|
||||||
}).collect::<Vec<_>>();
|
|
||||||
|
|
||||||
});
|
});
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue