GCC Code Coverage Report
Directory: . Exec Total Coverage
File: build-coverage/src/options/bv_options.cpp Lines: 18 59 30.5 %
Date: 2021-11-07 Branches: 23 97 23.7 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Mathias Preiner, Aina Niemetz
4
 *
5
 * This file is part of the cvc5 project.
6
 *
7
 * Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
8
 * in the top-level source directory and their institutional affiliations.
9
 * All rights reserved.  See the file COPYING in the top-level source
10
 * directory for licensing information.
11
 * ****************************************************************************
12
 *
13
 * Option template for option modules.
14
 *
15
 * For each <module>_options.toml configuration file, mkoptions.py
16
 * expands this template and generates a <module>_options.cpp file.
17
 */
18
#include "options/bv_options.h"
19
20
#include <iostream>
21
22
#include "base/check.h"
23
#include "options/option_exception.h"
24
25
namespace cvc5::options {
26
27
// clang-format off
28
std::ostream& operator<<(std::ostream& os, BitblastMode mode)
29
{
30
  switch(mode)
31
  {
32
    case BitblastMode::LAZY: return os << "lazy";
33
    case BitblastMode::EAGER: return os << "eager";
34
    default: Unreachable();
35
  }
36
  return os;
37
}
38
39
BitblastMode stringToBitblastMode(const std::string& optarg)
39
{
40
39
  if (optarg == "lazy") return BitblastMode::LAZY;
41
37
  else if (optarg == "eager") return BitblastMode::EAGER;
42
  else if (optarg == "help")
43
  {
44
    std::cerr << R"FOOBAR(
45
  Bit-blasting modes.
46
Available modes for --bitblast are:
47
+ lazy (default)
48
  Separate Boolean structure and term reasoning between the core SAT solver and
49
  the bit-vector SAT solver.
50
+ eager
51
  Bitblast eagerly to bit-vector SAT solver.
52
)FOOBAR";
53
    std::exit(1);
54
  }
55
  throw OptionException(std::string("unknown option for --bitblast: `") +
56
                        optarg + "'.  Try --bitblast=help.");
57
}
58
std::ostream& operator<<(std::ostream& os, BoolToBVMode mode)
59
{
60
  switch(mode)
61
  {
62
    case BoolToBVMode::ALL: return os << "all";
63
    case BoolToBVMode::ITE: return os << "ite";
64
    case BoolToBVMode::OFF: return os << "off";
65
    default: Unreachable();
66
  }
67
  return os;
68
}
69
12
BoolToBVMode stringToBoolToBVMode(const std::string& optarg)
70
{
71
12
  if (optarg == "all") return BoolToBVMode::ALL;
72
4
  else if (optarg == "ite") return BoolToBVMode::ITE;
73
  else if (optarg == "off") return BoolToBVMode::OFF;
74
  else if (optarg == "help")
75
  {
76
    std::cerr << R"FOOBAR(
77
  BoolToBV preprocessing pass modes.
78
Available modes for --bool-to-bv are:
79
+ all
80
  Force all booleans to be bit-vectors of width one except at the top level.
81
  Most aggressive mode.
82
+ ite
83
  Try to turn ITEs into BITVECTOR_ITE when possible. It can fail per-formula if
84
  not all sub-formulas can be turned to bit-vectors.
85
+ off (default)
86
  Don't push any booleans to width one bit-vectors.
87
)FOOBAR";
88
    std::exit(1);
89
  }
90
  throw OptionException(std::string("unknown option for --bool-to-bv: `") +
91
                        optarg + "'.  Try --bool-to-bv=help.");
92
}
93
std::ostream& operator<<(std::ostream& os, SatSolverMode mode)
94
{
95
  switch(mode)
96
  {
97
    case SatSolverMode::MINISAT: return os << "minisat";
98
    case SatSolverMode::KISSAT: return os << "kissat";
99
    case SatSolverMode::CADICAL: return os << "cadical";
100
    case SatSolverMode::CRYPTOMINISAT: return os << "cryptominisat";
101
    default: Unreachable();
102
  }
103
  return os;
104
}
105
18
SatSolverMode stringToSatSolverMode(const std::string& optarg)
106
{
107
18
  if (optarg == "minisat") return SatSolverMode::MINISAT;
108
16
  else if (optarg == "kissat") return SatSolverMode::KISSAT;
109
16
  else if (optarg == "cadical") return SatSolverMode::CADICAL;
110
12
  else if (optarg == "cryptominisat") return SatSolverMode::CRYPTOMINISAT;
111
2
  else if (optarg == "help")
112
  {
113
    std::cerr << R"FOOBAR(
114
  SAT solver for bit-blasting backend.
115
Available modes for --bv-sat-solver are:
116
)FOOBAR";
117
    std::exit(1);
118
  }
119
4
  throw OptionException(std::string("unknown option for --bv-sat-solver: `") +
120
6
                        optarg + "'.  Try --bv-sat-solver=help.");
121
}
122
std::ostream& operator<<(std::ostream& os, BVSolver mode)
123
{
124
  switch(mode)
125
  {
126
    case BVSolver::BITBLAST_INTERNAL: return os << "bitblast-internal";
127
    case BVSolver::BITBLAST: return os << "bitblast";
128
    default: Unreachable();
129
  }
130
  return os;
131
}
132
44
BVSolver stringToBVSolver(const std::string& optarg)
133
{
134
44
  if (optarg == "bitblast-internal") return BVSolver::BITBLAST_INTERNAL;
135
24
  else if (optarg == "bitblast") return BVSolver::BITBLAST;
136
  else if (optarg == "help")
137
  {
138
    std::cerr << R"FOOBAR(
139
  Bit-vector solvers.
140
Available modes for --bv-solver are:
141
+ bitblast-internal
142
  Enables bitblasting to internal SAT solver with proof support.
143
+ bitblast (default)
144
  Enables bitblasting solver.
145
)FOOBAR";
146
    std::exit(1);
147
  }
148
  throw OptionException(std::string("unknown option for --bv-solver: `") +
149
                        optarg + "'.  Try --bv-solver=help.");
150
}
151
// clang-format on
152
153
31137
}  // namespace cvc5::options