1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2 ; RUN: llc --mtriple=loongarch64 --target-abi=lp64s < %s | FileCheck %s
4 ;; This file contains specific tests for the lp64s ABI.
6 define i64 @callee_float_in_regs(i64 %a, float %b) nounwind {
7 ; CHECK-LABEL: callee_float_in_regs:
9 ; CHECK-NEXT: addi.d $sp, $sp, -16
10 ; CHECK-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
11 ; CHECK-NEXT: st.d $fp, $sp, 0 # 8-byte Folded Spill
12 ; CHECK-NEXT: move $fp, $a0
13 ; CHECK-NEXT: bstrpick.d $a0, $a1, 31, 0
14 ; CHECK-NEXT: bl %plt(__fixsfdi)
15 ; CHECK-NEXT: add.d $a0, $fp, $a0
16 ; CHECK-NEXT: ld.d $fp, $sp, 0 # 8-byte Folded Reload
17 ; CHECK-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
18 ; CHECK-NEXT: addi.d $sp, $sp, 16
20 %b_fptosi = fptosi float %b to i64
21 %1 = add i64 %a, %b_fptosi
25 define i64 @caller_float_in_regs() nounwind {
26 ; CHECK-LABEL: caller_float_in_regs:
28 ; CHECK-NEXT: addi.d $sp, $sp, -16
29 ; CHECK-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
30 ; CHECK-NEXT: ori $a0, $zero, 1
31 ; CHECK-NEXT: lu12i.w $a1, 262144
32 ; CHECK-NEXT: bl %plt(callee_float_in_regs)
33 ; CHECK-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
34 ; CHECK-NEXT: addi.d $sp, $sp, 16
36 %1 = call i64 @callee_float_in_regs(i64 1, float 2.0)
40 define i64 @callee_float_on_stack(i128 %a, i128 %b, i128 %c, i128 %d, float %e) nounwind {
41 ; CHECK-LABEL: callee_float_on_stack:
43 ; CHECK-NEXT: ld.w $a0, $sp, 0
45 %1 = trunc i128 %d to i64
46 %2 = bitcast float %e to i32
47 %3 = sext i32 %2 to i64
52 define i64 @caller_float_on_stack() nounwind {
53 ; CHECK-LABEL: caller_float_on_stack:
55 ; CHECK-NEXT: addi.d $sp, $sp, -16
56 ; CHECK-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
57 ; CHECK-NEXT: lu12i.w $a0, 264704
58 ; CHECK-NEXT: st.d $a0, $sp, 0
59 ; CHECK-NEXT: ori $a0, $zero, 1
60 ; CHECK-NEXT: ori $a2, $zero, 2
61 ; CHECK-NEXT: ori $a4, $zero, 3
62 ; CHECK-NEXT: ori $a6, $zero, 4
63 ; CHECK-NEXT: move $a1, $zero
64 ; CHECK-NEXT: move $a3, $zero
65 ; CHECK-NEXT: move $a5, $zero
66 ; CHECK-NEXT: move $a7, $zero
67 ; CHECK-NEXT: bl %plt(callee_float_on_stack)
68 ; CHECK-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
69 ; CHECK-NEXT: addi.d $sp, $sp, 16
71 %1 = call i64 @callee_float_on_stack(i128 1, i128 2, i128 3, i128 4, float 5.0)
75 define float @callee_tiny_scalar_ret() nounwind {
76 ; CHECK-LABEL: callee_tiny_scalar_ret:
78 ; CHECK-NEXT: lu12i.w $a0, 260096
83 define i64 @caller_tiny_scalar_ret() nounwind {
84 ; CHECK-LABEL: caller_tiny_scalar_ret:
86 ; CHECK-NEXT: addi.d $sp, $sp, -16
87 ; CHECK-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
88 ; CHECK-NEXT: bl %plt(callee_tiny_scalar_ret)
89 ; CHECK-NEXT: addi.w $a0, $a0, 0
90 ; CHECK-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
91 ; CHECK-NEXT: addi.d $sp, $sp, 16
93 %1 = call float @callee_tiny_scalar_ret()
94 %2 = bitcast float %1 to i32
95 %3 = sext i32 %2 to i64