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 java front end.

Ok?

java:
        * boehm.c: Include wide-int.h.
        (mark_reference_fields): Use a wide_int mask.
        (get_boehm_type_descriptor): Use wide-int interfaces.
        * expr.c: Include wide-int.h.
        (build_newarray): Remove bogus "== INTEGER_CST".
        (expand_java_pushc): Use real_from_integer.
        (build_field_ref): Use INT_CST_LT instead of INT_CST_LT_UNSIGNED.
        * jcf-parse.c: Include wide-int.h.
        (get_constant): Use wide-int interfaces.


diff --git a/gcc/java/boehm.c b/gcc/java/boehm.c
index 5910f03..d8ed239 100644
--- a/gcc/java/boehm.c
+++ b/gcc/java/boehm.c
@@ -32,8 +32,9 @@ The Free Software Foundation is independent of Sun 
Microsystems, Inc.  */
 #include "java-tree.h"
 #include "parse.h"
 #include "diagnostic-core.h"
+#include "wide-int.h"
 
-static void mark_reference_fields (tree, double_int *, unsigned int,
+static void mark_reference_fields (tree, wide_int *, unsigned int,
                                   int *, int *, int *, HOST_WIDE_INT *);
 
 /* A procedure-based object descriptor.  We know that our
@@ -47,7 +48,7 @@ static void mark_reference_fields (tree, double_int *, 
unsigned int,
 /* Recursively mark reference fields.  */
 static void
 mark_reference_fields (tree field,
-                      double_int *mask,
+                      wide_int *mask,
                       unsigned int ubit,
                       int *pointer_after_end,
                       int *all_bits_set,
@@ -107,7 +108,7 @@ mark_reference_fields (tree field,
             bits for all words in the record. This is conservative, but the 
             size_words != 1 case is impossible in regular java code. */
          for (i = 0; i < size_words; ++i)
-           *mask = (*mask).set_bit (ubit - count - i - 1);
+           *mask = wi::set_bit (*mask, ubit - count - i - 1);
 
          if (count >= ubit - 2)
            *pointer_after_end = 1;
@@ -136,16 +137,15 @@ get_boehm_type_descriptor (tree type)
   int last_set_index = 0;
   HOST_WIDE_INT last_view_index = -1;
   int pointer_after_end = 0;
-  double_int mask;
   tree field, value, value_type;
 
-  mask = double_int_zero;
-
   /* If the GC wasn't requested, just use a null pointer.  */
   if (! flag_use_boehm_gc)
     return null_pointer_node;
 
   value_type = java_type_for_mode (ptr_mode, 1);
+  wide_int mask = wi::zero (TYPE_PRECISION (value_type));
+
   /* If we have a type of unknown size, use a proc.  */
   if (int_size_in_bytes (type) == -1)
     goto procedure_object_descriptor;
@@ -194,22 +194,22 @@ get_boehm_type_descriptor (tree type)
          that we don't have to emit reflection data for run time
          marking. */
       count = 0;
-      mask = double_int_zero;
+      mask = wi::zero (TYPE_PRECISION (value_type));
       ++last_set_index;
       while (last_set_index)
        {
          if ((last_set_index & 1))
-           mask = mask.set_bit (log2_size + count);
+           mask = wi::set_bit (mask, log2_size + count);
          last_set_index >>= 1;
          ++count;
        }
-      value = double_int_to_tree (value_type, mask);
+      value = wide_int_to_tree (value_type, mask);
     }
   else if (! pointer_after_end)
     {
       /* Bottom two bits for bitmap mark type are 01.  */
-      mask = mask.set_bit (0);
-      value = double_int_to_tree (value_type, mask);
+      mask = wi::set_bit (mask, 0);
+      value = wide_int_to_tree (value_type, mask);
     }
   else
     {
diff --git a/gcc/java/expr.c b/gcc/java/expr.c
index c62d66d..7ae852f 100644
--- a/gcc/java/expr.c
+++ b/gcc/java/expr.c
@@ -46,6 +46,7 @@ The Free Software Foundation is independent of Sun 
Microsystems, Inc.  */
 #include "ggc.h"
 #include "tree-iterator.h"
 #include "target.h"
+#include "wide-int.h"
 
 static void flush_quick_stack (void);
 static void push_value (tree);
@@ -1051,7 +1052,7 @@ build_newarray (int atype_value, tree length)
   tree prim_type = decode_newarray_type (atype_value);
   tree type
     = build_java_array_type (prim_type,
-                            tree_fits_shwi_p (length) == INTEGER_CST
+                            tree_fits_shwi_p (length)
                             ? tree_to_shwi (length) : -1);
 
   /* Pass a reference to the primitive type class and save the runtime
@@ -1260,7 +1261,7 @@ expand_java_pushc (int ival, tree type)
   else if (type == float_type_node || type == double_type_node)
     {
       REAL_VALUE_TYPE x;
-      REAL_VALUE_FROM_INT (x, ival, 0, TYPE_MODE (type));
+      real_from_integer (&x, TYPE_MODE (type), ival, SIGNED);
       value = build_real (type, x);
     }
   else
@@ -1717,7 +1718,7 @@ build_field_ref (tree self_value, tree self_class, tree 
name)
          tree field_offset = byte_position (field_decl);
          if (! page_size)
            page_size = size_int (4096);              
-         check = ! INT_CST_LT_UNSIGNED (field_offset, page_size);
+         check = ! INT_CST_LT (field_offset, page_size);
        }
 
       if (base_type != TREE_TYPE (self_value))
diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c
index 9799523..fbd332c 100644
--- a/gcc/java/jcf-parse.c
+++ b/gcc/java/jcf-parse.c
@@ -41,6 +41,7 @@ The Free Software Foundation is independent of Sun 
Microsystems, Inc.  */
 #include "cgraph.h"
 #include "bitmap.h"
 #include "target.h"
+#include "wide-int.h"
 
 #ifdef HAVE_LOCALE_H
 #include <locale.h>
@@ -1040,14 +1041,13 @@ get_constant (JCF *jcf, int index)
     case CONSTANT_Long:
       {
        unsigned HOST_WIDE_INT num;
-       double_int val;
 
        num = JPOOL_UINT (jcf, index);
-       val = double_int::from_uhwi (num).llshift (32, 64);
+       wide_int val = wi::lshift (wide_int::from (num, 64, SIGNED), 32);
        num = JPOOL_UINT (jcf, index + 1);
-       val |= double_int::from_uhwi (num);
+       val |= num;
 
-       value = double_int_to_tree (long_type_node, val);
+       value = wide_int_to_tree (long_type_node, val);
        break;
       }
 

Reply via email to