summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAina Niemetz <aina.niemetz@gmail.com>2021-05-03 18:00:03 -0700
committerGitHub <noreply@github.com>2021-05-04 01:00:03 +0000
commitebcddc25124fe3f92df314c13b3d690b46dbd1e8 (patch)
treec0cb9441b7123801e40d7426d1d0b7de81e71892
parentc8c7a075428e6193dee86e57a9ecb8af11af270c (diff)
FP: Move type check from expandDefinitions. (#6479)
-rw-r--r--src/theory/fp/fp_expand_defs.cpp43
-rw-r--r--src/theory/fp/theory_fp_type_rules.cpp31
2 files changed, 38 insertions, 36 deletions
diff --git a/src/theory/fp/fp_expand_defs.cpp b/src/theory/fp/fp_expand_defs.cpp
index 34cc1ed5d..1fc893a30 100644
--- a/src/theory/fp/fp_expand_defs.cpp
+++ b/src/theory/fp/fp_expand_defs.cpp
@@ -40,37 +40,26 @@ Node removeToFPGeneric(TNode node)
op = nm->mkConst(FloatingPointToFPIEEEBitVector(info));
return nm->mkNode(op, node[0]);
}
+ Assert(children == 2);
+ Assert(node[0].getType().isRoundingMode());
+
+ TypeNode t = node[1].getType();
+
+ if (t.isFloatingPoint())
+ {
+ op = nm->mkConst(FloatingPointToFPFloatingPoint(info));
+ }
+ else if (t.isReal())
+ {
+ op = nm->mkConst(FloatingPointToFPReal(info));
+ }
else
{
- Assert(children == 2);
- Assert(node[0].getType().isRoundingMode());
-
- TypeNode t = node[1].getType();
-
- if (t.isFloatingPoint())
- {
- op = nm->mkConst(FloatingPointToFPFloatingPoint(info));
- }
- else if (t.isReal())
- {
- op = nm->mkConst(FloatingPointToFPReal(info));
- }
- else if (t.isBitVector())
- {
- op = nm->mkConst(FloatingPointToFPSignedBitVector(info));
- }
- else
- {
- throw TypeCheckingExceptionPrivate(
- node,
- "cannot rewrite to_fp generic due to incorrect type of second "
- "argument");
- }
-
- return nm->mkNode(op, node[0], node[1]);
+ Assert(t.isBitVector());
+ op = nm->mkConst(FloatingPointToFPSignedBitVector(info));
}
- Unreachable() << "to_fp generic not rewritten";
+ return nm->mkNode(op, node[0], node[1]);
}
} // namespace removeToFPGeneric
diff --git a/src/theory/fp/theory_fp_type_rules.cpp b/src/theory/fp/theory_fp_type_rules.cpp
index 6beba19ad..5951decd4 100644
--- a/src/theory/fp/theory_fp_type_rules.cpp
+++ b/src/theory/fp/theory_fp_type_rules.cpp
@@ -431,18 +431,31 @@ TypeNode FloatingPointToFPGenericTypeRule::computeType(NodeManager* nodeManager,
if (check)
{
- /* As this is a generic kind intended only for parsing,
- * the checking here is light. For better checking, use
- * expandDefinitions first.
- */
-
- size_t children = n.getNumChildren();
- for (size_t i = 0; i < children; ++i)
+ uint32_t nchildren = n.getNumChildren();
+ if (nchildren == 1)
+ {
+ if (!n[0].getType(check).isBitVector())
+ {
+ throw TypeCheckingExceptionPrivate(
+ n, "first argument must be a bit-vector");
+ }
+ }
+ else
{
- n[i].getType(check);
+ Assert(nchildren == 2);
+ if (!n[0].getType(check).isRoundingMode())
+ {
+ throw TypeCheckingExceptionPrivate(
+ n, "first argument must be a roundingmode");
+ }
+ TypeNode tn = n[1].getType(check);
+ if (!tn.isBitVector() && !tn.isFloatingPoint() && !tn.isReal())
+ {
+ throw TypeCheckingExceptionPrivate(
+ n, "second argument must be a bit-vector, floating-point or Real");
+ }
}
}
-
return nodeManager->mkFloatingPointType(info.getSize());
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback