1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=loongarch32 -mattr=+d < %s | FileCheck --check-prefix=LA32 %s
3 ; RUN: llc --mtriple=loongarch64 -mattr=+d < %s | FileCheck --check-prefix=LA64 %s
5 declare i32 @external_function(i32)
7 define i32 @test_call_external(i32 %a) nounwind {
8 ; LA32-LABEL: test_call_external:
10 ; LA32-NEXT: addi.w $sp, $sp, -16
11 ; LA32-NEXT: st.w $ra, $sp, 12 # 4-byte Folded Spill
12 ; LA32-NEXT: bl %plt(external_function)
13 ; LA32-NEXT: ld.w $ra, $sp, 12 # 4-byte Folded Reload
14 ; LA32-NEXT: addi.w $sp, $sp, 16
17 ; LA64-LABEL: test_call_external:
19 ; LA64-NEXT: addi.d $sp, $sp, -16
20 ; LA64-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
21 ; LA64-NEXT: bl %plt(external_function)
22 ; LA64-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
23 ; LA64-NEXT: addi.d $sp, $sp, 16
25 %1 = call i32 @external_function(i32 %a)
29 define i32 @defined_function(i32 %a) nounwind {
30 ; LA32-LABEL: defined_function:
32 ; LA32-NEXT: addi.w $a0, $a0, 1
35 ; LA64-LABEL: defined_function:
37 ; LA64-NEXT: addi.w $a0, $a0, 1
43 define i32 @test_call_defined(i32 %a) nounwind {
44 ; LA32-LABEL: test_call_defined:
46 ; LA32-NEXT: addi.w $sp, $sp, -16
47 ; LA32-NEXT: st.w $ra, $sp, 12 # 4-byte Folded Spill
48 ; LA32-NEXT: bl %plt(defined_function)
49 ; LA32-NEXT: ld.w $ra, $sp, 12 # 4-byte Folded Reload
50 ; LA32-NEXT: addi.w $sp, $sp, 16
53 ; LA64-LABEL: test_call_defined:
55 ; LA64-NEXT: addi.d $sp, $sp, -16
56 ; LA64-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
57 ; LA64-NEXT: bl %plt(defined_function)
58 ; LA64-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
59 ; LA64-NEXT: addi.d $sp, $sp, 16
61 %1 = call i32 @defined_function(i32 %a) nounwind
65 define i32 @test_call_indirect(ptr %a, i32 %b) nounwind {
66 ; LA32-LABEL: test_call_indirect:
68 ; LA32-NEXT: addi.w $sp, $sp, -16
69 ; LA32-NEXT: st.w $ra, $sp, 12 # 4-byte Folded Spill
70 ; LA32-NEXT: move $a2, $a0
71 ; LA32-NEXT: move $a0, $a1
72 ; LA32-NEXT: jirl $ra, $a2, 0
73 ; LA32-NEXT: ld.w $ra, $sp, 12 # 4-byte Folded Reload
74 ; LA32-NEXT: addi.w $sp, $sp, 16
77 ; LA64-LABEL: test_call_indirect:
79 ; LA64-NEXT: addi.d $sp, $sp, -16
80 ; LA64-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
81 ; LA64-NEXT: move $a2, $a0
82 ; LA64-NEXT: move $a0, $a1
83 ; LA64-NEXT: jirl $ra, $a2, 0
84 ; LA64-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
85 ; LA64-NEXT: addi.d $sp, $sp, 16
87 %1 = call i32 %a(i32 %b)