]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/ira-conflicts.c
rs6000: New iterator CCEITHER
[thirdparty/gcc.git] / gcc / ira-conflicts.c
index 870162223f75a1d2de05284011982125b00d9f90..9a3e3811dbd93d98f66c757955ddad06d2cc3fe8 100644 (file)
@@ -1,5 +1,5 @@
 /* IRA conflict builder.
-   Copyright (C) 2006-2014 Free Software Foundation, Inc.
+   Copyright (C) 2006-2019 Free Software Foundation, Inc.
    Contributed by Vladimir Makarov <vmakarov@redhat.com>.
 
 This file is part of GCC.
@@ -21,21 +21,18 @@ along with GCC; see the file COPYING3.  If not see
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
-#include "tm.h"
-#include "regs.h"
+#include "backend.h"
+#include "target.h"
 #include "rtl.h"
+#include "predict.h"
+#include "memmodel.h"
 #include "tm_p.h"
-#include "target.h"
-#include "flags.h"
-#include "hard-reg-set.h"
-#include "basic-block.h"
 #include "insn-config.h"
-#include "recog.h"
-#include "diagnostic-core.h"
+#include "regs.h"
+#include "ira.h"
+#include "ira-int.h"
 #include "params.h"
-#include "df.h"
 #include "sparseset.h"
-#include "ira-int.h"
 #include "addresses.h"
 
 /* This file contains code responsible for allocno conflict creation,
@@ -60,7 +57,7 @@ static IRA_INT_TYPE **conflicts;
 \f
 /* Record a conflict between objects OBJ1 and OBJ2.  If necessary,
    canonicalize the conflict by recording it for lower-order subobjects
-   of the corresponding allocnos. */
+   of the corresponding allocnos.  */
 static void
 record_object_conflict (ira_object_t obj1, ira_object_t obj2)
 {
@@ -170,7 +167,6 @@ build_conflict_bit_table (void)
          gcc_assert (id < ira_objects_num);
 
          aclass = ALLOCNO_CLASS (allocno);
-         sparseset_set_bit (objects_live, id);
          EXECUTE_IF_SET_IN_SPARSESET (objects_live, j)
            {
              ira_object_t live_obj = ira_object_id_map[j];
@@ -184,6 +180,7 @@ build_conflict_bit_table (void)
                  record_object_conflict (obj, live_obj);
                }
            }
+         sparseset_set_bit (objects_live, id);
        }
 
       for (r = ira_finish_point_ranges[i]; r != NULL; r = r->finish_next)
@@ -229,8 +226,11 @@ go_through_subreg (rtx x, int *offset)
   if (REGNO (reg) < FIRST_PSEUDO_REGISTER)
     *offset = subreg_regno_offset (REGNO (reg), GET_MODE (reg),
                                   SUBREG_BYTE (x), GET_MODE (x));
-  else
-    *offset = (SUBREG_BYTE (x) / REGMODE_NATURAL_SIZE (GET_MODE (x)));
+  else if (!can_div_trunc_p (SUBREG_BYTE (x),
+                            REGMODE_NATURAL_SIZE (GET_MODE (x)), offset))
+    /* Checked by validate_subreg.  We must know at compile time which
+       inner hard registers are being accessed.  */
+    gcc_unreachable ();
   return reg;
 }
 
@@ -244,13 +244,13 @@ go_through_subreg (rtx x, int *offset)
    FALSE.  */
 static bool
 process_regs_for_copy (rtx reg1, rtx reg2, bool constraint_p,
-                      rtx insn, int freq)
+                      rtx_insn *insn, int freq)
 {
   int allocno_preferenced_hard_regno, cost, index, offset1, offset2;
   bool only_regs_p;
   ira_allocno_t a;
   reg_class_t rclass, aclass;
-  enum machine_mode mode;
+  machine_mode mode;
   ira_copy_t cp;
 
   gcc_assert (REG_SUBREG_P (reg1) && REG_SUBREG_P (reg2));
@@ -289,7 +289,7 @@ process_regs_for_copy (rtx reg1, rtx reg2, bool constraint_p,
 
   if (! IN_RANGE (allocno_preferenced_hard_regno,
                  0, FIRST_PSEUDO_REGISTER - 1))
-    /* Can not be tied.  */
+    /* Cannot be tied.  */
     return false;
   rclass = REGNO_REG_CLASS (allocno_preferenced_hard_regno);
   mode = ALLOCNO_MODE (a);
@@ -300,7 +300,7 @@ process_regs_for_copy (rtx reg1, rtx reg2, bool constraint_p,
     return false;
   index = ira_class_hard_reg_index[aclass][allocno_preferenced_hard_regno];
   if (index < 0)
-    /* Can not be tied.  It is not in the allocno class.  */
+    /* Cannot be tied.  It is not in the allocno class.  */
     return false;
   ira_init_register_move_cost_if_necessary (mode);
   if (HARD_REGISTER_P (reg1))
@@ -345,7 +345,7 @@ process_reg_shuffles (rtx reg, int op_num, int freq, bool *bound_p)
          || bound_p[i])
        continue;
 
-      process_regs_for_copy (reg, another_reg, false, NULL_RTX, freq);
+      process_regs_for_copy (reg, another_reg, false, NULL, freq);
     }
 }
 
