1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andres Noetzli, Yoni Zohar, Justin Xu |
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 |
|
* The preprocessing pass registry |
14 |
|
* |
15 |
|
* This file defines the classes PreprocessingPassRegistry, which keeps track |
16 |
|
* of the available preprocessing passes. |
17 |
|
*/ |
18 |
|
|
19 |
|
#include "preprocessing/preprocessing_pass_registry.h" |
20 |
|
|
21 |
|
#include <algorithm> |
22 |
|
#include <utility> |
23 |
|
|
24 |
|
#include "base/check.h" |
25 |
|
#include "base/map_util.h" |
26 |
|
#include "base/output.h" |
27 |
|
#include "preprocessing/passes/ackermann.h" |
28 |
|
#include "preprocessing/passes/apply_substs.h" |
29 |
|
#include "preprocessing/passes/bool_to_bv.h" |
30 |
|
#include "preprocessing/passes/bv_abstraction.h" |
31 |
|
#include "preprocessing/passes/bv_eager_atoms.h" |
32 |
|
#include "preprocessing/passes/bv_gauss.h" |
33 |
|
#include "preprocessing/passes/bv_intro_pow2.h" |
34 |
|
#include "preprocessing/passes/bv_to_bool.h" |
35 |
|
#include "preprocessing/passes/bv_to_int.h" |
36 |
|
#include "preprocessing/passes/extended_rewriter_pass.h" |
37 |
|
#include "preprocessing/passes/foreign_theory_rewrite.h" |
38 |
|
#include "preprocessing/passes/fun_def_fmf.h" |
39 |
|
#include "preprocessing/passes/global_negate.h" |
40 |
|
#include "preprocessing/passes/ho_elim.h" |
41 |
|
#include "preprocessing/passes/int_to_bv.h" |
42 |
|
#include "preprocessing/passes/ite_removal.h" |
43 |
|
#include "preprocessing/passes/ite_simp.h" |
44 |
|
#include "preprocessing/passes/learned_rewrite.h" |
45 |
|
#include "preprocessing/passes/miplib_trick.h" |
46 |
|
#include "preprocessing/passes/nl_ext_purify.h" |
47 |
|
#include "preprocessing/passes/non_clausal_simp.h" |
48 |
|
#include "preprocessing/passes/pseudo_boolean_processor.h" |
49 |
|
#include "preprocessing/passes/quantifiers_preprocess.h" |
50 |
|
#include "preprocessing/passes/real_to_int.h" |
51 |
|
#include "preprocessing/passes/rewrite.h" |
52 |
|
#include "preprocessing/passes/sep_skolem_emp.h" |
53 |
|
#include "preprocessing/passes/sort_infer.h" |
54 |
|
#include "preprocessing/passes/static_learning.h" |
55 |
|
#include "preprocessing/passes/strings_eager_pp.h" |
56 |
|
#include "preprocessing/passes/sygus_inference.h" |
57 |
|
#include "preprocessing/passes/synth_rew_rules.h" |
58 |
|
#include "preprocessing/passes/theory_preprocess.h" |
59 |
|
#include "preprocessing/passes/theory_rewrite_eq.h" |
60 |
|
#include "preprocessing/passes/unconstrained_simplifier.h" |
61 |
|
#include "preprocessing/preprocessing_pass.h" |
62 |
|
|
63 |
|
namespace cvc5 { |
64 |
|
namespace preprocessing { |
65 |
|
|
66 |
|
using namespace cvc5::preprocessing::passes; |
67 |
|
|
68 |
9855 |
PreprocessingPassRegistry& PreprocessingPassRegistry::getInstance() |
69 |
|
{ |
70 |
9855 |
static PreprocessingPassRegistry* ppReg = new PreprocessingPassRegistry(); |
71 |
9855 |
return *ppReg; |
72 |
|
} |
73 |
|
|
74 |
226100 |
void PreprocessingPassRegistry::registerPassInfo( |
75 |
|
const std::string& name, |
76 |
|
std::function<PreprocessingPass*(PreprocessingPassContext*)> ctor) |
77 |
|
{ |
78 |
226100 |
AlwaysAssert(!ContainsKey(d_ppInfo, name)); |
79 |
226100 |
d_ppInfo[name] = ctor; |
80 |
226100 |
} |
81 |
|
|
82 |
335036 |
PreprocessingPass* PreprocessingPassRegistry::createPass( |
83 |
|
PreprocessingPassContext* ppCtx, const std::string& name) |
84 |
|
{ |
85 |
335036 |
return d_ppInfo[name](ppCtx); |
86 |
|
} |
87 |
|
|
88 |
9854 |
std::vector<std::string> PreprocessingPassRegistry::getAvailablePasses() |
89 |
|
{ |
90 |
9854 |
std::vector<std::string> passes; |
91 |
344890 |
for (const auto& info : d_ppInfo) |
92 |
|
{ |
93 |
335036 |
passes.push_back(info.first); |
94 |
|
} |
95 |
9854 |
std::sort(passes.begin(), passes.end()); |
96 |
9854 |
return passes; |
97 |
|
} |
98 |
|
|
99 |
1 |
bool PreprocessingPassRegistry::hasPass(const std::string& name) |
100 |
|
{ |
101 |
1 |
return d_ppInfo.find(name) != d_ppInfo.end(); |
102 |
|
} |
103 |
|
|
104 |
|
namespace { |
105 |
|
|
106 |
|
/** |
107 |
|
* This method is stored by the `PreprocessingPassRegistry` and used to create |
108 |
|
* a new instance of the preprocessing pass T. |
109 |
|
* |
110 |
|
* @param ppCtx The preprocessing pass context passed to the constructor of |
111 |
|
* the preprocessing pass |
112 |
|
*/ |
113 |
|
template <class T> |
114 |
335036 |
PreprocessingPass* callCtor(PreprocessingPassContext* ppCtx) |
115 |
|
{ |
116 |
335036 |
return new T(ppCtx); |
117 |
|
} |
118 |
|
|
119 |
|
} // namespace |
120 |
|
|
121 |
6650 |
PreprocessingPassRegistry::PreprocessingPassRegistry() |
122 |
|
{ |
123 |
6650 |
registerPassInfo("apply-substs", callCtor<ApplySubsts>); |
124 |
6650 |
registerPassInfo("bv-gauss", callCtor<BVGauss>); |
125 |
6650 |
registerPassInfo("static-learning", callCtor<StaticLearning>); |
126 |
6650 |
registerPassInfo("ite-simp", callCtor<ITESimp>); |
127 |
6650 |
registerPassInfo("global-negate", callCtor<GlobalNegate>); |
128 |
6650 |
registerPassInfo("int-to-bv", callCtor<IntToBV>); |
129 |
6650 |
registerPassInfo("bv-to-int", callCtor<BVToInt>); |
130 |
6650 |
registerPassInfo("learned-rewrite", callCtor<LearnedRewrite>); |
131 |
6650 |
registerPassInfo("foreign-theory-rewrite", callCtor<ForeignTheoryRewrite>); |
132 |
6650 |
registerPassInfo("synth-rr", callCtor<SynthRewRulesPass>); |
133 |
6650 |
registerPassInfo("real-to-int", callCtor<RealToInt>); |
134 |
6650 |
registerPassInfo("sygus-infer", callCtor<SygusInference>); |
135 |
6650 |
registerPassInfo("bv-to-bool", callCtor<BVToBool>); |
136 |
6650 |
registerPassInfo("bv-intro-pow2", callCtor<BvIntroPow2>); |
137 |
6650 |
registerPassInfo("sort-inference", callCtor<SortInferencePass>); |
138 |
6650 |
registerPassInfo("sep-skolem-emp", callCtor<SepSkolemEmp>); |
139 |
6650 |
registerPassInfo("rewrite", callCtor<Rewrite>); |
140 |
6650 |
registerPassInfo("bv-abstraction", callCtor<BvAbstraction>); |
141 |
6650 |
registerPassInfo("bv-eager-atoms", callCtor<BvEagerAtoms>); |
142 |
6650 |
registerPassInfo("pseudo-boolean-processor", |
143 |
|
callCtor<PseudoBooleanProcessor>); |
144 |
6650 |
registerPassInfo("unconstrained-simplifier", |
145 |
|
callCtor<UnconstrainedSimplifier>); |
146 |
6650 |
registerPassInfo("quantifiers-preprocess", callCtor<QuantifiersPreprocess>); |
147 |
6650 |
registerPassInfo("ite-removal", callCtor<IteRemoval>); |
148 |
6650 |
registerPassInfo("miplib-trick", callCtor<MipLibTrick>); |
149 |
6650 |
registerPassInfo("non-clausal-simp", callCtor<NonClausalSimp>); |
150 |
6650 |
registerPassInfo("ackermann", callCtor<Ackermann>); |
151 |
6650 |
registerPassInfo("ext-rew-pre", callCtor<ExtRewPre>); |
152 |
6650 |
registerPassInfo("theory-preprocess", callCtor<TheoryPreprocess>); |
153 |
6650 |
registerPassInfo("nl-ext-purify", callCtor<NlExtPurify>); |
154 |
6650 |
registerPassInfo("bool-to-bv", callCtor<BoolToBV>); |
155 |
6650 |
registerPassInfo("ho-elim", callCtor<HoElim>); |
156 |
6650 |
registerPassInfo("fun-def-fmf", callCtor<FunDefFmf>); |
157 |
6650 |
registerPassInfo("theory-rewrite-eq", callCtor<TheoryRewriteEq>); |
158 |
6650 |
registerPassInfo("strings-eager-pp", callCtor<StringsEagerPp>); |
159 |
6650 |
} |
160 |
|
|
161 |
|
} // namespace preprocessing |
162 |
29349 |
} // namespace cvc5 |