mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 10:19:23 +02:00
GP-0 Added ability to ignore specific pcode test failures. Corrected
BigInteger to BigFloat conversion used by INT2FLOAT emulation op.
This commit is contained in:
parent
a3ca5a67e1
commit
f56e922d43
9 changed files with 284 additions and 105 deletions
|
@ -60,8 +60,7 @@ public strictfp class BigFloat implements Comparable<BigFloat> {
|
|||
* @param scale value's scale (signed value with the biased range of expbits)
|
||||
* @throws IllegalArgumentException if invalid unscaled and scale values are specified based upon the fracbits and expbits values.
|
||||
*/
|
||||
BigFloat(int fracbits, int expbits, FloatKind kind, int sign, BigInteger unscaled,
|
||||
int scale) {
|
||||
BigFloat(int fracbits, int expbits, FloatKind kind, int sign, BigInteger unscaled, int scale) {
|
||||
this.fracbits = fracbits;
|
||||
this.expbits = expbits;
|
||||
this.kind = kind;
|
||||
|
@ -151,21 +150,6 @@ public strictfp class BigFloat implements Comparable<BigFloat> {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the BigFloat with the given number of bits representing the given BigInteger.
|
||||
*
|
||||
* @param fracbits number of fractional bits
|
||||
* @param expbits number of bits in the exponent
|
||||
* @param i an integer
|
||||
* @return a BigFloat representing i
|
||||
*/
|
||||
public static BigFloat valueOf(int fracbits, int expbits, BigInteger i) {
|
||||
BigFloat f = new BigFloat(fracbits, expbits, FloatKind.FINITE, i.signum() >= 0 ? +1 : -1,
|
||||
i.abs(), fracbits);
|
||||
f.scaleUpTo(fracbits + 1);
|
||||
return f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the BigFloat with the given number of bits representing zero.
|
||||
*
|
||||
|
|
|
@ -897,7 +897,7 @@ public strictfp class FloatFormat {
|
|||
else {
|
||||
a = Utils.convertToUnsignedValue(a, sizein);
|
||||
}
|
||||
return getEncoding(BigFloat.valueOf(frac_size, exp_size, a));
|
||||
return getEncoding(valueOf(a));
|
||||
}
|
||||
|
||||
public long opFloat2Float(long a, FloatFormat outformat) { // convert between floating
|
||||
|
@ -967,5 +967,28 @@ public strictfp class FloatFormat {
|
|||
fa.round();
|
||||
return getEncoding(fa);
|
||||
}
|
||||
|
||||
public BigFloat valueOf(BigInteger value) {
|
||||
|
||||
BigInteger unscaled = value;
|
||||
int sign = 1;
|
||||
if (unscaled.signum() < 0) {
|
||||
sign = -1;
|
||||
unscaled = unscaled.negate();
|
||||
}
|
||||
|
||||
int ulen = unscaled.bitLength();
|
||||
int shift = frac_size + 1 - ulen;
|
||||
|
||||
unscaled = unscaled.shiftLeft(shift);
|
||||
|
||||
int scale = frac_size - shift;
|
||||
|
||||
if (scale > bias) {
|
||||
return BigFloat.infinity(frac_size, exp_size, sign);
|
||||
}
|
||||
|
||||
return new BigFloat(frac_size, exp_size, FloatKind.FINITE, sign, unscaled, scale);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue