@@ -133,7 +133,7 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
133133 if (Subtarget.is64Bit())
134134 addRegisterClass(MVT::f64, &RISCV::GPRRegClass);
135135 else
136- addRegisterClass(MVT::f64, &RISCV::GPRF64PairRegClass );
136+ addRegisterClass(MVT::f64, &RISCV::GPRPairRegClass );
137137 }
138138
139139 static const MVT::SimpleValueType BoolVecVTs[] = {
@@ -300,6 +300,8 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
300300 setOperationAction(ISD::VASTART, MVT::Other, Custom);
301301 setOperationAction({ISD::VAARG, ISD::VACOPY, ISD::VAEND}, MVT::Other, Expand);
302302
303+ setOperationAction(ISD::BITCAST, MVT::Untyped, Custom);
304+
303305 if (!Subtarget.hasVendorXTHeadBb())
304306 setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i1, Expand);
305307
@@ -20499,7 +20501,7 @@ RISCVTargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
2049920501 if (VT == MVT::f32 && Subtarget.hasStdExtZfinx())
2050020502 return std::make_pair(0U, &RISCV::GPRF32NoX0RegClass);
2050120503 if (VT == MVT::f64 && Subtarget.hasStdExtZdinx() && !Subtarget.is64Bit())
20502- return std::make_pair(0U, &RISCV::GPRF64PairNoX0RegClass );
20504+ return std::make_pair(0U, &RISCV::GPRPairNoX0RegClass );
2050320505 return std::make_pair(0U, &RISCV::GPRNoX0RegClass);
2050420506 case 'f':
2050520507 if (VT == MVT::f16) {
@@ -20516,7 +20518,7 @@ RISCVTargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
2051620518 if (Subtarget.hasStdExtD())
2051720519 return std::make_pair(0U, &RISCV::FPR64RegClass);
2051820520 if (Subtarget.hasStdExtZdinx() && !Subtarget.is64Bit())
20519- return std::make_pair(0U, &RISCV::GPRF64PairNoX0RegClass );
20521+ return std::make_pair(0U, &RISCV::GPRPairNoX0RegClass );
2052020522 if (Subtarget.hasStdExtZdinx() && Subtarget.is64Bit())
2052120523 return std::make_pair(0U, &RISCV::GPRNoX0RegClass);
2052220524 }
@@ -20558,7 +20560,7 @@ RISCVTargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
2055820560 if (VT == MVT::f32 && Subtarget.hasStdExtZfinx())
2055920561 return std::make_pair(0U, &RISCV::GPRF32CRegClass);
2056020562 if (VT == MVT::f64 && Subtarget.hasStdExtZdinx() && !Subtarget.is64Bit())
20561- return std::make_pair(0U, &RISCV::GPRF64PairCRegClass );
20563+ return std::make_pair(0U, &RISCV::GPRPairCRegClass );
2056220564 if (!VT.isVector())
2056320565 return std::make_pair(0U, &RISCV::GPRCRegClass);
2056420566 } else if (Constraint == "cf") {
@@ -20576,13 +20578,13 @@ RISCVTargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
2057620578 if (Subtarget.hasStdExtD())
2057720579 return std::make_pair(0U, &RISCV::FPR64CRegClass);
2057820580 if (Subtarget.hasStdExtZdinx() && !Subtarget.is64Bit())
20579- return std::make_pair(0U, &RISCV::GPRF64PairCRegClass );
20581+ return std::make_pair(0U, &RISCV::GPRPairCRegClass );
2058020582 if (Subtarget.hasStdExtZdinx() && Subtarget.is64Bit())
2058120583 return std::make_pair(0U, &RISCV::GPRCRegClass);
2058220584 }
2058320585 } else if (Constraint == "Pr") {
2058420586 if (VT == MVT::f64 && !Subtarget.is64Bit() && Subtarget.hasStdExtZdinx())
20585- return std::make_pair(0U, &RISCV::GPRF64PairCRegClass );
20587+ return std::make_pair(0U, &RISCV::GPRPairCRegClass );
2058620588 return std::make_pair(0U, &RISCV::GPRPairNoX0RegClass);
2058720589 }
2058820590
@@ -20744,7 +20746,7 @@ RISCVTargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
2074420746 // Subtarget into account.
2074520747 if (Res.second == &RISCV::GPRF16RegClass ||
2074620748 Res.second == &RISCV::GPRF32RegClass ||
20747- Res.second == &RISCV::GPRF64PairRegClass )
20749+ Res.second == &RISCV::GPRPairRegClass )
2074820750 return std::make_pair(Res.first, &RISCV::GPRRegClass);
2074920751
2075020752 return Res;
@@ -21371,12 +21373,19 @@ bool RISCVTargetLowering::splitValueIntoRegisterParts(
2137121373 bool IsABIRegCopy = CC.has_value();
2137221374 EVT ValueVT = Val.getValueType();
2137321375
21374- if (ValueVT == (Subtarget.is64Bit() ? MVT::i128 : MVT::i64) &&
21376+ MVT PairVT = Subtarget.is64Bit() ? MVT::i128 : MVT::i64;
21377+ if ((ValueVT == PairVT ||
21378+ (!Subtarget.is64Bit() && Subtarget.hasStdExtZdinx() &&
21379+ ValueVT == MVT::f64)) &&
2137521380 NumParts == 1 && PartVT == MVT::Untyped) {
21376- // Pairs in Inline Assembly
21381+ // Pairs in Inline Assembly, f64 in Inline assembly on rv32_zdinx
2137721382 MVT XLenVT = Subtarget.getXLenVT();
21383+ if (ValueVT == MVT::f64)
21384+ Val = DAG.getBitcast(MVT::i64, Val);
2137821385 auto [Lo, Hi] = DAG.SplitScalar(Val, DL, XLenVT, XLenVT);
21379- Parts[0] = DAG.getNode(RISCVISD::BuildGPRPair, DL, MVT::Untyped, Lo, Hi);
21386+ // Always creating something MVT::Untyped, so always using
21387+ // RISCVISD::BuildGPRPair.
21388+ Parts[0] = DAG.getNode(RISCVISD::BuildGPRPair, DL, PartVT, Lo, Hi);
2138021389 return true;
2138121390 }
2138221391
@@ -21388,7 +21397,7 @@ bool RISCVTargetLowering::splitValueIntoRegisterParts(
2138821397 Val = DAG.getNode(ISD::ANY_EXTEND, DL, MVT::i32, Val);
2138921398 Val = DAG.getNode(ISD::OR, DL, MVT::i32, Val,
2139021399 DAG.getConstant(0xFFFF0000, DL, MVT::i32));
21391- Val = DAG.getNode(ISD::BITCAST, DL, MVT::f32 , Val);
21400+ Val = DAG.getNode(ISD::BITCAST, DL, PartVT , Val);
2139221401 Parts[0] = Val;
2139321402 return true;
2139421403 }
@@ -21452,14 +21461,24 @@ SDValue RISCVTargetLowering::joinRegisterPartsIntoValue(
2145221461 MVT PartVT, EVT ValueVT, std::optional<CallingConv::ID> CC) const {
2145321462 bool IsABIRegCopy = CC.has_value();
2145421463
21455- if (ValueVT == (Subtarget.is64Bit() ? MVT::i128 : MVT::i64) &&
21464+ MVT PairVT = Subtarget.is64Bit() ? MVT::i128 : MVT::i64;
21465+ if ((ValueVT == PairVT ||
21466+ (!Subtarget.is64Bit() && Subtarget.hasStdExtZdinx() &&
21467+ ValueVT == MVT::f64)) &&
2145621468 NumParts == 1 && PartVT == MVT::Untyped) {
21457- // Pairs in Inline Assembly
21469+ // Pairs in Inline Assembly, f64 in Inline assembly on rv32_zdinx
2145821470 MVT XLenVT = Subtarget.getXLenVT();
21459- SDValue Res = DAG.getNode(RISCVISD::SplitGPRPair, DL,
21460- DAG.getVTList(XLenVT, XLenVT), Parts[0]);
21461- return DAG.getNode(ISD::BUILD_PAIR, DL, ValueVT, Res.getValue(0),
21462- Res.getValue(1));
21471+
21472+ SDValue Val = Parts[0];
21473+ // Always starting with something MVT::Untyped, so always using
21474+ // RISCVISD::SplitGPRPair
21475+ Val = DAG.getNode(RISCVISD::SplitGPRPair, DL, DAG.getVTList(XLenVT, XLenVT),
21476+ Parts[0]);
21477+ Val = DAG.getNode(ISD::BUILD_PAIR, DL, PairVT, Val.getValue(0),
21478+ Val.getValue(1));
21479+ if (ValueVT == MVT::f64)
21480+ Val = DAG.getBitcast(ValueVT, Val);
21481+ return Val;
2146321482 }
2146421483
2146521484 if (IsABIRegCopy && (ValueVT == MVT::f16 || ValueVT == MVT::bf16) &&
0 commit comments