Hello,

For my delay-slot filler, I need to be able to see if a ref is in
CALL_INSN_FUNCTION_USAGE to see if a REG is a valid candidate to fill
a CALL_INSN delay slot. If a ref is a real use in the pattern of the
call insn then the insn can't be delayed, but if it's only a use in
CALL_INSN_FUNCTION_USAGE then it can be safely delayed.

To see if a ref comes from CALL_INSN_FUNCTION_USAGE is much harder,
you have to walk the whole list to find the location, or scan the call
insn pattern to make sure the USE or CLOBBER of the ref location does
not appear there. To make this task a lot easier, this patch marks
refs in CALL_INSN_FUNCTION_USAGE with a new ref flag
DF_REF_CALL_FUNCTION_USAGE.

DF_REF_SUBREG is almost unused and it's easy enough to see if a ref is
to a REG in a SUBREG by looking at the code of the ref location. So I
removed DF_REF_SUBREG and hi-jacked its bit for
DF_REF_CALL_FUNCTION_USAGE.

Bootstrapped&tested on powerpc64-unknown-linux-gnu unix{,-m32).
OK for trunk?

Ciao!
Steven
        * ira.c (build_insn_chain): Look at the rtx code of the use to see
        if it is a subreg.
        * df.h (enum df_ref_flags): Remove DF_REF_SUBREG.
        Add DF_REF_CALL_FUNCTION_USAGE.
        * df-scan.c (df_def_record_1): Do not pass DF_REF_SUBREG.
        (df_uses_record): Likewise.
        (df_get_call_refs): Pass DF_REF_CALL_FUNCTION_USAGE for refs found
        in the CALL_INSN_FUNCTION_USAGE of a call insn.

Index: ira.c
===================================================================
--- ira.c       (revision 198639)
+++ ira.c       (working copy)
@@ -3673,7 +3673,7 @@ build_insn_chain (void)
                       fabricated use. */
                    if (DF_REF_FLAGS_IS_SET (use, DF_REF_READ_WRITE)
                        && !DF_REF_FLAGS_IS_SET (use, DF_REF_ZERO_EXTRACT)
-                       && DF_REF_FLAGS_IS_SET (use, DF_REF_SUBREG))
+                       && GET_CODE (DF_REF_REG (use)) == SUBREG)
                      continue;
 
                    /* Add the last use of each var to dead_or_set.  */
Index: df.h
===================================================================
--- df.h        (revision 198639)
+++ df.h        (working copy)
@@ -136,10 +136,10 @@ enum df_ref_flags
     /* This flag is set if the ref contains a STRICT_LOW_PART.  */
     DF_REF_STRICT_LOW_PART = 1 << 10,
 
-    /* This flag is set if the ref contains a SUBREG.  */
-    DF_REF_SUBREG = 1 << 11,
+    /* This flag is set if this ref is in the CALL_INSN_FUNCTION_USAGE
+       chain of a CALL_INSN.  It may be overloaded for other insn types.  */
+    DF_REF_CALL_FUNCTION_USAGE = 1 << 11,
 
-
     /* This bit is true if this ref is part of a multiword hardreg.  */
     DF_REF_MW_HARDREG = 1 << 12,
 
Index: df-scan.c
===================================================================
--- df-scan.c   (revision 198639)
+++ df-scan.c   (working copy)
@@ -2991,9 +2991,6 @@ df_def_record_1 (struct df_collection_rec *collect
     {
       if (df_read_modify_subreg_p (dst))
        flags |= DF_REF_READ_WRITE | DF_REF_PARTIAL;
-
-      flags |= DF_REF_SUBREG;
-
       df_ref_record (DF_REF_REGULAR, collection_rec,
                     dst, loc, bb, insn_info, DF_REF_REG_DEF, flags);
     }
@@ -3207,7 +3204,7 @@ df_uses_record (struct df_collection_rec *collecti
                {
                  df_uses_record (collection_rec, &SUBREG_REG (dst),
                                  DF_REF_REG_USE, bb, insn_info,
-                                 flags | DF_REF_READ_WRITE | DF_REF_SUBREG);
+                                 flags | DF_REF_READ_WRITE);
                  break;
                }
              /* Fall through.  */
@@ -3443,7 +3440,8 @@ df_get_call_refs (struct df_collection_rec *collec
     {
       if (GET_CODE (XEXP (note, 0)) == USE)
         df_uses_record (collection_rec, &XEXP (XEXP (note, 0), 0),
-                       DF_REF_REG_USE, bb, insn_info, flags);
+                       DF_REF_REG_USE, bb, insn_info,
+                       flags | DF_REF_CALL_FUNCTION_USAGE);
       else if (GET_CODE (XEXP (note, 0)) == CLOBBER)
        {
          if (REG_P (XEXP (XEXP (note, 0), 0)))
@@ -3451,11 +3449,12 @@ df_get_call_refs (struct df_collection_rec *collec
              unsigned int regno = REGNO (XEXP (XEXP (note, 0), 0));
              if (!TEST_HARD_REG_BIT (defs_generated, regno))
                df_defs_record (collection_rec, XEXP (note, 0), bb,
-                               insn_info, flags);
+                               insn_info, flags | DF_REF_CALL_FUNCTION_USAGE);
            }
          else
            df_uses_record (collection_rec, &XEXP (note, 0),
-                           DF_REF_REG_USE, bb, insn_info, flags);
+                           DF_REF_REG_USE, bb, insn_info,
+                           flags | DF_REF_CALL_FUNCTION_USAGE);
        }
     }
 

Reply via email to