GCC Code Coverage Report
Directory: . Exec Total Coverage
File: build-coverage/src/options/uf_options.cpp Lines: 6 59 10.2 %
Date: 2021-08-06 Branches: 5 46 10.9 %

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/uf_options.h"
19
20
#include <iostream>
21
22
#include "base/check.h"
23
#include "options/option_exception.h"
24
25
// clang-format off
26
namespace cvc5 {
27
28
29
30
namespace options {
31
32
thread_local struct ufSymmetryBreaker__option_t ufSymmetryBreaker;
33
thread_local struct ufHo__option_t ufHo;
34
thread_local struct ufHoExt__option_t ufHoExt;
35
thread_local struct ufssAbortCardinality__option_t ufssAbortCardinality;
36
thread_local struct ufssFairness__option_t ufssFairness;
37
thread_local struct ufssFairnessMonotone__option_t ufssFairnessMonotone;
38
thread_local struct ufssTotalityLimited__option_t ufssTotalityLimited;
39
thread_local struct ufssTotalitySymBreak__option_t ufssTotalitySymBreak;
40
thread_local struct ufssMode__option_t ufssMode;
41
42
43
std::ostream& operator<<(std::ostream& os, UfssMode mode)
44
{
45
  switch(mode) {
46
    case UfssMode::NONE:
47
      return os << "UfssMode::NONE";
48
    case UfssMode::FULL:
49
      return os << "UfssMode::FULL";
50
    case UfssMode::NO_MINIMAL:
51
      return os << "UfssMode::NO_MINIMAL";
52
    default:
53
      Unreachable();
54
  }
55
  return os;
56
}
57
58
7
UfssMode stringToUfssMode(const std::string& optarg)
59
{
60
7
  if (optarg == "none")
61
  {
62
    return UfssMode::NONE;
63
  }
64
7
  else if (optarg == "full")
65
  {
66
    return UfssMode::FULL;
67
  }
68
7
  else if (optarg == "no-minimal")
69
  {
70
7
    return UfssMode::NO_MINIMAL;
71
  }
72
  else if (optarg == "help")
73
  {
74
    std::cerr << "UF with cardinality options currently supported by the --uf-ss option when\n"
75
         "combined with finite model finding.\n"
76
         "Available modes for --uf-ss are:\n"
77
         "+ none\n"
78
         "  Do not use UF with cardinality to shrink model sizes.\n"
79
         "+ full (default)\n"
80
         "  Default, use UF with cardinality to find minimal models for uninterpreted\n"
81
         "  sorts.\n"
82
         "+ no-minimal\n"
83
         "  Use UF with cardinality to shrink models, but do no enforce minimality.\n";
84
    std::exit(1);
85
  }
86
  throw OptionException(std::string("unknown option for --uf-ss: `") +
87
                        optarg + "'.  Try --uf-ss=help.");
88
}
89
90
91
92
namespace uf
93
{
94
// clang-format off
95
void setDefaultUfSymmetryBreaker(Options& opts, bool value)
96
{
97
    if (!opts.uf.ufSymmetryBreakerWasSetByUser) {
98
        opts.uf.ufSymmetryBreaker = value;
99
    }
100
}
101
void setDefaultUfHo(Options& opts, bool value)
102
{
103
    if (!opts.uf.ufHoWasSetByUser) {
104
        opts.uf.ufHo = value;
105
    }
106
}
107
void setDefaultUfHoExt(Options& opts, bool value)
108
{
109
    if (!opts.uf.ufHoExtWasSetByUser) {
110
        opts.uf.ufHoExt = value;
111
    }
112
}
113
void setDefaultUfssAbortCardinality(Options& opts, int64_t value)
114
{
115
    if (!opts.uf.ufssAbortCardinalityWasSetByUser) {
116
        opts.uf.ufssAbortCardinality = value;
117
    }
118
}
119
void setDefaultUfssFairness(Options& opts, bool value)
120
{
121
    if (!opts.uf.ufssFairnessWasSetByUser) {
122
        opts.uf.ufssFairness = value;
123
    }
124
}
125
void setDefaultUfssFairnessMonotone(Options& opts, bool value)
126
{
127
    if (!opts.uf.ufssFairnessMonotoneWasSetByUser) {
128
        opts.uf.ufssFairnessMonotone = value;
129
    }
130
}
131
void setDefaultUfssTotalityLimited(Options& opts, int64_t value)
132
{
133
    if (!opts.uf.ufssTotalityLimitedWasSetByUser) {
134
        opts.uf.ufssTotalityLimited = value;
135
    }
136
}
137
void setDefaultUfssTotalitySymBreak(Options& opts, bool value)
138
{
139
    if (!opts.uf.ufssTotalitySymBreakWasSetByUser) {
140
        opts.uf.ufssTotalitySymBreak = value;
141
    }
142
}
143
void setDefaultUfssMode(Options& opts, UfssMode value)
144
{
145
    if (!opts.uf.ufssModeWasSetByUser) {
146
        opts.uf.ufssMode = value;
147
    }
148
}
149
// clang-format on
150
}
151
152
}  // namespace options
153
29322
}  // namespace cvc5
154
// clang-format on