fixing hbbytecode having the std mentioned

This commit is contained in:
mlokr 2024-09-21 08:19:27 +02:00
parent 6057e88034
commit 0e9f4402cb
No known key found for this signature in database
GPG key ID: DEA147DDEE644993
5 changed files with 31 additions and 5 deletions

1
Cargo.lock generated
View file

@ -173,7 +173,6 @@ version = "0.10.2"
source = "git+https://github.com/jakubDoka/regalloc2#52b2bbe908e78af1715de88f562f62a83e36ca96"
dependencies = [
"hashbrown",
"log",
"rustc-hash",
"smallvec",
]

View file

@ -35,7 +35,7 @@ impl TryFrom<u8> for Instr {
}
if value < NAMES.len() as u8 {
unsafe { Ok(std::mem::transmute::<u8, Instr>(value)) }
unsafe { Ok(core::mem::transmute::<u8, Instr>(value)) }
} else {
failed(value)
}
@ -50,8 +50,9 @@ unsafe fn encode<T>(instr: T) -> (usize, [u8; instrs::MAX_SIZE]) {
}
#[inline]
#[cfg(feature = "disasm")]
fn decode<T>(binary: &mut &[u8]) -> Option<T> {
let (front, rest) = std::mem::take(binary).split_at_checked(core::mem::size_of::<T>())?;
let (front, rest) = core::mem::take(binary).split_at_checked(core::mem::size_of::<T>())?;
*binary = rest;
unsafe { Some(core::ptr::read(front.as_ptr() as *const T)) }
}

View file

@ -10,7 +10,7 @@ path = "src/main.rs"
[dependencies]
hbbytecode = { version = "0.1.0", path = "../hbbytecode" }
hbvm = { path = "../hbvm", features = ["nightly"] }
regalloc2 = { git = "https://github.com/jakubDoka/regalloc2", features = ["trace-log"] }
regalloc2 = { git = "https://github.com/jakubDoka/regalloc2", features = [] }
[dev-dependencies]
env_logger = "0.11.5"

View file

@ -504,6 +504,14 @@ main := fn(): int {
if y == width break
}
}
width += 1
loop {
if width < y break
y += 1
}
return i
}
```

View file

@ -1818,7 +1818,25 @@ impl Codegen {
std::mem::swap(&mut env.preferred_regs_by_class, &mut env.non_preferred_regs_by_class);
};
let options = regalloc2::RegallocOptions { verbose_log: false, validate_ssa: true };
let output = regalloc2::run(&func, &env, &options).unwrap_or_else(|err| panic!("{err}"));
let iters = std::time::SystemTime::now()
.duration_since(std::time::SystemTime::UNIX_EPOCH)
.unwrap()
.as_nanos() as u32
% 300
+ 300;
let mut output =
regalloc2::run(&func, &env, &options).unwrap_or_else(|err| panic!("{err}"));
let now = std::time::Instant::now();
for i in 0..iters {
output = regalloc2::run(&func, &env, &options).unwrap_or_else(|err| panic!("{err}"));
if (iters + i) % 2 == 0 {
std::mem::swap(
&mut env.preferred_regs_by_class,
&mut env.non_preferred_regs_by_class,
);
}
}
eprintln!("took: {:?}", now.elapsed().checked_div(iters).unwrap());
let mut saved_regs = HashMap::<u8, u8>::default();
let mut atr = |allc: regalloc2::Allocation| {