diff options
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Target/RISCV/RISCVISelLowering.cpp')
| -rw-r--r-- | contrib/llvm-project/llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 46 | 
1 files changed, 29 insertions, 17 deletions
diff --git a/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVISelLowering.cpp index 0a1a466af591..cb9ffabc4123 100644 --- a/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -138,7 +138,7 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,      if (Subtarget.is64Bit())        addRegisterClass(MVT::f64, &RISCV::GPRRegClass);      else -      addRegisterClass(MVT::f64, &RISCV::GPRPF64RegClass); +      addRegisterClass(MVT::f64, &RISCV::GPRPairRegClass);    }    static const MVT::SimpleValueType BoolVecVTs[] = { @@ -814,8 +814,8 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,        setOperationAction({ISD::FP_TO_SINT_SAT, ISD::FP_TO_UINT_SAT}, VT,                           Custom);        setOperationAction({ISD::LRINT, ISD::LLRINT}, VT, Custom); -      setOperationAction({ISD::AVGFLOORU, ISD::SADDSAT, ISD::UADDSAT, -                          ISD::SSUBSAT, ISD::USUBSAT}, +      setOperationAction({ISD::AVGFLOORU, ISD::AVGCEILU, ISD::SADDSAT, +                          ISD::UADDSAT, ISD::SSUBSAT, ISD::USUBSAT},                           VT, Legal);        // Integer VTs are lowered as a series of "RISCVISD::TRUNCATE_VECTOR_VL" @@ -1185,8 +1185,8 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,          if (VT.getVectorElementType() != MVT::i64 || Subtarget.hasStdExtV())            setOperationAction({ISD::MULHS, ISD::MULHU}, VT, Custom); -        setOperationAction({ISD::AVGFLOORU, ISD::SADDSAT, ISD::UADDSAT, -                            ISD::SSUBSAT, ISD::USUBSAT}, +        setOperationAction({ISD::AVGFLOORU, ISD::AVGCEILU, ISD::SADDSAT, +                            ISD::UADDSAT, ISD::SSUBSAT, ISD::USUBSAT},                             VT, Custom);          setOperationAction(ISD::VSELECT, VT, Custom); @@ -5466,6 +5466,7 @@ static unsigned getRISCVVLOp(SDValue Op) {    OP_CASE(SSUBSAT)    OP_CASE(USUBSAT)    OP_CASE(AVGFLOORU) +  OP_CASE(AVGCEILU)    OP_CASE(FADD)    OP_CASE(FSUB)    OP_CASE(FMUL) @@ -5570,7 +5571,7 @@ static bool hasMergeOp(unsigned Opcode) {           Opcode <= RISCVISD::LAST_RISCV_STRICTFP_OPCODE &&           "not a RISC-V target specific op");    static_assert(RISCVISD::LAST_VL_VECTOR_OP - RISCVISD::FIRST_VL_VECTOR_OP == -                    125 && +                    126 &&                  RISCVISD::LAST_RISCV_STRICTFP_OPCODE -                          ISD::FIRST_TARGET_STRICTFP_OPCODE ==                      21 && @@ -5596,7 +5597,7 @@ static bool hasMaskOp(unsigned Opcode) {           Opcode <= RISCVISD::LAST_RISCV_STRICTFP_OPCODE &&           "not a RISC-V target specific op");    static_assert(RISCVISD::LAST_VL_VECTOR_OP - RISCVISD::FIRST_VL_VECTOR_OP == -                    125 && +                    126 &&                  RISCVISD::LAST_RISCV_STRICTFP_OPCODE -                          ISD::FIRST_TARGET_STRICTFP_OPCODE ==                      21 && @@ -6461,6 +6462,7 @@ SDValue RISCVTargetLowering::LowerOperation(SDValue Op,        return SplitVectorOp(Op, DAG);      [[fallthrough]];    case ISD::AVGFLOORU: +  case ISD::AVGCEILU:    case ISD::SADDSAT:    case ISD::UADDSAT:    case ISD::SSUBSAT: @@ -7023,8 +7025,7 @@ foldBinOpIntoSelectIfProfitable(SDNode *BO, SelectionDAG &DAG,    if (!NewConstOp)      return SDValue(); -  const APInt &NewConstAPInt = -      cast<ConstantSDNode>(NewConstOp)->getAPIntValue(); +  const APInt &NewConstAPInt = NewConstOp->getAsAPIntVal();    if (!NewConstAPInt.isZero() && !NewConstAPInt.isAllOnes())      return SDValue(); @@ -7154,8 +7155,8 @@ SDValue RISCVTargetLowering::lowerSELECT(SDValue Op, SelectionDAG &DAG) const {    // is SETGE/SETLE to avoid an XORI.    if (isa<ConstantSDNode>(TrueV) && isa<ConstantSDNode>(FalseV) &&        CCVal == ISD::SETLT) { -    const APInt &TrueVal = cast<ConstantSDNode>(TrueV)->getAPIntValue(); -    const APInt &FalseVal = cast<ConstantSDNode>(FalseV)->getAPIntValue(); +    const APInt &TrueVal = TrueV->getAsAPIntVal(); +    const APInt &FalseVal = FalseV->getAsAPIntVal();      if (TrueVal - 1 == FalseVal)        return DAG.getNode(ISD::ADD, DL, VT, CondV, FalseV);      if (TrueVal + 1 == FalseVal) @@ -16345,7 +16346,7 @@ static MachineBasicBlock *emitSplitF64Pseudo(MachineInstr &MI,    Register SrcReg = MI.getOperand(2).getReg();    const TargetRegisterClass *SrcRC = MI.getOpcode() == RISCV::SplitF64Pseudo_INX -                                         ? &RISCV::GPRPF64RegClass +                                         ? &RISCV::GPRPairRegClass                                           : &RISCV::FPR64RegClass;    int FI = MF.getInfo<RISCVMachineFunctionInfo>()->getMoveF64FrameIndex(MF); @@ -16384,7 +16385,7 @@ static MachineBasicBlock *emitBuildPairF64Pseudo(MachineInstr &MI,    Register HiReg = MI.getOperand(2).getReg();    const TargetRegisterClass *DstRC = -      MI.getOpcode() == RISCV::BuildPairF64Pseudo_INX ? &RISCV::GPRPF64RegClass +      MI.getOpcode() == RISCV::BuildPairF64Pseudo_INX ? &RISCV::GPRPairRegClass                                                        : &RISCV::FPR64RegClass;    int FI = MF.getInfo<RISCVMachineFunctionInfo>()->getMoveF64FrameIndex(MF); @@ -18596,6 +18597,7 @@ const char *RISCVTargetLowering::getTargetNodeName(unsigned Opcode) const {    NODE_NAME_CASE(UREM_VL)    NODE_NAME_CASE(XOR_VL)    NODE_NAME_CASE(AVGFLOORU_VL) +  NODE_NAME_CASE(AVGCEILU_VL)    NODE_NAME_CASE(SADDSAT_VL)    NODE_NAME_CASE(UADDSAT_VL)    NODE_NAME_CASE(SSUBSAT_VL) @@ -18752,7 +18754,7 @@ RISCVTargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,        if (VT == MVT::f32 && Subtarget.hasStdExtZfinx())          return std::make_pair(0U, &RISCV::GPRF32RegClass);        if (VT == MVT::f64 && Subtarget.hasStdExtZdinx() && !Subtarget.is64Bit()) -        return std::make_pair(0U, &RISCV::GPRPF64RegClass); +        return std::make_pair(0U, &RISCV::GPRPairRegClass);        return std::make_pair(0U, &RISCV::GPRNoX0RegClass);      case 'f':        if (Subtarget.hasStdExtZfhmin() && VT == MVT::f16) @@ -18934,7 +18936,7 @@ RISCVTargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,    // Subtarget into account.    if (Res.second == &RISCV::GPRF16RegClass ||        Res.second == &RISCV::GPRF32RegClass || -      Res.second == &RISCV::GPRPF64RegClass) +      Res.second == &RISCV::GPRPairRegClass)      return std::make_pair(Res.first, &RISCV::GPRRegClass);    return Res; @@ -19362,6 +19364,11 @@ bool RISCVTargetLowering::isFMAFasterThanFMulAndFAdd(const MachineFunction &MF,    return false;  } +ISD::NodeType RISCVTargetLowering::getExtendForAtomicCmpSwapArg() const { +  // Zacas will use amocas.w which does not require extension. +  return Subtarget.hasStdExtZacas() ? ISD::ANY_EXTEND : ISD::SIGN_EXTEND; +} +  Register RISCVTargetLowering::getExceptionPointerRegister(      const Constant *PersonalityFn) const {    return RISCV::X10; @@ -20017,8 +20024,13 @@ unsigned RISCVTargetLowering::getCustomCtpopCost(EVT VT,  }  bool RISCVTargetLowering::fallBackToDAGISel(const Instruction &Inst) const { -  // At the moment, the only scalable instruction GISel knows how to lower is -  // ret with scalable argument. + +  // GISel support is in progress or complete for G_ADD, G_SUB, G_AND, G_OR, and +  // G_XOR. +  unsigned Op = Inst.getOpcode(); +  if (Op == Instruction::Add || Op == Instruction::Sub || +      Op == Instruction::And || Op == Instruction::Or || Op == Instruction::Xor) +    return false;    if (Inst.getType()->isScalableTy())      return true;  | 
