Skip to content

Commit 53bbf95

Browse files
committed
#397: add FunctionDeclarationKind for BV_ROTATE operations
1 parent 2158c99 commit 53bbf95

File tree

6 files changed

+45
-1
lines changed

6 files changed

+45
-1
lines changed

src/org/sosy_lab/java_smt/api/FunctionDeclarationKind.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,24 @@ public enum FunctionDeclarationKind {
181181
/** Arithmetic right-shift over bitvectors (fill from left with value of first bit). */
182182
BV_ASHR,
183183

184+
/** Performs a circular left rotation on the bitvector. */
185+
BV_ROTATE_LEFT,
186+
187+
/** Performs a circular right rotation on the bitvector. */
188+
BV_ROTATE_RIGHT,
189+
190+
/**
191+
* Performs a circular left rotation on the bitvector by a specified number of positions,
192+
* determined by an integer value.
193+
*/
194+
BV_ROTATE_LEFT_BY_INT,
195+
196+
/**
197+
* Performs a circular right rotation on the bitvector by a specified number of positions,
198+
* determined by an integer value.
199+
*/
200+
BV_ROTATE_RIGHT_BY_INT,
201+
184202
/** Cast an unsigned bitvector to a floating-point number. */
185203
BV_UCASTTO_FP,
186204

src/org/sosy_lab/java_smt/solvers/bitwuzla/BitwuzlaFormulaCreator.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,16 @@ private FunctionDeclarationKind getDeclarationKind(Term term) {
305305
return FunctionDeclarationKind.FP_CASTTO_UBV;
306306
} else if (kind.equals(Kind.BV_XOR)) {
307307
return FunctionDeclarationKind.BV_XOR;
308+
} else if (kind.equals(Kind.BV_ROL)) {
309+
return FunctionDeclarationKind.BV_ROTATE_LEFT;
310+
} else if (kind.equals(Kind.BV_ROR)) {
311+
return FunctionDeclarationKind.BV_ROTATE_RIGHT;
312+
} else if (kind.equals(Kind.BV_ROLI)) {
313+
return FunctionDeclarationKind.BV_ROTATE_LEFT_BY_INT;
314+
} else if (kind.equals(Kind.BV_RORI)) {
315+
return FunctionDeclarationKind.BV_ROTATE_RIGHT_BY_INT;
308316
}
309-
throw new UnsupportedOperationException("Can not discern formula kind " + kind);
317+
return FunctionDeclarationKind.OTHER;
310318
}
311319

312320
@SuppressWarnings("unchecked")

src/org/sosy_lab/java_smt/solvers/cvc4/CVC4FormulaCreator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,8 @@ private Expr normalize(Expr operator) {
458458
.put(Kind.BITVECTOR_SHL, FunctionDeclarationKind.BV_SHL)
459459
.put(Kind.BITVECTOR_ASHR, FunctionDeclarationKind.BV_ASHR)
460460
.put(Kind.BITVECTOR_LSHR, FunctionDeclarationKind.BV_LSHR)
461+
.put(Kind.BITVECTOR_ROTATE_LEFT, FunctionDeclarationKind.BV_ROTATE_LEFT_BY_INT)
462+
.put(Kind.BITVECTOR_ROTATE_RIGHT, FunctionDeclarationKind.BV_ROTATE_RIGHT_BY_INT)
461463
.put(Kind.BITVECTOR_NOT, FunctionDeclarationKind.BV_NOT)
462464
.put(Kind.BITVECTOR_NEG, FunctionDeclarationKind.BV_NEG)
463465
.put(Kind.BITVECTOR_EXTRACT, FunctionDeclarationKind.BV_EXTRACT)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,8 @@ private Term normalize(Term operator) {
578578
.put(Kind.BITVECTOR_SHL, FunctionDeclarationKind.BV_SHL)
579579
.put(Kind.BITVECTOR_ASHR, FunctionDeclarationKind.BV_ASHR)
580580
.put(Kind.BITVECTOR_LSHR, FunctionDeclarationKind.BV_LSHR)
581+
.put(Kind.BITVECTOR_ROTATE_LEFT, FunctionDeclarationKind.BV_ROTATE_LEFT_BY_INT)
582+
.put(Kind.BITVECTOR_ROTATE_RIGHT, FunctionDeclarationKind.BV_ROTATE_RIGHT_BY_INT)
581583
// Floating-point theory
582584
.put(Kind.TO_INTEGER, FunctionDeclarationKind.FLOOR)
583585
.put(Kind.TO_REAL, FunctionDeclarationKind.TO_REAL)

src/org/sosy_lab/java_smt/solvers/mathsat5/Mathsat5FormulaCreator.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.MSAT_TAG_BV_NEG;
2424
import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.MSAT_TAG_BV_NOT;
2525
import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.MSAT_TAG_BV_OR;
26+
import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.MSAT_TAG_BV_ROL;
27+
import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.MSAT_TAG_BV_ROR;
2628
import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.MSAT_TAG_BV_SDIV;
2729
import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.MSAT_TAG_BV_SEXT;
2830
import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.MSAT_TAG_BV_SLE;
@@ -458,6 +460,10 @@ private FunctionDeclarationKind getDeclarationKind(long pF) {
458460
return FunctionDeclarationKind.BV_SIGN_EXTENSION;
459461
case MSAT_TAG_BV_ZEXT:
460462
return FunctionDeclarationKind.BV_ZERO_EXTENSION;
463+
case MSAT_TAG_BV_ROL:
464+
return FunctionDeclarationKind.BV_ROTATE_LEFT_BY_INT;
465+
case MSAT_TAG_BV_ROR:
466+
return FunctionDeclarationKind.BV_ROTATE_RIGHT_BY_INT;
461467

462468
case MSAT_TAG_FP_NEG:
463469
return FunctionDeclarationKind.FP_NEG;

src/org/sosy_lab/java_smt/solvers/z3/Z3FormulaCreator.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,14 @@ private FunctionDeclarationKind getDeclarationKind(long f) {
707707
return FunctionDeclarationKind.BV_SIGN_EXTENSION;
708708
case Z3_OP_ZERO_EXT:
709709
return FunctionDeclarationKind.BV_ZERO_EXTENSION;
710+
case Z3_OP_ROTATE_LEFT:
711+
return FunctionDeclarationKind.BV_ROTATE_LEFT_BY_INT;
712+
case Z3_OP_ROTATE_RIGHT:
713+
return FunctionDeclarationKind.BV_ROTATE_RIGHT_BY_INT;
714+
case Z3_OP_EXT_ROTATE_LEFT:
715+
return FunctionDeclarationKind.BV_ROTATE_LEFT;
716+
case Z3_OP_EXT_ROTATE_RIGHT:
717+
return FunctionDeclarationKind.BV_ROTATE_RIGHT;
710718

711719
case Z3_OP_FPA_NEG:
712720
return FunctionDeclarationKind.FP_NEG;

0 commit comments

Comments
 (0)