[gcc/devel/ranger] IBM Z: zTPF: Add tpf trace customization options

Aldy Hernandez aldyh@gcc.gnu.org
Wed Jun 17 19:25:28 GMT 2020


https://gcc.gnu.org/g:181e2a2fa5e6d444a0aee95add450e5bcc659ca9

commit 181e2a2fa5e6d444a0aee95add450e5bcc659ca9
Author: Andreas Krebbel <krebbel@linux.ibm.com>
Date:   Wed Mar 4 13:29:38 2020 +0100

    IBM Z: zTPF: Add tpf trace customization options
    
    The zTPF OS implements a tracing facility for function entry and exit
    which uses global flags and trace function addresses. The addresses of
    the flags as well as the trace functions are currently hard-coded in
    the zTPF specific GCC parts of the IBM Z back-end.
    
    With this patch these addresses can be changed at compile-time using
    the new command line options.  For convenience one additional command
    line option (-mtpf-trace-skip) implements a new set of hard-coded
    addresses.
    
    gcc/ChangeLog:
    
    2020-03-04  Andreas Krebbel  <krebbel@linux.ibm.com>
    
            * config/s390/s390.c (s390_emit_prologue): Specify the 2 new
            operands to the prologue_tpf expander.
            (s390_emit_epilogue): Likewise.
            (s390_option_override_internal): Do error checking and setup for
            the new options.
            * config/s390/tpf.h (TPF_TRACE_PROLOGUE_CHECK)
            (TPF_TRACE_EPILOGUE_CHECK, TPF_TRACE_PROLOGUE_TARGET)
            (TPF_TRACE_EPILOGUE_TARGET, TPF_TRACE_PROLOGUE_SKIP_TARGET)
            (TPF_TRACE_EPILOGUE_SKIP_TARGET): New macro definitions.
            * config/s390/tpf.md ("prologue_tpf", "epilogue_tpf"): Add two new
            operands for the check flag and the branch target.
            * config/s390/tpf.opt ("mtpf-trace-hook-prologue-check")
            ("mtpf-trace-hook-prologue-target")
            ("mtpf-trace-hook-epilogue-check")
            ("mtpf-trace-hook-epilogue-target", "mtpf-trace-skip"): New
            options.
            * doc/invoke.texi: Document -mtpf-trace-skip option. The other
            options are for debugging purposes and will not be documented
            here.

Diff:
---
 gcc/config/s390/s390.c  | 53 +++++++++++++++++++++++++++++++++++++------------
 gcc/config/s390/tpf.h   | 16 +++++++++++++++
 gcc/config/s390/tpf.md  | 12 +++++++----
 gcc/config/s390/tpf.opt | 20 +++++++++++++++++++
 gcc/doc/invoke.texi     | 13 +++++++++++-
 5 files changed, 96 insertions(+), 18 deletions(-)

diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index ebba6704852..31af842eb35 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -11363,17 +11363,21 @@ s390_emit_prologue (void)
       emit_insn (insns);
     }
 
+#if TARGET_TPF != 0
   if (TARGET_TPF_PROFILING)
     {
-      /* Generate a BAS instruction to serve as a function
-	 entry intercept to facilitate the use of tracing
-	 algorithms located at the branch target.  */
-      emit_insn (gen_prologue_tpf ());
+      /* Generate a BAS instruction to serve as a function entry
+	 intercept to facilitate the use of tracing algorithms located
+	 at the branch target.  */
+      emit_insn (gen_prologue_tpf (
+		   GEN_INT (s390_tpf_trace_hook_prologue_check),
+		   GEN_INT (s390_tpf_trace_hook_prologue_target)));
 
-      /* Emit a blockage here so that all code
-	 lies between the profiling mechanisms.  */
+      /* Emit a blockage here so that all code lies between the
+	 profiling mechanisms.  */
       emit_insn (gen_blockage ());
     }
+#endif
 }
 
 /* Expand the epilogue into a bunch of separate insns.  */
@@ -11386,19 +11390,22 @@ s390_emit_epilogue (bool sibcall)
   int next_offset;
   int i;
 
+#if TARGET_TPF != 0
   if (TARGET_TPF_PROFILING)
     {
+      /* Generate a BAS instruction to serve as a function entry
+	 intercept to facilitate the use of tracing algorithms located
+	 at the branch target.  */
 
-      /* Generate a BAS instruction to serve as a function
-	 entry intercept to facilitate the use of tracing
-	 algorithms located at the branch target.  */
-
-      /* Emit a blockage here so that all code
-	 lies between the profiling mechanisms.  */
+      /* Emit a blockage here so that all code lies between the
+	 profiling mechanisms.  */
       emit_insn (gen_blockage ());
 
-      emit_insn (gen_epilogue_tpf ());
+      emit_insn (gen_epilogue_tpf (
+		   GEN_INT (s390_tpf_trace_hook_epilogue_check),
+		   GEN_INT (s390_tpf_trace_hook_epilogue_target)));
     }
+#endif
 
   /* Check whether to use frame or stack pointer for restore.  */
 
@@ -15266,6 +15273,26 @@ s390_option_override_internal (struct gcc_options *opts,
   if (!DISP_IN_RANGE ((1 << param_stack_clash_protection_probe_interval)))
     param_stack_clash_protection_probe_interval = 12;
 
+#if TARGET_TPF != 0
+  if (!CONST_OK_FOR_J (opts->x_s390_tpf_trace_hook_prologue_check))
+    error ("-mtpf-trace-hook-prologue-check requires integer in range 0..4095");
+
+  if (!CONST_OK_FOR_J (opts->x_s390_tpf_trace_hook_prologue_target))
+    error ("-mtpf-trace-hook-prologue-target requires integer in range 0..4095");
+
+  if (!CONST_OK_FOR_J (opts->x_s390_tpf_trace_hook_epilogue_check))
+    error ("-mtpf-trace-hook-epilogue-check requires integer in range 0..4095");
+
+  if (!CONST_OK_FOR_J (opts->x_s390_tpf_trace_hook_epilogue_target))
+    error ("-mtpf-trace-hook-epilogue-target requires integer in range 0..4095");
+
+  if (s390_tpf_trace_skip)
+    {
+      opts->x_s390_tpf_trace_hook_prologue_target = TPF_TRACE_PROLOGUE_SKIP_TARGET;
+      opts->x_s390_tpf_trace_hook_epilogue_target = TPF_TRACE_EPILOGUE_SKIP_TARGET;
+    }
+#endif
+
 #ifdef TARGET_DEFAULT_LONG_DOUBLE_128
   if (!TARGET_LONG_DOUBLE_128_P (opts_set->x_target_flags))
     opts->x_target_flags |= MASK_LONG_DOUBLE_128;
diff --git a/gcc/config/s390/tpf.h b/gcc/config/s390/tpf.h
index d83b1ae4785..22adf27c30b 100644
--- a/gcc/config/s390/tpf.h
+++ b/gcc/config/s390/tpf.h
@@ -131,4 +131,20 @@ along with GCC; see the file COPYING3.  If not see
 /* GAS supports it, but the debuggers don't, so avoid it.  */
 #define SUPPORTS_DISCRIMINATOR 0
 
+/* z/TPF hardcoded values for the -mtpf-trace feature.  */
+
+/* The *_CHECK value specify addresses in the lowcore whose byte
+   values can be used to turn on/off the tracing.  */
+#define TPF_TRACE_PROLOGUE_CHECK 4065
+#define TPF_TRACE_EPILOGUE_CHECK 4071
+
+/* The target addresses for the z/TPF trace facility.  */
+#define TPF_TRACE_PROLOGUE_TARGET 4064
+#define TPF_TRACE_EPILOGUE_TARGET 4070
+
+/* Alternate target addresses for the z/TPF trace facility.  These
+   will be used with the -mtpf-trace-skip switch.  */
+#define TPF_TRACE_PROLOGUE_SKIP_TARGET 4076
+#define TPF_TRACE_EPILOGUE_SKIP_TARGET 4082
+
 #endif /* ! _TPF_H */
diff --git a/gcc/config/s390/tpf.md b/gcc/config/s390/tpf.md
index af814f402e3..19c53a18b8a 100644
--- a/gcc/config/s390/tpf.md
+++ b/gcc/config/s390/tpf.md
@@ -18,16 +18,20 @@
 ;; <http://www.gnu.org/licenses/>.
 
 (define_insn "prologue_tpf"
-  [(unspec_volatile [(const_int 0)] UNSPECV_TPF_PROLOGUE)
+  [(unspec_volatile [(match_operand 0 "const_int_operand" "J")
+		     (match_operand 1 "const_int_operand" "J")]
+		    UNSPECV_TPF_PROLOGUE)
    (clobber (reg:DI 1))]
   "TARGET_TPF_PROFILING"
-  "larl\t%%r1,.+14\;tm\t4065,255\;bnz\t4064"
+  "larl\t%%r1,.+14\;tm\t%0,255\;bnz\t%1"
   [(set_attr "length"   "14")])
 
 
 (define_insn "epilogue_tpf"
-  [(unspec_volatile [(const_int 0)] UNSPECV_TPF_EPILOGUE)
+  [(unspec_volatile [(match_operand 0 "const_int_operand" "J")
+		     (match_operand 1 "const_int_operand" "J")]
+		    UNSPECV_TPF_EPILOGUE)
    (clobber (reg:DI 1))]
   "TARGET_TPF_PROFILING"
-  "larl\t%%r1,.+14\;tm\t4071,255\;bnz\t4070"
+  "larl\t%%r1,.+14\;tm\t%0,255\;bnz\t%1"
   [(set_attr "length"   "14")])
diff --git a/gcc/config/s390/tpf.opt b/gcc/config/s390/tpf.opt
index 90ab503f75a..9876a55c57f 100644
--- a/gcc/config/s390/tpf.opt
+++ b/gcc/config/s390/tpf.opt
@@ -22,6 +22,26 @@ mtpf-trace
 Target Report Mask(TPF_PROFILING)
 Enable TPF-OS tracing code.
 
+mtpf-trace-hook-prologue-check=
+Target RejectNegative Report Joined UInteger Var(s390_tpf_trace_hook_prologue_check) Init(TPF_TRACE_PROLOGUE_CHECK)
+Set the trace check address for prologue tpf hook
+
+mtpf-trace-hook-prologue-target=
+Target RejectNegative Report Joined UInteger Var(s390_tpf_trace_hook_prologue_target) Init(TPF_TRACE_PROLOGUE_TARGET)
+Set the trace jump address for prologue tpf hook
+
+mtpf-trace-hook-epilogue-check=
+Target RejectNegative Report Joined UInteger Var(s390_tpf_trace_hook_epilogue_check) Init(TPF_TRACE_EPILOGUE_CHECK)
+Set the trace check address for epilogue tpf hook
+
+mtpf-trace-hook-epilogue-target=
+Target RejectNegative Report Joined UInteger Var(s390_tpf_trace_hook_epilogue_target) Init(TPF_TRACE_EPILOGUE_TARGET)
+Set the trace jump address for epilogue tpf hook
+
+mtpf-trace-skip
+Target Report Var(s390_tpf_trace_skip) Init(0)
+Set the prologue and epilogue hook addresses to TPF_TRACE_PROLOGUE_SKIP_TARGET and TPF_TRACE_EPILOGUE_SKIP_TARGET. Equivalent to using -mtpf-trace-hook-prologue-target=TPF_TRACE_PROLOGUE_SKIP_TARGET and -mtpf-trace-hook-epilogue-target=TPF_TRACE_EPILOGUE_SKIP_TARGET
+
 mmain
 Target Report
 Specify main object for TPF-OS.
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index f51729d0e39..af28015234c 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -1223,7 +1223,8 @@ See RS/6000 and PowerPC Options.
 -msmall-exec  -mno-small-exec  -mmvcle  -mno-mvcle @gol
 -m64  -m31  -mdebug  -mno-debug  -mesa  -mzarch @gol
 -mhtm  -mvx  -mzvector @gol
--mtpf-trace  -mno-tpf-trace  -mfused-madd  -mno-fused-madd @gol
+-mtpf-trace  -mno-tpf-trace  -mtpf-trace-skip  -mno-tpf-trace-skip @gol
+-mfused-madd  -mno-fused-madd @gol
 -mwarn-framesize  -mwarn-dynamicstack  -mstack-size  -mstack-guard @gol
 -mhotpatch=@var{halfwords},@var{halfwords}}
 
@@ -26953,6 +26954,16 @@ Generate code that adds (does not add) in TPF OS specific branches to trace
 routines in the operating system.  This option is off by default, even
 when compiling for the TPF OS@.
 
+@item -mtpf-trace-skip
+@itemx -mno-tpf-trace-skip
+@opindex mtpf-trace-skip
+@opindex mno-tpf-trace-skip
+Generate code that changes (does not change) the default branch
+targets enabled by @option{-mtpf-trace} to point to specialized trace
+routines providing the ability of selectively skipping function trace
+entries for the TPF OS.  This option is off by default, even when
+compiling for the TPF OS and specifying @option{-mtpf-trace}.
+
 @item -mfused-madd
 @itemx -mno-fused-madd
 @opindex mfused-madd


More information about the Gcc-cvs mailing list