summaryrefslogtreecommitdiff
path: root/src/preprocessing/preprocessing_pass_registry.cpp
diff options
context:
space:
mode:
authorAndres Noetzli <andres.noetzli@gmail.com>2018-10-02 14:55:21 -0700
committerGitHub <noreply@github.com>2018-10-02 14:55:21 -0700
commit937d37ef78d3ef445335928d498422083df74d77 (patch)
tree0e686ba7f9a7d745bc86c71c8629ee21510bb728 /src/preprocessing/preprocessing_pass_registry.cpp
parenta580349bbb39fa9681ab2e2d05dd448f8b082399 (diff)
Make registration of preprocessing passes explicit (#2564)
As it turns out, self-registering types are problematic with static linkage [0]. Instead of fixing the issue with linker flags, which seems possible but also brittle (e.g. the flags may be different for different linkers), this commit adds an explicit registration of each preprocessing pass. [0] https://www.bfilipek.com/2018/02/static-vars-static-lib.html
Diffstat (limited to 'src/preprocessing/preprocessing_pass_registry.cpp')
-rw-r--r--src/preprocessing/preprocessing_pass_registry.cpp91
1 files changed, 89 insertions, 2 deletions
diff --git a/src/preprocessing/preprocessing_pass_registry.cpp b/src/preprocessing/preprocessing_pass_registry.cpp
index a50cd2541..f2e7c8603 100644
--- a/src/preprocessing/preprocessing_pass_registry.cpp
+++ b/src/preprocessing/preprocessing_pass_registry.cpp
@@ -12,8 +12,7 @@
** \brief The preprocessing pass registry
**
** This file defines the classes PreprocessingPassRegistry, which keeps track
- ** of the available preprocessing passes, and RegisterPass, which registers a
- ** preprocessing pass with the registry.
+ ** of the available preprocessing passes.
**/
#include "preprocessing/preprocessing_pass_registry.h"
@@ -22,12 +21,46 @@
#include <utility>
#include "base/cvc4_assert.h"
+#include "base/map_util.h"
#include "base/output.h"
+#include "preprocessing/passes/apply_substs.h"
+#include "preprocessing/passes/apply_to_const.h"
+#include "preprocessing/passes/bool_to_bv.h"
+#include "preprocessing/passes/bv_abstraction.h"
+#include "preprocessing/passes/bv_ackermann.h"
+#include "preprocessing/passes/bv_eager_atoms.h"
+#include "preprocessing/passes/bv_gauss.h"
+#include "preprocessing/passes/bv_intro_pow2.h"
+#include "preprocessing/passes/bv_to_bool.h"
+#include "preprocessing/passes/extended_rewriter_pass.h"
+#include "preprocessing/passes/global_negate.h"
+#include "preprocessing/passes/int_to_bv.h"
+#include "preprocessing/passes/ite_removal.h"
+#include "preprocessing/passes/ite_simp.h"
+#include "preprocessing/passes/miplib_trick.h"
+#include "preprocessing/passes/nl_ext_purify.h"
+#include "preprocessing/passes/non_clausal_simp.h"
+#include "preprocessing/passes/pseudo_boolean_processor.h"
+#include "preprocessing/passes/quantifier_macros.h"
+#include "preprocessing/passes/quantifiers_preprocess.h"
+#include "preprocessing/passes/real_to_int.h"
+#include "preprocessing/passes/rewrite.h"
+#include "preprocessing/passes/sep_skolem_emp.h"
+#include "preprocessing/passes/sort_infer.h"
+#include "preprocessing/passes/static_learning.h"
+#include "preprocessing/passes/sygus_inference.h"
+#include "preprocessing/passes/symmetry_breaker.h"
+#include "preprocessing/passes/symmetry_detect.h"
+#include "preprocessing/passes/synth_rew_rules.h"
+#include "preprocessing/passes/theory_preprocess.h"
+#include "preprocessing/passes/unconstrained_simplifier.h"
#include "preprocessing/preprocessing_pass.h"
namespace CVC4 {
namespace preprocessing {
+using namespace CVC4::preprocessing::passes;
+
PreprocessingPassRegistry& PreprocessingPassRegistry::getInstance()
{
static PreprocessingPassRegistry* ppReg = new PreprocessingPassRegistry();
@@ -38,6 +71,7 @@ void PreprocessingPassRegistry::registerPassInfo(
const std::string& name,
std::function<PreprocessingPass*(PreprocessingPassContext*)> ctor)
{
+ AlwaysAssert(!ContainsKey(d_ppInfo, name));
d_ppInfo[name] = ctor;
}
@@ -63,5 +97,58 @@ bool PreprocessingPassRegistry::hasPass(const std::string& name)
return d_ppInfo.find(name) != d_ppInfo.end();
}
+namespace {
+
+/**
+ * This method is stored by the `PreprocessingPassRegistry` and used to create
+ * a new instance of the preprocessing pass T.
+ *
+ * @param ppCtx The preprocessing pass context passed to the constructor of
+ * the preprocessing pass
+ */
+template <class T>
+PreprocessingPass* callCtor(PreprocessingPassContext* ppCtx)
+{
+ return new T(ppCtx);
+}
+
+} // namespace
+
+PreprocessingPassRegistry::PreprocessingPassRegistry()
+{
+ registerPassInfo("apply-substs", callCtor<ApplySubsts>);
+ registerPassInfo("bv-gauss", callCtor<BVGauss>);
+ registerPassInfo("static-learning", callCtor<StaticLearning>);
+ registerPassInfo("ite-simp", callCtor<ITESimp>);
+ registerPassInfo("apply-to-const", callCtor<ApplyToConst>);
+ registerPassInfo("global-negate", callCtor<GlobalNegate>);
+ registerPassInfo("int-to-bv", callCtor<IntToBV>);
+ registerPassInfo("synth-rr", callCtor<SynthRewRulesPass>);
+ registerPassInfo("real-to-int", callCtor<RealToInt>);
+ registerPassInfo("sygus-infer", callCtor<SygusInference>);
+ registerPassInfo("bv-to-bool", callCtor<BVToBool>);
+ registerPassInfo("bv-intro-pow2", callCtor<BvIntroPow2>);
+ registerPassInfo("sort-inference", callCtor<SortInferencePass>);
+ registerPassInfo("sep-skolem-emp", callCtor<SepSkolemEmp>);
+ registerPassInfo("rewrite", callCtor<Rewrite>);
+ registerPassInfo("bv-abstraction", callCtor<BvAbstraction>);
+ registerPassInfo("bv-eager-atoms", callCtor<BvEagerAtoms>);
+ registerPassInfo("pseudo-boolean-processor",
+ callCtor<PseudoBooleanProcessor>);
+ registerPassInfo("unconstrained-simplifier",
+ callCtor<UnconstrainedSimplifier>);
+ registerPassInfo("quantifiers-preprocess", callCtor<QuantifiersPreprocess>);
+ registerPassInfo("ite-removal", callCtor<IteRemoval>);
+ registerPassInfo("miplib-trick", callCtor<MipLibTrick>);
+ registerPassInfo("non-clausal-simp", callCtor<NonClausalSimp>);
+ registerPassInfo("bv-ackermann", callCtor<BVAckermann>);
+ registerPassInfo("sym-break", callCtor<SymBreakerPass>);
+ registerPassInfo("ext-rew-pre", callCtor<ExtRewPre>);
+ registerPassInfo("theory-preprocess", callCtor<TheoryPreprocess>);
+ registerPassInfo("quantifier-macros", callCtor<QuantifierMacros>);
+ registerPassInfo("nl-ext-purify", callCtor<NlExtPurify>);
+ registerPassInfo("bool-to-bv", callCtor<BoolToBV>);
+}
+
} // namespace preprocessing
} // namespace CVC4
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback