From c7d90297d41af6c178dbed4b8c389567aa4a4d06 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Fri, 28 Jun 2024 11:32:21 -0400 Subject: Add LLIL_REG_SPLIT to rust api --- rust/src/llil/operation.rs | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'rust/src/llil/operation.rs') diff --git a/rust/src/llil/operation.rs b/rust/src/llil/operation.rs index dfcfbc17..f42b3693 100644 --- a/rust/src/llil/operation.rs +++ b/rust/src/llil/operation.rs @@ -290,6 +290,62 @@ where } } +// LLIL_REG_SPLIT +pub struct RegSplit; + +impl<'func, A, M, V> Operation<'func, A, M, NonSSA, RegSplit> + where + A: 'func + Architecture, + M: FunctionMutability, + V: NonSSAVariant, +{ + pub fn size(&self) -> usize { + self.op.size + } + + pub fn low_reg(&self) -> Register { + let raw_id = self.op.operands[0] as u32; + + if raw_id >= 0x8000_0000 { + Register::Temp(raw_id & 0x7fff_ffff) + } else { + self.function + .arch() + .register_from_id(raw_id) + .map(Register::ArchReg) + .unwrap_or_else(|| { + error!( + "got garbage register from LLIL_REG @ 0x{:x}", + self.op.address + ); + + Register::Temp(0) + }) + } + } + + pub fn high_reg(&self) -> Register { + let raw_id = self.op.operands[1] as u32; + + if raw_id >= 0x8000_0000 { + Register::Temp(raw_id & 0x7fff_ffff) + } else { + self.function + .arch() + .register_from_id(raw_id) + .map(Register::ArchReg) + .unwrap_or_else(|| { + error!( + "got garbage register from LLIL_REG @ 0x{:x}", + self.op.address + ); + + Register::Temp(0) + }) + } + } +} + // LLIL_FLAG, LLIL_FLAG_SSA pub struct Flag; @@ -702,6 +758,7 @@ impl OperationArguments for SetFlag {} impl OperationArguments for Load {} impl OperationArguments for Store {} impl OperationArguments for Reg {} +impl OperationArguments for RegSplit {} impl OperationArguments for Flag {} impl OperationArguments for FlagBit {} impl OperationArguments for Jump {} -- cgit v1.3.1