summaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r--gcc/c-common.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 5f97a975933..30a61c2d5a5 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -131,6 +131,10 @@ cpp_reader *parse_in; /* Declared in c-pragma.h. */
tree complex_double_type_node;
tree complex_long_double_type_node;
+ tree dfloat32_type_node;
+ tree dfloat64_type_node;
+ tree_dfloat128_type_node;
+
tree intQI_type_node;
tree intHI_type_node;
tree intSI_type_node;
@@ -1686,6 +1690,13 @@ c_common_type_for_mode (enum machine_mode mode, int unsignedp)
return build_vector_type_for_mode (inner_type, mode);
}
+ if (mode == TYPE_MODE (dfloat32_type_node))
+ return dfloat32_type_node;
+ if (mode == TYPE_MODE (dfloat64_type_node))
+ return dfloat64_type_node;
+ if (mode == TYPE_MODE (dfloat128_type_node))
+ return dfloat128_type_node;
+
for (t = registered_builtin_types; t; t = TREE_CHAIN (t))
if (TYPE_MODE (TREE_VALUE (t)) == mode)
return TREE_VALUE (t);
@@ -2168,6 +2179,14 @@ shorten_compare (tree *op0_ptr, tree *op1_ptr, tree *restype_ptr,
in the type of the operand that is not constant.
TYPE is already properly set. */
}
+
+ /* If either arg is decimal float and the other is float, find the
+ proper common type to use for comparison. */
+ else if (real1 && real2
+ && (DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (primop0)))
+ || DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (primop1)))))
+ type = common_type (TREE_TYPE (primop0), TREE_TYPE (primop1));
+
else if (real1 && real2
&& (TYPE_PRECISION (TREE_TYPE (primop0))
== TYPE_PRECISION (TREE_TYPE (primop1))))
@@ -3084,6 +3103,17 @@ c_common_nodes_and_builtins (void)
record_builtin_type (RID_DOUBLE, NULL, double_type_node);
record_builtin_type (RID_MAX, "long double", long_double_type_node);
+ /* Only supported decimal floating point extension if the target
+ actually supports underlying modes. */
+ if (targetm.scalar_mode_supported_p (SDmode)
+ && targetm.scalar_mode_supported_p (DDmode)
+ && targetm.scalar_mode_supported_p (TDmode))
+ {
+ record_builtin_type (RID_DFLOAT32, NULL, dfloat32_type_node);
+ record_builtin_type (RID_DFLOAT64, NULL, dfloat64_type_node);
+ record_builtin_type (RID_DFLOAT128, NULL, dfloat128_type_node);
+ }
+
lang_hooks.decls.pushdecl (build_decl (TYPE_DECL,
get_identifier ("complex int"),
complex_integer_type_node));
@@ -4506,6 +4536,7 @@ handle_mode_attribute (tree *node, tree name, tree args,
case MODE_INT:
case MODE_PARTIAL_INT:
case MODE_FLOAT:
+ case MODE_DECIMAL_FLOAT:
valid_mode = targetm.scalar_mode_supported_p (mode);
break;