Debian Codegraph @

gcc/testsuite/gcc.target/arm/cmse/cmse-15.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-mcmse" } */
3 /* ARMv8-M expectation with target { ! arm_cmse_clear_ok }. */
4 /* ARMv8.1-M expectation with target arm_cmse_clear_ok. */
5 /* { dg-final { check-function-bodies "**" "" "" } } */
6
7 int __attribute__ ((cmse_nonsecure_call)) (*ns_foo) (void);
8 int (*s_bar) (void);
9 int __attribute__ ((cmse_nonsecure_call)) (**ns_foo2) (void);
10 int (**s_bar2) (void);
11
12 typedef int __attribute__ ((cmse_nonsecure_call)) ns_foo_t (void);
13 typedef int s_bar_t (void);
14 typedef int __attribute__ ((cmse_nonsecure_call)) (* ns_foo_ptr) (void);
15 typedef int (*s_bar_ptr) (void);
16
17 /*
18 ** nonsecure0: { target arm_cmse_clear_ok }
19 ** ...
20 ** blxns r[0-3]
21 ** ...
22 */
23 /*
24 ** nonsecure0: { target { ! arm_cmse_clear_ok } }
25 ** ...
26 ** bl __gnu_cmse_nonsecure_call
27 ** ...
28 */
29 int nonsecure0 (ns_foo_t * ns_foo_p)
30 {
31 return ns_foo_p ();
32 }
33
34 /*
35 ** nonsecure1: { target arm_cmse_clear_ok }
36 ** ...
37 ** blxns r[0-3]
38 ** ...
39 */
40 /*
41 ** nonsecure1: { target { ! arm_cmse_clear_ok } }
42 ** ...
43 ** bl __gnu_cmse_nonsecure_call
44 ** ...
45 */
46 int nonsecure1 (ns_foo_t ** ns_foo_p)
47 {
48 return (*ns_foo_p) ();
49 }
50
51 /*
52 ** nonsecure2: { target arm_cmse_clear_ok }
53 ** ...
54 ** (
55 ** blxns r[0-3]
56 ** |
57 ** b nonsecure0
58 ** )
59 ** ...
60 */
61 /*
62 ** nonsecure2: { target { ! arm_cmse_clear_ok } }
63 ** ...
64 ** (
65 ** bl __gnu_cmse_nonsecure_call
66 ** |
67 ** b nonsecure0
68 ** |
69 ** push {r4, lr}
70 ** bl nonsecure0
71 ** pop {r4, pc}
72 ** )
73 ** ...
74 */
75 int nonsecure2 (ns_foo_ptr ns_foo_p)
76 {
77 return ns_foo_p ();
78 }
79
80 /*
81 ** nonsecure3: { target arm_cmse_clear_ok }
82 ** ...
83 ** blxns r[0-3]
84 ** ...
85 */
86 /*
87 ** nonsecure3: { target { ! arm_cmse_clear_ok } }
88 ** ...
89 ** bl __gnu_cmse_nonsecure_call
90 ** ...
91 */
92 int nonsecure3 (ns_foo_ptr * ns_foo_p)
93 {
94 return (*ns_foo_p) ();
95 }
96
97 /*
98 ** secure0:
99 ** ...
100 ** (
101 ** bx r[0-3]
102 ** |
103 ** blx r[0-3]
104 ** )
105 ** ...
106 */
107 int secure0 (s_bar_t * s_bar_p)
108 {
109 return s_bar_p ();
110 }
111
112 /*
113 ** secure1:
114 ** ...
115 ** (
116 ** bx r[0-3]
117 ** |
118 ** blx r[0-3]
119 ** )
120 ** ...
121 */
122 int secure1 (s_bar_t ** s_bar_p)
123 {
124 return (*s_bar_p) ();
125 }
126
127 /*
128 ** secure2:
129 ** ...
130 ** (
131 ** bx r[0-3]
132 ** |
133 ** blx r[0-3]
134 ** |
135 ** b secure0
136 ** |
137 ** push {r4, lr}
138 ** bl secure0
139 ** pop {r4, pc}
140 ** )
141 ** ...
142 */
143 int secure2 (s_bar_ptr s_bar_p)
144 {
145 return s_bar_p ();
146 }
147
148 /*
149 ** secure3:
150 ** ...
151 ** (
152 ** bx r[0-3]
153 ** |
154 ** blx r[0-3]
155 ** |
156 ** b secure1
157 ** |
158 ** push {r4, lr}
159 ** bl secure1
160 ** pop {r4, pc}
161 ** )
162 ** ...
163 */
164 int secure3 (s_bar_ptr * s_bar_p)
165 {
166 return (*s_bar_p) ();
167 }
168
169 /*
170 ** nonsecure4: { target arm_cmse_clear_ok }
171 ** ...
172 ** blxns r[0-3]
173 ** ...
174 */
175 /*
176 ** nonsecure4: { target { ! arm_cmse_clear_ok } }
177 ** ...
178 ** bl __gnu_cmse_nonsecure_call
179 ** ...
180 */
181 int nonsecure4 (void)
182 {
183 return ns_foo ();
184 }
185
186 /*
187 ** nonsecure5: { target arm_cmse_clear_ok }
188 ** ...
189 ** blxns r[0-3]
190 ** ...
191 */
192 /*
193 ** nonsecure5: { target { ! arm_cmse_clear_ok } }
194 ** ...
195 ** bl __gnu_cmse_nonsecure_call
196 ** ...
197 */
198 int nonsecure5 (void)
199 {
200 return (*ns_foo2) ();
201 }
202
203 /*
204 ** secure4:
205 ** ...
206 ** (
207 ** bx r[0-3]
208 ** |
209 ** blx r[0-3]
210 ** )
211 ** ...
212 */
213 int secure4 (void)
214 {
215 return s_bar ();
216 }
217
218 /*
219 ** secure5:
220 ** ...
221 ** (
222 ** bx r[0-3]
223 ** |
224 ** blx r[0-3]
225 ** )
226 ** ...
227 */
228 int secure5 (void)
229 {
230 return (*s_bar2) ();
231 }