Skip to content

Commit 7be7ccf

Browse files
author
Daniel Kroening
committed
remove the --fixedbv command-line option
The option was marked deprecated in January 2017. A similar effect can be achieved with #define float/double __CPROVER_fixedbv[].
1 parent 41d7a45 commit 7be7ccf

File tree

7 files changed

+41
-147
lines changed

7 files changed

+41
-147
lines changed

src/ansi-c/ansi_c_internal_additions.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ void ansi_c_architecture_strings(std::string &code)
243243
code+=architecture_string(config.ansi_c.wchar_t_width, "wchar_t_width");
244244
code+=architecture_string(config.ansi_c.char_is_unsigned, "char_is_unsigned");
245245
code+=architecture_string(config.ansi_c.wchar_t_is_unsigned, "wchar_t_is_unsigned"); // NOLINT(whitespace/line_length)
246-
code+=architecture_string(config.ansi_c.use_fixed_for_float, "fixed_for_float"); // NOLINT(whitespace/line_length)
247246
code+=architecture_string(config.ansi_c.alignment, "alignment");
248247
code+=architecture_string(config.ansi_c.memory_operand_size, "memory_operand_size"); // NOLINT(whitespace/line_length)
249248
code+=architecture_string(static_cast<int>(config.ansi_c.endianness), "endianness"); // NOLINT(whitespace/line_length)

src/ansi-c/expr2c.cpp

