|
|
31fb32 |
diff -Nrup gcc/config/s390/s390.c gcc/config/s390/s390.c
|
|
|
31fb32 |
--- gcc/config/s390/s390.c 2018-03-27 09:33:20.158140823 -0600
|
|
|
31fb32 |
+++ gcc/config/s390/s390.c 2018-03-27 09:33:58.826861609 -0600
|
|
|
31fb32 |
@@ -958,6 +958,35 @@ s390_expand_builtin (tree exp, rtx targe
|
|
|
31fb32 |
}
|
|
|
31fb32 |
|
|
|
31fb32 |
|
|
|
31fb32 |
+/* Masks per jump target register indicating which thunk need to be
|
|
|
31fb32 |
+ generated. */
|
|
|
31fb32 |
+static GTY(()) int indirect_branch_prez10thunk_mask = 0;
|
|
|
31fb32 |
+static GTY(()) int indirect_branch_z10thunk_mask = 0;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+#define INDIRECT_BRANCH_NUM_OPTIONS 4
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+enum s390_indirect_branch_option
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ s390_opt_indirect_branch_jump = 0,
|
|
|
31fb32 |
+ s390_opt_indirect_branch_call,
|
|
|
31fb32 |
+ s390_opt_function_return_reg,
|
|
|
31fb32 |
+ s390_opt_function_return_mem
|
|
|
31fb32 |
+ };
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+static GTY(()) int indirect_branch_table_label_no[INDIRECT_BRANCH_NUM_OPTIONS] = { 0 };
|
|
|
31fb32 |
+const char *indirect_branch_table_label[INDIRECT_BRANCH_NUM_OPTIONS] = \
|
|
|
31fb32 |
+ { "LJUMP", "LCALL", "LRETREG", "LRETMEM" };
|
|
|
31fb32 |
+const char *indirect_branch_table_name[INDIRECT_BRANCH_NUM_OPTIONS] = \
|
|
|
31fb32 |
+ { ".s390_indirect_jump", ".s390_indirect_call",
|
|
|
31fb32 |
+ ".s390_return_reg", ".s390_return_mem" };
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+bool
|
|
|
31fb32 |
+s390_return_addr_from_memory ()
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ return (cfun_frame_layout.first_save_gpr <= RETURN_REGNUM
|
|
|
31fb32 |
+ && cfun_frame_layout.last_save_gpr >= RETURN_REGNUM);
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
static const int s390_hotpatch_hw_max = 1000000;
|
|
|
31fb32 |
static int s390_hotpatch_hw_before_label = 0;
|
|
|
31fb32 |
static int s390_hotpatch_hw_after_label = 0;
|
|
|
31fb32 |
@@ -2669,6 +2698,34 @@ s390_option_override (void)
|
|
|
31fb32 |
if (TARGET_64BIT && !TARGET_ZARCH)
|
|
|
31fb32 |
error ("64-bit ABI not supported in ESA/390 mode");
|
|
|
31fb32 |
|
|
|
31fb32 |
+ if (s390_indirect_branch != indirect_branch_keep)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ if (!global_options_set.x_s390_indirect_branch_call)
|
|
|
31fb32 |
+ s390_indirect_branch_call = s390_indirect_branch;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ if (!global_options_set.x_s390_indirect_branch_jump)
|
|
|
31fb32 |
+ s390_indirect_branch_jump = s390_indirect_branch;
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ if (s390_function_return != indirect_branch_keep)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ if (!global_options_set.x_s390_function_return_reg)
|
|
|
31fb32 |
+ s390_function_return_reg = s390_function_return;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ if (!global_options_set.x_s390_function_return_mem)
|
|
|
31fb32 |
+ s390_function_return_mem = s390_function_return;
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ if (!TARGET_CPU_ZARCH)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ if (s390_indirect_branch_call != indirect_branch_keep
|
|
|
31fb32 |
+ || s390_indirect_branch_jump != indirect_branch_keep)
|
|
|
31fb32 |
+ error ("-mindirect-branch* options require -march=z900 or higher");
|
|
|
31fb32 |
+ if (s390_function_return_reg != indirect_branch_keep
|
|
|
31fb32 |
+ || s390_function_return_mem != indirect_branch_keep)
|
|
|
31fb32 |
+ error ("-mfunction-return* options require -march=z900 or higher");
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+
|
|
|
31fb32 |
/* Use hardware DFP if available and not explicitly disabled by
|
|
|
31fb32 |
user. E.g. with -m31 -march=z10 -mzarch */
|
|
|
31fb32 |
if (!(target_flags_explicit & MASK_HARD_DFP) && TARGET_DFP)
|
|
|
31fb32 |
@@ -10873,7 +10930,6 @@ s390_emit_epilogue (bool sibcall)
|
|
|
31fb32 |
rtx frame_pointer, return_reg, cfa_restores = NULL_RTX;
|
|
|
31fb32 |
int area_bottom, area_top, offset = 0;
|
|
|
31fb32 |
int next_offset;
|
|
|
31fb32 |
- rtvec p;
|
|
|
31fb32 |
int i;
|
|
|
31fb32 |
|
|
|
31fb32 |
if (TARGET_TPF_PROFILING)
|
|
|
31fb32 |
@@ -11023,8 +11079,14 @@ s390_emit_epilogue (bool sibcall)
|
|
|
31fb32 |
&& cfun_frame_layout.last_restore_gpr > RETURN_REGNUM))
|
|
|
31fb32 |
{
|
|
|
31fb32 |
int return_regnum = find_unused_clobbered_reg();
|
|
|
31fb32 |
- if (!return_regnum)
|
|
|
31fb32 |
- return_regnum = 4;
|
|
|
31fb32 |
+ if (!return_regnum
|
|
|
31fb32 |
+ || (TARGET_INDIRECT_BRANCH_NOBP_RET_OPTION
|
|
|
31fb32 |
+ && !TARGET_CPU_Z10
|
|
|
31fb32 |
+ && return_regnum == INDIRECT_BRANCH_THUNK_REGNUM))
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ gcc_assert (INDIRECT_BRANCH_THUNK_REGNUM != 4);
|
|
|
31fb32 |
+ return_regnum = 4;
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
return_reg = gen_rtx_REG (Pmode, return_regnum);
|
|
|
31fb32 |
|
|
|
31fb32 |
addr = plus_constant (Pmode, frame_pointer,
|
|
|
31fb32 |
@@ -11054,16 +11116,7 @@ s390_emit_epilogue (bool sibcall)
|
|
|
31fb32 |
}
|
|
|
31fb32 |
|
|
|
31fb32 |
if (! sibcall)
|
|
|
31fb32 |
- {
|
|
|
31fb32 |
-
|
|
|
31fb32 |
- /* Return to caller. */
|
|
|
31fb32 |
-
|
|
|
31fb32 |
- p = rtvec_alloc (2);
|
|
|
31fb32 |
-
|
|
|
31fb32 |
- RTVEC_ELT (p, 0) = ret_rtx;
|
|
|
31fb32 |
- RTVEC_ELT (p, 1) = gen_rtx_USE (VOIDmode, return_reg);
|
|
|
31fb32 |
- emit_jump_insn (gen_rtx_PARALLEL (VOIDmode, p));
|
|
|
31fb32 |
- }
|
|
|
31fb32 |
+ emit_jump_insn (gen_return_use (return_reg));
|
|
|
31fb32 |
}
|
|
|
31fb32 |
|
|
|
31fb32 |
|
|
|
31fb32 |
@@ -12371,6 +12424,84 @@ s390_output_mi_thunk (FILE *file, tree t
|
|
|
31fb32 |
final_end_function ();
|
|
|
31fb32 |
}
|
|
|
31fb32 |
|
|
|
31fb32 |
+/* Output either an indirect jump or a an indirect call
|
|
|
31fb32 |
+ (RETURN_ADDR_REGNO != INVALID_REGNUM) with target register REGNO
|
|
|
31fb32 |
+ using a branch trampoline disabling branch target prediction. */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+void
|
|
|
31fb32 |
+s390_indirect_branch_via_thunk (unsigned int regno,
|
|
|
31fb32 |
+ unsigned int return_addr_regno,
|
|
|
31fb32 |
+ rtx comparison_operator,
|
|
|
31fb32 |
+ enum s390_indirect_branch_type type)
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ enum s390_indirect_branch_option option;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ if (type == s390_indirect_branch_type_return)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ if (s390_function_return_reg != indirect_branch_keep
|
|
|
31fb32 |
+ && !s390_return_addr_from_memory ())
|
|
|
31fb32 |
+ option = s390_opt_function_return_reg;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ if (s390_function_return_mem != indirect_branch_keep
|
|
|
31fb32 |
+ && s390_return_addr_from_memory ())
|
|
|
31fb32 |
+ option = s390_opt_function_return_mem;
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+ else if (type == s390_indirect_branch_type_jump)
|
|
|
31fb32 |
+ option = s390_opt_indirect_branch_jump;
|
|
|
31fb32 |
+ else if (type == s390_indirect_branch_type_call)
|
|
|
31fb32 |
+ option = s390_opt_indirect_branch_call;
|
|
|
31fb32 |
+ else
|
|
|
31fb32 |
+ gcc_unreachable ();
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ if (TARGET_INDIRECT_BRANCH_TABLE)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ char label[32];
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ ASM_GENERATE_INTERNAL_LABEL (label,
|
|
|
31fb32 |
+ indirect_branch_table_label[option],
|
|
|
31fb32 |
+ indirect_branch_table_label_no[option]++);
|
|
|
31fb32 |
+ ASM_OUTPUT_LABEL (asm_out_file, label);
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ if (return_addr_regno != INVALID_REGNUM)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ gcc_assert (comparison_operator == NULL_RTX);
|
|
|
31fb32 |
+ fprintf (asm_out_file, " \tbrasl\t%%r%d,", return_addr_regno);
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+ else
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ fputs (" \tjg", asm_out_file);
|
|
|
31fb32 |
+ if (comparison_operator != NULL_RTX)
|
|
|
31fb32 |
+ print_operand (asm_out_file, comparison_operator, 'C');
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ fputs ("\t", asm_out_file);
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ if (TARGET_CPU_Z10)
|
|
|
31fb32 |
+ fprintf (asm_out_file,
|
|
|
31fb32 |
+ TARGET_INDIRECT_BRANCH_THUNK_NAME_EXRL "\n",
|
|
|
31fb32 |
+ regno);
|
|
|
31fb32 |
+ else
|
|
|
31fb32 |
+ fprintf (asm_out_file,
|
|
|
31fb32 |
+ TARGET_INDIRECT_BRANCH_THUNK_NAME_EX "\n",
|
|
|
31fb32 |
+ INDIRECT_BRANCH_THUNK_REGNUM, regno);
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ if ((option == s390_opt_indirect_branch_jump
|
|
|
31fb32 |
+ && s390_indirect_branch_jump == indirect_branch_thunk)
|
|
|
31fb32 |
+ || (option == s390_opt_indirect_branch_call
|
|
|
31fb32 |
+ && s390_indirect_branch_call == indirect_branch_thunk)
|
|
|
31fb32 |
+ || (option == s390_opt_function_return_reg
|
|
|
31fb32 |
+ && s390_function_return_reg == indirect_branch_thunk)
|
|
|
31fb32 |
+ || (option == s390_opt_function_return_mem
|
|
|
31fb32 |
+ && s390_function_return_mem == indirect_branch_thunk))
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ if (TARGET_CPU_Z10)
|
|
|
31fb32 |
+ indirect_branch_z10thunk_mask |= (1 << regno);
|
|
|
31fb32 |
+ else
|
|
|
31fb32 |
+ indirect_branch_prez10thunk_mask |= (1 << regno);
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
static bool
|
|
|
31fb32 |
s390_valid_pointer_mode (enum machine_mode mode)
|
|
|
31fb32 |
{
|
|
|
31fb32 |
@@ -12476,6 +12607,14 @@ s390_function_ok_for_sibcall (tree decl,
|
|
|
31fb32 |
if (!TARGET_64BIT && flag_pic && decl && !targetm.binds_local_p (decl))
|
|
|
31fb32 |
return false;
|
|
|
31fb32 |
|
|
|
31fb32 |
+ /* The thunks for indirect branches require r1 if no exrl is
|
|
|
31fb32 |
+ available. r1 might not be available when doing a sibling
|
|
|
31fb32 |
+ call. */
|
|
|
31fb32 |
+ if (TARGET_INDIRECT_BRANCH_NOBP_CALL
|
|
|
31fb32 |
+ && !TARGET_CPU_Z10
|
|
|
31fb32 |
+ && !decl)
|
|
|
31fb32 |
+ return false;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
/* Register 6 on s390 is available as an argument register but unfortunately
|
|
|
31fb32 |
"caller saved". This makes functions needing this register for arguments
|
|
|
31fb32 |
not suitable for sibcalls. */
|
|
|
31fb32 |
@@ -12509,9 +12648,13 @@ s390_emit_call (rtx addr_location, rtx t
|
|
|
31fb32 |
{
|
|
|
31fb32 |
bool plt_call = false;
|
|
|
31fb32 |
rtx insn;
|
|
|
31fb32 |
- rtx call;
|
|
|
31fb32 |
- rtx clobber;
|
|
|
31fb32 |
- rtvec vec;
|
|
|
31fb32 |
+ rtx vec[4] = { NULL_RTX };
|
|
|
31fb32 |
+ int elts = 0;
|
|
|
31fb32 |
+ rtx *call = &vec[0];
|
|
|
31fb32 |
+ rtx *clobber_ret_reg = &vec[1];
|
|
|
31fb32 |
+ rtx *use = &vec[2];
|
|
|
31fb32 |
+ rtx *clobber_thunk_reg = &vec[3];
|
|
|
31fb32 |
+ int i;
|
|
|
31fb32 |
|
|
|
31fb32 |
/* Direct function calls need special treatment. */
|
|
|
31fb32 |
if (GET_CODE (addr_location) == SYMBOL_REF)
|
|
|
31fb32 |
@@ -12520,7 +12663,7 @@ s390_emit_call (rtx addr_location, rtx t
|
|
|
31fb32 |
replace the symbol itself with the PLT stub. */
|
|
|
31fb32 |
if (flag_pic && !SYMBOL_REF_LOCAL_P (addr_location))
|
|
|
31fb32 |
{
|
|
|
31fb32 |
- if (retaddr_reg != NULL_RTX)
|
|
|
31fb32 |
+ if (TARGET_64BIT || retaddr_reg != NULL_RTX)
|
|
|
31fb32 |
{
|
|
|
31fb32 |
addr_location = gen_rtx_UNSPEC (Pmode,
|
|
|
31fb32 |
gen_rtvec (1, addr_location),
|
|
|
31fb32 |
@@ -12563,26 +12706,57 @@ s390_emit_call (rtx addr_location, rtx t
|
|
|
31fb32 |
addr_location = gen_rtx_REG (Pmode, SIBCALL_REGNUM);
|
|
|
31fb32 |
}
|
|
|
31fb32 |
|
|
|
31fb32 |
+ if (TARGET_INDIRECT_BRANCH_NOBP_CALL
|
|
|
31fb32 |
+ && GET_CODE (addr_location) != SYMBOL_REF
|
|
|
31fb32 |
+ && !plt_call)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ /* Indirect branch thunks require the target to be a single GPR. */
|
|
|
31fb32 |
+ addr_location = force_reg (Pmode, addr_location);
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ /* Without exrl the indirect branch thunks need an additional
|
|
|
31fb32 |
+ register for larl;ex */
|
|
|
31fb32 |
+ if (!TARGET_CPU_Z10)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ *clobber_thunk_reg = gen_rtx_REG (Pmode, INDIRECT_BRANCH_THUNK_REGNUM);
|
|
|
31fb32 |
+ *clobber_thunk_reg = gen_rtx_CLOBBER (VOIDmode, *clobber_thunk_reg);
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+
|
|
|
31fb32 |
addr_location = gen_rtx_MEM (QImode, addr_location);
|
|
|
31fb32 |
- call = gen_rtx_CALL (VOIDmode, addr_location, const0_rtx);
|
|
|
31fb32 |
+ *call = gen_rtx_CALL (VOIDmode, addr_location, const0_rtx);
|
|
|
31fb32 |
|
|
|
31fb32 |
if (result_reg != NULL_RTX)
|
|
|
31fb32 |
- call = gen_rtx_SET (VOIDmode, result_reg, call);
|
|
|
31fb32 |
+ *call = gen_rtx_SET (VOIDmode, result_reg, *call);
|
|
|
31fb32 |
|
|
|
31fb32 |
if (retaddr_reg != NULL_RTX)
|
|
|
31fb32 |
{
|
|
|
31fb32 |
- clobber = gen_rtx_CLOBBER (VOIDmode, retaddr_reg);
|
|
|
31fb32 |
+ *clobber_ret_reg = gen_rtx_CLOBBER (VOIDmode, retaddr_reg);
|
|
|
31fb32 |
|
|
|
31fb32 |
if (tls_call != NULL_RTX)
|
|
|
31fb32 |
- vec = gen_rtvec (3, call, clobber,
|
|
|
31fb32 |
- gen_rtx_USE (VOIDmode, tls_call));
|
|
|
31fb32 |
- else
|
|
|
31fb32 |
- vec = gen_rtvec (2, call, clobber);
|
|
|
31fb32 |
+ *use = gen_rtx_USE (VOIDmode, tls_call);
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ for (i = 0; i < 4; i++)
|
|
|
31fb32 |
+ if (vec[i] != NULL_RTX)
|
|
|
31fb32 |
+ elts++;
|
|
|
31fb32 |
|
|
|
31fb32 |
- call = gen_rtx_PARALLEL (VOIDmode, vec);
|
|
|
31fb32 |
+ if (elts > 1)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ rtvec v;
|
|
|
31fb32 |
+ int e = 0;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ v = rtvec_alloc (elts);
|
|
|
31fb32 |
+ for (i = 0; i < 4; i++)
|
|
|
31fb32 |
+ if (vec[i] != NULL_RTX)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ RTVEC_ELT (v, e) = vec[i];
|
|
|
31fb32 |
+ e++;
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ *call = gen_rtx_PARALLEL (VOIDmode, v);
|
|
|
31fb32 |
}
|
|
|
31fb32 |
|
|
|
31fb32 |
- insn = emit_call_insn (call);
|
|
|
31fb32 |
+ insn = emit_call_insn (*call);
|
|
|
31fb32 |
|
|
|
31fb32 |
/* 31-bit PLT stubs and tls calls use the GOT register implicitly. */
|
|
|
31fb32 |
if ((!TARGET_64BIT && plt_call) || tls_call != NULL_RTX)
|
|
|
31fb32 |
@@ -13819,6 +13993,190 @@ s390_asm_file_end (void)
|
|
|
31fb32 |
file_end_indicate_exec_stack ();
|
|
|
31fb32 |
}
|
|
|
31fb32 |
|
|
|
31fb32 |
+#ifdef HAVE_GAS_HIDDEN
|
|
|
31fb32 |
+# define USE_HIDDEN_LINKONCE 1
|
|
|
31fb32 |
+#else
|
|
|
31fb32 |
+# define USE_HIDDEN_LINKONCE 0
|
|
|
31fb32 |
+#endif
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* Output an indirect branch trampoline for target register REGNO. */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+static void
|
|
|
31fb32 |
+s390_output_indirect_thunk_function (unsigned int regno, bool z10_p)
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ tree decl;
|
|
|
31fb32 |
+ char thunk_label[32];
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ int i;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ if (z10_p)
|
|
|
31fb32 |
+ sprintf (thunk_label, TARGET_INDIRECT_BRANCH_THUNK_NAME_EXRL, regno);
|
|
|
31fb32 |
+ else
|
|
|
31fb32 |
+ sprintf (thunk_label, TARGET_INDIRECT_BRANCH_THUNK_NAME_EX,
|
|
|
31fb32 |
+ INDIRECT_BRANCH_THUNK_REGNUM, regno);
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ decl = build_decl (BUILTINS_LOCATION, FUNCTION_DECL,
|
|
|
31fb32 |
+ get_identifier (thunk_label),
|
|
|
31fb32 |
+ build_function_type_list (void_type_node, NULL_TREE));
|
|
|
31fb32 |
+ DECL_RESULT (decl) = build_decl (BUILTINS_LOCATION, RESULT_DECL,
|
|
|
31fb32 |
+ NULL_TREE, void_type_node);
|
|
|
31fb32 |
+ TREE_PUBLIC (decl) = 1;
|
|
|
31fb32 |
+ TREE_STATIC (decl) = 1;
|
|
|
31fb32 |
+ DECL_IGNORED_P (decl) = 1;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ if (USE_HIDDEN_LINKONCE)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ DECL_COMDAT_GROUP (decl) = DECL_ASSEMBLER_NAME (decl);
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ targetm.asm_out.unique_section (decl, 0);
|
|
|
31fb32 |
+ switch_to_section (get_named_section (decl, NULL, 0));
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ targetm.asm_out.globalize_label (asm_out_file, thunk_label);
|
|
|
31fb32 |
+ fputs ("\t.hidden\t", asm_out_file);
|
|
|
31fb32 |
+ assemble_name (asm_out_file, thunk_label);
|
|
|
31fb32 |
+ putc ('\n', asm_out_file);
|
|
|
31fb32 |
+ ASM_DECLARE_FUNCTION_NAME (asm_out_file, thunk_label, decl);
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+ else
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ switch_to_section (text_section);
|
|
|
31fb32 |
+ ASM_OUTPUT_LABEL (asm_out_file, thunk_label);
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ DECL_INITIAL (decl) = make_node (BLOCK);
|
|
|
31fb32 |
+ current_function_decl = decl;
|
|
|
31fb32 |
+ allocate_struct_function (decl, false);
|
|
|
31fb32 |
+ init_function_start (decl);
|
|
|
31fb32 |
+ cfun->is_thunk = true;
|
|
|
31fb32 |
+ first_function_block_is_cold = false;
|
|
|
31fb32 |
+ final_start_function (emit_barrier (), asm_out_file, 1);
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ /* This makes CFI at least usable for indirect jumps.
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ jumps: stopping in the thunk: backtrace will point to the thunk
|
|
|
31fb32 |
+ target is if it was interrupted by a signal
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ calls: Instead of caller->thunk the backtrace will be
|
|
|
31fb32 |
+ caller->callee->thunk */
|
|
|
31fb32 |
+ if (flag_asynchronous_unwind_tables)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ fputs ("\t.cfi_signal_frame\n", asm_out_file);
|
|
|
31fb32 |
+ fprintf (asm_out_file, "\t.cfi_return_column %d\n", regno);
|
|
|
31fb32 |
+ for (i = 0; i < FPR15_REGNUM; i++)
|
|
|
31fb32 |
+ fprintf (asm_out_file, "\t.cfi_same_value %s\n", reg_names[i]);
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ if (z10_p)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ /* exrl 0,1f */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ /* We generate a thunk for z10 compiled code although z10 is
|
|
|
31fb32 |
+ currently not enabled. Tell the assembler to accept the
|
|
|
31fb32 |
+ instruction. */
|
|
|
31fb32 |
+ if (!TARGET_CPU_Z10)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ fputs ("\t.machine push\n", asm_out_file);
|
|
|
31fb32 |
+ fputs ("\t.machine z10\n", asm_out_file);
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+ /* We use exrl even if -mzarch hasn't been specified on the
|
|
|
31fb32 |
+ command line so we have to tell the assembler to accept
|
|
|
31fb32 |
+ it. */
|
|
|
31fb32 |
+ if (!TARGET_ZARCH)
|
|
|
31fb32 |
+ fputs ("\t.machinemode zarch\n", asm_out_file);
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ fputs ("\texrl\t0,1f\n", asm_out_file);
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ if (!TARGET_ZARCH)
|
|
|
31fb32 |
+ fputs ("\t.machinemode esa\n", asm_out_file);
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ if (!TARGET_CPU_Z10)
|
|
|
31fb32 |
+ fputs ("\t.machine pop\n", asm_out_file);
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+ else if (TARGET_CPU_ZARCH)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ /* larl %r1,1f */
|
|
|
31fb32 |
+ fprintf (asm_out_file, "\tlarl\t%%r%d,1f\n",
|
|
|
31fb32 |
+ INDIRECT_BRANCH_THUNK_REGNUM);
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ /* ex 0,0(%r1) */
|
|
|
31fb32 |
+ fprintf (asm_out_file, "\tex\t0,0(%%r%d)\n",
|
|
|
31fb32 |
+ INDIRECT_BRANCH_THUNK_REGNUM);
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+ else
|
|
|
31fb32 |
+ gcc_unreachable ();
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ /* 0: j 0b */
|
|
|
31fb32 |
+ fputs ("0:\tj\t0b\n", asm_out_file);
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ /* 1: br <regno> */
|
|
|
31fb32 |
+ fprintf (asm_out_file, "1:\tbr\t%%r%d\n", regno);
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ final_end_function ();
|
|
|
31fb32 |
+ init_insn_lengths ();
|
|
|
31fb32 |
+ free_after_compilation (cfun);
|
|
|
31fb32 |
+ set_cfun (NULL);
|
|
|
31fb32 |
+ current_function_decl = NULL;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* Implement the asm.code_end target hook. */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+static void
|
|
|
31fb32 |
+s390_code_end (void)
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ int i;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ for (i = 1; i < 16; i++)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ if (indirect_branch_z10thunk_mask & (1 << i))
|
|
|
31fb32 |
+ s390_output_indirect_thunk_function (i, true);
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ if (indirect_branch_prez10thunk_mask & (1 << i))
|
|
|
31fb32 |
+ s390_output_indirect_thunk_function (i, false);
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ if (TARGET_INDIRECT_BRANCH_TABLE)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ int o;
|
|
|
31fb32 |
+ int i;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ for (o = 0; o < INDIRECT_BRANCH_NUM_OPTIONS; o++)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ if (indirect_branch_table_label_no[o] == 0)
|
|
|
31fb32 |
+ continue;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ switch_to_section (get_section (indirect_branch_table_name[o],
|
|
|
31fb32 |
+ 0,
|
|
|
31fb32 |
+ NULL_TREE));
|
|
|
31fb32 |
+ for (i = 0; i < indirect_branch_table_label_no[o]; i++)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ char label_start[32];
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ ASM_GENERATE_INTERNAL_LABEL (label_start,
|
|
|
31fb32 |
+ indirect_branch_table_label[o], i);
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ fputs ("\t.long\t", asm_out_file);
|
|
|
31fb32 |
+ assemble_name_raw (asm_out_file, label_start);
|
|
|
31fb32 |
+ fputs ("-.\n", asm_out_file);
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+ switch_to_section (current_function_section ());
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* Implement the TARGET_CASE_VALUES_THRESHOLD target hook. */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+unsigned int
|
|
|
31fb32 |
+s390_case_values_threshold (void)
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ /* Disabling branch prediction for indirect jumps makes jump table
|
|
|
31fb32 |
+ much more expensive. */
|
|
|
31fb32 |
+ if (TARGET_INDIRECT_BRANCH_NOBP_JUMP)
|
|
|
31fb32 |
+ return 20;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ return default_case_values_threshold ();
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+
|
|
|
31fb32 |
/* Initialize GCC target structure. */
|
|
|
31fb32 |
|
|
|
31fb32 |
#undef TARGET_ASM_ALIGNED_HI_OP
|
|
|
31fb32 |
@@ -14015,6 +14373,12 @@ s390_asm_file_end (void)
|
|
|
31fb32 |
#undef TARGET_ASM_FILE_END
|
|
|
31fb32 |
#define TARGET_ASM_FILE_END s390_asm_file_end
|
|
|
31fb32 |
|
|
|
31fb32 |
+#undef TARGET_ASM_CODE_END
|
|
|
31fb32 |
+#define TARGET_ASM_CODE_END s390_code_end
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+#undef TARGET_CASE_VALUES_THRESHOLD
|
|
|
31fb32 |
+#define TARGET_CASE_VALUES_THRESHOLD s390_case_values_threshold
|
|
|
31fb32 |
+
|
|
|
31fb32 |
struct gcc_target targetm = TARGET_INITIALIZER;
|
|
|
31fb32 |
|
|
|
31fb32 |
#include "gt-s390.h"
|
|
|
31fb32 |
diff -Nrup gcc/config/s390/s390.h gcc/config/s390/s390.h
|
|
|
31fb32 |
--- gcc/config/s390/s390.h 2018-03-27 09:33:19.762143683 -0600
|
|
|
31fb32 |
+++ gcc/config/s390/s390.h 2018-03-27 09:33:58.827861602 -0600
|
|
|
31fb32 |
@@ -1006,4 +1006,37 @@ extern const int processor_flags_table[]
|
|
|
31fb32 |
s390_register_target_pragmas (); \
|
|
|
31fb32 |
} while (0)
|
|
|
31fb32 |
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+#define TARGET_INDIRECT_BRANCH_NOBP_RET_OPTION \
|
|
|
31fb32 |
+ (s390_function_return_reg != indirect_branch_keep \
|
|
|
31fb32 |
+ || s390_function_return_mem != indirect_branch_keep)
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+#define TARGET_INDIRECT_BRANCH_NOBP_RET \
|
|
|
31fb32 |
+ ((s390_function_return_reg != indirect_branch_keep \
|
|
|
31fb32 |
+ && !s390_return_addr_from_memory ()) \
|
|
|
31fb32 |
+ || (s390_function_return_mem != indirect_branch_keep \
|
|
|
31fb32 |
+ && s390_return_addr_from_memory ()))
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+#define TARGET_INDIRECT_BRANCH_NOBP_JUMP \
|
|
|
31fb32 |
+ (s390_indirect_branch_jump != indirect_branch_keep)
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+#define TARGET_INDIRECT_BRANCH_NOBP_JUMP_THUNK \
|
|
|
31fb32 |
+ (s390_indirect_branch_jump == indirect_branch_thunk \
|
|
|
31fb32 |
+ || s390_indirect_branch_jump == indirect_branch_thunk_extern)
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+#define TARGET_INDIRECT_BRANCH_NOBP_JUMP_INLINE_THUNK \
|
|
|
31fb32 |
+ (s390_indirect_branch_jump == indirect_branch_thunk_inline)
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+#define TARGET_INDIRECT_BRANCH_NOBP_CALL \
|
|
|
31fb32 |
+ (s390_indirect_branch_call != indirect_branch_keep)
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+#ifndef TARGET_DEFAULT_INDIRECT_BRANCH_TABLE
|
|
|
31fb32 |
+#define TARGET_DEFAULT_INDIRECT_BRANCH_TABLE 0
|
|
|
31fb32 |
+#endif
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+#define TARGET_INDIRECT_BRANCH_THUNK_NAME_EXRL "__s390_indirect_jump_r%d"
|
|
|
31fb32 |
+#define TARGET_INDIRECT_BRANCH_THUNK_NAME_EX "__s390_indirect_jump_r%duse_r%d"
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+#define TARGET_INDIRECT_BRANCH_TABLE s390_indirect_branch_table
|
|
|
31fb32 |
+
|
|
|
31fb32 |
#endif /* S390_H */
|
|
|
31fb32 |
diff -Nrup gcc/config/s390/s390.md gcc/config/s390/s390.md
|
|
|
31fb32 |
--- gcc/config/s390/s390.md 2018-03-27 09:33:19.763143675 -0600
|
|
|
31fb32 |
+++ gcc/config/s390/s390.md 2018-03-27 09:33:58.831861573 -0600
|
|
|
31fb32 |
@@ -285,6 +285,8 @@
|
|
|
31fb32 |
[
|
|
|
31fb32 |
; Sibling call register.
|
|
|
31fb32 |
(SIBCALL_REGNUM 1)
|
|
|
31fb32 |
+ ; A call-clobbered reg which can be used in indirect branch thunks
|
|
|
31fb32 |
+ (INDIRECT_BRANCH_THUNK_REGNUM 1)
|
|
|
31fb32 |
; Literal pool base register.
|
|
|
31fb32 |
(BASE_REGNUM 13)
|
|
|
31fb32 |
; Return address register.
|
|
|
31fb32 |
@@ -304,6 +306,7 @@
|
|
|
31fb32 |
; Floating point registers.
|
|
|
31fb32 |
(FPR0_REGNUM 16)
|
|
|
31fb32 |
(FPR2_REGNUM 18)
|
|
|
31fb32 |
+ (FPR15_REGNUM 31)
|
|
|
31fb32 |
(VR0_REGNUM 16)
|
|
|
31fb32 |
(VR16_REGNUM 38)
|
|
|
31fb32 |
(VR23_REGNUM 45)
|
|
|
31fb32 |
@@ -402,7 +405,10 @@
|
|
|
31fb32 |
z196_cracked"
|
|
|
31fb32 |
(const_string "none"))
|
|
|
31fb32 |
|
|
|
31fb32 |
-(define_attr "mnemonic" "bcr_flush,unknown" (const_string "unknown"))
|
|
|
31fb32 |
+; mnemonics which only get defined through if_then_else currently
|
|
|
31fb32 |
+; don't get added to the list values automatically and hence need to
|
|
|
31fb32 |
+; be listed here.
|
|
|
31fb32 |
+(define_attr "mnemonic" "b,br,bas,bc,bcr,bcr_flush,unknown" (const_string "unknown"))
|
|
|
31fb32 |
|
|
|
31fb32 |
;; Length in bytes.
|
|
|
31fb32 |
|
|
|
31fb32 |
@@ -8436,7 +8442,7 @@
|
|
|
31fb32 |
(match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
|
|
|
31fb32 |
(match_operand 0 "address_operand" "ZQZR")
|
|
|
31fb32 |
(pc)))]
|
|
|
31fb32 |
- ""
|
|
|
31fb32 |
+ "!TARGET_INDIRECT_BRANCH_NOBP_JUMP"
|
|
|
31fb32 |
{
|
|
|
31fb32 |
if (get_attr_op_type (insn) == OP_TYPE_RR)
|
|
|
31fb32 |
return "b%C1r\t%0";
|
|
|
31fb32 |
@@ -8446,6 +8452,9 @@
|
|
|
31fb32 |
[(set (attr "op_type")
|
|
|
31fb32 |
(if_then_else (match_operand 0 "register_operand" "")
|
|
|
31fb32 |
(const_string "RR") (const_string "RX")))
|
|
|
31fb32 |
+ (set (attr "mnemonic")
|
|
|
31fb32 |
+ (if_then_else (match_operand 0 "register_operand" "")
|
|
|
31fb32 |
+ (const_string "bcr") (const_string "bc")))
|
|
|
31fb32 |
(set_attr "type" "branch")
|
|
|
31fb32 |
(set_attr "atype" "agen")])
|
|
|
31fb32 |
|
|
|
31fb32 |
@@ -8499,7 +8508,7 @@
|
|
|
31fb32 |
(match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
|
|
|
31fb32 |
(pc)
|
|
|
31fb32 |
(match_operand 0 "address_operand" "ZQZR")))]
|
|
|
31fb32 |
- ""
|
|
|
31fb32 |
+ "!TARGET_INDIRECT_BRANCH_NOBP_JUMP"
|
|
|
31fb32 |
{
|
|
|
31fb32 |
if (get_attr_op_type (insn) == OP_TYPE_RR)
|
|
|
31fb32 |
return "b%D1r\t%0";
|
|
|
31fb32 |
@@ -8509,6 +8518,9 @@
|
|
|
31fb32 |
[(set (attr "op_type")
|
|
|
31fb32 |
(if_then_else (match_operand 0 "register_operand" "")
|
|
|
31fb32 |
(const_string "RR") (const_string "RX")))
|
|
|
31fb32 |
+ (set (attr "mnemonic")
|
|
|
31fb32 |
+ (if_then_else (match_operand 0 "register_operand" "")
|
|
|
31fb32 |
+ (const_string "bcr") (const_string "bc")))
|
|
|
31fb32 |
(set_attr "type" "branch")
|
|
|
31fb32 |
(set_attr "atype" "agen")])
|
|
|
31fb32 |
|
|
|
31fb32 |
@@ -9005,29 +9017,125 @@
|
|
|
31fb32 |
; indirect-jump instruction pattern(s).
|
|
|
31fb32 |
;
|
|
|
31fb32 |
|
|
|
31fb32 |
-(define_insn "indirect_jump"
|
|
|
31fb32 |
- [(set (pc) (match_operand 0 "address_operand" "ZQZR"))]
|
|
|
31fb32 |
- ""
|
|
|
31fb32 |
+(define_expand "indirect_jump"
|
|
|
31fb32 |
+ [(set (pc) (match_operand 0 "address_operand" "ZQZR"))]
|
|
|
31fb32 |
+ ""
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ if (TARGET_INDIRECT_BRANCH_NOBP_JUMP_THUNK)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ operands[0] = force_reg (Pmode, operands[0]);
|
|
|
31fb32 |
+ if (TARGET_CPU_Z10)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ if (TARGET_64BIT)
|
|
|
31fb32 |
+ emit_jump_insn (gen_indirect_jump_via_thunkdi_z10 (operands[0]));
|
|
|
31fb32 |
+ else
|
|
|
31fb32 |
+ emit_jump_insn (gen_indirect_jump_via_thunksi_z10 (operands[0]));
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+ else
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ if (TARGET_64BIT)
|
|
|
31fb32 |
+ emit_jump_insn (gen_indirect_jump_via_thunkdi (operands[0]));
|
|
|
31fb32 |
+ else
|
|
|
31fb32 |
+ emit_jump_insn (gen_indirect_jump_via_thunksi (operands[0]));
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+ DONE;
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+})
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+(define_insn "*indirect_jump"
|
|
|
31fb32 |
+ [(set (pc)
|
|
|
31fb32 |
+ (match_operand 0 "address_operand" "ZR"))]
|
|
|
31fb32 |
+ "!TARGET_INDIRECT_BRANCH_NOBP_JUMP_THUNK"
|
|
|
31fb32 |
{
|
|
|
31fb32 |
if (get_attr_op_type (insn) == OP_TYPE_RR)
|
|
|
31fb32 |
return "br\t%0";
|
|
|
31fb32 |
else
|
|
|
31fb32 |
return "b\t%a0";
|
|
|
31fb32 |
}
|
|
|
31fb32 |
- [(set (attr "op_type")
|
|
|
31fb32 |
- (if_then_else (match_operand 0 "register_operand" "")
|
|
|
31fb32 |
- (const_string "RR") (const_string "RX")))
|
|
|
31fb32 |
- (set_attr "type" "branch")
|
|
|
31fb32 |
- (set_attr "atype" "agen")])
|
|
|
31fb32 |
+ [(set (attr "op_type")
|
|
|
31fb32 |
+ (if_then_else (match_operand 0 "register_operand" "")
|
|
|
31fb32 |
+ (const_string "RR") (const_string "RX")))
|
|
|
31fb32 |
+ (set (attr "mnemonic")
|
|
|
31fb32 |
+ (if_then_else (match_operand 0 "register_operand" "")
|
|
|
31fb32 |
+ (const_string "br") (const_string "b")))
|
|
|
31fb32 |
+ (set_attr "type" "branch")
|
|
|
31fb32 |
+ (set_attr "atype" "agen")])
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+(define_insn "indirect_jump_via_thunk<mode>_z10"
|
|
|
31fb32 |
+ [(set (pc)
|
|
|
31fb32 |
+ (match_operand:P 0 "register_operand" "a"))]
|
|
|
31fb32 |
+ "TARGET_INDIRECT_BRANCH_NOBP_JUMP_THUNK
|
|
|
31fb32 |
+ && TARGET_CPU_Z10"
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ s390_indirect_branch_via_thunk (REGNO (operands[0]),
|
|
|
31fb32 |
+ INVALID_REGNUM,
|
|
|
31fb32 |
+ NULL_RTX,
|
|
|
31fb32 |
+ s390_indirect_branch_type_jump);
|
|
|
31fb32 |
+ return "";
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+ [(set_attr "op_type" "RIL")
|
|
|
31fb32 |
+ (set_attr "mnemonic" "jg")
|
|
|
31fb32 |
+ (set_attr "type" "branch")
|
|
|
31fb32 |
+ (set_attr "atype" "agen")])
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+(define_insn "indirect_jump_via_thunk<mode>"
|
|
|
31fb32 |
+ [(set (pc)
|
|
|
31fb32 |
+ (match_operand:P 0 "register_operand" " a"))
|
|
|
31fb32 |
+ (clobber (reg:P INDIRECT_BRANCH_THUNK_REGNUM))]
|
|
|
31fb32 |
+ "TARGET_INDIRECT_BRANCH_NOBP_JUMP_THUNK
|
|
|
31fb32 |
+ && !TARGET_CPU_Z10"
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ s390_indirect_branch_via_thunk (REGNO (operands[0]),
|
|
|
31fb32 |
+ INVALID_REGNUM,
|
|
|
31fb32 |
+ NULL_RTX,
|
|
|
31fb32 |
+ s390_indirect_branch_type_jump);
|
|
|
31fb32 |
+ return "";
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+ [(set_attr "op_type" "RIL")
|
|
|
31fb32 |
+ (set_attr "mnemonic" "jg")
|
|
|
31fb32 |
+ (set_attr "type" "branch")
|
|
|
31fb32 |
+ (set_attr "atype" "agen")])
|
|
|
31fb32 |
|
|
|
31fb32 |
;
|
|
|
31fb32 |
; casesi instruction pattern(s).
|
|
|
31fb32 |
;
|
|
|
31fb32 |
|
|
|
31fb32 |
-(define_insn "casesi_jump"
|
|
|
31fb32 |
- [(set (pc) (match_operand 0 "address_operand" "ZQZR"))
|
|
|
31fb32 |
- (use (label_ref (match_operand 1 "" "")))]
|
|
|
31fb32 |
- ""
|
|
|
31fb32 |
+(define_expand "casesi_jump"
|
|
|
31fb32 |
+ [(parallel
|
|
|
31fb32 |
+ [(set (pc) (match_operand 0 "address_operand"))
|
|
|
31fb32 |
+ (use (label_ref (match_operand 1 "")))])]
|
|
|
31fb32 |
+ ""
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ if (TARGET_INDIRECT_BRANCH_NOBP_JUMP_THUNK)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ operands[0] = force_reg (GET_MODE (operands[0]), operands[0]);
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ if (TARGET_CPU_Z10)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ if (TARGET_64BIT)
|
|
|
31fb32 |
+ emit_jump_insn (gen_casesi_jump_via_thunkdi_z10 (operands[0],
|
|
|
31fb32 |
+ operands[1]));
|
|
|
31fb32 |
+ else
|
|
|
31fb32 |
+ emit_jump_insn (gen_casesi_jump_via_thunksi_z10 (operands[0],
|
|
|
31fb32 |
+ operands[1]));
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+ else
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ if (TARGET_64BIT)
|
|
|
31fb32 |
+ emit_jump_insn (gen_casesi_jump_via_thunkdi (operands[0],
|
|
|
31fb32 |
+ operands[1]));
|
|
|
31fb32 |
+ else
|
|
|
31fb32 |
+ emit_jump_insn (gen_casesi_jump_via_thunksi (operands[0],
|
|
|
31fb32 |
+ operands[1]));
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+ DONE;
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+})
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+(define_insn "*casesi_jump"
|
|
|
31fb32 |
+ [(set (pc) (match_operand 0 "address_operand" "ZR"))
|
|
|
31fb32 |
+ (use (label_ref (match_operand 1 "" "")))]
|
|
|
31fb32 |
+ "!TARGET_INDIRECT_BRANCH_NOBP_JUMP_THUNK"
|
|
|
31fb32 |
{
|
|
|
31fb32 |
if (get_attr_op_type (insn) == OP_TYPE_RR)
|
|
|
31fb32 |
return "br\t%0";
|
|
|
31fb32 |
@@ -9035,11 +9143,50 @@
|
|
|
31fb32 |
return "b\t%a0";
|
|
|
31fb32 |
}
|
|
|
31fb32 |
[(set (attr "op_type")
|
|
|
31fb32 |
+ (if_then_else (match_operand 0 "register_operand" "")
|
|
|
31fb32 |
+ (const_string "RR") (const_string "RX")))
|
|
|
31fb32 |
+ (set (attr "mnemonic")
|
|
|
31fb32 |
(if_then_else (match_operand 0 "register_operand" "")
|
|
|
31fb32 |
- (const_string "RR") (const_string "RX")))
|
|
|
31fb32 |
+ (const_string "br") (const_string "b")))
|
|
|
31fb32 |
+ (set_attr "type" "branch")
|
|
|
31fb32 |
+ (set_attr "atype" "agen")])
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+(define_insn "casesi_jump_via_thunk<mode>_z10"
|
|
|
31fb32 |
+ [(set (pc) (match_operand:P 0 "register_operand" "a"))
|
|
|
31fb32 |
+ (use (label_ref (match_operand 1 "" "")))]
|
|
|
31fb32 |
+ "TARGET_INDIRECT_BRANCH_NOBP_JUMP_THUNK
|
|
|
31fb32 |
+ && TARGET_CPU_Z10"
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ s390_indirect_branch_via_thunk (REGNO (operands[0]),
|
|
|
31fb32 |
+ INVALID_REGNUM,
|
|
|
31fb32 |
+ NULL_RTX,
|
|
|
31fb32 |
+ s390_indirect_branch_type_jump);
|
|
|
31fb32 |
+ return "";
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+ [(set_attr "op_type" "RIL")
|
|
|
31fb32 |
+ (set_attr "mnemonic" "jg")
|
|
|
31fb32 |
(set_attr "type" "branch")
|
|
|
31fb32 |
(set_attr "atype" "agen")])
|
|
|
31fb32 |
|
|
|
31fb32 |
+(define_insn "casesi_jump_via_thunk<mode>"
|
|
|
31fb32 |
+ [(set (pc) (match_operand:P 0 "register_operand" "a"))
|
|
|
31fb32 |
+ (use (label_ref (match_operand 1 "" "")))
|
|
|
31fb32 |
+ (clobber (reg:P INDIRECT_BRANCH_THUNK_REGNUM))]
|
|
|
31fb32 |
+ "TARGET_INDIRECT_BRANCH_NOBP_JUMP_THUNK
|
|
|
31fb32 |
+ && !TARGET_CPU_Z10"
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ s390_indirect_branch_via_thunk (REGNO (operands[0]),
|
|
|
31fb32 |
+ INVALID_REGNUM,
|
|
|
31fb32 |
+ NULL_RTX,
|
|
|
31fb32 |
+ s390_indirect_branch_type_jump);
|
|
|
31fb32 |
+ return "";
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+ [(set_attr "op_type" "RIL")
|
|
|
31fb32 |
+ (set_attr "mnemonic" "jg")
|
|
|
31fb32 |
+ (set_attr "type" "branch")
|
|
|
31fb32 |
+ (set_attr "atype" "agen")])
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+
|
|
|
31fb32 |
(define_expand "casesi"
|
|
|
31fb32 |
[(match_operand:SI 0 "general_operand" "")
|
|
|
31fb32 |
(match_operand:SI 1 "general_operand" "")
|
|
|
31fb32 |
@@ -9141,11 +9288,30 @@
|
|
|
31fb32 |
|
|
|
31fb32 |
(define_insn "*sibcall_br"
|
|
|
31fb32 |
[(call (mem:QI (reg SIBCALL_REGNUM))
|
|
|
31fb32 |
- (match_operand 0 "const_int_operand" "n"))]
|
|
|
31fb32 |
+ (match_operand 0 "const_int_operand" "n"))]
|
|
|
31fb32 |
"SIBLING_CALL_P (insn)
|
|
|
31fb32 |
- && GET_MODE (XEXP (XEXP (PATTERN (insn), 0), 0)) == Pmode"
|
|
|
31fb32 |
- "br\t%%r1"
|
|
|
31fb32 |
- [(set_attr "op_type" "RR")
|
|
|
31fb32 |
+ && GET_MODE (XEXP (XEXP (PATTERN (insn), 0), 0)) == Pmode"
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ if (TARGET_INDIRECT_BRANCH_NOBP_CALL)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ gcc_assert (TARGET_CPU_Z10);
|
|
|
31fb32 |
+ s390_indirect_branch_via_thunk (SIBCALL_REGNUM,
|
|
|
31fb32 |
+ INVALID_REGNUM,
|
|
|
31fb32 |
+ NULL_RTX,
|
|
|
31fb32 |
+ s390_indirect_branch_type_call);
|
|
|
31fb32 |
+ return "";
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+ else
|
|
|
31fb32 |
+ return "br\t%%r1";
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+ [(set (attr "op_type")
|
|
|
31fb32 |
+ (if_then_else (match_test "TARGET_INDIRECT_BRANCH_NOBP_CALL")
|
|
|
31fb32 |
+ (const_string "RIL")
|
|
|
31fb32 |
+ (const_string "RR")))
|
|
|
31fb32 |
+ (set (attr "mnemonic")
|
|
|
31fb32 |
+ (if_then_else (match_test "TARGET_INDIRECT_BRANCH_NOBP_CALL")
|
|
|
31fb32 |
+ (const_string "jg")
|
|
|
31fb32 |
+ (const_string "br")))
|
|
|
31fb32 |
(set_attr "type" "branch")
|
|
|
31fb32 |
(set_attr "atype" "agen")])
|
|
|
31fb32 |
|
|
|
31fb32 |
@@ -9185,8 +9351,27 @@
|
|
|
31fb32 |
(match_operand 1 "const_int_operand" "n")))]
|
|
|
31fb32 |
"SIBLING_CALL_P (insn)
|
|
|
31fb32 |
&& GET_MODE (XEXP (XEXP (XEXP (PATTERN (insn), 1), 0), 0)) == Pmode"
|
|
|
31fb32 |
- "br\t%%r1"
|
|
|
31fb32 |
- [(set_attr "op_type" "RR")
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ if (TARGET_INDIRECT_BRANCH_NOBP_CALL)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ gcc_assert (TARGET_CPU_Z10);
|
|
|
31fb32 |
+ s390_indirect_branch_via_thunk (SIBCALL_REGNUM,
|
|
|
31fb32 |
+ INVALID_REGNUM,
|
|
|
31fb32 |
+ NULL_RTX,
|
|
|
31fb32 |
+ s390_indirect_branch_type_call);
|
|
|
31fb32 |
+ return "";
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+ else
|
|
|
31fb32 |
+ return "br\t%%r1";
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+ [(set (attr "op_type")
|
|
|
31fb32 |
+ (if_then_else (match_test "TARGET_INDIRECT_BRANCH_NOBP_CALL")
|
|
|
31fb32 |
+ (const_string "RIL")
|
|
|
31fb32 |
+ (const_string "RR")))
|
|
|
31fb32 |
+ (set (attr "mnemonic")
|
|
|
31fb32 |
+ (if_then_else (match_test "TARGET_INDIRECT_BRANCH_NOBP_CALL")
|
|
|
31fb32 |
+ (const_string "jg")
|
|
|
31fb32 |
+ (const_string "br")))
|
|
|
31fb32 |
(set_attr "type" "branch")
|
|
|
31fb32 |
(set_attr "atype" "agen")])
|
|
|
31fb32 |
|
|
|
31fb32 |
@@ -9252,7 +9437,9 @@
|
|
|
31fb32 |
[(call (mem:QI (match_operand 0 "address_operand" "ZQZR"))
|
|
|
31fb32 |
(match_operand 1 "const_int_operand" "n"))
|
|
|
31fb32 |
(clobber (match_operand 2 "register_operand" "=r"))]
|
|
|
31fb32 |
- "!SIBLING_CALL_P (insn) && GET_MODE (operands[2]) == Pmode"
|
|
|
31fb32 |
+ "!TARGET_INDIRECT_BRANCH_NOBP_CALL
|
|
|
31fb32 |
+ && !SIBLING_CALL_P (insn)
|
|
|
31fb32 |
+ && GET_MODE (operands[2]) == Pmode"
|
|
|
31fb32 |
{
|
|
|
31fb32 |
if (get_attr_op_type (insn) == OP_TYPE_RR)
|
|
|
31fb32 |
return "basr\t%2,%0";
|
|
|
31fb32 |
@@ -9262,6 +9449,50 @@
|
|
|
31fb32 |
[(set (attr "op_type")
|
|
|
31fb32 |
(if_then_else (match_operand 0 "register_operand" "")
|
|
|
31fb32 |
(const_string "RR") (const_string "RX")))
|
|
|
31fb32 |
+ (set (attr "mnemonic")
|
|
|
31fb32 |
+ (if_then_else (match_operand 0 "register_operand" "")
|
|
|
31fb32 |
+ (const_string "basr") (const_string "bas")))
|
|
|
31fb32 |
+ (set_attr "type" "jsr")
|
|
|
31fb32 |
+ (set_attr "atype" "agen")
|
|
|
31fb32 |
+ (set_attr "z196prop" "z196_cracked")])
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+(define_insn "*basr_via_thunk<mode>_z10"
|
|
|
31fb32 |
+ [(call (mem:QI (match_operand:P 0 "register_operand" "a"))
|
|
|
31fb32 |
+ (match_operand 1 "const_int_operand" "n"))
|
|
|
31fb32 |
+ (clobber (match_operand:P 2 "register_operand" "=&r"))]
|
|
|
31fb32 |
+ "TARGET_INDIRECT_BRANCH_NOBP_CALL
|
|
|
31fb32 |
+ && TARGET_CPU_Z10
|
|
|
31fb32 |
+ && !SIBLING_CALL_P (insn)"
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ s390_indirect_branch_via_thunk (REGNO (operands[0]),
|
|
|
31fb32 |
+ REGNO (operands[2]),
|
|
|
31fb32 |
+ NULL_RTX,
|
|
|
31fb32 |
+ s390_indirect_branch_type_call);
|
|
|
31fb32 |
+ return "";
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+ [(set_attr "op_type" "RIL")
|
|
|
31fb32 |
+ (set_attr "mnemonic" "brasl")
|
|
|
31fb32 |
+ (set_attr "type" "jsr")
|
|
|
31fb32 |
+ (set_attr "atype" "agen")
|
|
|
31fb32 |
+ (set_attr "z196prop" "z196_cracked")])
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+(define_insn "*basr_via_thunk<mode>"
|
|
|
31fb32 |
+ [(call (mem:QI (match_operand:P 0 "register_operand" "a"))
|
|
|
31fb32 |
+ (match_operand 1 "const_int_operand" "n"))
|
|
|
31fb32 |
+ (clobber (match_operand:P 2 "register_operand" "=&r"))
|
|
|
31fb32 |
+ (clobber (reg:P INDIRECT_BRANCH_THUNK_REGNUM))]
|
|
|
31fb32 |
+ "TARGET_INDIRECT_BRANCH_NOBP_CALL
|
|
|
31fb32 |
+ && !TARGET_CPU_Z10
|
|
|
31fb32 |
+ && !SIBLING_CALL_P (insn)"
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ s390_indirect_branch_via_thunk (REGNO (operands[0]),
|
|
|
31fb32 |
+ REGNO (operands[2]),
|
|
|
31fb32 |
+ NULL_RTX,
|
|
|
31fb32 |
+ s390_indirect_branch_type_call);
|
|
|
31fb32 |
+ return "";
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+ [(set_attr "op_type" "RIL")
|
|
|
31fb32 |
+ (set_attr "mnemonic" "brasl")
|
|
|
31fb32 |
(set_attr "type" "jsr")
|
|
|
31fb32 |
(set_attr "atype" "agen")
|
|
|
31fb32 |
(set_attr "z196prop" "z196_cracked")])
|
|
|
31fb32 |
@@ -9313,7 +9544,10 @@
|
|
|
31fb32 |
(call (mem:QI (match_operand 1 "address_operand" "ZQZR"))
|
|
|
31fb32 |
(match_operand 2 "const_int_operand" "n")))
|
|
|
31fb32 |
(clobber (match_operand 3 "register_operand" "=r"))]
|
|
|
31fb32 |
- "!SIBLING_CALL_P (insn) && GET_MODE (operands[3]) == Pmode"
|
|
|
31fb32 |
+ "!TARGET_INDIRECT_BRANCH_NOBP_CALL
|
|
|
31fb32 |
+ && !SIBLING_CALL_P (insn)
|
|
|
31fb32 |
+ && GET_MODE (operands[3]) == Pmode"
|
|
|
31fb32 |
+
|
|
|
31fb32 |
{
|
|
|
31fb32 |
if (get_attr_op_type (insn) == OP_TYPE_RR)
|
|
|
31fb32 |
return "basr\t%3,%1";
|
|
|
31fb32 |
@@ -9323,6 +9557,54 @@
|
|
|
31fb32 |
[(set (attr "op_type")
|
|
|
31fb32 |
(if_then_else (match_operand 1 "register_operand" "")
|
|
|
31fb32 |
(const_string "RR") (const_string "RX")))
|
|
|
31fb32 |
+ (set (attr "mnemonic")
|
|
|
31fb32 |
+ (if_then_else (match_operand 1 "register_operand" "")
|
|
|
31fb32 |
+ (const_string "basr") (const_string "bas")))
|
|
|
31fb32 |
+ (set_attr "type" "jsr")
|
|
|
31fb32 |
+ (set_attr "atype" "agen")
|
|
|
31fb32 |
+ (set_attr "z196prop" "z196_cracked")])
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+(define_insn "*basr_r_via_thunk_z10"
|
|
|
31fb32 |
+ [(set (match_operand 0 "" "")
|
|
|
31fb32 |
+ (call (mem:QI (match_operand 1 "register_operand" "a"))
|
|
|
31fb32 |
+ (match_operand 2 "const_int_operand" "n")))
|
|
|
31fb32 |
+ (clobber (match_operand 3 "register_operand" "=&r"))]
|
|
|
31fb32 |
+ "TARGET_INDIRECT_BRANCH_NOBP_CALL
|
|
|
31fb32 |
+ && TARGET_CPU_Z10
|
|
|
31fb32 |
+ && !SIBLING_CALL_P (insn)
|
|
|
31fb32 |
+ && GET_MODE (operands[3]) == Pmode"
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ s390_indirect_branch_via_thunk (REGNO (operands[1]),
|
|
|
31fb32 |
+ REGNO (operands[3]),
|
|
|
31fb32 |
+ NULL_RTX,
|
|
|
31fb32 |
+ s390_indirect_branch_type_call);
|
|
|
31fb32 |
+ return "";
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+ [(set_attr "op_type" "RIL")
|
|
|
31fb32 |
+ (set_attr "mnemonic" "brasl")
|
|
|
31fb32 |
+ (set_attr "type" "jsr")
|
|
|
31fb32 |
+ (set_attr "atype" "agen")
|
|
|
31fb32 |
+ (set_attr "z196prop" "z196_cracked")])
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+(define_insn "*basr_r_via_thunk"
|
|
|
31fb32 |
+ [(set (match_operand 0 "" "")
|
|
|
31fb32 |
+ (call (mem:QI (match_operand 1 "register_operand" "a"))
|
|
|
31fb32 |
+ (match_operand 2 "const_int_operand" "n")))
|
|
|
31fb32 |
+ (clobber (match_operand 3 "register_operand" "=&r"))
|
|
|
31fb32 |
+ (clobber (reg:P INDIRECT_BRANCH_THUNK_REGNUM))]
|
|
|
31fb32 |
+ "TARGET_INDIRECT_BRANCH_NOBP_CALL
|
|
|
31fb32 |
+ && !TARGET_CPU_Z10
|
|
|
31fb32 |
+ && !SIBLING_CALL_P (insn)
|
|
|
31fb32 |
+ && GET_MODE (operands[3]) == Pmode"
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ s390_indirect_branch_via_thunk (REGNO (operands[1]),
|
|
|
31fb32 |
+ REGNO (operands[3]),
|
|
|
31fb32 |
+ NULL_RTX,
|
|
|
31fb32 |
+ s390_indirect_branch_type_call);
|
|
|
31fb32 |
+ return "";
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+ [(set_attr "op_type" "RIL")
|
|
|
31fb32 |
+ (set_attr "mnemonic" "brasl")
|
|
|
31fb32 |
(set_attr "type" "jsr")
|
|
|
31fb32 |
(set_attr "atype" "agen")
|
|
|
31fb32 |
(set_attr "z196prop" "z196_cracked")])
|
|
|
31fb32 |
@@ -10056,15 +10338,78 @@
|
|
|
31fb32 |
""
|
|
|
31fb32 |
"s390_emit_epilogue (true); DONE;")
|
|
|
31fb32 |
|
|
|
31fb32 |
-(define_insn "*return"
|
|
|
31fb32 |
+(define_expand "return_use"
|
|
|
31fb32 |
+ [(parallel
|
|
|
31fb32 |
+ [(return)
|
|
|
31fb32 |
+ (use (match_operand 0 "register_operand" "a"))])]
|
|
|
31fb32 |
+ ""
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ if (!TARGET_CPU_Z10
|
|
|
31fb32 |
+ && TARGET_INDIRECT_BRANCH_NOBP_RET_OPTION)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ if (TARGET_64BIT)
|
|
|
31fb32 |
+ emit_jump_insn (gen_returndi_prez10 (operands[0]));
|
|
|
31fb32 |
+ else
|
|
|
31fb32 |
+ emit_jump_insn (gen_returnsi_prez10 (operands[0]));
|
|
|
31fb32 |
+ DONE;
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+})
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+(define_insn "*return<mode>"
|
|
|
31fb32 |
[(return)
|
|
|
31fb32 |
- (use (match_operand 0 "register_operand" "a"))]
|
|
|
31fb32 |
- "GET_MODE (operands[0]) == Pmode"
|
|
|
31fb32 |
- "br\t%0"
|
|
|
31fb32 |
- [(set_attr "op_type" "RR")
|
|
|
31fb32 |
+ (use (match_operand:P 0 "register_operand" "a"))]
|
|
|
31fb32 |
+ "TARGET_CPU_Z10 || !TARGET_INDIRECT_BRANCH_NOBP_RET_OPTION"
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ if (TARGET_INDIRECT_BRANCH_NOBP_RET)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ s390_indirect_branch_via_thunk (REGNO (operands[0]),
|
|
|
31fb32 |
+ INVALID_REGNUM,
|
|
|
31fb32 |
+ NULL_RTX,
|
|
|
31fb32 |
+ s390_indirect_branch_type_return);
|
|
|
31fb32 |
+ return "";
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+ else
|
|
|
31fb32 |
+ return "br\t%0";
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+ [(set (attr "op_type")
|
|
|
31fb32 |
+ (if_then_else (match_test "TARGET_INDIRECT_BRANCH_NOBP_RET")
|
|
|
31fb32 |
+ (const_string "RIL")
|
|
|
31fb32 |
+ (const_string "RR")))
|
|
|
31fb32 |
+ (set (attr "mnemonic")
|
|
|
31fb32 |
+ (if_then_else (match_test "TARGET_INDIRECT_BRANCH_NOBP_RET")
|
|
|
31fb32 |
+ (const_string "jg")
|
|
|
31fb32 |
+ (const_string "br")))
|
|
|
31fb32 |
(set_attr "type" "jsr")
|
|
|
31fb32 |
(set_attr "atype" "agen")])
|
|
|
31fb32 |
|
|
|
31fb32 |
+(define_insn "return<mode>_prez10"
|
|
|
31fb32 |
+ [(return)
|
|
|
31fb32 |
+ (use (match_operand:P 0 "register_operand" "a"))
|
|
|
31fb32 |
+ (clobber (reg:P INDIRECT_BRANCH_THUNK_REGNUM))]
|
|
|
31fb32 |
+ "!TARGET_CPU_Z10 && TARGET_INDIRECT_BRANCH_NOBP_RET_OPTION"
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ if (TARGET_INDIRECT_BRANCH_NOBP_RET)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ s390_indirect_branch_via_thunk (REGNO (operands[0]),
|
|
|
31fb32 |
+ INVALID_REGNUM,
|
|
|
31fb32 |
+ NULL_RTX,
|
|
|
31fb32 |
+ s390_indirect_branch_type_return);
|
|
|
31fb32 |
+ return "";
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+ else
|
|
|
31fb32 |
+ return "br\t%0";
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+ [(set (attr "op_type")
|
|
|
31fb32 |
+ (if_then_else (match_test "TARGET_INDIRECT_BRANCH_NOBP_RET")
|
|
|
31fb32 |
+ (const_string "RIL")
|
|
|
31fb32 |
+ (const_string "RR")))
|
|
|
31fb32 |
+ (set (attr "mnemonic")
|
|
|
31fb32 |
+ (if_then_else (match_test "TARGET_INDIRECT_BRANCH_NOBP_RET")
|
|
|
31fb32 |
+ (const_string "jg")
|
|
|
31fb32 |
+ (const_string "br")))
|
|
|
31fb32 |
+ (set_attr "type" "jsr")
|
|
|
31fb32 |
+ (set_attr "atype" "agen")])
|
|
|
31fb32 |
+
|
|
|
31fb32 |
|
|
|
31fb32 |
;; Instruction definition to extend a 31-bit pointer into a 64-bit
|
|
|
31fb32 |
;; pointer. This is used for compatibility.
|
|
|
31fb32 |
diff -Nrup gcc/config/s390/s390.opt gcc/config/s390/s390.opt
|
|
|
31fb32 |
--- gcc/config/s390/s390.opt 2018-03-27 09:33:19.763143675 -0600
|
|
|
31fb32 |
+++ gcc/config/s390/s390.opt 2018-03-27 09:33:58.832861566 -0600
|
|
|
31fb32 |
@@ -175,3 +175,59 @@ Target Report Joined RejectNegative UInt
|
|
|
31fb32 |
Set the branch costs for conditional branch instructions. Reasonable
|
|
|
31fb32 |
values are small, non-negative integers. The default branch cost is
|
|
|
31fb32 |
1.
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+mindirect-branch=
|
|
|
31fb32 |
+Target Report RejectNegative Joined Enum(indirect_branch) Var(s390_indirect_branch) Init(indirect_branch_keep)
|
|
|
31fb32 |
+Wrap all indirect branches into execute in order to disable branch
|
|
|
31fb32 |
+prediction.
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+mindirect-branch-jump=
|
|
|
31fb32 |
+Target Report RejectNegative Joined Enum(indirect_branch) Var(s390_indirect_branch_jump) Init(indirect_branch_keep)
|
|
|
31fb32 |
+Wrap indirect table jumps and computed gotos into execute in order to
|
|
|
31fb32 |
+disable branch prediction. Using thunk or thunk-extern with this
|
|
|
31fb32 |
+option requires the thunks to be considered signal handlers to order to
|
|
|
31fb32 |
+generate correct CFI. For environments where unwinding (e.g. for
|
|
|
31fb32 |
+exceptions) is required please use thunk-inline instead.
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+mindirect-branch-call=
|
|
|
31fb32 |
+Target Report RejectNegative Joined Enum(indirect_branch) Var(s390_indirect_branch_call) Init(indirect_branch_keep)
|
|
|
31fb32 |
+Wrap all indirect calls into execute in order to disable branch prediction.
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+mfunction-return=
|
|
|
31fb32 |
+Target Report RejectNegative Joined Enum(indirect_branch) Var(s390_function_return) Init(indirect_branch_keep)
|
|
|
31fb32 |
+Wrap all indirect return branches into execute in order to disable branch
|
|
|
31fb32 |
+prediction.
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+mfunction-return-mem=
|
|
|
31fb32 |
+Target Report RejectNegative Joined Enum(indirect_branch) Var(s390_function_return_mem) Init(indirect_branch_keep)
|
|
|
31fb32 |
+Wrap indirect return branches into execute in order to disable branch
|
|
|
31fb32 |
+prediction. This affects only branches where the return address is
|
|
|
31fb32 |
+going to be restored from memory.
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+mfunction-return-reg=
|
|
|
31fb32 |
+Target Report RejectNegative Joined Enum(indirect_branch) Var(s390_function_return_reg) Init(indirect_branch_keep)
|
|
|
31fb32 |
+Wrap indirect return branches into execute in order to disable branch
|
|
|
31fb32 |
+prediction. This affects only branches where the return address
|
|
|
31fb32 |
+doesn't need to be restored from memory.
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+Enum
|
|
|
31fb32 |
+Name(indirect_branch) Type(enum indirect_branch)
|
|
|
31fb32 |
+Known indirect branch choices (for use with the -mindirect-branch=/-mfunction-return= options):
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+EnumValue
|
|
|
31fb32 |
+Enum(indirect_branch) String(keep) Value(indirect_branch_keep)
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+EnumValue
|
|
|
31fb32 |
+Enum(indirect_branch) String(thunk) Value(indirect_branch_thunk)
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+EnumValue
|
|
|
31fb32 |
+Enum(indirect_branch) String(thunk-extern) Value(indirect_branch_thunk_extern)
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+mindirect-branch-table
|
|
|
31fb32 |
+Target Report Var(s390_indirect_branch_table) Init(TARGET_DEFAULT_INDIRECT_BRANCH_TABLE)
|
|
|
31fb32 |
+Generate sections .s390_indirect_jump, .s390_indirect_call,
|
|
|
31fb32 |
+.s390_return_reg, and .s390_return_mem to contain the indirect branch
|
|
|
31fb32 |
+locations which have been patched as part of using one of the
|
|
|
31fb32 |
+-mindirect-branch* or -mfunction-return* options. The sections
|
|
|
31fb32 |
+consist of an array of 32 bit elements. Each entry holds the offset
|
|
|
31fb32 |
+from the entry to the patched location.
|
|
|
31fb32 |
diff -Nrup gcc/config/s390/s390-opts.h gcc/config/s390/s390-opts.h
|
|
|
31fb32 |
--- gcc/config/s390/s390-opts.h 2018-03-27 09:33:19.764143668 -0600
|
|
|
31fb32 |
+++ gcc/config/s390/s390-opts.h 2018-03-27 09:33:58.821861645 -0600
|
|
|
31fb32 |
@@ -39,4 +39,12 @@ enum processor_type
|
|
|
31fb32 |
PROCESSOR_max
|
|
|
31fb32 |
};
|
|
|
31fb32 |
|
|
|
31fb32 |
+/* Values for -mindirect-branch and -mfunction-return options. */
|
|
|
31fb32 |
+enum indirect_branch {
|
|
|
31fb32 |
+ indirect_branch_unset = 0,
|
|
|
31fb32 |
+ indirect_branch_keep,
|
|
|
31fb32 |
+ indirect_branch_thunk,
|
|
|
31fb32 |
+ indirect_branch_thunk_extern
|
|
|
31fb32 |
+};
|
|
|
31fb32 |
+
|
|
|
31fb32 |
#endif
|
|
|
31fb32 |
diff -Nrup gcc/config/s390/s390-protos.h gcc/config/s390/s390-protos.h
|
|
|
31fb32 |
--- gcc/config/s390/s390-protos.h 2018-03-27 09:33:19.764143668 -0600
|
|
|
31fb32 |
+++ gcc/config/s390/s390-protos.h 2018-03-27 09:33:58.821861645 -0600
|
|
|
31fb32 |
@@ -41,6 +41,7 @@ extern void s390_set_has_landing_pad_p (
|
|
|
31fb32 |
extern bool s390_hard_regno_mode_ok (unsigned int, enum machine_mode);
|
|
|
31fb32 |
extern bool s390_hard_regno_rename_ok (unsigned int, unsigned int);
|
|
|
31fb32 |
extern int s390_class_max_nregs (enum reg_class, enum machine_mode);
|
|
|
31fb32 |
+extern bool s390_return_addr_from_memory(void);
|
|
|
31fb32 |
extern int s390_cannot_change_mode_class (enum machine_mode, enum machine_mode,
|
|
|
31fb32 |
enum reg_class);
|
|
|
31fb32 |
extern bool s390_function_arg_vector (enum machine_mode, const_tree);
|
|
|
31fb32 |
@@ -124,6 +125,18 @@ extern int s390_compare_and_branch_condi
|
|
|
31fb32 |
extern bool s390_extzv_shift_ok (int, int, unsigned HOST_WIDE_INT);
|
|
|
31fb32 |
extern void s390_asm_output_function_label (FILE *, const char *, tree);
|
|
|
31fb32 |
|
|
|
31fb32 |
+enum s390_indirect_branch_type
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ s390_indirect_branch_type_jump = 0,
|
|
|
31fb32 |
+ s390_indirect_branch_type_call,
|
|
|
31fb32 |
+ s390_indirect_branch_type_return
|
|
|
31fb32 |
+ };
|
|
|
31fb32 |
+extern void s390_indirect_branch_via_thunk (unsigned int regno,
|
|
|
31fb32 |
+ unsigned int return_addr_regno,
|
|
|
31fb32 |
+ rtx comparison_operator,
|
|
|
31fb32 |
+ enum s390_indirect_branch_type type);
|
|
|
31fb32 |
+extern void s390_indirect_branch_via_inline_thunk (rtx execute_target);
|
|
|
31fb32 |
+
|
|
|
31fb32 |
#endif /* RTX_CODE */
|
|
|
31fb32 |
|
|
|
31fb32 |
/* s390-c.c routines */
|
|
|
31fb32 |
diff -Nrup gcc/testsuite/gcc.target/s390/nobp-function-pointer-nothunk.c gcc/testsuite/gcc.target/s390/nobp-function-pointer-nothunk.c
|
|
|
31fb32 |
--- gcc/testsuite/gcc.target/s390/nobp-function-pointer-nothunk.c 1969-12-31 17:00:00.000000000 -0700
|
|
|
31fb32 |
+++ gcc/testsuite/gcc.target/s390/nobp-function-pointer-nothunk.c 2018-03-27 09:33:58.832861566 -0600
|
|
|
31fb32 |
@@ -0,0 +1,59 @@
|
|
|
31fb32 |
+/* { dg-do compile } */
|
|
|
31fb32 |
+/* { dg-options "-O3 -march=z10 --save-temps -mindirect-branch-call=thunk-extern -mindirect-branch-table" } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int gl;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+void __attribute__((noinline,noclone))
|
|
|
31fb32 |
+foo (int a)
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ gl = a + 40;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int __attribute__((noinline,noclone))
|
|
|
31fb32 |
+foo_value (int a)
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ return a + 40;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+void* __attribute__((noinline,noclone))
|
|
|
31fb32 |
+get_fptr (int a)
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ switch (a)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ case 0: return &foo; break;
|
|
|
31fb32 |
+ case 1: return &foo_value; break;
|
|
|
31fb32 |
+ default: __builtin_abort ();
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+void (*f) (int);
|
|
|
31fb32 |
+int (*g) (int);
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int
|
|
|
31fb32 |
+main ()
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ int res;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ f = get_fptr(0);
|
|
|
31fb32 |
+ f (2);
|
|
|
31fb32 |
+ if (gl != 42)
|
|
|
31fb32 |
+ __builtin_abort ();
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ g = get_fptr(1);
|
|
|
31fb32 |
+ if (g (2) != 42)
|
|
|
31fb32 |
+ __builtin_abort ();
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ return 0;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* 2 x main
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-times "brasl\t%r\[0-9\]*,__s390_indirect_jump" 2 } } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* No thunks due to thunk-extern. */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "exrl" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not ".globl __s390_indirect_jump" } } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_indirect_jump" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler "section\t.s390_indirect_call" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_return_reg" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_return_mem" } } */
|
|
|
31fb32 |
diff -Nrup gcc/testsuite/gcc.target/s390/nobp-function-pointer-z10.c gcc/testsuite/gcc.target/s390/nobp-function-pointer-z10.c
|
|
|
31fb32 |
--- gcc/testsuite/gcc.target/s390/nobp-function-pointer-z10.c 1969-12-31 17:00:00.000000000 -0700
|
|
|
31fb32 |
+++ gcc/testsuite/gcc.target/s390/nobp-function-pointer-z10.c 2018-03-27 09:33:58.833861558 -0600
|
|
|
31fb32 |
@@ -0,0 +1,56 @@
|
|
|
31fb32 |
+/* { dg-do run } */
|
|
|
31fb32 |
+/* { dg-options "-O3 -march=z10 --save-temps -mindirect-branch-call=thunk -mindirect-branch-table" } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int gl;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+void __attribute__((noinline,noclone))
|
|
|
31fb32 |
+foo (int a)
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ gl = a + 40;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int __attribute__((noinline,noclone))
|
|
|
31fb32 |
+foo_value (int a)
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ return a + 40;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+void* __attribute__((noinline,noclone))
|
|
|
31fb32 |
+get_fptr (int a)
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ switch (a)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ case 0: return &foo; break;
|
|
|
31fb32 |
+ case 1: return &foo_value; break;
|
|
|
31fb32 |
+ default: __builtin_abort ();
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+void (*f) (int);
|
|
|
31fb32 |
+int (*g) (int);
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int
|
|
|
31fb32 |
+main ()
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ int res;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ f = get_fptr(0);
|
|
|
31fb32 |
+ f (2);
|
|
|
31fb32 |
+ if (gl != 42)
|
|
|
31fb32 |
+ __builtin_abort ();
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ g = get_fptr(1);
|
|
|
31fb32 |
+ if (g (2) != 42)
|
|
|
31fb32 |
+ __builtin_abort ();
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ return 0;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* 2 x main
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-times "brasl\t%r\[0-9\]*,__s390_indirect_jump" 2 } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler "exrl" } } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_indirect_jump" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler "section\t.s390_indirect_call" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_return_reg" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_return_mem" } } */
|
|
|
31fb32 |
diff -Nrup gcc/testsuite/gcc.target/s390/nobp-function-pointer-z900.c gcc/testsuite/gcc.target/s390/nobp-function-pointer-z900.c
|
|
|
31fb32 |
--- gcc/testsuite/gcc.target/s390/nobp-function-pointer-z900.c 1969-12-31 17:00:00.000000000 -0700
|
|
|
31fb32 |
+++ gcc/testsuite/gcc.target/s390/nobp-function-pointer-z900.c 2018-03-27 09:33:58.833861558 -0600
|
|
|
31fb32 |
@@ -0,0 +1,56 @@
|
|
|
31fb32 |
+/* { dg-do run } */
|
|
|
31fb32 |
+/* { dg-options "-O3 -march=z900 --save-temps -mindirect-branch-call=thunk -mindirect-branch-table" } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int gl;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+void __attribute__((noinline,noclone))
|
|
|
31fb32 |
+foo (int a)
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ gl = a + 40;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int __attribute__((noinline,noclone))
|
|
|
31fb32 |
+foo_value (int a)
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ return a + 40;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+void* __attribute__((noinline,noclone))
|
|
|
31fb32 |
+get_fptr (int a)
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ switch (a)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ case 0: return &foo; break;
|
|
|
31fb32 |
+ case 1: return &foo_value; break;
|
|
|
31fb32 |
+ default: __builtin_abort ();
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+void (*f) (int);
|
|
|
31fb32 |
+int (*g) (int);
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int
|
|
|
31fb32 |
+main ()
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ int res;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ f = get_fptr(0);
|
|
|
31fb32 |
+ f (2);
|
|
|
31fb32 |
+ if (gl != 42)
|
|
|
31fb32 |
+ __builtin_abort ();
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ g = get_fptr(1);
|
|
|
31fb32 |
+ if (g (2) != 42)
|
|
|
31fb32 |
+ __builtin_abort ();
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ return 0;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* 2 x main
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-times "brasl\t%r\[0-9\]*,__s390_indirect_jump" 2 } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler "ex\t" } } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_indirect_jump" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler "section\t.s390_indirect_call" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_return_reg" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_return_mem" } } */
|
|
|
31fb32 |
diff -Nrup gcc/testsuite/gcc.target/s390/nobp-indirect-jump-nothunk.c gcc/testsuite/gcc.target/s390/nobp-indirect-jump-nothunk.c
|
|
|
31fb32 |
--- gcc/testsuite/gcc.target/s390/nobp-indirect-jump-nothunk.c 1969-12-31 17:00:00.000000000 -0700
|
|
|
31fb32 |
+++ gcc/testsuite/gcc.target/s390/nobp-indirect-jump-nothunk.c 2018-03-27 09:33:58.833861558 -0600
|
|
|
31fb32 |
@@ -0,0 +1,45 @@
|
|
|
31fb32 |
+/* { dg-do compile } */
|
|
|
31fb32 |
+/* { dg-options "-O3 -march=z10 --save-temps -mindirect-branch-jump=thunk-extern -mindirect-branch-table" } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* This is a copy of the gcc.c-torture/execute/20040302-1.c
|
|
|
31fb32 |
+ testcase. */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int code[]={0,0,0,0,1};
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+void
|
|
|
31fb32 |
+foo(int x) {
|
|
|
31fb32 |
+ volatile int b;
|
|
|
31fb32 |
+ b = 0xffffffff;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+void
|
|
|
31fb32 |
+bar(int *pc) {
|
|
|
31fb32 |
+ static const void *l[] = {&&lab0, &&end;;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ foo(0);
|
|
|
31fb32 |
+ goto *l[*pc];
|
|
|
31fb32 |
+ lab0:
|
|
|
31fb32 |
+ foo(0);
|
|
|
31fb32 |
+ pc++;
|
|
|
31fb32 |
+ goto *l[*pc];
|
|
|
31fb32 |
+ end:
|
|
|
31fb32 |
+ return;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int
|
|
|
31fb32 |
+main() {
|
|
|
31fb32 |
+ bar(code);
|
|
|
31fb32 |
+ return 0;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* 2 x bar
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-times "jg\t__s390_indirect_jump" 2 } } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* No thunks due to thunk-extern. */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "exrl" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not ".globl __s390_indirect_jump" } } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* { dg-final { scan-assembler "section\t.s390_indirect_jump" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_indirect_call" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_return_reg" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_return_mem" } } */
|
|
|
31fb32 |
diff -Nrup gcc/testsuite/gcc.target/s390/nobp-indirect-jump-z10.c gcc/testsuite/gcc.target/s390/nobp-indirect-jump-z10.c
|
|
|
31fb32 |
--- gcc/testsuite/gcc.target/s390/nobp-indirect-jump-z10.c 1969-12-31 17:00:00.000000000 -0700
|
|
|
31fb32 |
+++ gcc/testsuite/gcc.target/s390/nobp-indirect-jump-z10.c 2018-03-27 09:33:58.834861551 -0600
|
|
|
31fb32 |
@@ -0,0 +1,42 @@
|
|
|
31fb32 |
+/* { dg-do run } */
|
|
|
31fb32 |
+/* { dg-options "-O3 -march=z10 --save-temps -mindirect-branch-jump=thunk -mindirect-branch-table" } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* This is a copy of the gcc.c-torture/execute/20040302-1.c
|
|
|
31fb32 |
+ testcase. */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int code[]={0,0,0,0,1};
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+void
|
|
|
31fb32 |
+foo(int x) {
|
|
|
31fb32 |
+ volatile int b;
|
|
|
31fb32 |
+ b = 0xffffffff;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+void
|
|
|
31fb32 |
+bar(int *pc) {
|
|
|
31fb32 |
+ static const void *l[] = {&&lab0, &&end;;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ foo(0);
|
|
|
31fb32 |
+ goto *l[*pc];
|
|
|
31fb32 |
+ lab0:
|
|
|
31fb32 |
+ foo(0);
|
|
|
31fb32 |
+ pc++;
|
|
|
31fb32 |
+ goto *l[*pc];
|
|
|
31fb32 |
+ end:
|
|
|
31fb32 |
+ return;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int
|
|
|
31fb32 |
+main() {
|
|
|
31fb32 |
+ bar(code);
|
|
|
31fb32 |
+ return 0;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* 2x bar */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-times "jg\t__s390_indirect_jump" 2 } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler "exrl" } } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* { dg-final { scan-assembler "section\t.s390_indirect_jump" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_indirect_call" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_return_reg" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_return_mem" } } */
|
|
|
31fb32 |
diff -Nrup gcc/testsuite/gcc.target/s390/nobp-indirect-jump-z900.c gcc/testsuite/gcc.target/s390/nobp-indirect-jump-z900.c
|
|
|
31fb32 |
--- gcc/testsuite/gcc.target/s390/nobp-indirect-jump-z900.c 1969-12-31 17:00:00.000000000 -0700
|
|
|
31fb32 |
+++ gcc/testsuite/gcc.target/s390/nobp-indirect-jump-z900.c 2018-03-27 09:33:58.834861551 -0600
|
|
|
31fb32 |
@@ -0,0 +1,42 @@
|
|
|
31fb32 |
+/* { dg-do run } */
|
|
|
31fb32 |
+/* { dg-options "-O3 -march=z900 --save-temps -mindirect-branch-jump=thunk -mindirect-branch-table" } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* This is a copy of the gcc.c-torture/execute/20040302-1.c
|
|
|
31fb32 |
+ testcase. */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int code[]={0,0,0,0,1};
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+void
|
|
|
31fb32 |
+foo(int x) {
|
|
|
31fb32 |
+ volatile int b;
|
|
|
31fb32 |
+ b = 0xffffffff;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+void
|
|
|
31fb32 |
+bar(int *pc) {
|
|
|
31fb32 |
+ static const void *l[] = {&&lab0, &&end;;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ foo(0);
|
|
|
31fb32 |
+ goto *l[*pc];
|
|
|
31fb32 |
+ lab0:
|
|
|
31fb32 |
+ foo(0);
|
|
|
31fb32 |
+ pc++;
|
|
|
31fb32 |
+ goto *l[*pc];
|
|
|
31fb32 |
+ end:
|
|
|
31fb32 |
+ return;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int
|
|
|
31fb32 |
+main() {
|
|
|
31fb32 |
+ bar(code);
|
|
|
31fb32 |
+ return 0;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* 2 x bar
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-times "jg\t__s390_indirect_jump" 2 } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler "ex\t" } } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* { dg-final { scan-assembler "section\t.s390_indirect_jump" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_indirect_call" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_return_reg" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_return_mem" } } */
|
|
|
31fb32 |
diff -Nrup gcc/testsuite/gcc.target/s390/nobp-return-mem-nothunk.c gcc/testsuite/gcc.target/s390/nobp-return-mem-nothunk.c
|
|
|
31fb32 |
--- gcc/testsuite/gcc.target/s390/nobp-return-mem-nothunk.c 1969-12-31 17:00:00.000000000 -0700
|
|
|
31fb32 |
+++ gcc/testsuite/gcc.target/s390/nobp-return-mem-nothunk.c 2018-03-27 09:33:58.834861551 -0600
|
|
|
31fb32 |
@@ -0,0 +1,44 @@
|
|
|
31fb32 |
+/* { dg-do compile } */
|
|
|
31fb32 |
+/* { dg-options "-O3 -march=z10 -mzarch --save-temps -mfunction-return-mem=thunk-extern -mindirect-branch-table" } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int gl = 0;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int __attribute__((noinline,noclone))
|
|
|
31fb32 |
+bar (int a)
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ return a + 2;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+void __attribute__((noinline,noclone))
|
|
|
31fb32 |
+foo (int a)
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ int i;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ if (a == 42)
|
|
|
31fb32 |
+ return;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ for (i = 0; i < a; i++)
|
|
|
31fb32 |
+ gl += bar (i);
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int
|
|
|
31fb32 |
+main ()
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ foo (3);
|
|
|
31fb32 |
+ if (gl != 9)
|
|
|
31fb32 |
+ __builtin_abort ();
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ return 0;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* 1 x foo, 1 x main
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-times "jg\t__s390_indirect_jump" 2 } } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* No thunks due to thunk-extern. */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "exrl" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not ".globl __s390_indirect_jump" } } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_indirect_jump" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_indirect_call" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_return_reg" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler "section\t.s390_return_mem" } } */
|
|
|
31fb32 |
diff -Nrup gcc/testsuite/gcc.target/s390/nobp-return-mem-z10.c gcc/testsuite/gcc.target/s390/nobp-return-mem-z10.c
|
|
|
31fb32 |
--- gcc/testsuite/gcc.target/s390/nobp-return-mem-z10.c 1969-12-31 17:00:00.000000000 -0700
|
|
|
31fb32 |
+++ gcc/testsuite/gcc.target/s390/nobp-return-mem-z10.c 2018-03-27 09:33:58.835861544 -0600
|
|
|
31fb32 |
@@ -0,0 +1,41 @@
|
|
|
31fb32 |
+/* { dg-do run } */
|
|
|
31fb32 |
+/* { dg-options "-O3 -march=z10 -mzarch --save-temps -mfunction-return-mem=thunk -mindirect-branch-table" } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int gl = 0;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int __attribute__((noinline,noclone))
|
|
|
31fb32 |
+bar (int a)
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ return a + 2;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+void __attribute__((noinline,noclone))
|
|
|
31fb32 |
+foo (int a)
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ int i;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ if (a == 42)
|
|
|
31fb32 |
+ return;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ for (i = 0; i < a; i++)
|
|
|
31fb32 |
+ gl += bar (i);
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int
|
|
|
31fb32 |
+main ()
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ foo (3);
|
|
|
31fb32 |
+ if (gl != 9)
|
|
|
31fb32 |
+ __builtin_abort ();
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ return 0;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* 1 x foo, 1 x main
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-times "jg\t__s390_indirect_jump" 2 } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler "exrl" } } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_indirect_jump" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_indirect_call" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_return_reg" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler "section\t.s390_return_mem" } } */
|
|
|
31fb32 |
diff -Nrup gcc/testsuite/gcc.target/s390/nobp-return-mem-z900.c gcc/testsuite/gcc.target/s390/nobp-return-mem-z900.c
|
|
|
31fb32 |
--- gcc/testsuite/gcc.target/s390/nobp-return-mem-z900.c 1969-12-31 17:00:00.000000000 -0700
|
|
|
31fb32 |
+++ gcc/testsuite/gcc.target/s390/nobp-return-mem-z900.c 2018-03-27 09:33:58.835861544 -0600
|
|
|
31fb32 |
@@ -0,0 +1,42 @@
|
|
|
31fb32 |
+/* { dg-do run } */
|
|
|
31fb32 |
+/* { dg-options "-O3 -march=z900 --save-temps -mfunction-return-mem=thunk -mindirect-branch-table" } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int gl = 0;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int __attribute__((noinline,noclone))
|
|
|
31fb32 |
+bar (int a)
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ return a + 2;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+void __attribute__((noinline,noclone))
|
|
|
31fb32 |
+foo (int a)
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ int i;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ if (a == 42)
|
|
|
31fb32 |
+ return;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ for (i = 0; i < a; i++)
|
|
|
31fb32 |
+ gl += bar (i);
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int
|
|
|
31fb32 |
+main ()
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ foo (3);
|
|
|
31fb32 |
+ if (gl != 9)
|
|
|
31fb32 |
+ __builtin_abort ();
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ return 0;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* 1 x foo, 1 x main
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-times "jg\t__s390_indirect_jump" 2 } } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* { dg-final { scan-assembler "ex\t" } } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_indirect_jump" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_indirect_call" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_return_reg" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler "section\t.s390_return_mem" } } */
|
|
|
31fb32 |
diff -Nrup gcc/testsuite/gcc.target/s390/nobp-return-reg-nothunk.c gcc/testsuite/gcc.target/s390/nobp-return-reg-nothunk.c
|
|
|
31fb32 |
--- gcc/testsuite/gcc.target/s390/nobp-return-reg-nothunk.c 1969-12-31 17:00:00.000000000 -0700
|
|
|
31fb32 |
+++ gcc/testsuite/gcc.target/s390/nobp-return-reg-nothunk.c 2018-03-27 09:33:58.835861544 -0600
|
|
|
31fb32 |
@@ -0,0 +1,44 @@
|
|
|
31fb32 |
+/* { dg-do compile } */
|
|
|
31fb32 |
+/* { dg-options "-O3 -march=z10 --save-temps -mfunction-return-reg=thunk-extern -mindirect-branch-table" } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int gl = 0;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int __attribute__((noinline,noclone))
|
|
|
31fb32 |
+bar (int a)
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ return a + 2;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+void __attribute__((noinline,noclone))
|
|
|
31fb32 |
+foo (int a)
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ int i;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ if (a == 42)
|
|
|
31fb32 |
+ return;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ for (i = 0; i < a; i++)
|
|
|
31fb32 |
+ gl += bar (i);
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int
|
|
|
31fb32 |
+main ()
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ foo (3);
|
|
|
31fb32 |
+ if (gl != 9)
|
|
|
31fb32 |
+ __builtin_abort ();
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ return 0;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* 1 x bar
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-times "jg\t__s390_indirect_jump" 1 } } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* No thunks due to thunk-extern. */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "exrl" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not ".globl __s390_indirect_jump" } } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_indirect_jump" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_indirect_call" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler "section\t.s390_return_reg" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_return_mem" } } */
|
|
|
31fb32 |
diff -Nrup gcc/testsuite/gcc.target/s390/nobp-return-reg-z10.c gcc/testsuite/gcc.target/s390/nobp-return-reg-z10.c
|
|
|
31fb32 |
--- gcc/testsuite/gcc.target/s390/nobp-return-reg-z10.c 1969-12-31 17:00:00.000000000 -0700
|
|
|
31fb32 |
+++ gcc/testsuite/gcc.target/s390/nobp-return-reg-z10.c 2018-03-27 09:33:58.836861537 -0600
|
|
|
31fb32 |
@@ -0,0 +1,41 @@
|
|
|
31fb32 |
+/* { dg-do run } */
|
|
|
31fb32 |
+/* { dg-options "-O3 -march=z10 --save-temps -mfunction-return-reg=thunk -mindirect-branch-table" } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int gl = 0;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int __attribute__((noinline,noclone))
|
|
|
31fb32 |
+bar (int a)
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ return a + 2;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+void __attribute__((noinline,noclone))
|
|
|
31fb32 |
+foo (int a)
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ int i;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ if (a == 42)
|
|
|
31fb32 |
+ return;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ for (i = 0; i < a; i++)
|
|
|
31fb32 |
+ gl += bar (i);
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int
|
|
|
31fb32 |
+main ()
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ foo (3);
|
|
|
31fb32 |
+ if (gl != 9)
|
|
|
31fb32 |
+ __builtin_abort ();
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ return 0;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* 1 x bar
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-times "jg\t__s390_indirect_jump" 1 } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler "exrl" } } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_indirect_jump" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_indirect_call" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler "section\t.s390_return_reg" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_return_mem" } } */
|
|
|
31fb32 |
diff -Nrup gcc/testsuite/gcc.target/s390/nobp-return-reg-z900.c gcc/testsuite/gcc.target/s390/nobp-return-reg-z900.c
|
|
|
31fb32 |
--- gcc/testsuite/gcc.target/s390/nobp-return-reg-z900.c 1969-12-31 17:00:00.000000000 -0700
|
|
|
31fb32 |
+++ gcc/testsuite/gcc.target/s390/nobp-return-reg-z900.c 2018-03-27 09:33:58.836861537 -0600
|
|
|
31fb32 |
@@ -0,0 +1,41 @@
|
|
|
31fb32 |
+/* { dg-do run } */
|
|
|
31fb32 |
+/* { dg-options "-O3 -march=z900 --save-temps -mfunction-return-reg=thunk -mindirect-branch-table" } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int gl = 0;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int __attribute__((noinline,noclone))
|
|
|
31fb32 |
+bar (int a)
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ return a + 2;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+void __attribute__((noinline,noclone))
|
|
|
31fb32 |
+foo (int a)
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ int i;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ if (a == 42)
|
|
|
31fb32 |
+ return;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ for (i = 0; i < a; i++)
|
|
|
31fb32 |
+ gl += bar (i);
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int
|
|
|
31fb32 |
+main ()
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ foo (3);
|
|
|
31fb32 |
+ if (gl != 9)
|
|
|
31fb32 |
+ __builtin_abort ();
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ return 0;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* 1 x bar
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-times "jg\t__s390_indirect_jump" 1 } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler "ex\t" } } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_indirect_jump" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_indirect_call" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler "section\t.s390_return_reg" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_return_mem" } } */
|
|
|
31fb32 |
diff -Nrup gcc/testsuite/gcc.target/s390/nobp-table-jump-z10.c gcc/testsuite/gcc.target/s390/nobp-table-jump-z10.c
|
|
|
31fb32 |
--- gcc/testsuite/gcc.target/s390/nobp-table-jump-z10.c 1969-12-31 17:00:00.000000000 -0700
|
|
|
31fb32 |
+++ gcc/testsuite/gcc.target/s390/nobp-table-jump-z10.c 2018-03-27 09:33:58.836861537 -0600
|
|
|
31fb32 |
@@ -0,0 +1,77 @@
|
|
|
31fb32 |
+/* { dg-do run } */
|
|
|
31fb32 |
+/* { dg-options "-O3 -march=z10 -mzarch --save-temps -mindirect-branch-jump=thunk -mindirect-branch-table" } */
|
|
|
31fb32 |
+/* case-values-threshold will be set to 20 by the back-end when jump
|
|
|
31fb32 |
+ thunk are requested. */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo1 (void) { return 1; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo2 (void) { return 2; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo3 (void) { return 3; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo4 (void) { return 4; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo5 (void) { return 5; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo6 (void) { return 6; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo7 (void) { return 7; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo8 (void) { return 8; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo9 (void) { return 9; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo10 (void) { return 10; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo11 (void) { return 11; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo12 (void) { return 12; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo13 (void) { return 13; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo14 (void) { return 14; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo15 (void) { return 15; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo16 (void) { return 16; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo17 (void) { return 17; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo18 (void) { return 18; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo19 (void) { return 19; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo20 (void) { return 20; }
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int __attribute__((noinline,noclone))
|
|
|
31fb32 |
+bar (int a)
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ int ret = 0;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ switch (a)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ case 1: ret = foo1 (); break;
|
|
|
31fb32 |
+ case 2: ret = foo2 (); break;
|
|
|
31fb32 |
+ case 3: ret = foo3 (); break;
|
|
|
31fb32 |
+ case 4: ret = foo4 (); break;
|
|
|
31fb32 |
+ case 5: ret = foo5 (); break;
|
|
|
31fb32 |
+ case 6: ret = foo6 (); break;
|
|
|
31fb32 |
+ case 7: ret = foo7 (); break;
|
|
|
31fb32 |
+ case 8: ret = foo8 (); break;
|
|
|
31fb32 |
+ case 9: ret = foo9 (); break;
|
|
|
31fb32 |
+ case 10: ret = foo10 (); break;
|
|
|
31fb32 |
+ case 11: ret = foo11 (); break;
|
|
|
31fb32 |
+ case 12: ret = foo12 (); break;
|
|
|
31fb32 |
+ case 13: ret = foo13 (); break;
|
|
|
31fb32 |
+ case 14: ret = foo14 (); break;
|
|
|
31fb32 |
+ case 15: ret = foo15 (); break;
|
|
|
31fb32 |
+ case 16: ret = foo16 (); break;
|
|
|
31fb32 |
+ case 17: ret = foo17 (); break;
|
|
|
31fb32 |
+ case 18: ret = foo18 (); break;
|
|
|
31fb32 |
+ case 19: ret = foo19 (); break;
|
|
|
31fb32 |
+ case 20: ret = foo20 (); break;
|
|
|
31fb32 |
+ default:
|
|
|
31fb32 |
+ __builtin_abort ();
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ return ret;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int
|
|
|
31fb32 |
+main ()
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ if (bar (3) != 3)
|
|
|
31fb32 |
+ __builtin_abort ();
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ return 0;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* 1 x bar
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-times "exrl" 1 } } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* { dg-final { scan-assembler "section\t.s390_indirect_jump" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_indirect_call" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_return_fromreg" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_return_frommem" } } */
|
|
|
31fb32 |
diff -Nrup gcc/testsuite/gcc.target/s390/nobp-table-jump-z900.c gcc/testsuite/gcc.target/s390/nobp-table-jump-z900.c
|
|
|
31fb32 |
--- gcc/testsuite/gcc.target/s390/nobp-table-jump-z900.c 1969-12-31 17:00:00.000000000 -0700
|
|
|
31fb32 |
+++ gcc/testsuite/gcc.target/s390/nobp-table-jump-z900.c 2018-03-27 09:33:58.837861529 -0600
|
|
|
31fb32 |
@@ -0,0 +1,78 @@
|
|
|
31fb32 |
+/* { dg-do run } */
|
|
|
31fb32 |
+/* { dg-options "-O3 -march=z900 -mzarch --save-temps -mindirect-branch-jump=thunk -mindirect-branch-table" } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* case-values-threshold will be set to 20 by the back-end when jump
|
|
|
31fb32 |
+ thunk are requested. */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo1 (void) { return 1; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo2 (void) { return 2; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo3 (void) { return 3; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo4 (void) { return 4; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo5 (void) { return 5; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo6 (void) { return 6; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo7 (void) { return 7; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo8 (void) { return 8; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo9 (void) { return 9; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo10 (void) { return 10; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo11 (void) { return 11; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo12 (void) { return 12; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo13 (void) { return 13; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo14 (void) { return 14; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo15 (void) { return 15; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo16 (void) { return 16; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo17 (void) { return 17; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo18 (void) { return 18; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo19 (void) { return 19; }
|
|
|
31fb32 |
+int __attribute__((noinline,noclone)) foo20 (void) { return 20; }
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int __attribute__((noinline,noclone))
|
|
|
31fb32 |
+bar (int a)
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ int ret = 0;
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ switch (a)
|
|
|
31fb32 |
+ {
|
|
|
31fb32 |
+ case 1: ret = foo1 (); break;
|
|
|
31fb32 |
+ case 2: ret = foo2 (); break;
|
|
|
31fb32 |
+ case 3: ret = foo3 (); break;
|
|
|
31fb32 |
+ case 4: ret = foo4 (); break;
|
|
|
31fb32 |
+ case 5: ret = foo5 (); break;
|
|
|
31fb32 |
+ case 6: ret = foo6 (); break;
|
|
|
31fb32 |
+ case 7: ret = foo7 (); break;
|
|
|
31fb32 |
+ case 8: ret = foo8 (); break;
|
|
|
31fb32 |
+ case 9: ret = foo9 (); break;
|
|
|
31fb32 |
+ case 10: ret = foo10 (); break;
|
|
|
31fb32 |
+ case 11: ret = foo11 (); break;
|
|
|
31fb32 |
+ case 12: ret = foo12 (); break;
|
|
|
31fb32 |
+ case 13: ret = foo13 (); break;
|
|
|
31fb32 |
+ case 14: ret = foo14 (); break;
|
|
|
31fb32 |
+ case 15: ret = foo15 (); break;
|
|
|
31fb32 |
+ case 16: ret = foo16 (); break;
|
|
|
31fb32 |
+ case 17: ret = foo17 (); break;
|
|
|
31fb32 |
+ case 18: ret = foo18 (); break;
|
|
|
31fb32 |
+ case 19: ret = foo19 (); break;
|
|
|
31fb32 |
+ case 20: ret = foo20 (); break;
|
|
|
31fb32 |
+ default:
|
|
|
31fb32 |
+ __builtin_abort ();
|
|
|
31fb32 |
+ }
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ return ret;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+int
|
|
|
31fb32 |
+main ()
|
|
|
31fb32 |
+{
|
|
|
31fb32 |
+ if (bar (3) != 3)
|
|
|
31fb32 |
+ __builtin_abort ();
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+ return 0;
|
|
|
31fb32 |
+}
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* 1 x bar
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-times "ex\t" 1 } } */
|
|
|
31fb32 |
+
|
|
|
31fb32 |
+/* { dg-final { scan-assembler "section\t.s390_indirect_jump" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_indirect_call" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_return_fromreg" } } */
|
|
|
31fb32 |
+/* { dg-final { scan-assembler-not "section\t.s390_return_frommem" } } */
|