From 5d0dfa5e0e758fb075b70c4686e46abf45f3c3ba Mon Sep 17 00:00:00 2001 From: Alex Bradbury Date: Thu, 12 Apr 2018 05:42:42 +0000 Subject: [RISCV] Add codegen support for RV32D floating point arithmetic operations llvm-svn: 329874 --- llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 5 ++++- llvm/lib/Target/RISCV/RISCVInstrInfoD.td | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Target/RISCV') diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp index 3457ed599df..8b006d2d321 100644 --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -121,8 +121,11 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM, setOperationAction(ISD::BR_CC, MVT::f32, Expand); } - if (Subtarget.hasStdExtD()) + if (Subtarget.hasStdExtD()) { + setOperationAction(ISD::FMINNUM, MVT::f64, Legal); + setOperationAction(ISD::FMAXNUM, MVT::f64, Legal); setLoadExtAction(ISD::EXTLOAD, MVT::f64, MVT::f32, Expand); + } setOperationAction(ISD::GlobalAddress, XLenVT, Custom); setOperationAction(ISD::BlockAddress, XLenVT, Custom); diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoD.td b/llvm/lib/Target/RISCV/RISCVInstrInfoD.td index aec4ad0b262..13e8a3456d6 100644 --- a/llvm/lib/Target/RISCV/RISCVInstrInfoD.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoD.td @@ -191,6 +191,9 @@ def : InstAlias<"fneg.d $rd, $rs", (FSGNJN_D FPR64:$rd, FPR64:$rs, FPR64:$rs)>; // Pseudo-instructions and codegen patterns //===----------------------------------------------------------------------===// +class PatFpr64Fpr64 + : Pat<(OpNode FPR64:$rs1, FPR64:$rs2), (Inst $rs1, $rs2)>; + class PatFpr64Fpr64DynFrm : Pat<(OpNode FPR64:$rs1, FPR64:$rs2), (Inst $rs1, $rs2, 0b111)>; @@ -199,6 +202,32 @@ let Predicates = [HasStdExtD] in { /// Float arithmetic operations def : PatFpr64Fpr64DynFrm; +def : PatFpr64Fpr64DynFrm; +def : PatFpr64Fpr64DynFrm; +def : PatFpr64Fpr64DynFrm; + +def : Pat<(fsqrt FPR64:$rs1), (FSQRT_D FPR64:$rs1, 0b111)>; + +def : Pat<(fneg FPR64:$rs1), (FSGNJN_D $rs1, $rs1)>; +def : Pat<(fabs FPR64:$rs1), (FSGNJX_D $rs1, $rs1)>; + +def : PatFpr64Fpr64; +def : Pat<(fcopysign FPR64:$rs1, (fneg FPR64:$rs2)), (FSGNJN_D $rs1, $rs2)>; + +// The RISC-V 2.2 user-level ISA spec defines fmin and fmax as returning the +// canonical NaN when giving a signaling NaN. This doesn't match the LLVM +// behaviour (see https://bugs.llvm.org/show_bug.cgi?id=27363). However, the +// draft 2.3 ISA spec changes the definition of fmin and fmax in a way that +// matches LLVM's fminnum and fmaxnum +// . +def : PatFpr64Fpr64; +def : PatFpr64Fpr64; + +/// Setcc + +def : PatFpr64Fpr64; +def : PatFpr64Fpr64; +def : PatFpr64Fpr64; /// Loads -- cgit v1.2.3