1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=zfh -verify-machineinstrs < %s \
3 ; RUN: -target-abi=ilp32f | FileCheck -check-prefix=RV32ZFH %s
4 ; RUN: llc -mtriple=riscv64 -mattr=zfh -verify-machineinstrs < %s \
5 ; RUN: -target-abi=lp64f | FileCheck -check-prefix=RV64ZFH %s
6 ; RUN: llc -mtriple=riscv32 -mattr=zfh,+d -verify-machineinstrs < %s \
7 ; RUN: -target-abi=ilp32d | FileCheck -check-prefix=RV32DZFH %s
8 ; RUN: llc -mtriple=riscv64 -mattr=zfh,+d -verify-machineinstrs < %s \
9 ; RUN: -target-abi=lp64d | FileCheck -check-prefix=RV64DZFH %s
11 @gh = external global half
13 define half @constraint_f_half(half %a) nounwind {
14 ; RV32ZFH-LABEL: constraint_f_half:
16 ; RV32ZFH-NEXT: lui a0, %hi(gh)
17 ; RV32ZFH-NEXT: flh fa5, %lo(gh)(a0)
19 ; RV32ZFH-NEXT: fadd.h fa0, fa0, fa5
20 ; RV32ZFH-NEXT: #NO_APP
23 ; RV64ZFH-LABEL: constraint_f_half:
25 ; RV64ZFH-NEXT: lui a0, %hi(gh)
26 ; RV64ZFH-NEXT: flh fa5, %lo(gh)(a0)
28 ; RV64ZFH-NEXT: fadd.h fa0, fa0, fa5
29 ; RV64ZFH-NEXT: #NO_APP
32 ; RV32DZFH-LABEL: constraint_f_half:
34 ; RV32DZFH-NEXT: lui a0, %hi(gh)
35 ; RV32DZFH-NEXT: flh fa5, %lo(gh)(a0)
37 ; RV32DZFH-NEXT: fadd.h fa0, fa0, fa5
38 ; RV32DZFH-NEXT: #NO_APP
41 ; RV64DZFH-LABEL: constraint_f_half:
43 ; RV64DZFH-NEXT: lui a0, %hi(gh)
44 ; RV64DZFH-NEXT: flh fa5, %lo(gh)(a0)
46 ; RV64DZFH-NEXT: fadd.h fa0, fa0, fa5
47 ; RV64DZFH-NEXT: #NO_APP
49 %1 = load half, ptr @gh
50 %2 = tail call half asm "fadd.h $0, $1, $2", "=f,f,f"(half %a, half %1)
54 define half @constraint_f_half_abi_name(half %a) nounwind {
55 ; RV32ZFH-LABEL: constraint_f_half_abi_name:
57 ; RV32ZFH-NEXT: addi sp, sp, -16
58 ; RV32ZFH-NEXT: fsw fs0, 12(sp) # 4-byte Folded Spill
59 ; RV32ZFH-NEXT: lui a0, %hi(gh)
60 ; RV32ZFH-NEXT: flh fs0, %lo(gh)(a0)
62 ; RV32ZFH-NEXT: fadd.s ft0, fa0, fs0
63 ; RV32ZFH-NEXT: #NO_APP
64 ; RV32ZFH-NEXT: fmv.h fa0, ft0
65 ; RV32ZFH-NEXT: flw fs0, 12(sp) # 4-byte Folded Reload
66 ; RV32ZFH-NEXT: addi sp, sp, 16
69 ; RV64ZFH-LABEL: constraint_f_half_abi_name:
71 ; RV64ZFH-NEXT: addi sp, sp, -16
72 ; RV64ZFH-NEXT: fsw fs0, 12(sp) # 4-byte Folded Spill
73 ; RV64ZFH-NEXT: lui a0, %hi(gh)
74 ; RV64ZFH-NEXT: flh fs0, %lo(gh)(a0)
76 ; RV64ZFH-NEXT: fadd.s ft0, fa0, fs0
77 ; RV64ZFH-NEXT: #NO_APP
78 ; RV64ZFH-NEXT: fmv.h fa0, ft0
79 ; RV64ZFH-NEXT: flw fs0, 12(sp) # 4-byte Folded Reload
80 ; RV64ZFH-NEXT: addi sp, sp, 16
83 ; RV32DZFH-LABEL: constraint_f_half_abi_name:
85 ; RV32DZFH-NEXT: addi sp, sp, -16
86 ; RV32DZFH-NEXT: fsd fs0, 8(sp) # 8-byte Folded Spill
87 ; RV32DZFH-NEXT: lui a0, %hi(gh)
88 ; RV32DZFH-NEXT: flh fs0, %lo(gh)(a0)
90 ; RV32DZFH-NEXT: fadd.s ft0, fa0, fs0
91 ; RV32DZFH-NEXT: #NO_APP
92 ; RV32DZFH-NEXT: fmv.h fa0, ft0
93 ; RV32DZFH-NEXT: fld fs0, 8(sp) # 8-byte Folded Reload
94 ; RV32DZFH-NEXT: addi sp, sp, 16
97 ; RV64DZFH-LABEL: constraint_f_half_abi_name:
99 ; RV64DZFH-NEXT: addi sp, sp, -16
100 ; RV64DZFH-NEXT: fsd fs0, 8(sp) # 8-byte Folded Spill
101 ; RV64DZFH-NEXT: lui a0, %hi(gh)
102 ; RV64DZFH-NEXT: flh fs0, %lo(gh)(a0)
103 ; RV64DZFH-NEXT: #APP
104 ; RV64DZFH-NEXT: fadd.s ft0, fa0, fs0
105 ; RV64DZFH-NEXT: #NO_APP
106 ; RV64DZFH-NEXT: fmv.h fa0, ft0
107 ; RV64DZFH-NEXT: fld fs0, 8(sp) # 8-byte Folded Reload
108 ; RV64DZFH-NEXT: addi sp, sp, 16
110 %1 = load half, ptr @gh
111 %2 = tail call half asm "fadd.s $0, $1, $2", "={ft0},{fa0},{fs0}"(half %a, half %1)
115 define half @constraint_gpr(half %x) {
116 ; RV32ZFH-LABEL: constraint_gpr:
118 ; RV32ZFH-NEXT: .cfi_def_cfa_offset 0
119 ; RV32ZFH-NEXT: fmv.x.h a0, fa0
121 ; RV32ZFH-NEXT: mv a0, a0
122 ; RV32ZFH-NEXT: #NO_APP
123 ; RV32ZFH-NEXT: fmv.h.x fa0, a0
126 ; RV64ZFH-LABEL: constraint_gpr:
128 ; RV64ZFH-NEXT: .cfi_def_cfa_offset 0
129 ; RV64ZFH-NEXT: fmv.x.h a0, fa0
131 ; RV64ZFH-NEXT: mv a0, a0
132 ; RV64ZFH-NEXT: #NO_APP
133 ; RV64ZFH-NEXT: fmv.h.x fa0, a0
136 ; RV32DZFH-LABEL: constraint_gpr:
138 ; RV32DZFH-NEXT: .cfi_def_cfa_offset 0
139 ; RV32DZFH-NEXT: fmv.x.h a0, fa0
140 ; RV32DZFH-NEXT: #APP
141 ; RV32DZFH-NEXT: mv a0, a0
142 ; RV32DZFH-NEXT: #NO_APP
143 ; RV32DZFH-NEXT: fmv.h.x fa0, a0
146 ; RV64DZFH-LABEL: constraint_gpr:
148 ; RV64DZFH-NEXT: .cfi_def_cfa_offset 0
149 ; RV64DZFH-NEXT: fmv.x.h a0, fa0
150 ; RV64DZFH-NEXT: #APP
151 ; RV64DZFH-NEXT: mv a0, a0
152 ; RV64DZFH-NEXT: #NO_APP
153 ; RV64DZFH-NEXT: fmv.h.x fa0, a0
155 %1 = tail call half asm sideeffect alignstack "mv $0, $1", "={x10},{x10}"(half %x)