Skip to content

Commit a06a215

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 73a1414 commit a06a215

15 files changed

+27
-43
lines changed

jbmc/src/java_bytecode/java_bytecode_internal_additions.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,19 @@ Author: Daniel Kroening, [email protected]
1313
#include "remove_exceptions.h"
1414

1515
#include <util/c_types.h>
16+
#include <util/config.h>
1617
#include <util/cprover_prefix.h>
1718
#include <util/pointer_expr.h>
1819
#include <util/std_types.h>
1920
#include <util/symbol_table_base.h>
2021

21-
#include <goto-programs/adjust_float_expressions.h>
22-
2322
void java_internal_additions(symbol_table_baset &dest)
2423
{
2524
// add __CPROVER_rounding_mode
2625

2726
{
2827
symbolt symbol;
29-
symbol.name = rounding_mode_identifier();
28+
symbol.name = config.rounding_mode_identifier();
3029
symbol.base_name = symbol.name;
3130
symbol.type=signed_int_type();
3231
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>
@@ -658,7 +657,7 @@ bool constant_propagator_domaint::partial_evaluate(
658657
// if the current rounding mode is top we can
659658
// still get a non-top result by trying all rounding
660659
// modes and checking if the results are all the same
661-
if(!known_values.is_constant(rounding_mode_identifier()))
660+
if(!known_values.is_constant(config.rounding_mode_identifier()))
662661
return partial_evaluate_with_all_rounding_modes(known_values, expr, ns);
663662

664663
return replace_constants_and_simplify(known_values, expr, ns);
@@ -688,7 +687,7 @@ bool constant_propagator_domaint::partial_evaluate_with_all_rounding_modes(
688687
{
689688
valuest tmp_values = known_values;
690689
tmp_values.set_to(
691-
symbol_exprt(rounding_mode_identifier(), integer_typet()),
690+
symbol_exprt(config.rounding_mode_identifier(), integer_typet()),
692691
from_integer(rounding_modes[i], integer_typet()));
693692
exprt result = expr;
694693
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
"# 1 \"gcc_builtin_headers_types.h\"\n"
2018
#include "gcc_builtin_headers_types.inc"
@@ -210,7 +208,7 @@ void ansi_c_internal_additions(std::string &code)
210208

211209
// float stuff
212210
"int " CPROVER_PREFIX "thread_local " +
213-
id2string(rounding_mode_identifier()) + '='+
211+
id2string(config.rounding_mode_identifier()) + '='+
214212
std::to_string(config.ansi_c.rounding_mode)+";\n"
215213

216214
// 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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +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>
16-
#include <util/cprover_prefix.h>
1717

18-
#include <goto-programs/adjust_float_expressions.h>
1918
#include <goto-programs/remove_skip.h>
2019

2120
void full_slicert::add_dependencies(
@@ -249,7 +248,7 @@ static bool implicit(goto_programt::const_targett target)
249248

250249
const symbol_exprt &s = to_symbol_expr(a_lhs);
251250

252-
return s.get_identifier() == rounding_mode_identifier();
251+
return s.get_identifier() == config.rounding_mode_identifier();
253252
}
254253

255254
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.
@@ -191,7 +186,7 @@ void adjust_float_expressions(exprt &expr, const namespacet &ns)
191186
return;
192187

193188
symbol_exprt rounding_mode =
194-
ns.lookup(rounding_mode_identifier()).symbol_expr();
189+
ns.lookup(config.rounding_mode_identifier()).symbol_expr();
195190

196191
rounding_mode.add_source_location() = expr.source_location();
197192

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
@@ -18,7 +18,6 @@ Author: Michael Tautschnig, [email protected]
1818
#include <util/std_code.h>
1919
#include <util/symbol_table.h>
2020

21-
#include <goto-programs/adjust_float_expressions.h>
2221
#include <goto-programs/goto_functions.h>
2322

2423
#include <linking/static_lifetime_init.h>
@@ -37,7 +36,7 @@ static void create_initialize(symbol_tablet &symbol_table)
3736
namespacet ns(symbol_table);
3837

3938
symbol_exprt rounding_mode =
40-
ns.lookup(rounding_mode_identifier()).symbol_expr();
39+
ns.lookup(config.rounding_mode_identifier()).symbol_expr();
4140

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

src/jsil/jsil_internal_additions.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,11 @@ Author: Michael Tautschnig, [email protected]
1111

1212
#include "jsil_internal_additions.h"
1313

14-
#include <goto-programs/adjust_float_expressions.h>
15-
14+
#include <util/c_types.h>
15+
#include <util/config.h>
1616
#include <util/std_types.h>
17-
#include <util/cprover_prefix.h>
1817
#include <util/symbol_table.h>
1918

20-
#include <util/c_types.h>
21-
2219
#include "jsil_types.h"
2320

2421
void jsil_internal_additions(symbol_tablet &dest)
@@ -27,7 +24,7 @@ void jsil_internal_additions(symbol_tablet &dest)
2724

2825
{
2926
symbolt symbol;
30-
symbol.name = rounding_mode_identifier();
27+
symbol.name = config.rounding_mode_identifier();
3128
symbol.base_name = symbol.name;
3229
symbol.type=signed_int_type();
3330
symbol.mode=ID_C;

0 commit comments

Comments
 (0)