diff options
author | ghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-10-14 01:14:53 +0000 |
---|---|---|
committer | ghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-10-14 01:14:53 +0000 |
commit | 0e7e6e7f09cfa794f137dc97556052a7f27a3f48 (patch) | |
tree | ef482df1dbca9c07d51e39903d45c94ad89f9fc5 /gcc | |
parent | 3213bdbf724306805f244b9200902e9197848113 (diff) | |
download | ppe42-gcc-0e7e6e7f09cfa794f137dc97556052a7f27a3f48.tar.gz ppe42-gcc-0e7e6e7f09cfa794f137dc97556052a7f27a3f48.zip |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@152746 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/builtins.c | 40 | ||||
-rw-r--r-- | gcc/real.h | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/builtin-math-6.c | 49 | ||||
-rw-r--r-- | gcc/testsuite/lib/target-supports.exp | 23 |
6 files changed, 119 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e2440abd626..6b45ac0c837 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2009-10-13 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * builtins.c (fold_builtin_1): Support complex "arc" functions. + * real.h (HAVE_mpc_arc): Define. + 2009-10-14 Kaz Kojima <kkojima@gcc.gnu.org> * config/sh/sh.c (TARGET_BUILTIN_DECL): Define. diff --git a/gcc/builtins.c b/gcc/builtins.c index 55228d22c40..d991408fa28 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 e72723e01ea..e1fd3b07f60 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 55a49e95b15..2144290194d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-10-13 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * 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 <hp@axis.com> 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 1bf367a5deb..097a8c25d37 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 26ef7b7038e..c287cec85bb 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 { } { |