@@ -209,6 +209,57 @@ impl Ref<LowLevelILFunction<Mutable, NonSSA>> {
209209 }
210210}
211211
212+ impl < M : FunctionMutability > Ref < LowLevelILFunction < M , SSA > > {
213+ /// Return a vector of all instructions that use the given SSA register.
214+ #[ must_use]
215+ pub fn get_ssa_register_uses < R : ArchReg > (
216+ & self ,
217+ reg : LowLevelILSSARegisterKind < R > ,
218+ ) -> Vec < LowLevelILInstruction < M , SSA > > {
219+ use binaryninjacore_sys:: BNGetLowLevelILSSARegisterUses ;
220+ let register_id = match reg {
221+ LowLevelILSSARegisterKind :: Full { kind, .. } => kind. id ( ) ,
222+ LowLevelILSSARegisterKind :: Partial { partial_reg, .. } => partial_reg. id ( ) ,
223+ } ;
224+ let mut count = 0 ;
225+ let instrs = unsafe {
226+ BNGetLowLevelILSSARegisterUses (
227+ self . handle ,
228+ register_id. into ( ) ,
229+ reg. version ( ) as usize ,
230+ & mut count,
231+ )
232+ } ;
233+ let result = unsafe { std:: slice:: from_raw_parts ( instrs, count) }
234+ . iter ( )
235+ . map ( |idx| LowLevelILInstruction :: new ( self , LowLevelInstructionIndex ( * idx) ) )
236+ . collect ( ) ;
237+ unsafe { BNFreeILInstructionList ( instrs) } ;
238+ result
239+ }
240+
241+ /// Returns the instruction that defines the given SSA register.
242+ #[ must_use]
243+ pub fn get_ssa_register_definition < R : ArchReg > (
244+ & self ,
245+ reg : & LowLevelILSSARegisterKind < R > ,
246+ ) -> Option < LowLevelILInstruction < M , SSA > > {
247+ use binaryninjacore_sys:: BNGetLowLevelILSSARegisterDefinition ;
248+ let register_id = match reg {
249+ LowLevelILSSARegisterKind :: Full { kind, .. } => kind. id ( ) ,
250+ LowLevelILSSARegisterKind :: Partial { partial_reg, .. } => partial_reg. id ( ) ,
251+ } ;
252+ let instr_idx = unsafe {
253+ BNGetLowLevelILSSARegisterDefinition (
254+ self . handle ,
255+ register_id. into ( ) ,
256+ reg. version ( ) as usize ,
257+ )
258+ } ;
259+ self . instruction_from_index ( LowLevelInstructionIndex ( instr_idx) )
260+ }
261+ }
262+
212263impl < M , F > ToOwned for LowLevelILFunction < M , F >
213264where
214265 M : FunctionMutability ,
0 commit comments