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
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());
}