This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
fenv.h builtins
- From: Marc Glisse <marc dot glisse at inria dot fr>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 23 Jun 2017 17:12:26 +0200 (CEST)
- Subject: fenv.h builtins
- Authentication-results: sourceware.org; auth=none
Hello,
this is now the complete list of C99 fenv.h functions. I tried to be
rather conservative, only fegetround is pure, and functions that "raise an
exception" (in the fenv sense, not the C++ one) do not get nothrow,leaf.
We can always change that afterwards.
I am not convinced there is much we will be able to do with those, but at
least they are available now...
Trying to declare those functions with wrong prototypes now gives the
expected error.
Bootstrap + testsuite on powerpc64le-unknown-linux-gnu.
2017-06-23 Marc Glisse <marc.glisse@inria.fr>
* builtin-types.def (BT_FENV_T_PTR, BT_CONST_FENV_T_PTR,
BT_FEXCEPT_T_PTR, BT_CONST_FEXCEPT_T_PTR): New primitive types.
(BT_FN_INT_FENV_T_PTR, BT_FN_INT_CONST_FENV_T_PTR,
BT_FN_INT_FEXCEPT_T_PTR_INT, BT_FN_INT_CONST_FEXCEPT_T_PTR_INT):
New function types.
* builtins.def (BUILT_IN_FECLEAREXCEPT, BUILT_IN_FEGETENV,
BUILT_IN_FEGETEXCEPTFLAG, BUILT_IN_FEGETROUND,
BUILT_IN_FEHOLDEXCEPT, BUILT_IN_FERAISEEXCEPT,
BUILT_IN_FESETENV, BUILT_IN_FESETEXCEPTFLAG,
BUILT_IN_FESETROUND, BUILT_IN_FETESTEXCEPT,
BUILT_IN_FEUPDATEENV): New builtins.
* tree-core.h (TI_FENV_T_PTR_TYPE, TI_CONST_FENV_T_PTR_TYPE,
TI_FEXCEPT_T_PTR_TYPE, TI_CONST_FEXCEPT_T_PTR_TYPE): New entries.
* tree.h (fenv_t_ptr_type_node, const_fenv_t_ptr_type_node,
fexcept_t_ptr_type_node, const_fexcept_t_ptr_type_node): New
macros.
(builtin_structptr_types): Adjust size.
* tree.c (builtin_structptr_types): Add four entries.
--
Marc Glisse
Index: gcc/builtin-types.def
===================================================================
--- gcc/builtin-types.def (revision 249585)
+++ gcc/builtin-types.def (working copy)
@@ -100,20 +100,24 @@ DEF_PRIMITIVE_TYPE (BT_FLOAT64X, (float6
DEF_PRIMITIVE_TYPE (BT_FLOAT128X, (float128x_type_node
? float128x_type_node
: error_mark_node))
DEF_PRIMITIVE_TYPE (BT_COMPLEX_FLOAT, complex_float_type_node)
DEF_PRIMITIVE_TYPE (BT_COMPLEX_DOUBLE, complex_double_type_node)
DEF_PRIMITIVE_TYPE (BT_COMPLEX_LONGDOUBLE, complex_long_double_type_node)
DEF_PRIMITIVE_TYPE (BT_PTR, ptr_type_node)
DEF_PRIMITIVE_TYPE (BT_FILEPTR, fileptr_type_node)
DEF_PRIMITIVE_TYPE (BT_CONST_TM_PTR, const_tm_ptr_type_node)
+DEF_PRIMITIVE_TYPE (BT_FENV_T_PTR, fenv_t_ptr_type_node)
+DEF_PRIMITIVE_TYPE (BT_CONST_FENV_T_PTR, const_fenv_t_ptr_type_node)
+DEF_PRIMITIVE_TYPE (BT_FEXCEPT_T_PTR, fexcept_t_ptr_type_node)
+DEF_PRIMITIVE_TYPE (BT_CONST_FEXCEPT_T_PTR, const_fexcept_t_ptr_type_node)
DEF_PRIMITIVE_TYPE (BT_CONST_PTR, const_ptr_type_node)
DEF_PRIMITIVE_TYPE (BT_VOLATILE_PTR,
build_pointer_type
(build_qualified_type (void_type_node,
TYPE_QUAL_VOLATILE)))
DEF_PRIMITIVE_TYPE (BT_CONST_VOLATILE_PTR,
build_pointer_type
(build_qualified_type (void_type_node,
TYPE_QUAL_VOLATILE|TYPE_QUAL_CONST)))
DEF_PRIMITIVE_TYPE (BT_PTRMODE, (*lang_hooks.types.type_for_mode)(ptr_mode, 0))
@@ -291,20 +295,22 @@ DEF_FUNCTION_TYPE_1 (BT_FN_UINT16_UINT16
DEF_FUNCTION_TYPE_1 (BT_FN_UINT32_UINT32, BT_UINT32, BT_UINT32)
DEF_FUNCTION_TYPE_1 (BT_FN_UINT64_UINT64, BT_UINT64, BT_UINT64)
DEF_FUNCTION_TYPE_1 (BT_FN_UINT64_FLOAT, BT_UINT64, BT_FLOAT)
DEF_FUNCTION_TYPE_1 (BT_FN_BOOL_INT, BT_BOOL, BT_INT)
DEF_FUNCTION_TYPE_1 (BT_FN_PTR_CONST_PTR, BT_PTR, BT_CONST_PTR)
DEF_FUNCTION_TYPE_1 (BT_FN_CONST_PTR_CONST_PTR, BT_CONST_PTR, BT_CONST_PTR)
DEF_FUNCTION_TYPE_1 (BT_FN_BND_CONST_PTR, BT_BND, BT_CONST_PTR)
DEF_FUNCTION_TYPE_1 (BT_FN_CONST_PTR_BND, BT_CONST_PTR, BT_BND)
DEF_FUNCTION_TYPE_1 (BT_FN_UINT16_UINT32, BT_UINT16, BT_UINT32)
DEF_FUNCTION_TYPE_1 (BT_FN_UINT32_UINT16, BT_UINT32, BT_UINT16)
+DEF_FUNCTION_TYPE_1 (BT_FN_INT_FENV_T_PTR, BT_INT, BT_FENV_T_PTR)
+DEF_FUNCTION_TYPE_1 (BT_FN_INT_CONST_FENV_T_PTR, BT_INT, BT_CONST_FENV_T_PTR)
DEF_POINTER_TYPE (BT_PTR_FN_VOID_PTR, BT_FN_VOID_PTR)
DEF_FUNCTION_TYPE_2 (BT_FN_VOID_PTR_INT, BT_VOID, BT_PTR, BT_INT)
DEF_FUNCTION_TYPE_2 (BT_FN_STRING_STRING_CONST_STRING,
BT_STRING, BT_STRING, BT_CONST_STRING)
DEF_FUNCTION_TYPE_2 (BT_FN_INT_CONST_STRING_CONST_STRING,
BT_INT, BT_CONST_STRING, BT_CONST_STRING)
DEF_FUNCTION_TYPE_2 (BT_FN_STRING_CONST_STRING_CONST_STRING,
BT_STRING, BT_CONST_STRING, BT_CONST_STRING)
@@ -464,20 +470,24 @@ DEF_FUNCTION_TYPE_2 (BT_FN_VOID_UINT_UIN
DEF_FUNCTION_TYPE_2 (BT_FN_UINT_UINT_PTR, BT_UINT, BT_UINT, BT_PTR)
DEF_FUNCTION_TYPE_2 (BT_FN_PTR_CONST_PTR_SIZE, BT_PTR, BT_CONST_PTR, BT_SIZE)
DEF_FUNCTION_TYPE_2 (BT_FN_PTR_CONST_PTR_CONST_PTR, BT_PTR, BT_CONST_PTR, BT_CONST_PTR)
DEF_FUNCTION_TYPE_2 (BT_FN_VOID_PTRPTR_CONST_PTR, BT_VOID, BT_PTR_PTR, BT_CONST_PTR)
DEF_FUNCTION_TYPE_2 (BT_FN_VOID_CONST_PTR_SIZE, BT_VOID, BT_CONST_PTR, BT_SIZE)
DEF_FUNCTION_TYPE_2 (BT_FN_VOID_PTR_BND, BT_VOID, BT_PTR, BT_BND)
DEF_FUNCTION_TYPE_2 (BT_FN_CONST_PTR_CONST_PTR_CONST_PTR, BT_CONST_PTR, BT_CONST_PTR, BT_CONST_PTR)
DEF_FUNCTION_TYPE_2 (BT_FN_BND_CONST_PTR_SIZE, BT_BND, BT_CONST_PTR, BT_SIZE)
DEF_FUNCTION_TYPE_2 (BT_FN_UINT32_UINT64_PTR,
BT_UINT32, BT_UINT64, BT_PTR)
+DEF_FUNCTION_TYPE_2 (BT_FN_INT_FEXCEPT_T_PTR_INT, BT_INT, BT_FEXCEPT_T_PTR,
+ BT_INT)
+DEF_FUNCTION_TYPE_2 (BT_FN_INT_CONST_FEXCEPT_T_PTR_INT, BT_INT,
+ BT_CONST_FEXCEPT_T_PTR, BT_INT)
DEF_POINTER_TYPE (BT_PTR_FN_VOID_PTR_PTR, BT_FN_VOID_PTR_PTR)
DEF_FUNCTION_TYPE_3 (BT_FN_STRING_STRING_CONST_STRING_SIZE,
BT_STRING, BT_STRING, BT_CONST_STRING, BT_SIZE)
DEF_FUNCTION_TYPE_3 (BT_FN_INT_CONST_STRING_CONST_STRING_SIZE,
BT_INT, BT_CONST_STRING, BT_CONST_STRING, BT_SIZE)
DEF_FUNCTION_TYPE_3 (BT_FN_PTR_PTR_CONST_PTR_SIZE,
BT_PTR, BT_PTR, BT_CONST_PTR, BT_SIZE)
DEF_FUNCTION_TYPE_3 (BT_FN_VOID_PTR_CONST_PTR_SIZE,
Index: gcc/builtins.def
===================================================================
--- gcc/builtins.def (revision 249585)
+++ gcc/builtins.def (working copy)
@@ -358,20 +358,31 @@ DEF_C99_C90RES_BUILTIN (BUILT_IN_FABSF,
DEF_C99_C90RES_BUILTIN (BUILT_IN_FABSL, "fabsl", BT_FN_LONGDOUBLE_LONGDOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
#define FABS_TYPE(F) BT_FN_##F##_##F
DEF_GCC_FLOATN_NX_BUILTINS (BUILT_IN_FABS, "fabs", FABS_TYPE, ATTR_CONST_NOTHROW_LEAF_LIST)
#undef FABS_TYPE
DEF_GCC_BUILTIN (BUILT_IN_FABSD32, "fabsd32", BT_FN_DFLOAT32_DFLOAT32, ATTR_CONST_NOTHROW_LEAF_LIST)
DEF_GCC_BUILTIN (BUILT_IN_FABSD64, "fabsd64", BT_FN_DFLOAT64_DFLOAT64, ATTR_CONST_NOTHROW_LEAF_LIST)
DEF_GCC_BUILTIN (BUILT_IN_FABSD128, "fabsd128", BT_FN_DFLOAT128_DFLOAT128, ATTR_CONST_NOTHROW_LEAF_LIST)
DEF_C99_BUILTIN (BUILT_IN_FDIM, "fdim", BT_FN_DOUBLE_DOUBLE_DOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO)
DEF_C99_BUILTIN (BUILT_IN_FDIMF, "fdimf", BT_FN_FLOAT_FLOAT_FLOAT, ATTR_MATHFN_FPROUNDING_ERRNO)
DEF_C99_BUILTIN (BUILT_IN_FDIML, "fdiml", BT_FN_LONGDOUBLE_LONGDOUBLE_LONGDOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO)
+DEF_C99_BUILTIN (BUILT_IN_FECLEAREXCEPT, "feclearexcept", BT_FN_INT_INT, ATTR_NOTHROW_LEAF_LIST)
+DEF_C99_BUILTIN (BUILT_IN_FEGETENV, "fegetenv", BT_FN_INT_FENV_T_PTR, ATTR_NOTHROW_LEAF_LIST)
+DEF_C99_BUILTIN (BUILT_IN_FEGETEXCEPTFLAG, "fegetexceptflag", BT_FN_INT_FEXCEPT_T_PTR_INT, ATTR_NOTHROW_LEAF_LIST)
+DEF_C99_BUILTIN (BUILT_IN_FEGETROUND, "fegetround", BT_FN_INT, ATTR_PURE_NOTHROW_LEAF_LIST)
+DEF_C99_BUILTIN (BUILT_IN_FEHOLDEXCEPT, "feholdexcept", BT_FN_INT_FENV_T_PTR, ATTR_NOTHROW_LEAF_LIST)
+DEF_C99_BUILTIN (BUILT_IN_FERAISEEXCEPT, "feraiseexcept", BT_FN_INT_INT, ATTR_NULL)
+DEF_C99_BUILTIN (BUILT_IN_FESETENV, "fesetenv", BT_FN_INT_CONST_FENV_T_PTR, ATTR_NOTHROW_LEAF_LIST)
+DEF_C99_BUILTIN (BUILT_IN_FESETEXCEPTFLAG, "fesetexceptflag", BT_FN_INT_CONST_FEXCEPT_T_PTR_INT, ATTR_NULL)
+DEF_C99_BUILTIN (BUILT_IN_FESETROUND, "fesetround", BT_FN_INT_INT, ATTR_NOTHROW_LEAF_LIST)
+DEF_C99_BUILTIN (BUILT_IN_FETESTEXCEPT, "fetestexcept", BT_FN_INT_INT, ATTR_NOTHROW_LEAF_LIST)
+DEF_C99_BUILTIN (BUILT_IN_FEUPDATEENV, "feupdateenv", BT_FN_INT_CONST_FENV_T_PTR, ATTR_NULL)
DEF_LIB_BUILTIN (BUILT_IN_FLOOR, "floor", BT_FN_DOUBLE_DOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
DEF_C99_C90RES_BUILTIN (BUILT_IN_FLOORF, "floorf", BT_FN_FLOAT_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST)
DEF_C99_C90RES_BUILTIN (BUILT_IN_FLOORL, "floorl", BT_FN_LONGDOUBLE_LONGDOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
DEF_C99_BUILTIN (BUILT_IN_FMA, "fma", BT_FN_DOUBLE_DOUBLE_DOUBLE_DOUBLE, ATTR_MATHFN_FPROUNDING)
DEF_C99_BUILTIN (BUILT_IN_FMAF, "fmaf", BT_FN_FLOAT_FLOAT_FLOAT_FLOAT, ATTR_MATHFN_FPROUNDING)
DEF_C99_BUILTIN (BUILT_IN_FMAL, "fmal", BT_FN_LONGDOUBLE_LONGDOUBLE_LONGDOUBLE_LONGDOUBLE, ATTR_MATHFN_FPROUNDING)
DEF_C99_BUILTIN (BUILT_IN_FMAX, "fmax", BT_FN_DOUBLE_DOUBLE_DOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
DEF_C99_BUILTIN (BUILT_IN_FMAXF, "fmaxf", BT_FN_FLOAT_FLOAT_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST)
DEF_C99_BUILTIN (BUILT_IN_FMAXL, "fmaxl", BT_FN_LONGDOUBLE_LONGDOUBLE_LONGDOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
DEF_C99_BUILTIN (BUILT_IN_FMIN, "fmin", BT_FN_DOUBLE_DOUBLE_DOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
Index: gcc/tree-core.h
===================================================================
--- gcc/tree-core.h (revision 249585)
+++ gcc/tree-core.h (working copy)
@@ -620,20 +620,24 @@ enum tree_index {
TI_CONST_PTR_TYPE,
TI_SIZE_TYPE,
TI_PID_TYPE,
TI_PTRDIFF_TYPE,
TI_VA_LIST_TYPE,
TI_VA_LIST_GPR_COUNTER_FIELD,
TI_VA_LIST_FPR_COUNTER_FIELD,
TI_BOOLEAN_TYPE,
TI_FILEPTR_TYPE,
TI_CONST_TM_PTR_TYPE,
+ TI_FENV_T_PTR_TYPE,
+ TI_CONST_FENV_T_PTR_TYPE,
+ TI_FEXCEPT_T_PTR_TYPE,
+ TI_CONST_FEXCEPT_T_PTR_TYPE,
TI_POINTER_SIZED_TYPE,
TI_POINTER_BOUNDS_TYPE,
TI_DFLOAT32_TYPE,
TI_DFLOAT64_TYPE,
TI_DFLOAT128_TYPE,
TI_DFLOAT32_PTR_TYPE,
TI_DFLOAT64_PTR_TYPE,
TI_DFLOAT128_PTR_TYPE,
Index: gcc/tree.c
===================================================================
--- gcc/tree.c (revision 249585)
+++ gcc/tree.c (working copy)
@@ -14545,24 +14545,28 @@ get_nonnull_args (const_tree fntype)
}
}
return argmap;
}
/* List of pointer types used to declare builtins before we have seen their
real declaration.
Keep the size up to date in tree.h ! */
-const builtin_structptr_type builtin_structptr_types[2] =
+const builtin_structptr_type builtin_structptr_types[6] =
{
{ fileptr_type_node, ptr_type_node, "FILE" },
- { const_tm_ptr_type_node, const_ptr_type_node, "tm" }
+ { const_tm_ptr_type_node, const_ptr_type_node, "tm" },
+ { fenv_t_ptr_type_node, ptr_type_node, "fenv_t" },
+ { const_fenv_t_ptr_type_node, const_ptr_type_node, "fenv_t" },
+ { fexcept_t_ptr_type_node, ptr_type_node, "fexcept_t" },
+ { const_fexcept_t_ptr_type_node, const_ptr_type_node, "fexcept_t" }
};
#if CHECKING_P
namespace selftest {
/* Selftests for tree. */
/* Verify that integer constants are sane. */
Index: gcc/tree.h
===================================================================
--- gcc/tree.h (revision 249585)
+++ gcc/tree.h (working copy)
@@ -3718,20 +3718,26 @@ id_equal (const char *str, const_tree id
#define size_type_node global_trees[TI_SIZE_TYPE]
#define pid_type_node global_trees[TI_PID_TYPE]
#define ptrdiff_type_node global_trees[TI_PTRDIFF_TYPE]
#define va_list_type_node global_trees[TI_VA_LIST_TYPE]
#define va_list_gpr_counter_field global_trees[TI_VA_LIST_GPR_COUNTER_FIELD]
#define va_list_fpr_counter_field global_trees[TI_VA_LIST_FPR_COUNTER_FIELD]
/* The C type `FILE *'. */
#define fileptr_type_node global_trees[TI_FILEPTR_TYPE]
/* The C type `const struct tm *'. */
#define const_tm_ptr_type_node global_trees[TI_CONST_TM_PTR_TYPE]
+/* The C type `fenv_t *'. */
+#define fenv_t_ptr_type_node global_trees[TI_FENV_T_PTR_TYPE]
+#define const_fenv_t_ptr_type_node global_trees[TI_CONST_FENV_T_PTR_TYPE]
+/* The C type `fexcept_t *'. */
+#define fexcept_t_ptr_type_node global_trees[TI_FEXCEPT_T_PTR_TYPE]
+#define const_fexcept_t_ptr_type_node global_trees[TI_CONST_FEXCEPT_T_PTR_TYPE]
#define pointer_sized_int_node global_trees[TI_POINTER_SIZED_TYPE]
#define boolean_type_node global_trees[TI_BOOLEAN_TYPE]
#define boolean_false_node global_trees[TI_BOOLEAN_FALSE]
#define boolean_true_node global_trees[TI_BOOLEAN_TRUE]
/* The decimal floating point types. */
#define dfloat32_type_node global_trees[TI_DFLOAT32_TYPE]
#define dfloat64_type_node global_trees[TI_DFLOAT64_TYPE]
#define dfloat128_type_node global_trees[TI_DFLOAT128_TYPE]
@@ -5524,12 +5530,12 @@ desired_pro_or_demotion_p (const_tree to
}
/* Pointer type used to declare builtins before we have seen its real
declaration. */
struct builtin_structptr_type
{
tree& node;
tree& base;
const char *str;
};
-extern const builtin_structptr_type builtin_structptr_types[2];
+extern const builtin_structptr_type builtin_structptr_types[6];
#endif /* GCC_TREE_H */