Skip to content

Commit 0ec7bf0

Browse files
committed
Highlight: Consider reg offsets and signed immediates equivalent
Fixes #32
1 parent 74e8913 commit 0ec7bf0

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/obj/mod.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,30 @@ pub enum ObjInsArg {
5050
BranchOffset(i32),
5151
}
5252

53+
impl ObjInsArg {
54+
pub fn loose_eq(&self, other: &ObjInsArg) -> bool {
55+
match (self, other) {
56+
(ObjInsArg::PpcArg(a), ObjInsArg::PpcArg(b)) => {
57+
a == b
58+
|| match (a, b) {
59+
// Consider Simm and Offset equivalent
60+
(ppc750cl::Argument::Simm(simm), ppc750cl::Argument::Offset(off))
61+
| (ppc750cl::Argument::Offset(off), ppc750cl::Argument::Simm(simm)) => {
62+
simm.0 == off.0
63+
}
64+
_ => false,
65+
}
66+
}
67+
(ObjInsArg::MipsArg(a), ObjInsArg::MipsArg(b)) => a == b,
68+
(ObjInsArg::MipsArgWithBase(a), ObjInsArg::MipsArgWithBase(b)) => a == b,
69+
(ObjInsArg::Reloc, ObjInsArg::Reloc) => true,
70+
(ObjInsArg::RelocWithBase, ObjInsArg::RelocWithBase) => true,
71+
(ObjInsArg::BranchOffset(a), ObjInsArg::BranchOffset(b)) => a == b,
72+
_ => false,
73+
}
74+
}
75+
}
76+
5377
#[derive(Debug, Copy, Clone)]
5478
pub struct ObjInsArgDiff {
5579
/// Incrementing index for coloring

src/views/function_diff.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ fn write_ins(
194194
HighlightKind::Address(v) => {
195195
matches!(arg, ObjInsArg::BranchOffset(offset) if (offset + ins.address as i32 - base_addr as i32) as u32 == *v)
196196
}
197-
HighlightKind::Arg(v) => v == arg,
197+
HighlightKind::Arg(v) => v.loose_eq(arg),
198198
_ => false,
199199
};
200200
let color = if highlighted_arg {

0 commit comments

Comments
 (0)