[Committed] Lower conj, creal and cimag in builtins.c

Roger Sayle roger@eyesopen.com
Thu Jun 10 21:19:00 GMT 2004


As described to RTH, this patch is the second installment of a
series to lower built-in functions to tree nodes in the middle-end
instead of in each of the language front-ends.  This patch allows
us to lower conj, creal and cimag (and their float and long double
variants).  Once again, expand_builtin is tweaked to allow us to
fall back to the library functions in the event of argument type
mismatches.

The following patch has been tested on i686-pc-linux-gnu with a
complete "make bootstrap", all default languages, and regression
tested with a top-level "make -k check" with no new failures.

Committed to mainline CVS.


2004-06-10  Roger Sayle  <roger@eyesopen.com>

	* builtins.c (expand_builtin): Fall back to library function call for
	conj, conjf, conjl, creal, crealf, creall, cimag, cimagf and cimagl.
	(fold_builtin_1): Lower built-ins BUILT_IN_CONJ{,F,L} to CONJ_EXPR,
	BUILT_IN_CREAL{,F,L} to REALPART_EXPR, and BUILT_IN_CIMAG{,F,L} to
	IMAGPART_EXPR respectively.


Index: builtins.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/builtins.c,v
retrieving revision 1.334
diff -c -3 -p -r1.334 builtins.c
*** builtins.c	10 Jun 2004 13:29:34 -0000	1.334
--- builtins.c	10 Jun 2004 16:35:05 -0000
*************** expand_builtin (tree exp, rtx target, rt
*** 5649,5667 ****
  	}
        break;

-     case BUILT_IN_CONJ:
-     case BUILT_IN_CONJF:
-     case BUILT_IN_CONJL:
-     case BUILT_IN_CREAL:
-     case BUILT_IN_CREALF:
-     case BUILT_IN_CREALL:
-     case BUILT_IN_CIMAG:
-     case BUILT_IN_CIMAGF:
-     case BUILT_IN_CIMAGL:
-       /* expand_tree_builtin changes these into CONJ_EXPR, REALPART_EXPR
- 	 and IMAGPART_EXPR.  */
-       abort ();
-
      case BUILT_IN_EXP:
      case BUILT_IN_EXPF:
      case BUILT_IN_EXPL:
--- 5649,5654 ----
*************** fold_builtin_1 (tree exp)
*** 7663,7668 ****
--- 7650,7678 ----
      case BUILT_IN_IMAXABS:
        return fold_builtin_abs (arglist, type);

+     case BUILT_IN_CONJ:
+     case BUILT_IN_CONJF:
+     case BUILT_IN_CONJL:
+       if (validate_arglist (arglist, COMPLEX_TYPE, VOID_TYPE))
+ 	return fold (build1 (CONJ_EXPR, type, TREE_VALUE (arglist)));
+       break;
+
+     case BUILT_IN_CREAL:
+     case BUILT_IN_CREALF:
+     case BUILT_IN_CREALL:
+       if (validate_arglist (arglist, COMPLEX_TYPE, VOID_TYPE))
+         return non_lvalue (fold (build1 (REALPART_EXPR, type,
+ 					 TREE_VALUE (arglist))));
+       break;
+
+     case BUILT_IN_CIMAG:
+     case BUILT_IN_CIMAGF:
+     case BUILT_IN_CIMAGL:
+       if (validate_arglist (arglist, COMPLEX_TYPE, VOID_TYPE))
+         return non_lvalue (fold (build1 (IMAGPART_EXPR, type,
+ 					 TREE_VALUE (arglist))));
+       break;
+
      case BUILT_IN_CABS:
      case BUILT_IN_CABSF:
      case BUILT_IN_CABSL:


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



More information about the Gcc-patches mailing list