diff mbox

wide-int, sparc

Message ID C09FD5EA-22DE-4E57-BEE5-CA13B195F7B1@comcast.net
State New
Headers show

Commit Message

Mike Stump Nov. 23, 2013, 7:22 p.m. UTC
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.    This patch covers the sparc port.

Ok?
* config/sol2-c.c
	(solaris_pragma_align): Use tree_fits_uhwi_p.
	* config/sparc/sparc.c: Include wide-int.h.
	(sparc_fold_builtin): Use wide-int interfaces.

Comments

Eric Botcazou Nov. 25, 2013, 9:01 a.m. UTC | #1
> Richi has asked the we break the wide-int patch so that the individual port
> and front end maintainers can review their parts without have to go through
> the entire patch.    This patch covers the sparc port.

OK if you change the type of 'low' in solaris_pragma_align to unsigned HWI.
diff mbox

Patch

diff --git a/gcc/config/sol2-c.c b/gcc/config/sol2-c.c
index 8254af0..5a173ff 100644
--- a/gcc/config/sol2-c.c
+++ b/gcc/config/sol2-c.c
@@ -96,7 +96,7 @@  solaris_pragma_align (cpp_reader *pfile ATTRIBUTE_UNUSED)
     }
 
   low = TREE_INT_CST_LOW (x);
-  if (TREE_INT_CST_HIGH (x) != 0
+  if (!tree_fits_uhwi_p (x)
       || (low != 1 && low != 2 && low != 4 && low != 8 && low != 16
 	  && low != 32 && low != 64 && low != 128))
     {
diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
index 8bdc9bb..410c8ee 100644
--- a/gcc/config/sparc/sparc.c
+++ b/gcc/config/sparc/sparc.c
@@ -59,6 +59,7 @@  along with GCC; see the file COPYING3.  If not see
 #include "opts.h"
 #include "tree-pass.h"
 #include "context.h"
+#include "wide-int.h"
 
 /* Processor costs */
 
@@ -10643,30 +10644,30 @@  sparc_fold_builtin (tree fndecl, int n_args ATTRIBUTE_UNUSED,
 	  && TREE_CODE (arg2) == INTEGER_CST)
 	{
 	  bool overflow = false;
-	  double_int result = TREE_INT_CST (arg2);
-	  double_int tmp;
+	  wide_int result = arg2;
+	  wide_int tmp;
 	  unsigned i;
 
 	  for (i = 0; i < VECTOR_CST_NELTS (arg0); ++i)
 	    {
-	      double_int e0 = TREE_INT_CST (VECTOR_CST_ELT (arg0, i));
-	      double_int e1 = TREE_INT_CST (VECTOR_CST_ELT (arg1, i));
+	      tree e0 = VECTOR_CST_ELT (arg0, i);
+	      tree e1 = VECTOR_CST_ELT (arg1, i);
 
 	      bool neg1_ovf, neg2_ovf, add1_ovf, add2_ovf;
 
-	      tmp = e1.neg_with_overflow (&neg1_ovf);
-	      tmp = e0.add_with_sign (tmp, false, &add1_ovf);
-	      if (tmp.is_negative ())
-		tmp = tmp.neg_with_overflow (&neg2_ovf);
+	      tmp = wi::neg (e1, &neg1_ovf);
+	      tmp = wi::add (e0, tmp, SIGNED, &add1_ovf);
+	      if (wi::neg_p (tmp))
+		tmp = wi::neg (tmp, &neg2_ovf);
 	      else
 		neg2_ovf = false;
-	      result = result.add_with_sign (tmp, false, &add2_ovf);
+	      result = wi::add (result, tmp, SIGNED, &add2_ovf);
 	      overflow |= neg1_ovf | neg2_ovf | add1_ovf | add2_ovf;
 	    }
 
 	  gcc_assert (!overflow);
 
-	  return build_int_cst_wide (rtype, result.low, result.high);
+	  return wide_int_to_tree (rtype, result);
 	}
 
     default: