i386.c (classify_argument): Properly handle base types.
authorJan Hubicka <jh@suse.cz>
Fri, 31 May 2002 11:54:11 +0000 (13:54 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Fri, 31 May 2002 11:54:11 +0000 (11:54 +0000)
* i386.c (classify_argument): Properly handle base types.

* dwarf2out.c (expand_builin_init_dwarf_reg_sizes):
Store first DWARF_FRAME_REGISTERS dwarf registers, not pseudo
registers.

From-SVN: r54106

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/dwarf2out.c

index 77386f33af3d5382a1d502e4bb362ce65b6a58dc..4a0d837cac6fc3b3e1eb8eeeaad747e9d3088e17 100644 (file)
@@ -1,3 +1,11 @@
+Fri May 31 13:50:19 CEST 2002  Jan Hubicka  <jh@suse.cz>
+
+       * i386.c (classify_argument): Properly handle base types.
+
+       * dwarf2out.c (expand_builin_init_dwarf_reg_sizes):
+       Store first DWARF_FRAME_REGISTERS dwarf registers, not pseudo
+       registers.
+
 Fri May 31 13:37:54 CEST 2002  Jan Hubicka  <jh@suse.cz>
 
        * gcse.c (gcse_emit_move_after): New.
index 3486046c3ddfd4e0ada569aa82528b3ddf6e4564..d512646fdc52a5f497b315e175dab4bdf685e017 100644 (file)
@@ -1721,6 +1721,34 @@ classify_argument (mode, type, classes, bit_offset)
       /* Classify each field of record and merge classes.  */
       if (TREE_CODE (type) == RECORD_TYPE)
        {
+         /* For classes first merge in the field of the subclasses.  */
+         if (TYPE_BINFO (type) != NULL && TYPE_BINFO_BASETYPES (type) != NULL)
+           {
+             tree bases = TYPE_BINFO_BASETYPES (type);
+             int n_bases = TREE_VEC_LENGTH (bases);
+             int i;
+
+             for (i = 0; i < n_bases; ++i)
+               {
+                  tree binfo = TREE_VEC_ELT (bases, i);
+                  int num;
+                  int offset = tree_low_cst (BINFO_OFFSET (binfo), 0) * 8;
+                  tree type = BINFO_TYPE (binfo);
+
+                  num = classify_argument (TYPE_MODE (type),
+                                           type, subclasses,
+                                           (offset + bit_offset) % 256);
+                  if (!num)
+                    return 0;
+                  for (i = 0; i < num; i++)
+                    {
+                      int pos = (offset + bit_offset) / 8 / 8;
+                      classes[i + pos] =
+                        merge_classes (subclasses[i], classes[i + pos]);
+                    }
+               }
+           }
+         /* And now merge the fields of structure.   */
          for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
            {
              if (TREE_CODE (field) == FIELD_DECL)
@@ -1781,6 +1809,33 @@ classify_argument (mode, type, classes, bit_offset)
       else if (TREE_CODE (type) == UNION_TYPE
               || TREE_CODE (type) == QUAL_UNION_TYPE)
        {
+         /* For classes first merge in the field of the subclasses.  */
+         if (TYPE_BINFO (type) != NULL && TYPE_BINFO_BASETYPES (type) != NULL)
+           {
+             tree bases = TYPE_BINFO_BASETYPES (type);
+             int n_bases = TREE_VEC_LENGTH (bases);
+             int i;
+
+             for (i = 0; i < n_bases; ++i)
+               {
+                  tree binfo = TREE_VEC_ELT (bases, i);
+                  int num;
+                  int offset = tree_low_cst (BINFO_OFFSET (binfo), 0) * 8;
+                  tree type = BINFO_TYPE (binfo);
+
+                  num = classify_argument (TYPE_MODE (type),
+                                           type, subclasses,
+                                           (offset + bit_offset) % 256);
+                  if (!num)
+                    return 0;
+                  for (i = 0; i < num; i++)
+                    {
+                      int pos = (offset + bit_offset) / 8 / 8;
+                      classes[i + pos] =
+                        merge_classes (subclasses[i], classes[i + pos]);
+                    }
+               }
+           }
          for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
            {
              if (TREE_CODE (field) == FIELD_DECL)
@@ -2213,11 +2268,11 @@ function_arg (cum, mode, type, named)
   if (TARGET_DEBUG_ARG)
     {
       fprintf (stderr,
-              "function_arg (size=%d, wds=%2d, nregs=%d, mode=%4s, named=%d",
+              "function_arg (size=%d, wds=%2d, nregs=%d, mode=%4s, named=%d",
               words, cum->words, cum->nregs, GET_MODE_NAME (mode), named);
 
       if (ret)
-       fprintf (stderr, ", reg=%%e%s", reg_names[ REGNO (ret) ]);
+       print_simple_rtl (stderr, ret);
       else
        fprintf (stderr, ", stack");
 
index 07295229a11756f4eacbcbca8bf4fa6a774d29bf..f4b0ee7ff5d93b3e4bcbe08eebaa645969a2a81e 100644 (file)
@@ -420,16 +420,17 @@ expand_builtin_init_dwarf_reg_sizes (address)
   rtx addr = expand_expr (address, NULL_RTX, VOIDmode, 0);
   rtx mem = gen_rtx_MEM (BLKmode, addr);
 
-  for (i = 0; i < DWARF_FRAME_REGISTERS; i++)
-    {
-      HOST_WIDE_INT offset = DWARF_FRAME_REGNUM (i) * GET_MODE_SIZE (mode);
-      HOST_WIDE_INT size = GET_MODE_SIZE (reg_raw_mode[i]);
+  for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
+    if (DWARF_FRAME_REGNUM (i) < DWARF_FRAME_REGISTERS)
+      {
+       HOST_WIDE_INT offset = DWARF_FRAME_REGNUM (i) * GET_MODE_SIZE (mode);
+       HOST_WIDE_INT size = GET_MODE_SIZE (reg_raw_mode[i]);
 
-      if (offset < 0)
-       continue;
+       if (offset < 0)
+         continue;
 
-      emit_move_insn (adjust_address (mem, mode, offset), GEN_INT (size));
-    }
+       emit_move_insn (adjust_address (mem, mode, offset), GEN_INT (size));
+      }
 }
 
 /* Convert a DWARF call frame info. operation to its string name */