Commit ab22c1fa by Chao-ying Fu Committed by Chao-ying Fu

c-common.h (enum rid): Add new enumeration values of RID_SAT, RID_FRACT, and RID_ACCUM.

	* c-common.h (enum rid): Add new enumeration values of RID_SAT,
	RID_FRACT, and RID_ACCUM.  RID_SAT needs to be inserted before
	RID_ONEWAY, so that it can be checked in declspecs_add_type.
	(c_common_fixed_point_type_for_size): Declare.
	* c-parser.c (reswords): Add _Fract, _Accum, and _Sat.
	(c_token_starts_typename): Handle RID_FRACT, RID_ACCUM, and RID_SAT.
	(c_token_starts_declspecs): Likewise.
	(c_parser_declspecs): Likewise.
	(c_parser_attributes): Likewise.
	* c-tree.h (enum c_typespec_keyword): Add cts_fract and cts_accum.
	(c_declspecs): Add saturating_p.
	* c-decl.c (build_null_declspecs): Initialize saturating_p.
	(declspecs_add_type): Avoid using complex with _Fract, _Accum, or _Sat.
	Handle RID_SAT.
	Avoid using void, bool, char, int, float, double, _Decimal32,
	_Decimal64, _Decimal128, and complex with _Sat.
	Handle RID_FRACT and RID_ACCUM.
	Make sure _Sat is used with _Fract or _Accum.
	(finish_declspecs): Handle cts_fract and cts_accum.
	* c-common.c (fixed-value.h): New include.
	(constant_expression_warning): Handle FIXED_CST.
	(overflow_warning): Likewise.
	(warnings_for_convert_and_check): Likewise.
	(c_common_fixed_point_type_for_size): New.
	(c_common_type_for_mode): Handle fixed-point modes to
	return various saturating/non-saturating, signed/unsigned types.
	(c_common_signed_or_unsigned_type): Support fixed-point types.
	(shorten_compare): Check fixed-point zero.
	Handle FIXED_POINT_TYPE.
	(c_common_truthvalue_conversion): Handle FIXED_CST.
	Handle FIXED_POINT_TYPE.
	(c_common_nodes_and_builtins): Record builtin types for fixed-point
	types.
	(handle_mode_attribute): Handle fixed-point modes.  Need to check
	if the signness of base type and fixed-point modes are consistent.
	(handle_vector_size_attribute): Handle fixed-point modes.
	(same_scalar_type_ignoring_signedness): Handle FIXED_POINT_TYPE.
	(warn_for_div_by_zero): Check fixed-point zero.
	* c-typeck.c (c_common_type): Check FIXED_POINT_TYPE.  Build
	a common fixed-point type based on fbit, ibit, sign, and saturation.
	(build_unary_op): Allow FIXED_POINT_TYPE for CONVERT_EXPR,
	NEGATE_EXPR, TRUTH_NOT_EXPR, PREINCREMENT_EXPR, POSTINCREMENT_EXPR,
	PREDECREMENT_EXPR, and POSTDECREMENT_EXPR.
	(convert_for_assignment): Support FIXED_POINT_TYPE.
	(digest_init): Handle FIXED_POINT_TYPE.
	(build_binary_op): Support FIXED_POINT_TYPE in *_DIV_EXPR,
	TRUTH_ANDIF_EXPR, TRUTH_ORIF_EXPR, TRUTH_AND_EXPR, TRUTH_OR_EXPR,
	TRUTH_XOR_EXPR, RSHIFT_EXPR, LSHIFT_EXPR, EQ_EXPR, NE_EXPR, LE_EXPR,
	GE_EXPR, LT_EXPR, GT_EXPR.
	* target-def.h (TARGET_FIXED_POINT_SUPPORTED_P): New.
	(TARGET_INITIALIZER): Add TARGET_FIXED_POINT_SUPPORTED_P.
	* target.h (gcc_target): Add fixed_point_supported_p.
	* targhooks.c (default_scalar_mode_supported_p): Handle MODE_FRACT,
	MODE_UFRACT, MODE_ACCUM, and MODE_UACCUM.
	(default_fixed_point_supported_p): Define.
	* targhooks.h (default_fixed_point_supported_p): Declare.
	* doc/tm.texi (TARGET_FIXED_POINT_SUPPORTED_P): Add.
	* doc/install.texi (Configuration): Add --enable-fixed-point.
	* configure.ac (--enable-fixed-point): New to enable fixed-point
	arithmetic extension to C.  For mips targets, we enable it by default.
	* configure, config.in: Regenerate.

From-SVN: r127652
parent 43f14744
2007-08-20 Chao-ying Fu <fu@mips.com>
* c-common.h (enum rid): Add new enumeration values of RID_SAT,
RID_FRACT, and RID_ACCUM. RID_SAT needs to be inserted before
RID_ONEWAY, so that it can be checked in declspecs_add_type.
(c_common_fixed_point_type_for_size): Declare.
* c-parser.c (reswords): Add _Fract, _Accum, and _Sat.
(c_token_starts_typename): Handle RID_FRACT, RID_ACCUM, and RID_SAT.
(c_token_starts_declspecs): Likewise.
(c_parser_declspecs): Likewise.
(c_parser_attributes): Likewise.
* c-tree.h (enum c_typespec_keyword): Add cts_fract and cts_accum.
(c_declspecs): Add saturating_p.
* c-decl.c (build_null_declspecs): Initialize saturating_p.
(declspecs_add_type): Avoid using complex with _Fract, _Accum, or _Sat.
Handle RID_SAT.
Avoid using void, bool, char, int, float, double, _Decimal32,
_Decimal64, _Decimal128, and complex with _Sat.
Handle RID_FRACT and RID_ACCUM.
Make sure _Sat is used with _Fract or _Accum.
(finish_declspecs): Handle cts_fract and cts_accum.
* c-common.c (fixed-value.h): New include.
(constant_expression_warning): Handle FIXED_CST.
(overflow_warning): Likewise.
(warnings_for_convert_and_check): Likewise.
(c_common_fixed_point_type_for_size): New.
(c_common_type_for_mode): Handle fixed-point modes to
return various saturating/non-saturating, signed/unsigned types.
(c_common_signed_or_unsigned_type): Support fixed-point types.
(shorten_compare): Check fixed-point zero.
Handle FIXED_POINT_TYPE.
(c_common_truthvalue_conversion): Handle FIXED_CST.
Handle FIXED_POINT_TYPE.
(c_common_nodes_and_builtins): Record builtin types for fixed-point
types.
(handle_mode_attribute): Handle fixed-point modes. Need to check
if the signness of base type and fixed-point modes are consistent.
(handle_vector_size_attribute): Handle fixed-point modes.
(same_scalar_type_ignoring_signedness): Handle FIXED_POINT_TYPE.
(warn_for_div_by_zero): Check fixed-point zero.
* c-typeck.c (c_common_type): Check FIXED_POINT_TYPE. Build
a common fixed-point type based on fbit, ibit, sign, and saturation.
(build_unary_op): Allow FIXED_POINT_TYPE for CONVERT_EXPR,
NEGATE_EXPR, TRUTH_NOT_EXPR, PREINCREMENT_EXPR, POSTINCREMENT_EXPR,
PREDECREMENT_EXPR, and POSTDECREMENT_EXPR.
(convert_for_assignment): Support FIXED_POINT_TYPE.
(digest_init): Handle FIXED_POINT_TYPE.
(build_binary_op): Support FIXED_POINT_TYPE in *_DIV_EXPR,
TRUTH_ANDIF_EXPR, TRUTH_ORIF_EXPR, TRUTH_AND_EXPR, TRUTH_OR_EXPR,
TRUTH_XOR_EXPR, RSHIFT_EXPR, LSHIFT_EXPR, EQ_EXPR, NE_EXPR, LE_EXPR,
GE_EXPR, LT_EXPR, GT_EXPR.
* target-def.h (TARGET_FIXED_POINT_SUPPORTED_P): New.
(TARGET_INITIALIZER): Add TARGET_FIXED_POINT_SUPPORTED_P.
* target.h (gcc_target): Add fixed_point_supported_p.
* targhooks.c (default_scalar_mode_supported_p): Handle MODE_FRACT,
MODE_UFRACT, MODE_ACCUM, and MODE_UACCUM.
(default_fixed_point_supported_p): Define.
* targhooks.h (default_fixed_point_supported_p): Declare.
* doc/tm.texi (TARGET_FIXED_POINT_SUPPORTED_P): Add.
* doc/install.texi (Configuration): Add --enable-fixed-point.
* configure.ac (--enable-fixed-point): New to enable fixed-point
arithmetic extension to C. For mips targets, we enable it by default.
* configure, config.in: Regenerate.
2007-08-20 Pawel Sikora <pluto@pld-linux.org> 2007-08-20 Pawel Sikora <pluto@pld-linux.org>
* doc/invoke.texi (-Wnon-virtual-dtor): Update documentation. * doc/invoke.texi (-Wnon-virtual-dtor): Update documentation.
......
...@@ -52,7 +52,7 @@ enum rid ...@@ -52,7 +52,7 @@ enum rid
RID_VOLATILE, RID_SIGNED, RID_AUTO, RID_RESTRICT, RID_VOLATILE, RID_SIGNED, RID_AUTO, RID_RESTRICT,
/* C extensions */ /* C extensions */
RID_COMPLEX, RID_THREAD, RID_COMPLEX, RID_THREAD, RID_SAT,
/* C++ */ /* C++ */
RID_FRIEND, RID_VIRTUAL, RID_EXPLICIT, RID_EXPORT, RID_MUTABLE, RID_FRIEND, RID_VIRTUAL, RID_EXPLICIT, RID_EXPORT, RID_MUTABLE,
...@@ -72,6 +72,7 @@ enum rid ...@@ -72,6 +72,7 @@ enum rid
RID_EXTENSION, RID_IMAGPART, RID_REALPART, RID_LABEL, RID_CHOOSE_EXPR, RID_EXTENSION, RID_IMAGPART, RID_REALPART, RID_LABEL, RID_CHOOSE_EXPR,
RID_TYPES_COMPATIBLE_P, RID_TYPES_COMPATIBLE_P,
RID_DFLOAT32, RID_DFLOAT64, RID_DFLOAT128, RID_DFLOAT32, RID_DFLOAT64, RID_DFLOAT128,
RID_FRACT, RID_ACCUM,
/* Too many ways of getting the name of a function as a string */ /* Too many ways of getting the name of a function as a string */
RID_FUNCTION_NAME, RID_PRETTY_FUNCTION_NAME, RID_C99_FUNCTION_NAME, RID_FUNCTION_NAME, RID_PRETTY_FUNCTION_NAME, RID_C99_FUNCTION_NAME,
...@@ -670,6 +671,8 @@ extern int c_common_handle_option (size_t code, const char *arg, int value); ...@@ -670,6 +671,8 @@ extern int c_common_handle_option (size_t code, const char *arg, int value);
extern bool c_common_missing_argument (const char *opt, size_t code); extern bool c_common_missing_argument (const char *opt, size_t code);
extern tree c_common_type_for_mode (enum machine_mode, int); extern tree c_common_type_for_mode (enum machine_mode, int);
extern tree c_common_type_for_size (unsigned int, int); extern tree c_common_type_for_size (unsigned int, int);
extern tree c_common_fixed_point_type_for_size (unsigned int, unsigned int,
int, int);
extern tree c_common_unsigned_type (tree); extern tree c_common_unsigned_type (tree);
extern tree c_common_signed_type (tree); extern tree c_common_signed_type (tree);
extern tree c_common_signed_or_unsigned_type (int, tree); extern tree c_common_signed_or_unsigned_type (int, tree);
......
...@@ -7134,6 +7134,7 @@ build_null_declspecs (void) ...@@ -7134,6 +7134,7 @@ build_null_declspecs (void)
ret->const_p = false; ret->const_p = false;
ret->volatile_p = false; ret->volatile_p = false;
ret->restrict_p = false; ret->restrict_p = false;
ret->saturating_p = false;
return ret; return ret;
} }
...@@ -7196,7 +7197,7 @@ declspecs_add_type (struct c_declspecs *specs, struct c_typespec spec) ...@@ -7196,7 +7197,7 @@ declspecs_add_type (struct c_declspecs *specs, struct c_typespec spec)
} }
if ((int) i <= (int) RID_LAST_MODIFIER) if ((int) i <= (int) RID_LAST_MODIFIER)
{ {
/* "long", "short", "signed", "unsigned" or "_Complex". */ /* "long", "short", "signed", "unsigned", "_Complex" or "_Sat". */
bool dupe = false; bool dupe = false;
switch (i) switch (i)
{ {
...@@ -7356,9 +7357,55 @@ declspecs_add_type (struct c_declspecs *specs, struct c_typespec spec) ...@@ -7356,9 +7357,55 @@ declspecs_add_type (struct c_declspecs *specs, struct c_typespec spec)
else if (specs->typespec_word == cts_dfloat128) else if (specs->typespec_word == cts_dfloat128)
error ("both %<complex%> and %<_Decimal128%> in " error ("both %<complex%> and %<_Decimal128%> in "
"declaration specifiers"); "declaration specifiers");
else if (specs->typespec_word == cts_fract)
error ("both %<complex%> and %<_Fract%> in "
"declaration specifiers");
else if (specs->typespec_word == cts_accum)
error ("both %<complex%> and %<_Accum%> in "
"declaration specifiers");
else if (specs->saturating_p)
error ("both %<complex%> and %<_Sat%> in "
"declaration specifiers");
else else
specs->complex_p = true; specs->complex_p = true;
break; break;
case RID_SAT:
dupe = specs->saturating_p;
if (pedantic)
pedwarn ("ISO C does not support saturating types");
if (specs->typespec_word == cts_void)
error ("both %<_Sat%> and %<void%> in "
"declaration specifiers");
else if (specs->typespec_word == cts_bool)
error ("both %<_Sat%> and %<_Bool%> in "
"declaration specifiers");
else if (specs->typespec_word == cts_char)
error ("both %<_Sat%> and %<char%> in "
"declaration specifiers");
else if (specs->typespec_word == cts_int)
error ("both %<_Sat%> and %<int%> in "
"declaration specifiers");
else if (specs->typespec_word == cts_float)
error ("both %<_Sat%> and %<float%> in "
"declaration specifiers");
else if (specs->typespec_word == cts_double)
error ("both %<_Sat%> and %<double%> in "
"declaration specifiers");
else if (specs->typespec_word == cts_dfloat32)
error ("both %<_Sat%> and %<_Decimal32%> in "
"declaration specifiers");
else if (specs->typespec_word == cts_dfloat64)
error ("both %<_Sat%> and %<_Decimal64%> in "
"declaration specifiers");
else if (specs->typespec_word == cts_dfloat128)
error ("both %<_Sat%> and %<_Decimal128%> in "
"declaration specifiers");
else if (specs->complex_p)
error ("both %<_Sat%> and %<complex%> in "
"declaration specifiers");
else
specs->saturating_p = true;
break;
default: default:
gcc_unreachable (); gcc_unreachable ();
} }
...@@ -7370,7 +7417,8 @@ declspecs_add_type (struct c_declspecs *specs, struct c_typespec spec) ...@@ -7370,7 +7417,8 @@ declspecs_add_type (struct c_declspecs *specs, struct c_typespec spec)
} }
else else
{ {
/* "void", "_Bool", "char", "int", "float" or "double". */ /* "void", "_Bool", "char", "int", "float", "double", "_Decimal32",
"_Decimal64", "_Decimal128", "_Fract" or "_Accum". */
if (specs->typespec_word != cts_none) if (specs->typespec_word != cts_none)
{ {
error ("two or more data types in declaration specifiers"); error ("two or more data types in declaration specifiers");
...@@ -7394,6 +7442,9 @@ declspecs_add_type (struct c_declspecs *specs, struct c_typespec spec) ...@@ -7394,6 +7442,9 @@ declspecs_add_type (struct c_declspecs *specs, struct c_typespec spec)
else if (specs->complex_p) else if (specs->complex_p)
error ("both %<complex%> and %<void%> in " error ("both %<complex%> and %<void%> in "
"declaration specifiers"); "declaration specifiers");
else if (specs->saturating_p)
error ("both %<_Sat%> and %<void%> in "
"declaration specifiers");
else else
specs->typespec_word = cts_void; specs->typespec_word = cts_void;
return specs; return specs;
...@@ -7413,6 +7464,9 @@ declspecs_add_type (struct c_declspecs *specs, struct c_typespec spec) ...@@ -7413,6 +7464,9 @@ declspecs_add_type (struct c_declspecs *specs, struct c_typespec spec)
else if (specs->complex_p) else if (specs->complex_p)
error ("both %<complex%> and %<_Bool%> in " error ("both %<complex%> and %<_Bool%> in "
"declaration specifiers"); "declaration specifiers");
else if (specs->saturating_p)
error ("both %<_Sat%> and %<_Bool%> in "
"declaration specifiers");
else else
specs->typespec_word = cts_bool; specs->typespec_word = cts_bool;
return specs; return specs;
...@@ -7423,11 +7477,18 @@ declspecs_add_type (struct c_declspecs *specs, struct c_typespec spec) ...@@ -7423,11 +7477,18 @@ declspecs_add_type (struct c_declspecs *specs, struct c_typespec spec)
else if (specs->short_p) else if (specs->short_p)
error ("both %<short%> and %<char%> in " error ("both %<short%> and %<char%> in "
"declaration specifiers"); "declaration specifiers");
else if (specs->saturating_p)
error ("both %<_Sat%> and %<char%> in "
"declaration specifiers");
else else
specs->typespec_word = cts_char; specs->typespec_word = cts_char;
return specs; return specs;
case RID_INT: case RID_INT:
specs->typespec_word = cts_int; if (specs->saturating_p)
error ("both %<_Sat%> and %<int%> in "
"declaration specifiers");
else
specs->typespec_word = cts_int;
return specs; return specs;
case RID_FLOAT: case RID_FLOAT:
if (specs->long_p) if (specs->long_p)
...@@ -7442,6 +7503,9 @@ declspecs_add_type (struct c_declspecs *specs, struct c_typespec spec) ...@@ -7442,6 +7503,9 @@ declspecs_add_type (struct c_declspecs *specs, struct c_typespec spec)
else if (specs->unsigned_p) else if (specs->unsigned_p)
error ("both %<unsigned%> and %<float%> in " error ("both %<unsigned%> and %<float%> in "
"declaration specifiers"); "declaration specifiers");
else if (specs->saturating_p)
error ("both %<_Sat%> and %<float%> in "
"declaration specifiers");
else else
specs->typespec_word = cts_float; specs->typespec_word = cts_float;
return specs; return specs;
...@@ -7458,6 +7522,9 @@ declspecs_add_type (struct c_declspecs *specs, struct c_typespec spec) ...@@ -7458,6 +7522,9 @@ declspecs_add_type (struct c_declspecs *specs, struct c_typespec spec)
else if (specs->unsigned_p) else if (specs->unsigned_p)
error ("both %<unsigned%> and %<double%> in " error ("both %<unsigned%> and %<double%> in "
"declaration specifiers"); "declaration specifiers");
else if (specs->saturating_p)
error ("both %<_Sat%> and %<double%> in "
"declaration specifiers");
else else
specs->typespec_word = cts_double; specs->typespec_word = cts_double;
return specs; return specs;
...@@ -7490,6 +7557,9 @@ declspecs_add_type (struct c_declspecs *specs, struct c_typespec spec) ...@@ -7490,6 +7557,9 @@ declspecs_add_type (struct c_declspecs *specs, struct c_typespec spec)
else if (specs->complex_p) else if (specs->complex_p)
error ("both %<complex%> and %<%s%> in " error ("both %<complex%> and %<%s%> in "
"declaration specifiers", str); "declaration specifiers", str);
else if (specs->saturating_p)
error ("both %<_Sat%> and %<%s%> in "
"declaration specifiers", str);
else if (i == RID_DFLOAT32) else if (i == RID_DFLOAT32)
specs->typespec_word = cts_dfloat32; specs->typespec_word = cts_dfloat32;
else if (i == RID_DFLOAT64) else if (i == RID_DFLOAT64)
...@@ -7502,6 +7572,27 @@ declspecs_add_type (struct c_declspecs *specs, struct c_typespec spec) ...@@ -7502,6 +7572,27 @@ declspecs_add_type (struct c_declspecs *specs, struct c_typespec spec)
if (pedantic) if (pedantic)
pedwarn ("ISO C does not support decimal floating point"); pedwarn ("ISO C does not support decimal floating point");
return specs; return specs;
case RID_FRACT:
case RID_ACCUM:
{
const char *str;
if (i == RID_FRACT)
str = "_Fract";
else
str = "_Accum";
if (specs->complex_p)
error ("both %<complex%> and %<%s%> in "
"declaration specifiers", str);
else if (i == RID_FRACT)
specs->typespec_word = cts_fract;
else
specs->typespec_word = cts_accum;
}
if (!targetm.fixed_point_supported_p ())
error ("fixed-point types not supported for this target");
if (pedantic)
pedwarn ("ISO C does not support fixed-point types");
return specs;
default: default:
/* ObjC reserved word "id", handled below. */ /* ObjC reserved word "id", handled below. */
break; break;
...@@ -7673,6 +7764,8 @@ finish_declspecs (struct c_declspecs *specs) ...@@ -7673,6 +7764,8 @@ finish_declspecs (struct c_declspecs *specs)
"_Complex short" is equivalent to "_Complex short int". */ "_Complex short" is equivalent to "_Complex short int". */
if (specs->typespec_word == cts_none) if (specs->typespec_word == cts_none)
{ {
if (specs->saturating_p)
error ("%<_Sat%> is used without %<_Fract%> or %<_Accum%>");
if (specs->long_p || specs->short_p if (specs->long_p || specs->short_p
|| specs->signed_p || specs->unsigned_p) || specs->signed_p || specs->unsigned_p)
{ {
...@@ -7792,6 +7885,88 @@ finish_declspecs (struct c_declspecs *specs) ...@@ -7792,6 +7885,88 @@ finish_declspecs (struct c_declspecs *specs)
else else
specs->type = dfloat128_type_node; specs->type = dfloat128_type_node;
break; break;
case cts_fract:
gcc_assert (!specs->complex_p);
if (specs->saturating_p)
{
if (specs->long_long_p)
specs->type = specs->unsigned_p
? sat_unsigned_long_long_fract_type_node
: sat_long_long_fract_type_node;
else if (specs->long_p)
specs->type = specs->unsigned_p
? sat_unsigned_long_fract_type_node
: sat_long_fract_type_node;
else if (specs->short_p)
specs->type = specs->unsigned_p
? sat_unsigned_short_fract_type_node
: sat_short_fract_type_node;
else
specs->type = specs->unsigned_p
? sat_unsigned_fract_type_node
: sat_fract_type_node;
}
else
{
if (specs->long_long_p)
specs->type = specs->unsigned_p
? unsigned_long_long_fract_type_node
: long_long_fract_type_node;
else if (specs->long_p)
specs->type = specs->unsigned_p
? unsigned_long_fract_type_node
: long_fract_type_node;
else if (specs->short_p)
specs->type = specs->unsigned_p
? unsigned_short_fract_type_node
: short_fract_type_node;
else
specs->type = specs->unsigned_p
? unsigned_fract_type_node
: fract_type_node;
}
break;
case cts_accum:
gcc_assert (!specs->complex_p);
if (specs->saturating_p)
{
if (specs->long_long_p)
specs->type = specs->unsigned_p
? sat_unsigned_long_long_accum_type_node
: sat_long_long_accum_type_node;
else if (specs->long_p)
specs->type = specs->unsigned_p
? sat_unsigned_long_accum_type_node
: sat_long_accum_type_node;
else if (specs->short_p)
specs->type = specs->unsigned_p
? sat_unsigned_short_accum_type_node
: sat_short_accum_type_node;
else
specs->type = specs->unsigned_p
? sat_unsigned_accum_type_node
: sat_accum_type_node;
}
else
{
if (specs->long_long_p)
specs->type = specs->unsigned_p
? unsigned_long_long_accum_type_node
: long_long_accum_type_node;
else if (specs->long_p)
specs->type = specs->unsigned_p
? unsigned_long_accum_type_node
: long_accum_type_node;
else if (specs->short_p)
specs->type = specs->unsigned_p
? unsigned_short_accum_type_node
: short_accum_type_node;
else
specs->type = specs->unsigned_p
? unsigned_accum_type_node
: accum_type_node;
}
break;
default: default:
gcc_unreachable (); gcc_unreachable ();
} }
......
...@@ -80,6 +80,9 @@ static const struct resword reswords[] = ...@@ -80,6 +80,9 @@ static const struct resword reswords[] =
{ "_Decimal32", RID_DFLOAT32, D_EXT }, { "_Decimal32", RID_DFLOAT32, D_EXT },
{ "_Decimal64", RID_DFLOAT64, D_EXT }, { "_Decimal64", RID_DFLOAT64, D_EXT },
{ "_Decimal128", RID_DFLOAT128, D_EXT }, { "_Decimal128", RID_DFLOAT128, D_EXT },
{ "_Fract", RID_FRACT, D_EXT },
{ "_Accum", RID_ACCUM, D_EXT },
{ "_Sat", RID_SAT, D_EXT },
{ "__FUNCTION__", RID_FUNCTION_NAME, 0 }, { "__FUNCTION__", RID_FUNCTION_NAME, 0 },
{ "__PRETTY_FUNCTION__", RID_PRETTY_FUNCTION_NAME, 0 }, { "__PRETTY_FUNCTION__", RID_PRETTY_FUNCTION_NAME, 0 },
{ "__alignof", RID_ALIGNOF, 0 }, { "__alignof", RID_ALIGNOF, 0 },
...@@ -486,6 +489,9 @@ c_token_starts_typename (c_token *token) ...@@ -486,6 +489,9 @@ c_token_starts_typename (c_token *token)
case RID_VOLATILE: case RID_VOLATILE:
case RID_RESTRICT: case RID_RESTRICT:
case RID_ATTRIBUTE: case RID_ATTRIBUTE:
case RID_FRACT:
case RID_ACCUM:
case RID_SAT:
return true; return true;
default: default:
return false; return false;
...@@ -560,6 +566,9 @@ c_token_starts_declspecs (c_token *token) ...@@ -560,6 +566,9 @@ c_token_starts_declspecs (c_token *token)
case RID_VOLATILE: case RID_VOLATILE:
case RID_RESTRICT: case RID_RESTRICT:
case RID_ATTRIBUTE: case RID_ATTRIBUTE:
case RID_FRACT:
case RID_ACCUM:
case RID_SAT:
return true; return true;
default: default:
return false; return false;
...@@ -1493,6 +1502,12 @@ c_parser_asm_definition (c_parser *parser) ...@@ -1493,6 +1502,12 @@ c_parser_asm_definition (c_parser *parser)
_Decimal32 _Decimal32
_Decimal64 _Decimal64
_Decimal128 _Decimal128
_Fract
_Accum
_Sat
(_Fract, _Accum, and _Sat are new from ISO/IEC DTR 18037:
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf)
Objective-C: Objective-C:
...@@ -1595,6 +1610,9 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs, ...@@ -1595,6 +1610,9 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs,
case RID_DFLOAT64: case RID_DFLOAT64:
case RID_DFLOAT128: case RID_DFLOAT128:
case RID_BOOL: case RID_BOOL:
case RID_FRACT:
case RID_ACCUM:
case RID_SAT:
if (!typespec_ok) if (!typespec_ok)
goto out; goto out;
attrs_ok = true; attrs_ok = true;
...@@ -2857,6 +2875,9 @@ c_parser_attributes (c_parser *parser) ...@@ -2857,6 +2875,9 @@ c_parser_attributes (c_parser *parser)
case RID_DFLOAT64: case RID_DFLOAT64:
case RID_DFLOAT128: case RID_DFLOAT128:
case RID_BOOL: case RID_BOOL:
case RID_FRACT:
case RID_ACCUM:
case RID_SAT:
ok = true; ok = true;
break; break;
default: default:
......
...@@ -202,7 +202,8 @@ enum c_storage_class { ...@@ -202,7 +202,8 @@ enum c_storage_class {
}; };
/* A type specifier keyword "void", "_Bool", "char", "int", "float", /* A type specifier keyword "void", "_Bool", "char", "int", "float",
"double", or none of these. */ "double", "_Decimal32", "_Decimal64", "_Decimal128", "_Fract", "_Accum",
or none of these. */
enum c_typespec_keyword { enum c_typespec_keyword {
cts_none, cts_none,
cts_void, cts_void,
...@@ -213,7 +214,9 @@ enum c_typespec_keyword { ...@@ -213,7 +214,9 @@ enum c_typespec_keyword {
cts_double, cts_double,
cts_dfloat32, cts_dfloat32,
cts_dfloat64, cts_dfloat64,
cts_dfloat128 cts_dfloat128,
cts_fract,
cts_accum
}; };
/* A sequence of declaration specifiers in C. */ /* A sequence of declaration specifiers in C. */
...@@ -281,6 +284,8 @@ struct c_declspecs { ...@@ -281,6 +284,8 @@ struct c_declspecs {
BOOL_BITFIELD volatile_p : 1; BOOL_BITFIELD volatile_p : 1;
/* Whether "restrict" was specified. */ /* Whether "restrict" was specified. */
BOOL_BITFIELD restrict_p : 1; BOOL_BITFIELD restrict_p : 1;
/* Whether "_Sat" was specified. */
BOOL_BITFIELD saturating_p : 1;
}; };
/* The various kinds of declarators in C. */ /* The various kinds of declarators in C. */
......
...@@ -65,6 +65,12 @@ ...@@ -65,6 +65,12 @@
#endif #endif
/* Define to 1 to enable fixed-point arithmetic extension to C. */
#ifndef USED_FOR_TARGET
#undef ENABLE_FIXED_POINT
#endif
/* Define if you want fold checked that it never destructs its argument. This /* Define if you want fold checked that it never destructs its argument. This
is quite expensive. */ is quite expensive. */
#ifndef USED_FOR_TARGET #ifndef USED_FOR_TARGET
...@@ -1363,37 +1369,37 @@ ...@@ -1363,37 +1369,37 @@
#endif #endif
/* The size of a `int', as computed by sizeof. */ /* The size of `int', as computed by sizeof. */
#ifndef USED_FOR_TARGET #ifndef USED_FOR_TARGET
#undef SIZEOF_INT #undef SIZEOF_INT
#endif #endif
/* The size of a `long', as computed by sizeof. */ /* The size of `long', as computed by sizeof. */
#ifndef USED_FOR_TARGET #ifndef USED_FOR_TARGET
#undef SIZEOF_LONG #undef SIZEOF_LONG
#endif #endif
/* The size of a `long long', as computed by sizeof. */ /* The size of `long long', as computed by sizeof. */
#ifndef USED_FOR_TARGET #ifndef USED_FOR_TARGET
#undef SIZEOF_LONG_LONG #undef SIZEOF_LONG_LONG
#endif #endif
/* The size of a `short', as computed by sizeof. */ /* The size of `short', as computed by sizeof. */
#ifndef USED_FOR_TARGET #ifndef USED_FOR_TARGET
#undef SIZEOF_SHORT #undef SIZEOF_SHORT
#endif #endif
/* The size of a `void *', as computed by sizeof. */ /* The size of `void *', as computed by sizeof. */
#ifndef USED_FOR_TARGET #ifndef USED_FOR_TARGET
#undef SIZEOF_VOID_P #undef SIZEOF_VOID_P
#endif #endif
/* The size of a `__int64', as computed by sizeof. */ /* The size of `__int64', as computed by sizeof. */
#ifndef USED_FOR_TARGET #ifndef USED_FOR_TARGET
#undef SIZEOF___INT64 #undef SIZEOF___INT64
#endif #endif
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -641,6 +641,28 @@ AC_DEFINE_UNQUOTED(ENABLE_DECIMAL_BID_FORMAT, $bid, ...@@ -641,6 +641,28 @@ AC_DEFINE_UNQUOTED(ENABLE_DECIMAL_BID_FORMAT, $bid,
[Define to 1 to specify that we are using the BID decimal floating [Define to 1 to specify that we are using the BID decimal floating
point format instead of DPD]) point format instead of DPD])
# Enable C extension for fixed-point arithmetic.
AC_ARG_ENABLE(fixed-point,
[ --enable-fixed-point enable fixed-point arithmetic extension to C],
[
],
[
case $target in
mips*-*-*)
enable_fixed_point=yes
;;
*)
AC_MSG_WARN(fixed-point is not supported for this target, ignored)
enable_fixed_point=no
;;
esac
])
AC_SUBST(enable_fixed_point)
fixedpoint=`if test $enable_fixed_point = yes; then echo 1; else echo 0; fi`
AC_DEFINE_UNQUOTED(ENABLE_FIXED_POINT, $fixedpoint,
[Define to 1 to enable fixed-point arithmetic extension to C.])
# Enable threads # Enable threads
# Pass with no value to take the default # Pass with no value to take the default
# Pass with a value to specify a thread package # Pass with a value to specify a thread package
......
...@@ -1317,6 +1317,13 @@ or @samp{dpd}). The @samp{bid} (binary integer decimal) format is ...@@ -1317,6 +1317,13 @@ or @samp{dpd}). The @samp{bid} (binary integer decimal) format is
default on i386 and x86_64 systems, and the @samp{dpd} (densely packed default on i386 and x86_64 systems, and the @samp{dpd} (densely packed
decimal) format is default on PowerPC systems. decimal) format is default on PowerPC systems.
@item --enable-fixed-point
@itemx --disable-fixed-point
Enable (or disable) support for C fixed-point arithmetic.
This option is enabled by default for some targets (such as MIPS) which
have hardware-support for fixed-point operations. On other targets, you
may enable this option manually.
@item --with-long-double-128 @item --with-long-double-128
Specify if @code{long double} type should be 128-bit by default on selected Specify if @code{long double} type should be 128-bit by default on selected
GNU/Linux architectures. If using @code{--without-long-double-128}, GNU/Linux architectures. If using @code{--without-long-double-128},
......
...@@ -1502,6 +1502,10 @@ may affect its placement. ...@@ -1502,6 +1502,10 @@ may affect its placement.
Returns true if the target supports decimal floating point. Returns true if the target supports decimal floating point.
@end deftypefn @end deftypefn
@deftypefn {Target Hook} {bool} TARGET_FIXED_POINT_SUPPORTED_P (void)
Returns true if the target supports fixed-point arithmetic.
@end deftypefn
@deftypefn {Target Hook} {const char *} TARGET_MANGLE_TYPE (tree @var{type}) @deftypefn {Target Hook} {const char *} TARGET_MANGLE_TYPE (tree @var{type})
If your target defines any fundamental types, or any types your target If your target defines any fundamental types, or any types your target
uses should be mangled differently from the default, define this hook uses should be mangled differently from the default, define this hook
......
...@@ -437,6 +437,10 @@ ...@@ -437,6 +437,10 @@
#define TARGET_DECIMAL_FLOAT_SUPPORTED_P default_decimal_float_supported_p #define TARGET_DECIMAL_FLOAT_SUPPORTED_P default_decimal_float_supported_p
#endif #endif
#ifndef TARGET_FIXED_POINT_SUPPORTED_P
#define TARGET_FIXED_POINT_SUPPORTED_P default_fixed_point_supported_p
#endif
#ifndef TARGET_VECTOR_MODE_SUPPORTED_P #ifndef TARGET_VECTOR_MODE_SUPPORTED_P
#define TARGET_VECTOR_MODE_SUPPORTED_P hook_bool_mode_false #define TARGET_VECTOR_MODE_SUPPORTED_P hook_bool_mode_false
#endif #endif
...@@ -689,6 +693,7 @@ ...@@ -689,6 +693,7 @@
TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P, \ TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P, \
TARGET_MS_BITFIELD_LAYOUT_P, \ TARGET_MS_BITFIELD_LAYOUT_P, \
TARGET_DECIMAL_FLOAT_SUPPORTED_P, \ TARGET_DECIMAL_FLOAT_SUPPORTED_P, \
TARGET_FIXED_POINT_SUPPORTED_P, \
TARGET_ALIGN_ANON_BITFIELD, \ TARGET_ALIGN_ANON_BITFIELD, \
TARGET_NARROW_VOLATILE_BITFIELD, \ TARGET_NARROW_VOLATILE_BITFIELD, \
TARGET_INIT_BUILTINS, \ TARGET_INIT_BUILTINS, \
......
...@@ -479,6 +479,9 @@ struct gcc_target ...@@ -479,6 +479,9 @@ struct gcc_target
/* True if the target supports decimal floating point. */ /* True if the target supports decimal floating point. */
bool (* decimal_float_supported_p) (void); bool (* decimal_float_supported_p) (void);
/* True if the target supports fixed-point. */
bool (* fixed_point_supported_p) (void);
/* Return true if anonymous bitfields affect structure alignment. */ /* Return true if anonymous bitfields affect structure alignment. */
bool (* align_anon_bitfield) (void); bool (* align_anon_bitfield) (void);
......
...@@ -298,6 +298,10 @@ default_scalar_mode_supported_p (enum machine_mode mode) ...@@ -298,6 +298,10 @@ default_scalar_mode_supported_p (enum machine_mode mode)
return false; return false;
case MODE_DECIMAL_FLOAT: case MODE_DECIMAL_FLOAT:
case MODE_FRACT:
case MODE_UFRACT:
case MODE_ACCUM:
case MODE_UACCUM:
return false; return false;
default: default:
...@@ -313,6 +317,14 @@ default_decimal_float_supported_p (void) ...@@ -313,6 +317,14 @@ default_decimal_float_supported_p (void)
return ENABLE_DECIMAL_FLOAT; return ENABLE_DECIMAL_FLOAT;
} }
/* True if the target supports fixed-point arithmetic. */
bool
default_fixed_point_supported_p (void)
{
return ENABLE_FIXED_POINT;
}
/* NULL if INSN insn is valid within a low-overhead loop, otherwise returns /* NULL if INSN insn is valid within a low-overhead loop, otherwise returns
an error message. an error message.
......
...@@ -55,6 +55,7 @@ extern void default_unwind_emit (FILE *, rtx); ...@@ -55,6 +55,7 @@ extern void default_unwind_emit (FILE *, rtx);
extern bool default_scalar_mode_supported_p (enum machine_mode); extern bool default_scalar_mode_supported_p (enum machine_mode);
extern bool default_decimal_float_supported_p (void); extern bool default_decimal_float_supported_p (void);
extern bool default_fixed_point_supported_p (void);
extern const char * default_invalid_within_doloop (rtx); extern const char * default_invalid_within_doloop (rtx);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment