Interface IEImm
- All Superinterfaces:
IEGeneric
,IInstructionOperand
A terminal IR representing an immediate value. This IR object is holding a sequence of bits whose
interpretation can be:
- a 2-complement arithmetic integer of any length
- a single-precision 32-bit IEEE-754 floating-point value
- a double-precision 64-bit IEEE-754 floating-point value
- a 2-complement arithmetic integer of any length
- a single-precision 32-bit IEEE-754 floating-point value
- a double-precision 64-bit IEEE-754 floating-point value
-
Method Summary
Modifier and TypeMethodDescriptionPerform an addition.Perform a binary-and operation.int
Retrieve the effective length in bits, i.e._clearbit
(int pos) Reset a given bit to 0.int
Perform a signed operand comparison.int
Perform an unsigned operand comparison.Perform a signed division.Perform an unsigned division.Add this IEEE-754 float to another float immediate and return the result.Compare this IEEE-754 float with another float immediate and return 0, +1, -1 depending on the result of the comparison.Divide this IEEE-754 float by another float immediate and return the result.Multiply this IEEE-754 float to another float immediate and return the result.Subtract the IEEE-754 float parameter from this float immediate and return the result.boolean
Determine whether this immediate (treated as an unsigned integer) is a power of 2._log2()
Perform an exact log2 on this immediate treated as an unsigned integer.Perform a (truncated) multiplication._neg()
Perform a negation._not()
Perform a binary-not operation.Perform a binary-or operation._pow
(int exponent) Perform an exponentiation.Perform a signed remainder (modulo) operation.Perform an unsigned remainder (modulo) operation._rol
(int cnt) Perform a left-rotate operation._ror
(int cnt) Perform a right-rotate operation._sar
(int cnt) Perform an arithmetic right-shift operation (sign bit is maintained)._setbit
(int pos) Set a given bit to 1._shl
(int cnt) Perform a left-shift operation._shr
(int cnt) Perform a regular right-shift operation.int
_signum()
Retrieve the sign number of this immediate: 0 if 0, -1 if negative, +1 if positive.Perform a subtraction.boolean
_testbit
(int pos) Test if a given bit is set.Perform a binary-xor operation.boolean
boolean
boolean
Determine if this value can fit on a 64-bit long primitive.boolean
boolean
Determine if this value can fit as an unsigned long on a 64-bit long primitive (ie, with the MSB is set to 0).The resulting copy may not be mutable.Create a mutable copy of this immediate.Create a mutable copy of this immediate and assign it a type.expand
(int bits) Expand (zero-extension) this immediate.Retrieve the custom AST element that will be used when generating C code, if one was set.getGroup()
Determine the current group for the immediate: integer or float.Get this immediate as an unsigned big integer value.getValue()
Get this immediate as a big integer value (signed).long
Get the immediate value as a primitive long, preferably unsigned.double
long
Get the immediate value as a signed primitive long.float
long
Get the immediate value as an unsigned, zero-extended primitive long.boolean
Determine if this immediate is mutable.boolean
isOnes()
Determine whether this immediate has all its bits set to 1.boolean
boolean
isZero()
Determine whether this immediate has all its bits set to 0.Normalize this immediate bvy generating an immediate whose internal representation better matches the type.boolean
setCustomAST
(ICElement customAST) Set a custom AST element to be used when generating C code.signExtend
(int newBitsize) Sign extend the currentIEGeneric
.Format this immediate as an unsigned hexadecimal string.truncate
(int bits) Truncate this immediate or sign-extend it.zeroExtend
(int newBitsize) Zero extend the currentIEGeneric
Methods inherited from interface com.pnfsoftware.jeb.core.units.code.asm.decompiler.ir.IEGeneric
accessesMemory, addFlags, asCompose, asCond, asGroup, asGroupElt, asImm, asMem, asOperation, asRange, asSlice, asStatement, asVar, bit, collectSubExpressions, copyProperties, countSuccessiveBits, equalsEx, evaluate, evaluateAddress, evaluateUnsignedLong, examine, find, findByType, findByType, findParent, findParent, generateC, getBitsize, getDefinedOrUsedAsDestination, getExplicitlyUsed, getExplicitlyUsed, getFlags, getPriority, getSafeType, getType, getUsed, getUsed, half, hasFlags, isCompose, isCond, isGroup, isGroupElt, isImm, isMem, isOperation, isOperation, isOperation, isOperation, isRange, isSlice, isSlice, isStatement, isVar, isVar, leftShift, leftShift, lsb, msb, part, removeFlags, replaceSubExpression, replaceVar, rightShift, rightShift, safelyType, setFlags, setType, setType, setType, slice, slice, slice, topHalf, updateTypes, verify, visitDepthPost, visitDepthPost, visitDepthPost, visitDepthPre, visitDepthPre, visitDepthPre
Methods inherited from interface com.pnfsoftware.jeb.core.units.code.IInstructionOperand
format
-
Method Details
-
isMutable
boolean isMutable()Determine if this immediate is mutable. By default, they are not. UseduplicateWithType(IWildcardType)
to create a mutable immediate to which a type and custom AST element can be assigned.- Returns:
-
getGroup
IWildcardType.Group getGroup()Determine the current group for the immediate: integer or float. Do not confuse withIEGeneric.getType()
, although the group can be used to infer an appropriate type.- Returns:
-
duplicate
IEImm duplicate()The resulting copy may not be mutable. It will be mutable IFF this object is mutable itself. To ensure that the copy is mutable, useduplicateWithType(IWildcardType)
orduplicateToMutable()
. -
duplicateToMutable
IEImm duplicateToMutable()Create a mutable copy of this immediate. Those immediates can be assignedtypes
and custom AST elements.- Returns:
- a non-factory controlled, mutable immediate
-
duplicateWithType
Create a mutable copy of this immediate and assign it a type. Those immediates can be assignedtypes
and custom AST elements..- Parameters:
type
- the initial type, may be null- Returns:
- a non-factory controlled, mutable immediate
-
setCustomAST
Set a custom AST element to be used when generating C code. Reserved formutable
elements.- Parameters:
customAST
-- Returns:
-
getCustomAST
ICElement getCustomAST()Retrieve the custom AST element that will be used when generating C code, if one was set.- Returns:
- an AST element, possibly null
-
normalize
IEImm normalize()Normalize this immediate bvy generating an immediate whose internal representation better matches the type. If this immediate is not typed, it cannot be normalized. If the immediate is already normalized or cannot be normalized, this method returns null.- Returns:
- a new (normalized) immediate, or null if the imm is already normalized or cannot be normalized
-
toHexString
String toHexString()Format this immediate as an unsigned hexadecimal string.- Returns:
-
canReadAsLong
boolean canReadAsLong()Determine if this value can fit on a 64-bit long primitive.- Returns:
-
getValueAsLong
long getValueAsLong()Get the immediate value as a signed primitive long. Will raise if the value does not fit in [LONG_MIN, LONG_MAX] range (64 bits).- Returns:
-
canReadAsUnsignedLong
boolean canReadAsUnsignedLong()Determine if this value can fit as an unsigned long on a 64-bit long primitive (ie, with the MSB is set to 0).- Returns:
-
getValueAsUnsignedLong
long getValueAsUnsignedLong()Get the immediate value as an unsigned, zero-extended primitive long. Will raise if the value does not fit within [0, LONG_MAX] range (63 bits).getValueAsLong()
is a safer method.- Returns:
-
canReadAsAddress
boolean canReadAsAddress()- Returns:
-
getValueAsAddress
long getValueAsAddress()Get the immediate value as a primitive long, preferably unsigned. Will raise if the value does not fit on 64-bits.- Returns:
-
isStringLiteral
boolean isStringLiteral()- Returns:
-
getStringLiteral
String getStringLiteral()- Returns:
-
isZero
boolean isZero()Determine whether this immediate has all its bits set to 0.Note: do not mix this up with a zero-value equality check. That works if the underlying value is to be interpreted as an 2-complement integer, but may not work if the imm is to be understood as an ieee754 float value.
- Returns:
-
isOnes
boolean isOnes()Determine whether this immediate has all its bits set to 1.- Returns:
-
zeroExtend
Description copied from interface:IEGeneric
Zero extend the currentIEGeneric
- Specified by:
zeroExtend
in interfaceIEGeneric
- Parameters:
newBitsize
- must be superior toIEGeneric.getBitsize()
-
signExtend
Description copied from interface:IEGeneric
Sign extend the currentIEGeneric
. This method will create a validIEGeneric
(meaningIEGeneric
will not have duplicates id - in particular, in the form C(x, x.msb()?ones():zeros()) where x will be present in base value and msb predicate)- Specified by:
signExtend
in interfaceIEGeneric
- Parameters:
newBitsize
- must be superior toIEGeneric.getBitsize()
-
getValue
BigInteger getValue()Get this immediate as a big integer value (signed).- Returns:
-
getUnsignedValue
BigInteger getUnsignedValue()Get this immediate as an unsigned big integer value.- Returns:
-
truncate
Truncate this immediate or sign-extend it. If bits if less than the bitsize of this immediate, it is truncated. If bits is greater than the bitsize of this immediate, then the resulting value is sign-extended.- Parameters:
bits
-- Returns:
-
expand
Expand (zero-extension) this immediate. If bits if less than the bitsize of this immediate, this method is the same as truncate. If bits is greater than the bitsize of this immediate, then the resulting value is zero-extended.- Parameters:
bits
-- Returns:
-
_bitlength
int _bitlength()Retrieve the effective length in bits, i.e. the minimal number of bits required to store this immediate.- Returns:
-
_signum
int _signum()Retrieve the sign number of this immediate: 0 if 0, -1 if negative, +1 if positive.- Returns:
-
_neg
IEImm _neg()Perform a negation.- Returns:
-
_add
Perform an addition.- Parameters:
val
-- Returns:
-
_sub
Perform a subtraction.- Parameters:
val
-- Returns:
-
_mul
Perform a (truncated) multiplication.- Parameters:
val
-- Returns:
-
_div
Perform a signed division.- Parameters:
val
-- Returns:
-
_divU
Perform an unsigned division.- Parameters:
val
-- Returns:
-
_rem
Perform a signed remainder (modulo) operation.- Parameters:
val
-- Returns:
-
_remU
Perform an unsigned remainder (modulo) operation.- Parameters:
val
-- Returns:
-
_not
IEImm _not()Perform a binary-not operation.- Returns:
-
_and
Perform a binary-and operation.- Parameters:
val
-- Returns:
-
_or
Perform a binary-or operation.- Parameters:
val
-- Returns:
-
_xor
Perform a binary-xor operation.- Parameters:
val
-- Returns:
-
_testbit
boolean _testbit(int pos) Test if a given bit is set.- Parameters:
pos
-- Returns:
- true if set, false if unset
-
_setbit
Set a given bit to 1.- Parameters:
pos
-- Returns:
-
_clearbit
Reset a given bit to 0.- Parameters:
pos
-- Returns:
-
_shl
Perform a left-shift operation. The effective count is computed modulo-positiveIEGeneric.getBitsize()
.- Parameters:
cnt
-- Returns:
-
_shr
Perform a regular right-shift operation. The effective count is computed modulo-positiveIEGeneric.getBitsize()
.- Parameters:
cnt
-- Returns:
-
_sar
Perform an arithmetic right-shift operation (sign bit is maintained). The effective count is computed modulo-positiveIEGeneric.getBitsize()
.- Parameters:
cnt
-- Returns:
-
_rol
Perform a left-rotate operation.- Parameters:
cnt
-- Returns:
-
_ror
Perform a right-rotate operation.- Parameters:
cnt
-- Returns:
-
_pow
Perform an exponentiation.- Parameters:
exponent
- must be positive or zero- Returns:
-
_cmp
Perform a signed operand comparison.- Parameters:
val
-- Returns:
- 0, 1, or -1
-
_cmpU
Perform an unsigned operand comparison.- Parameters:
val
-- Returns:
- 0, 1, or -1
-
_isPowerOf2
boolean _isPowerOf2()Determine whether this immediate (treated as an unsigned integer) is a power of 2.- Returns:
-
_log2
Integer _log2()Perform an exact log2 on this immediate treated as an unsigned integer. If the immediate is not a power of 2, a null value is returned.- Returns:
- a non-null log2 of this immediate
-
canReadAsSingleFloat
boolean canReadAsSingleFloat() -
getValueAsSingleFloat
float getValueAsSingleFloat() -
canReadAsDoubleFloat
boolean canReadAsDoubleFloat() -
getValueAsDoubleFloat
double getValueAsDoubleFloat() -
_fadd
Add this IEEE-754 float to another float immediate and return the result.- Parameters:
val
-- Returns:
-
_fsub
Subtract the IEEE-754 float parameter from this float immediate and return the result.- Parameters:
val
-- Returns:
-
_fmul
Multiply this IEEE-754 float to another float immediate and return the result.- Parameters:
val
-- Returns:
-
_fdiv
Divide this IEEE-754 float by another float immediate and return the result.- Parameters:
val
-- Returns:
-
_fcmp
Compare this IEEE-754 float with another float immediate and return 0, +1, -1 depending on the result of the comparison. Comparisons are ordered. If any of the operands are unordered, null is returned.- Parameters:
val
-- Returns:
-