This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH]: MPC cleanup in middle-end
- From: "Kaveh R. GHAZI" <ghazi at caip dot rutgers dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 15 Nov 2009 11:46:58 -0500 (EST)
- Subject: [PATCH]: MPC cleanup in middle-end
This patch removes the HAVE_mpc* cpp conditionals from the middle-end.
They were necessary only while MPC was optional. It depends on this
patch to require MPC:
http://gcc.gnu.org/ml/gcc-patches/2009-11/msg00731.html
Tested on x86_64-unknown-linux-gnu, no regressions.
Okay for mainline once the above patch goes in?
Thanks,
--Kaveh
2009-11-14 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* builtins.c: Remove HAVE_mpc* checks throughout.
* fold-const.c: Likewise.
* real.h: Likewise.
* toplev.c: Likewise.
diff -rup orig/egcc-SVN20091114/gcc/builtins.c egcc-SVN20091114/gcc/builtins.c
--- orig/egcc-SVN20091114/gcc/builtins.c 2009-11-09 02:00:39.000000000 +0100
+++ egcc-SVN20091114/gcc/builtins.c 2009-11-14 23:28:19.000000000 +0100
@@ -58,9 +58,7 @@ along with GCC; see the file COPYING3.
#ifndef PAD_VARARGS_DOWN
#define PAD_VARARGS_DOWN BYTES_BIG_ENDIAN
#endif
-#ifdef HAVE_mpc
static tree do_mpc_arg1 (tree, tree, int (*)(mpc_ptr, mpc_srcptr, mpc_rnd_t));
-#endif
/* Define the names of the builtin function types and codes. */
const char *const built_in_class_names[4]
@@ -7467,20 +7465,17 @@ fold_builtin_cosh (location_t loc, tree
NULL_TREE if no simplification can be made. */
static tree
-fold_builtin_ccos (location_t loc,
- tree arg, tree type ATTRIBUTE_UNUSED, tree fndecl,
- bool hyper ATTRIBUTE_UNUSED)
+fold_builtin_ccos (location_t loc, tree arg, tree type, tree fndecl,
+ bool hyper)
{
if (validate_arg (arg, COMPLEX_TYPE)
&& TREE_CODE (TREE_TYPE (TREE_TYPE (arg))) == REAL_TYPE)
{
tree tmp;
-#ifdef HAVE_mpc
/* Calculate the result when the argument is a constant. */
if ((tmp = do_mpc_arg1 (arg, type, (hyper ? mpc_cosh : mpc_cos))))
return tmp;
-#endif
/* Optimize fn(-x) into fn(x). */
if ((tmp = fold_strip_sign_ops (arg)))
@@ -7565,19 +7560,15 @@ fold_builtin_cexp (location_t loc, tree
{
tree rtype;
tree realp, imagp, ifn;
-#ifdef HAVE_mpc
tree res;
-#endif
if (!validate_arg (arg0, COMPLEX_TYPE)
|| TREE_CODE (TREE_TYPE (TREE_TYPE (arg0))) != REAL_TYPE)
return NULL_TREE;
-#ifdef HAVE_mpc
/* Calculate the result when the argument is a constant. */
if ((res = do_mpc_arg1 (arg0, type, mpc_exp)))
return res;
-#endif
rtype = TREE_TYPE (TREE_TYPE (arg0));
@@ -10015,7 +10006,6 @@ fold_builtin_1 (location_t loc, tree fnd
CASE_FLT_FN (BUILT_IN_CCOSH):
return fold_builtin_ccos(loc, arg0, type, fndecl, /*hyper=*/ true);
-#ifdef HAVE_mpc
CASE_FLT_FN (BUILT_IN_CSIN):
if (validate_arg (arg0, COMPLEX_TYPE)
&& TREE_CODE (TREE_TYPE (TREE_TYPE (arg0))) == REAL_TYPE)
@@ -10052,7 +10042,6 @@ fold_builtin_1 (location_t loc, tree fnd
return do_mpc_arg1 (arg0, type, mpc_sqrt);
break;
-#ifdef HAVE_mpc_arc
CASE_FLT_FN (BUILT_IN_CASIN):
if (validate_arg (arg0, COMPLEX_TYPE)
&& TREE_CODE (TREE_TYPE (TREE_TYPE (arg0))) == REAL_TYPE)
@@ -10088,8 +10077,6 @@ fold_builtin_1 (location_t loc, tree fnd
&& TREE_CODE (TREE_TYPE (TREE_TYPE (arg0))) == REAL_TYPE)
return do_mpc_arg1 (arg0, type, mpc_atanh);
break;
-#endif /* HAVE_mpc_arc */
-#endif /* HAVE_mpc */
CASE_FLT_FN (BUILT_IN_CABS):
return fold_builtin_cabs (loc, arg0, type, fndecl);
@@ -10407,7 +10394,6 @@ fold_builtin_2 (location_t loc, tree fnd
CASE_FLT_FN (BUILT_IN_HYPOT):
return fold_builtin_hypot (loc, fndecl, arg0, arg1, type);
-#ifdef HAVE_mpc_pow
CASE_FLT_FN (BUILT_IN_CPOW):
if (validate_arg (arg0, COMPLEX_TYPE)
&& TREE_CODE (TREE_TYPE (TREE_TYPE (arg0))) == REAL_TYPE
@@ -10415,7 +10401,6 @@ fold_builtin_2 (location_t loc, tree fnd
&& TREE_CODE (TREE_TYPE (TREE_TYPE (arg1))) == REAL_TYPE)
return do_mpc_arg2 (arg0, arg1, type, /*do_nonfinite=*/ 0, mpc_pow);
break;
-#endif
CASE_FLT_FN (BUILT_IN_LDEXP):
return fold_builtin_load_exponent (loc, arg0, arg1, type, /*ldexp=*/true);
@@ -13035,7 +13020,6 @@ do_mpfr_ckconv (mpfr_srcptr m, tree type
return NULL_TREE;
}
-#ifdef HAVE_mpc
/* Helper function for do_mpc_arg*(). Ensure M is a normal complex
number and no overflow/underflow occurred. INEXACT is true if M
was not exactly calculated. TYPE is the tree type for the result.
@@ -13082,7 +13066,6 @@ do_mpc_ckconv (mpc_srcptr m, tree type,
}
return NULL_TREE;
}
-#endif /* HAVE_mpc */
/* If argument ARG is a REAL_CST, call the one-argument mpfr function
FUNC on it and return the resulting value as a tree with type TYPE.
@@ -13480,7 +13463,6 @@ do_mpfr_lgamma_r (tree arg, tree arg_sg,
return result;
}
-#ifdef HAVE_mpc
/* If argument ARG is a COMPLEX_CST, call the one-argument mpc
function FUNC on it and return the resulting value as a tree with
type TYPE. The mpfr precision is set to the precision of TYPE. We
@@ -13534,7 +13516,6 @@ do_mpc_arg1 (tree arg, tree type, int (*
DO_NONFINITE is true, then fold expressions containing Inf or NaN
in the arguments and/or results. */
-#ifdef HAVE_mpc
tree
do_mpc_arg2 (tree arg0, tree arg1, tree type, int do_nonfinite,
int (*func)(mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t))
@@ -13585,8 +13566,6 @@ do_mpc_arg2 (tree arg0, tree arg1, tree
return result;
}
-# endif
-#endif /* HAVE_mpc */
/* FIXME tuples.
The functions below provide an alternate interface for folding
diff -rup orig/egcc-SVN20091114/gcc/fold-const.c egcc-SVN20091114/gcc/fold-const.c
--- orig/egcc-SVN20091114/gcc/fold-const.c 2009-11-11 02:00:49.000000000 +0100
+++ egcc-SVN20091114/gcc/fold-const.c 2009-11-14 23:25:25.000000000 +0100
@@ -1966,12 +1966,10 @@ const_binop (enum tree_code code, tree a
break;
case MULT_EXPR:
-#ifdef HAVE_mpc
if (COMPLEX_FLOAT_TYPE_P (type))
return do_mpc_arg2 (arg1, arg2, type,
/* do_nonfinite= */ folding_initializer,
mpc_mul);
-#endif
real = const_binop (MINUS_EXPR,
const_binop (MULT_EXPR, r1, r2, notrunc),
@@ -1984,14 +1982,11 @@ const_binop (enum tree_code code, tree a
break;
case RDIV_EXPR:
-#ifdef HAVE_mpc
if (COMPLEX_FLOAT_TYPE_P (type))
return do_mpc_arg2 (arg1, arg2, type,
/* do_nonfinite= */ folding_initializer,
mpc_div);
/* Fallthru ... */
-#endif
-
case TRUNC_DIV_EXPR:
case CEIL_DIV_EXPR:
case FLOOR_DIV_EXPR:
diff -rup orig/egcc-SVN20091114/gcc/real.h egcc-SVN20091114/gcc/real.h
--- orig/egcc-SVN20091114/gcc/real.h 2009-10-14 03:40:36.000000000 +0200
+++ egcc-SVN20091114/gcc/real.h 2009-11-14 23:23:27.000000000 +0100
@@ -24,18 +24,8 @@
#ifndef GENERATOR_FILE
#include <gmp.h>
#include <mpfr.h>
-#ifdef HAVE_mpc
#include <mpc.h>
-# ifdef HAVE_mpc
extern tree do_mpc_arg2 (tree, tree, tree, int, int (*)(mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t));
-# endif
-# if MPC_VERSION >= MPC_VERSION_NUM(0,6,1)
-# define HAVE_mpc_pow
-# endif
-# if MPC_VERSION >= MPC_VERSION_NUM(0,7,1)
-# define HAVE_mpc_arc
-# endif
-#endif
#endif
#include "machmode.h"
diff -rup orig/egcc-SVN20091114/gcc/toplev.c egcc-SVN20091114/gcc/toplev.c
--- orig/egcc-SVN20091114/gcc/toplev.c 2009-10-04 02:00:39.000000000 +0200
+++ egcc-SVN20091114/gcc/toplev.c 2009-11-14 23:24:40.000000000 +0100
@@ -1198,13 +1198,8 @@ print_version (FILE *file, const char *i
N_("%s%s%s %sversion %s (%s) compiled by CC, ")
#endif
;
-#ifdef HAVE_mpc
static const char fmt2[] =
N_("GMP version %s, MPFR version %s, MPC version %s\n");
-#else
- static const char fmt2[] =
- N_("GMP version %s, MPFR version %s\n");
-#endif
static const char fmt3[] =
N_("%s%swarning: %s header version %s differs from library version %s.\n");
static const char fmt4[] =
@@ -1236,11 +1231,7 @@ print_version (FILE *file, const char *i
#endif
fprintf (file,
file == stderr ? _(fmt2) : fmt2,
- GCC_GMP_STRINGIFY_VERSION, MPFR_VERSION_STRING
-#ifdef HAVE_mpc
- , MPC_VERSION_STRING
-#endif
- );
+ GCC_GMP_STRINGIFY_VERSION, MPFR_VERSION_STRING, MPC_VERSION_STRING);
if (strcmp (GCC_GMP_STRINGIFY_VERSION, gmp_version))
fprintf (file,
file == stderr ? _(fmt3) : fmt3,
@@ -1251,13 +1242,11 @@ print_version (FILE *file, const char *i
file == stderr ? _(fmt3) : fmt3,
indent, *indent != 0 ? " " : "",
"MPFR", MPFR_VERSION_STRING, mpfr_get_version ());
-#ifdef HAVE_mpc
if (strcmp (MPC_VERSION_STRING, mpc_get_version ()))
fprintf (file,
file == stderr ? _(fmt3) : fmt3,
indent, *indent != 0 ? " " : "",
"MPC", MPC_VERSION_STRING, mpc_get_version ());
-#endif
fprintf (file,
file == stderr ? _(fmt4) : fmt4,
indent, *indent != 0 ? " " : "",