1 //===-- RISCVISelLowering.h - RISCV DAG Lowering Interface ------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file defines the interfaces that RISCV uses to lower LLVM code into a 10 // selection DAG. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_LIB_TARGET_RISCV_RISCVISELLOWERING_H 15 #define LLVM_LIB_TARGET_RISCV_RISCVISELLOWERING_H 16 17 #include "RISCV.h" 18 #include "llvm/CodeGen/SelectionDAG.h" 19 #include "llvm/CodeGen/TargetLowering.h" 20 21 namespace llvm { 22 class RISCVSubtarget; 23 struct RISCVRegisterInfo; 24 namespace RISCVISD { 25 enum NodeType : unsigned { 26 FIRST_NUMBER = ISD::BUILTIN_OP_END, 27 RET_FLAG, 28 URET_FLAG, 29 SRET_FLAG, 30 MRET_FLAG, 31 CALL, 32 /// Select with condition operator - This selects between a true value and 33 /// a false value (ops #3 and #4) based on the boolean result of comparing 34 /// the lhs and rhs (ops #0 and #1) of a conditional expression with the 35 /// condition code in op #2, a XLenVT constant from the ISD::CondCode enum. 36 /// The lhs and rhs are XLenVT integers. The true and false values can be 37 /// integer or floating point. 38 SELECT_CC, 39 BR_CC, 40 BuildPairF64, 41 SplitF64, 42 TAIL, 43 // Multiply high for signedxunsigned. 44 MULHSU, 45 // RV64I shifts, directly matching the semantics of the named RISC-V 46 // instructions. 47 SLLW, 48 SRAW, 49 SRLW, 50 // 32-bit operations from RV64M that can't be simply matched with a pattern 51 // at instruction selection time. These have undefined behavior for division 52 // by 0 or overflow (divw) like their target independent counterparts. 53 DIVW, 54 DIVUW, 55 REMUW, 56 // RV64IB rotates, directly matching the semantics of the named RISC-V 57 // instructions. 58 ROLW, 59 RORW, 60 // RV64IZbb bit counting instructions directly matching the semantics of the 61 // named RISC-V instructions. 62 CLZW, 63 CTZW, 64 // RV64IB/RV32IB funnel shifts, with the semantics of the named RISC-V 65 // instructions, but the same operand order as fshl/fshr intrinsics. 66 FSR, 67 FSL, 68 // RV64IB funnel shifts, with the semantics of the named RISC-V instructions, 69 // but the same operand order as fshl/fshr intrinsics. 70 FSRW, 71 FSLW, 72 // FPR<->GPR transfer operations when the FPR is smaller than XLEN, needed as 73 // XLEN is the only legal integer width. 74 // 75 // FMV_H_X matches the semantics of the FMV.H.X. 76 // FMV_X_ANYEXTH is similar to FMV.X.H but has an any-extended result. 77 // FMV_W_X_RV64 matches the semantics of the FMV.W.X. 78 // FMV_X_ANYEXTW_RV64 is similar to FMV.X.W but has an any-extended result. 79 // 80 // This is a more convenient semantic for producing dagcombines that remove 81 // unnecessary GPR->FPR->GPR moves. 82 FMV_H_X, 83 FMV_X_ANYEXTH, 84 FMV_W_X_RV64, 85 FMV_X_ANYEXTW_RV64, 86 // READ_CYCLE_WIDE - A read of the 64-bit cycle CSR on a 32-bit target 87 // (returns (Lo, Hi)). It takes a chain operand. 88 READ_CYCLE_WIDE, 89 // Generalized Reverse and Generalized Or-Combine - directly matching the 90 // semantics of the named RISC-V instructions. Lowered as custom nodes as 91 // TableGen chokes when faced with commutative permutations in deeply-nested 92 // DAGs. Each node takes an input operand and a control operand and outputs a 93 // bit-manipulated version of input. All operands are i32 or XLenVT. 94 GREV, 95 GREVW, 96 GORC, 97 GORCW, 98 SHFL, 99 SHFLW, 100 UNSHFL, 101 UNSHFLW, 102 // Bit Compress/Decompress implement the generic bit extract and bit deposit 103 // functions. This operation is also referred to as bit gather/scatter, bit 104 // pack/unpack, parallel extract/deposit, compress/expand, or right 105 // compress/right expand. 106 BCOMPRESS, 107 BCOMPRESSW, 108 BDECOMPRESS, 109 BDECOMPRESSW, 110 // Vector Extension 111 // VMV_V_X_VL matches the semantics of vmv.v.x but includes an extra operand 112 // for the VL value to be used for the operation. 113 VMV_V_X_VL, 114 // VFMV_V_F_VL matches the semantics of vfmv.v.f but includes an extra operand 115 // for the VL value to be used for the operation. 116 VFMV_V_F_VL, 117 // VMV_X_S matches the semantics of vmv.x.s. The result is always XLenVT sign 118 // extended from the vector element size. 119 VMV_X_S, 120 // VMV_S_X_VL matches the semantics of vmv.s.x. It carries a VL operand. 121 VMV_S_X_VL, 122 // VFMV_S_F_VL matches the semantics of vfmv.s.f. It carries a VL operand. 123 VFMV_S_F_VL, 124 // Splats an i64 scalar to a vector type (with element type i64) where the 125 // scalar is a sign-extended i32. 126 SPLAT_VECTOR_I64, 127 // Read VLENB CSR 128 READ_VLENB, 129 // Truncates a RVV integer vector by one power-of-two. Carries both an extra 130 // mask and VL operand. 131 TRUNCATE_VECTOR_VL, 132 // Unit-stride fault-only-first load 133 VLEFF, 134 VLEFF_MASK, 135 // Matches the semantics of vslideup/vslidedown. The first operand is the 136 // pass-thru operand, the second is the source vector, the third is the 137 // XLenVT index (either constant or non-constant), the fourth is the mask 138 // and the fifth the VL. 139 VSLIDEUP_VL, 140 VSLIDEDOWN_VL, 141 // Matches the semantics of vslide1up/slide1down. The first operand is the 142 // source vector, the second is the XLenVT scalar value. The third and fourth 143 // operands are the mask and VL operands. 144 VSLIDE1UP_VL, 145 VSLIDE1DOWN_VL, 146 // Matches the semantics of the vid.v instruction, with a mask and VL 147 // operand. 148 VID_VL, 149 // Matches the semantics of the vfcnvt.rod function (Convert double-width 150 // float to single-width float, rounding towards odd). Takes a double-width 151 // float vector and produces a single-width float vector. Also has a mask and 152 // VL operand. 153 VFNCVT_ROD_VL, 154 // These nodes match the semantics of the corresponding RVV vector reduction 155 // instructions. They produce a vector result which is the reduction 156 // performed over the first vector operand plus the first element of the 157 // second vector operand. The first operand is an unconstrained vector type, 158 // and the result and second operand's types are expected to be the 159 // corresponding full-width LMUL=1 type for the first operand: 160 // nxv8i8 = vecreduce_add nxv32i8, nxv8i8 161 // nxv2i32 = vecreduce_add nxv8i32, nxv2i32 162 // The different in types does introduce extra vsetvli instructions but 163 // similarly it reduces the number of registers consumed per reduction. 164 // Also has a mask and VL operand. 165 VECREDUCE_ADD_VL, 166 VECREDUCE_UMAX_VL, 167 VECREDUCE_SMAX_VL, 168 VECREDUCE_UMIN_VL, 169 VECREDUCE_SMIN_VL, 170 VECREDUCE_AND_VL, 171 VECREDUCE_OR_VL, 172 VECREDUCE_XOR_VL, 173 VECREDUCE_FADD_VL, 174 VECREDUCE_SEQ_FADD_VL, 175 VECREDUCE_FMIN_VL, 176 VECREDUCE_FMAX_VL, 177 178 // Vector binary and unary ops with a mask as a third operand, and VL as a 179 // fourth operand. 180 // FIXME: Can we replace these with ISD::VP_*? 181 ADD_VL, 182 AND_VL, 183 MUL_VL, 184 OR_VL, 185 SDIV_VL, 186 SHL_VL, 187 SREM_VL, 188 SRA_VL, 189 SRL_VL, 190 SUB_VL, 191 UDIV_VL, 192 UREM_VL, 193 XOR_VL, 194 FADD_VL, 195 FSUB_VL, 196 FMUL_VL, 197 FDIV_VL, 198 FNEG_VL, 199 FABS_VL, 200 FSQRT_VL, 201 FMA_VL, 202 FCOPYSIGN_VL, 203 SMIN_VL, 204 SMAX_VL, 205 UMIN_VL, 206 UMAX_VL, 207 FMINNUM_VL, 208 FMAXNUM_VL, 209 MULHS_VL, 210 MULHU_VL, 211 FP_TO_SINT_VL, 212 FP_TO_UINT_VL, 213 SINT_TO_FP_VL, 214 UINT_TO_FP_VL, 215 FP_ROUND_VL, 216 FP_EXTEND_VL, 217 218 // Vector compare producing a mask. Fourth operand is input mask. Fifth 219 // operand is VL. 220 SETCC_VL, 221 222 // Vector select with an additional VL operand. This operation is unmasked. 223 VSELECT_VL, 224 225 // Mask binary operators. 226 VMAND_VL, 227 VMOR_VL, 228 VMXOR_VL, 229 230 // Set mask vector to all zeros or ones. 231 VMCLR_VL, 232 VMSET_VL, 233 234 // Matches the semantics of vrgather.vx and vrgather.vv with an extra operand 235 // for VL. 236 VRGATHER_VX_VL, 237 VRGATHER_VV_VL, 238 VRGATHEREI16_VV_VL, 239 240 // Vector sign/zero extend with additional mask & VL operands. 241 VSEXT_VL, 242 VZEXT_VL, 243 // vpopc.m with additional mask and VL operands. 244 VPOPC_VL, 245 246 // Reads value of CSR. 247 // The first operand is a chain pointer. The second specifies address of the 248 // required CSR. Two results are produced, the read value and the new chain 249 // pointer. 250 READ_CSR, 251 // Write value to CSR. 252 // The first operand is a chain pointer, the second specifies address of the 253 // required CSR and the third is the value to write. The result is the new 254 // chain pointer. 255 WRITE_CSR, 256 // Read and write value of CSR. 257 // The first operand is a chain pointer, the second specifies address of the 258 // required CSR and the third is the value to write. Two results are produced, 259 // the value read before the modification and the new chain pointer. 260 SWAP_CSR, 261 262 // Memory opcodes start here. 263 VLE_VL = ISD::FIRST_TARGET_MEMORY_OPCODE, 264 VSE_VL, 265 266 // WARNING: Do not add anything in the end unless you want the node to 267 // have memop! In fact, starting from FIRST_TARGET_MEMORY_OPCODE all 268 // opcodes will be thought as target memory ops! 269 }; 270 } // namespace RISCVISD 271 272 class RISCVTargetLowering : public TargetLowering { 273 const RISCVSubtarget &Subtarget; 274 275 public: 276 explicit RISCVTargetLowering(const TargetMachine &TM, 277 const RISCVSubtarget &STI); 278 279 const RISCVSubtarget &getSubtarget() const { return Subtarget; } 280 281 bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallInst &I, 282 MachineFunction &MF, 283 unsigned Intrinsic) const override; 284 bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty, 285 unsigned AS, 286 Instruction *I = nullptr) const override; 287 bool isLegalICmpImmediate(int64_t Imm) const override; 288 bool isLegalAddImmediate(int64_t Imm) const override; 289 bool isTruncateFree(Type *SrcTy, Type *DstTy) const override; 290 bool isTruncateFree(EVT SrcVT, EVT DstVT) const override; 291 bool isZExtFree(SDValue Val, EVT VT2) const override; 292 bool isSExtCheaperThanZExt(EVT SrcVT, EVT DstVT) const override; 293 bool isCheapToSpeculateCttz() const override; 294 bool isCheapToSpeculateCtlz() const override; 295 bool isFPImmLegal(const APFloat &Imm, EVT VT, 296 bool ForCodeSize) const override; 297 298 bool softPromoteHalfType() const override { return true; } 299 300 /// Return the register type for a given MVT, ensuring vectors are treated 301 /// as a series of gpr sized integers. 302 MVT getRegisterTypeForCallingConv(LLVMContext &Context, CallingConv::ID CC, 303 EVT VT) const override; 304 305 /// Return the number of registers for a given MVT, ensuring vectors are 306 /// treated as a series of gpr sized integers. 307 unsigned getNumRegistersForCallingConv(LLVMContext &Context, 308 CallingConv::ID CC, 309 EVT VT) const override; 310 311 /// Return true if the given shuffle mask can be codegen'd directly, or if it 312 /// should be stack expanded. 313 bool isShuffleMaskLegal(ArrayRef<int> M, EVT VT) const override; 314 315 bool hasBitPreservingFPLogic(EVT VT) const override; 316 bool 317 shouldExpandBuildVectorWithShuffles(EVT VT, 318 unsigned DefinedValues) const override; 319 320 // Provide custom lowering hooks for some operations. 321 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override; 322 void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue> &Results, 323 SelectionDAG &DAG) const override; 324 325 SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override; 326 327 bool targetShrinkDemandedConstant(SDValue Op, const APInt &DemandedBits, 328 const APInt &DemandedElts, 329 TargetLoweringOpt &TLO) const override; 330 331 void computeKnownBitsForTargetNode(const SDValue Op, 332 KnownBits &Known, 333 const APInt &DemandedElts, 334 const SelectionDAG &DAG, 335 unsigned Depth) const override; 336 unsigned ComputeNumSignBitsForTargetNode(SDValue Op, 337 const APInt &DemandedElts, 338 const SelectionDAG &DAG, 339 unsigned Depth) const override; 340 341 // This method returns the name of a target specific DAG node. 342 const char *getTargetNodeName(unsigned Opcode) const override; 343 344 ConstraintType getConstraintType(StringRef Constraint) const override; 345 346 unsigned getInlineAsmMemConstraint(StringRef ConstraintCode) const override; 347 348 std::pair<unsigned, const TargetRegisterClass *> 349 getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, 350 StringRef Constraint, MVT VT) const override; 351 352 void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint, 353 std::vector<SDValue> &Ops, 354 SelectionDAG &DAG) const override; 355 356 MachineBasicBlock * 357 EmitInstrWithCustomInserter(MachineInstr &MI, 358 MachineBasicBlock *BB) const override; 359 360 EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context, 361 EVT VT) const override; 362 363 bool convertSetCCLogicToBitwiseLogic(EVT VT) const override { 364 return VT.isScalarInteger(); 365 } 366 bool convertSelectOfConstantsToMath(EVT VT) const override { return true; } 367 368 bool shouldInsertFencesForAtomic(const Instruction *I) const override { 369 return isa<LoadInst>(I) || isa<StoreInst>(I); 370 } 371 Instruction *emitLeadingFence(IRBuilder<> &Builder, Instruction *Inst, 372 AtomicOrdering Ord) const override; 373 Instruction *emitTrailingFence(IRBuilder<> &Builder, Instruction *Inst, 374 AtomicOrdering Ord) const override; 375 376 bool isFMAFasterThanFMulAndFAdd(const MachineFunction &MF, 377 EVT VT) const override; 378 379 ISD::NodeType getExtendForAtomicOps() const override { 380 return ISD::SIGN_EXTEND; 381 } 382 383 ISD::NodeType getExtendForAtomicCmpSwapArg() const override { 384 return ISD::SIGN_EXTEND; 385 } 386 387 bool shouldExpandShift(SelectionDAG &DAG, SDNode *N) const override { 388 if (DAG.getMachineFunction().getFunction().hasMinSize()) 389 return false; 390 return true; 391 } 392 bool isDesirableToCommuteWithShift(const SDNode *N, 393 CombineLevel Level) const override; 394 395 /// If a physical register, this returns the register that receives the 396 /// exception address on entry to an EH pad. 397 Register 398 getExceptionPointerRegister(const Constant *PersonalityFn) const override; 399 400 /// If a physical register, this returns the register that receives the 401 /// exception typeid on entry to a landing pad. 402 Register 403 getExceptionSelectorRegister(const Constant *PersonalityFn) const override; 404 405 bool shouldExtendTypeInLibCall(EVT Type) const override; 406 bool shouldSignExtendTypeInLibCall(EVT Type, bool IsSigned) const override; 407 408 /// Returns the register with the specified architectural or ABI name. This 409 /// method is necessary to lower the llvm.read_register.* and 410 /// llvm.write_register.* intrinsics. Allocatable registers must be reserved 411 /// with the clang -ffixed-xX flag for access to be allowed. 412 Register getRegisterByName(const char *RegName, LLT VT, 413 const MachineFunction &MF) const override; 414 415 // Lower incoming arguments, copy physregs into vregs 416 SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, 417 bool IsVarArg, 418 const SmallVectorImpl<ISD::InputArg> &Ins, 419 const SDLoc &DL, SelectionDAG &DAG, 420 SmallVectorImpl<SDValue> &InVals) const override; 421 bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF, 422 bool IsVarArg, 423 const SmallVectorImpl<ISD::OutputArg> &Outs, 424 LLVMContext &Context) const override; 425 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, 426 const SmallVectorImpl<ISD::OutputArg> &Outs, 427 const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL, 428 SelectionDAG &DAG) const override; 429 SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI, 430 SmallVectorImpl<SDValue> &InVals) const override; 431 432 bool shouldConvertConstantLoadToIntImm(const APInt &Imm, 433 Type *Ty) const override { 434 return true; 435 } 436 bool mayBeEmittedAsTailCall(const CallInst *CI) const override; 437 bool shouldConsiderGEPOffsetSplit() const override { return true; } 438 439 bool decomposeMulByConstant(LLVMContext &Context, EVT VT, 440 SDValue C) const override; 441 442 TargetLowering::AtomicExpansionKind 443 shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const override; 444 Value *emitMaskedAtomicRMWIntrinsic(IRBuilder<> &Builder, AtomicRMWInst *AI, 445 Value *AlignedAddr, Value *Incr, 446 Value *Mask, Value *ShiftAmt, 447 AtomicOrdering Ord) const override; 448 TargetLowering::AtomicExpansionKind 449 shouldExpandAtomicCmpXchgInIR(AtomicCmpXchgInst *CI) const override; 450 Value *emitMaskedAtomicCmpXchgIntrinsic(IRBuilder<> &Builder, 451 AtomicCmpXchgInst *CI, 452 Value *AlignedAddr, Value *CmpVal, 453 Value *NewVal, Value *Mask, 454 AtomicOrdering Ord) const override; 455 456 /// Returns true if the target allows unaligned memory accesses of the 457 /// specified type. 458 bool allowsMisalignedMemoryAccesses( 459 EVT VT, unsigned AddrSpace = 0, Align Alignment = Align(1), 460 MachineMemOperand::Flags Flags = MachineMemOperand::MONone, 461 bool *Fast = nullptr) const override; 462 463 bool splitValueIntoRegisterParts(SelectionDAG &DAG, const SDLoc &DL, 464 SDValue Val, SDValue *Parts, 465 unsigned NumParts, MVT PartVT, 466 Optional<CallingConv::ID> CC) const override; 467 468 SDValue 469 joinRegisterPartsIntoValue(SelectionDAG &DAG, const SDLoc &DL, 470 const SDValue *Parts, unsigned NumParts, 471 MVT PartVT, EVT ValueVT, 472 Optional<CallingConv::ID> CC) const override; 473 474 static RISCVVLMUL getLMUL(MVT VT); 475 static unsigned getRegClassIDForLMUL(RISCVVLMUL LMul); 476 static unsigned getSubregIndexByMVT(MVT VT, unsigned Index); 477 static unsigned getRegClassIDForVecVT(MVT VT); 478 static std::pair<unsigned, unsigned> 479 decomposeSubvectorInsertExtractToSubRegs(MVT VecVT, MVT SubVecVT, 480 unsigned InsertExtractIdx, 481 const RISCVRegisterInfo *TRI); 482 MVT getContainerForFixedLengthVector(MVT VT) const; 483 484 bool shouldRemoveExtendFromGSIndex(EVT VT) const override; 485 486 private: 487 void analyzeInputArgs(MachineFunction &MF, CCState &CCInfo, 488 const SmallVectorImpl<ISD::InputArg> &Ins, 489 bool IsRet) const; 490 void analyzeOutputArgs(MachineFunction &MF, CCState &CCInfo, 491 const SmallVectorImpl<ISD::OutputArg> &Outs, 492 bool IsRet, CallLoweringInfo *CLI) const; 493 494 template <class NodeTy> 495 SDValue getAddr(NodeTy *N, SelectionDAG &DAG, bool IsLocal = true) const; 496 497 SDValue getStaticTLSAddr(GlobalAddressSDNode *N, SelectionDAG &DAG, 498 bool UseGOT) const; 499 SDValue getDynamicTLSAddr(GlobalAddressSDNode *N, SelectionDAG &DAG) const; 500 501 SDValue lowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const; 502 SDValue lowerBlockAddress(SDValue Op, SelectionDAG &DAG) const; 503 SDValue lowerConstantPool(SDValue Op, SelectionDAG &DAG) const; 504 SDValue lowerJumpTable(SDValue Op, SelectionDAG &DAG) const; 505 SDValue lowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const; 506 SDValue lowerSELECT(SDValue Op, SelectionDAG &DAG) const; 507 SDValue lowerBRCOND(SDValue Op, SelectionDAG &DAG) const; 508 SDValue lowerVASTART(SDValue Op, SelectionDAG &DAG) const; 509 SDValue lowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const; 510 SDValue lowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const; 511 SDValue lowerShiftLeftParts(SDValue Op, SelectionDAG &DAG) const; 512 SDValue lowerShiftRightParts(SDValue Op, SelectionDAG &DAG, bool IsSRA) const; 513 SDValue lowerSPLAT_VECTOR_PARTS(SDValue Op, SelectionDAG &DAG) const; 514 SDValue lowerVectorMaskSplat(SDValue Op, SelectionDAG &DAG) const; 515 SDValue lowerVectorMaskExt(SDValue Op, SelectionDAG &DAG, 516 int64_t ExtTrueVal) const; 517 SDValue lowerVectorMaskTrunc(SDValue Op, SelectionDAG &DAG) const; 518 SDValue lowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const; 519 SDValue lowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const; 520 SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const; 521 SDValue LowerINTRINSIC_W_CHAIN(SDValue Op, SelectionDAG &DAG) const; 522 SDValue lowerVECREDUCE(SDValue Op, SelectionDAG &DAG) const; 523 SDValue lowerVectorMaskVECREDUCE(SDValue Op, SelectionDAG &DAG) const; 524 SDValue lowerFPVECREDUCE(SDValue Op, SelectionDAG &DAG) const; 525 SDValue lowerINSERT_SUBVECTOR(SDValue Op, SelectionDAG &DAG) const; 526 SDValue lowerEXTRACT_SUBVECTOR(SDValue Op, SelectionDAG &DAG) const; 527 SDValue lowerSTEP_VECTOR(SDValue Op, SelectionDAG &DAG) const; 528 SDValue lowerVECTOR_REVERSE(SDValue Op, SelectionDAG &DAG) const; 529 SDValue lowerABS(SDValue Op, SelectionDAG &DAG) const; 530 SDValue lowerMLOAD(SDValue Op, SelectionDAG &DAG) const; 531 SDValue lowerMSTORE(SDValue Op, SelectionDAG &DAG) const; 532 SDValue lowerFixedLengthVectorFCOPYSIGNToRVV(SDValue Op, 533 SelectionDAG &DAG) const; 534 SDValue lowerMGATHER(SDValue Op, SelectionDAG &DAG) const; 535 SDValue lowerMSCATTER(SDValue Op, SelectionDAG &DAG) const; 536 SDValue lowerFixedLengthVectorLoadToRVV(SDValue Op, SelectionDAG &DAG) const; 537 SDValue lowerFixedLengthVectorStoreToRVV(SDValue Op, SelectionDAG &DAG) const; 538 SDValue lowerFixedLengthVectorSetccToRVV(SDValue Op, SelectionDAG &DAG) const; 539 SDValue lowerFixedLengthVectorLogicOpToRVV(SDValue Op, SelectionDAG &DAG, 540 unsigned MaskOpc, 541 unsigned VecOpc) const; 542 SDValue lowerFixedLengthVectorSelectToRVV(SDValue Op, 543 SelectionDAG &DAG) const; 544 SDValue lowerToScalableOp(SDValue Op, SelectionDAG &DAG, unsigned NewOpc, 545 bool HasMask = true) const; 546 SDValue lowerVPOp(SDValue Op, SelectionDAG &DAG, unsigned RISCVISDOpc) const; 547 SDValue lowerFixedLengthVectorExtendToRVV(SDValue Op, SelectionDAG &DAG, 548 unsigned ExtendOpc) const; 549 SDValue lowerGET_ROUNDING(SDValue Op, SelectionDAG &DAG) const; 550 SDValue lowerSET_ROUNDING(SDValue Op, SelectionDAG &DAG) const; 551 552 bool isEligibleForTailCallOptimization( 553 CCState &CCInfo, CallLoweringInfo &CLI, MachineFunction &MF, 554 const SmallVector<CCValAssign, 16> &ArgLocs) const; 555 556 /// Generate error diagnostics if any register used by CC has been marked 557 /// reserved. 558 void validateCCReservedRegs( 559 const SmallVectorImpl<std::pair<llvm::Register, llvm::SDValue>> &Regs, 560 MachineFunction &MF) const; 561 562 bool useRVVForFixedLengthVectorVT(MVT VT) const; 563 }; 564 565 namespace RISCV { 566 // We use 64 bits as the known part in the scalable vector types. 567 static constexpr unsigned RVVBitsPerBlock = 64; 568 } // namespace RISCV 569 570 namespace RISCVVIntrinsicsTable { 571 572 struct RISCVVIntrinsicInfo { 573 unsigned IntrinsicID; 574 uint8_t SplatOperand; 575 }; 576 577 using namespace RISCV; 578 579 #define GET_RISCVVIntrinsicsTable_DECL 580 #include "RISCVGenSearchableTables.inc" 581 582 } // end namespace RISCVVIntrinsicsTable 583 584 } // end namespace llvm 585 586 #endif 587