public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 00/12] Eliminate the text-based dwarf2out interface
@ 2011-06-29 21:50 Richard Henderson
  2011-06-29 21:50 ` [PATCH 05/12] arm: Use REG_CFA_REGISTER instead of UNSPEC_STACK_ALIGN Richard Henderson
                   ` (12 more replies)
  0 siblings, 13 replies; 19+ messages in thread
From: Richard Henderson @ 2011-06-29 21:50 UTC (permalink / raw)
  To: gcc-patches; +Cc: richard.earnshaw, sje, ubizjak, matt

In preparation for the changes required to support shrink-wrapping,
it makes things Much Easier if we no longer have to handle seeing
new unwind states being introduced during pass_final, while emitting
the actual assembly.  Thus we want to convert everything that used
the text-based interfaces to use the REG_CFA_* notes instead.

The following set has been tested on i386-linux, x86_64-linux,
ia64-linux, arm-elf, arm-eabi, and a cross-compile to vax-linux.


r~


Richard Henderson (12):
  dwarf2out: Convert regs_saved_in_regs to VEC.
  dwarf2out: Handle pc_rtx as return column in REG_CFA_OFFSET too.
  dwarf2out: Add REG_CFA_FLUSH_QUEUE.
  vax: Emit prologue as rtl.
  arm: Use REG_CFA_REGISTER instead of UNSPEC_STACK_ALIGN.
  ia64: Issue REG_CFA_REGISTER for ar.pfs at alloc insn.
  ia64: Remove ia64_dwarf2out_def_steady_cfa.
  ia64: Use pc_rtx to save the return address.
  ia64: Remove dead code in process_epilogue.
  ia64: Remove TARGET_DWARF_HANDLE_FRAME_UNSPEC hook.
  i386: Always use TARGET_DEEP_BRANCH_PREDICTION.
  dwarf2out: Remove unused text-based unwind entry points.

 gcc/config/arm/arm.c        |  114 ++++++++++++----------
 gcc/config/arm/arm.md       |    2 -
 gcc/config/i386/i386.c      |  105 +++----------------
 gcc/config/i386/i386.h      |    3 -
 gcc/config/ia64/ia64.c      |  108 ++++++---------------
 gcc/config/vax/vax-protos.h |    1 +
 gcc/config/vax/vax.c        |   86 ++++++++++++-----
 gcc/config/vax/vax.md       |   25 ++++-
 gcc/dwarf2out.c             |  233 ++++++++++++++++++++-----------------------
 gcc/final.c                 |    4 +-
 gcc/reg-notes.def           |   11 ++-
 gcc/tree.h                  |   27 -----
 12 files changed, 313 insertions(+), 406 deletions(-)

-- 
1.7.5.4

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 10/12] ia64: Remove TARGET_DWARF_HANDLE_FRAME_UNSPEC hook.
  2011-06-29 21:50 [PATCH 00/12] Eliminate the text-based dwarf2out interface Richard Henderson
  2011-06-29 21:50 ` [PATCH 05/12] arm: Use REG_CFA_REGISTER instead of UNSPEC_STACK_ALIGN Richard Henderson
  2011-06-29 21:50 ` [PATCH 07/12] ia64: Remove ia64_dwarf2out_def_steady_cfa Richard Henderson
@ 2011-06-29 21:50 ` Richard Henderson
  2011-06-29 21:50 ` [PATCH 12/12] dwarf2out: Remove unused text-based unwind entry points Richard Henderson
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Richard Henderson @ 2011-06-29 21:50 UTC (permalink / raw)
  To: gcc-patches; +Cc: richard.earnshaw, sje, ubizjak, matt

Use an empty REG_FRAME_RELATED_EXPR instead.
---
 gcc/config/ia64/ia64.c |   23 +++++++++--------------
 1 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
index bdabe82..2ebb225 100644
--- a/gcc/config/ia64/ia64.c
+++ b/gcc/config/ia64/ia64.c
@@ -319,7 +319,6 @@ static enum machine_mode ia64_promote_function_mode (const_tree,
 static void ia64_trampoline_init (rtx, tree, rtx);
 static void ia64_override_options_after_change (void);
 
-static void ia64_dwarf_handle_frame_unspec (const char *, rtx, int);
 static tree ia64_builtin_decl (unsigned, bool);
 
 static reg_class_t ia64_preferred_reload_class (rtx, reg_class_t);
@@ -551,8 +550,6 @@ static const struct attribute_spec ia64_attribute_table[] =
 #undef TARGET_GIMPLIFY_VA_ARG_EXPR
 #define TARGET_GIMPLIFY_VA_ARG_EXPR ia64_gimplify_va_arg
 
-#undef TARGET_DWARF_HANDLE_FRAME_UNSPEC
-#define TARGET_DWARF_HANDLE_FRAME_UNSPEC  ia64_dwarf_handle_frame_unspec
 #undef TARGET_ASM_UNWIND_EMIT
 #define TARGET_ASM_UNWIND_EMIT ia64_asm_unwind_emit
 #undef TARGET_ASM_EMIT_EXCEPT_PERSONALITY
@@ -3793,10 +3790,19 @@ ia64_expand_epilogue (int sibcall_p)
       if (current_frame_info.n_input_regs != 0)
 	{
 	  rtx n_inputs = GEN_INT (current_frame_info.n_input_regs);
+
 	  insn = emit_insn (gen_alloc (gen_rtx_REG (DImode, fp),
 				const0_rtx, const0_rtx,
 				n_inputs, const0_rtx));
 	  RTX_FRAME_RELATED_P (insn) = 1;
+
+	  /* ??? We need to mark the alloc as frame-related so that it gets
+	     passed into ia64_asm_unwind_emit for ia64-specific unwinding.
+	     But there's nothing dwarf2 related to be done wrt the register
+	     windows.  If we do nothing, dwarf2out will abort on the UNSPEC;
+	     the empty parallel means dwarf2out will not see anything.  */
+	  add_reg_note (insn, REG_FRAME_RELATED_EXPR,
+			gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (0)));
 	}
     }
 }
@@ -9620,17 +9626,6 @@ static bool need_copy_state;
 # define MAX_ARTIFICIAL_LABEL_BYTES 30
 #endif
 
-/* All we need to do here is avoid a crash in the generic dwarf2
-   processing.  The real CFA definition is set up above.  */
-
-static void
-ia64_dwarf_handle_frame_unspec (const char * ARG_UNUSED (label),
-				rtx ARG_UNUSED (pattern),
-				int index)
-{
-  gcc_assert (index == UNSPECV_ALLOC);
-}
-
 /* The function emits unwind directives for the start of an epilogue.  */
 
 static void
