blob: 25bce62952aedbc75ad29b4c87326d6737d4e315 [file] [log] [blame]
Sam Elliott9e6b2e12019-07-31 09:45:55 +00001; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=riscv32 -mattr=+f -verify-machineinstrs < %s \
3; RUN: | FileCheck -check-prefix=RV32F %s
4; RUN: llc -mtriple=riscv64 -mattr=+f -verify-machineinstrs < %s \
5; RUN: | FileCheck -check-prefix=RV64F %s
6
7@gf = external global float
8
9define float @constraint_f_float(float %a) nounwind {
10; RV32F-LABEL: constraint_f_float:
11; RV32F: # %bb.0:
Luis Marques3d0fbaf2019-09-17 11:15:35 +000012; RV32F-NEXT: lui a1, %hi(gf)
13; RV32F-NEXT: flw ft0, %lo(gf)(a1)
14; RV32F-NEXT: fmv.w.x ft1, a0
Sam Elliott9e6b2e12019-07-31 09:45:55 +000015; RV32F-NEXT: #APP
Luis Marques3d0fbaf2019-09-17 11:15:35 +000016; RV32F-NEXT: fadd.s ft0, ft1, ft0
Sam Elliott9e6b2e12019-07-31 09:45:55 +000017; RV32F-NEXT: #NO_APP
18; RV32F-NEXT: fmv.x.w a0, ft0
19; RV32F-NEXT: ret
20;
21; RV64F-LABEL: constraint_f_float:
22; RV64F: # %bb.0:
Luis Marques3d0fbaf2019-09-17 11:15:35 +000023; RV64F-NEXT: lui a1, %hi(gf)
24; RV64F-NEXT: flw ft0, %lo(gf)(a1)
25; RV64F-NEXT: fmv.w.x ft1, a0
Sam Elliott9e6b2e12019-07-31 09:45:55 +000026; RV64F-NEXT: #APP
Luis Marques3d0fbaf2019-09-17 11:15:35 +000027; RV64F-NEXT: fadd.s ft0, ft1, ft0
Sam Elliott9e6b2e12019-07-31 09:45:55 +000028; RV64F-NEXT: #NO_APP
29; RV64F-NEXT: fmv.x.w a0, ft0
30; RV64F-NEXT: ret
31 %1 = load float, float* @gf
32 %2 = tail call float asm "fadd.s $0, $1, $2", "=f,f,f"(float %a, float %1)
33 ret float %2
34}
Sam Elliott856d5c52019-08-08 14:59:16 +000035
36define float @constraint_f_float_abi_name(float %a) nounwind {
37; RV32F-LABEL: constraint_f_float_abi_name:
38; RV32F: # %bb.0:
Luis Marques3d0fbaf2019-09-17 11:15:35 +000039; RV32F-NEXT: lui a1, %hi(gf)
40; RV32F-NEXT: flw fs0, %lo(gf)(a1)
Sam Elliott856d5c52019-08-08 14:59:16 +000041; RV32F-NEXT: fmv.w.x fa0, a0
Sam Elliott856d5c52019-08-08 14:59:16 +000042; RV32F-NEXT: #APP
43; RV32F-NEXT: fadd.s ft0, fa0, fs0
44; RV32F-NEXT: #NO_APP
45; RV32F-NEXT: fmv.x.w a0, ft0
46; RV32F-NEXT: ret
47;
48; RV64F-LABEL: constraint_f_float_abi_name:
49; RV64F: # %bb.0:
Luis Marques3d0fbaf2019-09-17 11:15:35 +000050; RV64F-NEXT: lui a1, %hi(gf)
51; RV64F-NEXT: flw fs0, %lo(gf)(a1)
Sam Elliott856d5c52019-08-08 14:59:16 +000052; RV64F-NEXT: fmv.w.x fa0, a0
Sam Elliott856d5c52019-08-08 14:59:16 +000053; RV64F-NEXT: #APP
54; RV64F-NEXT: fadd.s ft0, fa0, fs0
55; RV64F-NEXT: #NO_APP
56; RV64F-NEXT: fmv.x.w a0, ft0
57; RV64F-NEXT: ret
58 %1 = load float, float* @gf
59 %2 = tail call float asm "fadd.s $0, $1, $2", "={ft0},{fa0},{fs0}"(float %a, float %1)
60 ret float %2
61}