gcc/
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 26 Jun 2015 10:06:56 +0000 (10:06 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 26 Jun 2015 10:06:56 +0000 (10:06 +0000)
* rtl.h (emit): Add an optional boolean parameter to control
whether barriers are emitted.
* emit-rtl.c (emit): Likewise.
* gensupport.c (get_emit_function): Return null rather than "emit".
* genemit.c (gen_emit_seq): Handle the null return value.
Don't emit barriers after the final instruction in the sequence.
* gentarget-def.c (main): Don't emit barriers after the instruction.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@225000 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/emit-rtl.c
gcc/genemit.c
gcc/gensupport.c
gcc/gentarget-def.c
gcc/rtl.h

index ecc209f..bd9abfc 100644 (file)
@@ -1,3 +1,13 @@
+2015-06-26  Richard Sandiford  <richard.sandiford@arm.com>
+
+       * rtl.h (emit): Add an optional boolean parameter to control
+       whether barriers are emitted.
+       * emit-rtl.c (emit): Likewise.
+       * gensupport.c (get_emit_function): Return null rather than "emit".
+       * genemit.c (gen_emit_seq): Handle the null return value.
+       Don't emit barriers after the final instruction in the sequence.
+       * gentarget-def.c (main): Don't emit barriers after the instruction.
+
 2015-06-26  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
 
        * config/arm/arm.c (arm_output_multireg_pop): Fix use of
index e7f7eab..80c0adb 100644 (file)
@@ -5303,11 +5303,14 @@ set_dst_reg_note (rtx insn, enum reg_note kind, rtx datum, rtx dst)
   return NULL_RTX;
 }
 \f
-/* Emit the rtl pattern X as an appropriate kind of insn.
+/* Emit the rtl pattern X as an appropriate kind of insn.  Also emit a
+   following barrier if the instruction needs one and if ALLOW_BARRIER_P
+   is true.
+
    If X is a label, it is simply added into the insn chain.  */
 
 rtx_insn *
-emit (rtx x)
+emit (rtx x, bool allow_barrier_p)
 {
   enum rtx_code code = classify_insn (x);
 
@@ -5320,7 +5323,8 @@ emit (rtx x)
     case  JUMP_INSN:
       {
        rtx_insn *insn = emit_jump_insn (x);
-       if (any_uncondjump_p (insn) || GET_CODE (x) == RETURN)
+       if (allow_barrier_p
+           && (any_uncondjump_p (insn) || GET_CODE (x) == RETURN))
          return emit_barrier ();
        return insn;
       }
index 15ec081..4ee07a0 100644 (file)
@@ -277,12 +277,22 @@ gen_emit_seq (rtvec vec, char *used)
 {
   for (int i = 0, len = GET_NUM_ELEM (vec); i < len; ++i)
     {
+      bool last_p = (i == len - 1);
       rtx next = RTVEC_ELT (vec, i);
-      printf ("  %s (", get_emit_function (next));
-      gen_exp (next, DEFINE_EXPAND, used);
-      printf (");\n");
-      if (needs_barrier_p (next))
-       printf ("  emit_barrier ();");
+      if (const char *name = get_emit_function (next))
+       {
+         printf ("  %s (", name);
+         gen_exp (next, DEFINE_EXPAND, used);
+         printf (");\n");
+         if (!last_p && needs_barrier_p (next))
+           printf ("  emit_barrier ();");
+       }
+      else
+       {
+         printf ("  emit (");
+         gen_exp (next, DEFINE_EXPAND, used);
+         printf (", %s);\n", last_p ? "false" : "true");
+       }
     }
 }
 \f
index 916fbc1..729366c 100644 (file)
@@ -2983,7 +2983,9 @@ get_pattern_stats (struct pattern_stats *stats, rtvec pattern)
                                       stats->max_scratch_opno)) + 1;
 }
 
-/* Return the emit_* function that should be used for pattern X.  */
+/* Return the emit_* function that should be used for pattern X, or NULL
+   if we can't pick a particular type at compile time and should instead
+   fall back to "emit".  */
 
 const char *
 get_emit_function (rtx x)
@@ -3000,7 +3002,7 @@ get_emit_function (rtx x)
       return "emit_jump_insn";
 
     case UNKNOWN:
-      return "emit";
+      return NULL;
 
     default:
       gcc_unreachable ();
index bca9480..c1125dd 100644 (file)
@@ -245,7 +245,7 @@ main (int argc, char **argv)
   printf ("  if (rtx_insn *insn = dyn_cast <rtx_insn *> (x))\n");
   printf ("    return insn;\n");
   printf ("  start_sequence ();\n");
-  printf ("  emit (x);\n");
+  printf ("  emit (x, false);\n");
   printf ("  rtx_insn *res = get_insns ();\n");
   printf ("  end_sequence ();\n");
   printf ("  return res;\n");
index 37ec7d4..d74c20f 100644 (file)
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -3494,7 +3494,7 @@ extern void add_insn (rtx_insn *);
 extern void add_insn_before (rtx, rtx, basic_block);
 extern void add_insn_after (rtx, rtx, basic_block);
 extern void remove_insn (rtx);
-extern rtx_insn *emit (rtx);
+extern rtx_insn *emit (rtx, bool = true);
 extern void emit_insn_at_entry (rtx);
 extern rtx gen_lowpart_SUBREG (machine_mode, rtx);
 extern rtx gen_const_mem (machine_mode, rtx);