[PATCH]: convert more fold(buildN()) -> fold_buildN()

Kaveh R. GHAZI ghazi@caip.rutgers.edu
Sat Mar 3 16:19:00 GMT 2007


This patch catches some of the remaining fold(buildN()) -> fold_buildN()
conversions.  After this patch what remains is two in tree.c which call
fold(build4()).  There is no corresponding fold_build4 function to convert
these into.

./tree.c:2485:      new = fold (build4 (code, TREE_TYPE (exp), op0, op1, op2, op3));
./tree.c:2639:        return fold (build4 (code, TREE_TYPE (exp), op0, op1, op2, op3));

There are also about 50 remaining fold(buildN()) in the ada directory.
I'm not setup to bootstrap ada on my box, so I didn't touch those.

Tested on sparc-sun-solaris2.10, no regressions.  I also configured
cross-compilers to i686-unknown-linux-gnu and alpha-unknown-linux-gnu and
built cc1 to ensure there were no typos in the cpu.c files for those
systems.

Okay for mainline?

		Thanks,
		--Kaveh


2007-03-02  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* c-pretty-print.c (pp_c_direct_abstract_declarator): Use
	fold_build2.
	* config/alpha/alpha.c (alpha_fold_builtin_zapnot,
	alpha_fold_vector_minmax): Likewise.
	* config/i386/i386.c (ix86_gimplify_va_arg): Likewise.
	* config/sparc/sparc.c (sparc_gimplify_va_arg): Likewise.

diff -rup orig/egcc-SVN20070301/gcc/c-pretty-print.c egcc-SVN20070301/gcc/c-pretty-print.c
--- orig/egcc-SVN20070301/gcc/c-pretty-print.c	2007-02-15 20:03:54.000000000 -0500
+++ egcc-SVN20070301/gcc/c-pretty-print.c	2007-03-02 22:57:48.139741448 -0500
@@ -528,8 +528,8 @@ pp_c_direct_abstract_declarator (c_prett
 	  if (host_integerp (maxval, 0))
 	    pp_wide_integer (pp, tree_low_cst (maxval, 0) + 1);
 	  else
-	    pp_expression (pp, fold (build2 (PLUS_EXPR, type, maxval,
-					     build_int_cst (type, 1))));
+	    pp_expression (pp, fold_build2 (PLUS_EXPR, type, maxval,
+					    build_int_cst (type, 1)));
 	}
       pp_c_right_bracket (pp);
       pp_direct_abstract_declarator (pp, TREE_TYPE (t));
diff -rup orig/egcc-SVN20070301/gcc/config/alpha/alpha.c egcc-SVN20070301/gcc/config/alpha/alpha.c
--- orig/egcc-SVN20070301/gcc/config/alpha/alpha.c	2007-02-20 20:02:13.000000000 -0500
+++ egcc-SVN20070301/gcc/config/alpha/alpha.c	2007-03-02 22:59:30.743730817 -0500
@@ -6629,8 +6629,8 @@ alpha_fold_builtin_zapnot (tree *op, uns
 	return build_int_cst (long_integer_type_node, opint[0] & mask);

       if (op)
-	return fold (build2 (BIT_AND_EXPR, long_integer_type_node, op[0],
-			     build_int_cst (long_integer_type_node, mask)));
+	return fold_build2 (BIT_AND_EXPR, long_integer_type_node, op[0],
+			    build_int_cst (long_integer_type_node, mask));
     }
   else if ((op_const & 1) && opint[0] == 0)
     return build_int_cst (long_integer_type_node, 0);
@@ -6783,7 +6783,7 @@ alpha_fold_vector_minmax (enum tree_code
 {
   tree op0 = fold_convert (vtype, op[0]);
   tree op1 = fold_convert (vtype, op[1]);
-  tree val = fold (build2 (code, vtype, op0, op1));
+  tree val = fold_build2 (code, vtype, op0, op1);
   return fold_convert (long_integer_type_node, val);
 }

diff -rup orig/egcc-SVN20070301/gcc/config/i386/i386.c egcc-SVN20070301/gcc/config/i386/i386.c
--- orig/egcc-SVN20070301/gcc/config/i386/i386.c	2007-03-01 20:02:47.000000000 -0500
+++ egcc-SVN20070301/gcc/config/i386/i386.c	2007-03-02 22:59:44.401876185 -0500
@@ -4851,13 +4851,13 @@ ix86_gimplify_va_arg (tree valist, tree
 		  src_offset = REGNO (reg) * 8;
 		}
 	      src_addr = fold_convert (addr_type, src_addr);
-	      src_addr = fold (build2 (PLUS_EXPR, addr_type, src_addr,
-				       size_int (src_offset)));
+	      src_addr = fold_build2 (PLUS_EXPR, addr_type, src_addr,
+				      size_int (src_offset));
 	      src = build_va_arg_indirect_ref (src_addr);

 	      dest_addr = fold_convert (addr_type, addr);
-	      dest_addr = fold (build2 (PLUS_EXPR, addr_type, dest_addr,
-					size_int (INTVAL (XEXP (slot, 1)))));
+	      dest_addr = fold_build2 (PLUS_EXPR, addr_type, dest_addr,
+				       size_int (INTVAL (XEXP (slot, 1))));
 	      dest = build_va_arg_indirect_ref (dest_addr);

 	      t = build2 (GIMPLE_MODIFY_STMT, void_type_node, dest, src);
diff -rup orig/egcc-SVN20070301/gcc/config/sparc/sparc.c egcc-SVN20070301/gcc/config/sparc/sparc.c
--- orig/egcc-SVN20070301/gcc/config/sparc/sparc.c	2007-02-20 20:02:15.000000000 -0500
+++ egcc-SVN20070301/gcc/config/sparc/sparc.c	2007-03-02 22:57:16.186293664 -0500
@@ -5673,18 +5673,18 @@ sparc_gimplify_va_arg (tree valist, tree
   incr = valist;
   if (align)
     {
-      incr = fold (build2 (PLUS_EXPR, ptr_type_node, incr,
-			   ssize_int (align - 1)));
-      incr = fold (build2 (BIT_AND_EXPR, ptr_type_node, incr,
-			   ssize_int (-align)));
+      incr = fold_build2 (PLUS_EXPR, ptr_type_node, incr,
+			  ssize_int (align - 1));
+      incr = fold_build2 (BIT_AND_EXPR, ptr_type_node, incr,
+			  ssize_int (-align));
     }

   gimplify_expr (&incr, pre_p, post_p, is_gimple_val, fb_rvalue);
   addr = incr;

   if (BYTES_BIG_ENDIAN && size < rsize)
-    addr = fold (build2 (PLUS_EXPR, ptr_type_node, incr,
-			 ssize_int (rsize - size)));
+    addr = fold_build2 (PLUS_EXPR, ptr_type_node, incr,
+			ssize_int (rsize - size));

   if (indirect)
     {
@@ -5712,7 +5712,7 @@ sparc_gimplify_va_arg (tree valist, tree
   else
     addr = fold_convert (ptrtype, addr);

-  incr = fold (build2 (PLUS_EXPR, ptr_type_node, incr, ssize_int (rsize)));
+  incr = fold_build2 (PLUS_EXPR, ptr_type_node, incr, ssize_int (rsize));
   incr = build2 (GIMPLE_MODIFY_STMT, ptr_type_node, valist, incr);
   gimplify_and_add (incr, post_p);



More information about the Gcc-patches mailing list