- Undo temporary changes to default features (`all-arch`) and a
signal-handler test.
- Remove `SIGTRAP` handler: no longer needed now that we've found an
"undefined opcode" option on ARM64.
- Rename pp.rs to pretty_print.rs in machinst/.
- Only use empty stack-probe on non-x86. As per a comment in
rust-lang/compiler-builtins [1], LLVM only supports stack probes on
x86 and x86-64. Thus, on any other CPU architecture, we cannot refer
to `__rust_probestack`, because it does not exist.
- Rename arm64 to aarch64.
- Use `target` directive in vcode filetests.
- Run the flags verifier, but without encinfo, when using new backends.
- Clean up warning overrides.
- Fix up use of casts: use u32::from(x) and siblings when possible,
u32::try_from(x).unwrap() when not, to avoid silent truncation.
- Take immutable `Function` borrows as input; we don't actually
mutate the input IR.
- Lots of other miscellaneous cleanups.
[1] cae3e6ea23/src/probestack.rs (L39)
67 lines
2.6 KiB
Rust
67 lines
2.6 KiB
Rust
//! Pretty-printing for machine code (virtual-registerized or final).
|
|
|
|
use regalloc::{RealRegUniverse, Reg, Writable};
|
|
|
|
use std::fmt::Debug;
|
|
use std::hash::Hash;
|
|
use std::string::{String, ToString};
|
|
|
|
// FIXME: Should this go into regalloc.rs instead?
|
|
|
|
/// A trait for printing instruction bits and pieces, with the the ability to
|
|
/// take a contextualising RealRegUniverse that is used to give proper names to
|
|
/// registers.
|
|
pub trait ShowWithRRU {
|
|
/// Return a string that shows the implementing object in context of the
|
|
/// given `RealRegUniverse`, if provided.
|
|
fn show_rru(&self, mb_rru: Option<&RealRegUniverse>) -> String;
|
|
|
|
/// The same as |show_rru|, but with an optional hint giving a size in
|
|
/// bytes. Its interpretation is object-dependent, and it is intended to
|
|
/// pass around enough information to facilitate printing sub-parts of
|
|
/// real registers correctly. Objects may ignore size hints that are
|
|
/// irrelevant to them.
|
|
fn show_rru_sized(&self, mb_rru: Option<&RealRegUniverse>, _size: u8) -> String {
|
|
// Default implementation is to ignore the hint.
|
|
self.show_rru(mb_rru)
|
|
}
|
|
}
|
|
|
|
impl ShowWithRRU for Reg {
|
|
fn show_rru(&self, mb_rru: Option<&RealRegUniverse>) -> String {
|
|
if self.is_real() {
|
|
if let Some(rru) = mb_rru {
|
|
let reg_ix = self.get_index();
|
|
if reg_ix < rru.regs.len() {
|
|
return rru.regs[reg_ix].1.to_string();
|
|
} else {
|
|
// We have a real reg which isn't listed in the universe.
|
|
// Per the regalloc.rs interface requirements, this is
|
|
// Totally Not Allowed. Print it generically anyway, so
|
|
// we have something to debug.
|
|
return format!("!!{:?}!!", self);
|
|
}
|
|
}
|
|
}
|
|
// The reg is virtual, or we have no universe. Be generic.
|
|
format!("%{:?}", self)
|
|
}
|
|
|
|
fn show_rru_sized(&self, _mb_rru: Option<&RealRegUniverse>, _size: u8) -> String {
|
|
// For the specific case of Reg, we demand not to have a size hint,
|
|
// since interpretation of the size is target specific, but this code
|
|
// is used by all targets.
|
|
panic!("Reg::show_rru_sized: impossible to implement");
|
|
}
|
|
}
|
|
|
|
impl<R: ShowWithRRU + Copy + Ord + Hash + Eq + Debug> ShowWithRRU for Writable<R> {
|
|
fn show_rru(&self, mb_rru: Option<&RealRegUniverse>) -> String {
|
|
self.to_reg().show_rru(mb_rru)
|
|
}
|
|
|
|
fn show_rru_sized(&self, mb_rru: Option<&RealRegUniverse>, size: u8) -> String {
|
|
self.to_reg().show_rru_sized(mb_rru, size)
|
|
}
|
|
}
|