Convert INT_MULT and shift forms into INT_DIV or INT_SDIV.
The unsigned and signed variants are:
sub( (zext(V)*c)>>n, 0) => V / (2^n/(c-1))
sub( (sext(V)*c)s>>n, 0) => V s/ (2^n/(c-1))
Check for INT_(S)RIGHT and/or SUBPIECE followed by INT_MULT.
Look for the forms:
sub(ext(X) * #y,#c)
or
sub(ext(X) * #y,#c) >> n
or
(ext(X) * #y) >> n
Looks for truncation/multiplication consistent with an optimized division. The truncation can come as either a SUBPIECE operation and/or right shifts. The numerand and the amount it has been extended is discovered. The extension can be, but doesn't have to be, an explicit INT_ZEXT or INT_SEXT. If the form doesn't match NULL is returned. If the Varnode holding the extended numerand matches the final operand size, it is returned, otherwise the unextended numerand is returned. The total truncation, the multiplicative constant, the numerand size, and the extension type are all passed back.
- Parameters
-
op | is the root of the expression |
n | is the reference that will hold the total number of bits of truncation |
y | will hold the multiplicative constant |
xsize | will hold the number of (non-zero) bits in the numerand |
extopc | holds whether the extension is INT_ZEXT or INT_SEXT |
- Returns
- the extended numerand if possible, or the unextended numerand, or NULL