summaryrefslogtreecommitdiff
path: root/rust/src/llil/operation.rs
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2024-06-28 11:32:21 -0400
committermason <35282038+emesare@users.noreply.github.com>2024-07-01 12:35:51 +0000
commitc7d90297d41af6c178dbed4b8c389567aa4a4d06 (patch)
treebcebdf11d6fa2fac07e558bdece6a823566f2844 /rust/src/llil/operation.rs
parent3765f2dce4addd02364af6fb2973ff8eb47a7cd9 (diff)
Add LLIL_REG_SPLIT to rust api
Diffstat (limited to 'rust/src/llil/operation.rs')
-rw-r--r--rust/src/llil/operation.rs57
1 files changed, 57 insertions, 0 deletions
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<V>, RegSplit>
+ where
+ A: 'func + Architecture,
+ M: FunctionMutability,
+ V: NonSSAVariant,
+{
+ pub fn size(&self) -> usize {
+ self.op.size
+ }
+
+ pub fn low_reg(&self) -> Register<A::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<A::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 {}