]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
IBM Z: zTPF: Add tpf trace customization options
authorAndreas Krebbel <krebbel@linux.ibm.com>
Wed, 4 Mar 2020 12:29:38 +0000 (13:29 +0100)
committerAndreas Krebbel <krebbel@linux.ibm.com>
Wed, 4 Mar 2020 12:30:22 +0000 (13:30 +0100)
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.

gcc/config/s390/s390.c
gcc/config/s390/tpf.h
gcc/config/s390/tpf.md
gcc/config/s390/tpf.opt
gcc/doc/invoke.texi

index ebba670485253fdb109e3db7e4d6e4f7b6c7d1ab..31af842eb352610fceb7bbbf9e47ce2291c6b355 100644 (file)
@@ -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;
index d83b1ae4785f4acddfd38a09fe3ad27394623c20..22adf27c30b5e756d16d500380b5a6198100f52c 100644 (file)
@@ -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 */
index af814f402e3b0a5f7b63878a09ba8817847da0ce..19c53a18b8ae4909a42848ccc1fd7510125c95ba 100644 (file)
 ;; <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")])
index 90ab503f75aaa79071274928778813d401b961b8..9876a55c57f54d0c0f6934c8387d72cb6472baca 100644 (file)
@@ -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.
index f51729d0e399302e104d45436b987cbac4491151..af28015234c7e8cd4a2a081f3abbc801eac951cb 100644 (file)
@@ -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