mirror of https://github.com/encounter/objdiff.git
Highlight: Consider reg offsets and signed immediates equivalent
Fixes #32
This commit is contained in:
parent
74e89130a8
commit
0ec7bf078b
|
@ -50,6 +50,30 @@ pub enum ObjInsArg {
|
|||
BranchOffset(i32),
|
||||
}
|
||||
|
||||
impl ObjInsArg {
|
||||
pub fn loose_eq(&self, other: &ObjInsArg) -> bool {
|
||||
match (self, other) {
|
||||
(ObjInsArg::PpcArg(a), ObjInsArg::PpcArg(b)) => {
|
||||
a == b
|
||||
|| match (a, b) {
|
||||
// Consider Simm and Offset equivalent
|
||||
(ppc750cl::Argument::Simm(simm), ppc750cl::Argument::Offset(off))
|
||||
| (ppc750cl::Argument::Offset(off), ppc750cl::Argument::Simm(simm)) => {
|
||||
simm.0 == off.0
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
(ObjInsArg::MipsArg(a), ObjInsArg::MipsArg(b)) => a == b,
|
||||
(ObjInsArg::MipsArgWithBase(a), ObjInsArg::MipsArgWithBase(b)) => a == b,
|
||||
(ObjInsArg::Reloc, ObjInsArg::Reloc) => true,
|
||||
(ObjInsArg::RelocWithBase, ObjInsArg::RelocWithBase) => true,
|
||||
(ObjInsArg::BranchOffset(a), ObjInsArg::BranchOffset(b)) => a == b,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct ObjInsArgDiff {
|
||||
/// Incrementing index for coloring
|
||||
|
|
|
@ -194,7 +194,7 @@ fn write_ins(
|
|||
HighlightKind::Address(v) => {
|
||||
matches!(arg, ObjInsArg::BranchOffset(offset) if (offset + ins.address as i32 - base_addr as i32) as u32 == *v)
|
||||
}
|
||||
HighlightKind::Arg(v) => v == arg,
|
||||
HighlightKind::Arg(v) => v.loose_eq(arg),
|
||||
_ => false,
|
||||
};
|
||||
let color = if highlighted_arg {
|
||||
|
|
Loading…
Reference in New Issue