aboutsummaryrefslogtreecommitdiff
path: root/gcc/c/c-parser.cc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2024-11-15 08:43:48 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2024-11-15 08:43:48 +0100
commit1910ecf15bfcc560dc5089d42c9d75bc30b35c2a (patch)
treece06587321e192eb766a57984a489d0cdb65f125 /gcc/c/c-parser.cc
parent3757009af71cd8404198909f087b5140ce42500a (diff)
downloadgcc-1910ecf15bfcc560dc5089d42c9d75bc30b35c2a.zip
gcc-1910ecf15bfcc560dc5089d42c9d75bc30b35c2a.tar.gz
gcc-1910ecf15bfcc560dc5089d42c9d75bc30b35c2a.tar.bz2
c: Add _Decimal64x support
The following patch adds _Decimal64x type support. Our dfp libraries (dpd & libbid) can only handle decimal32, decimal64 and decimal128 formats and I don't see that changing any time soon, so the following patch just hardcodes that _Decimal64x has the same mode as _Decimal128 (but is a distinct type). In the unlikely event some target would introduce something different that can be of course changed with target hooks but would be an ABI change. _Decimal128x is optional and we don't have a wider decimal type, so that type isn't added. 2024-11-15 Jakub Jelinek <jakub@redhat.com> gcc/ * tree-core.h (enum tree_index): Add TI_DFLOAT64X_TYPE. * tree.h (dfloat64x_type_node): Define. * tree.cc (build_common_tree_nodes): Initialize dfloat64x_type_node. * builtin-types.def (BT_DFLOAT64X): New DEF_PRIMITIVE_TYPE. (BT_FN_DFLOAT64X): New DEF_FUNCTION_TYPE_0. (BT_FN_DFLOAT64X_CONST_STRING, BT_FN_DFLOAT64X_DFLOAT64X): New DEF_FUNCTION_TYPE_1. * builtins.def (BUILT_IN_FABSD64X, BUILT_IN_INFD64X, BUILT_IN_NAND64X, BUILT_IN_NANSD64X): New builtins. * builtins.cc (expand_builtin): Handle BUILT_IN_FABSD64X. (fold_builtin_0): Handle BUILT_IN_INFD64X. (fold_builtin_1): Handle BUILT_IN_FABSD64X. * fold-const-call.cc (fold_const_call): Handle CFN_BUILT_IN_NAND64X and CFN_BUILT_IN_NANSD64X. * ginclude/float.h (DEC64X_MANT_DIG, DEC64X_MIN_EXP, DEC64X_MAX_EXP, DEC64X_MAX, DEC64X_EPSILON, DEC64X_MIN, DEC64X_TRUE_MIN, DEC64X_SNAN): Redefine. gcc/c-family/ * c-common.h (enum rid): Add RID_DFLOAT64X. * c-common.cc (c_global_trees): Fix comment typo. Add dfloat64x_type_node. (c_common_nodes_and_builtins): Handle RID_DFLOAT64X. * c-cppbuiltin.cc (c_cpp_builtins): Call builtin_define_decimal_float_constants also for dfloat64x_type_node if non-NULL. * c-lex.cc (interpret_float): Handle d64x suffixes. * c-pretty-print.cc (pp_c_floating_constant): Print d64x suffixes on dfloat64x_type_node typed constants. gcc/c/ * c-tree.h (enum c_typespec_keyword): Add cts_dfloat64x and adjust comment. * c-parser.cc (c_keyword_starts_typename, c_token_starts_declspecs, c_parser_declspecs, c_parser_gnu_attribute_any_word): Handle RID_DFLOAT64X. (c_parser_postfix_expression): Handle _Decimal64x arguments in __builtin_tgmath. (warn_for_abs): Handle BUILT_IN_FABSD64X. * c-decl.cc (declspecs_add_type): Handle cts_dfloat64x and RID_DFLOAT64X. (finish_declspecs): Handle cts_dfloat64x. * c-typeck.cc (c_common_type): Handle dfloat64x_type_node. gcc/testsuite/ * gcc.dg/dfp/c11-decimal64x-1.c: New test. * gcc.dg/dfp/c11-decimal64x-2.c: New test. * gcc.dg/dfp/c23-decimal64x-1.c: New test. * gcc.dg/dfp/c23-decimal64x-2.c: New test. * gcc.dg/dfp/c23-decimal64x-3.c: New test. * gcc.dg/dfp/c23-decimal64x-4.c: New test. libcpp/ * expr.cc (interpret_float_suffix): Handle d64x and D64x suffixes, adjust comment.
Diffstat (limited to 'gcc/c/c-parser.cc')
-rw-r--r--gcc/c/c-parser.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc
index 3ab8a49..70fbf94 100644
--- a/gcc/c/c-parser.cc
+++ b/gcc/c/c-parser.cc
@@ -597,6 +597,7 @@ c_keyword_starts_typename (enum rid keyword)
case RID_DFLOAT32:
case RID_DFLOAT64:
case RID_DFLOAT128:
+ case RID_DFLOAT64X:
CASE_RID_FLOATN_NX:
case RID_BOOL:
case RID_BITINT:
@@ -801,6 +802,7 @@ c_token_starts_declspecs (c_token *token)
case RID_DFLOAT32:
case RID_DFLOAT64:
case RID_DFLOAT128:
+ case RID_DFLOAT64X:
CASE_RID_FLOATN_NX:
case RID_BOOL:
case RID_BITINT:
@@ -3505,6 +3507,7 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs,
case RID_DFLOAT32:
case RID_DFLOAT64:
case RID_DFLOAT128:
+ case RID_DFLOAT64X:
CASE_RID_FLOATN_NX:
case RID_BOOL:
case RID_FRACT:
@@ -5229,6 +5232,7 @@ c_parser_gnu_attribute_any_word (c_parser *parser)
case RID_DFLOAT32:
case RID_DFLOAT64:
case RID_DFLOAT128:
+ case RID_DFLOAT64X:
CASE_RID_FLOATN_NX:
case RID_BOOL:
case RID_BITINT:
@@ -11897,6 +11901,7 @@ c_parser_postfix_expression (c_parser *parser)
bool arg_binary = all_binary;
bool arg_int_decimal = all_decimal;
bool arg_int_floatnx = false;
+ bool arg_int_decimalx = false;
for (unsigned int j = 1; j <= nargs; j++)
{
if (parm_kind[j] == tgmath_fixed)
@@ -12001,6 +12006,8 @@ c_parser_postfix_expression (c_parser *parser)
arg_int_floatnx = true;
break;
}
+ if (rtype == dfloat64x_type_node)
+ arg_int_decimalx = true;
}
tree arg_real = NULL_TREE;
for (unsigned int j = 1; j <= nargs; j++)
@@ -12012,10 +12019,12 @@ c_parser_postfix_expression (c_parser *parser)
if (TREE_CODE (type) == COMPLEX_TYPE)
type = TREE_TYPE (type);
if (INTEGRAL_TYPE_P (type))
- type = (arg_int_decimal
- ? dfloat64_type_node
+ type = (arg_int_decimalx
+ ? dfloat64x_type_node
: arg_int_floatnx
? float32x_type_node
+ : arg_int_decimal
+ ? dfloat64_type_node
: double_type_node);
if (arg_real == NULL_TREE)
arg_real = type;
@@ -13173,6 +13182,7 @@ warn_for_abs (location_t loc, tree fndecl, tree arg)
case BUILT_IN_FABSD32:
case BUILT_IN_FABSD64:
case BUILT_IN_FABSD128:
+ case BUILT_IN_FABSD64X:
if (!DECIMAL_FLOAT_TYPE_P (atype))
{
if (INTEGRAL_TYPE_P (atype))