@@ -353,7 +353,7 @@ process_reg_shuffles (rtx reg, int op_num, int freq, bool *bound_p)
    it might be because INSN is a pseudo-register move or INSN is two
    operand insn.  */
 static void
-add_insn_allocno_copies (rtx insn)
+add_insn_allocno_copies (rtx_insn *insn)
 {
   rtx set, operand, dup;
   bool bound_p[MAX_RECOG_OPERANDS];
@@ -396,7 +396,7 @@ add_insn_allocno_copies (rtx insn)
                                REG_P (operand)
                                ? operand
                                : SUBREG_REG (operand)) != NULL_RTX)
-           process_regs_for_copy (operand, dup, true, NULL_RTX,
+           process_regs_for_copy (operand, dup, true, NULL,
                                   freq);
        }
     }
@@ -421,7 +421,7 @@ static void
 add_copies (ira_loop_tree_node_t loop_tree_node)
 {
   basic_block bb;
-  rtx insn;
+  rtx_insn *insn;
 
   bb = loop_tree_node->bb;
   if (bb == NULL)
@@ -633,7 +633,12 @@ print_allocno_conflicts (FILE * file, bool reg_p, ira_allocno_t a)
       ira_object_conflict_iterator oci;
 
       if (OBJECT_CONFLICT_ARRAY (obj) == NULL)
-       continue;
+       {
+         fprintf (file, "\n;;     total conflict hard regs:\n");
+         fprintf (file, ";;     conflict hard regs:\n\n");
+         continue;
+       }
+
       if (n > 1)
        fprintf (file, "\n;;   subobject %d:", i);
       FOR_EACH_OBJECT_CONFLICT (obj, conflict_obj, oci)
@@ -683,6 +688,7 @@ print_conflicts (FILE *file, bool reg_p)
 
   FOR_EACH_ALLOCNO (a, ai)
     print_allocno_conflicts (file, reg_p, a);
+  putc ('\n', file);
 }
 
 /* Print information about allocno or only regno (if REG_P) conflicts
@@ -746,6 +752,7 @@ ira_build_conflicts (void)
       for (i = 0; i < n; i++)
        {
          ira_object_t obj = ALLOCNO_OBJECT (a, i);
+         machine_mode obj_mode = obj->allocno->mode;
          rtx allocno_reg = regno_reg_rtx [ALLOCNO_REGNO (a)];
 
          if ((! flag_caller_saves && ALLOCNO_CALLS_CROSSED_NUM (a) != 0)
@@ -774,6 +781,31 @@ ira_build_conflicts (void)
                                temp_hard_reg_set);
            }
 
+         /* Now we deal with paradoxical subreg cases where certain registers
+            cannot be accessed in the widest mode.  */
+         machine_mode outer_mode = ALLOCNO_WMODE (a);
+         machine_mode inner_mode = ALLOCNO_MODE (a);
+         if (paradoxical_subreg_p (outer_mode, inner_mode))
+           {
+             enum reg_class aclass = ALLOCNO_CLASS (a);
+             for (int j = ira_class_hard_regs_num[aclass] - 1; j >= 0; --j)
+               {
+                  int inner_regno = ira_class_hard_regs[aclass][j];
+                  int outer_regno = simplify_subreg_regno (inner_regno,
+                                                           inner_mode, 0,
+                                                           outer_mode);
+                  if (outer_regno < 0
+                      || !in_hard_reg_set_p (reg_class_contents[aclass],
+                                             outer_mode, outer_regno))
+                    {
+                      SET_HARD_REG_BIT (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj),
+                                        inner_regno);
+                      SET_HARD_REG_BIT (OBJECT_CONFLICT_HARD_REGS (obj),
+                                        inner_regno);
+                    }
+               }
+           }
+
          if (ALLOCNO_CALLS_CROSSED_NUM (a) != 0)
            {
              int regno;
@@ -782,8 +814,8 @@ ira_build_conflicts (void)
                 regs must conflict with them.  */
              for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
                if (!TEST_HARD_REG_BIT (call_used_reg_set, regno)
-                   && HARD_REGNO_CALL_PART_CLOBBERED (regno,
-                                                      obj->allocno->mode))
+                   && targetm.hard_regno_call_part_clobbered (NULL, regno,
+                                                              obj_mode))
                  {
                    SET_HARD_REG_BIT (OBJECT_CONFLICT_HARD_REGS (obj), regno);
                    SET_HARD_REG_BIT (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj),