Branch data Line data Source code
1 : : /****************************************************************************** 2 : : * This file is part of the cvc5 project. 3 : : * 4 : : * Copyright (c) 2009-2026 by the authors listed in the file AUTHORS 5 : : * in the top-level source directory and their institutional affiliations. 6 : : * All rights reserved. See the file COPYING in the top-level source 7 : : * directory for licensing information. 8 : : * **************************************************************************** 9 : : * 10 : : * The preprocessing pass registry 11 : : * 12 : : * This file defines the classes PreprocessingPassRegistry, which keeps track 13 : : * of the available preprocessing passes. 14 : : */ 15 : : 16 : : #include "preprocessing/preprocessing_pass_registry.h" 17 : : 18 : : #include <algorithm> 19 : : #include <utility> 20 : : 21 : : #include "base/check.h" 22 : : #include "base/map_util.h" 23 : : #include "base/output.h" 24 : : #include "preprocessing/passes/ackermann.h" 25 : : #include "preprocessing/passes/apply_substs.h" 26 : : #include "preprocessing/passes/bool_to_bv.h" 27 : : #include "preprocessing/passes/bv_eager_atoms.h" 28 : : #include "preprocessing/passes/bv_gauss.h" 29 : : #include "preprocessing/passes/bv_intro_pow2.h" 30 : : #include "preprocessing/passes/bv_to_bool.h" 31 : : #include "preprocessing/passes/bv_to_int.h" 32 : : #include "preprocessing/passes/extended_rewriter_pass.h" 33 : : #include "preprocessing/passes/ff_bitsum.h" 34 : : #include "preprocessing/passes/ff_disjunctive_bit.h" 35 : : #include "preprocessing/passes/foreign_theory_rewrite.h" 36 : : #include "preprocessing/passes/fun_def_fmf.h" 37 : : #include "preprocessing/passes/global_negate.h" 38 : : #include "preprocessing/passes/ho_elim.h" 39 : : #include "preprocessing/passes/int_to_bv.h" 40 : : #include "preprocessing/passes/ite_removal.h" 41 : : #include "preprocessing/passes/ite_simp.h" 42 : : #include "preprocessing/passes/learned_rewrite.h" 43 : : #include "preprocessing/passes/miplib_trick.h" 44 : : #include "preprocessing/passes/nl_ext_purify.h" 45 : : #include "preprocessing/passes/non_clausal_simp.h" 46 : : #include "preprocessing/passes/normalize.h" 47 : : #include "preprocessing/passes/pseudo_boolean_processor.h" 48 : : #include "preprocessing/passes/quantifiers_preprocess.h" 49 : : #include "preprocessing/passes/real_to_int.h" 50 : : #include "preprocessing/passes/rewrite.h" 51 : : #include "preprocessing/passes/sep_skolem_emp.h" 52 : : #include "preprocessing/passes/sort_infer.h" 53 : : #include "preprocessing/passes/static_learning.h" 54 : : #include "preprocessing/passes/static_rewrite.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/unconstrained_simplifier.h" 60 : : #include "preprocessing/preprocessing_pass.h" 61 : : 62 : : namespace cvc5::internal { 63 : : namespace preprocessing { 64 : : 65 : : using namespace cvc5::internal::preprocessing::passes; 66 : : 67 : 51787 : PreprocessingPassRegistry& PreprocessingPassRegistry::getInstance() 68 : : { 69 : : static thread_local PreprocessingPassRegistry* ppReg = 70 [ + + ]: 51787 : new PreprocessingPassRegistry(); 71 : 51787 : return *ppReg; 72 : : } 73 : : 74 : 616320 : void PreprocessingPassRegistry::registerPassInfo( 75 : : const std::string& name, 76 : : std::function<PreprocessingPass*(PreprocessingPassContext*)> ctor) 77 : : { 78 [ - + ][ - + ]: 616320 : AlwaysAssert(!ContainsKey(d_ppInfo, name)); [ - - ] 79 : 616320 : d_ppInfo[name] = ctor; 80 : 616320 : } 81 : : 82 : 1864332 : PreprocessingPass* PreprocessingPassRegistry::createPass( 83 : : PreprocessingPassContext* ppCtx, const std::string& name) 84 : : { 85 [ - + ][ - + ]: 1864332 : Assert(d_ppInfo.count(name)); [ - - ] 86 : 1864332 : return d_ppInfo[name](ppCtx); 87 : : } 88 : : 89 : 51787 : std::vector<std::string> PreprocessingPassRegistry::getAvailablePasses() 90 : : { 91 : 51787 : std::vector<std::string> passes; 92 [ + + ]: 1916119 : for (const auto& info : d_ppInfo) 93 : : { 94 : 1864332 : passes.push_back(info.first); 95 : : } 96 : 51787 : std::sort(passes.begin(), passes.end()); 97 : 51787 : return passes; 98 : 0 : } 99 : : 100 : 0 : bool PreprocessingPassRegistry::hasPass(const std::string& name) 101 : : { 102 : 0 : return d_ppInfo.find(name) != d_ppInfo.end(); 103 : : } 104 : : 105 : : namespace { 106 : : 107 : : /** 108 : : * This method is stored by the `PreprocessingPassRegistry` and used to create 109 : : * a new instance of the preprocessing pass T. 110 : : * 111 : : * @param ppCtx The preprocessing pass context passed to the constructor of 112 : : * the preprocessing pass 113 : : */ 114 : : template <class T> 115 : 1864332 : PreprocessingPass* callCtor(PreprocessingPassContext* ppCtx) 116 : : { 117 : 1864332 : return new T(ppCtx); 118 : : } 119 : : 120 : : } // namespace 121 : : 122 : 17120 : PreprocessingPassRegistry::PreprocessingPassRegistry() 123 : : { 124 : 17120 : registerPassInfo("apply-substs", callCtor<ApplySubsts>); 125 : 17120 : registerPassInfo("bv-gauss", callCtor<BVGauss>); 126 : 17120 : registerPassInfo("static-learning", callCtor<StaticLearning>); 127 : 17120 : registerPassInfo("ite-simp", callCtor<ITESimp>); 128 : 17120 : registerPassInfo("global-negate", callCtor<GlobalNegate>); 129 : 17120 : registerPassInfo("int-to-bv", callCtor<IntToBV>); 130 : 17120 : registerPassInfo("bv-to-int", callCtor<BVToInt>); 131 : 17120 : registerPassInfo("ff-bitsum", callCtor<FfBitsum>); 132 : 17120 : registerPassInfo("ff-disjunctive-bit", callCtor<FfDisjunctiveBit>); 133 : 17120 : registerPassInfo("learned-rewrite", callCtor<LearnedRewrite>); 134 : 17120 : registerPassInfo("foreign-theory-rewrite", callCtor<ForeignTheoryRewrite>); 135 : 17120 : registerPassInfo("synth-rr", callCtor<SynthRewRulesPass>); 136 : 17120 : registerPassInfo("real-to-int", callCtor<RealToInt>); 137 : 17120 : registerPassInfo("sygus-infer", callCtor<SygusInference>); 138 : 17120 : registerPassInfo("bv-to-bool", callCtor<BVToBool>); 139 : 17120 : registerPassInfo("bv-intro-pow2", callCtor<BvIntroPow2>); 140 : 17120 : registerPassInfo("sort-inference", callCtor<SortInferencePass>); 141 : 17120 : registerPassInfo("sep-skolem-emp", callCtor<SepSkolemEmp>); 142 : 17120 : registerPassInfo("rewrite", callCtor<Rewrite>); 143 : 17120 : registerPassInfo("bv-eager-atoms", callCtor<BvEagerAtoms>); 144 : 17120 : registerPassInfo("pseudo-boolean-processor", 145 : : callCtor<PseudoBooleanProcessor>); 146 : 17120 : registerPassInfo("unconstrained-simplifier", 147 : : callCtor<UnconstrainedSimplifier>); 148 : 17120 : registerPassInfo("quantifiers-preprocess", callCtor<QuantifiersPreprocess>); 149 : 17120 : registerPassInfo("ite-removal", callCtor<IteRemoval>); 150 : 17120 : registerPassInfo("miplib-trick", callCtor<MipLibTrick>); 151 : 17120 : registerPassInfo("non-clausal-simp", callCtor<NonClausalSimp>); 152 : 17120 : registerPassInfo("ackermann", callCtor<Ackermann>); 153 : 17120 : registerPassInfo("ext-rew-pre", callCtor<ExtRewPre>); 154 : 17120 : registerPassInfo("theory-preprocess", callCtor<TheoryPreprocess>); 155 : 17120 : registerPassInfo("nl-ext-purify", callCtor<NlExtPurify>); 156 : 17120 : registerPassInfo("bool-to-bv", callCtor<BoolToBV>); 157 : 17120 : registerPassInfo("ho-elim", callCtor<HoElim>); 158 : 17120 : registerPassInfo("fun-def-fmf", callCtor<FunDefFmf>); 159 : 17120 : registerPassInfo("static-rewrite", callCtor<StaticRewrite>); 160 : 17120 : registerPassInfo("strings-eager-pp", callCtor<StringsEagerPp>); 161 : 17120 : registerPassInfo("normalize", callCtor<Normalize>); 162 : 17120 : } 163 : : 164 : : } // namespace preprocessing 165 : : } // namespace cvc5::internal