summaryrefslogtreecommitdiff
path: root/python/lowlevelil.py
diff options
context:
space:
mode:
authorMark Rowe <mark@vector35.com>2026-06-07 16:04:21 -0700
committerMark Rowe <mark@vector35.com>2026-06-07 16:12:52 -0700
commite1ebfcd751ee5933da99bb21606b779edfe440b2 (patch)
treec119d4e2c533321a9107f1be5a55933c9c590dc3 /python/lowlevelil.py
parent61b068347672bf2dbea4ee31d7080d32a3b919fe (diff)
[Python] Fix copy_expr_to and add builder methods for recently-added instructions
Diffstat (limited to 'python/lowlevelil.py')
-rw-r--r--python/lowlevelil.py198
1 files changed, 198 insertions, 0 deletions
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.<size>{<flags>}(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.<size>{<flags>}(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.<size>{<flags>}(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.<size>{<flags>}(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.<size>{<flags>}(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.<size>{<flags>}(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.<size>{<flags>}(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.<size>{<flags>}(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.<size>{<flags>}(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.<size>{<flags>}(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.<size>{<flags>}(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