1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc %s -o - -mtriple=thumbv8m.base | \
3; RUN:   FileCheck %s --check-prefix=CHECK-8B
4; RUN: llc %s -o - -mtriple=thumbebv8m.base | \
5; RUN:   FileCheck %s --check-prefix=CHECK-8B
6; RUN: llc %s -o - -mtriple=thumbv8m.main -mattr=-fpregs,+dsp | \
7; RUN:   FileCheck %s --check-prefix=CHECK-8M-SOFT
8; RUN: llc %s -o - -mtriple=thumbebv8m.main -mattr=-fpregs,+dsp | \
9; RUN:   FileCheck %s --check-prefix=CHECK-8M-SOFT
10; RUN: llc %s -o - -mtriple=thumbv8m.main -mattr=+fp-armv8d16sp,+dsp | \
11; RUN:   FileCheck %s --check-prefix=CHECK-8M-SOFTFP
12; RUN: llc %s -o - -mtriple=thumbebv8m.main -mattr=+fp-armv8d16sp,+dsp | \
13; RUN:   FileCheck %s --check-prefix=CHECK-8M-SOFTFP
14; RUN: llc %s -o - -mtriple=thumbv8.1m.main -mattr=-fpregs,+dsp | \
15; RUN:   FileCheck %s --check-prefix=CHECK-81M-SOFT
16; RUN: llc %s -o - -mtriple=thumbebv8.1m.main -mattr=-fpregs,+dsp | \
17; RUN:   FileCheck %s --check-prefix=CHECK-81M-SOFT
18; RUN: llc %s -o - -mtriple=thumbv8.1m.main -mattr=+fp-armv8d16sp,+dsp | \
19; RUN:   FileCheck %s --check-prefix=CHECK-81M-SOFTFP
20; RUN: llc %s -o - -mtriple=thumbebv8.1m.main -mattr=+fp-armv8d16sp,+dsp | \
21; RUN:   FileCheck %s --check-prefix=CHECK-81M-SOFTFP
22; RUN: llc %s -o - -mtriple=thumbv8.1m.main -mattr=+mve | \
23; RUN:   FileCheck %s --check-prefix=CHECK-81M-SOFTFP
24; RUN: llc %s -o - -mtriple=thumbebv8.1m.main -mattr=mve | \
25; RUN:   FileCheck %s --check-prefix=CHECK-81M-SOFTFP
26
27define i32 @ns_entry(i32 (i32)* nocapture %fptr) #0 {
28; CHECK-8B-LABEL: ns_entry:
29; CHECK-8B:       @ %bb.0: @ %entry
30; CHECK-8B-NEXT:    push {r7, lr}
31; CHECK-8B-NEXT:    mov r1, r0
32; CHECK-8B-NEXT:    movs r0, #10
33; CHECK-8B-NEXT:    blx r1
34; CHECK-8B-NEXT:    pop {r7}
35; CHECK-8B-NEXT:    pop {r1}
36; CHECK-8B-NEXT:    mov lr, r1
37; CHECK-8B-NEXT:    mov r1, lr
38; CHECK-8B-NEXT:    mov r2, lr
39; CHECK-8B-NEXT:    mov r3, lr
40; CHECK-8B-NEXT:    mov r12, lr
41; CHECK-8B-NEXT:    msr apsr, lr
42; CHECK-8B-NEXT:    bxns lr
43;
44; CHECK-8M-SOFT-LABEL: ns_entry:
45; CHECK-8M-SOFT:       @ %bb.0: @ %entry
46; CHECK-8M-SOFT-NEXT:    push {r7, lr}
47; CHECK-8M-SOFT-NEXT:    mov r1, r0
48; CHECK-8M-SOFT-NEXT:    movs r0, #10
49; CHECK-8M-SOFT-NEXT:    blx r1
50; CHECK-8M-SOFT-NEXT:    pop.w {r7, lr}
51; CHECK-8M-SOFT-NEXT:    mov r1, lr
52; CHECK-8M-SOFT-NEXT:    mov r2, lr
53; CHECK-8M-SOFT-NEXT:    mov r3, lr
54; CHECK-8M-SOFT-NEXT:    mov r12, lr
55; CHECK-8M-SOFT-NEXT:    msr apsr_nzcvqg, lr
56; CHECK-8M-SOFT-NEXT:    bxns lr
57;
58; CHECK-8M-SOFTFP-LABEL: ns_entry:
59; CHECK-8M-SOFTFP:       @ %bb.0: @ %entry
60; CHECK-8M-SOFTFP-NEXT:    push {r7, lr}
61; CHECK-8M-SOFTFP-NEXT:    mov r1, r0
62; CHECK-8M-SOFTFP-NEXT:    movs r0, #10
63; CHECK-8M-SOFTFP-NEXT:    blx r1
64; CHECK-8M-SOFTFP-NEXT:    pop.w {r7, lr}
65; CHECK-8M-SOFTFP-NEXT:    mrs r12, control
66; CHECK-8M-SOFTFP-NEXT:    tst.w r12, #8
67; CHECK-8M-SOFTFP-NEXT:    beq .LBB0_2
68; CHECK-8M-SOFTFP-NEXT:  @ %bb.1: @ %entry
69; CHECK-8M-SOFTFP-NEXT:    vmrs r12, fpscr
70; CHECK-8M-SOFTFP-NEXT:    vmov d0, lr, lr
71; CHECK-8M-SOFTFP-NEXT:    vmov d1, lr, lr
72; CHECK-8M-SOFTFP-NEXT:    vmov d2, lr, lr
73; CHECK-8M-SOFTFP-NEXT:    vmov d3, lr, lr
74; CHECK-8M-SOFTFP-NEXT:    vmov d4, lr, lr
75; CHECK-8M-SOFTFP-NEXT:    vmov d5, lr, lr
76; CHECK-8M-SOFTFP-NEXT:    vmov d6, lr, lr
77; CHECK-8M-SOFTFP-NEXT:    vmov d7, lr, lr
78; CHECK-8M-SOFTFP-NEXT:    bic r12, r12, #159
79; CHECK-8M-SOFTFP-NEXT:    bic r12, r12, #4026531840
80; CHECK-8M-SOFTFP-NEXT:    vmsr fpscr, r12
81; CHECK-8M-SOFTFP-NEXT:  .LBB0_2: @ %entry
82; CHECK-8M-SOFTFP-NEXT:    mov r1, lr
83; CHECK-8M-SOFTFP-NEXT:    mov r2, lr
84; CHECK-8M-SOFTFP-NEXT:    mov r3, lr
85; CHECK-8M-SOFTFP-NEXT:    mov r12, lr
86; CHECK-8M-SOFTFP-NEXT:    msr apsr_nzcvqg, lr
87; CHECK-8M-SOFTFP-NEXT:    bxns lr
88;
89; CHECK-81M-SOFT-LABEL: ns_entry:
90; CHECK-81M-SOFT:       @ %bb.0: @ %entry
91; CHECK-81M-SOFT-NEXT:    vstr fpcxtns, [sp, #-4]!
92; CHECK-81M-SOFT-NEXT:    push {r7, lr}
93; CHECK-81M-SOFT-NEXT:    sub sp, #4
94; CHECK-81M-SOFT-NEXT:    mov r1, r0
95; CHECK-81M-SOFT-NEXT:    movs r0, #10
96; CHECK-81M-SOFT-NEXT:    blx r1
97; CHECK-81M-SOFT-NEXT:    add sp, #4
98; CHECK-81M-SOFT-NEXT:    pop.w {r7, lr}
99; CHECK-81M-SOFT-NEXT:    vscclrm {s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, vpr}
100; CHECK-81M-SOFT-NEXT:    vldr fpcxtns, [sp], #4
101; CHECK-81M-SOFT-NEXT:    clrm {r1, r2, r3, r12, apsr}
102; CHECK-81M-SOFT-NEXT:    bxns lr
103;
104; CHECK-81M-SOFTFP-LABEL: ns_entry:
105; CHECK-81M-SOFTFP:       @ %bb.0: @ %entry
106; CHECK-81M-SOFTFP-NEXT:    vstr fpcxtns, [sp, #-4]!
107; CHECK-81M-SOFTFP-NEXT:    push {r7, lr}
108; CHECK-81M-SOFTFP-NEXT:    sub sp, #4
109; CHECK-81M-SOFTFP-NEXT:    mov r1, r0
110; CHECK-81M-SOFTFP-NEXT:    movs r0, #10
111; CHECK-81M-SOFTFP-NEXT:    blx r1
112; CHECK-81M-SOFTFP-NEXT:    add sp, #4
113; CHECK-81M-SOFTFP-NEXT:    pop.w {r7, lr}
114; CHECK-81M-SOFTFP-NEXT:    vscclrm {s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, vpr}
115; CHECK-81M-SOFTFP-NEXT:    vldr fpcxtns, [sp], #4
116; CHECK-81M-SOFTFP-NEXT:    clrm {r1, r2, r3, r12, apsr}
117; CHECK-81M-SOFTFP-NEXT:    bxns lr
118entry:
119  %call = call i32 %fptr(i32 10) #1
120  ret i32 %call
121}
122
123attributes #0 = { "cmse_nonsecure_entry" nounwind }
124attributes #1 = { nounwind }
125
126
127define i32 @ns_call(i32 (i32)* nocapture %fptr) #2 {
128; CHECK-8B-LABEL: ns_call:
129; CHECK-8B:       @ %bb.0: @ %entry
130; CHECK-8B-NEXT:    push {r7, lr}
131; CHECK-8B-NEXT:    mov r1, r0
132; CHECK-8B-NEXT:    movs r0, #10
133; CHECK-8B-NEXT:    push {r4, r5, r6, r7}
134; CHECK-8B-NEXT:    mov r7, r11
135; CHECK-8B-NEXT:    mov r6, r10
136; CHECK-8B-NEXT:    mov r5, r9
137; CHECK-8B-NEXT:    mov r4, r8
138; CHECK-8B-NEXT:    push {r4, r5, r6, r7}
139; CHECK-8B-NEXT:    mov r2, #1
140; CHECK-8B-NEXT:    bics r1, r2
141; CHECK-8B-NEXT:    mov r2, r1
142; CHECK-8B-NEXT:    mov r3, r1
143; CHECK-8B-NEXT:    mov r4, r1
144; CHECK-8B-NEXT:    mov r5, r1
145; CHECK-8B-NEXT:    mov r6, r1
146; CHECK-8B-NEXT:    mov r7, r1
147; CHECK-8B-NEXT:    mov r8, r1
148; CHECK-8B-NEXT:    mov r9, r1
149; CHECK-8B-NEXT:    mov r10, r1
150; CHECK-8B-NEXT:    mov r11, r1
151; CHECK-8B-NEXT:    mov r12, r1
152; CHECK-8B-NEXT:    msr apsr, r1
153; CHECK-8B-NEXT:    blxns r1
154; CHECK-8B-NEXT:    pop {r4, r5, r6, r7}
155; CHECK-8B-NEXT:    mov r8, r4
156; CHECK-8B-NEXT:    mov r9, r5
157; CHECK-8B-NEXT:    mov r10, r6
158; CHECK-8B-NEXT:    mov r11, r7
159; CHECK-8B-NEXT:    pop {r4, r5, r6, r7}
160; CHECK-8B-NEXT:    pop {r7, pc}
161;
162; CHECK-8M-SOFT-LABEL: ns_call:
163; CHECK-8M-SOFT:       @ %bb.0: @ %entry
164; CHECK-8M-SOFT-NEXT:    push {r7, lr}
165; CHECK-8M-SOFT-NEXT:    mov r1, r0
166; CHECK-8M-SOFT-NEXT:    movs r0, #10
167; CHECK-8M-SOFT-NEXT:    push.w {r4, r5, r6, r7, r8, r9, r10, r11}
168; CHECK-8M-SOFT-NEXT:    bic r1, r1, #1
169; CHECK-8M-SOFT-NEXT:    msr apsr_nzcvqg, r1
170; CHECK-8M-SOFT-NEXT:    mov r2, r1
171; CHECK-8M-SOFT-NEXT:    mov r3, r1
172; CHECK-8M-SOFT-NEXT:    mov r4, r1
173; CHECK-8M-SOFT-NEXT:    mov r5, r1
174; CHECK-8M-SOFT-NEXT:    mov r6, r1
175; CHECK-8M-SOFT-NEXT:    mov r7, r1
176; CHECK-8M-SOFT-NEXT:    mov r8, r1
177; CHECK-8M-SOFT-NEXT:    mov r9, r1
178; CHECK-8M-SOFT-NEXT:    mov r10, r1
179; CHECK-8M-SOFT-NEXT:    mov r11, r1
180; CHECK-8M-SOFT-NEXT:    mov r12, r1
181; CHECK-8M-SOFT-NEXT:    blxns r1
182; CHECK-8M-SOFT-NEXT:    pop.w {r4, r5, r6, r7, r8, r9, r10, r11}
183; CHECK-8M-SOFT-NEXT:    pop {r7, pc}
184;
185; CHECK-8M-SOFTFP-LABEL: ns_call:
186; CHECK-8M-SOFTFP:       @ %bb.0: @ %entry
187; CHECK-8M-SOFTFP-NEXT:    push {r7, lr}
188; CHECK-8M-SOFTFP-NEXT:    mov r1, r0
189; CHECK-8M-SOFTFP-NEXT:    movs r0, #10
190; CHECK-8M-SOFTFP-NEXT:    push.w {r4, r5, r6, r7, r8, r9, r10, r11}
191; CHECK-8M-SOFTFP-NEXT:    bic r1, r1, #1
192; CHECK-8M-SOFTFP-NEXT:    sub sp, #136
193; CHECK-8M-SOFTFP-NEXT:    vlstm sp
194; CHECK-8M-SOFTFP-NEXT:    mov r2, r1
195; CHECK-8M-SOFTFP-NEXT:    mov r3, r1
196; CHECK-8M-SOFTFP-NEXT:    mov r4, r1
197; CHECK-8M-SOFTFP-NEXT:    mov r5, r1
198; CHECK-8M-SOFTFP-NEXT:    mov r6, r1
199; CHECK-8M-SOFTFP-NEXT:    mov r7, r1
200; CHECK-8M-SOFTFP-NEXT:    mov r8, r1
201; CHECK-8M-SOFTFP-NEXT:    mov r9, r1
202; CHECK-8M-SOFTFP-NEXT:    mov r10, r1
203; CHECK-8M-SOFTFP-NEXT:    mov r11, r1
204; CHECK-8M-SOFTFP-NEXT:    mov r12, r1
205; CHECK-8M-SOFTFP-NEXT:    msr apsr_nzcvqg, r1
206; CHECK-8M-SOFTFP-NEXT:    blxns r1
207; CHECK-8M-SOFTFP-NEXT:    vlldm sp
208; CHECK-8M-SOFTFP-NEXT:    add sp, #136
209; CHECK-8M-SOFTFP-NEXT:    pop.w {r4, r5, r6, r7, r8, r9, r10, r11}
210; CHECK-8M-SOFTFP-NEXT:    pop {r7, pc}
211;
212; CHECK-81M-SOFT-LABEL: ns_call:
213; CHECK-81M-SOFT:       @ %bb.0: @ %entry
214; CHECK-81M-SOFT-NEXT:    push {r7, lr}
215; CHECK-81M-SOFT-NEXT:    mov r1, r0
216; CHECK-81M-SOFT-NEXT:    movs r0, #10
217; CHECK-81M-SOFT-NEXT:    push.w {r4, r5, r6, r7, r8, r9, r10, r11}
218; CHECK-81M-SOFT-NEXT:    bic r1, r1, #1
219; CHECK-81M-SOFT-NEXT:    sub sp, #136
220; CHECK-81M-SOFT-NEXT:    vlstm sp
221; CHECK-81M-SOFT-NEXT:    clrm {r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, apsr}
222; CHECK-81M-SOFT-NEXT:    blxns r1
223; CHECK-81M-SOFT-NEXT:    vlldm sp
224; CHECK-81M-SOFT-NEXT:    add sp, #136
225; CHECK-81M-SOFT-NEXT:    pop.w {r4, r5, r6, r7, r8, r9, r10, r11}
226; CHECK-81M-SOFT-NEXT:    pop {r7, pc}
227;
228; CHECK-81M-SOFTFP-LABEL: ns_call:
229; CHECK-81M-SOFTFP:       @ %bb.0: @ %entry
230; CHECK-81M-SOFTFP-NEXT:    push {r7, lr}
231; CHECK-81M-SOFTFP-NEXT:    mov r1, r0
232; CHECK-81M-SOFTFP-NEXT:    movs r0, #10
233; CHECK-81M-SOFTFP-NEXT:    push.w {r4, r5, r6, r7, r8, r9, r10, r11}
234; CHECK-81M-SOFTFP-NEXT:    bic r1, r1, #1
235; CHECK-81M-SOFTFP-NEXT:    sub sp, #136
236; CHECK-81M-SOFTFP-NEXT:    vlstm sp
237; CHECK-81M-SOFTFP-NEXT:    clrm {r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, apsr}
238; CHECK-81M-SOFTFP-NEXT:    blxns r1
239; CHECK-81M-SOFTFP-NEXT:    vlldm sp
240; CHECK-81M-SOFTFP-NEXT:    add sp, #136
241; CHECK-81M-SOFTFP-NEXT:    pop.w {r4, r5, r6, r7, r8, r9, r10, r11}
242; CHECK-81M-SOFTFP-NEXT:    pop {r7, pc}
243entry:
244  %call = call i32 %fptr(i32 10) #3
245  ret i32 %call
246}
247
248attributes #2 = { nounwind }
249attributes #3 = { "cmse_nonsecure_call" nounwind }
250
251
252define i32 @ns_tail_call(i32 (i32)* nocapture %fptr) #4 {
253; CHECK-8B-LABEL: ns_tail_call:
254; CHECK-8B:       @ %bb.0: @ %entry
255; CHECK-8B-NEXT:    push {r7, lr}
256; CHECK-8B-NEXT:    mov r1, r0
257; CHECK-8B-NEXT:    movs r0, #10
258; CHECK-8B-NEXT:    push {r4, r5, r6, r7}
259; CHECK-8B-NEXT:    mov r7, r11
260; CHECK-8B-NEXT:    mov r6, r10
261; CHECK-8B-NEXT:    mov r5, r9
262; CHECK-8B-NEXT:    mov r4, r8
263; CHECK-8B-NEXT:    push {r4, r5, r6, r7}
264; CHECK-8B-NEXT:    mov r2, #1
265; CHECK-8B-NEXT:    bics r1, r2
266; CHECK-8B-NEXT:    mov r2, r1
267; CHECK-8B-NEXT:    mov r3, r1
268; CHECK-8B-NEXT:    mov r4, r1
269; CHECK-8B-NEXT:    mov r5, r1
270; CHECK-8B-NEXT:    mov r6, r1
271; CHECK-8B-NEXT:    mov r7, r1
272; CHECK-8B-NEXT:    mov r8, r1
273; CHECK-8B-NEXT:    mov r9, r1
274; CHECK-8B-NEXT:    mov r10, r1
275; CHECK-8B-NEXT:    mov r11, r1
276; CHECK-8B-NEXT:    mov r12, r1
277; CHECK-8B-NEXT:    msr apsr, r1
278; CHECK-8B-NEXT:    blxns r1
279; CHECK-8B-NEXT:    pop {r4, r5, r6, r7}
280; CHECK-8B-NEXT:    mov r8, r4
281; CHECK-8B-NEXT:    mov r9, r5
282; CHECK-8B-NEXT:    mov r10, r6
283; CHECK-8B-NEXT:    mov r11, r7
284; CHECK-8B-NEXT:    pop {r4, r5, r6, r7}
285; CHECK-8B-NEXT:    pop {r7, pc}
286;
287; CHECK-8M-SOFT-LABEL: ns_tail_call:
288; CHECK-8M-SOFT:       @ %bb.0: @ %entry
289; CHECK-8M-SOFT-NEXT:    push {r7, lr}
290; CHECK-8M-SOFT-NEXT:    mov r1, r0
291; CHECK-8M-SOFT-NEXT:    movs r0, #10
292; CHECK-8M-SOFT-NEXT:    push.w {r4, r5, r6, r7, r8, r9, r10, r11}
293; CHECK-8M-SOFT-NEXT:    bic r1, r1, #1
294; CHECK-8M-SOFT-NEXT:    msr apsr_nzcvqg, r1
295; CHECK-8M-SOFT-NEXT:    mov r2, r1
296; CHECK-8M-SOFT-NEXT:    mov r3, r1
297; CHECK-8M-SOFT-NEXT:    mov r4, r1
298; CHECK-8M-SOFT-NEXT:    mov r5, r1
299; CHECK-8M-SOFT-NEXT:    mov r6, r1
300; CHECK-8M-SOFT-NEXT:    mov r7, r1
301; CHECK-8M-SOFT-NEXT:    mov r8, r1
302; CHECK-8M-SOFT-NEXT:    mov r9, r1
303; CHECK-8M-SOFT-NEXT:    mov r10, r1
304; CHECK-8M-SOFT-NEXT:    mov r11, r1
305; CHECK-8M-SOFT-NEXT:    mov r12, r1
306; CHECK-8M-SOFT-NEXT:    blxns r1
307; CHECK-8M-SOFT-NEXT:    pop.w {r4, r5, r6, r7, r8, r9, r10, r11}
308; CHECK-8M-SOFT-NEXT:    pop {r7, pc}
309;
310; CHECK-8M-SOFTFP-LABEL: ns_tail_call:
311; CHECK-8M-SOFTFP:       @ %bb.0: @ %entry
312; CHECK-8M-SOFTFP-NEXT:    push {r7, lr}
313; CHECK-8M-SOFTFP-NEXT:    mov r1, r0
314; CHECK-8M-SOFTFP-NEXT:    movs r0, #10
315; CHECK-8M-SOFTFP-NEXT:    push.w {r4, r5, r6, r7, r8, r9, r10, r11}
316; CHECK-8M-SOFTFP-NEXT:    bic r1, r1, #1
317; CHECK-8M-SOFTFP-NEXT:    sub sp, #136
318; CHECK-8M-SOFTFP-NEXT:    vlstm sp
319; CHECK-8M-SOFTFP-NEXT:    mov r2, r1
320; CHECK-8M-SOFTFP-NEXT:    mov r3, r1
321; CHECK-8M-SOFTFP-NEXT:    mov r4, r1
322; CHECK-8M-SOFTFP-NEXT:    mov r5, r1
323; CHECK-8M-SOFTFP-NEXT:    mov r6, r1
324; CHECK-8M-SOFTFP-NEXT:    mov r7, r1
325; CHECK-8M-SOFTFP-NEXT:    mov r8, r1
326; CHECK-8M-SOFTFP-NEXT:    mov r9, r1
327; CHECK-8M-SOFTFP-NEXT:    mov r10, r1
328; CHECK-8M-SOFTFP-NEXT:    mov r11, r1
329; CHECK-8M-SOFTFP-NEXT:    mov r12, r1
330; CHECK-8M-SOFTFP-NEXT:    msr apsr_nzcvqg, r1
331; CHECK-8M-SOFTFP-NEXT:    blxns r1
332; CHECK-8M-SOFTFP-NEXT:    vlldm sp
333; CHECK-8M-SOFTFP-NEXT:    add sp, #136
334; CHECK-8M-SOFTFP-NEXT:    pop.w {r4, r5, r6, r7, r8, r9, r10, r11}
335; CHECK-8M-SOFTFP-NEXT:    pop {r7, pc}
336;
337; CHECK-81M-SOFT-LABEL: ns_tail_call:
338; CHECK-81M-SOFT:       @ %bb.0: @ %entry
339; CHECK-81M-SOFT-NEXT:    push {r7, lr}
340; CHECK-81M-SOFT-NEXT:    mov r1, r0
341; CHECK-81M-SOFT-NEXT:    movs r0, #10
342; CHECK-81M-SOFT-NEXT:    push.w {r4, r5, r6, r7, r8, r9, r10, r11}
343; CHECK-81M-SOFT-NEXT:    bic r1, r1, #1
344; CHECK-81M-SOFT-NEXT:    sub sp, #136
345; CHECK-81M-SOFT-NEXT:    vlstm sp
346; CHECK-81M-SOFT-NEXT:    clrm {r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, apsr}
347; CHECK-81M-SOFT-NEXT:    blxns r1
348; CHECK-81M-SOFT-NEXT:    vlldm sp
349; CHECK-81M-SOFT-NEXT:    add sp, #136
350; CHECK-81M-SOFT-NEXT:    pop.w {r4, r5, r6, r7, r8, r9, r10, r11}
351; CHECK-81M-SOFT-NEXT:    pop {r7, pc}
352;
353; CHECK-81M-SOFTFP-LABEL: ns_tail_call:
354; CHECK-81M-SOFTFP:       @ %bb.0: @ %entry
355; CHECK-81M-SOFTFP-NEXT:    push {r7, lr}
356; CHECK-81M-SOFTFP-NEXT:    mov r1, r0
357; CHECK-81M-SOFTFP-NEXT:    movs r0, #10
358; CHECK-81M-SOFTFP-NEXT:    push.w {r4, r5, r6, r7, r8, r9, r10, r11}
359; CHECK-81M-SOFTFP-NEXT:    bic r1, r1, #1
360; CHECK-81M-SOFTFP-NEXT:    sub sp, #136
361; CHECK-81M-SOFTFP-NEXT:    vlstm sp
362; CHECK-81M-SOFTFP-NEXT:    clrm {r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, apsr}
363; CHECK-81M-SOFTFP-NEXT:    blxns r1
364; CHECK-81M-SOFTFP-NEXT:    vlldm sp
365; CHECK-81M-SOFTFP-NEXT:    add sp, #136
366; CHECK-81M-SOFTFP-NEXT:    pop.w {r4, r5, r6, r7, r8, r9, r10, r11}
367; CHECK-81M-SOFTFP-NEXT:    pop {r7, pc}
368entry:
369  %call = tail call i32 %fptr(i32 10) #5
370  ret i32 %call
371}
372
373attributes #4 = { nounwind }
374attributes #5 = { "cmse_nonsecure_call" nounwind }
375
376
377define void (i32, i32, i32, i32)* @ns_tail_call_many_args(void (i32, i32, i32, i32)* %f, i32 %a, i32 %b, i32 %c, i32 %d) #6 {
378; CHECK-8B-LABEL: ns_tail_call_many_args:
379; CHECK-8B:       @ %bb.0:
380; CHECK-8B-NEXT:    push {r4, r5, r7, lr}
381; CHECK-8B-NEXT:    mov r5, r3
382; CHECK-8B-NEXT:    mov r4, r0
383; CHECK-8B-NEXT:    ldr r3, [sp, #16]
384; CHECK-8B-NEXT:    mov r0, r1
385; CHECK-8B-NEXT:    mov r1, r2
386; CHECK-8B-NEXT:    mov r2, r5
387; CHECK-8B-NEXT:    push {r4, r5, r6, r7}
388; CHECK-8B-NEXT:    mov r7, r11
389; CHECK-8B-NEXT:    mov r6, r10
390; CHECK-8B-NEXT:    mov r5, r9
391; CHECK-8B-NEXT:    push {r5, r6, r7}
392; CHECK-8B-NEXT:    mov r5, r8
393; CHECK-8B-NEXT:    push {r5}
394; CHECK-8B-NEXT:    mov r5, #1
395; CHECK-8B-NEXT:    bics r4, r5
396; CHECK-8B-NEXT:    mov r5, r4
397; CHECK-8B-NEXT:    mov r6, r4
398; CHECK-8B-NEXT:    mov r7, r4
399; CHECK-8B-NEXT:    mov r8, r4
400; CHECK-8B-NEXT:    mov r9, r4
401; CHECK-8B-NEXT:    mov r10, r4
402; CHECK-8B-NEXT:    mov r11, r4
403; CHECK-8B-NEXT:    mov r12, r4
404; CHECK-8B-NEXT:    msr apsr, r4
405; CHECK-8B-NEXT:    blxns r4
406; CHECK-8B-NEXT:    pop {r4, r5, r6, r7}
407; CHECK-8B-NEXT:    mov r8, r4
408; CHECK-8B-NEXT:    mov r9, r5
409; CHECK-8B-NEXT:    mov r10, r6
410; CHECK-8B-NEXT:    mov r11, r7
411; CHECK-8B-NEXT:    pop {r4, r5, r6, r7}
412; CHECK-8B-NEXT:    mov r0, r4
413; CHECK-8B-NEXT:    pop {r4, r5, r7, pc}
414;
415; CHECK-8M-SOFT-LABEL: ns_tail_call_many_args:
416; CHECK-8M-SOFT:       @ %bb.0:
417; CHECK-8M-SOFT-NEXT:    push {r4, lr}
418; CHECK-8M-SOFT-NEXT:    mov r4, r0
419; CHECK-8M-SOFT-NEXT:    mov r12, r3
420; CHECK-8M-SOFT-NEXT:    mov r0, r1
421; CHECK-8M-SOFT-NEXT:    mov r1, r2
422; CHECK-8M-SOFT-NEXT:    ldr r3, [sp, #8]
423; CHECK-8M-SOFT-NEXT:    mov r2, r12
424; CHECK-8M-SOFT-NEXT:    push.w {r4, r5, r6, r7, r8, r9, r10, r11}
425; CHECK-8M-SOFT-NEXT:    bic r4, r4, #1
426; CHECK-8M-SOFT-NEXT:    msr apsr_nzcvqg, r4
427; CHECK-8M-SOFT-NEXT:    mov r5, r4
428; CHECK-8M-SOFT-NEXT:    mov r6, r4
429; CHECK-8M-SOFT-NEXT:    mov r7, r4
430; CHECK-8M-SOFT-NEXT:    mov r8, r4
431; CHECK-8M-SOFT-NEXT:    mov r9, r4
432; CHECK-8M-SOFT-NEXT:    mov r10, r4
433; CHECK-8M-SOFT-NEXT:    mov r11, r4
434; CHECK-8M-SOFT-NEXT:    mov r12, r4
435; CHECK-8M-SOFT-NEXT:    blxns r4
436; CHECK-8M-SOFT-NEXT:    pop.w {r4, r5, r6, r7, r8, r9, r10, r11}
437; CHECK-8M-SOFT-NEXT:    mov r0, r4
438; CHECK-8M-SOFT-NEXT:    pop {r4, pc}
439;
440; CHECK-8M-SOFTFP-LABEL: ns_tail_call_many_args:
441; CHECK-8M-SOFTFP:       @ %bb.0:
442; CHECK-8M-SOFTFP-NEXT:    push {r4, lr}
443; CHECK-8M-SOFTFP-NEXT:    mov r4, r0
444; CHECK-8M-SOFTFP-NEXT:    mov r12, r3
445; CHECK-8M-SOFTFP-NEXT:    mov r0, r1
446; CHECK-8M-SOFTFP-NEXT:    mov r1, r2
447; CHECK-8M-SOFTFP-NEXT:    ldr r3, [sp, #8]
448; CHECK-8M-SOFTFP-NEXT:    mov r2, r12
449; CHECK-8M-SOFTFP-NEXT:    push.w {r4, r5, r6, r7, r8, r9, r10, r11}
450; CHECK-8M-SOFTFP-NEXT:    bic r4, r4, #1
451; CHECK-8M-SOFTFP-NEXT:    sub sp, #136
452; CHECK-8M-SOFTFP-NEXT:    vlstm sp
453; CHECK-8M-SOFTFP-NEXT:    mov r5, r4
454; CHECK-8M-SOFTFP-NEXT:    mov r6, r4
455; CHECK-8M-SOFTFP-NEXT:    mov r7, r4
456; CHECK-8M-SOFTFP-NEXT:    mov r8, r4
457; CHECK-8M-SOFTFP-NEXT:    mov r9, r4
458; CHECK-8M-SOFTFP-NEXT:    mov r10, r4
459; CHECK-8M-SOFTFP-NEXT:    mov r11, r4
460; CHECK-8M-SOFTFP-NEXT:    mov r12, r4
461; CHECK-8M-SOFTFP-NEXT:    msr apsr_nzcvqg, r4
462; CHECK-8M-SOFTFP-NEXT:    blxns r4
463; CHECK-8M-SOFTFP-NEXT:    vlldm sp
464; CHECK-8M-SOFTFP-NEXT:    add sp, #136
465; CHECK-8M-SOFTFP-NEXT:    pop.w {r4, r5, r6, r7, r8, r9, r10, r11}
466; CHECK-8M-SOFTFP-NEXT:    mov r0, r4
467; CHECK-8M-SOFTFP-NEXT:    pop {r4, pc}
468;
469; CHECK-81M-SOFT-LABEL: ns_tail_call_many_args:
470; CHECK-81M-SOFT:       @ %bb.0:
471; CHECK-81M-SOFT-NEXT:    push {r4, lr}
472; CHECK-81M-SOFT-NEXT:    mov r4, r0
473; CHECK-81M-SOFT-NEXT:    mov r12, r3
474; CHECK-81M-SOFT-NEXT:    mov r0, r1
475; CHECK-81M-SOFT-NEXT:    mov r1, r2
476; CHECK-81M-SOFT-NEXT:    ldr r3, [sp, #8]
477; CHECK-81M-SOFT-NEXT:    mov r2, r12
478; CHECK-81M-SOFT-NEXT:    push.w {r4, r5, r6, r7, r8, r9, r10, r11}
479; CHECK-81M-SOFT-NEXT:    bic r4, r4, #1
480; CHECK-81M-SOFT-NEXT:    sub sp, #136
481; CHECK-81M-SOFT-NEXT:    vlstm sp
482; CHECK-81M-SOFT-NEXT:    clrm {r5, r6, r7, r8, r9, r10, r11, r12, apsr}
483; CHECK-81M-SOFT-NEXT:    blxns r4
484; CHECK-81M-SOFT-NEXT:    vlldm sp
485; CHECK-81M-SOFT-NEXT:    add sp, #136
486; CHECK-81M-SOFT-NEXT:    pop.w {r4, r5, r6, r7, r8, r9, r10, r11}
487; CHECK-81M-SOFT-NEXT:    mov r0, r4
488; CHECK-81M-SOFT-NEXT:    pop {r4, pc}
489;
490; CHECK-81M-SOFTFP-LABEL: ns_tail_call_many_args:
491; CHECK-81M-SOFTFP:       @ %bb.0:
492; CHECK-81M-SOFTFP-NEXT:    push {r4, lr}
493; CHECK-81M-SOFTFP-NEXT:    mov r4, r0
494; CHECK-81M-SOFTFP-NEXT:    mov r12, r3
495; CHECK-81M-SOFTFP-NEXT:    mov r0, r1
496; CHECK-81M-SOFTFP-NEXT:    mov r1, r2
497; CHECK-81M-SOFTFP-NEXT:    ldr r3, [sp, #8]
498; CHECK-81M-SOFTFP-NEXT:    mov r2, r12
499; CHECK-81M-SOFTFP-NEXT:    push.w {r4, r5, r6, r7, r8, r9, r10, r11}
500; CHECK-81M-SOFTFP-NEXT:    bic r4, r4, #1
501; CHECK-81M-SOFTFP-NEXT:    sub sp, #136
502; CHECK-81M-SOFTFP-NEXT:    vlstm sp
503; CHECK-81M-SOFTFP-NEXT:    clrm {r5, r6, r7, r8, r9, r10, r11, r12, apsr}
504; CHECK-81M-SOFTFP-NEXT:    blxns r4
505; CHECK-81M-SOFTFP-NEXT:    vlldm sp
506; CHECK-81M-SOFTFP-NEXT:    add sp, #136
507; CHECK-81M-SOFTFP-NEXT:    pop.w {r4, r5, r6, r7, r8, r9, r10, r11}
508; CHECK-81M-SOFTFP-NEXT:    mov r0, r4
509; CHECK-81M-SOFTFP-NEXT:    pop {r4, pc}
510  tail call void %f(i32 %a, i32 %b, i32 %c, i32 %d) #7
511  ret void (i32, i32, i32, i32)* %f
512}
513
514attributes #6 = { nounwind }
515attributes #7 = { "cmse_nonsecure_call" nounwind }
516
517
518define i32 @ns_call_void(i32 %reg0, i32 ()* nocapture %fptr) #8 {
519; CHECK-8B-LABEL: ns_call_void:
520; CHECK-8B:       @ %bb.0: @ %entry
521; CHECK-8B-NEXT:    push {r7, lr}
522; CHECK-8B-NEXT:    push {r4, r5, r6, r7}
523; CHECK-8B-NEXT:    mov r7, r11
524; CHECK-8B-NEXT:    mov r6, r10
525; CHECK-8B-NEXT:    mov r5, r9
526; CHECK-8B-NEXT:    mov r4, r8
527; CHECK-8B-NEXT:    push {r4, r5, r6, r7}
528; CHECK-8B-NEXT:    mov r0, #1
529; CHECK-8B-NEXT:    bics r1, r0
530; CHECK-8B-NEXT:    mov r0, r1
531; CHECK-8B-NEXT:    mov r2, r1
532; CHECK-8B-NEXT:    mov r3, r1
533; CHECK-8B-NEXT:    mov r4, r1
534; CHECK-8B-NEXT:    mov r5, r1
535; CHECK-8B-NEXT:    mov r6, r1
536; CHECK-8B-NEXT:    mov r7, r1
537; CHECK-8B-NEXT:    mov r8, r1
538; CHECK-8B-NEXT:    mov r9, r1
539; CHECK-8B-NEXT:    mov r10, r1
540; CHECK-8B-NEXT:    mov r11, r1
541; CHECK-8B-NEXT:    mov r12, r1
542; CHECK-8B-NEXT:    msr apsr, r1
543; CHECK-8B-NEXT:    blxns r1
544; CHECK-8B-NEXT:    pop {r4, r5, r6, r7}
545; CHECK-8B-NEXT:    mov r8, r4
546; CHECK-8B-NEXT:    mov r9, r5
547; CHECK-8B-NEXT:    mov r10, r6
548; CHECK-8B-NEXT:    mov r11, r7
549; CHECK-8B-NEXT:    pop {r4, r5, r6, r7}
550; CHECK-8B-NEXT:    pop {r7, pc}
551;
552; CHECK-8M-SOFT-LABEL: ns_call_void:
553; CHECK-8M-SOFT:       @ %bb.0: @ %entry
554; CHECK-8M-SOFT-NEXT:    push {r7, lr}
555; CHECK-8M-SOFT-NEXT:    push.w {r4, r5, r6, r7, r8, r9, r10, r11}
556; CHECK-8M-SOFT-NEXT:    bic r1, r1, #1
557; CHECK-8M-SOFT-NEXT:    msr apsr_nzcvqg, r1
558; CHECK-8M-SOFT-NEXT:    mov r0, r1
559; CHECK-8M-SOFT-NEXT:    mov r2, r1
560; CHECK-8M-SOFT-NEXT:    mov r3, r1
561; CHECK-8M-SOFT-NEXT:    mov r4, r1
562; CHECK-8M-SOFT-NEXT:    mov r5, r1
563; CHECK-8M-SOFT-NEXT:    mov r6, r1
564; CHECK-8M-SOFT-NEXT:    mov r7, r1
565; CHECK-8M-SOFT-NEXT:    mov r8, r1
566; CHECK-8M-SOFT-NEXT:    mov r9, r1
567; CHECK-8M-SOFT-NEXT:    mov r10, r1
568; CHECK-8M-SOFT-NEXT:    mov r11, r1
569; CHECK-8M-SOFT-NEXT:    mov r12, r1
570; CHECK-8M-SOFT-NEXT:    blxns r1
571; CHECK-8M-SOFT-NEXT:    pop.w {r4, r5, r6, r7, r8, r9, r10, r11}
572; CHECK-8M-SOFT-NEXT:    pop {r7, pc}
573;
574; CHECK-8M-SOFTFP-LABEL: ns_call_void:
575; CHECK-8M-SOFTFP:       @ %bb.0: @ %entry
576; CHECK-8M-SOFTFP-NEXT:    push {r7, lr}
577; CHECK-8M-SOFTFP-NEXT:    push.w {r4, r5, r6, r7, r8, r9, r10, r11}
578; CHECK-8M-SOFTFP-NEXT:    bic r1, r1, #1
579; CHECK-8M-SOFTFP-NEXT:    sub sp, #136
580; CHECK-8M-SOFTFP-NEXT:    vlstm sp
581; CHECK-8M-SOFTFP-NEXT:    mov r0, r1
582; CHECK-8M-SOFTFP-NEXT:    mov r2, r1
583; CHECK-8M-SOFTFP-NEXT:    mov r3, r1
584; CHECK-8M-SOFTFP-NEXT:    mov r4, r1
585; CHECK-8M-SOFTFP-NEXT:    mov r5, r1
586; CHECK-8M-SOFTFP-NEXT:    mov r6, r1
587; CHECK-8M-SOFTFP-NEXT:    mov r7, r1
588; CHECK-8M-SOFTFP-NEXT:    mov r8, r1
589; CHECK-8M-SOFTFP-NEXT:    mov r9, r1
590; CHECK-8M-SOFTFP-NEXT:    mov r10, r1
591; CHECK-8M-SOFTFP-NEXT:    mov r11, r1
592; CHECK-8M-SOFTFP-NEXT:    mov r12, r1
593; CHECK-8M-SOFTFP-NEXT:    msr apsr_nzcvqg, r1
594; CHECK-8M-SOFTFP-NEXT:    blxns r1
595; CHECK-8M-SOFTFP-NEXT:    vlldm sp
596; CHECK-8M-SOFTFP-NEXT:    add sp, #136
597; CHECK-8M-SOFTFP-NEXT:    pop.w {r4, r5, r6, r7, r8, r9, r10, r11}
598; CHECK-8M-SOFTFP-NEXT:    pop {r7, pc}
599;
600; CHECK-81M-SOFT-LABEL: ns_call_void:
601; CHECK-81M-SOFT:       @ %bb.0: @ %entry
602; CHECK-81M-SOFT-NEXT:    push {r7, lr}
603; CHECK-81M-SOFT-NEXT:    push.w {r4, r5, r6, r7, r8, r9, r10, r11}
604; CHECK-81M-SOFT-NEXT:    bic r1, r1, #1
605; CHECK-81M-SOFT-NEXT:    sub sp, #136
606; CHECK-81M-SOFT-NEXT:    vlstm sp
607; CHECK-81M-SOFT-NEXT:    clrm {r0, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, apsr}
608; CHECK-81M-SOFT-NEXT:    blxns r1
609; CHECK-81M-SOFT-NEXT:    vlldm sp
610; CHECK-81M-SOFT-NEXT:    add sp, #136
611; CHECK-81M-SOFT-NEXT:    pop.w {r4, r5, r6, r7, r8, r9, r10, r11}
612; CHECK-81M-SOFT-NEXT:    pop {r7, pc}
613;
614; CHECK-81M-SOFTFP-LABEL: ns_call_void:
615; CHECK-81M-SOFTFP:       @ %bb.0: @ %entry
616; CHECK-81M-SOFTFP-NEXT:    push {r7, lr}
617; CHECK-81M-SOFTFP-NEXT:    push.w {r4, r5, r6, r7, r8, r9, r10, r11}
618; CHECK-81M-SOFTFP-NEXT:    bic r1, r1, #1
619; CHECK-81M-SOFTFP-NEXT:    sub sp, #136
620; CHECK-81M-SOFTFP-NEXT:    vlstm sp
621; CHECK-81M-SOFTFP-NEXT:    clrm {r0, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, apsr}
622; CHECK-81M-SOFTFP-NEXT:    blxns r1
623; CHECK-81M-SOFTFP-NEXT:    vlldm sp
624; CHECK-81M-SOFTFP-NEXT:    add sp, #136
625; CHECK-81M-SOFTFP-NEXT:    pop.w {r4, r5, r6, r7, r8, r9, r10, r11}
626; CHECK-81M-SOFTFP-NEXT:    pop {r7, pc}
627entry:
628  %call = call i32 %fptr() #9
629  ret i32 %call
630}
631
632attributes #8 = { nounwind }
633attributes #9 = { "cmse_nonsecure_call" nounwind }
634
635