CBMC
letify.h
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module: Introduce LET for common subexpressions
4
5
Author: Daniel Kroening, kroening@kroening.com
6
7
\*******************************************************************/
8
9
#ifndef CPROVER_SOLVERS_SMT2_LETIFY_H
10
#define CPROVER_SOLVERS_SMT2_LETIFY_H
11
12
#include <
util/std_expr.h
>
13
15
class
letifyt
16
{
17
public
:
18
exprt
operator()
(
const
exprt
&);
19
20
protected
:
21
// to produce a fresh ID for each new let
22
std::size_t
let_id_count
= 0;
23
24
struct
let_count_idt
25
{
26
let_count_idt
(std::size_t _count,
const
symbol_exprt
&_let_symbol)
27
:
count
(_count),
let_symbol
(_let_symbol)
28
{
29
}
30
31
std::size_t
count
;
32
symbol_exprt
let_symbol
;
33
};
34
35
#if HASH_CODE
36
using
seen_expressionst
= std::unordered_map<exprt, let_count_idt, irep_hash>;
37
#else
38
using
seen_expressionst
=
irep_hash_mapt<exprt, let_count_idt>
;
39
#endif
40
41
void
collect_bindings
(
42
const
exprt
&expr,
43
seen_expressionst
&map,
44
std::vector<exprt> &let_order);
45
46
static
exprt
letify
(
47
const
exprt
&expr,
48
const
std::vector<exprt> &let_order,
49
const
seen_expressionst
&map);
50
51
static
exprt
substitute_let
(
const
exprt
&expr,
const
seen_expressionst
&map);
52
};
53
54
#endif // CPROVER_SOLVERS_SMT2_LETIFY_H
letifyt
Introduce LET for common subexpressions.
Definition:
letify.h:15
letifyt::let_count_idt::let_count_idt
let_count_idt(std::size_t _count, const symbol_exprt &_let_symbol)
Definition:
letify.h:26
letifyt::let_id_count
std::size_t let_id_count
Definition:
letify.h:22
exprt
Base class for all expressions.
Definition:
expr.h:55
letifyt::collect_bindings
void collect_bindings(const exprt &expr, seen_expressionst &map, std::vector< exprt > &let_order)
Definition:
letify.cpp:16
symbol_exprt
Expression to hold a symbol (variable)
Definition:
std_expr.h:112
letifyt::let_count_idt::count
std::size_t count
Definition:
letify.h:31
irep_hash_mapt
Definition:
irep_hash_container.h:101
letifyt::substitute_let
static exprt substitute_let(const exprt &expr, const seen_expressionst &map)
Definition:
letify.cpp:89
letifyt::seen_expressionst
std::unordered_map< exprt, let_count_idt, irep_hash > seen_expressionst
Definition:
letify.h:36
letifyt::let_count_idt
Definition:
letify.h:24
letifyt::let_count_idt::let_symbol
symbol_exprt let_symbol
Definition:
letify.h:32
letifyt::operator()
exprt operator()(const exprt &)
Definition:
letify.cpp:79
letifyt::letify
static exprt letify(const exprt &expr, const std::vector< exprt > &let_order, const seen_expressionst &map)
Construct a nested let expression for expressions in let_order that are used more than once.
Definition:
letify.cpp:53
std_expr.h
src
solvers
smt2
letify.h
Generated by
1.8.17