Skip to content

Commit 480c153

Browse files
committed
[Mips] Set custom lowering for STRICT_FSETCC/STRICT_FSETCC ops.
1 parent 6d5f87f commit 480c153

File tree

3 files changed

+614
-1
lines changed

3 files changed

+614
-1
lines changed

llvm/lib/Target/Mips/MipsISelLowering.cpp

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,11 @@ MipsTargetLowering::MipsTargetLowering(const MipsTargetMachine &TM,
357357
setOperationAction(ISD::FCOPYSIGN, MVT::f64, Custom);
358358
setOperationAction(ISD::FP_TO_SINT, MVT::i32, Custom);
359359

360+
setOperationAction(ISD::STRICT_FSETCC, MVT::f32, Custom);
361+
setOperationAction(ISD::STRICT_FSETCCS, MVT::f32, Custom);
362+
setOperationAction(ISD::STRICT_FSETCC, MVT::f64, Custom);
363+
setOperationAction(ISD::STRICT_FSETCCS, MVT::f64, Custom);
364+
360365
if (Subtarget.hasMips32r2() ||
361366
getTargetMachine().getTargetTriple().isOSLinux())
362367
setOperationAction(ISD::READCYCLECOUNTER, MVT::i64, Custom);
@@ -661,7 +666,8 @@ static bool invertFPCondCodeUser(Mips::CondCode CC) {
661666
// Returns Op if setcc is not a floating point comparison.
662667
static SDValue createFPCmp(SelectionDAG &DAG, const SDValue &Op) {
663668
// must be a SETCC node
664-
if (Op.getOpcode() != ISD::SETCC)
669+
if (Op.getOpcode() != ISD::SETCC && Op.getOpcode() != ISD::STRICT_FSETCC
670+
&& Op.getOpcode() != ISD::STRICT_FSETCCS)
665671
return Op;
666672

667673
SDValue LHS = Op.getOperand(0);
@@ -1338,6 +1344,8 @@ LowerOperation(SDValue Op, SelectionDAG &DAG) const
13381344
case ISD::JumpTable: return lowerJumpTable(Op, DAG);
13391345
case ISD::SELECT: return lowerSELECT(Op, DAG);
13401346
case ISD::SETCC: return lowerSETCC(Op, DAG);
1347+
case ISD::STRICT_FSETCC:
1348+
case ISD::STRICT_FSETCCS: return lowerFSETCC(Op, DAG);
13411349
case ISD::VASTART: return lowerVASTART(Op, DAG);
13421350
case ISD::VAARG: return lowerVAARG(Op, DAG);
13431351
case ISD::FCOPYSIGN: return lowerFCOPYSIGN(Op, DAG);
@@ -2227,6 +2235,24 @@ SDValue MipsTargetLowering::lowerSETCC(SDValue Op, SelectionDAG &DAG) const {
22272235
return createCMovFP(DAG, Cond, True, False, DL);
22282236
}
22292237

2238+
SDValue MipsTargetLowering::lowerFSETCC(SDValue Op, SelectionDAG &DAG) const {
2239+
assert(!Subtarget.hasMips32r6() && !Subtarget.hasMips64r6());
2240+
2241+
SDLoc DL(Op);
2242+
SDValue Chain = Op.getOperand(0);
2243+
SDValue LHS = Op.getOperand(1);
2244+
SDValue RHS = Op.getOperand(2);
2245+
ISD::CondCode CC = cast<CondCodeSDNode>(Op.getOperand(3))->get();
2246+
2247+
SDValue Cond = DAG.getNode(MipsISD::FPCmp, DL, MVT::Glue, LHS, RHS,
2248+
DAG.getConstant(condCodeToFCC(CC), DL, MVT::i32));
2249+
SDValue True = DAG.getConstant(1, DL, MVT::i32);
2250+
SDValue False = DAG.getConstant(0, DL, MVT::i32);
2251+
SDValue CMovFP = createCMovFP(DAG, Cond, True, False, DL);
2252+
2253+
return DAG.getMergeValues({CMovFP, Chain}, DL);
2254+
}
2255+
22302256
SDValue MipsTargetLowering::lowerGlobalAddress(SDValue Op,
22312257
SelectionDAG &DAG) const {
22322258
EVT Ty = Op.getValueType();

llvm/lib/Target/Mips/MipsISelLowering.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,7 @@ class TargetRegisterClass;
572572
SDValue lowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
573573
SDValue lowerSELECT(SDValue Op, SelectionDAG &DAG) const;
574574
SDValue lowerSETCC(SDValue Op, SelectionDAG &DAG) const;
575+
SDValue lowerFSETCC(SDValue Op, SelectionDAG &DAG) const;
575576
SDValue lowerVASTART(SDValue Op, SelectionDAG &DAG) const;
576577
SDValue lowerVAARG(SDValue Op, SelectionDAG &DAG) const;
577578
SDValue lowerFCOPYSIGN(SDValue Op, SelectionDAG &DAG) const;

0 commit comments

Comments
 (0)