Skip to content

Commit ad916e0

Browse files
author
Daniel Kroening
committed
bugfix: __float128
1 parent 4cb2afa commit ad916e0

5 files changed

+41
-19
lines changed

src/ansi-c/ansi_c_internal_additions.cpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,25 @@ void ansi_c_internal_additions(std::string &code)
192192
// there are many more, e.g., look at
193193
// https://developer.apple.com/library/mac/#documentation/developertools/gcc-4.0.1/gcc/Target-Builtins.html
194194

195-
if(config.ansi_c.arch=="i386" ||
196-
config.ansi_c.arch=="x86_64" ||
197-
config.ansi_c.arch=="x32")
195+
if(
196+
config.ansi_c.arch == "i386" || config.ansi_c.arch == "x86_64" ||
197+
config.ansi_c.arch == "x32" || config.ansi_c.arch == "powerpc" ||
198+
config.ansi_c.arch == "ppc64" || config.ansi_c.arch == "ppc64le" ||
199+
config.ansi_c.arch == "ia64")
198200
{
199-
if(config.ansi_c.mode == configt::ansi_ct::flavourt::CLANG)
200-
code+="typedef double __float128;\n"; // clang doesn't do __float128
201+
// https://gcc.gnu.org/onlinedocs/gcc/Floating-Types.html
202+
// clang doesn't do __float128
203+
// Note that this is a typedef and not a keyword.
204+
if(config.ansi_c.mode != configt::ansi_ct::flavourt::CLANG)
205+
code += "typedef __CPROVER_Float128 __float128;\n";
206+
}
207+
else if(config.ansi_c.arch == "hppa")
208+
{
209+
// https://gcc.gnu.org/onlinedocs/gcc/Floating-Types.html
210+
// clang doesn't do __float128
211+
// Note that this is a typedef and not a keyword.
212+
if(config.ansi_c.mode != configt::ansi_ct::flavourt::CLANG)
213+
code+="typedef long double __float128;\n";
201214
}
202215

203216
// On 64-bit systems, both gcc and clang have typedefs

src/ansi-c/gcc_builtin_headers_ia32.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// from
22
// http://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/X86-Built_002din-Functions.html
33

4-
__float128 __builtin_fabsq(__float128);
5-
__float128 __builtin_copysignq(__float128, __float128);
4+
__CPROVER_Float128 __builtin_fabsq(__CPROVER_Float128);
5+
__CPROVER_Float128 __builtin_copysignq(__CPROVER_Float128, __CPROVER_Float128);
66
void __builtin_ia32_pause();
7-
__float128 __builtin_infq(void);
8-
__float128 __builtin_huge_valq(void);
7+
__CPROVER_Float128 __builtin_infq(void);
8+
__CPROVER_Float128 __builtin_huge_valq(void);
99
__gcc_v8qi __builtin_ia32_paddb(__gcc_v8qi, __gcc_v8qi);
1010
__gcc_v4hi __builtin_ia32_paddw(__gcc_v4hi, __gcc_v4hi);
1111
__gcc_v2si __builtin_ia32_paddd(__gcc_v2si, __gcc_v2si);

src/ansi-c/get-gcc-builtins.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ cat > builtins.h <<EOF
102102
// some newer versions of GCC apparently support __floatXYZ
103103
#define dfloat32_type_node __float32
104104
#define dfloat64_type_node __float64
105-
#define dfloat128_type_node __float128
105+
#define dfloat128_type_node __CPROVER_Float128
106106
107107
#define build_qualified_type(t, q) q t
108108
#define build_pointer_type(t) t*

src/ansi-c/scanner.l

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -496,17 +496,14 @@ void ansi_c_scanner_init()
496496
return make_identifier();
497497
}
498498

499-
"__float128" { // clang doesn't have it
500-
if(PARSER.mode==configt::ansi_ct::flavourt::GCC)
499+
"_Float128" { if(PARSER.Float128_type)
501500
{ loc(); return TOK_GCC_FLOAT128; }
502501
else
503502
return make_identifier();
504503
}
505504

506-
"_Float128" { if(PARSER.Float128_type)
507-
{ loc(); return TOK_GCC_FLOAT128; }
508-
else
509-
return make_identifier();
505+
"__CPROVER_Float128" {
506+
loc(); return TOK_GCC_FLOAT128;
510507
}
511508

512509
"_Float128x" { if(PARSER.ts_18661_3_Floatn_types)

src/cpp/cpp_internal_additions.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,23 @@ void cpp_internal_additions(std::ostream &out)
124124

125125
if(
126126
config.ansi_c.arch == "i386" || config.ansi_c.arch == "x86_64" ||
127-
config.ansi_c.arch == "x32")
127+
config.ansi_c.arch == "x32" || config.ansi_c.arch == "powerpc" ||
128+
config.ansi_c.arch == "ppc64" || config.ansi_c.arch == "ppc64le" ||
129+
config.ansi_c.arch == "ia64")
128130
{
131+
// https://gcc.gnu.org/onlinedocs/gcc/Floating-Types.html
129132
// clang doesn't do __float128
130-
if(config.ansi_c.mode == configt::ansi_ct::flavourt::CLANG)
131-
out << "typedef double __float128;" << '\n';
133+
// Note that this is a typedef and not a keyword.
134+
if(config.ansi_c.mode != configt::ansi_ct::flavourt::CLANG)
135+
out << "typedef __CPROVER_Float128 __float128;" << '\n';
136+
}
137+
else if(config.ansi_c.arch == "hppa")
138+
{
139+
// https://gcc.gnu.org/onlinedocs/gcc/Floating-Types.html
140+
// clang doesn't do __float128
141+
// Note that this is a typedef and not a keyword.
142+
if(config.ansi_c.mode != configt::ansi_ct::flavourt::CLANG)
143+
out << "typedef long double __float128;" << '\n';
132144
}
133145

134146
// On 64-bit systems, gcc has typedefs

0 commit comments

Comments
 (0)