11#ifndef MCRL2_DATA_DETAIL_REWR_JITTYC_H
12#define MCRL2_DATA_DETAIL_REWR_JITTYC_H
25#ifdef MCRL2_ENABLE_JITTYC
34typedef std::vector < sort_expression_list> sort_list_vector;
42class normal_form_cache
45 std::set<data_expression> m_lookup;
53 normal_form_cache(
const normal_form_cache& ) =
delete;
54 normal_form_cache(normal_form_cache&& ) =
delete;
55 normal_form_cache& operator=(
const normal_form_cache& ) =
delete;
56 normal_form_cache& operator=(normal_form_cache&& ) =
delete;
65 std::string
insert(
const data_expression& t)
68 const data_expression* cached_term = &*(m_lookup.insert(t).first);
69 ss <<
"*reinterpret_cast<const data_expression*>(" << (
void*)(cached_term) <<
")";
77 return m_lookup.
empty();
85class RewriterCompilingJitty:
public Rewriter
88 typedef Rewriter::substitution_type substitution_type;
89 typedef void (*
rewriter_function)(data_expression&,
const application&, RewriterCompilingJitty*);
91 RewriterCompilingJitty(
const data_specification& DataSpec,
const used_data_equation_selector&);
92 virtual ~RewriterCompilingJitty();
96 data_expression
rewrite(
const data_expression& term, substitution_type&
sigma);
98 void rewrite(data_expression& result,
const data_expression& term, substitution_type&
sigma);
102 substitution_type *global_sigma;
103 bool rewriting_in_progress;
104 rewrite_stack m_rewrite_stack;
108 std::vector<variable_list> rewriter_binding_variable_lists;
109 std::map <variable_list, std::size_t> variable_list_indices1;
110 std::size_t binding_variable_list_index(
const variable_list& v);
111 inline variable_list binding_variable_list_get(
const std::size_t i)
113 return (rewriter_binding_variable_lists[i]);
121 std::vector<variable> rewriter_bound_variables;
122 std::map <variable, std::size_t> variable_indices0;
128 std::size_t arity_bound;
129 std::size_t index_bound;
131 std::size_t bound_variable_index(
const variable& v);
132 variable bound_variable_get(
const std::size_t i)
134 return (rewriter_bound_variables[i]);
139 std::vector<rewriter_function> functions_when_arguments_are_not_in_normal_form;
140 std::vector<rewriter_function> functions_when_arguments_are_in_normal_form;
143 std::vector<data_expression> normal_forms_for_constants;
146 RewriterCompilingJitty& operator=(
const RewriterCompilingJitty& other)=
delete;
148 std::shared_ptr<detail::Rewriter> clone()
150 return std::shared_ptr<Rewriter>(
new RewriterCompilingJitty(*
this));
155 friend class ImplementTree;
157 RewriterJitty jitty_rewriter;
158 std::set < data_equation > rewrite_rules;
159 const match_tree dummy=match_tree();
161 std::map<function_symbol, data_equation_list> jittyc_eqns;
162 std::set<function_symbol> m_extra_symbols;
164 std::shared_ptr<uncompiled_library> rewriter_so;
165 std::shared_ptr<normal_form_cache> m_nf_cache;
177 RewriterCompilingJitty(RewriterCompilingJitty& other) =
default;
179 void (*so_rewr_cleanup)();
180 void (*so_rewr)(data_expression& result,
const data_expression&, RewriterCompilingJitty*);
182 void add_base_nfs(nfs_array& a,
const function_symbol& opid, std::size_t arity);
183 void extend_nfs(nfs_array& a,
const function_symbol& opid, std::size_t arity);
184 bool opid_is_nf(
const function_symbol& opid, std::size_t num_args);
185 void calc_nfs_list(nfs_array& a,
const application& args, variable_or_number_list nnfvars);
186 bool calc_nfs(
const data_expression& t, variable_or_number_list nnfvars);
187 void CleanupRewriteSystem();
188 void BuildRewriteSystem();
189 void generate_code(
const std::string& filename);
190 void generate_rewr_functions(std::ostream& s,
const data::function_symbol&
func,
const data_equation_list& eqs);
191 bool lift_rewrite_rule_to_right_arity(data_equation& e,
const std::size_t requested_arity);
192 sort_list_vector get_residual_sorts(
const sort_expression& s,
const std::size_t actual_arity,
const std::size_t requested_arity);
194 void term2seq(
const data_expression& t, match_tree_list& s, std::size_t *var_cnt,
const bool omit_head);
195 match_tree_list create_sequence(
const data_equation& rule, std::size_t* var_cnt);
198 const variable& new_val,
199 const std::size_t num,
200 const mutable_map_substitution<>& substs);
201 match_tree build_tree(build_pars pars, std::size_t i);
202 match_tree create_tree(
const data_equation_list& rules);
204 void thread_initialise()
211struct rewriter_interface
213 std::string caller_toolset_version;
215 RewriterCompilingJitty* rewriter;
216 void (*rewrite_external)(data_expression& result,
const data_expression& t, RewriterCompilingJitty*);
bool empty() const
Returns true if the term has no arguments.
This is a thread's specific access to the global aterm pool which ensures that garbage collection and...
void(* rewriter_function)(data_expression &, const application &, RewriterCompilingJitty *)
static RewriterCompilingJitty::substitution_type & sigma(RewriterCompilingJitty *this_rewriter)
static void rewrite_cleanup()
static void rewrite(data_expression &result, const data_expression &t, RewriterCompilingJitty *this_rewriter)
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
add your file description here.
thread_aterm_pool & g_thread_term_pool()
A reference to the thread local term pool storage.
strategy create_strategy(data_equation_list rules)
Creates a strategy for given set of rewrite rules with head symbol f.
atermpp::term_list< match_tree > match_tree_list
function_symbol insert(const sort_expression &s)
Constructor for function symbol @fbag_insert.
function_symbol empty(const sort_expression &s)
Constructor for function symbol {:}.
rewrite_strategy
The strategy of the rewriter.
atermpp::term_list< variable > variable_list
\brief list of variables
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
This is an array in which it is recorded which arguments are normal forms and which are not.