From 7610abd8cbb3c9f75a88b90196e9bb207aff09db Mon Sep 17 00:00:00 2001 From: "Kaveh R. Ghazi" Date: Wed, 14 Oct 2009 01:14:53 +0000 Subject: builtins.c (fold_builtin_1): Support complex "arc" functions. * builtins.c (fold_builtin_1): Support complex "arc" functions. * real.h (HAVE_mpc_arc): Define. testsuite: * gcc.dg/torture/builtin-math-6.c: Test complex "arc" functions. * lib/target-supports.exp (check_effective_target_mpc_arc): New. From-SVN: r152746 --- gcc/ChangeLog | 5 +++ gcc/builtins.c | 40 +++++++++++++++++++++- gcc/real.h | 3 ++ gcc/testsuite/ChangeLog | 5 +++ gcc/testsuite/gcc.dg/torture/builtin-math-6.c | 49 ++++++++++++++++++++++++--- gcc/testsuite/lib/target-supports.exp | 23 +++++++++++++ 6 files changed, 119 insertions(+), 6 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e2440ab..6b45ac0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2009-10-13 Kaveh R. Ghazi + + * builtins.c (fold_builtin_1): Support complex "arc" functions. + * real.h (HAVE_mpc_arc): Define. + 2009-10-14 Kaz Kojima * config/sh/sh.c (TARGET_BUILTIN_DECL): Define. diff --git a/gcc/builtins.c b/gcc/builtins.c index 55228d2..d991408 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -10063,7 +10063,45 @@ fold_builtin_1 (location_t loc, tree fndecl, tree arg0, bool ignore) && TREE_CODE (TREE_TYPE (TREE_TYPE (arg0))) == REAL_TYPE) return do_mpc_arg1 (arg0, type, mpc_sqrt); break; -#endif + +#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) + return do_mpc_arg1 (arg0, type, mpc_asin); + break; + + CASE_FLT_FN (BUILT_IN_CACOS): + if (validate_arg (arg0, COMPLEX_TYPE) + && TREE_CODE (TREE_TYPE (TREE_TYPE (arg0))) == REAL_TYPE) + return do_mpc_arg1 (arg0, type, mpc_acos); + break; + + CASE_FLT_FN (BUILT_IN_CATAN): + if (validate_arg (arg0, COMPLEX_TYPE) + && TREE_CODE (TREE_TYPE (TREE_TYPE (arg0))) == REAL_TYPE) + return do_mpc_arg1 (arg0, type, mpc_atan); + break; + + CASE_FLT_FN (BUILT_IN_CASINH): + if (validate_arg (arg0, COMPLEX_TYPE) + && TREE_CODE (TREE_TYPE (TREE_TYPE (arg0))) == REAL_TYPE) + return do_mpc_arg1 (arg0, type, mpc_asinh); + break; + + CASE_FLT_FN (BUILT_IN_CACOSH): + if (validate_arg (arg0, COMPLEX_TYPE) + && TREE_CODE (TREE_TYPE (TREE_TYPE (arg0))) == REAL_TYPE) + return do_mpc_arg1 (arg0, type, mpc_acosh); + break; + + CASE_FLT_FN (BUILT_IN_CATANH): + if (validate_arg (arg0, COMPLEX_TYPE) + && 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); diff --git a/gcc/real.h b/gcc/real.h index e72723e..e1fd3b0 100644 --- a/gcc/real.h +++ b/gcc/real.h @@ -32,6 +32,9 @@ extern tree do_mpc_arg2 (tree, tree, tree, int, int (*)(mpc_ptr, mpc_srcptr, mpc # 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 --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 55a49e9..2144290 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-10-13 Kaveh R. Ghazi + + * gcc.dg/torture/builtin-math-6.c: Test complex "arc" functions. + * lib/target-supports.exp (check_effective_target_mpc_arc): New. + 2009-10-14 Hans-Peter Nilsson PR target/38948 diff --git a/gcc/testsuite/gcc.dg/torture/builtin-math-6.c b/gcc/testsuite/gcc.dg/torture/builtin-math-6.c index 1bf367a..097a8c2 100644 --- a/gcc/testsuite/gcc.dg/torture/builtin-math-6.c +++ b/gcc/testsuite/gcc.dg/torture/builtin-math-6.c @@ -6,7 +6,7 @@ Origin: Kaveh R. Ghazi, January 28, 2009. */ /* { dg-do link } */ -/* { dg-require-effective-target mpc_pow } */ +/* { dg-require-effective-target mpc_arc } */ /* All references to link_error should go away at compile-time. The first number is the line number and the second is the value number @@ -180,9 +180,48 @@ extern void link_error(int, int); int main (void) { + TESTIT_COMPLEX (1, cacos, 1, CONJ(0)); + TESTIT_COMPLEX_R (1, cacos, -1, CONJ(3.141593F)); + TESTIT_COMPLEX (1, cacos, CONJ(1), 0); + TESTIT_COMPLEX_R (1, cacos, CONJ(-1), 3.141593F); + TESTIT_COMPLEX_R_ALLNEG (cacos, 3.45678F + 2.34567FI, + 0.60971F - 2.11780FI, 2.531875F - 2.117800FI, + 0.60971F + 2.11780FI, 2.531875F + 2.117800FI); + + TESTIT_COMPLEX_ALLNEG (casin, 0, + 0, -CONJ(0), CONJ(0), CONJ(-0.F)); + TESTIT_COMPLEX_R_ALLNEG (casin, 3.45678F + 2.34567FI, + 0.96107F + 2.11780FI, -0.96107F + 2.11780FI, + 0.96107F - 2.11780FI, -0.96107F - 2.11780FI); + + TESTIT_COMPLEX_ALLNEG (catan, 0, + 0, -CONJ(0), CONJ(0), CONJ(-0.F)); + TESTIT_COMPLEX_R_ALLNEG (catan, 3.45678F + 2.34567FI, + 1.37188F + 0.12997FI, -1.37188F + 0.12997FI, + 1.37188F - 0.12997FI, -1.37188F - 0.12997FI); + + TESTIT_COMPLEX (1, cacosh, 1, 0); + TESTIT_COMPLEX_R (1, cacosh, -1, 3.141593FI); + TESTIT_COMPLEX (1, cacosh, CONJ(1), CONJ(0)); + TESTIT_COMPLEX_R (1, cacosh, CONJ(-1), CONJ(3.141593FI)); + TESTIT_COMPLEX_R_ALLNEG (cacosh, 3.45678F + 2.34567FI, + 2.11780F + 0.60971FI, 2.11780F + 2.531875FI, + 2.11780F - 0.60971FI, 2.11780F - 2.531875FI); + + TESTIT_COMPLEX_ALLNEG (casinh, 0, + 0, -CONJ(0), CONJ(0), CONJ(-0.F)); + TESTIT_COMPLEX_R_ALLNEG (casinh, 3.45678F + 2.34567FI, + 2.12836F + 0.58310FI, -2.12836F + 0.58310FI, + 2.12836F - 0.58310FI, -2.12836F - 0.58310FI); + + TESTIT_COMPLEX_ALLNEG (catanh, 0, + 0, -CONJ(0), CONJ(0), CONJ(-0.F)); + TESTIT_COMPLEX_R_ALLNEG (catanh, 3.45678F + 2.34567FI, + 0.19693F + 1.43190FI, -0.19693F + 1.43190FI, + 0.19693F - 1.43190FI, -0.19693F - 1.43190FI); + TESTIT_COMPLEX_ALLNEG (csin, 0, - 0, -0.F, - CONJ(0), CONJ(-0.F)); + 0, -0.F, CONJ(0), CONJ(-0.F)); TESTIT_COMPLEX_R_ALLNEG (csin, 3.45678F + 2.34567FI, -1.633059F - 4.917448FI, 1.633059F - 4.917448FI, -1.633059F + 4.917448FI, 1.633059F + 4.917448FI); @@ -219,8 +258,8 @@ int main (void) TESTIT_COMPLEX (1, clog, 1, 0); TESTIT_COMPLEX_R (1, clog, -1, 3.141593FI); - TESTIT_COMPLEX (1, clog, CONJ(1), CONJ(0)); /* Fails with mpc-0.6. */ - TESTIT_COMPLEX_R (1, clog, CONJ(-1), CONJ(3.141593FI)); /* Fails with mpc-0.6. */ + TESTIT_COMPLEX (1, clog, CONJ(1), CONJ(0)); + TESTIT_COMPLEX_R (1, clog, CONJ(-1), CONJ(3.141593FI)); TESTIT_COMPLEX_R_ALLNEG (clog, 3.45678F + 2.34567FI, 1.429713F + 0.596199FI, 1.429713F + 2.545394FI, 1.429713F - 0.596199FI, 1.429713F - 2.545394FI); diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 26ef7b7..c287cec 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -3127,6 +3127,29 @@ proc check_effective_target_mpc_pow { } { }] } +# Return 1 if the MPC library with "arc" functions is integrated with GCC, 0 otherwise. + +proc check_effective_target_mpc_arc { } { + return [check_no_compiler_messages mpc_arc executable { + extern void link_error(void); + int main () + { + if (__builtin_cacos(1) != 0) + link_error(); + if (__builtin_casin(0) != 0) + link_error(); + if (__builtin_catan(0) != 0) + link_error(); + if (__builtin_cacosh(1) != 0) + link_error(); + if (__builtin_casinh(0) != 0) + link_error(); + if (__builtin_catanh(0) != 0) + link_error(); + } + }] +} + # Return 1 if the language for the compiler under test is C. proc check_effective_target_c { } { -- cgit v1.1