extern void xtensa_emit_loop_end (rtx_insn *, rtx *);
extern char *xtensa_emit_branch (bool, rtx *);
extern char *xtensa_emit_movcc (bool, bool, bool, rtx *);
-extern void xtensa_prepare_expand_call (int, rtx *);
+extern void xtensa_expand_call (int, rtx *);
extern char *xtensa_emit_call (int, rtx *);
extern char *xtensa_emit_sibcall (int, rtx *);
extern bool xtensa_tls_referenced_p (rtx);
void
-xtensa_prepare_expand_call (int callop, rtx *operands)
+xtensa_expand_call (int callop, rtx *operands)
{
+ rtx call;
+ rtx_insn *call_insn;
rtx addr = XEXP (operands[callop], 0);
if (flag_pic && SYMBOL_REF_P (addr)
Pmode);
XEXP (operands[callop], 0) = reg;
}
+
+ call = gen_rtx_CALL (VOIDmode, operands[callop], operands[callop + 1]);
+
+ if (callop)
+ call = gen_rtx_SET (operands[0], call);
+
+ call_insn = emit_call_insn (call);
+
+ if (TARGET_WINDOWED_ABI)
+ {
+ /*
+ * Windowed xtensa ABI specifies that static chain pointer is passed
+ * in memory below the caller's stack pointer, which means that the
+ * callee may clobber it if it's a non-leaf function.
+ * Add the clobber expression for the static chain to the function call
+ * expression list so that it is not assumed to be live across the call.
+ */
+ rtx clob = gen_rtx_CLOBBER (Pmode, xtensa_static_chain (NULL, false));
+ CALL_INSN_FUNCTION_USAGE (call_insn) =
+ gen_rtx_EXPR_LIST (Pmode, clob, CALL_INSN_FUNCTION_USAGE (call_insn));
+ }
}
(match_operand 1 "" ""))]
""
{
- xtensa_prepare_expand_call (0, operands);
+ xtensa_expand_call (0, operands);
+ DONE;
})
(define_insn "call_internal"
(match_operand 2 "" "")))]
""
{
- xtensa_prepare_expand_call (1, operands);
+ xtensa_expand_call (1, operands);
+ DONE;
})
(define_insn "call_value_internal"
(match_operand 1 "" ""))]
"!TARGET_WINDOWED_ABI"
{
- xtensa_prepare_expand_call (0, operands);
+ xtensa_expand_call (0, operands);
+ DONE;
})
(define_insn "sibcall_internal"
(match_operand 2 "" "")))]
"!TARGET_WINDOWED_ABI"
{
- xtensa_prepare_expand_call (1, operands);
+ xtensa_expand_call (1, operands);
+ DONE;
})
(define_insn "sibcall_value_internal"
--- /dev/null
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+
+#ifdef __XTENSA_CALL0_ABI__
+void __xtensa_libgcc_window_spill (void)
+{
+}
+#else
+void __xtensa_libgcc_window_spill (void);
+#endif
+
+__attribute__((noinline)) void h (void)
+{
+ __xtensa_libgcc_window_spill ();
+}
+
+int f (int u, int v)
+{
+ int a = u;
+ int s;
+
+ __attribute__((noinline,pure)) int nested1 (int b)
+ {
+ h();
+ return a + b;
+ }
+
+ __attribute__((noinline,pure)) int nested2 (int b)
+ {
+ h();
+ return a - b;
+ }
+
+ s = nested1 (v);
+ s += nested2 (v);
+ return s;
+}
+
+int main (void)
+{
+ int u = 0x12345678;
+ int v = 1;
+
+ return f (u, v) == 2 * u ? 0 : 1;
+}