OSDN Git Service

* config/mn10300/mn10300.c (TARGET_ASM_OUTPUT_MI_THUNK): Define.
[pf3gnuchains/gcc-fork.git] / gcc / ipa-struct-reorg.c
index 0cb7ccc..bef303e 100644 (file)
@@ -248,6 +248,32 @@ finalize_stmt_and_append (gimple_seq *stmts, gimple stmt)
   finalize_stmt (stmt);
 }
 
+/* This function returns true if two fields FIELD1 and FIELD2 are 
+   semantically equal, and false otherwise.  */
+
+static bool
+compare_fields (tree field1, tree field2)
+{
+  if (DECL_NAME (field1) && DECL_NAME (field2))
+    {
+      const char *name1 = IDENTIFIER_POINTER (DECL_NAME (field1));
+      const char *name2 = IDENTIFIER_POINTER (DECL_NAME (field2));
+
+      gcc_assert (name1 && name2);
+
+      if (strcmp (name1, name2))
+       return false;
+       
+    }
+  else if (DECL_NAME (field1) || DECL_NAME (field2))
+    return false;
+
+  if (!is_equal_types (TREE_TYPE (field1), TREE_TYPE (field2)))
+    return false;
+
+  return true;
+}
+
 /* Given structure type SRT_TYPE and field FIELD,
    this function is looking for a field with the same name
    and type as FIELD in STR_TYPE. It returns it if found,
@@ -264,24 +290,12 @@ find_field_in_struct_1 (tree str_type, tree field)
   for (str_field = TYPE_FIELDS (str_type); str_field;
        str_field = TREE_CHAIN (str_field))
     {
-      const char *str_field_name;
-      const char *field_name;
 
       if (!DECL_NAME (str_field))
        continue;
 
-      str_field_name = IDENTIFIER_POINTER (DECL_NAME (str_field));
-      field_name = IDENTIFIER_POINTER (DECL_NAME (field));
-
-      gcc_assert (str_field_name);
-      gcc_assert (field_name);
-
-      if (!strcmp (str_field_name, field_name))
-       {
-         /* Check field types.  */
-         if (is_equal_types (TREE_TYPE (str_field), TREE_TYPE (field)))
-           return str_field;
-       }
+      if (compare_fields (field, str_field))
+       return str_field;
     }
 
   return NULL_TREE;
@@ -569,7 +583,7 @@ static new_var
 is_in_new_vars_htab (tree decl, htab_t new_vars_htab)
 {
   return (new_var) htab_find_with_hash (new_vars_htab, decl,
-                                       htab_hash_pointer (decl));
+                                       DECL_UID (decl));
 }
 
 /* Given original variable ORIG_VAR, this function returns
@@ -1596,11 +1610,8 @@ is_equal_types (tree type1, tree type2)
   name1 = get_type_name (type1);
   name2 = get_type_name (type2);
 
-  if (name1 && name2 && !strcmp (name1, name2))
-    return true;
-
-  if (name1 && name2 && strcmp (name1, name2))
-    return false;
+  if (name1 && name2)
+    return strcmp (name1, name2) == 0;
 
   switch (TREE_CODE (type1))
     {
@@ -1616,16 +1627,20 @@ is_equal_types (tree type1, tree type2)
     case QUAL_UNION_TYPE:
     case ENUMERAL_TYPE:
       {
-       tree field1;
+       tree field1, field2;
+
        /* Compare fields of structure.  */
-       for (field1 = TYPE_FIELDS (type1); field1;
-            field1 = TREE_CHAIN (field1))
+       for (field1 = TYPE_FIELDS (type1), field2 = TYPE_FIELDS (type2);
+            field1 && field2;
+            field1 = TREE_CHAIN (field1), field2 = TREE_CHAIN (field2))
          {
-           tree field2 = find_field_in_struct_1 (type2, field1);
-           if (!field2)
+           if (!compare_fields (field1, field2))
              return false;
          }
-       return true;
+       if (field1 || field2)
+         return false;
+       else
+         return true;
       }
       break;
 
@@ -1962,7 +1977,7 @@ add_to_new_vars_htab (new_var new_node, htab_t new_vars_htab)
   void **slot;
 
   slot = htab_find_slot_with_hash (new_vars_htab, new_node->orig_var,
-                                  htab_hash_pointer (new_node->orig_var),
+                                  DECL_UID (new_node->orig_var),
                                   INSERT);
   *slot = new_node;
 }
@@ -2254,15 +2269,19 @@ create_new_var (tree var_decl, htab_t new_vars_htab)
 static hashval_t
 new_var_hash (const void *x)
 {
-  return htab_hash_pointer (((const_new_var)x)->orig_var);
+  return DECL_UID (((const_new_var)x)->orig_var);
 }
 
-/* This function returns nonzero if orig_var of new_var X is equal to Y.  */
+/* This function returns nonzero if orig_var of new_var X 
+   and tree Y have equal UIDs.  */
 
 static int
 new_var_eq (const void *x, const void *y)
 {
-  return ((const_new_var)x)->orig_var == (const_tree)y;
+  if (DECL_P ((const_tree)y))
+    return DECL_UID (((const_new_var)x)->orig_var) == DECL_UID ((const_tree)y);
+  else
+    return 0;
 }
 
 /* This function check whether a structure type represented by STR