1 ; RUN: llc --mtriple=xtensa < %s | FileCheck %s
3 declare ptr @llvm.stacksave()
5 declare void @llvm.stackrestore(ptr)
7 declare void @use_addr(ptr)
9 define void @test_saverestore(i64 %n) {
11 ; CHECK-NEXT: addi a8, a1, -16
12 ; CHECK-NEXT: or a1, a8, a8
13 ; CHECK: s32i a0, a1, 8
14 ; CHECK-NEXT: s32i a12, a1, 4
15 ; CHECK-NEXT: s32i a15, a1, 0
16 ; CHECK: or a15, a1, a1
17 ; CHECK: addi a8, a2, 3
18 ; CHECK-NEXT: movi a9, -4
19 ; CHECK-NEXT: and a8, a8, a9
20 ; CHECK-NEXT: addi a8, a8, 31
21 ; CHECK-NEXT: movi a9, -32
22 ; CHECK-NEXT: and a8, a8, a9
23 ; CHECK-NEXT: or a12, a1, a1
24 ; CHECK-NEXT: sub a1, a1, a8
25 ; CHECK-NEXT: or a2, a1, a1
26 ; CHECK-NEXT: l32r a8, .LCPI0_0
27 ; CHECK-NEXT: callx0 a8
28 ; CHECK-NEXT: or a1, a12, a12
29 ; CHECK-NEXT: or a1, a15, a15
30 ; CHECK-NEXT: l32i a15, a1, 0
31 ; CHECK-NEXT: l32i a12, a1, 4
32 ; CHECK-NEXT: l32i a0, a1, 8
33 ; CHECK-NEXT: addi a8, a1, 16
34 ; CHECK-NEXT: or a1, a8, a8
37 %sp = call ptr @llvm.stacksave.p0()
38 %addr = alloca i8, i64 %n
39 call void @use_addr(ptr %addr)
40 call void @llvm.stackrestore.p0(ptr %sp)