-- 
1.7.5.4

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 07/12] ia64: Remove ia64_dwarf2out_def_steady_cfa.
  2011-06-29 21:50 [PATCH 00/12] Eliminate the text-based dwarf2out interface Richard Henderson
  2011-06-29 21:50 ` [PATCH 05/12] arm: Use REG_CFA_REGISTER instead of UNSPEC_STACK_ALIGN Richard Henderson
@ 2011-06-29 21:50 ` Richard Henderson
  2011-06-29 21:50 ` [PATCH 10/12] ia64: Remove TARGET_DWARF_HANDLE_FRAME_UNSPEC hook Richard Henderson
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Richard Henderson @ 2011-06-29 21:50 UTC (permalink / raw)
  To: gcc-patches; +Cc: richard.earnshaw, sje, ubizjak, matt

This defines nothing that we can't deduce already,
so remove it.
---
 gcc/config/ia64/ia64.c |   24 ------------------------
 1 files changed, 0 insertions(+), 24 deletions(-)

diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
index 0a6f2e6..bb3fc4d 100644
--- a/gcc/config/ia64/ia64.c
+++ b/gcc/config/ia64/ia64.c
@@ -9642,26 +9642,6 @@ ia64_emit_deleted_label_after_insn (rtx insn)
   return xstrdup (label);
 }
 
-/* Define the CFA after INSN with the steady-state definition.  */
-
-static void
-ia64_dwarf2out_def_steady_cfa (rtx insn, bool frame)
-{
-  rtx fp = frame_pointer_needed
-    ? hard_frame_pointer_rtx
-    : stack_pointer_rtx;
-  const char *label = ia64_emit_deleted_label_after_insn (insn);
-
-  if (!frame)
-    return;
-
-  dwarf2out_def_cfa
-    (label, REGNO (fp),
-     ia64_initial_elimination_offset
-     (REGNO (arg_pointer_rtx), REGNO (fp))
-     + ARG_POINTER_CFA_OFFSET (current_function_decl));
-}
-
 /* All we need to do here is avoid a crash in the generic dwarf2
    processing.  The real CFA definition is set up above.  */
 
@@ -9727,7 +9707,6 @@ process_cfa_adjust_cfa (FILE *asm_out_file, rtx pat, rtx insn,
 		fprintf (asm_out_file,
 			 "\t.fframe "HOST_WIDE_INT_PRINT_DEC"\n",
 			 -INTVAL (op1));
-	      ia64_dwarf2out_def_steady_cfa (insn, frame);
 	    }
 	  else
 	    process_epilogue (asm_out_file, insn, unwind, frame);
@@ -9746,7 +9725,6 @@ process_cfa_adjust_cfa (FILE *asm_out_file, rtx pat, rtx insn,
       if (unwind)
 	fprintf (asm_out_file, "\t.vframe r%d\n",
 		 ia64_dbx_register_number (REGNO (dest)));
-      ia64_dwarf2out_def_steady_cfa (insn, frame);
     }
   else
     gcc_unreachable ();
@@ -9946,8 +9924,6 @@ ia64_asm_unwind_emit (FILE *asm_out_file, rtx insn)
 	      fprintf (asm_out_file, "\t.copy_state %d\n",
 		       cfun->machine->state_num);
 	    }
-	  if (IA64_CHANGE_CFA_IN_EPILOGUE)
-	    ia64_dwarf2out_def_steady_cfa (insn, frame);
 	  need_copy_state = false;
 	}
     }
-- 
1.7.5.4

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 12/12] dwarf2out: Remove unused text-based unwind entry points.
  2011-06-29 21:50 [PATCH 00/12] Eliminate the text-based dwarf2out interface Richard Henderson
                   ` (2 preceding siblings ...)
  2011-06-29 21:50 ` [PATCH 10/12] ia64: Remove TARGET_DWARF_HANDLE_FRAME_UNSPEC hook Richard Henderson
@ 2011-06-29 21:50 ` Richard Henderson
  2011-06-29 21:51 ` [PATCH 09/12] ia64: Remove dead code in process_epilogue Richard Henderson
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Richard Henderson @ 2011-06-29 21:50 UTC (permalink / raw)
  To: gcc-patches; +Cc: richard.earnshaw, sje, ubizjak, matt

The dwarf2out_cfi_label function is privatized, the
dwarf2out_def_cfa function is merged into its last user.
The others really are unused.
---
 gcc/dwarf2out.c |   65 ++++++-------------------------------------------------
 gcc/tree.h      |   27 ----------------------
 2 files changed, 7 insertions(+), 85 deletions(-)

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 9cccc04..7778dc9 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -848,7 +848,7 @@ add_cfi (cfi_vec *vec, dw_cfi_ref cfi)
 /* Generate a new label for the CFI info to refer to.  FORCE is true
    if a label needs to be output even when using .cfi_* directives.  */
 
-char *
+static char *
 dwarf2out_cfi_label (bool force)
 {
   static char label[20];
@@ -1080,21 +1080,6 @@ static HOST_WIDE_INT args_size;
 /* The last args_size we actually output.  */
 static HOST_WIDE_INT old_args_size;
 
-/* Entry point to update the canonical frame address (CFA).
-   LABEL is passed to add_fde_cfi.  The value of CFA is now to be
-   calculated from REG+OFFSET.  */
-
-void
-dwarf2out_def_cfa (const char *label, unsigned int reg, HOST_WIDE_INT offset)
-{
-  dw_cfa_location loc;
-  loc.indirect = 0;
-  loc.base_offset = 0;
-  loc.reg = reg;
-  loc.offset = offset;
-  def_cfa_1 (label, &loc);
-}
-
 /* Determine if two dw_cfa_location structures define the same data.  */
 
 static bool
@@ -1232,33 +1217,6 @@ reg_save (const char *label, unsigned int reg, unsigned int sreg, HOST_WIDE_INT
   add_fde_cfi (label, cfi);
 }
 
-/* Entry point for saving a register to the stack.  REG is the GCC register
-   number.  LABEL and OFFSET are passed to reg_save.  */
-
-void
-dwarf2out_reg_save (const char *label, unsigned int reg, HOST_WIDE_INT offset)
-{
-  reg_save (label, DWARF_FRAME_REGNUM (reg), INVALID_REGNUM, offset);
-}
-
-/* Entry point for saving the return address in the stack.
-   LABEL and OFFSET are passed to reg_save.  */
-
-void
-dwarf2out_return_save (const char *label, HOST_WIDE_INT offset)
-{
-  reg_save (label, DWARF_FRAME_RETURN_COLUMN, INVALID_REGNUM, offset);
-}
-
-/* Entry point for saving the return address in a register.
-   LABEL and SREG are passed to reg_save.  */
-
-void
-dwarf2out_return_reg (const char *label, unsigned int sreg)
-{
-  reg_save (label, DWARF_FRAME_RETURN_COLUMN, DWARF_FRAME_REGNUM (sreg), 0);
-}
-
 /* Record the initial position of the return address.  RTL is
    INCOMING_RETURN_ADDR_RTX.  */
 
@@ -1866,20 +1824,6 @@ clobbers_queued_reg_save (const_rtx insn)
   return false;
 }
 
-/* Entry point for saving the first register into the second.  */
-
-void
-dwarf2out_reg_save_reg (const char *label, rtx reg, rtx sreg)
-{
-  unsigned int regno, sregno;
-
-  record_reg_saved_in_reg (sreg, reg);
-
-  regno = DWARF_FRAME_REGNUM (REGNO (reg));
-  sregno = DWARF_FRAME_REGNUM (REGNO (sreg));
-  reg_save (label, regno, sregno, 0);
-}
-
 /* What register, if any, is currently saved in REG?  */
 
 static rtx
@@ -4273,6 +4217,8 @@ dwarf2out_end_epilogue (unsigned int line ATTRIBUTE_UNUSED,
 void
 dwarf2out_frame_init (void)
 {
+  dw_cfa_location loc;
+
   /* Allocate the initial hunk of the fde_table.  */
   fde_table = ggc_alloc_cleared_vec_dw_fde_node (FDE_TABLE_INCREMENT);
   fde_table_allocated = FDE_TABLE_INCREMENT;
@@ -4282,7 +4228,10 @@ dwarf2out_frame_init (void)
      sake of lookup_cfa.  */
 
   /* On entry, the Canonical Frame Address is at SP.  */
-  dwarf2out_def_cfa (NULL, STACK_POINTER_REGNUM, INCOMING_FRAME_SP_OFFSET);
+  memset(&loc, 0, sizeof (loc));
+  loc.reg = STACK_POINTER_REGNUM;
+  loc.offset = INCOMING_FRAME_SP_OFFSET;
+  def_cfa_1 (NULL, &loc);
 
   if (targetm.debug_unwind_info () == UI_DWARF2
       || targetm_common.except_unwind_info (&global_options) == UI_DWARF2)
diff --git a/gcc/tree.h b/gcc/tree.h
index 20ba295..b642953 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -5596,33 +5596,6 @@ extern tree tree_overlaps_hard_reg_set (tree, HARD_REG_SET *);
 #endif
 
 \f
-/* In dwarf2out.c */
-/* Interface of the DWARF2 unwind info support.  */
-
-/* Generate a new label for the CFI info to refer to.  */
-
-extern char *dwarf2out_cfi_label (bool);
-
-/* Entry point to update the canonical frame address (CFA).  */
-
-extern void dwarf2out_def_cfa (const char *, unsigned, HOST_WIDE_INT);
-
-/* Entry point for saving a register to the stack.  */
-
-extern void dwarf2out_reg_save (const char *, unsigned, HOST_WIDE_INT);
-
-/* Entry point for saving the return address in the stack.  */
-
-extern void dwarf2out_return_save (const char *, HOST_WIDE_INT);
-
-/* Entry point for saving the return address in a register.  */
-
-extern void dwarf2out_return_reg (const char *, unsigned);
-
-/* Entry point for saving the first register into the second.  */
-
-extern void dwarf2out_reg_save_reg (const char *, rtx, rtx);
-
 /* In tree-inline.c  */
 
 /* The type of a set of already-visited pointers.  Functions for creating
-- 
1.7.5.4

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 05/12] arm: Use REG_CFA_REGISTER instead of UNSPEC_STACK_ALIGN.
  2011-06-29 21:50 [PATCH 00/12] Eliminate the text-based dwarf2out interface Richard Henderson
@ 2011-06-29 21:50 ` Richard Henderson
  2011-06-29 21:50 ` [PATCH 07/12] ia64: Remove ia64_dwarf2out_def_steady_cfa Richard Henderson
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Richard Henderson @ 2011-06-29 21:50 UTC (permalink / raw)
  To: gcc-patches; +Cc: richard.earnshaw, sje, ubizjak, matt, Richard Henderson

From: Richard Henderson <rth@twiddle.net>

This requires a bit of extra preparation in arm_unwind_emit, in
order to handle the change for ARM unwinding.
---
 gcc/config/arm/arm.c  |  114 ++++++++++++++++++++++++++----------------------
 gcc/config/arm/arm.md |    2 -
 2 files changed, 62 insertions(+), 54 deletions(-)

diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 4c6041a..0e371f3 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -203,7 +203,6 @@ static bool arm_output_ttype (rtx);
 static void arm_asm_emit_except_personality (rtx);
 static void arm_asm_init_sections (void);
 #endif
-static void arm_dwarf_handle_frame_unspec (const char *, rtx, int);
 static rtx arm_dwarf_register_span (rtx);
 
 static tree arm_cxx_guard_type (void);
@@ -501,9 +500,6 @@ static const struct attribute_spec arm_attribute_table[] =
 #define TARGET_ASM_INIT_SECTIONS arm_asm_init_sections
 #endif /* ARM_UNWIND_INFO */
 
-#undef TARGET_DWARF_HANDLE_FRAME_UNSPEC
-#define TARGET_DWARF_HANDLE_FRAME_UNSPEC arm_dwarf_handle_frame_unspec
-
 #undef TARGET_DWARF_REGISTER_SPAN
 #define TARGET_DWARF_REGISTER_SPAN arm_dwarf_register_span
 
@@ -15830,9 +15826,8 @@ arm_expand_prologue (void)
 
   if (IS_STACKALIGN (func_type))
     {
-      rtx dwarf;
-      rtx r0;
-      rtx r1;
+      rtx r0, r1;
+
       /* Handle a word-aligned stack pointer.  We generate the following:
 
 	  mov r0, sp
@@ -15848,15 +15843,18 @@ arm_expand_prologue (void)
 
       r0 = gen_rtx_REG (SImode, 0);
       r1 = gen_rtx_REG (SImode, 1);
-      /* Use a real rtvec rather than NULL_RTVEC so the rest of the
-	 compiler won't choke.  */
-      dwarf = gen_rtx_UNSPEC (SImode, rtvec_alloc (0), UNSPEC_STACK_ALIGN);
-      dwarf = gen_rtx_SET (VOIDmode, r0, dwarf);
-      insn = gen_movsi (r0, stack_pointer_rtx);
+
+      insn = emit_insn (gen_movsi (r0, stack_pointer_rtx));
       RTX_FRAME_RELATED_P (insn) = 1;
-      add_reg_note (insn, REG_FRAME_RELATED_EXPR, dwarf);
-      emit_insn (insn);
+      add_reg_note (insn, REG_CFA_REGISTER, NULL);
+
       emit_insn (gen_andsi3 (r1, r0, GEN_INT (~(HOST_WIDE_INT)7)));
+
+      /* ??? The CFA changes here, which may cause GDB to conclude that it
+	 has entered a different function.  That said, the unwind info is
+	 correct, individually, before and after this instruction because
+	 we've described the save of SP, which will override the default
+	 handling of SP as restoring from the CFA.  */
       emit_insn (gen_movsi (stack_pointer_rtx, r1));
     }
 
@@ -22880,13 +22878,6 @@ arm_unwind_emit_set (FILE * asm_out_file, rtx p)
 	  asm_fprintf (asm_out_file, "\t.movsp %r, #%d\n",
 		       REGNO (e0), (int)INTVAL(XEXP (e1, 1)));
 	}
-      else if (GET_CODE (e1) == UNSPEC && XINT (e1, 1) == UNSPEC_STACK_ALIGN)
-	{
-	  /* Stack pointer save before alignment.  */
-	  reg = REGNO (e0);
-	  asm_fprintf (asm_out_file, "\t.unwind_raw 0, 0x%x @ vsp = r%d\n",
-		       reg + 0x90, reg);
-	}
       else
 	abort ();
       break;
@@ -22902,7 +22893,8 @@ arm_unwind_emit_set (FILE * asm_out_file, rtx p)
 static void
 arm_unwind_emit (FILE * asm_out_file, rtx insn)
 {
-  rtx pat;
+  rtx note, pat;
+  bool handled_one = false;
 
   if (arm_except_unwind_info (&global_options) != UI_TARGET)
     return;
@@ -22912,14 +22904,56 @@ arm_unwind_emit (FILE * asm_out_file, rtx insn)
 	  || crtl->all_throwers_are_sibcalls))
     return;
 
-  if (GET_CODE (insn) == NOTE || !RTX_FRAME_RELATED_P (insn))
+  if (NOTE_P (insn) || !RTX_FRAME_RELATED_P (insn))
     return;
 
-  pat = find_reg_note (insn, REG_FRAME_RELATED_EXPR, NULL_RTX);
-  if (pat)
-    pat = XEXP (pat, 0);
-  else
-    pat = PATTERN (insn);
+  for (note = REG_NOTES (insn); note ; note = XEXP (note, 1))
+    {
+      pat = XEXP (note, 0);
+      switch (REG_NOTE_KIND (note))
+	{
+	case REG_FRAME_RELATED_EXPR:
+	  goto found;
+
+	case REG_CFA_REGISTER:
+	  if (pat == NULL)
+	    {
+	      pat = PATTERN (insn);
+	      if (GET_CODE (pat) == PARALLEL)
+		pat = XVECEXP (pat, 0, 0);
+	    }
+
+	  /* Only emitted for IS_STACKALIGN re-alignment.  */
+	  {
+	    rtx dest, src;
+	    unsigned reg;
+
+	    src = SET_SRC (pat);
+	    dest = SET_DEST (pat);
+
+	    gcc_assert (src == stack_pointer_rtx);
+	    reg = REGNO (dest);
+	    asm_fprintf (asm_out_file, "\t.unwind_raw 0, 0x%x @ vsp = r%d\n",
+			 reg + 0x90, reg);
+	  }
+	  handled_one = true;
+	  break;
+
+	case REG_CFA_DEF_CFA:
+	case REG_CFA_EXPRESSION:
+	case REG_CFA_ADJUST_CFA:
+	case REG_CFA_OFFSET:
+	  /* ??? Only handling here what we actually emit.  */
+	  gcc_unreachable ();
+
+	default:
+	  break;
+	}
+    }
+  if (handled_one)
+    return;
+  pat = PATTERN (insn);
+ found:
 
   switch (GET_CODE (pat))
     {
@@ -22975,30 +23009,6 @@ arm_asm_init_sections (void)
 }
 #endif /* ARM_UNWIND_INFO */
 
-/* Handle UNSPEC DWARF call frame instructions.  These are needed for dynamic
-   stack alignment.  */
-
-static void
-arm_dwarf_handle_frame_unspec (const char *label, rtx pattern, int index)
-{
-  rtx unspec = SET_SRC (pattern);
-  gcc_assert (GET_CODE (unspec) == UNSPEC);
-
-  switch (index)
-    {
-    case UNSPEC_STACK_ALIGN:
-      /* ??? We should set the CFA = (SP & ~7).  At this point we haven't
-         put anything on the stack, so hopefully it won't matter.
-         CFA = SP will be correct after alignment.  */
-      dwarf2out_reg_save_reg (label, stack_pointer_rtx,
-                              SET_DEST (pattern));
-      break;
-    default:
-      gcc_unreachable ();
-    }
-}
-
-
 /* Output unwind directives for the start/end of a function.  */
 
 void
diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md
index 2bf3551..03ae72d 100644
--- a/gcc/config/arm/arm.md
+++ b/gcc/config/arm/arm.md
@@ -94,8 +94,6 @@
   UNSPEC_TLS            ; A symbol that has been treated properly for TLS usage.
   UNSPEC_PIC_LABEL      ; A label used for PIC access that does not appear in the
                         ; instruction stream.
-  UNSPEC_STACK_ALIGN    ; Doubleword aligned stack pointer.  Used to
-                        ; generate correct unwind information.
   UNSPEC_PIC_OFFSET     ; A symbolic 12-bit OFFSET that has been treated
                         ; correctly for PIC usage.
   UNSPEC_GOTSYM_OFF     ; The offset of the start of the GOT from a
-- 
1.7.5.4

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 01/12] dwarf2out: Convert regs_saved_in_regs to VEC.
  2011-06-29 21:50 [PATCH 00/12] Eliminate the text-based dwarf2out interface Richard Henderson
                   ` (4 preceding siblings ...)
  2011-06-29 21:51 ` [PATCH 09/12] ia64: Remove dead code in process_epilogue Richard Henderson
@ 2011-06-29 21:51 ` Richard Henderson
  2011-06-29 21:51 ` [PATCH 02/12] dwarf2out: Handle pc_rtx as return column in REG_CFA_OFFSET too Richard Henderson
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Richard Henderson @ 2011-06-29 21:51 UTC (permalink / raw)
  To: gcc-patches; +Cc: richard.earnshaw, sje, ubizjak, matt

Also pull out value insertion into a subroutine.
---
 gcc/dwarf2out.c |  115 +++++++++++++++++++++++++++++++------------------------
 1 files changed, 65 insertions(+), 50 deletions(-)

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 3d63d7b..3ecdd94 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -1732,17 +1732,56 @@ struct GTY(()) queued_reg_save {
 static GTY(()) struct queued_reg_save *queued_reg_saves;
 
 /* The caller's ORIG_REG is saved in SAVED_IN_REG.  */
-struct GTY(()) reg_saved_in_data {
+typedef struct GTY(()) reg_saved_in_data {
   rtx orig_reg;
   rtx saved_in_reg;
-};
+} reg_saved_in_data;
+
+DEF_VEC_O (reg_saved_in_data);
+DEF_VEC_ALLOC_O (reg_saved_in_data, gc);
+
+/* A set of registers saved in other registers.  This is implemented as
+   a flat array because it normally contains zero or 1 entry, depending
+   on the target.  IA-64 is the big spender here, using a maximum of
+   5 entries.  */
+static GTY(()) VEC(reg_saved_in_data, gc) *regs_saved_in_regs;
 
-/* A list of registers saved in other registers.
-   The list intentionally has a small maximum capacity of 4; if your
-   port needs more than that, you might consider implementing a
-   more efficient data structure.  */
-static GTY(()) struct reg_saved_in_data regs_saved_in_regs[4];
-static GTY(()) size_t num_regs_saved_in_regs;
+/* Compare X and Y for equivalence.  The inputs may be REGs or PC_RTX.  */
+
+static bool
+compare_reg_or_pc (rtx x, rtx y)
+{
+  if (REG_P (x) && REG_P (y))
+    return REGNO (x) == REGNO (y);
+  return x == y;
+}
+
+/* Record SRC as being saved in DEST.  DEST may be null to delete an
+   existing entry.  SRC may be a register or PC_RTX.  */
+
+static void
+record_reg_saved_in_reg (rtx dest, rtx src)
+{
+  reg_saved_in_data *elt;
+  size_t i;
+
+  FOR_EACH_VEC_ELT (reg_saved_in_data, regs_saved_in_regs, i, elt)
+    if (compare_reg_or_pc (elt->orig_reg, src))
+      {
+	if (dest == NULL)
+	  VEC_unordered_remove(reg_saved_in_data, regs_saved_in_regs, i);
+	else
+	  elt->saved_in_reg = dest;
+	return;
+      }
+
+  if (dest == NULL)
+    return;
+
+  elt = VEC_safe_push(reg_saved_in_data, gc, regs_saved_in_regs, NULL);
+  elt->orig_reg = src;
+  elt->saved_in_reg = dest;
+}
 
 static const char *last_reg_save_label;
 
@@ -1784,22 +1823,9 @@ dwarf2out_flush_queued_reg_saves (void)
 
   for (q = queued_reg_saves; q; q = q->next)
     {
-      size_t i;
       unsigned int reg, sreg;
 
-      for (i = 0; i < num_regs_saved_in_regs; i++)
-	if (REGNO (regs_saved_in_regs[i].orig_reg) == REGNO (q->reg))
-	  break;
-      if (q->saved_reg && i == num_regs_saved_in_regs)
-	{
-	  gcc_assert (i != ARRAY_SIZE (regs_saved_in_regs));
-	  num_regs_saved_in_regs++;
-	}
-      if (i != num_regs_saved_in_regs)
-	{
-	  regs_saved_in_regs[i].orig_reg = q->reg;
-	  regs_saved_in_regs[i].saved_in_reg = q->saved_reg;
-	}
+      record_reg_saved_in_reg (q->saved_reg, q->reg);
 
       reg = DWARF_FRAME_REGNUM (REGNO (q->reg));
       if (q->saved_reg)
@@ -1826,11 +1852,14 @@ clobbers_queued_reg_save (const_rtx insn)
   for (q = queued_reg_saves; q; q = q->next)
     {
       size_t i;
+      reg_saved_in_data *rir;
+
       if (modified_in_p (q->reg, insn))
 	return true;
-      for (i = 0; i < num_regs_saved_in_regs; i++)
-	if (REGNO (q->reg) == REGNO (regs_saved_in_regs[i].orig_reg)
-	    && modified_in_p (regs_saved_in_regs[i].saved_in_reg, insn))
+
+      FOR_EACH_VEC_ELT (reg_saved_in_data, regs_saved_in_regs, i, rir)
+	if (compare_reg_or_pc (q->reg, rir->orig_reg)
+	    && modified_in_p (rir->saved_in_reg, insn))
 	  return true;
     }
 
@@ -1842,19 +1871,9 @@ clobbers_queued_reg_save (const_rtx insn)
 void
 dwarf2out_reg_save_reg (const char *label, rtx reg, rtx sreg)
 {
-  size_t i;
   unsigned int regno, sregno;
 
-  for (i = 0; i < num_regs_saved_in_regs; i++)
-    if (REGNO (regs_saved_in_regs[i].orig_reg) == REGNO (reg))
-      break;
-  if (i == num_regs_saved_in_regs)
-    {
-      gcc_assert (i != ARRAY_SIZE (regs_saved_in_regs));
-      num_regs_saved_in_regs++;
-    }
-  regs_saved_in_regs[i].orig_reg = reg;
-  regs_saved_in_regs[i].saved_in_reg = sreg;
+  record_reg_saved_in_reg (sreg, reg);
 
   regno = DWARF_FRAME_REGNUM (REGNO (reg));
   sregno = DWARF_FRAME_REGNUM (REGNO (sreg));
@@ -1867,17 +1886,17 @@ static rtx
 reg_saved_in (rtx reg)
 {
   unsigned int regn = REGNO (reg);
-  size_t i;
   struct queued_reg_save *q;
+  reg_saved_in_data *rir;
+  size_t i;
 
   for (q = queued_reg_saves; q; q = q->next)
     if (q->saved_reg && regn == REGNO (q->saved_reg))
       return q->reg;
 
-  for (i = 0; i < num_regs_saved_in_regs; i++)
-    if (regs_saved_in_regs[i].saved_in_reg
-	&& regn == REGNO (regs_saved_in_regs[i].saved_in_reg))
-      return regs_saved_in_regs[i].orig_reg;
+  FOR_EACH_VEC_ELT (reg_saved_in_data, regs_saved_in_regs, i, rir)
+    if (regn == REGNO (rir->saved_in_reg))
+      return rir->orig_reg;
 
   return NULL_RTX;
 }
@@ -2026,7 +2045,10 @@ dwarf2out_frame_debug_cfa_register (rtx set, const char *label)
   if (src == pc_rtx)
     sregno = DWARF_FRAME_RETURN_COLUMN;
   else
-    sregno = DWARF_FRAME_REGNUM (REGNO (src));
+    {
+      record_reg_saved_in_reg (dest, src);
+      sregno = DWARF_FRAME_REGNUM (REGNO (src));
+    }
 
   dregno = DWARF_FRAME_REGNUM (REGNO (dest));
 
@@ -2928,8 +2950,6 @@ dwarf2out_frame_debug (rtx insn, bool after_p)
 void
 dwarf2out_frame_debug_init (void)
 {
-  size_t i;
-
   /* Flush any queued register saves.  */
   dwarf2out_flush_queued_reg_saves ();
 
@@ -2943,12 +2963,7 @@ dwarf2out_frame_debug_init (void)
   cfa_temp.reg = -1;
   cfa_temp.offset = 0;
 
-  for (i = 0; i < num_regs_saved_in_regs; i++)
-    {
-      regs_saved_in_regs[i].orig_reg = NULL_RTX;
-      regs_saved_in_regs[i].saved_in_reg = NULL_RTX;
-    }
-  num_regs_saved_in_regs = 0;
+  regs_saved_in_regs = NULL;
 
   if (barrier_args_size)
     {
-- 
1.7.5.4

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 02/12] dwarf2out: Handle pc_rtx as return column in REG_CFA_OFFSET too.
  2011-06-29 21:50 [PATCH 00/12] Eliminate the text-based dwarf2out interface Richard Henderson
                   ` (5 preceding siblings ...)
  2011-06-29 21:51 ` [PATCH 01/12] dwarf2out: Convert regs_saved_in_regs to VEC Richard Henderson
@ 2011-06-29 21:51 ` Richard Henderson
  2011-06-29 21:54 ` [PATCH 11/12] i386: Always use TARGET_DEEP_BRANCH_PREDICTION Richard Henderson
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Richard Henderson @ 2011-06-29 21:51 UTC (permalink / raw)
  To: gcc-patches; +Cc: richard.earnshaw, sje, ubizjak, matt

---
 gcc/dwarf2out.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 3ecdd94..6fad7e9 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -1982,6 +1982,7 @@ dwarf2out_frame_debug_cfa_offset (rtx set, const char *label)
 {
   HOST_WIDE_INT offset;
   rtx src, addr, span;
+  unsigned int sregno;
 
   src = XEXP (set, 1);
   addr = XEXP (set, 0);
@@ -2003,12 +2004,21 @@ dwarf2out_frame_debug_cfa_offset (rtx set, const char *label)
       gcc_unreachable ();
     }
 
-  span = targetm.dwarf_register_span (src);
+  if (src == pc_rtx)
+    {
+      span = NULL;
+      sregno = DWARF_FRAME_RETURN_COLUMN;
+    }
+  else 
+    {
+      span = targetm.dwarf_register_span (src);
+      sregno = DWARF_FRAME_REGNUM (REGNO (src));
+    }
 
   /* ??? We'd like to use queue_reg_save, but we need to come up with
      a different flushing heuristic for epilogues.  */
   if (!span)
-    reg_save (label, DWARF_FRAME_REGNUM (REGNO (src)), INVALID_REGNUM, offset);
+    reg_save (label, sregno, INVALID_REGNUM, offset);
   else
     {
       /* We have a PARALLEL describing where the contents of SRC live.
@@ -2024,8 +2034,8 @@ dwarf2out_frame_debug_cfa_offset (rtx set, const char *label)
 	{
 	  rtx elem = XVECEXP (span, 0, par_index);
 
-	  reg_save (label, DWARF_FRAME_REGNUM (REGNO (elem)),
-		    INVALID_REGNUM, span_offset);
+	  sregno = DWARF_FRAME_REGNUM (REGNO (src));
+	  reg_save (label, sregno, INVALID_REGNUM, span_offset);
 	  span_offset += GET_MODE_SIZE (GET_MODE (elem));
 	}
     }
-- 
1.7.5.4

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 09/12] ia64: Remove dead code in process_epilogue.
  2011-06-29 21:50 [PATCH 00/12] Eliminate the text-based dwarf2out interface Richard Henderson
                   ` (3 preceding siblings ...)
  2011-06-29 21:50 ` [PATCH 12/12] dwarf2out: Remove unused text-based unwind entry points Richard Henderson
@ 2011-06-29 21:51 ` Richard Henderson
  2011-06-29 21:51 ` [PATCH 01/12] dwarf2out: Convert regs_saved_in_regs to VEC Richard Henderson
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Richard Henderson @ 2011-06-29 21:51 UTC (permalink / raw)
  To: gcc-patches; +Cc: richard.earnshaw, sje, ubizjak, matt

---
 gcc/config/ia64/ia64.c |   35 ++---------------------------------
 1 files changed, 2 insertions(+), 33 deletions(-)

diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
index b37919c..bdabe82 100644
--- a/gcc/config/ia64/ia64.c
+++ b/gcc/config/ia64/ia64.c
@@ -9620,29 +9620,6 @@ static bool need_copy_state;
 # define MAX_ARTIFICIAL_LABEL_BYTES 30
 #endif
 
-/* Emit a debugging label after a call-frame-related insn.  We'd
-   rather output the label right away, but we'd have to output it
-   after, not before, the instruction, and the instruction has not
-   been output yet.  So we emit the label after the insn, delete it to
-   avoid introducing basic blocks, and mark it as preserved, such that
-   it is still output, given that it is referenced in debug info.  */
-
-static const char *
-ia64_emit_deleted_label_after_insn (rtx insn)
-{
-  char label[MAX_ARTIFICIAL_LABEL_BYTES];
-  rtx lb = gen_label_rtx ();
-  rtx label_insn = emit_label_after (lb, insn);
-
-  LABEL_PRESERVE_P (lb) = 1;
-
-  delete_insn (label_insn);
-
-  ASM_GENERATE_INTERNAL_LABEL (label, "L", CODE_LABEL_NUMBER (label_insn));
-
-  return xstrdup (label);
-}
-
 /* All we need to do here is avoid a crash in the generic dwarf2
    processing.  The real CFA definition is set up above.  */
 
@@ -9654,16 +9631,11 @@ ia64_dwarf_handle_frame_unspec (const char * ARG_UNUSED (label),
   gcc_assert (index == UNSPECV_ALLOC);
 }
 
-/* The generic dwarf2 frame debug info generator does not define a
-   separate region for the very end of the epilogue, so refrain from
-   doing so in the IA64-specific code as well.  */
-
-#define IA64_CHANGE_CFA_IN_EPILOGUE 0
-
 /* The function emits unwind directives for the start of an epilogue.  */
 
 static void
-process_epilogue (FILE *asm_out_file, rtx insn, bool unwind, bool frame)
+process_epilogue (FILE *asm_out_file, rtx insn ATTRIBUTE_UNUSED,
+		  bool unwind, bool frame ATTRIBUTE_UNUSED)
 {
   /* If this isn't the last block of the function, then we need to label the
      current state, and copy it back in at the start of the next block.  */
@@ -9678,9 +9650,6 @@ process_epilogue (FILE *asm_out_file, rtx insn, bool unwind, bool frame)
 
   if (unwind)
     fprintf (asm_out_file, "\t.restore sp\n");
-  if (IA64_CHANGE_CFA_IN_EPILOGUE && frame)
-    dwarf2out_def_cfa (ia64_emit_deleted_label_after_insn (insn),
-		       STACK_POINTER_REGNUM, INCOMING_FRAME_SP_OFFSET);
 }
 
 /* This function processes a SET pattern for REG_CFA_ADJUST_CFA.  */
-- 
1.7.5.4

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 11/12] i386: Always use TARGET_DEEP_BRANCH_PREDICTION.
  2011-06-29 21:50 [PATCH 00/12] Eliminate the text-based dwarf2out interface Richard Henderson
                   ` (6 preceding siblings ...)
  2011-06-29 21:51 ` [PATCH 02/12] dwarf2out: Handle pc_rtx as return column in REG_CFA_OFFSET too Richard Henderson
@ 2011-06-29 21:54 ` Richard Henderson
  2011-09-02 11:17   ` Jan Hubicka
  2011-06-29 22:26 ` [PATCH 04/12] vax: Emit prologue as rtl Richard Henderson
                   ` (4 subsequent siblings)
  12 siblings, 1 reply; 19+ messages in thread
From: Richard Henderson @ 2011-06-29 21:54 UTC (permalink / raw)
  To: gcc-patches; +Cc: richard.earnshaw, sje, ubizjak, matt

While it could be possible to output_set_got such that we can
individually annotate the instructions, it's simpler to simply
admit that all processors currently being manufactured do want
deep branch prediction.  At which point all of the complication
simply goes away.
---
 gcc/config/i386/i386.c |  105 +++++++----------------------------------------
 gcc/config/i386/i386.h |    3 -
 2 files changed, 16 insertions(+), 92 deletions(-)

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 014401b..332e65b 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -55,7 +55,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "params.h"
 #include "cselib.h"
 #include "debug.h"
-#include "dwarf2out.h"
 #include "sched-int.h"
 #include "sbitmap.h"
 #include "fibheap.h"
@@ -1847,10 +1846,6 @@ static unsigned int initial_ix86_tune_features[X86_TUNE_LAST] = {
   m_486 | m_PENT | m_ATOM | m_PPRO | m_AMD_MULTIPLE | m_K6
   | m_CORE2I7 | m_GENERIC,
 
-  /* X86_TUNE_DEEP_BRANCH_PREDICTION */
-  m_ATOM | m_PPRO | m_K6_GEODE | m_AMD_MULTIPLE | m_PENT4
-  | m_CORE2I7 | m_GENERIC,
-
   /* X86_TUNE_BRANCH_PREDICTION_HINTS: Branch hints were put in P4 based
      on simulation result. But after P4 was made, no performance benefit
      was observed with branch hints.  It also increases the code size.
@@ -8323,31 +8318,11 @@ output_set_got (rtx dest, rtx label ATTRIBUTE_UNUSED)
 
   xops[1] = gen_rtx_SYMBOL_REF (Pmode, GOT_SYMBOL_NAME);
 
-  if (! TARGET_DEEP_BRANCH_PREDICTION || !flag_pic)
+  if (!flag_pic)
     {
       xops[2] = gen_rtx_LABEL_REF (Pmode, label ? label : gen_label_rtx ());
 
-      if (!flag_pic)
-	output_asm_insn ("mov%z0\t{%2, %0|%0, %2}", xops);
-      else
-	{
-	  output_asm_insn ("call\t%a2", xops);
-#ifdef DWARF2_UNWIND_INFO
-	  /* The call to next label acts as a push.  */
-	  if (dwarf2out_do_frame ())
-	    {
-	      rtx insn;
-	      start_sequence ();
-	      insn = emit_insn (gen_rtx_SET (VOIDmode, stack_pointer_rtx,
-					     gen_rtx_PLUS (Pmode,
-							   stack_pointer_rtx,
-							   GEN_INT (-4))));
-	      RTX_FRAME_RELATED_P (insn) = 1;
-	      dwarf2out_frame_debug (insn, true);
-	      end_sequence ();
-	    }
-#endif
-	}
+      output_asm_insn ("mov%z0\t{%2, %0|%0, %2}", xops);
 
 #if TARGET_MACHO
       /* Output the Mach-O "canonical" label name ("Lxx$pb") here too.  This
@@ -8358,29 +8333,6 @@ output_set_got (rtx dest, rtx label ATTRIBUTE_UNUSED)
 
       targetm.asm_out.internal_label (asm_out_file, "L",
 				      CODE_LABEL_NUMBER (XEXP (xops[2], 0)));
-
-      if (flag_pic)
-	{
-	  output_asm_insn ("pop%z0\t%0", xops);
-#ifdef DWARF2_UNWIND_INFO
-	  /* The pop is a pop and clobbers dest, but doesn't restore it
-	     for unwind info purposes.  */
-	  if (dwarf2out_do_frame ())
-	    {
-	      rtx insn;
-	      start_sequence ();
-	      insn = emit_insn (gen_rtx_SET (VOIDmode, dest, const0_rtx));
-	      dwarf2out_frame_debug (insn, true);
-	      insn = emit_insn (gen_rtx_SET (VOIDmode, stack_pointer_rtx,
-					     gen_rtx_PLUS (Pmode,
-							   stack_pointer_rtx,
-							   GEN_INT (4))));
-	      RTX_FRAME_RELATED_P (insn) = 1;
-	      dwarf2out_frame_debug (insn, true);
-	      end_sequence ();
-	    }
-#endif
-	}
     }
   else
     {
@@ -8388,12 +8340,6 @@ output_set_got (rtx dest, rtx label ATTRIBUTE_UNUSED)
       get_pc_thunk_name (name, REGNO (dest));
       pic_labels_used |= 1 << REGNO (dest);
 
-#ifdef DWARF2_UNWIND_INFO
-      /* Ensure all queued register saves are flushed before the
-	 call.  */
-      if (dwarf2out_do_frame ())
-	dwarf2out_flush_queued_reg_saves ();
-#endif
       xops[2] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (name));
       xops[2] = gen_rtx_MEM (QImode, xops[2]);
       output_asm_insn ("call\t%X2", xops);
@@ -8408,13 +8354,8 @@ output_set_got (rtx dest, rtx label ATTRIBUTE_UNUSED)
 #endif
     }
 
-  if (TARGET_MACHO)
-    return "";
-
-  if (!flag_pic || TARGET_DEEP_BRANCH_PREDICTION)
+  if (!TARGET_MACHO)
     output_asm_insn ("add%z0\t{%1, %0|%0, %1}", xops);
-  else
-    output_asm_insn ("add%z0\t{%1+[.-%a2], %0|%0, %1+(.-%a2)}", xops);
 
   return "";
 }
@@ -10138,7 +10079,11 @@ ix86_expand_prologue (void)
             insn = emit_insn (gen_set_got_rex64 (pic_offset_table_rtx));
 	}
       else
-        insn = emit_insn (gen_set_got (pic_offset_table_rtx));
+	{
+          insn = emit_insn (gen_set_got (pic_offset_table_rtx));
+	  RTX_FRAME_RELATED_P (insn) = 1;
+	  add_reg_note (insn, REG_CFA_FLUSH_QUEUE, NULL_RTX);
+	}
     }
 
   /* In the pic_reg_used case, make sure that the got load isn't deleted
@@ -28979,12 +28924,7 @@ machopic_output_stub (FILE *file, const char *symb, const char *stub)
   if (MACHOPIC_ATT_STUB)
     switch_to_section (darwin_sections[machopic_picsymbol_stub3_section]);
   else if (MACHOPIC_PURE)
-    {
-      if (TARGET_DEEP_BRANCH_PREDICTION)
-	switch_to_section (darwin_sections[machopic_picsymbol_stub2_section]);
-      else
-    switch_to_section (darwin_sections[machopic_picsymbol_stub_section]);
-    }
+    switch_to_section (darwin_sections[machopic_picsymbol_stub2_section]);
   else
     switch_to_section (darwin_sections[machopic_symbol_stub_section]);
 
@@ -28998,19 +28938,11 @@ machopic_output_stub (FILE *file, const char *symb, const char *stub)
   else if (MACHOPIC_PURE)
     {
       /* PIC stub.  */
-      if (TARGET_DEEP_BRANCH_PREDICTION)
-	{
-	  /* 25-byte PIC stub using "CALL get_pc_thunk".  */
-	  rtx tmp = gen_rtx_REG (SImode, 2 /* ECX */);
-	  output_set_got (tmp, NULL_RTX);	/* "CALL ___<cpu>.get_pc_thunk.cx".  */
-	  fprintf (file, "LPC$%d:\tmovl\t%s-LPC$%d(%%ecx),%%ecx\n", label, lazy_ptr_name, label);
-	}
-      else
-	{
-	  /* 26-byte PIC stub using inline picbase: "CALL L42 ! L42: pop %eax".  */
-	  fprintf (file, "\tcall LPC$%d\nLPC$%d:\tpopl %%ecx\n", label, label);
-	  fprintf (file, "\tmovl %s-LPC$%d(%%ecx),%%ecx\n", lazy_ptr_name, label);
-	}
+      /* 25-byte PIC stub using "CALL get_pc_thunk".  */
+      rtx tmp = gen_rtx_REG (SImode, 2 /* ECX */);
+      output_set_got (tmp, NULL_RTX);	/* "CALL ___<cpu>.get_pc_thunk.cx".  */
+      fprintf (file, "LPC$%d:\tmovl\t%s-LPC$%d(%%ecx),%%ecx\n",
+	       label, lazy_ptr_name, label);
       fprintf (file, "\tjmp\t*%%ecx\n");
     }
   else
@@ -29039,13 +28971,8 @@ machopic_output_stub (FILE *file, const char *symb, const char *stub)
      compatibility with existing dylibs.  */
   if (MACHOPIC_PURE)
     {
-      /* PIC stubs.  */
-      if (TARGET_DEEP_BRANCH_PREDICTION)
-	/* 25-byte PIC stub using "CALL get_pc_thunk".  */
-	switch_to_section (darwin_sections[machopic_lazy_symbol_ptr2_section]);
-      else
-	/* 26-byte PIC stub using inline picbase: "CALL L42 ! L42: pop %ebx".  */
-  switch_to_section (darwin_sections[machopic_lazy_symbol_ptr_section]);
+      /* 25-byte PIC stub using "CALL get_pc_thunk".  */
+      switch_to_section (darwin_sections[machopic_lazy_symbol_ptr2_section]);
     }
   else
     /* 16-byte -mdynamic-no-pic stub.  */
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index 8badcbb..1452226 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -249,7 +249,6 @@ enum ix86_tune_indices {
   X86_TUNE_PUSH_MEMORY,
   X86_TUNE_ZERO_EXTEND_WITH_AND,
   X86_TUNE_UNROLL_STRLEN,
-  X86_TUNE_DEEP_BRANCH_PREDICTION,
   X86_TUNE_BRANCH_PREDICTION_HINTS,
   X86_TUNE_DOUBLE_WITH_ADD,
   X86_TUNE_USE_SAHF,
@@ -323,8 +322,6 @@ extern unsigned char ix86_tune_features[X86_TUNE_LAST];
 #define TARGET_ZERO_EXTEND_WITH_AND \
 	ix86_tune_features[X86_TUNE_ZERO_EXTEND_WITH_AND]
 #define TARGET_UNROLL_STRLEN	ix86_tune_features[X86_TUNE_UNROLL_STRLEN]
-#define TARGET_DEEP_BRANCH_PREDICTION \
-	ix86_tune_features[X86_TUNE_DEEP_BRANCH_PREDICTION]
 #define TARGET_BRANCH_PREDICTION_HINTS \
 	ix86_tune_features[X86_TUNE_BRANCH_PREDICTION_HINTS]
 #define TARGET_DOUBLE_WITH_ADD	ix86_tune_features[X86_TUNE_DOUBLE_WITH_ADD]
-- 
1.7.5.4

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 04/12] vax: Emit prologue as rtl.
  2011-06-29 21:50 [PATCH 00/12] Eliminate the text-based dwarf2out interface Richard Henderson
                   ` (7 preceding siblings ...)
  2011-06-29 21:54 ` [PATCH 11/12] i386: Always use TARGET_DEEP_BRANCH_PREDICTION Richard Henderson
@ 2011-06-29 22:26 ` Richard Henderson
  2011-06-29 23:19   ` Steven Bosscher
  2011-06-29 22:27 ` [PATCH 06/12] ia64: Issue REG_CFA_REGISTER for ar.pfs at alloc insn Richard Henderson
                   ` (3 subsequent siblings)
  12 siblings, 1 reply; 19+ messages in thread
From: Richard Henderson @ 2011-06-29 22:26 UTC (permalink / raw)
  To: gcc-patches; +Cc: richard.earnshaw, sje, ubizjak, matt

Not that there's much rtl to emit, since the CALL instruction
interpreting the procedure entry mask does almost all the work.
However, it means we're no longer emitting dwarf2 via the
text-based entry points.
---
 gcc/config/vax/vax-protos.h |    1 +
 gcc/config/vax/vax.c        |   86 +++++++++++++++++++++++++++++++------------
 gcc/config/vax/vax.md       |   25 ++++++++++--
 3 files changed, 84 insertions(+), 28 deletions(-)

diff --git a/gcc/config/vax/vax-protos.h b/gcc/config/vax/vax-protos.h
index a8f88bf..3f24794 100644
--- a/gcc/config/vax/vax-protos.h
+++ b/gcc/config/vax/vax-protos.h
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3.  If not see
 
 extern bool legitimate_constant_address_p (rtx);
 extern bool vax_mode_dependent_address_p (rtx);
+extern void vax_expand_prologue (void);
 
 #ifdef RTX_CODE
 extern const char *cond_name (rtx);
diff --git a/gcc/config/vax/vax.c b/gcc/config/vax/vax.c
index 7c7070c..13a4515 100644
--- a/gcc/config/vax/vax.c
+++ b/gcc/config/vax/vax.c
@@ -48,7 +48,6 @@ along with GCC; see the file COPYING3.  If not see
 
 static void vax_option_override (void);
 static bool vax_legitimate_address_p (enum machine_mode, rtx, bool);
-static void vax_output_function_prologue (FILE *, HOST_WIDE_INT);
 static void vax_file_start (void);
 static void vax_init_libfuncs (void);
 static void vax_output_mi_thunk (FILE *, tree, HOST_WIDE_INT,
@@ -70,9 +69,6 @@ static int vax_return_pops_args (tree, tree, int);
 #undef TARGET_ASM_ALIGNED_HI_OP
 #define TARGET_ASM_ALIGNED_HI_OP "\t.word\t"
 
-#undef TARGET_ASM_FUNCTION_PROLOGUE
-#define TARGET_ASM_FUNCTION_PROLOGUE vax_output_function_prologue
-
 #undef TARGET_ASM_FILE_START
 #define TARGET_ASM_FILE_START vax_file_start
 #undef TARGET_ASM_FILE_START_APP_OFF
@@ -137,6 +133,17 @@ vax_option_override (void)
 #endif
 }
 
+static void
+vax_add_reg_cfa_offset (rtx insn, int offset, rtx src)
+{
+  rtx x;
+
+  x = plus_constant (frame_pointer_rtx, offset);
+  x = gen_rtx_MEM (SImode, x);
+  x = gen_rtx_SET (VOIDmode, x, src);
+  add_reg_note (insn, REG_CFA_OFFSET, x);
+}
+
 /* Generate the assembly code for function entry.  FILE is a stdio
    stream to output the code to.  SIZE is an int: how many units of
    temporary storage to allocate.
@@ -146,38 +153,67 @@ vax_option_override (void)
    used in the function.  This function is responsible for knowing
    which registers should not be saved even if used.  */
 
-static void
-vax_output_function_prologue (FILE * file, HOST_WIDE_INT size)
+void
+vax_expand_prologue (void)
 {
-  int regno;
+  int regno, offset;
   int mask = 0;
+  HOST_WIDE_INT size;
+  rtx insn;
 
   for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
     if (df_regs_ever_live_p (regno) && !call_used_regs[regno])
       mask |= 1 << regno;
 
-  fprintf (file, "\t.word 0x%x\n", mask);
+  insn = emit_insn (gen_procedure_entry_mask (GEN_INT (mask)));
+  RTX_FRAME_RELATED_P (insn) = 1;
 
-  if (dwarf2out_do_frame ())
-    {
-      const char *label = dwarf2out_cfi_label (false);
-      int offset = 0;
+  /* The layout of the CALLG/S stack frame is follows:
 
-      for (regno = FIRST_PSEUDO_REGISTER-1; regno >= 0; --regno)
-	if (df_regs_ever_live_p (regno) && !call_used_regs[regno])
-	  dwarf2out_reg_save (label, regno, offset -= 4);
+		<- CFA, AP
+	r11
+	r10
+	...	Registers saved as specified by MASK
+	r3
+	r2
+	return-addr
+	old fp
+	old ap
+	old psw
+	zero
+		<- FP, SP
 
-      dwarf2out_reg_save (label, PC_REGNUM, offset -= 4);
-      dwarf2out_reg_save (label, FRAME_POINTER_REGNUM, offset -= 4);
-      dwarf2out_reg_save (label, ARG_POINTER_REGNUM, offset -= 4);
-      dwarf2out_def_cfa (label, FRAME_POINTER_REGNUM, -(offset - 4));
-    }
+     The rest of the prologue will adjust the SP for the local frame.  */
+
+  vax_add_reg_cfa_offset (insn, 4, arg_pointer_rtx);
+  vax_add_reg_cfa_offset (insn, 8, frame_pointer_rtx);
+  vax_add_reg_cfa_offset (insn, 12, pc_rtx);
+
+  offset = 16;
+  for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
+    if (mask & (1 << regno))
+      {
+	vax_add_reg_cfa_offset (insn, offset, gen_rtx_REG (SImode, regno));
+	offset += 4;
+      }
+
+  /* Because add_reg_note pushes the notes, adding this last means that
+     it will be processed first.  This is required to allow the other
+     notes be interpreted properly.  */
+  add_reg_note (insn, REG_CFA_DEF_CFA,
+		plus_constant (frame_pointer_rtx, offset));
 
+  /* Allocate the local stack frame.  */
+  size = get_frame_size ();
   size -= STARTING_FRAME_OFFSET;
-  if (size >= 64)
-    asm_fprintf (file, "\tmovab %wd(%Rsp),%Rsp\n", -size);
-  else if (size)
-    asm_fprintf (file, "\tsubl2 $%wd,%Rsp\n", size);
+  emit_insn (gen_addsi3 (stack_pointer_rtx,
+			 stack_pointer_rtx, GEN_INT (-size)));
+
+  /* Do not allow instructions referencing local stack memory to be
+     scheduled before the frame is allocated.  This is more pedantic
+     than anything else, given that VAX does not currently have a
+     scheduling description.  */
+  emit_insn (gen_blockage ());
 }
 
 /* When debugging with stabs, we want to output an extra dummy label
@@ -485,6 +521,8 @@ print_operand (FILE *file, rtx x, int code)
     fprintf (file, "$%d", (int) (0xff & - INTVAL (x)));
   else if (code == 'M' && CONST_INT_P (x))
     fprintf (file, "$%d", ~((1 << INTVAL (x)) - 1));
+  else if (code == 'x' && CONST_INT_P (x))
+    fprintf (file, HOST_WIDE_INT_PRINT_HEX, INTVAL (x));
   else if (REG_P (x))
     fprintf (file, "%s", reg_names[REGNO (x)]);
   else if (MEM_P (x))
diff --git a/gcc/config/vax/vax.md b/gcc/config/vax/vax.md
index 8c3ef00..32f50fd 100644
--- a/gcc/config/vax/vax.md
+++ b/gcc/config/vax/vax.md
@@ -29,11 +29,15 @@
 
 ;; UNSPEC_VOLATILE usage:
 
-(define_constants
-  [(VUNSPEC_BLOCKAGE 0)	    ; `blockage' insn to prevent scheduling across an
+(define_c_enum "unspecv" [
+  VUNSPEC_BLOCKAGE 	    ; 'blockage' insn to prevent scheduling across an
 			    ; insn in the code.
-   (VUNSPEC_SYNC_ISTREAM 1) ; sequence of insns to sync the I-stream
-   (VAX_AP_REGNUM 12)	    ; Register 12 contains the argument pointer
+  VUNSPEC_SYNC_ISTREAM      ; sequence of insns to sync the I-stream
+  VUNSPEC_PEM		    ; 'procedure_entry_mask' insn.
+])
+
+(define_constants
+  [(VAX_AP_REGNUM 12)	    ; Register 12 contains the argument pointer
    (VAX_FP_REGNUM 13)	    ; Register 13 contains the frame pointer
    (VAX_SP_REGNUM 14)	    ; Register 14 contains the stack pointer
    (VAX_PC_REGNUM 15)	    ; Register 15 contains the program counter
@@ -1409,11 +1413,24 @@
   ""
   "")
 
+(define_insn "procedure_entry_mask"
+  [(unspec_volatile [(match_operand 0 "const_int_operand")] VUNSPEC_PEM)]
+  ""
+  ".word %x0")
+
 (define_insn "return"
   [(return)]
   ""
   "ret")
 
+(define_expand "prologue"
+  [(const_int 0)]
+  ""
+{
+  vax_expand_prologue ();
+  DONE;
+})
+
 (define_expand "epilogue"
   [(return)]
   ""
-- 
1.7.5.4

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 08/12] ia64: Use pc_rtx to save the return address.
  2011-06-29 21:50 [PATCH 00/12] Eliminate the text-based dwarf2out interface Richard Henderson
                   ` (9 preceding siblings ...)
  2011-06-29 22:27 ` [PATCH 06/12] ia64: Issue REG_CFA_REGISTER for ar.pfs at alloc insn Richard Henderson
@ 2011-06-29 22:27 ` Richard Henderson
  2011-06-29 22:33 ` [PATCH 03/12] dwarf2out: Add REG_CFA_FLUSH_QUEUE Richard Henderson
  2011-06-30 13:20 ` [PATCH 00/12] Eliminate the text-based dwarf2out interface Bernd Schmidt
  12 siblings, 0 replies; 19+ messages in thread
From: Richard Henderson @ 2011-06-29 22:27 UTC (permalink / raw)
  To: gcc-patches; +Cc: richard.earnshaw, sje, ubizjak, matt

When actually emitting dwarf2, this now produces proper results.
When emitting ia64 unwind info, this removes a hard-coded assumption.
---
 gcc/config/ia64/ia64.c |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
index bb3fc4d..b37919c 100644
--- a/gcc/config/ia64/ia64.c
+++ b/gcc/config/ia64/ia64.c
@@ -3444,7 +3444,8 @@ ia64_expand_prologue (void)
           reg_emitted (reg_save_b0);
 	  insn = emit_move_insn (alt_reg, reg);
 	  RTX_FRAME_RELATED_P (insn) = 1;
-	  add_reg_note (insn, REG_CFA_REGISTER, NULL_RTX);
+	  add_reg_note (insn, REG_CFA_REGISTER,
+			gen_rtx_SET (VOIDmode, alt_reg, pc_rtx));
 
 	  /* Even if we're not going to generate an epilogue, we still
 	     need to save the register so that EH works.  */
@@ -9737,20 +9738,22 @@ process_cfa_register (FILE *asm_out_file, rtx pat, bool unwind)
 {
   rtx dest = SET_DEST (pat);
   rtx src = SET_SRC (pat);
-
   int dest_regno = REGNO (dest);
-  int src_regno = REGNO (src);
+  int src_regno;
 
-  switch (src_regno)
+  if (src == pc_rtx)
     {
-    case BR_REG (0):
       /* Saving return address pointer.  */
-      gcc_assert (dest_regno == current_frame_info.r[reg_save_b0]);
       if (unwind)
 	fprintf (asm_out_file, "\t.save rp, r%d\n",
 		 ia64_dbx_register_number (dest_regno));
-      break;
+      return;
+    }
+
+  src_regno = REGNO (src);
 
+  switch (src_regno)
+    {
     case PR_REG (0):
       gcc_assert (dest_regno == current_frame_info.r[reg_save_pr]);
       if (unwind)
-- 
1.7.5.4

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 06/12] ia64: Issue REG_CFA_REGISTER for ar.pfs at alloc insn.
  2011-06-29 21:50 [PATCH 00/12] Eliminate the text-based dwarf2out interface Richard Henderson
                   ` (8 preceding siblings ...)
  2011-06-29 22:26 ` [PATCH 04/12] vax: Emit prologue as rtl Richard Henderson
@ 2011-06-29 22:27 ` Richard Henderson
  2011-06-29 22:27 ` [PATCH 08/12] ia64: Use pc_rtx to save the return address Richard Henderson
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Richard Henderson @ 2011-06-29 22:27 UTC (permalink / raw)
  To: gcc-patches; +Cc: richard.earnshaw, sje, ubizjak, matt

---
 gcc/config/ia64/ia64.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
index c06903d..0a6f2e6 100644
--- a/gcc/config/ia64/ia64.c
+++ b/gcc/config/ia64/ia64.c
@@ -3249,7 +3249,14 @@ ia64_expand_prologue (void)
 				   GEN_INT (current_frame_info.n_local_regs),
 				   GEN_INT (current_frame_info.n_output_regs),
 				   GEN_INT (current_frame_info.n_rotate_regs)));
-      RTX_FRAME_RELATED_P (insn) = (current_frame_info.r[reg_save_ar_pfs] != 0);
+      if (current_frame_info.r[reg_save_ar_pfs])
+	{
+	  RTX_FRAME_RELATED_P (insn) = 1;
+	  add_reg_note (insn, REG_CFA_REGISTER,
+			gen_rtx_SET (VOIDmode,
+				     ar_pfs_save_reg,
+				     gen_rtx_REG (DImode, AR_PFS_REGNUM)));
+	}
     }
 
   /* Set up frame pointer, stack pointer, and spill iterators.  */
-- 
1.7.5.4

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 03/12] dwarf2out: Add REG_CFA_FLUSH_QUEUE.
  2011-06-29 21:50 [PATCH 00/12] Eliminate the text-based dwarf2out interface Richard Henderson
                   ` (10 preceding siblings ...)
  2011-06-29 22:27 ` [PATCH 08/12] ia64: Use pc_rtx to save the return address Richard Henderson
@ 2011-06-29 22:33 ` Richard Henderson
  2011-06-30 13:20 ` [PATCH 00/12] Eliminate the text-based dwarf2out interface Bernd Schmidt
  12 siblings, 0 replies; 19+ messages in thread
From: Richard Henderson @ 2011-06-29 22:33 UTC (permalink / raw)
  To: gcc-patches; +Cc: richard.earnshaw, sje, ubizjak, matt

---
 gcc/dwarf2out.c   |   37 +++++++++++++++++++++++++------------
 gcc/final.c       |    4 +++-
 gcc/reg-notes.def |   11 +++++++++--
 3 files changed, 37 insertions(+), 15 deletions(-)

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 6fad7e9..9cccc04 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -2832,6 +2832,7 @@ dwarf2out_frame_debug (rtx insn, bool after_p)
   const char *label;
   rtx note, n;
   bool handled_one = false;
+  bool need_flush = false;
 
   if (!NONJUMP_INSN_P (insn) || clobbers_queued_reg_save (insn))
     dwarf2out_flush_queued_reg_saves ();
@@ -2854,7 +2855,7 @@ dwarf2out_frame_debug (rtx insn, bool after_p)
       {
       case REG_FRAME_RELATED_EXPR:
 	insn = XEXP (note, 0);
-	goto found;
+	goto do_frame_expr;
 
       case REG_CFA_DEF_CFA:
 	dwarf2out_frame_debug_def_cfa (XEXP (note, 0), label);
@@ -2934,24 +2935,36 @@ dwarf2out_frame_debug (rtx insn, bool after_p)
 	handled_one = true;
 	break;
 
+      case REG_CFA_FLUSH_QUEUE:
+	/* The actual flush happens below.  */
+	need_flush = true;
+	handled_one = true;
+	break;
+
       default:
 	break;
       }
+
   if (handled_one)
     {
-      if (any_cfis_emitted)
-	dwarf2out_flush_queued_reg_saves ();
-      return;
+      /* Minimize the number of advances by emitting the entire queue
+	 once anything is emitted.  */
+      need_flush |= any_cfis_emitted;
     }
+  else
+    {
+      insn = PATTERN (insn);
+    do_frame_expr:
+      dwarf2out_frame_debug_expr (insn, label);
 
-  insn = PATTERN (insn);
- found:
-  dwarf2out_frame_debug_expr (insn, label);
+      /* Check again.  A parallel can save and update the same register.
+         We could probably check just once, here, but this is safer than
+         removing the check at the start of the function.  */
+      if (any_cfis_emitted || clobbers_queued_reg_save (insn))
+	need_flush = true;
+    }
 
-  /* Check again.  A parallel can save and update the same register.
-     We could probably check just once, here, but this is safer than
-     removing the check above.  */
-  if (any_cfis_emitted || clobbers_queued_reg_save (insn))
+  if (need_flush)
     dwarf2out_flush_queued_reg_saves ();
 }
 
diff --git a/gcc/final.c b/gcc/final.c
index cb4a83d..c0c1fc8 100644
--- a/gcc/final.c
+++ b/gcc/final.c
@@ -2683,7 +2683,9 @@ final_scan_insn (rtx insn, FILE *file, int optimize_p ATTRIBUTE_UNUSED,
 
 	current_output_insn = debug_insn = insn;
 
-	if (CALL_P (insn) && dwarf2out_do_frame ())
+	if (dwarf2out_do_frame ()
+	    && (CALL_P (insn)
+		|| find_reg_note (insn, REG_CFA_FLUSH_QUEUE, NULL)))
 	  dwarf2out_frame_debug (insn, false);
 
 	/* Find the proper template for this insn.  */
diff --git a/gcc/reg-notes.def b/gcc/reg-notes.def
index 9924355..eccac9e 100644
--- a/gcc/reg-notes.def
+++ b/gcc/reg-notes.def
@@ -155,16 +155,23 @@ REG_NOTE (CFA_EXPRESSION)
    first pattern is the register to be restored.  */
 REG_NOTE (CFA_RESTORE)
 
-/* Attached to insn that is RTX_FRAME_RELATED_P, marks insn that sets
+/* Attached to insns that are RTX_FRAME_RELATED_P, marks insn that sets
    vDRAP from DRAP.  If vDRAP is a register, vdrap_reg is initalized
    to the argument, if it is a MEM, it is ignored.  */
 REG_NOTE (CFA_SET_VDRAP)
 
-/* Attached to insn that are RTX_FRAME_RELATED_P, indicating a window
+/* Attached to insns that are RTX_FRAME_RELATED_P, indicating a window
    save operation, i.e. will result in a DW_CFA_GNU_window_save.
    The argument is ignored.  */
 REG_NOTE (CFA_WINDOW_SAVE)
 
+/* Attached to insns that are RTX_FRAME_RELATED_P, marks the insn as
+   requiring that all queued information should be flushed *before* insn,
+   regardless of what is visible in the rtl.  The argument is ignored.
+   This is normally used for a call instruction which is not exposed to
+   the rest of the compiler as a CALL_INSN.  */
+REG_NOTE (CFA_FLUSH_QUEUE)
+
 /* Indicates that REG holds the exception context for the function.
    This context is shared by inline functions, so the code to acquire
    the real exception context is delayed until after inlining.  */
-- 
1.7.5.4

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 04/12] vax: Emit prologue as rtl.
  2011-06-29 22:26 ` [PATCH 04/12] vax: Emit prologue as rtl Richard Henderson
@ 2011-06-29 23:19   ` Steven Bosscher
  2011-06-29 23:34     ` Richard Henderson
  2011-06-30 17:41     ` Richard Henderson
  0 siblings, 2 replies; 19+ messages in thread
From: Steven Bosscher @ 2011-06-29 23:19 UTC (permalink / raw)
  To: Richard Henderson; +Cc: gcc-patches, richard.earnshaw, sje, ubizjak, matt

On Wed, Jun 29, 2011 at 11:49 PM, Richard Henderson <rth@redhat.com> wrote:
> --- a/gcc/config/vax/vax.c
> +++ b/gcc/config/vax/vax.c
> @@ -70,9 +69,6 @@ static int vax_return_pops_args (tree, tree, int);
>  #undef TARGET_ASM_ALIGNED_HI_OP
>  #define TARGET_ASM_ALIGNED_HI_OP "\t.word\t"
>
> -#undef TARGET_ASM_FUNCTION_PROLOGUE
> -#define TARGET_ASM_FUNCTION_PROLOGUE vax_output_function_prologue
> -
>  #undef TARGET_ASM_FILE_START
>  #define TARGET_ASM_FILE_START vax_file_start
>  #undef TARGET_ASM_FILE_START_APP_OFF

Can you please also update http://gcc.gnu.org/backends.html? I think
VAX should have a 'g' after you commit this patch.

How many TARGET_ASM_FUNCTION_{PRO,EPI}LOGUE targets are left anyway?

Ciao!
Steven

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 04/12] vax: Emit prologue as rtl.
  2011-06-29 23:19   ` Steven Bosscher
@ 2011-06-29 23:34     ` Richard Henderson
  2011-06-30 17:41     ` Richard Henderson
  1 sibling, 0 replies; 19+ messages in thread
From: Richard Henderson @ 2011-06-29 23:34 UTC (permalink / raw)
  To: Steven Bosscher; +Cc: gcc-patches, richard.earnshaw, sje, ubizjak, matt

On 06/29/2011 04:01 PM, Steven Bosscher wrote:
> Can you please also update http://gcc.gnu.org/backends.html? I think
> VAX should have a 'g' after you commit this patch.

Sure.

> How many TARGET_ASM_FUNCTION_{PRO,EPI}LOGUE targets are left anyway?

It's difficult to tell at a glance, because quite a few use
the hook for Other Things.  Such as ARM printing debug info
about the stack frame, or Sparc outputting the scratch register
elf info, or IA-64 and Alpha using it to output some portion
of the unwind info.


r~

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 00/12] Eliminate the text-based dwarf2out interface
  2011-06-29 21:50 [PATCH 00/12] Eliminate the text-based dwarf2out interface Richard Henderson
                   ` (11 preceding siblings ...)
  2011-06-29 22:33 ` [PATCH 03/12] dwarf2out: Add REG_CFA_FLUSH_QUEUE Richard Henderson
@ 2011-06-30 13:20 ` Bernd Schmidt
  12 siblings, 0 replies; 19+ messages in thread
From: Bernd Schmidt @ 2011-06-30 13:20 UTC (permalink / raw)
  To: Richard Henderson; +Cc: gcc-patches, richard.earnshaw, sje, ubizjak, matt

On 06/29/11 23:49, Richard Henderson wrote:
> In preparation for the changes required to support shrink-wrapping,
> it makes things Much Easier if we no longer have to handle seeing
> new unwind states being introduced during pass_final, while emitting
> the actual assembly.  Thus we want to convert everything that used
> the text-based interfaces to use the REG_CFA_* notes instead.
> 
> The following set has been tested on i386-linux, x86_64-linux,
> ia64-linux, arm-elf, arm-eabi, and a cross-compile to vax-linux.
> 
> 
> r~
> 
> 
> Richard Henderson (12):
>   dwarf2out: Convert regs_saved_in_regs to VEC.
>   dwarf2out: Handle pc_rtx as return column in REG_CFA_OFFSET too.
>   dwarf2out: Add REG_CFA_FLUSH_QUEUE.
>   vax: Emit prologue as rtl.
>   arm: Use REG_CFA_REGISTER instead of UNSPEC_STACK_ALIGN.
>   ia64: Issue REG_CFA_REGISTER for ar.pfs at alloc insn.
>   ia64: Remove ia64_dwarf2out_def_steady_cfa.
>   ia64: Use pc_rtx to save the return address.
>   ia64: Remove dead code in process_epilogue.
>   ia64: Remove TARGET_DWARF_HANDLE_FRAME_UNSPEC hook.
>   i386: Always use TARGET_DEEP_BRANCH_PREDICTION.
>   dwarf2out: Remove unused text-based unwind entry points.

Thanks so much for working on this. Ok for the dwarf2out parts, and I
guess the other bits as well absent any target maintainer objections in
a day or two.


Bernd

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 04/12] vax: Emit prologue as rtl.
  2011-06-29 23:19   ` Steven Bosscher
  2011-06-29 23:34     ` Richard Henderson
@ 2011-06-30 17:41     ` Richard Henderson
  2011-06-30 17:47       ` Paul Koning
  1 sibling, 1 reply; 19+ messages in thread
From: Richard Henderson @ 2011-06-30 17:41 UTC (permalink / raw)
  To: Steven Bosscher; +Cc: gcc-patches

On 06/29/2011 04:01 PM, Steven Bosscher wrote:
> How many TARGET_ASM_FUNCTION_{PRO,EPI}LOGUE targets are left anyway?

Answering the question that it sounds like you actually asked: 2 or 3.
Not that it does us that much good because of the other uses.

FWIW, Alpha appears to be the only target that (ab)uses 
ASM_DECLARE_FUNCTION_NAME to output unwind info.  That might have been
a mistake, considering the interference that causes with using elfos.h.

I'm not sure what all the zeroing of backend variables that several 
targets are doing is for.  Better GC at the end of the function maybe?


r~

----------------------


Users of TARGET_ASM_FUNCTION_PROLOGUE

   Outputs the real prologue
	pdp11
	rs6000		if !TARGET_SCHED_PROLOG

   Outputs assembly comments
	arm
	m32r
	mep
	picochip
	rx

   Outputs unwind info
	ia64		(.regstk, .prologue)
	microblaze	(.ent, .frame, .mask)
	mips		(.ent, .frame, .mask)
	pa		(.PROC and .CALLINFO)
	score		(.ent, .frame, .mask)

   Other
	frv		renaming of gr3?, frv_pack_insns
	mips		mips16 function stub, gp load at function start
	microblaze	add _interrupt_handler alias?
	mmix		init register renaming?
	rs6000		emit .extern as needed before uses?
	sparc		emit .register as needed

Users of TARGET_ASM_FUNCTION_EPILOGUE

   Outputs the real epilogue
	arm		thumb1 only
	pdp11
	rs6000		if !TARGET_SCHED_PROLOG

   Outputs assembly comments
	picochip
	mmix		actually just a newline?

   Outputs unwind info
	microblaze	(.end)
	mips		(.end)
	pa		(.PROCEND and stuff)
	rs6000		aix traceback table
	score		(.end)

   Other
	arm		validate some frame offsets?
	frv		reset variables
	i386		undo pic register renaming, darwin nop hack
	ia64		undo register renaming
	m32r		reset variables
	microblaze	finish _interrupt_handler alias, reset variables
	mips		undo pic register renaming
	rs6000		darwin branch islands
	sh		reset variables
	sparc		unwind nop, deferred case vectors
	xtensa		reset variables

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 04/12] vax: Emit prologue as rtl.
  2011-06-30 17:41     ` Richard Henderson
@ 2011-06-30 17:47       ` Paul Koning
  0 siblings, 0 replies; 19+ messages in thread
From: Paul Koning @ 2011-06-30 17:47 UTC (permalink / raw)
  To: Richard Henderson; +Cc: Steven Bosscher, gcc-patches

On Jun 30, 2011, at 1:21 PM, Richard Henderson wrote:

> On 06/29/2011 04:01 PM, Steven Bosscher wrote:
>> How many TARGET_ASM_FUNCTION_{PRO,EPI}LOGUE targets are left anyway?
> 
> Answering the question that it sounds like you actually asked: 2 or 3.
> Not that it does us that much good because of the other uses.
> ...
> Users of TARGET_ASM_FUNCTION_PROLOGUE
> 
>   Outputs the real prologue
> 	pdp11
> 	rs6000		if !TARGET_SCHED_PROLOG
> ...

I intend to change pdp11 over to RTL based pro/epilogue in the not too distant future.

	paul

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 11/12] i386: Always use TARGET_DEEP_BRANCH_PREDICTION.
  2011-06-29 21:54 ` [PATCH 11/12] i386: Always use TARGET_DEEP_BRANCH_PREDICTION Richard Henderson
@ 2011-09-02 11:17   ` Jan Hubicka
  0 siblings, 0 replies; 19+ messages in thread
From: Jan Hubicka @ 2011-09-02 11:17 UTC (permalink / raw)
  To: Richard Henderson; +Cc: gcc-patches, richard.earnshaw, sje, ubizjak, matt

> While it could be possible to output_set_got such that we can
> individually annotate the instructions, it's simpler to simply
> admit that all processors currently being manufactured do want
> deep branch prediction.  At which point all of the complication
> simply goes away.

Note that most of modern CPUs special case call to next instruction, so 
they will work well with !X86_TUNE_DEEP_BRANCH_PREDICTION code.

Honza
> ---
>  gcc/config/i386/i386.c |  105 +++++++----------------------------------------
>  gcc/config/i386/i386.h |    3 -
>  2 files changed, 16 insertions(+), 92 deletions(-)
> 
> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> index 014401b..332e65b 100644
> --- a/gcc/config/i386/i386.c
> +++ b/gcc/config/i386/i386.c
> @@ -55,7 +55,6 @@ along with GCC; see the file COPYING3.  If not see
>  #include "params.h"
>  #include "cselib.h"
>  #include "debug.h"
> -#include "dwarf2out.h"
>  #include "sched-int.h"
>  #include "sbitmap.h"
>  #include "fibheap.h"
> @@ -1847,10 +1846,6 @@ static unsigned int initial_ix86_tune_features[X86_TUNE_LAST] = {
>    m_486 | m_PENT | m_ATOM | m_PPRO | m_AMD_MULTIPLE | m_K6
>    | m_CORE2I7 | m_GENERIC,
>  
> -  /* X86_TUNE_DEEP_BRANCH_PREDICTION */
> -  m_ATOM | m_PPRO | m_K6_GEODE | m_AMD_MULTIPLE | m_PENT4
> -  | m_CORE2I7 | m_GENERIC,
> -
>    /* X86_TUNE_BRANCH_PREDICTION_HINTS: Branch hints were put in P4 based
>       on simulation result. But after P4 was made, no performance benefit
>       was observed with branch hints.  It also increases the code size.
> @@ -8323,31 +8318,11 @@ output_set_got (rtx dest, rtx label ATTRIBUTE_UNUSED)
>  
>    xops[1] = gen_rtx_SYMBOL_REF (Pmode, GOT_SYMBOL_NAME);
>  
> -  if (! TARGET_DEEP_BRANCH_PREDICTION || !flag_pic)
> +  if (!flag_pic)
>      {
>        xops[2] = gen_rtx_LABEL_REF (Pmode, label ? label : gen_label_rtx ());
>  
> -      if (!flag_pic)
> -	output_asm_insn ("mov%z0\t{%2, %0|%0, %2}", xops);
> -      else
> -	{
> -	  output_asm_insn ("call\t%a2", xops);
> -#ifdef DWARF2_UNWIND_INFO
> -	  /* The call to next label acts as a push.  */
> -	  if (dwarf2out_do_frame ())
> -	    {
> -	      rtx insn;
> -	      start_sequence ();
> -	      insn = emit_insn (gen_rtx_SET (VOIDmode, stack_pointer_rtx,
> -					     gen_rtx_PLUS (Pmode,
> -							   stack_pointer_rtx,
> -							   GEN_INT (-4))));
> -	      RTX_FRAME_RELATED_P (insn) = 1;
> -	      dwarf2out_frame_debug (insn, true);
> -	      end_sequence ();
> -	    }
> -#endif
> -	}
> +      output_asm_insn ("mov%z0\t{%2, %0|%0, %2}", xops);
>  
>  #if TARGET_MACHO
>        /* Output the Mach-O "canonical" label name ("Lxx$pb") here too.  This
> @@ -8358,29 +8333,6 @@ output_set_got (rtx dest, rtx label ATTRIBUTE_UNUSED)
>  
>        targetm.asm_out.internal_label (asm_out_file, "L",
>  				      CODE_LABEL_NUMBER (XEXP (xops[2], 0)));
> -
> -      if (flag_pic)
> -	{
> -	  output_asm_insn ("pop%z0\t%0", xops);
> -#ifdef DWARF2_UNWIND_INFO
> -	  /* The pop is a pop and clobbers dest, but doesn't restore it
> -	     for unwind info purposes.  */
> -	  if (dwarf2out_do_frame ())
> -	    {
> -	      rtx insn;
> -	      start_sequence ();
> -	      insn = emit_insn (gen_rtx_SET (VOIDmode, dest, const0_rtx));
> -	      dwarf2out_frame_debug (insn, true);
> -	      insn = emit_insn (gen_rtx_SET (VOIDmode, stack_pointer_rtx,
> -					     gen_rtx_PLUS (Pmode,
> -							   stack_pointer_rtx,
> -							   GEN_INT (4))));
> -	      RTX_FRAME_RELATED_P (insn) = 1;
> -	      dwarf2out_frame_debug (insn, true);
> -	      end_sequence ();
> -	    }
> -#endif
> -	}
>      }
>    else
>      {
> @@ -8388,12 +8340,6 @@ output_set_got (rtx dest, rtx label ATTRIBUTE_UNUSED)
>        get_pc_thunk_name (name, REGNO (dest));
>        pic_labels_used |= 1 << REGNO (dest);
>  
> -#ifdef DWARF2_UNWIND_INFO
> -      /* Ensure all queued register saves are flushed before the
> -	 call.  */
> -      if (dwarf2out_do_frame ())
> -	dwarf2out_flush_queued_reg_saves ();
> -#endif
>        xops[2] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (name));
>        xops[2] = gen_rtx_MEM (QImode, xops[2]);
>        output_asm_insn ("call\t%X2", xops);
> @@ -8408,13 +8354,8 @@ output_set_got (rtx dest, rtx label ATTRIBUTE_UNUSED)
>  #endif
>      }
>  
> -  if (TARGET_MACHO)
> -    return "";
> -
> -  if (!flag_pic || TARGET_DEEP_BRANCH_PREDICTION)
> +  if (!TARGET_MACHO)
>      output_asm_insn ("add%z0\t{%1, %0|%0, %1}", xops);
> -  else
> -    output_asm_insn ("add%z0\t{%1+[.-%a2], %0|%0, %1+(.-%a2)}", xops);
>  
>    return "";
>  }
> @@ -10138,7 +10079,11 @@ ix86_expand_prologue (void)
>              insn = emit_insn (gen_set_got_rex64 (pic_offset_table_rtx));
>  	}
>        else
> -        insn = emit_insn (gen_set_got (pic_offset_table_rtx));
> +	{
> +          insn = emit_insn (gen_set_got (pic_offset_table_rtx));
> +	  RTX_FRAME_RELATED_P (insn) = 1;
> +	  add_reg_note (insn, REG_CFA_FLUSH_QUEUE, NULL_RTX);
> +	}
>      }
>  
>    /* In the pic_reg_used case, make sure that the got load isn't deleted
> @@ -28979,12 +28924,7 @@ machopic_output_stub (FILE *file, const char *symb, const char *stub)
>    if (MACHOPIC_ATT_STUB)
>      switch_to_section (darwin_sections[machopic_picsymbol_stub3_section]);
>    else if (MACHOPIC_PURE)
> -    {
> -      if (TARGET_DEEP_BRANCH_PREDICTION)
> -	switch_to_section (darwin_sections[machopic_picsymbol_stub2_section]);
> -      else
> -    switch_to_section (darwin_sections[machopic_picsymbol_stub_section]);
> -    }
> +    switch_to_section (darwin_sections[machopic_picsymbol_stub2_section]);
>    else
>      switch_to_section (darwin_sections[machopic_symbol_stub_section]);
>  
> @@ -28998,19 +28938,11 @@ machopic_output_stub (FILE *file, const char *symb, const char *stub)
>    else if (MACHOPIC_PURE)
>      {
>        /* PIC stub.  */
> -      if (TARGET_DEEP_BRANCH_PREDICTION)
> -	{
> -	  /* 25-byte PIC stub using "CALL get_pc_thunk".  */
> -	  rtx tmp = gen_rtx_REG (SImode, 2 /* ECX */);
> -	  output_set_got (tmp, NULL_RTX);	/* "CALL ___<cpu>.get_pc_thunk.cx".  */
> -	  fprintf (file, "LPC$%d:\tmovl\t%s-LPC$%d(%%ecx),%%ecx\n", label, lazy_ptr_name, label);
> -	}
> -      else
> -	{
> -	  /* 26-byte PIC stub using inline picbase: "CALL L42 ! L42: pop %eax".  */
> -	  fprintf (file, "\tcall LPC$%d\nLPC$%d:\tpopl %%ecx\n", label, label);
> -	  fprintf (file, "\tmovl %s-LPC$%d(%%ecx),%%ecx\n", lazy_ptr_name, label);
> -	}
> +      /* 25-byte PIC stub using "CALL get_pc_thunk".  */
> +      rtx tmp = gen_rtx_REG (SImode, 2 /* ECX */);
> +      output_set_got (tmp, NULL_RTX);	/* "CALL ___<cpu>.get_pc_thunk.cx".  */
> +      fprintf (file, "LPC$%d:\tmovl\t%s-LPC$%d(%%ecx),%%ecx\n",
> +	       label, lazy_ptr_name, label);
>        fprintf (file, "\tjmp\t*%%ecx\n");
>      }
>    else
> @@ -29039,13 +28971,8 @@ machopic_output_stub (FILE *file, const char *symb, const char *stub)
>       compatibility with existing dylibs.  */
>    if (MACHOPIC_PURE)
>      {
> -      /* PIC stubs.  */
> -      if (TARGET_DEEP_BRANCH_PREDICTION)
> -	/* 25-byte PIC stub using "CALL get_pc_thunk".  */
> -	switch_to_section (darwin_sections[machopic_lazy_symbol_ptr2_section]);
> -      else
> -	/* 26-byte PIC stub using inline picbase: "CALL L42 ! L42: pop %ebx".  */
> -  switch_to_section (darwin_sections[machopic_lazy_symbol_ptr_section]);
> +      /* 25-byte PIC stub using "CALL get_pc_thunk".  */
> +      switch_to_section (darwin_sections[machopic_lazy_symbol_ptr2_section]);
>      }
>    else
>      /* 16-byte -mdynamic-no-pic stub.  */
> diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
> index 8badcbb..1452226 100644
> --- a/gcc/config/i386/i386.h
> +++ b/gcc/config/i386/i386.h
> @@ -249,7 +249,6 @@ enum ix86_tune_indices {
>    X86_TUNE_PUSH_MEMORY,
>    X86_TUNE_ZERO_EXTEND_WITH_AND,
>    X86_TUNE_UNROLL_STRLEN,
> -  X86_TUNE_DEEP_BRANCH_PREDICTION,
>    X86_TUNE_BRANCH_PREDICTION_HINTS,
>    X86_TUNE_DOUBLE_WITH_ADD,
>    X86_TUNE_USE_SAHF,
> @@ -323,8 +322,6 @@ extern unsigned char ix86_tune_features[X86_TUNE_LAST];
>  #define TARGET_ZERO_EXTEND_WITH_AND \
>  	ix86_tune_features[X86_TUNE_ZERO_EXTEND_WITH_AND]
>  #define TARGET_UNROLL_STRLEN	ix86_tune_features[X86_TUNE_UNROLL_STRLEN]
> -#define TARGET_DEEP_BRANCH_PREDICTION \
> -	ix86_tune_features[X86_TUNE_DEEP_BRANCH_PREDICTION]
>  #define TARGET_BRANCH_PREDICTION_HINTS \
>  	ix86_tune_features[X86_TUNE_BRANCH_PREDICTION_HINTS]
>  #define TARGET_DOUBLE_WITH_ADD	ix86_tune_features[X86_TUNE_DOUBLE_WITH_ADD]
> -- 
> 1.7.5.4

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2011-09-02 11:17 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-29 21:50 [PATCH 00/12] Eliminate the text-based dwarf2out interface Richard Henderson
2011-06-29 21:50 ` [PATCH 05/12] arm: Use REG_CFA_REGISTER instead of UNSPEC_STACK_ALIGN Richard Henderson
2011-06-29 21:50 ` [PATCH 07/12] ia64: Remove ia64_dwarf2out_def_steady_cfa Richard Henderson
2011-06-29 21:50 ` [PATCH 10/12] ia64: Remove TARGET_DWARF_HANDLE_FRAME_UNSPEC hook Richard Henderson
2011-06-29 21:50 ` [PATCH 12/12] dwarf2out: Remove unused text-based unwind entry points Richard Henderson
2011-06-29 21:51 ` [PATCH 09/12] ia64: Remove dead code in process_epilogue Richard Henderson
2011-06-29 21:51 ` [PATCH 01/12] dwarf2out: Convert regs_saved_in_regs to VEC Richard Henderson
2011-06-29 21:51 ` [PATCH 02/12] dwarf2out: Handle pc_rtx as return column in REG_CFA_OFFSET too Richard Henderson
2011-06-29 21:54 ` [PATCH 11/12] i386: Always use TARGET_DEEP_BRANCH_PREDICTION Richard Henderson
2011-09-02 11:17   ` Jan Hubicka
2011-06-29 22:26 ` [PATCH 04/12] vax: Emit prologue as rtl Richard Henderson
2011-06-29 23:19   ` Steven Bosscher
2011-06-29 23:34     ` Richard Henderson
2011-06-30 17:41     ` Richard Henderson
2011-06-30 17:47       ` Paul Koning
2011-06-29 22:27 ` [PATCH 06/12] ia64: Issue REG_CFA_REGISTER for ar.pfs at alloc insn Richard Henderson
2011-06-29 22:27 ` [PATCH 08/12] ia64: Use pc_rtx to save the return address Richard Henderson
2011-06-29 22:33 ` [PATCH 03/12] dwarf2out: Add REG_CFA_FLUSH_QUEUE Richard Henderson
2011-06-30 13:20 ` [PATCH 00/12] Eliminate the text-based dwarf2out interface Bernd Schmidt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).