aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-decl.c
diff options
context:
space:
mode:
authorJon Grimm <jgrimm2@us.ibm.com>2005-12-16 06:38:26 +0000
committerBen Elliston <bje@gcc.gnu.org>2005-12-16 17:38:26 +1100
commit9a8ce21f3b47a109b9ac35239e21198bb36e1146 (patch)
tree321186c5aa65ee914dcef01ba4318ad4b03f142d /gcc/c-decl.c
parent425de7399f1ad69ba9ff0f71ba8f9343798277b9 (diff)
downloadgcc-9a8ce21f3b47a109b9ac35239e21198bb36e1146.zip
gcc-9a8ce21f3b47a109b9ac35239e21198bb36e1146.tar.gz
gcc-9a8ce21f3b47a109b9ac35239e21198bb36e1146.tar.bz2
target-def.h (TARGET_DECIMAL_FLOAT_SUPPORTED_P): New.
2005-12-16 Jon Grimm <jgrimm2@us.ibm.com> Janis Johnson <janis187@us.ibm.com> Ben Elliston <bje@au.ibm.com> * target-def.h (TARGET_DECIMAL_FLOAT_SUPPORTED_P): New. (TARGET_INITIALIZER): Add TARGET_DECIMAL_FLOAT_P. * target.h (struct gcc_target): Add decimal_float_supported_p. * targhooks.c (default_scalar_mode_supported_p): Handle MODE_DECIMAL_FLOAT. * builtins.def: Add new builtins for 32, 64 and 128 bit variants of inf, nan, finite, isinf and isnan. * builtin-types.def (BT_DFLOAT32, BT_DFLOAT64, BT_DFLOAT128, BT_DFLOAT32_PTR, BT_DFLOAT64_PTR, BT_DFLOAT128_PTR, BT_FN_DFLOAT32, BT_FN_DFLOAT64, BT_FN_DFLOAT128, BT_FN_INT_DFLOAT32, BT_FN_INT_DFLOAT64, BT_FN_INT_DFLOAT128, BT_FN_DFLOAT32_CONST_STRING, BT_FN_DFLOAT64_CONST_STRING, BT_FN_DFLOAT32_CONST_STRING, BT_FN_DFLOAT32_DFLOAT32, BT_FN_DFLOAT64_DFLOAT64, BT_FN_DFLOAT128_DFLOAT128): New. * c-decl.c (declspecs_add_type): Verify combos on type qualifiers. Pedwarn if decimal floating point types are used. Error if decimal floating point is not supported by the target. (finish_declspecs): Return type from DFP typespec_word. * c-typeck.c (c_common_type): Choose the decimal floating point type with the greater precision when determining a common type. (convert_arguments): Warn if there is a mismatch between argument and prototype for decimal float types. Warn of conversions with binary float types and of precision narrowing due to prototype. * c-parser.c (reswords): Add _Decimal32, _Decimal64, _Decimal128. (c_token_starts_typename): Handle RID_DFLOAT32/64/128. (c_token_starts_declspecs): Likewise. (c_parser_attributes): Likewise. * c-common.h (enum rid): Add new enumeration values RID_DFLOAT32, RID_DFLOAT64, RID_DFLOAT128. (T_D32, TEX_D32, T_D64, TEX_D64, T_D128, TEX_D128): New macros. * c-common.c (c_common_type_for_mode): Handle decimal float modes. (shorten_compare): Convert DFP/BFP operands to a common type. (c_common_modes_and_builtins): Register built-in decimal float types if the target supports them. (handle_mode_addtribute): Handle MODE_DECIMAL_FLOAT. * builtins.c (fold_builtin_1): Handle 32, 64 and 128 bit cases of inf, nan, finite, isinf and isnan builtins. * c-cppbuiltin.c (builtin_define_decimal_float_constants): New. (builtin_define_float_constants): Assert non-decimal radix. (c_cpp_builtins): Register built-in __DEC_EVAL_METHOD__ define. Call builtin_define_decimal_float_constants for each type. * c-lex.c (interpret_float): Decode decimal float types from CPP_N flags. Use real_from_string3, which can handle binary or decimal floats. * c-tree.h (enum c_typespec_keyword): Add cts_dfloat32, cts_dfloat64, cts_dfloat128. * tree.c (build_common_tree_nodes_2): Add decimal float types. * tree.h (enum tree_index): Add new enumeration values TI_DFLOAT32_TYPE, TI_DFLOAT64_TYPE, TI_DFLOAT128_TYPE, TI_DFLOAT32_PTR_TYPE, TI_DFLOAT64_PTR_TYPE, TI_DFLOAT128_PTR_TYPE. (dfloat32_type_node): New macro. (dfloat64_type_node, dfloat128_type_node): Likewise. (dfloat32_ptr_type_node, dfloat64_ptr_type_node): Likewise. (dfloat128_ptr_type_node): Likewise. * c-pretty-print.c (pp_c_floating_constant): Append 32, 64 and 128 bit decimal floating point types with "df", "dd" and "dl". * c-format.h (enum format_lengths): Add new enumeration values FMT_LEN_H, FMT_LEN_D and FMT_LEN_DD. * c-format.c (printf_length_specs, scanf_length_specs): Add entries for H, D, DD. (print_char_table, scan_char_table): Use new entries. (asm_fprintf_char_table, gcc_diag_char_table, gcc_cdiag_char_table, gcc_cxxdiag_char_table): Adjust for longer length arrays. * defaults.h (DECIMAL32_TYPE_SIZE): Define. (DECIMAL64_TYPE_SIZE): Likewise. (DECIMAL128_TYPE_SIZE): Likewise. (TARGET_DEC_EVAL_METHOD): Likewise. * doc/extend.texi (Decimal Float): New node. (Constructing Calls): Document decimal float built-ins. * doc/tm.texi: Document TARGET_DECIMAL_FLOAT_SUPPORTED_P hook. * Makefile.in (USER_H): Add $(srcdir)/ginclude/decfloat.h. * ginclude/decfloat.h: New file. Co-Authored-By: Ben Elliston <bje@au.ibm.com> Co-Authored-By: Janis Johnson <janis187@us.ibm.com> From-SVN: r108629
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r--gcc/c-decl.c98
1 files changed, 98 insertions, 0 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 44e03ab..8a27e97 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -7069,6 +7069,15 @@ declspecs_add_type (struct c_declspecs *specs, struct c_typespec spec)
else if (specs->typespec_word == cts_float)
error ("both %<long%> and %<float%> in "
"declaration specifiers");
+ else if (specs->typespec_word == cts_dfloat32)
+ error ("both %<long%> and %<_Decimal32%> in "
+ "declaration specifiers");
+ else if (specs->typespec_word == cts_dfloat64)
+ error ("both %<long%> and %<_Decimal64%> in "
+ "declaration specifiers");
+ else if (specs->typespec_word == cts_dfloat128)
+ error ("both %<long%> and %<_Decimal128%> in "
+ "declaration specifiers");
else
specs->long_p = true;
break;
@@ -7092,6 +7101,15 @@ declspecs_add_type (struct c_declspecs *specs, struct c_typespec spec)
else if (specs->typespec_word == cts_double)
error ("both %<short%> and %<double%> in "
"declaration specifiers");
+ else if (specs->typespec_word == cts_dfloat32)
+ error ("both %<short%> and %<_Decimal32%> in "
+ "declaration specifiers");
+ else if (specs->typespec_word == cts_dfloat64)
+ error ("both %<short%> and %<_Decimal64%> in "
+ "declaration specifiers");
+ else if (specs->typespec_word == cts_dfloat128)
+ error ("both %<short%> and %<_Decimal128%> in "
+ "declaration specifiers");
else
specs->short_p = true;
break;
@@ -7112,6 +7130,15 @@ declspecs_add_type (struct c_declspecs *specs, struct c_typespec spec)
else if (specs->typespec_word == cts_double)
error ("both %<signed%> and %<double%> in "
"declaration specifiers");
+ else if (specs->typespec_word == cts_dfloat32)
+ error ("both %<signed%> and %<_Decimal32%> in "
+ "declaration specifiers");
+ else if (specs->typespec_word == cts_dfloat64)
+ error ("both %<signed%> and %<_Decimal64%> in "
+ "declaration specifiers");
+ else if (specs->typespec_word == cts_dfloat128)
+ error ("both %<signed%> and %<_Decimal128%> in "
+ "declaration specifiers");
else
specs->signed_p = true;
break;
@@ -7132,6 +7159,15 @@ declspecs_add_type (struct c_declspecs *specs, struct c_typespec spec)
else if (specs->typespec_word == cts_double)
error ("both %<unsigned%> and %<double%> in "
"declaration specifiers");
+ else if (specs->typespec_word == cts_dfloat32)
+ error ("both %<unsigned%> and %<_Decimal32%> in "
+ "declaration specifiers");
+ else if (specs->typespec_word == cts_dfloat64)
+ error ("both %<unsigned%> and %<_Decimal64%> in "
+ "declaration specifiers");
+ else if (specs->typespec_word == cts_dfloat128)
+ error ("both %<unsigned%> and %<_Decimal128%> in "
+ "declaration specifiers");
else
specs->unsigned_p = true;
break;
@@ -7145,6 +7181,15 @@ declspecs_add_type (struct c_declspecs *specs, struct c_typespec spec)
else if (specs->typespec_word == cts_bool)
error ("both %<complex%> and %<_Bool%> in "
"declaration specifiers");
+ else if (specs->typespec_word == cts_dfloat32)
+ error ("both %<complex%> and %<_Decimal32%> in "
+ "declaration specifiers");
+ else if (specs->typespec_word == cts_dfloat64)
+ error ("both %<complex%> and %<_Decimal64%> in "
+ "declaration specifiers");
+ else if (specs->typespec_word == cts_dfloat128)
+ error ("both %<complex%> and %<_Decimal128%> in "
+ "declaration specifiers");
else
specs->complex_p = true;
break;
@@ -7250,6 +7295,47 @@ declspecs_add_type (struct c_declspecs *specs, struct c_typespec spec)
else
specs->typespec_word = cts_double;
return specs;
+ case RID_DFLOAT32:
+ case RID_DFLOAT64:
+ case RID_DFLOAT128:
+ {
+ const char *str;
+ if (i == RID_DFLOAT32)
+ str = "_Decimal32";
+ else if (i == RID_DFLOAT64)
+ str = "_Decimal64";
+ else
+ str = "_Decimal128";
+ if (specs->long_long_p)
+ error ("both %<long long%> and %<%s%> in "
+ "declaration specifiers", str);
+ if (specs->long_p)
+ error ("both %<long%> and %<%s%> in "
+ "declaration specifiers", str);
+ else if (specs->short_p)
+ error ("both %<short%> and %<%s%> in "
+ "declaration specifiers", str);
+ else if (specs->signed_p)
+ error ("both %<signed%> and %<%s%> in "
+ "declaration specifiers", str);
+ else if (specs->unsigned_p)
+ error ("both %<unsigned%> and %<%s%> in "
+ "declaration specifiers", str);
+ else if (specs->complex_p)
+ error ("both %<complex%> and %<%s%> in "
+ "declaration specifiers", str);
+ else if (i == RID_DFLOAT32)
+ specs->typespec_word = cts_dfloat32;
+ else if (i == RID_DFLOAT64)
+ specs->typespec_word = cts_dfloat64;
+ else
+ specs->typespec_word = cts_dfloat128;
+ }
+ if (!targetm.decimal_float_supported_p ())
+ error ("decimal floating point not supported for this target");
+ if (pedantic)
+ pedwarn ("ISO C does not support decimal floating point");
+ return specs;
default:
/* ObjC reserved word "id", handled below. */
break;
@@ -7527,6 +7613,18 @@ finish_declspecs (struct c_declspecs *specs)
: double_type_node);
}
break;
+ case cts_dfloat32:
+ case cts_dfloat64:
+ case cts_dfloat128:
+ gcc_assert (!specs->long_p && !specs->long_long_p && !specs->short_p
+ && !specs->signed_p && !specs->unsigned_p && !specs->complex_p);
+ if (specs->typespec_word == cts_dfloat32)
+ specs->type = dfloat32_type_node;
+ else if (specs->typespec_word == cts_dfloat64)
+ specs->type = dfloat64_type_node;
+ else
+ specs->type = dfloat128_type_node;
+ break;
default:
gcc_unreachable ();
}