java.lang.Object | |
↳ | com.pnfsoftware.jeb.core.units.code.asm.decompiler.ir.EUtil |
Utility methods to manipulate IR expressions
.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
EUtil() |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
static IECond |
abs(IERoutineContext ctx, IEGeneric a)
Operation Math#abs(int, int) applied to
IEGeneric
| ||||||||||
static IEOperation | add(IEGeneric a, IEGeneric b, IEGeneric c) | ||||||||||
static IEOperation | add(IEGeneric a, IEGeneric b) | ||||||||||
static int | adjustBranchToIRInstruction(IEStatement stm, int currentTargetIROffset, int newTargetIROffset) | ||||||||||
static IEOperation | andB(IEGeneric a, IEGeneric b) | ||||||||||
static IEOperation | andL(IEGeneric a, IEGeneric b) | ||||||||||
static IEGeneric |
buildCarryFlag(IEGeneric a, IEGeneric b, IEGeneric result, boolean addition, boolean nativeOp)
Generate an IR expression computing the carry flag bit of an integer addition or subtraction
operation.
| ||||||||||
static IEOperation |
buildLogicalOperation(IEOperation e)
Transform the operands of an operation into logical operands (LOG_NEQ with 0).
| ||||||||||
static IEGeneric |
buildOverflowFlag(IEGeneric a, IEGeneric b, IEGeneric result, boolean addition)
Generate an IR expression computing the overflow flag bit of an integer addition or
subtraction operation.
| ||||||||||
static IECond |
buildStrictLogicalECond(IECond e)
Check if the ECond predicate is a ""boolean"", i.e.
| ||||||||||
static IEOperation |
buildStrictLogicalOperation(IEOperation e)
Check if the operands of logical OR, AND and NOT are ""booleans"", i.e.
| ||||||||||
static int |
calculateComplexity(IEGeneric e)
Calculate the trivial complexity metric for the provided IR expression.
| ||||||||||
static Boolean | checkCallReturnAddress(IERoutineContext ctx, CFG<IEStatement> cfg, BasicBlock<IEStatement> b, int insnIndex) | ||||||||||
static IEGeneric | checkFalse(IEGeneric e) | ||||||||||
static IEGeneric | checkTrue(IEGeneric e) | ||||||||||
static IEGeneric | cmpFloat(OperationType op, IEGeneric op1, IEGeneric op2) | ||||||||||
static void |
collectVars(IEGeneric e, Collection<IEVar> sink)
Collect all EVars of an expression.
| ||||||||||
static Set<IEVar> | collectVars(IEGeneric e) | ||||||||||
static IEGeneric |
compose(IEGeneric... elts)
This method is deprecated.
use #compose(IERoutineContext, IEGeneric...)
| ||||||||||
static IEGeneric |
compose(IERoutineContext ctx, IEGeneric... elts)
Create a composition if the provided list of elements contains at least two entries, else
return the single element.
| ||||||||||
static IEGeneric |
compose(IERoutineContext ctx, Collection<IEGeneric> elts)
Create a composition if the provided list of elements contains at list two entries, else
return the single element.
| ||||||||||
static boolean |
contains(IEGeneric target, IEGeneric token)
Indicates if the target expression contains any token expression
| ||||||||||
static boolean |
containsMemoryAccess(IEGeneric e)
Indicates if the generic expression contains any memory access (meaning
IEMem ) | ||||||||||
static boolean |
containsUndeterminedInvocations(IEGeneric e)
Indicates if the generic expression invokes any undetermined kind of call (meaning
IECall , IEJumpFar or IEUntranslatedInstruction ) | ||||||||||
static int |
countExpressionPresence(IEGeneric e, IEGeneric target)
Recursively count (using deep equality) how many times the provided target is seen in the
input expression.
| ||||||||||
static void |
countExpressionsPresence(IEGeneric e, List<IEGeneric> targets, int[] acounts)
Recursively count (using deep equality) how many times each of the provided targets is seen
in the input expression.
| ||||||||||
static int |
countSubExpressions(IEGeneric e)
Collect sub-expressions of the input expression and return the cardinal of that collection.
| ||||||||||
static int |
countVariablePresence(IEGeneric e, IEVar target)
Count the number of times an
IEVar is present in an expression. | ||||||||||
static int | countVariableUse(IEGeneric e) | ||||||||||
static IEOperation |
createConversionOperation(OperationType convOperator, IEGeneric src, int dstSize)
Create a conversion operation: an integer truncation, integer extension (zero or signed),
float truncation or extension, float-to-int and int-to-float conversion.
| ||||||||||
static IEOperation |
createResizeOperation(IEGeneric src, int dstSize, boolean signed)
Create a resize operation operation: truncation, zero-extension, or sign-extension.
| ||||||||||
static int |
determineArgumentStackSlotCount(IWildcardPrototype prototype, Collection<IWildcardType> varArgTypes)
Determine the number of stacks slots used by invoking a method having the provided prototype
and an optional list of additional arguments.
| ||||||||||
static int |
determineReturnValuesStackSlotCount(IWildcardPrototype prototype, int inputStackSlotCount)
Determine the number of stack slots filled out when a routine with the provided prototype
returns.
| ||||||||||
static IEOperation |
div(IEGeneric a, IEGeneric b, boolean signed)
Alias for
divS(IEGeneric, IEGeneric) / divU(IEGeneric, IEGeneric)
| ||||||||||
static IEOperation | divS(IEGeneric a, IEGeneric b) | ||||||||||
static IEOperation | divU(IEGeneric a, IEGeneric b) | ||||||||||
static void |
dump(CFG<IEStatement> cfg, String filename, String title)
Dump an IR-CFG to a Graphviz
dot file in the user's temporary folder. | ||||||||||
static void |
dump(CFG<IEStatement> cfg, String filename)
Dump an IR-CFG to a Graphviz
dot file in the user's temporary folder. | ||||||||||
static IEOperation | eq(IEGeneric a, IEGeneric b) | ||||||||||
static IEGeneric |
eqFloat(IEGeneric op1, IEGeneric op2)
This method is deprecated.
Use
FEQ instead
| ||||||||||
static int |
evalAsPositiveInt(IEImm imm)
Evaluate an immediate to a 32-bit positive int.
| ||||||||||
static int |
evalAsSaturatedPositiveInt(IEImm imm)
Evaluate and convert a positive immediate to a 32-bit int.
| ||||||||||
static long | evaluateAddress_preVerified(IEGeneric e) | ||||||||||
static long | evaluateAddress_preVerified(IEGeneric e, EState state) | ||||||||||
static long | evaluateUnsignedLong_preVerified(IEGeneric e) | ||||||||||
static long | evaluateUnsignedLong_preVerified(IEGeneric e, EState state) | ||||||||||
static IEImm | evaluate_preVerified(IEGeneric e, EState state) | ||||||||||
static IEImm | evaluate_preVerified(IEGeneric e) | ||||||||||
static boolean |
expandCalls(IERoutineContext ctx, boolean alsoExpandPCAssign)
Call/PC-assign expansion: augment the size to at least 2, to accommodate splitting:
- if an EReturn is to be inserted (tail-calls) in lieu of a ECall - if a raw PC-assign cannot be converted to a single EJumpFar | ||||||||||
static CFG<IEStatement> |
expandStatementSize(IERoutineContext ectx, IEStatement stm0, int minSize)
Expand the
size of a statement. | ||||||||||
static CFG<IEStatement> |
expandStatementSizes(IERoutineContext ectx, Collection<IEStatement> stmcoll, int minSize)
Expand the
sizes of a collection of statements. | ||||||||||
static IEGeneric |
extend(IEGeneric a, int bitsize, boolean signExtend)
Extend an
IEGeneric . | ||||||||||
static IECond |
fabs(IERoutineContext ctx, IEGeneric a)
Operation Math#abs(float, float) applied to
IEGeneric
| ||||||||||
static IECond |
fmax(IERoutineContext ctx, IEGeneric a, IEGeneric b)
Operation
max(float, float) applied to IEGeneric
| ||||||||||
static IECond |
fmin(IERoutineContext ctx, IEGeneric a, IEGeneric b)
Operation
min(float, float) applied to IEGeneric
| ||||||||||
static String |
formatIR(IERoutineContext ectx)
Format an IR-CFG.
| ||||||||||
static String |
formatIR(IERoutineContext ectx, boolean displayOffsets, boolean displayDataChains, boolean displayTypes)
Format an IR-CFG.
| ||||||||||
static String | formatStatements(List<? extends IEStatement> irlist) | ||||||||||
static String | formatVars(IERoutineContext ctx, Collection<Integer> varids) | ||||||||||
static String | formatVars(IERoutineContext ctx, int... varids) | ||||||||||
static List<IWildcardType> |
gatherArgumentTypes(IWildcardPrototype prototype, Collection<IWildcardType> varArgTypes)
Retrieve the list of input types, by examining the provided prototype and optional list of
additional arguments.
| ||||||||||
static IEOperation | geS(IEGeneric a, IEGeneric b) | ||||||||||
static IEOperation | geU(IEGeneric a, IEGeneric b) | ||||||||||
static IEMem | getAssigningFromMemory(IEStatement stm) | ||||||||||
static IEMem | getAssigningToMemory(IEStatement stm) | ||||||||||
static IEGeneric |
getAssignmentDestination(IEStatement stm)
Retrieve the destination of an
IEAssign (or null if is not an assignment). | ||||||||||
static IEGeneric |
getAssignmentSource(IEStatement stm)
Retrieve the source of an
IEAssign (or null if is not an assignment). | ||||||||||
static IWildcardType | getBestType(IWildcardType a, IWildcardType b) | ||||||||||
static OperationType | getMirrorOperation(OperationType optype) | ||||||||||
static OperationType | getOperation(IEGeneric e, OperationType... optypes) | ||||||||||
static OperationType | getOperation(IEOperation e, OperationType... optypes) | ||||||||||
static List<IEGeneric> |
getParents(IEGeneric expression, IEGeneric value)
Retrieve all the parents of a value.
| ||||||||||
static OperationType | getReverseOperation(OperationType optype) | ||||||||||
static IEGeneric |
getSignExtensionBase(IECompose e)
Check if the composition is a sign-extension of a base expression, and if so, provide the
base expression.
| ||||||||||
static IEGeneric |
getSignExtensionBase(IEGeneric base, IEGeneric extend)
Check if the composition of both expressions make up a sign-extension, and if so, provide the
base expression.
| ||||||||||
static IEGeneric |
getSignExtensionBase(IEGeneric e)
Check if an IR expression looks like a sign-extension operation, and if so, provide the base
expression.
| ||||||||||
static List<IEGeneric> |
getSubExpressions(IEGeneric e)
Collect the sub-expressions of an IRE.
| ||||||||||
static Set<Integer> | getUsedVarIds(IEGeneric e) | ||||||||||
static IEVar | getVarSlice(IEGeneric e) | ||||||||||
static Integer | getVarSliceId(IEGeneric e) | ||||||||||
static List<IEVar> | getVars(IERoutineContext ctx, Collection<Integer> varids) | ||||||||||
static List<IWildcardType> | getWildcardTypes(IWildcardTypeManager etypeman, Collection<IEGeneric> elts) | ||||||||||
static IEGeneric |
gtFloat(IEGeneric op1, IEGeneric op2)
This method is deprecated.
Use
FGT instead
| ||||||||||
static IEOperation | gtS(IEGeneric a, IEGeneric b) | ||||||||||
static IEOperation | gtU(IEGeneric a, IEGeneric b) | ||||||||||
static boolean | hasExplicitlyUsedVar(IEGeneric e, IEVar target) | ||||||||||
static boolean |
hasLinearControlFlow(IERoutineContext ctx)
Checks if an IR routine contains only basic blocks with one parent and one child (no merge or
disjunction of control-flow).
| ||||||||||
static boolean |
hasNoSideEffect(IEGeneric e)
Determine if an IR expression is side-effect free.
| ||||||||||
static boolean |
hasNoTypeInfo(IEGeneric e)
Determine if the provided IR expression embeds no amount at all of type information.
| ||||||||||
static boolean | hasSameType(IEGeneric e1, IEGeneric e2) | ||||||||||
static boolean |
hasSideEffect(IEGeneric e)
The opposite of
hasNoSideEffect(IEGeneric) . | ||||||||||
static boolean |
hasTypeInfo(IEGeneric e)
Determine if the provided IR expression embeds some type information.
| ||||||||||
static IEGeneric | identL(IEGeneric a) | ||||||||||
static IEImm |
imm(byte[] val, int bitsize)
Create an arbitrary-long immediate.
| ||||||||||
static IEImm |
imm(String val, int bitsize)
Create an arbitrary-long immediate.
| ||||||||||
static IEImm |
imm(BigInteger val, int bitsize)
Create an arbitrary-long immediate.
| ||||||||||
static IEImm |
imm(long val, int bitsize)
Create an immediate, limited to 64 bits.
| ||||||||||
static boolean |
isAssignedIn(BasicBlock<IEStatement> bb, IEGeneric checkedDst)
Check that an IRE is assigned in a basic block.
| ||||||||||
static boolean |
isBitOne(IEGeneric e)
Verify that an IRE is a single-bit immediate set to 1 (technically, -1).
| ||||||||||
static boolean |
isBitZero(IEGeneric e)
Verify that an IRE is a single-bit immediate set to 0.
| ||||||||||
static boolean | isComparableIntegerOperation(IEOperation e) | ||||||||||
static boolean | isComparableOperation(IEOperation e) | ||||||||||
static boolean | isComparableOperation(IEOperation e, boolean allowUnsigned, boolean allowFloat) | ||||||||||
static boolean |
isComparableOperation(IEGeneric e)
""Boolean"" comparable operation (eq/neq and all greater/lesser comparisons)
| ||||||||||
static boolean | isComparableSignedOperation(IEOperation e) | ||||||||||
static boolean | isCondEAssign(IEStatement e) | ||||||||||
static boolean | isConditionalJump(IEStatement e) | ||||||||||
static boolean | isExpressionModified(IEStatement insn, IEGeneric target, boolean defuse) | ||||||||||
static boolean | isFirstBit(IESlice s2) | ||||||||||
static boolean | isImmNonZero(IEGeneric e) | ||||||||||
static boolean | isImmSize(IEGeneric e, int bitsize) | ||||||||||
static boolean | isImmValue(IEGeneric e, BigInteger value) | ||||||||||
static boolean | isImmValue(IEGeneric e, long value) | ||||||||||
static boolean | isImmZero(IEGeneric e) | ||||||||||
static boolean | isImmediate(IEGeneric e) | ||||||||||
static boolean | isJump(IEGeneric e) | ||||||||||
static boolean | isLastBit(IESlice s2) | ||||||||||
static boolean |
isLegalSignedImmediate(IEImm v, int checkedBitsize)
Verify that the provided immediate is a legal signed value if it were to be treated as a
signed integer of `checkedBitsize`.
| ||||||||||
static boolean |
isLegalUnsignedImmediate(IEImm v, int checkedBitsize)
Verify that the provided immediate is a legal unsigned value if it were to be treated as an
unsigned integer of `checkedBitsize`.
| ||||||||||
static boolean |
isLikeImmediate(IEGeneric a)
Determine if the IRE is an EImm or a slice or composition of immediates.
| ||||||||||
static boolean |
isLikeLongImmediate(IEGeneric e, boolean unsigned)
Determine if the expression is equivalent to an EImm that can be read as a
long
primitive. | ||||||||||
static boolean |
isLikeLongImmediate(IEGeneric e)
Determine if the expression is equivalent to an EImm that can be read as a
long
primitive. | ||||||||||
static boolean |
isLogicalOperation(IEGeneric e)
""Boolean"" operation (and, or, not, eq/neq and all greater/lesser comparisons)
| ||||||||||
static boolean |
isLongImmediate(IEGeneric e, boolean unsigned)
Determine if the expression is an EImm that can be read as a
long primitive. | ||||||||||
static boolean |
isLongImmediate(IEGeneric e)
Determine if the expression is an EImm that can be read as a
long primitive. | ||||||||||
static boolean | isMatchDuaryOperation(IEGeneric e, OperationType wantedOperationType, IEGeneric wantedOperand1, IEGeneric wantedOperand2) | ||||||||||
static boolean |
isMinusOne(IEGeneric e)
Verify that an IRE is an immediate holding the value -1.
| ||||||||||
static boolean | isNBit(IESlice s2, int n) | ||||||||||
static IEGeneric |
isNaN(IEGeneric op)
As per IEEE 754-1985 floating-point standard, is NaN a number which exponent is filled with
ones and a non-zero number in the mantissa
| ||||||||||
static boolean |
isNotPredicate(IEGeneric p, IEGeneric p2)
Indicate if p == !p2.
| ||||||||||
static boolean |
isOne(IEGeneric e)
Verify that an IRE is an immediate holding 1.
| ||||||||||
static boolean |
isOperation(IEGeneric e, OperationType optype)
Determine if the
IEGeneric is an IEOperation . | ||||||||||
static boolean |
isOperation(IEGeneric e, OperationType... optypes)
Determine if the
IEGeneric is an IEOperation . | ||||||||||
static boolean | isOperationSize(IEGeneric e, int bitsize) | ||||||||||
static boolean |
isPCAssign(IEStatement stm)
Determine if the provided statement is a PC-assign:
PC = ... | ||||||||||
static boolean |
isSPAssign(IEStatement stm)
Determine if the provided statement is a SP-assign:
SP = ... | ||||||||||
static boolean |
isSPAssignOrPCAssign(IEStatement stm)
Determine if the provided statement is assigning the stack pointer or the program counter.
| ||||||||||
static boolean | isSameType(IWildcardType a, IWildcardType b) | ||||||||||
static boolean | isStrictLogicalOperation(IEOperation e) | ||||||||||
static boolean |
isStrictLogicalOperation(IEGeneric e)
Logical operations that should have logical operands (and, or, not)
| ||||||||||
static boolean | isTrampoline(BasicBlock<IEStatement> bb) | ||||||||||
static boolean | isUnconditionalJump(IEStatement e) | ||||||||||
static boolean | isVar(IEGeneric e, int id) | ||||||||||
static boolean | isVarOrVarSlice(IEGeneric e) | ||||||||||
static boolean | isVariableAssigned(IEStatement stm, IEVar var) | ||||||||||
static boolean |
isZero(IEGeneric e)
Verify that an IRE is a Zero representation (EImm(0) or ESlice(0, x, x))
| ||||||||||
static boolean | isZeroExtend(IECompose e) | ||||||||||
static boolean | isZeroExtend(IEGeneric e) | ||||||||||
static IEOperation | leS(IEGeneric a, IEGeneric b) | ||||||||||
static IEOperation | leU(IEGeneric a, IEGeneric b) | ||||||||||
static boolean |
looksLikeSignExtension(IECompose e)
Determine if a composition looks like a sign-extension operation.
| ||||||||||
static IEGeneric |
ltFloat(IEGeneric op1, IEGeneric op2)
This method is deprecated.
Use
FLT instead
| ||||||||||
static IEOperation | ltS(IEGeneric a, IEGeneric b) | ||||||||||
static IEOperation | ltU(IEGeneric a, IEGeneric b) | ||||||||||
static void |
makeUncond(IEJumpWithOptionalCondition j)
throws if failure
| ||||||||||
static IEImm |
mask(int bitsize, int maskbits)
Create a bit mask, eg mask(16, 4) will create the mask:
b0000000000001111 | ||||||||||
static IEImm |
mask(int bitsize, int maskbegin, int maskend)
Create a bit mask, eg mask(16, 1, 5) will create the mask:
b0000000000011110 | ||||||||||
static IECond |
max(IERoutineContext ctx, IEGeneric a, IEGeneric b, boolean signed)
Operation
max(int, int) applied to IEGeneric
| ||||||||||
static IECond |
min(IERoutineContext ctx, IEGeneric a, IEGeneric b, boolean signed)
Operation
min(int, int) applied to IEGeneric
| ||||||||||
static IEImm |
minusOne(int bitsize)
Generates the value -1, ie an EImm filled with ones.
| ||||||||||
static IEOperation | mul(IEGeneric a, IEGeneric b) | ||||||||||
static IEOperation | ne(IEGeneric a, IEGeneric b) | ||||||||||
static IEGeneric | notB(IEGeneric a) | ||||||||||
static IEGeneric | notL(IEGeneric a, boolean allowOpt) | ||||||||||
static IEGeneric | notL(IEGeneric a) | ||||||||||
static IEImm |
one(int bitsize)
Generates the value 1L with defined bitsize.
| ||||||||||
static IEOperation | op(OperationType operator, IEGeneric a, IEGeneric b) | ||||||||||
static IEOperation | op(OperationType operator, IEGeneric a) | ||||||||||
static IEOperation | orB(IEGeneric a, IEGeneric b) | ||||||||||
static IEOperation | orL(IEGeneric a, IEGeneric b) | ||||||||||
static IEOperation | pow(IEGeneric a, IEGeneric b) | ||||||||||
static IEOperation | remS(IEGeneric a, IEGeneric b) | ||||||||||
static IEOperation | remU(IEGeneric a, IEGeneric b) | ||||||||||
static IEGeneric | replaceSubExpressionRecursive(IEGeneric stm, IEGeneric src, IEGeneric dst, EVisitResults results) | ||||||||||
static IEGeneric | replaceSubExpressionRecursive(IEGeneric stm, IEGeneric src, IEGeneric dst) | ||||||||||
static boolean |
requiresExplicitCast(IWildcardType a, IWildcardType b)
Determine if type `b` can be implicitly converted to type `a`, without a cast.
| ||||||||||
static boolean |
resolveExpressionsBackward(Object name, IEConverter<?> conv, List<IEStatement> r, IEGeneric... targets)
Apply a list of IEStatements to user targets, resolving expression starting from last
IEStatement to first. | ||||||||||
static IEGeneric | reversePredicate(IEGeneric predicate) | ||||||||||
static IEGeneric |
safeExtend(IEGeneric a, int bitsize, boolean signExtend)
Safely extend an
IEGeneric . | ||||||||||
static int |
sameBitsize(IEGeneric... elts)
If all the provided expressions have the same bitsize, return it.
| ||||||||||
static int |
sameBitsizeAllowNulls(IEGeneric... elts)
If all the provided expressions have the same bitsize, return it.
| ||||||||||
static IEOperation | sar(IEGeneric a, IEGeneric b) | ||||||||||
static void | setLowerLevelAddress(long addr, List<IEStatement> list) | ||||||||||
static void | setLowerLevelAddress(long addr, List<IEStatement> list, int fromIndex, int toIndex) | ||||||||||
static void | setLowerLevelAddressIfNone(long addr, List<IEStatement> list) | ||||||||||
static void | setLowerLevelAddressIfNone(long addr, List<IEStatement> list, int fromIndex, int toIndex) | ||||||||||
static IEOperation | shl(IEGeneric a, IEGeneric b) | ||||||||||
static IEOperation | shr(IEGeneric a, IEGeneric b) | ||||||||||
static IEGeneric |
signExt(IEGeneric src, int dstSize)
Sign-extend operation IRE.
| ||||||||||
static IEOperation | sub(IEGeneric a, IEGeneric b) | ||||||||||
static IEGeneric |
truncate(IEGeneric src, int dstSize)
Truncate operation IRE.
| ||||||||||
static void |
verify(CFG<IEStatement> cfg)
Verify an IR-CFG.
| ||||||||||
static void |
verify(IERoutineContext ctx)
Verify an IR-CFG.
| ||||||||||
static IEOperation | xorB(IEGeneric a, IEGeneric b) | ||||||||||
static IEImm |
zero(int bitsize)
Generates the value 0 with defined bitsize.
| ||||||||||
static IEGeneric |
zeroExt(IEGeneric src, int dstSize)
Zero-extend operation IRE.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Operation Math#abs(int, int) applied to IEGeneric
Generate an IR expression computing the carry flag bit of an integer addition or subtraction operation.
The carry flag is used to indicate wrap-around for unsigned operations.
a | operand a |
---|---|
b | operand b |
result | result c (may have an additional carry flag added before) |
addition | true if the carry is to be computed for "a + b", false for "a - b" |
nativeOp | indicate it CARRY / LT_U can be
used over complex xor expression |
Transform the operands of an operation into logical operands (LOG_NEQ with 0).
Generate an IR expression computing the overflow flag bit of an integer addition or subtraction operation.
The Overflow flag is used to indicate wrap-around for signed operations.
Note: The generated IR is equivalent to: MSB((a ^ c) & ~(a ^ b))
for an
addition, or MSB((a ^ c) & (a ^ b))
for a subtraction.
a | operand a |
---|---|
b | operand b |
result | result c, comprising an optional carry flag added beforehand |
addition | true if the overflow is to be computed for "a + b", false for "a - b" |
Check if the ECond predicate is a ""boolean"", i.e. a logical operation.
In case it is not, a new ECond with a boolean predicate is built (based on LOG_NEQ 0).
Check if the operands of logical OR, AND and NOT are ""booleans"", i.e. logical operations.
In case they are not, a new operation with boolean operands is built (based on LOG_NEQ 0).
Calculate the trivial complexity metric for the provided IR expression. Every IR element has a weight of 1.
Collect all EVars of an expression. If the expression is an EVar, it will be collected.
e | IR expression |
---|---|
sink | a recipient for collected EVars. Note that a set may be used to collect unique EVars, or a list may be used to collect all encountered EVars |
This method is deprecated.
use #compose(IERoutineContext, IEGeneric...)
Create a composition if the provided list of elements contains at least two entries, else return the single element.@return7
Create a composition if the provided list of elements contains at least two entries, else return the single element.
Create a composition if the provided list of elements contains at list two entries, else return the single element.
Indicates if the target expression contains any token expression
target | expression to search into |
---|---|
token | token to search |
Indicates if the generic expression invokes any undetermined kind of call (meaning
IECall
, IEJumpFar
or IEUntranslatedInstruction
)
e | IEGeneric |
---|
Recursively count (using deep equality) how many times the provided target is seen in the input expression.
e | expression to be examined |
---|---|
target | target |
Recursively count (using deep equality) how many times each of the provided targets is seen in the input expression.
e | expression to be examined |
---|---|
targets | targets |
acounts | output counts, the array size must match target's, and counts must be initially set to 0 |
Collect sub-expressions of the input expression and return the cardinal of that collection.
Simply calls getSubExpressions(List)
. Not recursive!
Create a conversion operation: an integer truncation, integer extension (zero or signed), float truncation or extension, float-to-int and int-to-float conversion.
convOperator | one of for which isConversion() returns true (eg,
CAST , CAST_S ,
FP2FP , FP2INT ,
INT2FP ) |
---|---|
src | operand to be extended, truncated, or converted |
dstSize | resulting bitsize |
Create a resize operation operation: truncation, zero-extension, or sign-extension.
src | the source to be extended (dstSize > srcSize) or truncated (dstSize < srcSize) |
---|---|
dstSize | the destination size; should be different than the source's |
signed | for extensions, else N/A |
Determine the number of stacks slots used by invoking a method having the provided prototype and an optional list of additional arguments.
varArgTypes | optional; the prototype MUST be marked VarArg for this to not be disregarded |
---|
Determine the number of stack slots filled out when a routine with the provided prototype returns.
inputStackSlotCount | the number of stack slots used for input (arguments); depending on the calling convention specified in the prototype, this value may be needed in order to calculate the count correctly |
---|
Alias for divS(IEGeneric, IEGeneric)
/ divU(IEGeneric, IEGeneric)
Dump an IR-CFG to a Graphviz dot
file in the user's temporary folder.
cfg | CFG |
---|---|
filename | filename (the ".dot" extension will be appended if necessary) |
title | optional title or header string |
Dump an IR-CFG to a Graphviz dot
file in the user's temporary folder.
cfg | CFG |
---|---|
filename | filename (the ".dot" extension will be appended if necessary) |
Evaluate an immediate to a 32-bit positive int. Apply Integer positive mask is greater than
MAX_VALUE
.
Call/PC-assign expansion: augment the size to at least 2, to accommodate splitting:
- if an EReturn is to be inserted (tail-calls) in lieu of a ECall
- if a raw PC-assign cannot be converted to a single EJumpFar
ctx | routine context |
---|---|
alsoExpandPCAssign | if true, PC-assigns will also be expanded; else, only ECalls are expanded |
Expand the size
of a statement.
CAREFUL! This method can modify the structure of the CFG (block order, block count, etc.).
Expand the sizes
of a collection of statements.
CAREFUL! This method can modify the structure of the CFG (block order, block count, etc.).
Operation Math#abs(float, float) applied to IEGeneric
Operation max(float, float)
applied to IEGeneric
Operation min(float, float)
applied to IEGeneric
Format an IR-CFG.
ectx | routine context |
---|
Format an IR-CFG.
ectx | routine context |
---|
Retrieve the list of input types, by examining the provided prototype and optional list of additional arguments.
varArgTypes | optional; the prototype MUST be marked VarArg for this to not be disregarded |
---|
Retrieve the destination of an IEAssign
(or null if is not an assignment).
Retrieve the source of an IEAssign
(or null if is not an assignment).
Retrieve all the parents of a value. The search is done by reference.
expression | expression to search into. |
---|---|
value | value to be searched. |
Check if the composition is a sign-extension of a base expression, and if so, provide the base expression.
e | expression to test that should be a signExtend |
---|
Check if the composition of both expressions make up a sign-extension, and if so, provide the base expression.
if the input expression is as such: COMPOSE(base, MSB(base) ? -1: 0)
, then return:
base
base | candidate base (i.e., base we expect to retrieve) |
---|---|
extend | candidate sign-extension expression, extending base |
Check if an IR expression looks like a sign-extension operation, and if so, provide the base expression.
Collect the sub-expressions of an IRE. Simply calls
getSubExpressions(List)
. Not recursive!
Checks if an IR routine contains only basic blocks with one parent and one child (no merge or disjunction of control-flow).
Determine if an IR expression is side-effect free.
This method is taking a liberal approach to side-effects: Side effects include invocations to other routines determined to be non side-effect-free, voluntarily throwing an exception, or performing a memory-access that will trigger an exception.
The opposite of hasSideEffect(IEGeneric)
.
Determine if the provided IR expression embeds no amount at all of type information.
Determine if the provided IR expression embeds some type information. Note that the sub-expressions are not examined.
Create an arbitrary-long immediate.
val | big-endian bytes of the value |
---|
Create an arbitrary-long immediate.
val | string representation of the integer immediate |
---|
Create an arbitrary-long immediate.
val | value |
---|
Check that an IRE is assigned in a basic block.
This method does not rely on data flow analysis; it simply searches for an assignment to the given IRE.
Verify that an IRE is a single-bit immediate set to 1 (technically, -1).
Verify that an IRE is a single-bit immediate set to 0.
""Boolean"" comparable operation (eq/neq and all greater/lesser comparisons)
e | IR expression |
---|
Verify that the provided immediate is a legal signed value if it were to be treated as a signed integer of `checkedBitsize`.
Examples:
the 64-bit value 0x00000000_07FFFFFFF is legal if treated as a 32-bit signed immediate the 64-bit value 0xFFFFFFFF_FFFFE0000 is legal if treated as a 32-bit signed immediate the 64-bit value 0x00000000_87FFFFFFF is ILLEGAL if treated as a 32-bit signed immediate the 64-bit value 0x00100000_000000012 is ILLEGAL if treated as a 32-bit signed immediate the 64-bit value 0xFFFF00FF_FFFFE0000 is ILLEGAL if treated as a 32-bit signed immediate
Verify that the provided immediate is a legal unsigned value if it were to be treated as an unsigned integer of `checkedBitsize`.
Determine if the IRE is an EImm or a slice or composition of immediates.
Determine if the expression is equivalent to an EImm that can be read as a long
primitive.
e | expression |
---|
Determine if the expression is equivalent to an EImm that can be read as a long
primitive.
e | expression |
---|
""Boolean"" operation (and, or, not, eq/neq and all greater/lesser comparisons)
e | IR expression |
---|
Determine if the expression is an EImm that can be read as a long
primitive.
e | expression |
---|
Determine if the expression is an EImm that can be read as a long
primitive.
e | expression |
---|
Verify that an IRE is an immediate holding the value -1.
As per IEEE 754-1985 floating-point standard, is NaN a number which exponent is filled with ones and a non-zero number in the mantissa
Indicate if p == !p2. Search for reversed operator as well as mirrored predicate. Do not consider NOT operations.
p | reference predicate |
---|---|
p2 | predicate to test |
Verify that an IRE is an immediate holding 1.
IMPORTANT: i1:1 will fail the test since it is equal to -1. Consider using
isBitOne(IEGeneric)
or isMinusOne(IEGeneric)
instead.
Determine if the IEGeneric
is an IEOperation
. Use when e can be null,
otherwise prefer native isOperation(OperationType)
e | IR expression |
---|
e != null && e.IsOperation(optype)
Determine if the IEGeneric
is an IEOperation
. Use when e can be null,
otherwise prefer native isOperation(OperationType)
e | IR expression |
---|
e != null && e.IsOperation(optypes)
Determine if the provided statement is a PC-assign: PC = ...
stm | a statement |
---|
Determine if the provided statement is a SP-assign: SP = ...
or
SP[slice] = ...
.
stm | a statement |
---|
Determine if the provided statement is assigning the stack pointer or the program counter.
Combines isSPAssign(IEStatement)
isPCAssign(IEStatement)
in a single
efficient call.
stm | a statement |
---|
Logical operations that should have logical operands (and, or, not)
Verify that an IRE is a Zero representation (EImm(0) or ESlice(0, x, x))
Determine if a composition looks like a sign-extension operation.
Create a bit mask, eg mask(16, 4) will create the mask: b0000000000001111
maskbits | must be less than or equal to `bitsize` |
---|
Create a bit mask, eg mask(16, 1, 5) will create the mask: b0000000000011110
maskbegin | start bit of the mask, inclusive |
---|---|
maskend | end bit of the mask, exclusive |
Operation max(int, int)
applied to IEGeneric
Operation min(int, int)
applied to IEGeneric
Generates the value -1, ie an EImm filled with ones.
bitsize | Bitsize of the EImm |
---|
Generates the value 1L with defined bitsize. Do not mistake #one(ERoutineContext, int) for #ones(ERoutineContext, int)
bitsize | Bitsize of the EImm |
---|
Determine if type `b` can be implicitly converted to type `a`, without a cast.
Apply a list of IEStatements to user targets, resolving expression starting from last
IEStatement
to first. If any error occur (something can not be translated for
example), this method returns false.
As an example:
r = {R0 = 7; R0 = R0 + 4; R1 = 8} targets = [R0, R1] i = 2 => targets = [R0, 8] i = 1 => targets = [R0+4, 8] i = 0 => targets = [11, 8] return true
If all the provided expressions have the same bitsize, return it. Null elements are considered invalid and will result in a failure (the method will return 0).
elts | a list of IRE |
---|
If all the provided expressions have the same bitsize, return it. Null elements are ignored.
elts | a list of IRE |
---|
Sign-extend operation IRE.
dstSize | must be greater or equal than src's size |
---|
Truncate operation IRE.
dstSize | must be less or equal than src's size |
---|
Verify an IR-CFG. This method relies on the ECFGVerifier and throws on error.
cfg | IR graph |
---|
Verify an IR-CFG. This method relies on the ECFGVerifier and throws on error.
ctx | IR context |
---|
Generates the value 0 with defined bitsize.
bitsize | Bitsize of the EImm |
---|
Zero-extend operation IRE.
dstSize | must be greater or equal than src's size |
---|