-9
Original file line numberDiff line numberDiff line change
@@ -219,15 +219,6 @@ std::string expr2ct::convert_rec(
219219
{
220220
const std::size_t width=to_fixedbv_type(src).get_width();
221221

222-
if(config.ansi_c.use_fixed_for_float)
223-
{
224-
if(width==config.ansi_c.single_width)
225-
return q+"float"+d;
226-
if(width==config.ansi_c.double_width)
227-
return q+"double"+d;
228-
if(width==config.ansi_c.long_double_width)
229-
return q+"long double"+d;
230-
}
231222
const std::size_t fraction_bits=to_fixedbv_type(src).get_fraction_bits();
232223
return
233224
q+"__CPROVER_fixedbv["+std::to_string(width)+"]["+

src/ansi-c/literals/convert_float_literal.cpp

+9-51
Original file line numberDiff line numberDiff line change
@@ -80,60 +80,18 @@ exprt convert_float_literal(const std::string &src)
8080
// but these aren't handled anywhere
8181
}
8282

83-
if(config.ansi_c.use_fixed_for_float)
84-
{
85-
unsigned width=result.type().get_int(ID_width);
86-
unsigned fraction_bits;
87-
const irep_idt integer_bits=result.type().get(ID_integer_bits);
88-
89-
assert(width!=0);
83+
ieee_floatt a(to_floatbv_type(result.type()));
9084

91-
if(integer_bits==irep_idt())
92-
fraction_bits=width/2; // default
93-
else
94-
fraction_bits=width-std::stoi(id2string(integer_bits));
95-
96-
mp_integer factor=mp_integer(1)<<fraction_bits;
97-
mp_integer value=significand*factor;
98-
99-
if(value!=0)
100-
{
101-
if(exponent<0)
102-
value/=power(base, -exponent);
103-
else
104-
{
105-
value*=power(base, exponent);
106-
107-
if(value>=power(2, width-1))
108-
{
109-
// saturate: use "biggest value"
110-
value=power(2, width-1)-1;
111-
}
112-
else if(value<=-power(2, width-1)-1)
113-
{
114-
// saturate: use "smallest value"
115-
value=-power(2, width-1);
116-
}
117-
}
118-
}
119-
120-
result.set(ID_value, integer2binary(value, width));
121-
}
85+
if(base==10)
86+
a.from_base10(significand, exponent);
87+
else if(base==2) // hex
88+
a.build(significand, exponent);
12289
else
123-
{
124-
ieee_floatt a(to_floatbv_type(result.type()));
125-
126-
if(base==10)
127-
a.from_base10(significand, exponent);
128-
else if(base==2) // hex
129-
a.build(significand, exponent);
130-
else
131-
assert(false);
90+
assert(false);
13291

133-
result.set(
134-
ID_value,
135-
integer2binary(a.pack(), a.spec.width()));
136-
}
92+
result.set(
93+
ID_value,
94+
integer2binary(a.pack(), a.spec.width()));
13795

13896
if(is_imaginary)
13997
{

src/cbmc/cbmc_parse_options.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class optionst;
7474
OPT_FLUSH \
7575
"(localize-faults)(localize-faults-method):" \
7676
OPT_GOTO_TRACE \
77-
"(claim):(show-claims)(fixedbv)(floatbv)(all-claims)(all-properties)" // legacy, and will eventually disappear // NOLINT(whitespace/line_length)
77+
"(claim):(show-claims)(floatbv)(all-claims)(all-properties)" // legacy, and will eventually disappear // NOLINT(whitespace/line_length)
7878
// clang-format on
7979

8080
class cbmc_parse_optionst:

src/util/c_types.cpp

+31-76
Original file line numberDiff line numberDiff line change
@@ -184,99 +184,54 @@ unsignedbv_typet char32_t_type()
184184

185185
bitvector_typet float_type()
186186
{
187-
if(config.ansi_c.use_fixed_for_float)
188-
{
189-
fixedbv_typet result;
190-
result.set_width(config.ansi_c.single_width);
191-
result.set_integer_bits(config.ansi_c.single_width/2);
192-
result.set(ID_C_c_type, ID_float);
193-
return result;
194-
}
195-
else
196-
{
197-
floatbv_typet result=
198-
ieee_float_spect::single_precision().to_type();
199-
result.set(ID_C_c_type, ID_float);
200-
return result;
201-
}
187+
floatbv_typet result=
188+
ieee_float_spect::single_precision().to_type();
189+
result.set(ID_C_c_type, ID_float);
190+
return result;
202191
}
203192

204193
bitvector_typet double_type()
205194
{
206-
if(config.ansi_c.use_fixed_for_float)
207-
{
208-
fixedbv_typet result;
209-
result.set_width(config.ansi_c.double_width);
210-
result.set_integer_bits(config.ansi_c.double_width/2);
211-
result.set(ID_C_c_type, ID_double);
212-
return result;
213-
}
214-
else
215-
{
216-
floatbv_typet result=
217-
ieee_float_spect::double_precision().to_type();
218-
result.set(ID_C_c_type, ID_double);
219-
return result;
220-
}
195+
floatbv_typet result=
196+
ieee_float_spect::double_precision().to_type();
197+
result.set(ID_C_c_type, ID_double);
198+
return result;
221199
}
222200

223201
bitvector_typet long_double_type()
224202
{
225-
if(config.ansi_c.use_fixed_for_float)
203+
floatbv_typet result;
204+
if(config.ansi_c.long_double_width==128)
205+
result=ieee_float_spect::quadruple_precision().to_type();
206+
else if(config.ansi_c.long_double_width==64)
207+
result=ieee_float_spect::double_precision().to_type();
208+
else if(config.ansi_c.long_double_width==80)
226209
{
227-
fixedbv_typet result;
228-
result.set_width(config.ansi_c.long_double_width);
229-
result.set_integer_bits(config.ansi_c.long_double_width/2);
230-
result.set(ID_C_c_type, ID_long_double);
231-
return result;
210+
// x86 extended precision has 80 bits in total, and
211+
// deviating from IEEE, does not use a hidden bit.
212+
// We use the closest we have got, but the below isn't accurate.
213+
result=ieee_float_spect(63, 15).to_type();
232214
}
233-
else
215+
else if(config.ansi_c.long_double_width==96)
234216
{
235-
floatbv_typet result;
236-
if(config.ansi_c.long_double_width==128)
237-
result=ieee_float_spect::quadruple_precision().to_type();
238-
else if(config.ansi_c.long_double_width==64)
239-
result=ieee_float_spect::double_precision().to_type();
240-
else if(config.ansi_c.long_double_width==80)
241-
{
242-
// x86 extended precision has 80 bits in total, and
243-
// deviating from IEEE, does not use a hidden bit.
244-
// We use the closest we have got, but the below isn't accurate.
245-
result=ieee_float_spect(63, 15).to_type();
246-
}
247-
else if(config.ansi_c.long_double_width==96)
248-
{
249-
result=ieee_float_spect(80, 15).to_type();
250-
// not quite right. The extra bits beyond 80 are usually padded.
251-
}
252-
else
253-
INVARIANT(false, "width of long double");
254-
255-
result.set(ID_C_c_type, ID_long_double);
256-
257-
return result;
217+
result=ieee_float_spect(80, 15).to_type();
218+
// not quite right. The extra bits beyond 80 are usually padded.
258219
}
220+
else
221+
INVARIANT(false, "width of long double");
222+
223+
result.set(ID_C_c_type, ID_long_double);
224+
225+
return result;
259226
}
260227

261228
bitvector_typet gcc_float128_type()
262229
{
263230
// not same as long double!
264-
265-
if(config.ansi_c.use_fixed_for_float)
266-
{
267-
fixedbv_typet result;
268-
result.set_width(128);
269-
result.set_integer_bits(128/2);
270-
result.set(ID_C_c_type, ID_gcc_float128);
271-
return result;
272-
}
273-
else
274-
{
275-
floatbv_typet result=
276-
ieee_float_spect::quadruple_precision().to_type();
277-
result.set(ID_C_c_type, ID_gcc_float128);
278-
return result;
279-
}
231+
floatbv_typet result=
232+
ieee_float_spect::quadruple_precision().to_type();
233+
result.set(ID_C_c_type, ID_gcc_float128);
234+
return result;
280235
}
281236

282237
signedbv_typet pointer_diff_type()

src/util/config.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,6 @@ bool configt::set(const cmdlinet &cmdline)
739739
ansi_c.single_precision_constant=false;
740740
ansi_c.for_has_scope=true; // C99 or later
741741
ansi_c.c_standard=ansi_ct::default_c_standard();
742-
ansi_c.use_fixed_for_float=false;
743742
ansi_c.endianness=ansi_ct::endiannesst::NO_ENDIANNESS;
744743
ansi_c.os=ansi_ct::ost::NO_OS;
745744
ansi_c.arch="none";
@@ -791,12 +790,6 @@ bool configt::set(const cmdlinet &cmdline)
791790
if(cmdline.isset("include"))
792791
ansi_c.include_files=cmdline.get_values("include");
793792

794-
if(cmdline.isset("floatbv"))
795-
ansi_c.use_fixed_for_float=false;
796-
797-
if(cmdline.isset("fixedbv"))
798-
ansi_c.use_fixed_for_float=true;
799-
800793
// the default architecture is the one we run on
801794
irep_idt this_arch=this_architecture();
802795
irep_idt arch=this_arch;
@@ -1142,7 +1135,6 @@ void configt::set_from_symbol_table(
11421135

11431136
ansi_c.char_is_unsigned=unsigned_from_ns(ns, "char_is_unsigned")!=0;
11441137
ansi_c.wchar_t_is_unsigned=unsigned_from_ns(ns, "wchar_t_is_unsigned")!=0;
1145-
ansi_c.use_fixed_for_float=unsigned_from_ns(ns, "fixed_for_float")!=0;
11461138
// for_has_scope, single_precision_constant, rounding_mode not
11471139
// stored in namespace
11481140

src/util/config.h

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ class configt
4141

4242
// various language options
4343
bool char_is_unsigned, wchar_t_is_unsigned;
44-
bool use_fixed_for_float;
4544
bool for_has_scope;
4645
bool single_precision_constant;
4746
enum class c_standardt { C89, C99, C11 } c_standard;

0 commit comments

Comments
 (0)