Compare commits

..

2 Commits

Author SHA1 Message Date
T0b1
55211229ef better vcode printing 2023-04-18 12:19:51 +02:00
T0b1
e3117a84c8 local changes 2023-04-18 12:19:51 +02:00
3 changed files with 48 additions and 15 deletions

25
Cargo.lock generated
View File

@@ -607,7 +607,7 @@ dependencies = [
"cranelift-isle", "cranelift-isle",
"criterion", "criterion",
"gimli", "gimli",
"hashbrown 0.13.1", "hashbrown 0.13.2",
"log", "log",
"regalloc2", "regalloc2",
"serde", "serde",
@@ -677,7 +677,7 @@ name = "cranelift-frontend"
version = "0.96.0" version = "0.96.0"
dependencies = [ dependencies = [
"cranelift-codegen", "cranelift-codegen",
"hashbrown 0.13.1", "hashbrown 0.13.2",
"log", "log",
"similar", "similar",
"smallvec", "smallvec",
@@ -747,7 +747,7 @@ dependencies = [
"anyhow", "anyhow",
"cranelift-codegen", "cranelift-codegen",
"cranelift-control", "cranelift-control",
"hashbrown 0.13.1", "hashbrown 0.13.2",
] ]
[[package]] [[package]]
@@ -837,7 +837,7 @@ dependencies = [
"cranelift-codegen", "cranelift-codegen",
"cranelift-entity", "cranelift-entity",
"cranelift-frontend", "cranelift-frontend",
"hashbrown 0.13.1", "hashbrown 0.13.2",
"itertools", "itertools",
"log", "log",
"serde", "serde",
@@ -1498,9 +1498,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.13.1" version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33ff8ae62cd3a9102e5637afc8452c55acf3844001bd5374e0b0bd7b6616c038" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e"
dependencies = [ dependencies = [
"ahash", "ahash",
] ]
@@ -2049,7 +2049,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439"
dependencies = [ dependencies = [
"crc32fast", "crc32fast",
"hashbrown 0.13.1", "hashbrown 0.13.2",
"indexmap", "indexmap",
"memchr", "memchr",
] ]
@@ -2578,11 +2578,10 @@ dependencies = [
[[package]] [[package]]
name = "regalloc2" name = "regalloc2"
version = "0.6.1" version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80535183cae11b149d618fbd3c37e38d7cda589d82d7769e196ca9a9042d7621"
dependencies = [ dependencies = [
"fxhash", "hashbrown 0.13.2",
"log", "log",
"rustc-hash",
"serde", "serde",
"slice-group-by", "slice-group-by",
"smallvec", "smallvec",
@@ -2674,6 +2673,12 @@ version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342"
[[package]]
name = "rustc-hash"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]] [[package]]
name = "rustix" name = "rustix"
version = "0.36.8" version = "0.36.8"

View File

@@ -771,6 +771,7 @@ impl<I: VCodeInst> VCode<I> {
{ {
// To write into disasm string. // To write into disasm string.
use core::fmt::Write; use core::fmt::Write;
let want_disasm = true;
let _tt = timing::vcode_emit(); let _tt = timing::vcode_emit();
let mut buffer = MachBuffer::new(); let mut buffer = MachBuffer::new();
@@ -934,7 +935,7 @@ impl<I: VCodeInst> VCode<I> {
// and they come out the other end, if // and they come out the other end, if
// still needed (not elided), as // still needed (not elided), as
// regalloc-inserted moves. // regalloc-inserted moves.
continue; //continue;
} }
// Update the srcloc at this point in the buffer. // Update the srcloc at this point in the buffer.
@@ -1349,12 +1350,39 @@ impl<I: VCodeInst> fmt::Debug for VCode<I> {
for block in 0..self.num_blocks() { for block in 0..self.num_blocks() {
let block = BlockIndex::new(block); let block = BlockIndex::new(block);
writeln!(f, "Block {}:", block.index())?; write!(f, "Block {}(", block.index())?;
{
let mut first = true;
for vreg in self.block_params(block) {
if !first {
write!(f, ", ")?;
} else {
first = false;
}
write!(f, "{}", vreg)?;
}
}
writeln!(f, "):")?;
if let Some(bb) = self.bindex_to_bb(block) { if let Some(bb) = self.bindex_to_bb(block) {
writeln!(f, " (original IR block: {})", bb)?; writeln!(f, " (original IR block: {})", bb)?;
} }
for succ in self.succs(block) { for (i, succ) in self.succs(block).iter().enumerate() {
writeln!(f, " (successor: Block {})", succ.index())?; let last_inst = self.block_insns(block).last();
if self.is_branch(last_inst) {
write!(f, " (successor: Block {}(", succ.index())?;
let mut first = true;
for vreg in self.branch_blockparams(block, last_inst, i) {
if !first {
write!(f, ", ")?;
} else {
first = false;
}
write!(f, "{}", vreg)?;
}
writeln!(f, "))")?;
} else {
write!(f, " (successor: Block {})", succ.index())?;
}
} }
let (start, end) = self.block_ranges[block.index()]; let (start, end) = self.block_ranges[block.index()];
writeln!( writeln!(

View File

@@ -17,7 +17,7 @@ target-lexicon = { workspace = true, features = ["std"] }
# In the next iteration we'll factor out the common bits so that they can be consumed # In the next iteration we'll factor out the common bits so that they can be consumed
# by Cranelift and Winch. # by Cranelift and Winch.
cranelift-codegen = { workspace = true } cranelift-codegen = { workspace = true }
regalloc2 = "0.6.0" regalloc2 = { path = "../../../regalloc2" }
gimli = { workspace = true } gimli = { workspace = true }
[features] [features]