Skip to content

Commit 8b2ec0d

Browse files
committed
Move rounding_mode_identifier() to configt
This removes a goto-programs dependency from linking/, which is all about symbol tables, not goto programs.
1 parent d932d6f commit 8b2ec0d

15 files changed

+28
-38
lines changed

jbmc/src/java_bytecode/java_bytecode_internal_additions.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,22 @@ Author: Daniel Kroening, [email protected]
99
#include "java_bytecode_internal_additions.h"
1010

1111
// For INFLIGHT_EXCEPTION_VARIABLE_NAME
12-
#include "java_types.h"
13-
#include "remove_exceptions.h"
14-
1512
#include <util/c_types.h>
13+
#include <util/config.h>
1614
#include <util/pointer_expr.h>
1715
#include <util/std_types.h>
1816
#include <util/symbol_table_base.h>
1917

20-
#include <goto-programs/adjust_float_expressions.h>
18+
#include "java_types.h"
19+
#include "remove_exceptions.h"
2120

2221
void java_internal_additions(symbol_table_baset &dest)
2322
{
2423
// add __CPROVER_rounding_mode
2524

2625
{
2726
symbolt symbol;
28-
symbol.name = rounding_mode_identifier();
27+
symbol.name = config.rounding_mode_identifier();
2928
symbol.base_name = symbol.name;
3029
symbol.type=signed_int_type();
3130
symbol.mode=ID_C;

jbmc/src/java_bytecode/java_entry_point.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Author: Daniel Kroening, [email protected]
1313
#include <util/journalling_symbol_table.h>
1414
#include <util/suffix.h>
1515

16-
#include <goto-programs/adjust_float_expressions.h>
1716
#include <goto-programs/class_identifier.h>
1817
#include <goto-programs/goto_functions.h>
1918

@@ -240,7 +239,7 @@ void java_static_lifetime_init(
240239
code_blockt code_block;
241240

242241
const symbol_exprt rounding_mode =
243-
symbol_table.lookup_ref(rounding_mode_identifier()).symbol_expr();
242+
symbol_table.lookup_ref(config.rounding_mode_identifier()).symbol_expr();
244243
code_block.add(code_frontend_assignt{rounding_mode,
245244
from_integer(0, rounding_mode.type())});
246245

src/analyses/constant_propagator.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ Author: Peter Schrammel
1111

1212
#include "constant_propagator.h"
1313

14-
#include <goto-programs/adjust_float_expressions.h>
15-
1614
#ifdef DEBUG
1715
#include <iostream>
1816
#include <util/format_expr.h>
1917
#endif
2018

2119
#include <util/arith_tools.h>
2220
#include <util/c_types.h>
21+
#include <util/config.h>
2322
#include <util/cprover_prefix.h>
2423
#include <util/expr_util.h>
2524
#include <util/ieee_float.h>
@@ -657,7 +656,7 @@ bool constant_propagator_domaint::partial_evaluate(
657656
// if the current rounding mode is top we can
658657
// still get a non-top result by trying all rounding
659658
// modes and checking if the results are all the same
660-
if(!known_values.is_constant(rounding_mode_identifier()))
659+
if(!known_values.is_constant(config.rounding_mode_identifier()))
661660
return partial_evaluate_with_all_rounding_modes(known_values, expr, ns);
662661

663662
return replace_constants_and_simplify(known_values, expr, ns);
@@ -687,7 +686,7 @@ bool constant_propagator_domaint::partial_evaluate_with_all_rounding_modes(
687686
{
688687
valuest tmp_values = known_values;
689688
tmp_values.set_to(
690-
symbol_exprt(rounding_mode_identifier(), integer_typet()),
689+
symbol_exprt(config.rounding_mode_identifier(), integer_typet()),
691690
from_integer(rounding_modes[i], integer_typet()));
692691
exprt result = expr;
693692
if(replace_constants_and_simplify(tmp_values, result, ns))

src/ansi-c/ansi_c_internal_additions.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ Author: Daniel Kroening, [email protected]
1313

1414
#include <linking/static_lifetime_init.h>
1515

16-
#include <goto-programs/adjust_float_expressions.h>
17-
1816
const char gcc_builtin_headers_types[] =
1917
"#line 1 \"gcc_builtin_headers_types.h\"\n"
2018
#include "gcc_builtin_headers_types.inc" // IWYU pragma: keep
@@ -198,7 +196,7 @@ void ansi_c_internal_additions(std::string &code)
198196

199197
// float stuff
200198
"int " CPROVER_PREFIX "thread_local " +
201-
id2string(rounding_mode_identifier()) + '='+
199+
id2string(config.rounding_mode_identifier()) + '='+
202200
std::to_string(config.ansi_c.rounding_mode)+";\n"
203201

204202
// pipes, write, read, close

src/cpp/cpp_internal_additions.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ Author: Daniel Kroening, [email protected]
1717

1818
#include <linking/static_lifetime_init.h>
1919

20-
#include <goto-programs/adjust_float_expressions.h>
21-
2220
std::string c2cpp(const std::string &s)
2321
{
2422
std::string result;
@@ -109,7 +107,7 @@ void cpp_internal_additions(std::ostream &out)
109107

110108
// float
111109
// TODO: should be thread_local
112-
out << "int " << rounding_mode_identifier() << " = "
110+
out << "int " << config.rounding_mode_identifier() << " = "
113111
<< std::to_string(config.ansi_c.rounding_mode) << ';' << '\n';
114112

115113
// pipes, write, read, close

src/goto-instrument/full_slicer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ Author: Daniel Kroening, [email protected]
1212
#include "full_slicer.h"
1313
#include "full_slicer_class.h"
1414

15+
#include <util/config.h>
1516
#include <util/find_symbols.h>
1617

17-
#include <goto-programs/adjust_float_expressions.h>
1818
#include <goto-programs/remove_skip.h>
1919

2020
void full_slicert::add_dependencies(
@@ -248,7 +248,7 @@ static bool implicit(goto_programt::const_targett target)
248248

249249
const symbol_exprt &s = to_symbol_expr(a_lhs);
250250

251-
return s.get_identifier() == rounding_mode_identifier();
251+
return s.get_identifier() == config.rounding_mode_identifier();
252252
}
253253

254254
void full_slicert::operator()(

src/goto-programs/adjust_float_expressions.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Author: Daniel Kroening, [email protected]
1212
#include "adjust_float_expressions.h"
1313

1414
#include <util/arith_tools.h>
15-
#include <util/cprover_prefix.h>
15+
#include <util/config.h>
1616
#include <util/expr_util.h>
1717
#include <util/floatbv_expr.h>
1818
#include <util/ieee_float.h>
@@ -21,11 +21,6 @@ Author: Daniel Kroening, [email protected]
2121

2222
#include "goto_model.h"
2323

24-
irep_idt rounding_mode_identifier()
25-
{
26-
return CPROVER_PREFIX "rounding_mode";
27-
}
28-
2924
/// Iterate over an expression and check it or any of its subexpressions are
3025
/// floating point operations that haven't been adjusted with a rounding mode
3126
/// yet.
@@ -193,7 +188,7 @@ void adjust_float_expressions(exprt &expr, const namespacet &ns)
193188
return;
194189

195190
symbol_exprt rounding_mode =
196-
ns.lookup(rounding_mode_identifier()).symbol_expr();
191+
ns.lookup(config.rounding_mode_identifier()).symbol_expr();
197192

198193
rounding_mode.add_source_location() = expr.source_location();
199194

src/goto-programs/adjust_float_expressions.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,4 @@ void adjust_float_expressions(
5656
/// \see adjust_float_expressions(goto_functionst &, const namespacet &)
5757
void adjust_float_expressions(goto_modelt &goto_model);
5858

59-
/// Return the identifier of the program symbol used to
60-
/// store the current rounding mode.
61-
irep_idt rounding_mode_identifier();
62-
6359
#endif // CPROVER_GOTO_PROGRAMS_ADJUST_FLOAT_EXPRESSIONS_H

src/jsil/jsil_entry_point.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ Author: Michael Tautschnig, [email protected]
1919
#include <util/std_code.h>
2020
#include <util/symbol_table_base.h>
2121

22-
#include <goto-programs/adjust_float_expressions.h>
2322
#include <goto-programs/goto_functions.h>
2423

2524
#include <linking/static_lifetime_init.h>
@@ -38,7 +37,7 @@ static void create_initialize(symbol_table_baset &symbol_table)
3837
namespacet ns(symbol_table);
3938

4039
symbol_exprt rounding_mode =
41-
ns.lookup(rounding_mode_identifier()).symbol_expr();
40+
ns.lookup(config.rounding_mode_identifier()).symbol_expr();
4241

4342
code_assignt a(rounding_mode, from_integer(0, rounding_mode.type()));
4443
init_code.add(a);

src/jsil/jsil_internal_additions.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Author: Michael Tautschnig, [email protected]
1212
#include "jsil_internal_additions.h"
1313

1414
#include <util/c_types.h>
15+
#include <util/config.h>
1516
#include <util/std_types.h>
1617
#include <util/symbol_table_base.h>
1718

@@ -25,7 +26,7 @@ void jsil_internal_additions(symbol_table_baset &dest)
2526

2627
{
2728
symbolt symbol;
28-
symbol.name = rounding_mode_identifier();
29+
symbol.name = config.rounding_mode_identifier();
2930
symbol.base_name = symbol.name;
3031
symbol.type=signed_int_type();
3132
symbol.mode=ID_C;

0 commit comments

Comments
 (0)