From e68629c339e8e43e8c094cc3b87606e576e4502c Mon Sep 17 00:00:00 2001 From: Luke Street Date: Fri, 6 Oct 2023 01:22:07 -0400 Subject: [PATCH] Update ppc750cl (subi{,s,c} mnemonics, capstone-style CR bits) --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/obj/mod.rs | 35 +---------------------------------- src/obj/ppc.rs | 14 ++------------ 4 files changed, 5 insertions(+), 48 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3721980..7afe5e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2799,7 +2799,7 @@ checksum = "26f6a7b87c2e435a3241addceeeff740ff8b7e76b74c13bf9acb17fa454ea00b" [[package]] name = "ppc750cl" version = "0.2.0" -source = "git+https://github.com/terorie/ppc750cl?rev=9ae36eef34aa6d74e00972c7671f547a2acfd0aa#9ae36eef34aa6d74e00972c7671f547a2acfd0aa" +source = "git+https://github.com/encounter/ppc750cl?rev=4a2bbbc6f84dcb76255ab6f3595a8d4a0ce96618#4a2bbbc6f84dcb76255ab6f3595a8d4a0ce96618" dependencies = [ "num-traits", "serde", diff --git a/Cargo.toml b/Cargo.toml index b6a2ba2..9ed4efe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/obj/mod.rs b/src/obj/mod.rs index d03bebb..16955f5 100644 --- a/src/obj/mod.rs +++ b/src/obj/mod.rs @@ -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), @@ -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 diff --git a/src/obj/ppc.rs b/src/obj/ppc.rs index b332fd4..78dddf9 100644 --- a/src/obj/ppc.rs +++ b/src/obj/ppc.rs @@ -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}; @@ -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, - } -}