Skip to content

Commit

Permalink
Update ppc750cl (subi{,s,c} mnemonics, capstone-style CR bits)
Browse files Browse the repository at this point in the history
  • Loading branch information
encounter committed Oct 6, 2023
1 parent bb9ff4b commit e68629c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 48 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ memmap2 = "0.9.0"
notify = "6.1.1"
object = { version = "0.32.1", features = ["read_core", "std", "elf"], default-features = false }
png = "0.17.10"
ppc750cl = { git = "https://github.com/terorie/ppc750cl", rev = "9ae36eef34aa6d74e00972c7671f547a2acfd0aa" }
ppc750cl = { git = "https://github.com/encounter/ppc750cl", rev = "4a2bbbc6f84dcb76255ab6f3595a8d4a0ce96618" }
rabbitizer = "1.7.10"
rfd = { version = "0.12.0" } #, default-features = false, features = ['xdg-portal']
ron = "0.8.1"
Expand Down
35 changes: 1 addition & 34 deletions src/obj/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub struct ObjSection {
pub match_percent: f32,
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum ObjInsArg {
PpcArg(ppc750cl::Argument),
MipsArg(String),
Expand All @@ -48,39 +48,6 @@ pub enum ObjInsArg {
BranchOffset(i32),
}

// TODO derive PartialEq on ppc750cl::Argument so this isn't necessary
impl PartialEq for ObjInsArg {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(ObjInsArg::PpcArg(a), ObjInsArg::PpcArg(b)) => {
use ppc750cl::Argument;
match (a, b) {
(Argument::GPR(a), Argument::GPR(b)) => a == b,
(Argument::FPR(a), Argument::FPR(b)) => a == b,
(Argument::SR(a), Argument::SR(b)) => a == b,
(Argument::SPR(a), Argument::SPR(b)) => a == b,
(Argument::CRField(a), Argument::CRField(b)) => a == b,
(Argument::CRBit(a), Argument::CRBit(b)) => a == b,
(Argument::GQR(a), Argument::GQR(b)) => a == b,
(Argument::Uimm(a), Argument::Uimm(b)) => a == b,
(Argument::Simm(a), Argument::Simm(b)) => a == b,
(Argument::Offset(a), Argument::Offset(b)) => a == b,
(Argument::BranchDest(a), Argument::BranchDest(b)) => a == b,
(Argument::Bit(a), Argument::Bit(b)) => a == b,
(Argument::OpaqueU(a), Argument::OpaqueU(b)) => a == b,
(_, _) => 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
Expand Down
14 changes: 2 additions & 12 deletions src/obj/ppc.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::BTreeMap;

use anyhow::Result;
use ppc750cl::{disasm_iter, Argument, Ins, SimplifiedIns};
use ppc750cl::{disasm_iter, Argument, SimplifiedIns};

use crate::obj::{ObjIns, ObjInsArg, ObjReloc, ObjRelocKind};

Expand Down Expand Up @@ -89,18 +89,8 @@ pub fn process_code(
op: ins.op as u8,
branch_dest: None,
line,
orig: Some(format!("{}", basic_form(ins))),
orig: Some(format!("{}", SimplifiedIns::basic_form(ins))),
});
}
Ok((ops, insts))
}

// TODO make public in ppc750cl
fn basic_form(ins: Ins) -> SimplifiedIns {
SimplifiedIns {
mnemonic: ins.op.mnemonic(),
suffix: ins.suffix(),
args: ins.fields().iter().flat_map(|field| field.argument()).collect(),
ins,
}
}

0 comments on commit e68629c

Please sign in to comment.