ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
migrate.h
Go to the documentation of this file.
1#ifndef _ESBMC_UTIL_MIGRATE_H_
2#define _ESBMC_UTIL_MIGRATE_H_
3
4// "Migration" refers to the process of moving an expression from the prior
5// string-based internal representation to the newer typed representation.
6// There's a full mapping in both directions.
7
8#include <irep2/irep2.h>
10#include <util/irep/std_types.h>
11
12class contextt;
13
14// Don't ask
15class namespacet;
16class symbolt;
17// thread_local so parallel symex threads can each set their own
18// namespace pointer without racing.
19extern thread_local const namespacet *migrate_namespace_lookup;
20
21type2tc migrate_type(const typet &type);
22void migrate_expr(const exprt &expr, expr2tc &new_expr);
23
27inline expr2tc migrate_expr(const exprt &expr)
28{
29 expr2tc out;
30 migrate_expr(expr, out);
31 return out;
32}
33
34// IREP2 form of a symbol's type. Named chokepoint for symbol type reads in
35// the migration layer (esbmc/esbmc#4715, B2): returns `sym.get_type2()` which
36// is the IREP2 source of truth after the B2 storage flip. In debug builds it
37// also asserts the IREP2 form is stable under a round-trip through legacy
38// irept -- the property (proven for synthetic types in
39// unit/util/migrate.test.cpp) that makes the lazy legacy cache on `symbolt`
40// lossless, now checked on every real symbol type the pipeline reads.
42
43// IREP2 form of a symbol's value. Value-side counterpart of
44// migrate_symbol_type. The debug cross-check is *guarded*: function bodies
45// (sym.get_type().is_code()) are skipped (no caller goes through this path on
46// them today, and the assertion would force a potentially-large body
47// round-trip for no signal); nil values are skipped too.
48void migrate_symbol_value(const symbolt &sym, expr2tc &dest);
49
50// Set a symbol's type from an IREP2 form (esbmc/esbmc#4715, B2). The
51// chokepoint for symbol-type writes: routes through symbolt's IREP2-side
52// setter, which stores the form natively and invalidates the lazy legacy
53// cache. Replaces the previous round-trip pattern
54// `sym.set_type(migrate_type_back(t))` at the call sites.
55void set_symbol_type(symbolt &sym, const type2tc &t);
56
58
59// Drop the memoised legacy forms of migrated aggregate types.
62
63// --- Phase 4.2 construction helpers (Part IV ยง6: "build once, shared") -------
64// IREP2 replacements for the two legacy expression constructors the frontends
65// lean on most, so frontend code can build IREP2 nodes directly instead of
66// `symbol_expr(symbolt)` / `side_effect_expr_function_callt`. These are pure
67// construction helpers with round-trip unit tests; no call site is rewired
68// here -- the wiring is Phase 4.3/4.4 work, shipped separately so this
69// infrastructure carries zero coverage-axis risk (the V-track lesson).
70
71// IREP2 form of `symbol_expr(const symbolt&)`: a level-0 `symbol2t` carrying
72// the symbol's IREP2 type (read via migrate_symbol_type, the B2 source of
73// truth) and its identifier. The legacy node also stores a cosmetic display
74// name; IREP2 symbols carry only the identifier, so it is neither represented
75// nor needed (`migrate_expr` drops it on the same path).
77
78// IREP2 form of `side_effect_expr_function_callt`: an expression-context call
79// `function(arguments...)` evaluating to `return_type`, i.e. a `sideeffect2t`
80// with allockind::function_call. Mirrors migrate.cpp's function_call lowering
81// (operand = callee, arguments = args, no size/alloctype).
83 const type2tc &return_type,
84 const expr2tc &function,
85 const std::vector<expr2tc> &arguments);
86
97void migrate_census(const contextt &context);
98
99#endif /* _ESBMC_UTIL_MIGRATE_H_ */
Definition context.h:57
Definition expr.h:34
Definition namespace.h:10
Definition symbol.h:12
Definition type.h:9
Classes and definitions for non-stringy internal representation.
irep_container< type2t > type2tc
Definition irep2.h:430
irep_container< expr2t > expr2tc
Definition irep2.h:431
const namespacet * migrate_namespace_lookup
Definition migrate.cpp:74
void migrate_symbol_value(const symbolt &sym, expr2tc &dest)
Definition migrate.cpp:588
type2tc migrate_symbol_type(const symbolt &sym)
Definition migrate.cpp:567
expr2tc symbol_expr2tc(const symbolt &sym)
Definition migrate.cpp:623
exprt migrate_expr_back(const expr2tc &ref)
Definition migrate.cpp:3949
void migrate_type_back_cache_clear()
Definition migrate.cpp:3428
expr2tc side_effect_function_call2tc(const type2tc &return_type, const expr2tc &function, const std::vector< expr2tc > &arguments)
Definition migrate.cpp:631
void set_symbol_type(symbolt &sym, const type2tc &t)
Definition migrate.cpp:615
type2tc migrate_type(const typet &type)
Definition migrate.cpp:557
void migrate_expr(const exprt &expr, expr2tc &new_expr)
Definition migrate.cpp:1512
typet migrate_type_back(const type2tc &ref)
Definition migrate.cpp:3476
void migrate_census(const contextt &context)
Migrate every symbol's type, and its value where it has one, and report what could not be represented...
Definition migrate.cpp:5370
Definition module.h:12