Skip to content

Commit

Permalink
Cranelift: include return values in instruction pretty print output. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
KarelPeeters authored Jan 3, 2023
1 parent e3c7bf6 commit 320d67f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 6 deletions.
11 changes: 10 additions & 1 deletion cranelift/codegen/src/isa/aarch64/inst/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2657,7 +2657,16 @@ impl Inst {
}
s
}
&Inst::Ret { .. } => "ret".to_string(),
&Inst::Ret { ref rets } => {
let mut s = "ret".to_string();
for ret in rets {
use std::fmt::Write;
let preg = pretty_print_reg(ret.preg, &mut empty_allocs);
let vreg = pretty_print_reg(ret.vreg, allocs);
write!(&mut s, " {}={}", vreg, preg).unwrap();
}
s
}
&Inst::AuthenticatedRet { key, is_hint, .. } => {
let key = match key {
APIKey::A => "a",
Expand Down
12 changes: 10 additions & 2 deletions cranelift/codegen/src/isa/riscv64/inst/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1406,8 +1406,16 @@ impl Inst {
}
s
}
&Inst::Ret { .. } => {
format!("ret")
&Inst::Ret { ref rets } => {
let mut s = "ret".to_string();
let mut empty_allocs = AllocationConsumer::default();
for ret in rets {
use std::fmt::Write;
let preg = format_reg(ret.preg, &mut empty_allocs);
let vreg = format_reg(ret.vreg, allocs);
write!(&mut s, " {}={}", vreg, preg).unwrap();
}
s
}

&MInst::Extend {
Expand Down
11 changes: 9 additions & 2 deletions cranelift/codegen/src/isa/s390x/inst/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3145,9 +3145,16 @@ impl Inst {
}
s
}
&Inst::Ret { link, .. } => {
&Inst::Ret { link, ref rets } => {
debug_assert_eq!(link, gpr(14));
format!("br {}", show_reg(link))
let mut s = format!("br {}", show_reg(link));
for ret in rets {
use std::fmt::Write;
let preg = pretty_print_reg(ret.preg, &mut empty_allocs);
let vreg = pretty_print_reg(ret.vreg, allocs);
write!(&mut s, " {}={}", vreg, preg).unwrap();
}
s
}
&Inst::Jump { dest } => {
let dest = dest.to_string();
Expand Down
11 changes: 10 additions & 1 deletion cranelift/codegen/src/isa/x64/inst/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1537,7 +1537,16 @@ impl PrettyPrint for Inst {
s
}

Inst::Ret { .. } => "ret".to_string(),
Inst::Ret { rets } => {
let mut s = "ret".to_string();
for ret in rets {
use std::fmt::Write;
let preg = regs::show_reg(ret.preg);
let vreg = pretty_print_reg(ret.vreg, 8, allocs);
write!(&mut s, " {}={}", vreg, preg).unwrap();
}
s
}

Inst::JmpKnown { dst } => {
format!("{} {}", ljustify("jmp".to_string()), dst.to_string())
Expand Down

0 comments on commit 320d67f

Please sign in to comment.