Skip to content

Commit 52f7a93

Browse files
author
BaierD
committed
Replace generic implementation of fromIeeeBitvectorImpl() with CVC5 native implementation
1 parent 8e79a61 commit 52f7a93

File tree

1 file changed

+10
-21
lines changed

1 file changed

+10
-21
lines changed

src/org/sosy_lab/java_smt/solvers/cvc5/CVC5FloatingPointFormulaManager.java

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -408,29 +408,18 @@ protected Term isNegative(Term pParam) {
408408
}
409409

410410
@Override
411-
protected Term fromIeeeBitvectorImpl(Term bitvector, FloatingPointType pTargetType) {
412-
int mantissaSize = pTargetType.getMantissaSize();
413-
int exponentSize = pTargetType.getExponentSize();
414-
int size = pTargetType.getTotalSize();
415-
assert size == mantissaSize + exponentSize + 1;
416-
417-
Op signExtract;
418-
Op exponentExtract;
419-
Op mantissaExtract;
411+
protected Term fromIeeeBitvectorImpl(Term pBitvector, FloatingPointType pTargetType) {
420412
try {
421-
signExtract = termManager.mkOp(Kind.BITVECTOR_EXTRACT, size - 1, size - 1);
422-
exponentExtract = termManager.mkOp(Kind.BITVECTOR_EXTRACT, size - 2, mantissaSize);
423-
mantissaExtract = termManager.mkOp(Kind.BITVECTOR_EXTRACT, mantissaSize - 1, 0);
424-
} catch (CVC5ApiException e) {
425-
throw new IllegalArgumentException(
426-
"You tried creating a invalid bitvector extract in term " + bitvector + ".", e);
413+
return termManager.mkTerm(
414+
termManager.mkOp(
415+
Kind.FLOATINGPOINT_TO_FP_FROM_IEEE_BV,
416+
pTargetType.getExponentSize(),
417+
pTargetType.getMantissaSize() + 1), // add sign bit
418+
pBitvector);
419+
} catch (CVC5ApiException pE) {
420+
// This seems to only be thrown for wrong exponent and mantissa sizes
421+
throw new RuntimeException(pE);
427422
}
428-
429-
Term sign = termManager.mkTerm(signExtract, bitvector);
430-
Term exponent = termManager.mkTerm(exponentExtract, bitvector);
431-
Term mantissa = termManager.mkTerm(mantissaExtract, bitvector);
432-
433-
return termManager.mkTerm(Kind.FLOATINGPOINT_FP, sign, exponent, mantissa);
434423
}
435424

436425
@Override

0 commit comments

Comments
 (0)