Use capstone to validate precise-output tests (#5780)
Use the capstone library to disassemble precise-output tests, in addition to pretty-printing their vcode.
This commit is contained in:
@@ -91,7 +91,7 @@ impl TargetIsa for Riscv64Backend {
|
||||
Ok(CompiledCodeStencil {
|
||||
buffer,
|
||||
frame_size,
|
||||
disasm: emit_result.disasm,
|
||||
vcode: emit_result.disasm,
|
||||
value_labels_ranges,
|
||||
sized_stackslot_offsets,
|
||||
dynamic_stackslot_offsets,
|
||||
@@ -169,6 +169,20 @@ impl TargetIsa for Riscv64Backend {
|
||||
fn function_alignment(&self) -> u32 {
|
||||
4
|
||||
}
|
||||
|
||||
#[cfg(feature = "disas")]
|
||||
fn to_capstone(&self) -> Result<capstone::Capstone, capstone::Error> {
|
||||
use capstone::prelude::*;
|
||||
let mut cs = Capstone::new()
|
||||
.riscv()
|
||||
.mode(arch::riscv::ArchMode::RiscV64)
|
||||
.build()?;
|
||||
// Similar to AArch64, RISC-V uses inline constants rather than a separate
|
||||
// constant pool. We want to skip dissasembly over inline constants instead
|
||||
// of stopping on invalid bytes.
|
||||
cs.set_skipdata(true)?;
|
||||
Ok(cs)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Riscv64Backend {
|
||||
|
||||
Reference in New Issue
Block a user