aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/arm/cmse/extend-return.c
blob: 2288d166bd3b71439f38fa3eaef3fa1e30465bf6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/* { dg-do compile } */
/* { dg-options "-mcmse -fshort-enums" } */
/* ARMv8-M expectation with target { ! arm_cmse_clear_ok }.  */
/* ARMv8.1-M expectation with target arm_cmse_clear_ok.  */
/* { dg-final { check-function-bodies "**" "" "" } } */

#include <arm_cmse.h>
#include <stdbool.h>

enum offset
{
    zero = 0,
    one = 1,
    two = 2
};

typedef unsigned char __attribute__ ((cmse_nonsecure_call)) ns_unsign_foo_t (void);
typedef signed char __attribute__ ((cmse_nonsecure_call)) ns_sign_foo_t (void);
typedef unsigned short __attribute__ ((cmse_nonsecure_call)) ns_short_unsign_foo_t (void);
typedef signed short __attribute__ ((cmse_nonsecure_call)) ns_short_sign_foo_t (void);
typedef enum offset __attribute__ ((cmse_nonsecure_call)) ns_enum_foo_t (void);
typedef bool __attribute__ ((cmse_nonsecure_call)) ns_bool_foo_t (void);

/*
**unsignNonsecure0:  { target arm_cmse_clear_ok }
**	...
**	blxns	r[0-3]
**	...
**	uxtb	r0, r0
**	...
*/
/*
**unsignNonsecure0: { target { ! arm_cmse_clear_ok } }
**	...
**	bl	__gnu_cmse_nonsecure_call
**	uxtb	r0, r0
**	...
*/
unsigned char unsignNonsecure0 (ns_unsign_foo_t * ns_foo_p)
{
  return ns_foo_p ();
}

/*
**signNonsecure0:  { target arm_cmse_clear_ok }
**	...
**	blxns	r[0-3]
**	...
**	sxtb	r0, r0
**	...
*/
/*
**signNonsecure0: { target { ! arm_cmse_clear_ok } }
**	...
**	bl	__gnu_cmse_nonsecure_call
**	sxtb	r0, r0
**	...
*/
signed char signNonsecure0 (ns_sign_foo_t * ns_foo_p)
{
  return ns_foo_p ();
}

/*
**shortUnsignNonsecure0:  { target arm_cmse_clear_ok }
**	...
**	blxns	r[0-3]
**	...
**	uxth	r0, r0
**	...
*/
/*
**shortUnsignNonsecure0: { target { ! arm_cmse_clear_ok } }
**	...
**	bl	__gnu_cmse_nonsecure_call
**	uxth	r0, r0
**	...
*/
unsigned short shortUnsignNonsecure0 (ns_short_unsign_foo_t * ns_foo_p)
{
  return ns_foo_p ();
}

/*
**shortSignNonsecure0:  { target arm_cmse_clear_ok }
**	...
**	blxns	r[0-3]
**	...
**	sxth	r0, r0
**	...
*/
/*
**shortSignNonsecure0: { target { ! arm_cmse_clear_ok } }
**	...
**	bl	__gnu_cmse_nonsecure_call
**	sxth	r0, r0
**	...
*/
signed short shortSignNonsecure0 (ns_short_sign_foo_t * ns_foo_p)
{
  return ns_foo_p ();
}

/*
**enumNonsecure0:  { target arm_cmse_clear_ok }
**	...
**	blxns	r[0-3]
**	...
**	uxtb	r0, r0
**	...
*/
/*
**enumNonsecure0: { target { ! arm_cmse_clear_ok } }
**	...
**	bl	__gnu_cmse_nonsecure_call
**	uxtb	r0, r0
**	...
*/
unsigned char __attribute__((noipa)) enumNonsecure0 (ns_enum_foo_t * ns_foo_p)
{
  return ns_foo_p ();
}

/*
**boolNonsecure0:  { target arm_cmse_clear_ok }
**	...
**	blxns	r[0-3]
**	...
**	uxtb	r0, r0
**	...
*/
/*
**boolNonsecure0: { target { ! arm_cmse_clear_ok } }
**	...
**	bl	__gnu_cmse_nonsecure_call
**	uxtb	r0, r0
**	...
*/
unsigned char boolNonsecure0 (ns_bool_foo_t * ns_foo_p)
{
  return ns_foo_p ();
}