Struct cranelift_codegen::ir::RelSourceLoc
source · pub struct RelSourceLoc(_);
Expand description
Source location relative to another base source location.
Implementations§
source§impl RelSourceLoc
impl RelSourceLoc
sourcepub fn from_base_offset(base: SourceLoc, offset: SourceLoc) -> Self
pub fn from_base_offset(base: SourceLoc, offset: SourceLoc) -> Self
Creates a new RelSourceLoc
based on the given base and offset.
Panics
Panics if the offset is smaller than the base.
Examples found in repository?
More examples
src/legalizer/heap.rs (line 401)
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408
fn cast_index_to_pointer_ty(
index: ir::Value,
index_ty: ir::Type,
pointer_ty: ir::Type,
pos: &mut FuncCursor,
) -> ir::Value {
if index_ty == pointer_ty {
return index;
}
// Note that using 64-bit heaps on a 32-bit host is not currently supported,
// would require at least a bounds check here to ensure that the truncation
// from 64-to-32 bits doesn't lose any upper bits. For now though we're
// mostly interested in the 32-bit-heaps-on-64-bit-hosts cast.
assert!(index_ty.bits() < pointer_ty.bits());
// Convert `index` to `addr_ty`.
let extended_index = pos.ins().uextend(pointer_ty, index);
// Add debug value-label alias so that debuginfo can name the extended
// value as the address
let loc = pos.srcloc();
let loc = RelSourceLoc::from_base_offset(pos.func.params.base_srcloc(), loc);
pos.func
.stencil
.dfg
.add_value_label_alias(extended_index, loc, index);
extended_index
}
sourcepub fn expand(&self, base: SourceLoc) -> SourceLoc
pub fn expand(&self, base: SourceLoc) -> SourceLoc
Expands the relative source location into an absolute one, using the given base.
Examples found in repository?
More examples
sourcepub fn is_default(self) -> bool
pub fn is_default(self) -> bool
Is this the default relative source location?
Examples found in repository?
src/ir/sourceloc.rs (line 80)
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
pub fn expand(&self, base: SourceLoc) -> SourceLoc {
if self.is_default() || base.is_default() {
Default::default()
} else {
SourceLoc::new(self.0.wrapping_add(base.bits()))
}
}
/// Is this the default relative source location?
pub fn is_default(self) -> bool {
self == Default::default()
}
}
impl Default for RelSourceLoc {
fn default() -> Self {
Self(!0)
}
}
impl fmt::Display for RelSourceLoc {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if self.is_default() {
write!(f, "@-")
} else {
write!(f, "@+{:04x}", self.0)
}
}
Trait Implementations§
source§impl Clone for RelSourceLoc
impl Clone for RelSourceLoc
source§fn clone(&self) -> RelSourceLoc
fn clone(&self) -> RelSourceLoc
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for RelSourceLoc
impl Debug for RelSourceLoc
source§impl Default for RelSourceLoc
impl Default for RelSourceLoc
source§impl Display for RelSourceLoc
impl Display for RelSourceLoc
source§impl Hash for RelSourceLoc
impl Hash for RelSourceLoc
source§impl PartialEq<RelSourceLoc> for RelSourceLoc
impl PartialEq<RelSourceLoc> for RelSourceLoc
source§fn eq(&self, other: &RelSourceLoc) -> bool
fn eq(&self, other: &RelSourceLoc) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Copy for RelSourceLoc
impl Eq for RelSourceLoc
impl StructuralEq for RelSourceLoc
impl StructuralPartialEq for RelSourceLoc
Auto Trait Implementations§
impl RefUnwindSafe for RelSourceLoc
impl Send for RelSourceLoc
impl Sync for RelSourceLoc
impl Unpin for RelSourceLoc
impl UnwindSafe for RelSourceLoc
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.