This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[FORTRAN] Use tan and atan builtins


The following patch tweaks the g77 front-end to use GCC's tan and
atan built-ins to implement FORTRAN's TAN and ATAN functions.

The following patch has been tested on i686-pc-linux-gnu with a full
"make bootstrap" configured with --enable-languages=c,f77 and regression
tested with a top-level "make -k check" with no new failures.

Ok for mainline?


2003-05-28  Roger Sayle  <roger@eyesopen.com>

	* com.c (ffecom_init_0): Define built-in functions for tan and atan.
	* com-rt.def: Use then to implement g77's tan and atan intrinsics.


Index: com.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/f/com.c,v
retrieving revision 1.196
diff -c -3 -p -r1.196 com.c
*** com.c	22 May 2003 19:49:01 -0000	1.196
--- com.c	25 May 2003 18:38:56 -0000
*************** ffecom_init_0 ()
*** 11753,11758 ****
--- 11753,11765 ----
    ffecom_tree_blockdata_type
      = build_function_type (void_type_node, NULL_TREE);

+   builtin_function ("__builtin_atanf", float_ftype_float,
+ 		    BUILT_IN_ATANF, BUILT_IN_NORMAL, "atanf", NULL_TREE);
+   builtin_function ("__builtin_atan", double_ftype_double,
+ 		    BUILT_IN_ATAN, BUILT_IN_NORMAL, "atan", NULL_TREE);
+   builtin_function ("__builtin_atanl", ldouble_ftype_ldouble,
+ 		    BUILT_IN_ATANL, BUILT_IN_NORMAL, "atanl", NULL_TREE);
+
    builtin_function ("__builtin_atan2f", float_ftype_float_float,
  		    BUILT_IN_ATAN2F, BUILT_IN_NORMAL, "atan2f", NULL_TREE);
    builtin_function ("__builtin_atan2", double_ftype_double_double,
*************** ffecom_init_0 ()
*** 11815,11820 ****
--- 11822,11834 ----
  		    BUILT_IN_SQRT, BUILT_IN_NORMAL, "sqrt", NULL_TREE);
    builtin_function ("__builtin_sqrtl", ldouble_ftype_ldouble,
  		    BUILT_IN_SQRTL, BUILT_IN_NORMAL, "sqrtl", NULL_TREE);
+
+   builtin_function ("__builtin_tanf", float_ftype_float,
+ 		    BUILT_IN_TANF, BUILT_IN_NORMAL, "tanf", NULL_TREE);
+   builtin_function ("__builtin_tan", double_ftype_double,
+ 		    BUILT_IN_TAN, BUILT_IN_NORMAL, "tan", NULL_TREE);
+   builtin_function ("__builtin_tanl", ldouble_ftype_ldouble,
+ 		    BUILT_IN_TANL, BUILT_IN_NORMAL, "tanl", NULL_TREE);

    pedantic_lvalues = FALSE;

Index: com-rt.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/f/com-rt.def,v
retrieving revision 1.14
diff -c -3 -p -r1.14 com-rt.def
*** com-rt.def	12 May 2003 12:45:25 -0000	1.14
--- com-rt.def	25 May 2003 18:38:56 -0000
*************** DEFGFRT (FFECOM_gfrtDIMAG, "d_imag", FFE
*** 259,265 ****

  DEFGFRT (FFECOM_gfrtL_ACOS, "acos", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)
  DEFGFRT (FFECOM_gfrtL_ASIN, "asin", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)
! DEFGFRT (FFECOM_gfrtL_ATAN, "atan", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)
  DEFGFRT (FFECOM_gfrtL_ATAN2, "__builtin_atan2", FFECOM_rttypeDOUBLE_, "dd", FALSE, FALSE, TRUE)
  DEFGFRT (FFECOM_gfrtL_COS, "__builtin_cos", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)
  DEFGFRT (FFECOM_gfrtL_COSH, "cosh", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)
--- 259,265 ----

  DEFGFRT (FFECOM_gfrtL_ACOS, "acos", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)
  DEFGFRT (FFECOM_gfrtL_ASIN, "asin", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)
! DEFGFRT (FFECOM_gfrtL_ATAN, "__builtin_atan", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)
  DEFGFRT (FFECOM_gfrtL_ATAN2, "__builtin_atan2", FFECOM_rttypeDOUBLE_, "dd", FALSE, FALSE, TRUE)
  DEFGFRT (FFECOM_gfrtL_COS, "__builtin_cos", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)
  DEFGFRT (FFECOM_gfrtL_COSH, "cosh", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)
*************** DEFGFRT (FFECOM_gfrtL_POW, "__builtin_po
*** 274,280 ****
  DEFGFRT (FFECOM_gfrtL_SIN, "__builtin_sin", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)
  DEFGFRT (FFECOM_gfrtL_SINH, "sinh", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)
  DEFGFRT (FFECOM_gfrtL_SQRT, "__builtin_sqrt", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)
! DEFGFRT (FFECOM_gfrtL_TAN, "tan", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)
  DEFGFRT (FFECOM_gfrtL_TANH, "tanh", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)

  DEFGFRT (FFECOM_gfrtPOW_CI, "pow_ci", FFECOM_rttypeCOMPLEX_F2C_, "&c&i", FALSE, TRUE, FALSE)
--- 274,280 ----
  DEFGFRT (FFECOM_gfrtL_SIN, "__builtin_sin", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)
  DEFGFRT (FFECOM_gfrtL_SINH, "sinh", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)
  DEFGFRT (FFECOM_gfrtL_SQRT, "__builtin_sqrt", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)
! DEFGFRT (FFECOM_gfrtL_TAN, "__builtin_tan", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)
  DEFGFRT (FFECOM_gfrtL_TANH, "tanh", FFECOM_rttypeDOUBLE_, "d", FALSE, FALSE, TRUE)

  DEFGFRT (FFECOM_gfrtPOW_CI, "pow_ci", FFECOM_rttypeCOMPLEX_F2C_, "&c&i", FALSE, TRUE, FALSE)


Roger
--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-473-0833


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]