Struct cranelift_codegen::ir::ValueLabel
source · pub struct ValueLabel(_);Expand description
Marked with a label value.
Implementations§
source§impl ValueLabel
impl ValueLabel
sourcepub fn from_u32(x: u32) -> Self
pub fn from_u32(x: u32) -> Self
Create a new instance from a u32.
Examples found in repository?
src/machinst/vcode.rs (line 1112)
1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163
fn compute_value_labels_ranges(
&self,
regalloc: ®alloc2::Output,
inst_offsets: &[CodeOffset],
func_body_len: u32,
) -> ValueLabelsRanges {
if self.debug_value_labels.is_empty() {
return ValueLabelsRanges::default();
}
let mut value_labels_ranges: ValueLabelsRanges = HashMap::new();
for &(label, from, to, alloc) in ®alloc.debug_locations {
let ranges = value_labels_ranges
.entry(ValueLabel::from_u32(label))
.or_insert_with(|| vec![]);
let from_offset = inst_offsets[from.inst().index()];
let to_offset = if to.inst().index() == inst_offsets.len() {
func_body_len
} else {
inst_offsets[to.inst().index()]
};
// Empty range or to-offset of zero can happen because of
// cold blocks (see above).
if to_offset == 0 || from_offset == to_offset {
continue;
}
let loc = if let Some(preg) = alloc.as_reg() {
LabelValueLoc::Reg(Reg::from(preg))
} else {
// We can't translate spillslot locations at the
// moment because ValueLabelLoc requires an
// instantaneous SP offset, and this can *change*
// within the range we have here because of callsites
// adjusting SP temporarily. To avoid the complexity
// of accurately plumbing through nominal-SP
// adjustment sites, we just omit debug info for
// values that are spilled. Not ideal, but debug info
// is best-effort.
continue;
};
ranges.push(ValueLocRange {
loc,
// ValueLocRanges are recorded by *instruction-end
// offset*. `from_offset` is the *start* of the
// instruction; that is the same as the end of another
// instruction, so we only want to begin coverage once
// we are past the previous instruction's end.
start: from_offset + 1,
// Likewise, `end` is exclusive, but we want to
// *include* the end of the last
// instruction. `to_offset` is the start of the
// `to`-instruction, which is the exclusive end, i.e.,
// the first instruction not covered. That
// instruction's start is the same as the end of the
// last instruction that is included, so we go one
// byte further to be sure to include it.
end: to_offset + 1,
});
}
value_labels_ranges
}sourcepub fn as_u32(self) -> u32
pub fn as_u32(self) -> u32
Return the underlying index value as a u32.
Examples found in repository?
src/machinst/vcode.rs (line 533)
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542
fn reverse_and_finalize(&mut self) {
let n_insts = self.vcode.insts.len();
if n_insts == 0 {
return;
}
// Reverse the per-block and per-inst sequences.
self.vcode.block_ranges.reverse();
// block_params_range is indexed by block (and blocks were
// traversed in reverse) so we reverse it; but block-param
// sequences in the concatenated vec can remain in reverse
// order (it is effectively an arena of arbitrarily-placed
// referenced sequences).
self.vcode.block_params_range.reverse();
// Likewise, we reverse block_succ_range, but the block_succ
// concatenated array can remain as-is.
self.vcode.block_succ_range.reverse();
self.vcode.insts.reverse();
self.vcode.srclocs.reverse();
// Likewise, branch_block_arg_succ_range is indexed by block
// so must be reversed.
self.vcode.branch_block_arg_succ_range.reverse();
// To translate an instruction index *endpoint* in reversed
// order to forward order, compute `n_insts - i`.
//
// Why not `n_insts - 1 - i`? That would be correct to
// translate an individual instruction index (for ten insts 0
// to 9 inclusive, inst 0 becomes 9, and inst 9 becomes
// 0). But for the usual inclusive-start, exclusive-end range
// idiom, inclusive starts become exclusive ends and
// vice-versa, so e.g. an (inclusive) start of 0 becomes an
// (exclusive) end of 10.
let translate = |inst: InsnIndex| InsnIndex::new(n_insts - inst.index());
// Edit the block-range instruction indices.
for tuple in &mut self.vcode.block_ranges {
let (start, end) = *tuple;
*tuple = (translate(end), translate(start)); // Note reversed order.
}
// Generate debug-value labels based on per-label maps.
for (label, tuples) in &self.debug_info {
for &(start, end, vreg) in tuples {
let vreg = self.resolve_vreg_alias(vreg);
let fwd_start = translate(end);
let fwd_end = translate(start);
self.vcode
.debug_value_labels
.push((vreg, fwd_start, fwd_end, label.as_u32()));
}
}
// Now sort debug value labels by VReg, as required
// by regalloc2.
self.vcode
.debug_value_labels
.sort_unstable_by_key(|(vreg, _, _, _)| *vreg);
}Trait Implementations§
source§impl Clone for ValueLabel
impl Clone for ValueLabel
source§fn clone(&self) -> ValueLabel
fn clone(&self) -> ValueLabel
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 ValueLabel
impl Debug for ValueLabel
source§impl Display for ValueLabel
impl Display for ValueLabel
source§impl EntityRef for ValueLabel
impl EntityRef for ValueLabel
source§impl Hash for ValueLabel
impl Hash for ValueLabel
source§impl PartialEq<ValueLabel> for ValueLabel
impl PartialEq<ValueLabel> for ValueLabel
source§fn eq(&self, other: &ValueLabel) -> bool
fn eq(&self, other: &ValueLabel) -> bool
This method tests for
self and other values to be equal, and is used
by ==.source§impl ReservedValue for ValueLabel
impl ReservedValue for ValueLabel
source§fn reserved_value() -> ValueLabel
fn reserved_value() -> ValueLabel
Create an instance of the reserved value.
source§fn is_reserved_value(&self) -> bool
fn is_reserved_value(&self) -> bool
Checks whether value is the reserved one.
impl Copy for ValueLabel
impl Eq for ValueLabel
impl StructuralEq for ValueLabel
impl StructuralPartialEq for ValueLabel
Auto Trait Implementations§
impl RefUnwindSafe for ValueLabel
impl Send for ValueLabel
impl Sync for ValueLabel
impl Unpin for ValueLabel
impl UnwindSafe for ValueLabel
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.