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 176 // Vector binary and unary ops with a mask as a third operand, and VL as a 177 // fourth operand. 178 // FIXME: Can we replace these with ISD::VP_*? 179 ADD_VL, 180 AND_VL, 181 MUL_VL, 182 OR_VL, 183 SDIV_VL, 184 SHL_VL, 185 SREM_VL, 186 SRA_VL, 187 SRL_VL, 188 SUB_VL, 189 UDIV_VL, 190 UREM_VL, 191 XOR_VL, 192 FADD_VL, 193 FSUB_VL, 194 FMUL_VL, 195 FDIV_VL, 196 FNEG_VL, 197 FABS_VL, 198 FSQRT_VL, 199 FMA_VL, 200 FCOPYSIGN_VL, 201 SMIN_VL, 202 SMAX_VL, 203 UMIN_VL, 204 UMAX_VL, 205 FMINNUM_VL, 206 FMAXNUM_VL, 207 MULHS_VL, 208 MULHU_VL, 209 FP_TO_SINT_VL, 210 FP_TO_UINT_VL, 211 SINT_TO_FP_VL, 212 UINT_TO_FP_VL, 213 FP_ROUND_VL, 214 FP_EXTEND_VL, 215 216 // Vector compare producing a mask. Fourth operand is input mask. Fifth 217 // operand is VL. 218 SETCC_VL, 219 220 // Vector select with an additional VL operand. This operation is unmasked. 221 VSELECT_VL, 222 223 // Mask binary operators. 224 VMAND_VL, 225 VMOR_VL, 226 VMXOR_VL, 227 228 // Set mask vector to all zeros or ones. 229 VMCLR_VL, 230 VMSET_VL, 231 232 // Matches the semantics of vrgather.vx and vrgather.vv with an extra operand 233 // for VL. 234 VRGATHER_VX_VL, 235 VRGATHER_VV_VL, 236 VRGATHEREI16_VV_VL, 237 238 // Vector sign/zero extend with additional mask & VL operands. 239 VSEXT_VL, 240 VZEXT_VL, 241 // vpopc.m with additional mask and VL operands. 242 VPOPC_VL, 243 244 // Reads value of CSR. 245 // The first operand is a chain pointer. The second specifies address of the 246 // required CSR. Two results are produced, the read value and the new chain 247 // pointer. 248 READ_CSR, 249 // Write value to CSR. 250 // The first operand is a chain pointer, the second specifies address of the 251 // required CSR and the third is the value to write. The result is the new 252 // chain pointer. 253 WRITE_CSR, 254 // Read and write value of CSR. 255 // The first operand is a chain pointer, the second specifies address of the 256 // required CSR and the third is the value to write. Two results are produced, 257 // the value read before the modification and the new chain pointer. 258 SWAP_CSR, 259 260 // Memory opcodes start here. 261 VLE_VL = ISD::FIRST_TARGET_MEMORY_OPCODE, 262 VSE_VL, 263 264 // WARNING: Do not add anything in the end unless you want the node to 265 // have memop! In fact, starting from FIRST_TARGET_MEMORY_OPCODE all 266 // opcodes will be thought as target memory ops! 267 }; 268 } // namespace RISCVISD 269 270 class RISCVTargetLowering : public TargetLowering { 271 const RISCVSubtarget &Subtarget; 272 273 public: 274 explicit RISCVTargetLowering(const TargetMachine &TM, 275 const RISCVSubtarget &STI); 276 277 const RISCVSubtarget &getSubtarget() const { return Subtarget; } 278 279 bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallInst &I, 280 MachineFunction &MF, 281 unsigned Intrinsic) const override; 282 bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty, 283 unsigned AS, 284 Instruction *I = nullptr) const override; 285 bool isLegalICmpImmediate(int64_t Imm) const override; 286 bool isLegalAddImmediate(int64_t Imm) const override; 287 bool isTruncateFree(Type *SrcTy, Type *DstTy) const override; 288 bool isTruncateFree(EVT SrcVT, EVT DstVT) const override; 289 bool isZExtFree(SDValue Val, EVT VT2) const override; 290 bool isSExtCheaperThanZExt(EVT SrcVT, EVT DstVT) const override; 291 bool isCheapToSpeculateCttz() const override; 292 bool isCheapToSpeculateCtlz() const override; 293 bool isFPImmLegal(const APFloat &Imm, EVT VT, 294 bool ForCodeSize) const override; 295 296 bool softPromoteHalfType() const override { return true; } 297 298 /// Return the register type for a given MVT, ensuring vectors are treated 299 /// as a series of gpr sized integers. 300 MVT getRegisterTypeForCallingConv(LLVMContext &Context, CallingConv::ID CC, 301 EVT VT) const override; 302 303 /// Return the number of registers for a given MVT, ensuring vectors are 304 /// treated as a series of gpr sized integers. 305 unsigned getNumRegistersForCallingConv(LLVMContext &Context, 306 CallingConv::ID CC, 307 EVT VT) const override; 308 309 /// Return true if the given shuffle mask can be codegen'd directly, or if it 310 /// should be stack expanded. 311 bool isShuffleMaskLegal(ArrayRef<int> M, EVT VT) const override; 312 313 bool hasBitPreservingFPLogic(EVT VT) const override; 314 bool 315 shouldExpandBuildVectorWithShuffles(EVT VT, 316 unsigned DefinedValues) const override; 317 318 // Provide custom lowering hooks for some operations. 319 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override; 320 void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue> &Results, 321 SelectionDAG &DAG) const override; 322 323 SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override; 324 325 bool targetShrinkDemandedConstant(SDValue Op, const APInt &DemandedBits, 326 const APInt &DemandedElts, 327 TargetLoweringOpt &TLO) const override; 328 329 void computeKnownBitsForTargetNode(const SDValue Op, 330 KnownBits &Known, 331 const APInt &DemandedElts, 332 const SelectionDAG &DAG, 333 unsigned Depth) const override; 334 unsigned ComputeNumSignBitsForTargetNode(SDValue Op, 335 const APInt &DemandedElts, 336 const SelectionDAG &DAG, 337 unsigned Depth) const override; 338 339 // This method returns the name of a target specific DAG node. 340 const char *getTargetNodeName(unsigned Opcode) const override; 341 342 ConstraintType getConstraintType(StringRef Constraint) const override; 343 344 unsigned getInlineAsmMemConstraint(StringRef ConstraintCode) const override; 345 346 std::pair<unsigned, const TargetRegisterClass *> 347 getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, 348 StringRef Constraint, MVT VT) const override; 349 350 void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint, 351 std::vector<SDValue> &Ops, 352 SelectionDAG &DAG) const override; 353 354 MachineBasicBlock * 355 EmitInstrWithCustomInserter(MachineInstr &MI, 356 MachineBasicBlock *BB) const override; 357 358 EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context, 359 EVT VT) const override; 360 361 bool convertSetCCLogicToBitwiseLogic(EVT VT) const override { 362 return VT.isScalarInteger(); 363 } 364 bool convertSelectOfConstantsToMath(EVT VT) const override { return true; } 365 366 bool shouldInsertFencesForAtomic(const Instruction *I) const override { 367 return isa<LoadInst>(I) || isa<StoreInst>(I); 368 } 369 Instruction *emitLeadingFence(IRBuilder<> &Builder, Instruction *Inst, 370 AtomicOrdering Ord) const override; 371 Instruction *emitTrailingFence(IRBuilder<> &Builder, Instruction *Inst, 372 AtomicOrdering Ord) const override; 373 374 bool isFMAFasterThanFMulAndFAdd(const MachineFunction &MF, 375 EVT VT) const override; 376 377 ISD::NodeType getExtendForAtomicOps() const override { 378 return ISD::SIGN_EXTEND; 379 } 380 381 ISD::NodeType getExtendForAtomicCmpSwapArg() const override { 382 return ISD::SIGN_EXTEND; 383 } 384 385 bool shouldExpandShift(SelectionDAG &DAG, SDNode *N) const override { 386 if (DAG.getMachineFunction().getFunction().hasMinSize()) 387 return false; 388 return true; 389 } 390 bool isDesirableToCommuteWithShift(const SDNode *N, 391 CombineLevel Level) const override; 392 393 /// If a physical register, this returns the register that receives the 394 /// exception address on entry to an EH pad. 395 Register 396 getExceptionPointerRegister(const Constant *PersonalityFn) const override; 397 398 /// If a physical register, this returns the register that receives the 399 /// exception typeid on entry to a landing pad. 400 Register 401 getExceptionSelectorRegister(const Constant *PersonalityFn) const override; 402 403 bool shouldExtendTypeInLibCall(EVT Type) const override; 404 bool shouldSignExtendTypeInLibCall(EVT Type, bool IsSigned) const override; 405 406 /// Returns the register with the specified architectural or ABI name. This 407 /// method is necessary to lower the llvm.read_register.* and 408 /// llvm.write_register.* intrinsics. Allocatable registers must be reserved 409 /// with the clang -ffixed-xX flag for access to be allowed. 410 Register getRegisterByName(const char *RegName, LLT VT, 411 const MachineFunction &MF) const override; 412 413 // Lower incoming arguments, copy physregs into vregs 414 SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, 415 bool IsVarArg, 416 const SmallVectorImpl<ISD::InputArg> &Ins, 417 const SDLoc &DL, SelectionDAG &DAG, 418 SmallVectorImpl<SDValue> &InVals) const override; 419 bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF, 420 bool IsVarArg, 421 const SmallVectorImpl<ISD::OutputArg> &Outs, 422 LLVMContext &Context) const override; 423 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, 424 const SmallVectorImpl<ISD::OutputArg> &Outs, 425 const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL, 426 SelectionDAG &DAG) const override; 427 SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI, 428 SmallVectorImpl<SDValue> &InVals) const override; 429 430 bool shouldConvertConstantLoadToIntImm(const APInt &Imm, 431 Type *Ty) const override { 432 return true; 433 } 434 bool mayBeEmittedAsTailCall(const CallInst *CI) const override; 435 bool shouldConsiderGEPOffsetSplit() const override { return true; } 436 437 bool decomposeMulByConstant(LLVMContext &Context, EVT VT, 438 SDValue C) const override; 439 440 TargetLowering::AtomicExpansionKind 441 shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const override; 442 Value *emitMaskedAtomicRMWIntrinsic(IRBuilder<> &Builder, AtomicRMWInst *AI, 443 Value *AlignedAddr, Value *Incr, 444 Value *Mask, Value *ShiftAmt, 445 AtomicOrdering Ord) const override; 446 TargetLowering::AtomicExpansionKind 447 shouldExpandAtomicCmpXchgInIR(AtomicCmpXchgInst *CI) const override; 448 Value *emitMaskedAtomicCmpXchgIntrinsic(IRBuilder<> &Builder, 449 AtomicCmpXchgInst *CI, 450 Value *AlignedAddr, Value *CmpVal, 451 Value *NewVal, Value *Mask, 452 AtomicOrdering Ord) const override; 453 454 /// Returns true if the target allows unaligned memory accesses of the 455 /// specified type. 456 bool allowsMisalignedMemoryAccesses( 457 EVT VT, unsigned AddrSpace = 0, Align Alignment = Align(1), 458 MachineMemOperand::Flags Flags = MachineMemOperand::MONone, 459 bool *Fast = nullptr) const override; 460 461 bool splitValueIntoRegisterParts(SelectionDAG &DAG, const SDLoc &DL, 462 SDValue Val, SDValue *Parts, 463 unsigned NumParts, MVT PartVT, 464 Optional<CallingConv::ID> CC) const override; 465 466 SDValue 467 joinRegisterPartsIntoValue(SelectionDAG &DAG, const SDLoc &DL, 468 const SDValue *Parts, unsigned NumParts, 469 MVT PartVT, EVT ValueVT, 470 Optional<CallingConv::ID> CC) const override; 471 472 static RISCVVLMUL getLMUL(MVT VT); 473 static unsigned getRegClassIDForLMUL(RISCVVLMUL LMul); 474 static unsigned getSubregIndexByMVT(MVT VT, unsigned Index); 475 static unsigned getRegClassIDForVecVT(MVT VT); 476 static std::pair<unsigned, unsigned> 477 decomposeSubvectorInsertExtractToSubRegs(MVT VecVT, MVT SubVecVT, 478 unsigned InsertExtractIdx, 479 const RISCVRegisterInfo *TRI); 480 MVT getContainerForFixedLengthVector(MVT VT) const; 481 482 bool shouldRemoveExtendFromGSIndex(EVT VT) const override; 483 484 private: 485 void analyzeInputArgs(MachineFunction &MF, CCState &CCInfo, 486 const SmallVectorImpl<ISD::InputArg> &Ins, 487 bool IsRet) const; 488 void analyzeOutputArgs(MachineFunction &MF, CCState &CCInfo, 489 const SmallVectorImpl<ISD::OutputArg> &Outs, 490 bool IsRet, CallLoweringInfo *CLI) const; 491 492 template <class NodeTy> 493 SDValue getAddr(NodeTy *N, SelectionDAG &DAG, bool IsLocal = true) const; 494 495 SDValue getStaticTLSAddr(GlobalAddressSDNode *N, SelectionDAG &DAG, 496 bool UseGOT) const; 497 SDValue getDynamicTLSAddr(GlobalAddressSDNode *N, SelectionDAG &DAG) const; 498 499 SDValue lowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const; 500 SDValue lowerBlockAddress(SDValue Op, SelectionDAG &DAG) const; 501 SDValue lowerConstantPool(SDValue Op, SelectionDAG &DAG) const; 502 SDValue lowerJumpTable(SDValue Op, SelectionDAG &DAG) const; 503 SDValue lowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const; 504 SDValue lowerSELECT(SDValue Op, SelectionDAG &DAG) const; 505 SDValue lowerBRCOND(SDValue Op, SelectionDAG &DAG) const; 506 SDValue lowerVASTART(SDValue Op, SelectionDAG &DAG) const; 507 SDValue lowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const; 508 SDValue lowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const; 509 SDValue lowerShiftLeftParts(SDValue Op, SelectionDAG &DAG) const; 510 SDValue lowerShiftRightParts(SDValue Op, SelectionDAG &DAG, bool IsSRA) const; 511 SDValue lowerSPLAT_VECTOR_PARTS(SDValue Op, SelectionDAG &DAG) const; 512 SDValue lowerVectorMaskExt(SDValue Op, SelectionDAG &DAG, 513 int64_t ExtTrueVal) const; 514 SDValue lowerVectorMaskTrunc(SDValue Op, SelectionDAG &DAG) const; 515 SDValue lowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const; 516 SDValue lowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const; 517 SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const; 518 SDValue LowerINTRINSIC_W_CHAIN(SDValue Op, SelectionDAG &DAG) const; 519 SDValue lowerVECREDUCE(SDValue Op, SelectionDAG &DAG) const; 520 SDValue lowerVectorMaskVECREDUCE(SDValue Op, SelectionDAG &DAG) const; 521 SDValue lowerFPVECREDUCE(SDValue Op, SelectionDAG &DAG) const; 522 SDValue lowerINSERT_SUBVECTOR(SDValue Op, SelectionDAG &DAG) const; 523 SDValue lowerEXTRACT_SUBVECTOR(SDValue Op, SelectionDAG &DAG) const; 524 SDValue lowerSTEP_VECTOR(SDValue Op, SelectionDAG &DAG) const; 525 SDValue lowerVECTOR_REVERSE(SDValue Op, SelectionDAG &DAG) const; 526 SDValue lowerABS(SDValue Op, SelectionDAG &DAG) const; 527 SDValue lowerMLOAD(SDValue Op, SelectionDAG &DAG) const; 528 SDValue lowerMSTORE(SDValue Op, SelectionDAG &DAG) const; 529 SDValue lowerFixedLengthVectorFCOPYSIGNToRVV(SDValue Op, 530 SelectionDAG &DAG) const; 531 SDValue lowerMGATHER(SDValue Op, SelectionDAG &DAG) const; 532 SDValue lowerMSCATTER(SDValue Op, SelectionDAG &DAG) const; 533 SDValue lowerFixedLengthVectorLoadToRVV(SDValue Op, SelectionDAG &DAG) const; 534 SDValue lowerFixedLengthVectorStoreToRVV(SDValue Op, SelectionDAG &DAG) const; 535 SDValue lowerFixedLengthVectorSetccToRVV(SDValue Op, SelectionDAG &DAG) const; 536 SDValue lowerFixedLengthVectorLogicOpToRVV(SDValue Op, SelectionDAG &DAG, 537 unsigned MaskOpc, 538 unsigned VecOpc) const; 539 SDValue lowerFixedLengthVectorSelectToRVV(SDValue Op, 540 SelectionDAG &DAG) const; 541 SDValue lowerToScalableOp(SDValue Op, SelectionDAG &DAG, unsigned NewOpc, 542 bool HasMask = true) const; 543 SDValue lowerFixedLengthVectorExtendToRVV(SDValue Op, SelectionDAG &DAG, 544 unsigned ExtendOpc) const; 545 SDValue lowerGET_ROUNDING(SDValue Op, SelectionDAG &DAG) const; 546 SDValue lowerSET_ROUNDING(SDValue Op, SelectionDAG &DAG) const; 547 548 bool isEligibleForTailCallOptimization( 549 CCState &CCInfo, CallLoweringInfo &CLI, MachineFunction &MF, 550 const SmallVector<CCValAssign, 16> &ArgLocs) const; 551 552 /// Generate error diagnostics if any register used by CC has been marked 553 /// reserved. 554 void validateCCReservedRegs( 555 const SmallVectorImpl<std::pair<llvm::Register, llvm::SDValue>> &Regs, 556 MachineFunction &MF) const; 557 558 bool useRVVForFixedLengthVectorVT(MVT VT) const; 559 }; 560 561 namespace RISCV { 562 // We use 64 bits as the known part in the scalable vector types. 563 static constexpr unsigned RVVBitsPerBlock = 64; 564 } // namespace RISCV 565 566 namespace RISCVVIntrinsicsTable { 567 568 struct RISCVVIntrinsicInfo { 569 unsigned IntrinsicID; 570 uint8_t SplatOperand; 571 }; 572 573 using namespace RISCV; 574 575 #define GET_RISCVVIntrinsicsTable_DECL 576 #include "RISCVGenSearchableTables.inc" 577 578 } // end namespace RISCVVIntrinsicsTable 579 580 } // end namespace llvm 581 582 #endif 583