From e1ebfcd751ee5933da99bb21606b779edfe440b2 Mon Sep 17 00:00:00 2001 From: Mark Rowe Date: Sun, 7 Jun 2026 16:04:21 -0700 Subject: [Python] Fix copy_expr_to and add builder methods for recently-added instructions --- python/lowlevelil.py | 198 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 198 insertions(+) (limited to 'python/lowlevelil.py') diff --git a/python/lowlevelil.py b/python/lowlevelil.py index 9f601fd4..68143203 100644 --- a/python/lowlevelil.py +++ b/python/lowlevelil.py @@ -4177,6 +4177,13 @@ class LowLevelILFunction: LowLevelILOperation.LLIL_PUSH, LowLevelILOperation.LLIL_NEG, LowLevelILOperation.LLIL_NOT, + LowLevelILOperation.LLIL_BSWAP, + LowLevelILOperation.LLIL_POPCNT, + LowLevelILOperation.LLIL_CLZ, + LowLevelILOperation.LLIL_CTZ, + LowLevelILOperation.LLIL_RBIT, + LowLevelILOperation.LLIL_CLS, + LowLevelILOperation.LLIL_ABS, LowLevelILOperation.LLIL_SX, LowLevelILOperation.LLIL_ZX, LowLevelILOperation.LLIL_LOW_PART, @@ -4207,6 +4214,10 @@ class LowLevelILFunction: LowLevelILOperation.LLIL_ROL, LowLevelILOperation.LLIL_ROR, LowLevelILOperation.LLIL_MUL, + LowLevelILOperation.LLIL_MINS, + LowLevelILOperation.LLIL_MAXS, + LowLevelILOperation.LLIL_MINU, + LowLevelILOperation.LLIL_MAXU, LowLevelILOperation.LLIL_MULU_DP, LowLevelILOperation.LLIL_MULS_DP, LowLevelILOperation.LLIL_DIVU, @@ -5076,6 +5087,78 @@ class LowLevelILFunction: """ return self.expr(LowLevelILOperation.LLIL_MULU_DP, a, b, size=size, flags=flags, source_location=loc) + def min_signed( + self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagWriteType'] = None, + loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: + """ + ``min_signed`` signed minimum of expressions ``a`` and ``b`` potentially setting flags ``flags`` and returning an + expression of ``size`` bytes. + + :param int size: the size of the result in bytes + :param ExpressionIndex a: LHS expression + :param ExpressionIndex b: RHS expression + :param FlagWriteType flags: optional, flag write type caused by this operation + :param ILSourceLocation loc: location of returned expression + :return: The expression ``mins.{}(a, b)`` + :rtype: ExpressionIndex + """ + return self.expr(LowLevelILOperation.LLIL_MINS, a, b, size=size, flags=flags, source_location=loc) + + def max_signed( + self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagWriteType'] = None, + loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: + """ + ``max_signed`` signed maximum of expressions ``a`` and ``b`` potentially setting flags ``flags`` and returning an + expression of ``size`` bytes. + + :param int size: the size of the result in bytes + :param ExpressionIndex a: LHS expression + :param ExpressionIndex b: RHS expression + :param FlagWriteType flags: optional, flag write type caused by this operation + :param ILSourceLocation loc: location of returned expression + :return: The expression ``maxs.{}(a, b)`` + :rtype: ExpressionIndex + """ + return self.expr(LowLevelILOperation.LLIL_MAXS, a, b, size=size, flags=flags, source_location=loc) + + def min_unsigned( + self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagWriteType'] = None, + loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: + """ + ``min_unsigned`` unsigned minimum of expressions ``a`` and ``b`` potentially setting flags ``flags`` and returning an + expression of ``size`` bytes. + + :param int size: the size of the result in bytes + :param ExpressionIndex a: LHS expression + :param ExpressionIndex b: RHS expression + :param FlagWriteType flags: optional, flag write type caused by this operation + :param ILSourceLocation loc: location of returned expression + :return: The expression ``minu.{}(a, b)`` + :rtype: ExpressionIndex + """ + return self.expr(LowLevelILOperation.LLIL_MINU, a, b, size=size, flags=flags, source_location=loc) + + def max_unsigned( + self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagWriteType'] = None, + loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: + """ + ``max_unsigned`` unsigned maximum of expressions ``a`` and ``b`` potentially setting flags ``flags`` and returning an + expression of ``size`` bytes. + + :param int size: the size of the result in bytes + :param ExpressionIndex a: LHS expression + :param ExpressionIndex b: RHS expression + :param FlagWriteType flags: optional, flag write type caused by this operation + :param ILSourceLocation loc: location of returned expression + :return: The expression ``maxu.{}(a, b)`` + :rtype: ExpressionIndex + """ + return self.expr(LowLevelILOperation.LLIL_MAXU, a, b, size=size, flags=flags, source_location=loc) + def div_signed( self, size: int, a: ExpressionIndex, b: ExpressionIndex, flags: Optional['architecture.FlagWriteType'] = None, loc: Optional['ILSourceLocation'] = None @@ -5256,6 +5339,121 @@ class LowLevelILFunction: """ return self.expr(LowLevelILOperation.LLIL_NOT, value, size=size, flags=flags, source_location=loc) + def byte_swap( + self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagWriteType'] = None, + loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: + """ + ``byte_swap`` reverses the byte order of expression ``value`` of size ``size`` potentially setting flags + + :param int size: the size of the result in bytes + :param ExpressionIndex value: the expression to byte swap + :param FlagWriteType flags: optional, flag write type caused by this operation + :param ILSourceLocation loc: location of returned expression + :return: The expression ``bswap.{}(value)`` + :rtype: ExpressionIndex + """ + return self.expr(LowLevelILOperation.LLIL_BSWAP, value, size=size, flags=flags, source_location=loc) + + def population_count( + self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagWriteType'] = None, + loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: + """ + ``population_count`` counts the number of set bits in expression ``value`` of size ``size`` potentially setting flags + + :param int size: the size of the result in bytes + :param ExpressionIndex value: the expression to count set bits in + :param FlagWriteType flags: optional, flag write type caused by this operation + :param ILSourceLocation loc: location of returned expression + :return: The expression ``popcnt.{}(value)`` + :rtype: ExpressionIndex + """ + return self.expr(LowLevelILOperation.LLIL_POPCNT, value, size=size, flags=flags, source_location=loc) + + def count_leading_zeros( + self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagWriteType'] = None, + loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: + """ + ``count_leading_zeros`` counts the leading zero bits in expression ``value`` of size ``size`` potentially setting + flags. The result is ``8 * size`` when ``value`` is zero. + + :param int size: the size of the result in bytes + :param ExpressionIndex value: the expression to count leading zero bits in + :param FlagWriteType flags: optional, flag write type caused by this operation + :param ILSourceLocation loc: location of returned expression + :return: The expression ``clz.{}(value)`` + :rtype: ExpressionIndex + """ + return self.expr(LowLevelILOperation.LLIL_CLZ, value, size=size, flags=flags, source_location=loc) + + def count_trailing_zeros( + self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagWriteType'] = None, + loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: + """ + ``count_trailing_zeros`` counts the trailing zero bits in expression ``value`` of size ``size`` potentially setting + flags. The result is ``8 * size`` when ``value`` is zero. + + :param int size: the size of the result in bytes + :param ExpressionIndex value: the expression to count trailing zero bits in + :param FlagWriteType flags: optional, flag write type caused by this operation + :param ILSourceLocation loc: location of returned expression + :return: The expression ``ctz.{}(value)`` + :rtype: ExpressionIndex + """ + return self.expr(LowLevelILOperation.LLIL_CTZ, value, size=size, flags=flags, source_location=loc) + + def reverse_bits( + self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagWriteType'] = None, + loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: + """ + ``reverse_bits`` reverses the bit order of expression ``value`` of size ``size`` potentially setting flags + + :param int size: the size of the result in bytes + :param ExpressionIndex value: the expression to reverse the bits of + :param FlagWriteType flags: optional, flag write type caused by this operation + :param ILSourceLocation loc: location of returned expression + :return: The expression ``rbit.{}(value)`` + :rtype: ExpressionIndex + """ + return self.expr(LowLevelILOperation.LLIL_RBIT, value, size=size, flags=flags, source_location=loc) + + def count_leading_signs( + self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagWriteType'] = None, + loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: + """ + ``count_leading_signs`` counts the leading sign bits in expression ``value`` of size ``size`` (the number of bits + below the sign bit that match it) potentially setting flags + + :param int size: the size of the result in bytes + :param ExpressionIndex value: the expression to count leading sign bits in + :param FlagWriteType flags: optional, flag write type caused by this operation + :param ILSourceLocation loc: location of returned expression + :return: The expression ``cls.{}(value)`` + :rtype: ExpressionIndex + """ + return self.expr(LowLevelILOperation.LLIL_CLS, value, size=size, flags=flags, source_location=loc) + + def absolute_value( + self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagWriteType'] = None, + loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: + """ + ``absolute_value`` signed absolute value of expression ``value`` of size ``size`` potentially setting flags + + :param int size: the size of the result in bytes + :param ExpressionIndex value: the expression to take the absolute value of + :param FlagWriteType flags: optional, flag write type caused by this operation + :param ILSourceLocation loc: location of returned expression + :return: The expression ``abs.{}(value)`` + :rtype: ExpressionIndex + """ + return self.expr(LowLevelILOperation.LLIL_ABS, value, size=size, flags=flags, source_location=loc) + def sign_extend( self, size: int, value: ExpressionIndex, flags: Optional['architecture.FlagWriteType'] = None, loc: Optional['ILSourceLocation'] = None -- cgit v1.3.1