summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/RISCV/float-convert.ll
diff options
context:
space:
mode:
authorAlex Bradbury <asb@lowrisc.org>2018-03-20 12:45:35 +0000
committerAlex Bradbury <asb@lowrisc.org>2018-03-20 12:45:35 +0000
commit76c29ee8158142b9c97ad56f5da7f99970bbbd9f (patch)
treeb3dea9690ace28baf1391f4d8dc5c7fcca49ac0d /llvm/test/CodeGen/RISCV/float-convert.ll
parentdca383123fa560b0076c374d133e4059367c18bd (diff)
downloadbcm5719-llvm-76c29ee8158142b9c97ad56f5da7f99970bbbd9f.tar.gz
bcm5719-llvm-76c29ee8158142b9c97ad56f5da7f99970bbbd9f.zip
[RISCV] Add codegen for RV32F arithmetic and conversion operations
Currently, only a soft floating point ABI is supported. llvm-svn: 327976
Diffstat (limited to 'llvm/test/CodeGen/RISCV/float-convert.ll')
-rw-r--r--llvm/test/CodeGen/RISCV/float-convert.ll72
1 files changed, 72 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/RISCV/float-convert.ll b/llvm/test/CodeGen/RISCV/float-convert.ll
new file mode 100644
index 00000000000..d6e67cc6a8e
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/float-convert.ll
@@ -0,0 +1,72 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv32 -mattr=+f -verify-machineinstrs < %s \
+; RUN: | FileCheck -check-prefix=RV32IF %s
+
+define i32 @fcvt_w_s(float %a) nounwind {
+; RV32IF-LABEL: fcvt_w_s:
+; RV32IF: # %bb.0:
+; RV32IF-NEXT: fmv.w.x ft0, a0
+; RV32IF-NEXT: fcvt.w.s a0, ft0, rtz
+; RV32IF-NEXT: ret
+ %1 = fptosi float %a to i32
+ ret i32 %1
+}
+
+define i32 @fcvt_wu_s(float %a) nounwind {
+; RV32IF-LABEL: fcvt_wu_s:
+; RV32IF: # %bb.0:
+; RV32IF-NEXT: fmv.w.x ft0, a0
+; RV32IF-NEXT: fcvt.wu.s a0, ft0, rtz
+; RV32IF-NEXT: ret
+ %1 = fptoui float %a to i32
+ ret i32 %1
+}
+
+define i32 @fmv_x_w(float %a, float %b) nounwind {
+; RV32IF-LABEL: fmv_x_w:
+; RV32IF: # %bb.0:
+; RV32IF-NEXT: fmv.w.x ft0, a1
+; RV32IF-NEXT: fmv.w.x ft1, a0
+; RV32IF-NEXT: fadd.s ft0, ft1, ft0
+; RV32IF-NEXT: fmv.x.w a0, ft0
+; RV32IF-NEXT: ret
+; Ensure fmv.x.w is generated even for a soft float calling convention
+ %1 = fadd float %a, %b
+ %2 = bitcast float %1 to i32
+ ret i32 %2
+}
+
+define float @fcvt_s_w(i32 %a) nounwind {
+; RV32IF-LABEL: fcvt_s_w:
+; RV32IF: # %bb.0:
+; RV32IF-NEXT: fcvt.s.w ft0, a0
+; RV32IF-NEXT: fmv.x.w a0, ft0
+; RV32IF-NEXT: ret
+ %1 = sitofp i32 %a to float
+ ret float %1
+}
+
+define float @fcvt_s_wu(i32 %a) nounwind {
+; RV32IF-LABEL: fcvt_s_wu:
+; RV32IF: # %bb.0:
+; RV32IF-NEXT: fcvt.s.wu ft0, a0
+; RV32IF-NEXT: fmv.x.w a0, ft0
+; RV32IF-NEXT: ret
+ %1 = uitofp i32 %a to float
+ ret float %1
+}
+
+define float @fmv_w_x(i32 %a, i32 %b) nounwind {
+; RV32IF-LABEL: fmv_w_x:
+; RV32IF: # %bb.0:
+; RV32IF-NEXT: fmv.w.x ft0, a1
+; RV32IF-NEXT: fmv.w.x ft1, a0
+; RV32IF-NEXT: fadd.s ft0, ft1, ft0
+; RV32IF-NEXT: fmv.x.w a0, ft0
+; RV32IF-NEXT: ret
+; Ensure fmv.w.x is generated even for a soft float calling convention
+ %1 = bitcast i32 %a to float
+ %2 = bitcast i32 %b to float
+ %3 = fadd float %1, %2
+ ret float %3
+}
OpenPOWER on IntegriCloud