Review feedback.
This commit is contained in:
@@ -265,13 +265,14 @@ pub struct SetBitsIter(u64);
|
||||
impl Iterator for SetBitsIter {
|
||||
type Item = usize;
|
||||
fn next(&mut self) -> Option<usize> {
|
||||
if self.0 == 0 {
|
||||
None
|
||||
} else {
|
||||
let bitidx = self.0.trailing_zeros();
|
||||
self.0 &= !(1 << bitidx);
|
||||
Some(bitidx as usize)
|
||||
}
|
||||
// Build an `Option<NonZeroU64>` so that on the nonzero path,
|
||||
// the compiler can optimize the trailing-zeroes operator
|
||||
// using that knowledge.
|
||||
std::num::NonZeroU64::new(self.0).map(|nz| {
|
||||
let bitidx = nz.trailing_zeros();
|
||||
self.0 &= self.0 - 1; // clear highest set bit
|
||||
bitidx as usize
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ impl<'a, F: Function> Env<'a, F> {
|
||||
self.compute_liveness()?;
|
||||
self.merge_vreg_bundles();
|
||||
self.queue_bundles();
|
||||
if log::log_enabled!(log::Level::Debug) {
|
||||
if log::log_enabled!(log::Level::Trace) {
|
||||
self.dump_state();
|
||||
}
|
||||
Ok(())
|
||||
|
||||
@@ -411,9 +411,9 @@ impl<'a, F: Function> Env<'a, F> {
|
||||
from_block.index(),
|
||||
alloc,
|
||||
);
|
||||
#[cfg(debug)]
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
if log::log_enabled!(log::Level::Debug) {
|
||||
if log::log_enabled!(log::Level::Trace) {
|
||||
self.annotate(
|
||||
self.cfginfo.block_entry[block.index()],
|
||||
format!(
|
||||
@@ -772,9 +772,9 @@ impl<'a, F: Function> Env<'a, F> {
|
||||
input_alloc
|
||||
);
|
||||
if input_alloc != output_alloc {
|
||||
#[cfg(debug)]
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
if log::log_enabled!(log::Level::Debug) {
|
||||
if log::log_enabled!(log::Level::Trace) {
|
||||
self.annotate(
|
||||
ProgPoint::before(inst),
|
||||
format!(
|
||||
|
||||
14
src/lib.rs
14
src/lib.rs
@@ -47,15 +47,16 @@ impl PReg {
|
||||
|
||||
/// Create a new PReg. The `hw_enc` range is 6 bits.
|
||||
#[inline(always)]
|
||||
pub fn new(hw_enc: usize, class: RegClass) -> Self {
|
||||
assert!(hw_enc <= Self::MAX);
|
||||
pub const fn new(hw_enc: usize, class: RegClass) -> Self {
|
||||
PReg(hw_enc as u8, class)
|
||||
}
|
||||
|
||||
/// The physical register number, as encoded by the ISA for the particular register class.
|
||||
#[inline(always)]
|
||||
pub fn hw_enc(self) -> usize {
|
||||
self.0 as usize
|
||||
let hw_enc = self.0 as usize;
|
||||
debug_assert!(hw_enc <= Self::MAX);
|
||||
hw_enc
|
||||
}
|
||||
|
||||
/// The register class.
|
||||
@@ -121,14 +122,15 @@ impl VReg {
|
||||
pub const MAX: usize = (1 << Self::MAX_BITS) - 1;
|
||||
|
||||
#[inline(always)]
|
||||
pub fn new(virt_reg: usize, class: RegClass) -> Self {
|
||||
assert!(virt_reg <= Self::MAX);
|
||||
pub const fn new(virt_reg: usize, class: RegClass) -> Self {
|
||||
VReg(((virt_reg as u32) << 1) | (class as u8 as u32))
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn vreg(self) -> usize {
|
||||
(self.0 >> 1) as usize
|
||||
let vreg = (self.0 >> 1) as usize;
|
||||
debug_assert!(vreg <= Self::MAX);
|
||||
vreg
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
||||
Reference in New Issue
Block a user