Skip to content

Commit 96dfda9

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 22d25d1 commit 96dfda9

13 files changed

+26
-36
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,22 +9,21 @@ 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
{
27-
symbolt symbol{rounding_mode_identifier(), signed_int_type(), ID_C};
26+
symbolt symbol{config.rounding_mode_identifier(), signed_int_type(), ID_C};
2827
symbol.base_name = symbol.name;
2928
symbol.is_lvalue=true;
3029
symbol.is_state_var=true;

jbmc/src/java_bytecode/java_entry_point.cpp

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

17-
#include <goto-programs/adjust_float_expressions.h>
1817
#include <goto-programs/class_identifier.h>
1918
#include <goto-programs/goto_functions.h>
2019

@@ -239,7 +238,7 @@ void java_static_lifetime_init(
239238
code_blockt code_block;
240239

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

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>
@@ -663,7 +662,7 @@ bool constant_propagator_domaint::partial_evaluate(
663662
// if the current rounding mode is top we can
664663
// still get a non-top result by trying all rounding
665664
// modes and checking if the results are all the same
666-
if(!known_values.is_constant(rounding_mode_identifier(), ns))
665+
if(!known_values.is_constant(config.rounding_mode_identifier(), ns))
667666
return partial_evaluate_with_all_rounding_modes(known_values, expr, ns);
668667

669668
return replace_constants_and_simplify(known_values, expr, ns);
@@ -693,7 +692,7 @@ bool constant_propagator_domaint::partial_evaluate_with_all_rounding_modes(
693692
{
694693
valuest tmp_values = known_values;
695694
tmp_values.set_to(
696-
symbol_exprt(rounding_mode_identifier(), integer_typet()),
695+
symbol_exprt(config.rounding_mode_identifier(), integer_typet()),
697696
from_integer(rounding_modes[i], integer_typet()));
698697
exprt result = expr;
699698
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
@@ -11,8 +11,6 @@ Author: Daniel Kroening, [email protected]
1111
#include <util/c_types.h>
1212
#include <util/config.h>
1313

14-
#include <goto-programs/adjust_float_expressions.h>
15-
1614
#include <linking/static_lifetime_init.h>
1715

1816
#include "ansi_c_parser.h"
@@ -179,7 +177,7 @@ void ansi_c_internal_additions(std::string &code, bool support_float16_type)
179177

180178
// float stuff
181179
"int " CPROVER_PREFIX "thread_local " +
182-
id2string(rounding_mode_identifier()) + '='+
180+
id2string(config.rounding_mode_identifier()) + '='+
183181
std::to_string(config.ansi_c.rounding_mode)+";\n"
184182

185183
// 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;
@@ -86,7 +84,7 @@ void cpp_internal_additions(std::ostream &out)
8684

8785
// float
8886
// TODO: should be thread_local
89-
out << "int " << rounding_mode_identifier() << " = "
87+
out << "int " << config.rounding_mode_identifier() << " = "
9088
<< std::to_string(config.ansi_c.rounding_mode) << ';' << '\n';
9189

9290
// 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.
@@ -195,7 +190,7 @@ void adjust_float_expressions(exprt &expr, const namespacet &ns)
195190
return;
196191

197192
symbol_exprt rounding_mode =
198-
ns.lookup(rounding_mode_identifier()).symbol_expr();
193+
ns.lookup(config.rounding_mode_identifier()).symbol_expr();
199194

200195
rounding_mode.add_source_location() = expr.source_location();
201196

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/linking/module_dependencies.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
ansi-c
2-
goto-programs
32
langapi # should go away
43
linking
54
util

src/linking/remove_internal_symbols.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ Author: Daniel Kroening
1919
#include <util/std_types.h>
2020
#include <util/symbol_table_base.h>
2121

22-
#include <goto-programs/adjust_float_expressions.h>
23-
2422
#include "static_lifetime_init.h"
2523

2624
static void get_symbols(
@@ -153,7 +151,7 @@ void remove_internal_symbols(
153151
special.insert(CPROVER_PREFIX "freeable");
154152
special.insert(CPROVER_PREFIX "is_freeable");
155153
special.insert(CPROVER_PREFIX "was_freed");
156-
special.insert(rounding_mode_identifier());
154+
special.insert(config.rounding_mode_identifier());
157155
special.insert("__new");
158156
special.insert("__new_array");
159157
special.insert("__placement_new");

0 commit comments

Comments
 (0)