Sha256: 683c1b26deef13922f46a30c1edaccfd38856fca7625979112ef8920180bf36f

Contents?: true

Size: 1.77 KB

Versions: 12

Compression:

Stored size: 1.77 KB

Contents

use crate::ir::{SourceLoc, ValueLabel};
use crate::machinst::Reg;
use crate::HashMap;
use alloc::vec::Vec;
use core::cmp::Ordering;
use core::convert::From;
use core::ops::Deref;

#[cfg(feature = "enable-serde")]
use serde::{Deserialize, Serialize};

/// Value location range.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
pub struct ValueLocRange {
    /// The ValueLoc containing a ValueLabel during this range.
    pub loc: LabelValueLoc,
    /// The start of the range. It is an offset in the generated code.
    pub start: u32,
    /// The end of the range. It is an offset in the generated code.
    pub end: u32,
}

/// The particular location for a value.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
pub enum LabelValueLoc {
    /// New-backend Reg.
    Reg(Reg),
    /// New-backend offset from stack pointer.
    SPOffset(i64),
}

/// Resulting map of Value labels and their ranges/locations.
pub type ValueLabelsRanges = HashMap<ValueLabel, Vec<ValueLocRange>>;

#[derive(Eq, Clone, Copy)]
pub struct ComparableSourceLoc(SourceLoc);

impl From<SourceLoc> for ComparableSourceLoc {
    fn from(s: SourceLoc) -> Self {
        Self(s)
    }
}

impl Deref for ComparableSourceLoc {
    type Target = SourceLoc;
    fn deref(&self) -> &SourceLoc {
        &self.0
    }
}

impl PartialOrd for ComparableSourceLoc {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}

impl Ord for ComparableSourceLoc {
    fn cmp(&self, other: &Self) -> Ordering {
        self.0.bits().cmp(&other.0.bits())
    }
}

impl PartialEq for ComparableSourceLoc {
    fn eq(&self, other: &Self) -> bool {
        self.0 == other.0
    }
}

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
wasmtime-11.0.0 ./ext/cargo-vendor/cranelift-codegen-0.98.1/src/value_label.rs
wasmtime-10.0.1 ./ext/cargo-vendor/cranelift-codegen-0.97.1/src/value_label.rs
wasmtime-10.0.0 ./ext/cargo-vendor/cranelift-codegen-0.97.1/src/value_label.rs
wasmtime-9.0.4 ./ext/cargo-vendor/cranelift-codegen-0.96.4/src/value_label.rs
wasmtime-9.0.1 ./ext/cargo-vendor/cranelift-codegen-0.96.1/src/value_label.rs
wasmtime-8.0.0 ./ext/cargo-vendor/cranelift-codegen-0.95.0/src/value_label.rs
wasmtime-7.0.0 ./ext/cargo-vendor/cranelift-codegen-0.94.0/src/value_label.rs
wasmtime-6.0.1 ./ext/cargo-vendor/cranelift-codegen-0.93.1/src/value_label.rs
wasmtime-6.0.0 ./ext/cargo-vendor/cranelift-codegen-0.93.0/src/value_label.rs
wasmtime-5.0.0 ./ext/cargo-vendor/cranelift-codegen-0.92.0/src/value_label.rs
wasmtime-0.4.1 ./ext/cargo-vendor/cranelift-codegen-0.91.0/src/value_label.rs
wasmtime-0.4.0 ./ext/cargo-vendor/cranelift-codegen-0.91.0/src/value_label.rs