call = SET_SRC (call);
/* Check if it is a cmse_nonsecure_call. */
- unspec = XEXP (call, 0);
+ unspec = XVECEXP (pat, 0, 2);
+
if (GET_CODE (unspec) != UNSPEC
|| XINT (unspec, 1) != UNSPEC_NONSECURE_MEM)
continue;
/* Make sure the register used to hold the function address is not
cleared. */
- address = RTVEC_ELT (XVEC (unspec, 0), 0);
+ address = XEXP (call, 0);
gcc_assert (MEM_P (address));
gcc_assert (REG_P (XEXP (address, 0)));
address_regnum = REGNO (XEXP (address, 0));
if (detect_cmse_nonsecure_call (addr))
{
pat = gen_nonsecure_call_internal (operands[0], operands[1],
- operands[2]);
+ operands[2], const0_rtx);
emit_call_insn (pat);
}
else
(clobber (reg:SI LR_REGNUM))])])
(define_expand "nonsecure_call_internal"
- [(parallel [(call (unspec:SI [(match_operand 0 "memory_operand")]
- UNSPEC_NONSECURE_MEM)
+ [(parallel [(call (match_operand 0 "memory_operand")
(match_operand 1 "general_operand"))
(use (match_operand 2 "" ""))
+ (unspec:SI [(match_operand 3)] UNSPEC_NONSECURE_MEM)
(clobber (reg:SI LR_REGNUM))])]
"use_cmse"
{
if (detect_cmse_nonsecure_call (addr))
{
pat = gen_nonsecure_call_value_internal (operands[0], operands[1],
- operands[2], operands[3]);
+ operands[2], operands[3],
+ const0_rtx);
emit_call_insn (pat);
}
else
(define_expand "nonsecure_call_value_internal"
[(parallel [(set (match_operand 0 "" "")
- (call (unspec:SI [(match_operand 1 "memory_operand")]
- UNSPEC_NONSECURE_MEM)
+ (call (match_operand 1 "memory_operand")
(match_operand 2 "general_operand")))
(use (match_operand 3 "" ""))
+ (unspec:SI [(match_operand 4)] UNSPEC_NONSECURE_MEM)
(clobber (reg:SI LR_REGNUM))])]
"use_cmse"
"
)
(define_insn "*nonsecure_call_reg_thumb1_v5"
- [(call (unspec:SI [(mem:SI (reg:SI R4_REGNUM))]
- UNSPEC_NONSECURE_MEM)
+ [(call (mem:SI (reg:SI R4_REGNUM))
(match_operand 0 "" ""))
(use (match_operand 1 "" ""))
+ (unspec:SI [(match_operand 2)]UNSPEC_NONSECURE_MEM)
(clobber (reg:SI LR_REGNUM))]
"TARGET_THUMB1 && use_cmse && !SIBLING_CALL_P (insn)"
"bl\\t__gnu_cmse_nonsecure_call"
(define_insn "*nonsecure_call_value_reg_thumb1_v5"
[(set (match_operand 0 "" "")
- (call (unspec:SI
- [(mem:SI (reg:SI R4_REGNUM))]
- UNSPEC_NONSECURE_MEM)
+ (call (mem:SI (reg:SI R4_REGNUM))
(match_operand 1 "" "")))
(use (match_operand 2 "" ""))
+ (unspec:SI [(match_operand 3)] UNSPEC_NONSECURE_MEM)
(clobber (reg:SI LR_REGNUM))]
"TARGET_THUMB1 && use_cmse"
"bl\\t__gnu_cmse_nonsecure_call"
)
(define_insn "*nonsecure_call_reg_thumb2_fpcxt"
- [(call (unspec:SI [(mem:SI (match_operand:SI 0 "s_register_operand" "l*r"))]
- UNSPEC_NONSECURE_MEM)
+ [(call (mem:SI (match_operand:SI 0 "s_register_operand" "l*r"))
(match_operand 1 "" ""))
(use (match_operand 2 "" ""))
+ (unspec:SI [(match_operand 3)] UNSPEC_NONSECURE_MEM)
(clobber (reg:SI LR_REGNUM))]
"TARGET_THUMB2 && use_cmse && TARGET_HAVE_FPCXT_CMSE"
"blxns\\t%0"
)
(define_insn "*nonsecure_call_reg_thumb2"
- [(call (unspec:SI [(mem:SI (reg:SI R4_REGNUM))]
- UNSPEC_NONSECURE_MEM)
+ [(call (mem:SI (reg:SI R4_REGNUM))
(match_operand 0 "" ""))
(use (match_operand 1 "" ""))
+ (unspec:SI [(match_operand 2)] UNSPEC_NONSECURE_MEM)
(clobber (reg:SI LR_REGNUM))]
"TARGET_THUMB2 && use_cmse && !TARGET_HAVE_FPCXT_CMSE"
"bl\\t__gnu_cmse_nonsecure_call"
(define_insn "*nonsecure_call_value_reg_thumb2_fpcxt"
[(set (match_operand 0 "" "")
- (call
- (unspec:SI [(mem:SI (match_operand:SI 1 "register_operand" "l*r"))]
- UNSPEC_NONSECURE_MEM)
- (match_operand 2 "" "")))
+ (call (mem:SI (match_operand:SI 1 "register_operand" "l*r"))
+ (match_operand 2 "" "")))
(use (match_operand 3 "" ""))
+ (unspec:SI [(match_operand 4)] UNSPEC_NONSECURE_MEM)
(clobber (reg:SI LR_REGNUM))]
"TARGET_THUMB2 && use_cmse && TARGET_HAVE_FPCXT_CMSE"
"blxns\\t%1"
(define_insn "*nonsecure_call_value_reg_thumb2"
[(set (match_operand 0 "" "")
- (call
- (unspec:SI [(mem:SI (reg:SI R4_REGNUM))] UNSPEC_NONSECURE_MEM)
- (match_operand 1 "" "")))
+ (call (mem:SI (reg:SI R4_REGNUM))
+ (match_operand 1 "" "")))
(use (match_operand 2 "" ""))
+ (unspec:SI [(match_operand 3)] UNSPEC_NONSECURE_MEM)
(clobber (reg:SI LR_REGNUM))]
"TARGET_THUMB2 && use_cmse && !TARGET_HAVE_FPCXT_CMSE"
"bl\\t__gnu_cmse_nonsecure_call"
/* { dg-do compile } */
-/* { dg-options "-mcmse -fdump-rtl-final-slim" } */
+/* Make sure FPCXT is not enabled. */
+/* { dg-options "-mcmse -fdump-rtl-final -march=armv8-m.main+fp" } */
typedef void (*f)(int) __attribute__((cmse_nonsecure_call));
func(a);
}
-/* { dg-final { scan-rtl-dump "call unspec\\\[\\\[r4:SI\\\]\\\]" "final" { target { ! arm_v8_1m_mve_ok } } } } */
-/* { dg-final { scan-rtl-dump "call unspec\\\[\\\[r\[0-7\]:SI\\\]\\\]" "final" { target { arm_v8_1m_mve_ok } } } } */
+/* { dg-final { scan-rtl-dump "call \\\(mem:SI \\\(reg:SI 4 r4" "final" } } */
+/* { dg-final { scan-rtl-dump "UNSPEC_NONSECURE_MEM" "final" } } */
--- /dev/null
+/* { dg-do compile } */
+/* This is a duplicate of cmse-18.c, targetting arm_v8_1m_mve, to make sure
+ FPCXT is enabled. */
+/* { dg-options "-mcmse -fdump-rtl-final -march=armv8.1-m.main+mve" } */
+
+typedef void (*f)(int) __attribute__((cmse_nonsecure_call));
+
+void bar(f func, int a)
+{
+ func(a);
+}
+
+/* { dg-final { scan-rtl-dump "call \\\(mem:SI \\\(reg/f:SI \[0-7] r\[0-7\]" "final" } } */
+/* { dg-final { scan-rtl-dump "UNSPEC_NONSECURE_MEM" "final" } } */