Commit 66e30545 by Iain Sandoe Committed by Iain Sandoe

rs6000, darwin - fix bootstrap.

Recent changes to the lowerings for call handling in rs6000
have broken bootstrap for powerpc-darwin.  This patch modifies
the calls to handle Darwin asa subset, a subsequent patch will
split Darwin out.

2018-12-12  Iain Sandoe  <iain@sandoe.co.uk>

	* config/rs6000/darwin.md (call_indirect_nonlocal_darwin64): Remove.
	(call_nonlocal_darwin64): Remove.
	(call_value_indirect_nonlocal_darwin64): Remove.
	(call_value_nonlocal_darwin64): Remove.
	* config/rs6000/rs6000.c (rs6000_call_template_1): Handle Darwin with
	the same asm output as AIX/ELFv2.  (rs6000_call_sysv): Preserve the
	CALL_LONG flag when needed for Darwin.
	* config/rs6000/rs6000.md (define expand “call”): Expand Darwin as
	per sysv.
	(define_expand “call_value”): Likewise.
	(define_expand “sibcall”): Likewise.
	(define_expand “sibcall_value”): Likewise.
	(call_indirect_nonlocal_sysv): Mark the clobber mode P.
	(call_nonlocal_sysv): Likewise.
	(call_nonlocal_sysv_secure): Likewise.
	(call_value_indirect_nonlocal_sysv): Likewise.
	(call_value_nonlocal_sysv): Likewise.
	(call_value_nonlocal_sysv_secure): Likewise.
	(call_local64): Mark the clobber DI.
	(call_value_local64): Likewise.

