re PR target/19889 (g++.old-deja/g++.law/profile1.C execution test fails on ia64...
authorSteve Ellcey <sje@cup.hp.com>
Fri, 17 Jun 2005 20:45:50 +0000 (20:45 +0000)
committerSteve Ellcey <sje@gcc.gnu.org>
Fri, 17 Jun 2005 20:45:50 +0000 (20:45 +0000)
PR target/19889
* config/ia64/hpux.h (FUNCTION_PROFILER): New (dummy).
(PROFILE_HOOK): New.
(PROFILE_BEFORE_PROLOGUE): Undef.
(NO_PROFILE_COUNTERS): New.
* config/ia64/ia64-protos.h (ia64_profile_hook): New.
* config/ia64/ia64.c (ia64_compute_frame_size): Add ifdef.
(gen_mcount_func_rtx): New.
(ia64_profile_hook): New.
* config/ia64/ia64.md (ip_value): New.

From-SVN: r101134

gcc/ChangeLog
gcc/config/ia64/hpux.h
gcc/config/ia64/ia64-protos.h
gcc/config/ia64/ia64.c
gcc/config/ia64/ia64.md

index ae8f419a343f759aef566f9efa7698fa0dd028a5..c48bf43f7ceb4ed442c6c60181f71ee38f2a12ec 100644 (file)
@@ -1,3 +1,16 @@
+2005-06-17  Steve Ellcey  <sje@cup.hp.com>
+
+       PR target/19889
+       * config/ia64/hpux.h (FUNCTION_PROFILER): New (dummy).
+       (PROFILE_HOOK): New.
+       (PROFILE_BEFORE_PROLOGUE): Undef.
+       (NO_PROFILE_COUNTERS): New.
+       * config/ia64/ia64-protos.h (ia64_profile_hook): New.
+       * config/ia64/ia64.c (ia64_compute_frame_size): Add ifdef.
+       (gen_mcount_func_rtx): New.
+       (ia64_profile_hook): New.
+       * config/ia64/ia64.md (ip_value): New.
+
 2005-06-17  Devang Patel  <dpatel@apple.com>
 
        * config/rs6000/predicates.md (s5bit_cint_operand,
index 396094fc6682fee14bb1cb7c2fd1ff57a6e3cc15..6423124bb9fb38a31425fc9a9205d72db4ad895a 100644 (file)
@@ -208,3 +208,18 @@ do {                                                               \
 
 /* HP-UX headers are C++-compatible.  */
 #define NO_IMPLICIT_EXTERN_C
+
+/* HP-UX uses PROFILE_HOOK instead of FUNCTION_PROFILER but we need a
+   FUNCTION_PROFILER defined because its use is not ifdefed.  When using
+   PROFILE_HOOK, the profile call comes after the prologue.  */
+
+#undef FUNCTION_PROFILER
+#define FUNCTION_PROFILER(FILE, LABELNO) do { } while (0)
+
+#undef PROFILE_HOOK
+#define PROFILE_HOOK(LABEL) ia64_profile_hook (LABEL)
+
+#undef  PROFILE_BEFORE_PROLOGUE
+
+#undef NO_PROFILE_COUNTERS
+#define NO_PROFILE_COUNTERS 0
index 7b097bf56c4586b1eb1b9a073860e43f2166e30f..e3e1560e559e8f27c25688b87d86d496454002d9 100644 (file)
@@ -114,3 +114,4 @@ extern enum direction ia64_hpux_function_arg_padding (enum machine_mode, tree);
 
 extern void ia64_hpux_handle_builtin_pragma (struct cpp_reader *);
 extern void ia64_output_function_profiler (FILE *, int);
+extern void ia64_profile_hook (int);
index dc701e4dc58c1d4bf634a4abbe1384c6cc5dd966..8d20992227164b38ace9661ba37d678dd58adc00 100644 (file)
@@ -2087,12 +2087,14 @@ ia64_compute_frame_size (HOST_WIDE_INT size)
       break;
   i = regno - OUT_REG (0) + 1;
 
+#ifndef PROFILE_HOOK
   /* When -p profiling, we need one output register for the mcount argument.
      Likewise for -a profiling for the bb_init_func argument.  For -ax
      profiling, we need two output registers for the two bb_init_trace_func
      arguments.  */
   if (current_function_profile)
     i = MAX (i, 1);
+#endif
   current_frame_info.n_output_regs = i;
 
   /* ??? No rotating register support yet.  */
@@ -8579,4 +8581,38 @@ ia64_output_function_profiler (FILE *file, int labelno)
   fputs ("\tbr.call.sptk.many b0 = _mcount\n\t;;\n", file);
 }
 
+static GTY(()) rtx mcount_func_rtx;
+static rtx
+gen_mcount_func_rtx (void)
+{
+  if (!mcount_func_rtx)
+    mcount_func_rtx = init_one_libfunc ("_mcount");
+  return mcount_func_rtx;
+}
+
+void
+ia64_profile_hook (int labelno)
+{
+  rtx label, ip;
+
+  if (NO_PROFILE_COUNTERS)
+    label = const0_rtx;
+  else
+    {
+      char buf[30];
+      const char *label_name;
+      ASM_GENERATE_INTERNAL_LABEL (buf, "LP", labelno);
+      label_name = (*targetm.strip_name_encoding) (ggc_strdup (buf));
+      label = gen_rtx_SYMBOL_REF (Pmode, label_name);
+      SYMBOL_REF_FLAGS (label) = SYMBOL_FLAG_LOCAL;
+    }
+  ip = gen_reg_rtx (Pmode);
+  emit_insn (gen_ip_value (ip));
+  emit_library_call (gen_mcount_func_rtx (), LCT_NORMAL,
+                     VOIDmode, 3,
+                    gen_rtx_REG (Pmode, BR_REG (0)), Pmode,
+                    ip, Pmode,
+                    label, Pmode);
+}
+
 #include "gt-ia64.h"
index 7260678504babded425fcd24c88acbc807a5cdc5..0accd9603999a09b156061e6d92331ae5d6e4d32 100644 (file)
   "addp4 %0 = %1, %2"
   [(set_attr "itanium_class" "ialu")])
 
+;;
+;; Get instruction pointer
+
+(define_insn "ip_value"
+  [(set (match_operand:DI 0 "register_operand" "=r")
+        (pc))]
+ ""
+ "mov %0 = ip"
+  [(set_attr "itanium_class" "ialu")])
+
 ;; Vector operations
 (include "vect.md")
 ;; Atomic operations