From-SVN: r267046
parent 0d7924f2
2018-12-12 Iain Sandoe <iain@sandoe.co.uk>
* config/rs6000/darwin.md (call_indirect_nonlocal_darwin64): Remove.
(call_nonlocal_darwin64): Remove.
(call_value_indirect_nonlocal_darwin64): Remove.
(call_value_nonlocal_darwin64): Remove.
* config/rs6000/rs6000.c (rs6000_call_template_1): Handle Darwin with
the same asm output as AIX/ELFv2. (rs6000_call_sysv): Preserve the
CALL_LONG flag when needed for Darwin.
* config/rs6000/rs6000.md (define expand “call”): Expand Darwin as
per sysv.
(define_expand “call_value”): Likewise.
(define_expand “sibcall”): Likewise.
(define_expand “sibcall_value”): Likewise.
(call_indirect_nonlocal_sysv): Mark the clobber mode P.
(call_nonlocal_sysv): Likewise.
(call_nonlocal_sysv_secure): Likewise.
(call_value_indirect_nonlocal_sysv): Likewise.
(call_value_nonlocal_sysv): Likewise.
(call_value_nonlocal_sysv_secure): Likewise.
(call_local64): Mark the clobber DI.
(call_value_local64): Likewise.
2018-12-11 Jakub Jelinek <jakub@redhat.com> 2018-12-11 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/88444 PR tree-optimization/88444
...@@ -300,66 +300,6 @@ You should have received a copy of the GNU General Public License ...@@ -300,66 +300,6 @@ You should have received a copy of the GNU General Public License
"addis %0,%1,ha16(%2-%3)\n\taddi %0,%0,lo16(%2-%3)" "addis %0,%1,ha16(%2-%3)\n\taddi %0,%0,lo16(%2-%3)"
[(set_attr "length" "8")]) [(set_attr "length" "8")])
(define_insn "*call_indirect_nonlocal_darwin64"
[(call (mem:SI (match_operand:DI 0 "register_operand" "c,*l,c,*l"))
(match_operand 1))
(use (match_operand:SI 2 "immediate_operand" "O,O,n,n"))
(clobber (reg:SI LR_REGNO))]
"DEFAULT_ABI == ABI_DARWIN && TARGET_64BIT"
{
return "b%T0l";
}
[(set_attr "type" "jmpreg,jmpreg,jmpreg,jmpreg")
(set_attr "length" "4,4,8,8")])
(define_insn "*call_nonlocal_darwin64"
[(call (mem:SI (match_operand:DI 0 "symbol_ref_operand" "s,s"))
(match_operand 1))
(use (match_operand:SI 2 "immediate_operand" "O,n"))
(clobber (reg:SI LR_REGNO))]
"(DEFAULT_ABI == ABI_DARWIN)
&& (INTVAL (operands[2]) & CALL_LONG) == 0"
{
#if TARGET_MACHO
return output_call(insn, operands, 0, 2);
#else
gcc_unreachable ();
#endif
}
[(set_attr "type" "branch,branch")
(set_attr "length" "4,8")])
(define_insn "*call_value_indirect_nonlocal_darwin64"
[(set (match_operand 0 "" "")
(call (mem:SI (match_operand:DI 1 "register_operand" "c,*l,c,*l"))
(match_operand 2)))
(use (match_operand:SI 3 "immediate_operand" "O,O,n,n"))
(clobber (reg:SI LR_REGNO))]
"DEFAULT_ABI == ABI_DARWIN"
{
return "b%T1l";
}
[(set_attr "type" "jmpreg,jmpreg,jmpreg,jmpreg")
(set_attr "length" "4,4,8,8")])
(define_insn "*call_value_nonlocal_darwin64"
[(set (match_operand 0 "" "")
(call (mem:SI (match_operand:DI 1 "symbol_ref_operand" "s,s"))
(match_operand 2)))
(use (match_operand:SI 3 "immediate_operand" "O,n"))
(clobber (reg:SI LR_REGNO))]
"(DEFAULT_ABI == ABI_DARWIN)
&& (INTVAL (operands[3]) & CALL_LONG) == 0"
{
#if TARGET_MACHO
return output_call(insn, operands, 1, 3);
#else
gcc_unreachable ();
#endif
}
[(set_attr "type" "branch,branch")
(set_attr "length" "4,8")])
(define_expand "reload_macho_picbase" (define_expand "reload_macho_picbase"
[(set (reg:SI LR_REGNO) [(set (reg:SI LR_REGNO)
(unspec [(match_operand 0 "")] (unspec [(match_operand 0 "")]
......
...@@ -21534,7 +21534,8 @@ rs6000_call_template_1 (rtx *operands, unsigned int funop, bool sibcall) ...@@ -21534,7 +21534,8 @@ rs6000_call_template_1 (rtx *operands, unsigned int funop, bool sibcall)
? "+32768" : "")); ? "+32768" : ""));
static char str[32]; /* 2 spare */ static char str[32]; /* 2 spare */
if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2) if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2
|| DEFAULT_ABI == ABI_DARWIN)
sprintf (str, "b%s %s%s%s", sibcall ? "" : "l", z, arg, sprintf (str, "b%s %s%s%s", sibcall ? "" : "l", z, arg,
sibcall ? "" : "\n\tnop"); sibcall ? "" : "\n\tnop");
else if (DEFAULT_ABI == ABI_V4) else if (DEFAULT_ABI == ABI_V4)
...@@ -37958,6 +37959,7 @@ rs6000_call_sysv (rtx value, rtx func_desc, rtx tlsarg, rtx cookie) ...@@ -37958,6 +37959,7 @@ rs6000_call_sysv (rtx value, rtx func_desc, rtx tlsarg, rtx cookie)
/* Handle longcall attributes. */ /* Handle longcall attributes. */
if ((INTVAL (cookie) & CALL_LONG) != 0 if ((INTVAL (cookie) & CALL_LONG) != 0
&& DEFAULT_ABI != ABI_DARWIN /* Darwin does it's own thing. */
&& GET_CODE (func_desc) == SYMBOL_REF) && GET_CODE (func_desc) == SYMBOL_REF)
{ {
func = rs6000_longcall_ref (func_desc, tlsarg); func = rs6000_longcall_ref (func_desc, tlsarg);
...@@ -37998,8 +38000,13 @@ rs6000_call_sysv (rtx value, rtx func_desc, rtx tlsarg, rtx cookie) ...@@ -37998,8 +38000,13 @@ rs6000_call_sysv (rtx value, rtx func_desc, rtx tlsarg, rtx cookie)
if (value != NULL_RTX) if (value != NULL_RTX)
call[0] = gen_rtx_SET (value, call[0]); call[0] = gen_rtx_SET (value, call[0]);
unsigned int mask = CALL_V4_SET_FP_ARGS | CALL_V4_CLEAR_FP_ARGS; if (DEFAULT_ABI == ABI_DARWIN && TARGET_32BIT)
call[1] = gen_rtx_USE (VOIDmode, GEN_INT (INTVAL (cookie) & mask)); call[1] = gen_rtx_USE (VOIDmode, GEN_INT (INTVAL (cookie)));
else
{
unsigned int mask = CALL_V4_SET_FP_ARGS | CALL_V4_CLEAR_FP_ARGS;
call[1] = gen_rtx_USE (VOIDmode, GEN_INT (INTVAL (cookie) & mask));
}
call[2] = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (Pmode, LR_REGNO)); call[2] = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (Pmode, LR_REGNO));
...@@ -10266,6 +10266,7 @@ ...@@ -10266,6 +10266,7 @@
}) })
;; Call and call_value insns ;; Call and call_value insns
;; For the purposes of expanding calls, Darwin is very similar to SYSV.
(define_expand "call" (define_expand "call"
[(parallel [(call (mem:SI (match_operand 0 "address_operand")) [(parallel [(call (mem:SI (match_operand 0 "address_operand"))
(match_operand 1 "")) (match_operand 1 ""))
...@@ -10283,19 +10284,11 @@ ...@@ -10283,19 +10284,11 @@
operands[0] = XEXP (operands[0], 0); operands[0] = XEXP (operands[0], 0);
if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2) if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
{ rs6000_call_aix (NULL_RTX, operands[0], operands[1], operands[2]);
rs6000_call_aix (NULL_RTX, operands[0], operands[1], operands[2]); else
DONE; rs6000_call_sysv (NULL_RTX, operands[0], operands[1], operands[2]);
}
if (DEFAULT_ABI == ABI_V4)
{
rs6000_call_sysv (NULL_RTX, operands[0], operands[1], operands[2]);
DONE;
}
if (GET_CODE (operands[0]) != SYMBOL_REF) DONE;
operands[0] = force_reg (Pmode, operands[0]);
}) })
(define_expand "call_value" (define_expand "call_value"
...@@ -10316,19 +10309,11 @@ ...@@ -10316,19 +10309,11 @@
operands[1] = XEXP (operands[1], 0); operands[1] = XEXP (operands[1], 0);
if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2) if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
{ rs6000_call_aix (operands[0], operands[1], operands[2], operands[3]);
rs6000_call_aix (operands[0], operands[1], operands[2], operands[3]); else
DONE; rs6000_call_sysv (operands[0], operands[1], operands[2], operands[3]);
}
if (DEFAULT_ABI == ABI_V4)
{
rs6000_call_sysv (operands[0], operands[1], operands[2], operands[3]);
DONE;
}
if (GET_CODE (operands[1]) != SYMBOL_REF) DONE;
operands[1] = force_reg (Pmode, operands[1]);
}) })
;; Call to function in current module. No TOC pointer reload needed. ;; Call to function in current module. No TOC pointer reload needed.
...@@ -10359,7 +10344,7 @@ ...@@ -10359,7 +10344,7 @@
[(call (mem:SI (match_operand:DI 0 "current_file_function_operand" "s,s")) [(call (mem:SI (match_operand:DI 0 "current_file_function_operand" "s,s"))
(match_operand 1)) (match_operand 1))
(use (match_operand:SI 2 "immediate_operand" "O,n")) (use (match_operand:SI 2 "immediate_operand" "O,n"))
(clobber (reg:SI LR_REGNO))] (clobber (reg:DI LR_REGNO))]
"TARGET_64BIT && (INTVAL (operands[2]) & CALL_LONG) == 0" "TARGET_64BIT && (INTVAL (operands[2]) & CALL_LONG) == 0"
{ {
if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS) if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
...@@ -10398,7 +10383,7 @@ ...@@ -10398,7 +10383,7 @@
(call (mem:SI (match_operand:DI 1 "current_file_function_operand" "s,s")) (call (mem:SI (match_operand:DI 1 "current_file_function_operand" "s,s"))
(match_operand 2))) (match_operand 2)))
(use (match_operand:SI 3 "immediate_operand" "O,n")) (use (match_operand:SI 3 "immediate_operand" "O,n"))
(clobber (reg:SI LR_REGNO))] (clobber (reg:DI LR_REGNO))]
"TARGET_64BIT && (INTVAL (operands[3]) & CALL_LONG) == 0" "TARGET_64BIT && (INTVAL (operands[3]) & CALL_LONG) == 0"
{ {
if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS) if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
...@@ -10423,7 +10408,7 @@ ...@@ -10423,7 +10408,7 @@
[(call (mem:SI (match_operand:P 0 "indirect_call_operand" "c,*l,X")) [(call (mem:SI (match_operand:P 0 "indirect_call_operand" "c,*l,X"))
(match_operand 1)) (match_operand 1))
(use (match_operand:SI 2 "immediate_operand" "n,n,n")) (use (match_operand:SI 2 "immediate_operand" "n,n,n"))
(clobber (reg:SI LR_REGNO))] (clobber (reg:P LR_REGNO))]
"DEFAULT_ABI == ABI_V4 "DEFAULT_ABI == ABI_V4
|| DEFAULT_ABI == ABI_DARWIN" || DEFAULT_ABI == ABI_DARWIN"
{ {
...@@ -10451,7 +10436,7 @@ ...@@ -10451,7 +10436,7 @@
[(call (mem:SI (match_operand:P 0 "symbol_ref_operand" "s,s")) [(call (mem:SI (match_operand:P 0 "symbol_ref_operand" "s,s"))
(match_operand 1)) (match_operand 1))
(use (match_operand:SI 2 "immediate_operand" "O,n")) (use (match_operand:SI 2 "immediate_operand" "O,n"))
(clobber (reg:SI LR_REGNO))] (clobber (reg:P LR_REGNO))]
"(DEFAULT_ABI == ABI_DARWIN "(DEFAULT_ABI == ABI_DARWIN
|| (DEFAULT_ABI == ABI_V4 || (DEFAULT_ABI == ABI_V4
&& (INTVAL (operands[2]) & CALL_LONG) == 0))" && (INTVAL (operands[2]) & CALL_LONG) == 0))"
...@@ -10487,7 +10472,7 @@ ...@@ -10487,7 +10472,7 @@
(match_operand 1)) (match_operand 1))
(use (match_operand:SI 2 "immediate_operand" "O,n")) (use (match_operand:SI 2 "immediate_operand" "O,n"))
(use (match_operand:SI 3 "register_operand" "r,r")) (use (match_operand:SI 3 "register_operand" "r,r"))
(clobber (reg:SI LR_REGNO))] (clobber (reg:P LR_REGNO))]
"(DEFAULT_ABI == ABI_V4 "(DEFAULT_ABI == ABI_V4
&& TARGET_SECURE_PLT && flag_pic && !SYMBOL_REF_LOCAL_P (operands[0]) && TARGET_SECURE_PLT && flag_pic && !SYMBOL_REF_LOCAL_P (operands[0])
&& (INTVAL (operands[2]) & CALL_LONG) == 0)" && (INTVAL (operands[2]) & CALL_LONG) == 0)"
...@@ -10508,7 +10493,7 @@ ...@@ -10508,7 +10493,7 @@
(call (mem:SI (match_operand:P 1 "indirect_call_operand" "c,*l,X")) (call (mem:SI (match_operand:P 1 "indirect_call_operand" "c,*l,X"))
(match_operand 2))) (match_operand 2)))
(use (match_operand:SI 3 "immediate_operand" "n,n,n")) (use (match_operand:SI 3 "immediate_operand" "n,n,n"))
(clobber (reg:SI LR_REGNO))] (clobber (reg:P LR_REGNO))]
"DEFAULT_ABI == ABI_V4 "DEFAULT_ABI == ABI_V4
|| DEFAULT_ABI == ABI_DARWIN" || DEFAULT_ABI == ABI_DARWIN"
{ {
...@@ -10537,7 +10522,7 @@ ...@@ -10537,7 +10522,7 @@
(call (mem:SI (match_operand:P 1 "symbol_ref_operand" "s,s")) (call (mem:SI (match_operand:P 1 "symbol_ref_operand" "s,s"))
(match_operand 2))) (match_operand 2)))
(use (match_operand:SI 3 "immediate_operand" "O,n")) (use (match_operand:SI 3 "immediate_operand" "O,n"))
(clobber (reg:SI LR_REGNO))] (clobber (reg:P LR_REGNO))]
"(DEFAULT_ABI == ABI_DARWIN "(DEFAULT_ABI == ABI_DARWIN
|| (DEFAULT_ABI == ABI_V4 || (DEFAULT_ABI == ABI_V4
&& (INTVAL (operands[3]) & CALL_LONG) == 0))" && (INTVAL (operands[3]) & CALL_LONG) == 0))"
...@@ -10575,7 +10560,7 @@ ...@@ -10575,7 +10560,7 @@
(match_operand 2))) (match_operand 2)))
(use (match_operand:SI 3 "immediate_operand" "O,n")) (use (match_operand:SI 3 "immediate_operand" "O,n"))
(use (match_operand:SI 4 "register_operand" "r,r")) (use (match_operand:SI 4 "register_operand" "r,r"))
(clobber (reg:SI LR_REGNO))] (clobber (reg:P LR_REGNO))]
"(DEFAULT_ABI == ABI_V4 "(DEFAULT_ABI == ABI_V4
&& TARGET_SECURE_PLT && flag_pic && !SYMBOL_REF_LOCAL_P (operands[1]) && TARGET_SECURE_PLT && flag_pic && !SYMBOL_REF_LOCAL_P (operands[1])
&& (INTVAL (operands[3]) & CALL_LONG) == 0)" && (INTVAL (operands[3]) & CALL_LONG) == 0)"
...@@ -10760,16 +10745,11 @@ ...@@ -10760,16 +10745,11 @@
operands[0] = XEXP (operands[0], 0); operands[0] = XEXP (operands[0], 0);
if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2) if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
{ rs6000_sibcall_aix (NULL_RTX, operands[0], operands[1], operands[2]);
rs6000_sibcall_aix (NULL_RTX, operands[0], operands[1], operands[2]); else
DONE; rs6000_sibcall_sysv (NULL_RTX, operands[0], operands[1], operands[2]);
}
if (DEFAULT_ABI == ABI_V4) DONE;
{
rs6000_sibcall_sysv (NULL_RTX, operands[0], operands[1], operands[2]);
DONE;
}
}) })
(define_expand "sibcall_value" (define_expand "sibcall_value"
...@@ -10791,16 +10771,11 @@ ...@@ -10791,16 +10771,11 @@
operands[1] = XEXP (operands[1], 0); operands[1] = XEXP (operands[1], 0);
if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2) if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
{ rs6000_sibcall_aix (operands[0], operands[1], operands[2], operands[3]);
rs6000_sibcall_aix (operands[0], operands[1], operands[2], operands[3]); else
DONE; rs6000_sibcall_sysv (operands[0], operands[1], operands[2], operands[3]);
}
if (DEFAULT_ABI == ABI_V4) DONE;
{
rs6000_sibcall_sysv (operands[0], operands[1], operands[2], operands[3]);
DONE;
}
}) })
(define_insn "*sibcall_local32" (define_insn "*sibcall_local32"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment