LLVM 22.0.0git
RISCVISelLowering.h
Go to the documentation of this file.
1//===-- RISCVISelLowering.h - RISC-V 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 RISC-V 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 "RISCVCallingConv.h"
22#include <optional>
23
24namespace llvm {
25class InstructionCost;
26class RISCVSubtarget;
27struct RISCVRegisterInfo;
28
30 const RISCVSubtarget &Subtarget;
31
32public:
33 explicit RISCVTargetLowering(const TargetMachine &TM,
34 const RISCVSubtarget &STI);
35
36 const RISCVSubtarget &getSubtarget() const { return Subtarget; }
37
38 bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallInst &I,
40 unsigned Intrinsic) const override;
41 bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty,
42 unsigned AS,
43 Instruction *I = nullptr) const override;
44 bool isLegalICmpImmediate(int64_t Imm) const override;
45 bool isLegalAddImmediate(int64_t Imm) const override;
46 bool isTruncateFree(Type *SrcTy, Type *DstTy) const override;
47 bool isTruncateFree(EVT SrcVT, EVT DstVT) const override;
48 bool isTruncateFree(SDValue Val, EVT VT2) const override;
49 bool isZExtFree(SDValue Val, EVT VT2) const override;
50 bool isSExtCheaperThanZExt(EVT SrcVT, EVT DstVT) const override;
51 bool signExtendConstant(const ConstantInt *CI) const override;
52 bool isCheapToSpeculateCttz(Type *Ty) const override;
53 bool isCheapToSpeculateCtlz(Type *Ty) const override;
54 bool isMaskAndCmp0FoldingBeneficial(const Instruction &AndI) const override;
55 bool hasAndNotCompare(SDValue Y) const override;
56 bool hasAndNot(SDValue Y) const override;
57 bool hasBitTest(SDValue X, SDValue Y) const override;
60 unsigned OldShiftOpcode, unsigned NewShiftOpcode,
61 SelectionDAG &DAG) const override;
62 bool shouldScalarizeBinop(SDValue VecOp) const override;
63 bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
64 int getLegalZfaFPImm(const APFloat &Imm, EVT VT) const;
65 bool isFPImmLegal(const APFloat &Imm, EVT VT,
66 bool ForCodeSize) const override;
67 bool isExtractSubvectorCheap(EVT ResVT, EVT SrcVT,
68 unsigned Index) const override;
69
70 bool isIntDivCheap(EVT VT, AttributeList Attr) const override;
71
72 bool preferScalarizeSplat(SDNode *N) const override;
73
74 bool softPromoteHalfType() const override { return true; }
75
76 /// Return the register type for a given MVT, ensuring vectors are treated
77 /// as a series of gpr sized integers.
79 EVT VT) const override;
80
81 /// Return the number of registers for a given MVT, for inline assembly
82 unsigned
83 getNumRegisters(LLVMContext &Context, EVT VT,
84 std::optional<MVT> RegisterVT = std::nullopt) const override;
85
86 /// Return the number of registers for a given MVT, ensuring vectors are
87 /// treated as a series of gpr sized integers.
90 EVT VT) const override;
91
93 CallingConv::ID CC, EVT VT,
94 EVT &IntermediateVT,
95 unsigned &NumIntermediates,
96 MVT &RegisterVT) const override;
97
98 bool shouldFoldSelectWithIdentityConstant(unsigned BinOpcode, EVT VT,
99 unsigned SelectOpcode, SDValue X,
100 SDValue Y) const override;
101
102 /// Return true if the given shuffle mask can be codegen'd directly, or if it
103 /// should be stack expanded.
104 bool isShuffleMaskLegal(ArrayRef<int> M, EVT VT) const override;
105
106 bool isMultiStoresCheaperThanBitsMerge(EVT LTy, EVT HTy) const override {
107 // If the pair to store is a mixture of float and int values, we will
108 // save two bitwise instructions and one float-to-int instruction and
109 // increase one store instruction. There is potentially a more
110 // significant benefit because it avoids the float->int domain switch
111 // for input value. So It is more likely a win.
112 if ((LTy.isFloatingPoint() && HTy.isInteger()) ||
113 (LTy.isInteger() && HTy.isFloatingPoint()))
114 return true;
115 // If the pair only contains int values, we will save two bitwise
116 // instructions and increase one store instruction (costing one more
117 // store buffer). Since the benefit is more blurred we leave such a pair
118 // out until we get testcase to prove it is a win.
119 return false;
120 }
121
122 bool
124 unsigned DefinedValues) const override;
125
126 bool shouldExpandCttzElements(EVT VT) const override;
127
128 /// Return the cost of LMUL for linear operations.
130
135
136 // Provide custom lowering hooks for some operations.
137 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
139 SelectionDAG &DAG) const override;
140
141 SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
142
144 const APInt &DemandedElts,
145 TargetLoweringOpt &TLO) const override;
146
148 KnownBits &Known,
149 const APInt &DemandedElts,
150 const SelectionDAG &DAG,
151 unsigned Depth) const override;
153 const APInt &DemandedElts,
154 const SelectionDAG &DAG,
155 unsigned Depth) const override;
156
158 const APInt &DemandedElts,
159 KnownBits &Known,
160 TargetLoweringOpt &TLO,
161 unsigned Depth) const override;
162
164 const APInt &DemandedElts,
165 const SelectionDAG &DAG,
166 bool PoisonOnly, bool ConsiderFlags,
167 unsigned Depth) const override;
168
169 const Constant *getTargetConstantFromLoad(LoadSDNode *LD) const override;
170
172 getTargetMMOFlags(const Instruction &I) const override;
173
175 getTargetMMOFlags(const MemSDNode &Node) const override;
176
177 bool
179 const MemSDNode &NodeY) const override;
180
181 ConstraintType getConstraintType(StringRef Constraint) const override;
182
184 getInlineAsmMemConstraint(StringRef ConstraintCode) const override;
185
186 std::pair<unsigned, const TargetRegisterClass *>
188 StringRef Constraint, MVT VT) const override;
189
191 std::vector<SDValue> &Ops,
192 SelectionDAG &DAG) const override;
193
196 MachineBasicBlock *BB) const override;
197
199 SDNode *Node) const override;
200
202 EVT VT) const override;
203
204 bool shouldFormOverflowOp(unsigned Opcode, EVT VT,
205 bool MathUsed) const override {
206 if (VT == MVT::i8 || VT == MVT::i16)
207 return false;
208
209 return TargetLowering::shouldFormOverflowOp(Opcode, VT, MathUsed);
210 }
211
212 bool storeOfVectorConstantIsCheap(bool IsZero, EVT MemVT, unsigned NumElem,
213 unsigned AddrSpace) const override {
214 // If we can replace 4 or more scalar stores, there will be a reduction
215 // in instructions even after we add a vector constant load.
216 return NumElem >= 4;
217 }
218
219 bool convertSetCCLogicToBitwiseLogic(EVT VT) const override {
220 return VT.isScalarInteger();
221 }
222 bool convertSelectOfConstantsToMath(EVT VT) const override { return true; }
223
224 bool isCtpopFast(EVT VT) const override;
225
226 unsigned getCustomCtpopCost(EVT VT, ISD::CondCode Cond) const override;
227
228 bool preferZeroCompareBranch() const override { return true; }
229
230 // Note that one specific case requires fence insertion for an
231 // AtomicCmpXchgInst but is handled via the RISCVZacasABIFix pass rather
232 // than this hook due to limitations in the interface here.
233 bool shouldInsertFencesForAtomic(const Instruction *I) const override;
234
236 AtomicOrdering Ord) const override;
238 AtomicOrdering Ord) const override;
239
241 EVT VT) const override;
242
244 return ISD::SIGN_EXTEND;
245 }
246
248
250 unsigned KeptBits) const override;
251
254 unsigned ExpansionFactor) const override {
258 ExpansionFactor);
259 }
260
262 CombineLevel Level) const override;
263
264 /// If a physical register, this returns the register that receives the
265 /// exception address on entry to an EH pad.
267 getExceptionPointerRegister(const Constant *PersonalityFn) const override;
268
269 /// If a physical register, this returns the register that receives the
270 /// exception typeid on entry to a landing pad.
272 getExceptionSelectorRegister(const Constant *PersonalityFn) const override;
273
274 bool shouldExtendTypeInLibCall(EVT Type) const override;
275 bool shouldSignExtendTypeInLibCall(Type *Ty, bool IsSigned) const override;
276
277 /// Returns the register with the specified architectural or ABI name. This
278 /// method is necessary to lower the llvm.read_register.* and
279 /// llvm.write_register.* intrinsics. Allocatable registers must be reserved
280 /// with the clang -ffixed-xX flag for access to be allowed.
281 Register getRegisterByName(const char *RegName, LLT VT,
282 const MachineFunction &MF) const override;
283
284 // Lower incoming arguments, copy physregs into vregs
286 bool IsVarArg,
288 const SDLoc &DL, SelectionDAG &DAG,
289 SmallVectorImpl<SDValue> &InVals) const override;
291 bool IsVarArg,
293 LLVMContext &Context, const Type *RetTy) const override;
294 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,
296 const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL,
297 SelectionDAG &DAG) const override;
299 SmallVectorImpl<SDValue> &InVals) const override;
300
302 Type *Ty) const override;
303 bool isUsedByReturnOnly(SDNode *N, SDValue &Chain) const override;
304 bool mayBeEmittedAsTailCall(const CallInst *CI) const override;
305 bool shouldConsiderGEPOffsetSplit() const override { return true; }
306
307 bool decomposeMulByConstant(LLVMContext &Context, EVT VT,
308 SDValue C) const override;
309
311 SDValue ConstNode) const override;
312
314 shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const override;
316 Value *AlignedAddr, Value *Incr,
317 Value *Mask, Value *ShiftAmt,
318 AtomicOrdering Ord) const override;
323 Value *AlignedAddr, Value *CmpVal,
324 Value *NewVal, Value *Mask,
325 AtomicOrdering Ord) const override;
326
327 /// Returns true if the target allows unaligned memory accesses of the
328 /// specified type.
330 EVT VT, unsigned AddrSpace = 0, Align Alignment = Align(1),
332 unsigned *Fast = nullptr) const override;
333
334 EVT getOptimalMemOpType(LLVMContext &Context, const MemOp &Op,
335 const AttributeList &FuncAttributes) const override;
336
338 SelectionDAG & DAG, const SDLoc &DL, SDValue Val, SDValue *Parts,
339 unsigned NumParts, MVT PartVT, std::optional<CallingConv::ID> CC)
340 const override;
341
343 SelectionDAG & DAG, const SDLoc &DL, const SDValue *Parts,
344 unsigned NumParts, MVT PartVT, EVT ValueVT,
345 std::optional<CallingConv::ID> CC) const override;
346
347 // Return the value of VLMax for the given vector type (i.e. SEW and LMUL)
348 SDValue computeVLMax(MVT VecVT, const SDLoc &DL, SelectionDAG &DAG) const;
349
350 static RISCVVType::VLMUL getLMUL(MVT VT);
351 inline static unsigned computeVLMAX(unsigned VectorBits, unsigned EltSize,
352 unsigned MinSize) {
353 // Original equation:
354 // VLMAX = (VectorBits / EltSize) * LMUL
355 // where LMUL = MinSize / RISCV::RVVBitsPerBlock
356 // The following equations have been reordered to prevent loss of precision
357 // when calculating fractional LMUL.
358 return ((VectorBits / EltSize) * MinSize) / RISCV::RVVBitsPerBlock;
359 }
360
361 // Return inclusive (low, high) bounds on the value of VLMAX for the
362 // given scalable container type given known bounds on VLEN.
363 static std::pair<unsigned, unsigned>
364 computeVLMAXBounds(MVT ContainerVT, const RISCVSubtarget &Subtarget);
365
366 /// Given a vector (either fixed or scalable), return the scalable vector
367 /// corresponding to a vector register (i.e. an m1 register group).
368 static MVT getM1VT(MVT VT) {
369 unsigned EltSizeInBits = VT.getVectorElementType().getSizeInBits();
370 assert(EltSizeInBits <= RISCV::RVVBitsPerBlock && "Unexpected vector MVT");
372 RISCV::RVVBitsPerBlock / EltSizeInBits);
373 }
374
375 static unsigned getRegClassIDForLMUL(RISCVVType::VLMUL LMul);
376 static unsigned getSubregIndexByMVT(MVT VT, unsigned Index);
377 static unsigned getRegClassIDForVecVT(MVT VT);
378 static std::pair<unsigned, unsigned>
380 unsigned InsertExtractIdx,
381 const RISCVRegisterInfo *TRI);
383
384 bool shouldRemoveExtendFromGSIndex(SDValue Extend, EVT DataVT) const override;
385
386 bool isLegalElementTypeForRVV(EVT ScalarTy) const;
387
388 bool shouldConvertFpToSat(unsigned Op, EVT FPVT, EVT VT) const override;
389
390 unsigned getJumpTableEncoding() const override;
391
393 const MachineBasicBlock *MBB,
394 unsigned uid,
395 MCContext &Ctx) const override;
396
397 bool isVScaleKnownToBeAPowerOfTwo() const override;
398
400 ISD::MemIndexedMode &AM, SelectionDAG &DAG) const;
403 SelectionDAG &DAG) const override;
406 SelectionDAG &DAG) const override;
407
409 uint64_t ElemSize) const override {
410 // Scaled addressing not supported on indexed load/stores
411 return Scale == 1;
412 }
413
414 /// If the target has a standard location for the stack protector cookie,
415 /// returns the address of that location. Otherwise, returns nullptr.
416 Value *getIRStackGuard(IRBuilderBase &IRB) const override;
417
418 /// Returns whether or not generating a interleaved load/store intrinsic for
419 /// this type will be legal.
420 bool isLegalInterleavedAccessType(VectorType *VTy, unsigned Factor,
421 Align Alignment, unsigned AddrSpace,
422 const DataLayout &) const;
423
424 /// Return true if a stride load store of the given result type and
425 /// alignment is legal.
426 bool isLegalStridedLoadStore(EVT DataType, Align Alignment) const;
427
428 unsigned getMaxSupportedInterleaveFactor() const override { return 8; }
429
430 bool fallBackToDAGISel(const Instruction &Inst) const override;
431
432 bool lowerInterleavedLoad(Instruction *Load, Value *Mask,
434 ArrayRef<unsigned> Indices, unsigned Factor,
435 const APInt &GapMask) const override;
436
437 bool lowerInterleavedStore(Instruction *Store, Value *Mask,
438 ShuffleVectorInst *SVI, unsigned Factor,
439 const APInt &GapMask) const override;
440
442 IntrinsicInst *DI) const override;
443
445 Instruction *Store, Value *Mask,
446 ArrayRef<Value *> InterleaveValues) const override;
447
448 bool supportKCFIBundles() const override { return true; }
449
451 int JTI, SelectionDAG &DAG) const override;
452
455 const TargetInstrInfo *TII) const override;
456
457 /// True if stack clash protection is enabled for this functions.
458 bool hasInlineStackProbe(const MachineFunction &MF) const override;
459
460 unsigned getStackProbeSize(const MachineFunction &MF, Align StackAlign) const;
461
463 MachineBasicBlock *MBB) const;
464
466
467 /// Match a mask which "spreads" the leading elements of a vector evenly
468 /// across the result. Factor is the spread amount, and Index is the
469 /// offset applied.
470 static bool isSpreadMask(ArrayRef<int> Mask, unsigned Factor,
471 unsigned &Index);
472
473private:
474 void analyzeInputArgs(MachineFunction &MF, CCState &CCInfo,
475 const SmallVectorImpl<ISD::InputArg> &Ins, bool IsRet,
476 RISCVCCAssignFn Fn) const;
477 void analyzeOutputArgs(MachineFunction &MF, CCState &CCInfo,
479 bool IsRet, CallLoweringInfo *CLI,
480 RISCVCCAssignFn Fn) const;
481
482 template <class NodeTy>
483 SDValue getAddr(NodeTy *N, SelectionDAG &DAG, bool IsLocal = true,
484 bool IsExternWeak = false) const;
485 SDValue getStaticTLSAddr(GlobalAddressSDNode *N, SelectionDAG &DAG,
486 bool UseGOT) const;
487 SDValue getDynamicTLSAddr(GlobalAddressSDNode *N, SelectionDAG &DAG) const;
488 SDValue getTLSDescAddr(GlobalAddressSDNode *N, SelectionDAG &DAG) const;
489
490 SDValue lowerConstantFP(SDValue Op, SelectionDAG &DAG) const;
491 SDValue lowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
492 SDValue lowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
493 SDValue lowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
494 SDValue lowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
495 SDValue lowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
496 SDValue lowerSELECT(SDValue Op, SelectionDAG &DAG) const;
497 SDValue lowerBRCOND(SDValue Op, SelectionDAG &DAG) const;
498 SDValue lowerVASTART(SDValue Op, SelectionDAG &DAG) const;
499 SDValue lowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
500 SDValue lowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
501 SDValue lowerShiftLeftParts(SDValue Op, SelectionDAG &DAG) const;
502 SDValue lowerShiftRightParts(SDValue Op, SelectionDAG &DAG, bool IsSRA) const;
503 SDValue lowerSPLAT_VECTOR_PARTS(SDValue Op, SelectionDAG &DAG) const;
504 SDValue lowerVectorMaskSplat(SDValue Op, SelectionDAG &DAG) const;
505 SDValue lowerVectorMaskExt(SDValue Op, SelectionDAG &DAG,
506 int64_t ExtTrueVal) const;
507 SDValue lowerVectorMaskTruncLike(SDValue Op, SelectionDAG &DAG) const;
508 SDValue lowerVectorTruncLike(SDValue Op, SelectionDAG &DAG) const;
509 SDValue lowerVectorFPExtendOrRoundLike(SDValue Op, SelectionDAG &DAG) const;
510 SDValue lowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
511 SDValue lowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
512 SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
513 SDValue LowerINTRINSIC_W_CHAIN(SDValue Op, SelectionDAG &DAG) const;
514 SDValue LowerINTRINSIC_VOID(SDValue Op, SelectionDAG &DAG) const;
515 SDValue lowerVPREDUCE(SDValue Op, SelectionDAG &DAG) const;
516 SDValue lowerVECREDUCE(SDValue Op, SelectionDAG &DAG) const;
517 SDValue lowerVectorMaskVecReduction(SDValue Op, SelectionDAG &DAG,
518 bool IsVP) const;
519 SDValue lowerFPVECREDUCE(SDValue Op, SelectionDAG &DAG) const;
520 SDValue lowerINSERT_SUBVECTOR(SDValue Op, SelectionDAG &DAG) const;
521 SDValue lowerEXTRACT_SUBVECTOR(SDValue Op, SelectionDAG &DAG) const;
522 SDValue lowerVECTOR_DEINTERLEAVE(SDValue Op, SelectionDAG &DAG) const;
523 SDValue lowerVECTOR_INTERLEAVE(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 lowerVECTOR_SPLICE(SDValue Op, SelectionDAG &DAG) const;
527 SDValue lowerABS(SDValue Op, SelectionDAG &DAG) const;
528 SDValue lowerMaskedLoad(SDValue Op, SelectionDAG &DAG) const;
529 SDValue lowerLoadFF(SDValue Op, SelectionDAG &DAG) const;
530 SDValue lowerMaskedStore(SDValue Op, SelectionDAG &DAG) const;
531 SDValue lowerVectorCompress(SDValue Op, SelectionDAG &DAG) const;
532 SDValue lowerFixedLengthVectorFCOPYSIGNToRVV(SDValue Op,
533 SelectionDAG &DAG) const;
534 SDValue lowerMaskedGather(SDValue Op, SelectionDAG &DAG) const;
535 SDValue lowerMaskedScatter(SDValue Op, SelectionDAG &DAG) const;
536 SDValue lowerFixedLengthVectorLoadToRVV(SDValue Op, SelectionDAG &DAG) const;
537 SDValue lowerFixedLengthVectorStoreToRVV(SDValue Op, SelectionDAG &DAG) const;
538 SDValue lowerToScalableOp(SDValue Op, SelectionDAG &DAG) const;
539 SDValue LowerIS_FPCLASS(SDValue Op, SelectionDAG &DAG) const;
540 SDValue lowerVPOp(SDValue Op, SelectionDAG &DAG) const;
541 SDValue lowerLogicVPOp(SDValue Op, SelectionDAG &DAG) const;
542 SDValue lowerVPExtMaskOp(SDValue Op, SelectionDAG &DAG) const;
543 SDValue lowerVPSetCCMaskOp(SDValue Op, SelectionDAG &DAG) const;
544 SDValue lowerVPMergeMask(SDValue Op, SelectionDAG &DAG) const;
545 SDValue lowerVPSplatExperimental(SDValue Op, SelectionDAG &DAG) const;
546 SDValue lowerVPSpliceExperimental(SDValue Op, SelectionDAG &DAG) const;
547 SDValue lowerVPReverseExperimental(SDValue Op, SelectionDAG &DAG) const;
548 SDValue lowerVPFPIntConvOp(SDValue Op, SelectionDAG &DAG) const;
549 SDValue lowerVPStridedLoad(SDValue Op, SelectionDAG &DAG) const;
550 SDValue lowerVPStridedStore(SDValue Op, SelectionDAG &DAG) const;
551 SDValue lowerVPCttzElements(SDValue Op, SelectionDAG &DAG) const;
552 SDValue lowerGET_ROUNDING(SDValue Op, SelectionDAG &DAG) const;
553 SDValue lowerSET_ROUNDING(SDValue Op, SelectionDAG &DAG) const;
554 SDValue lowerGET_FPENV(SDValue Op, SelectionDAG &DAG) const;
555 SDValue lowerSET_FPENV(SDValue Op, SelectionDAG &DAG) const;
556 SDValue lowerRESET_FPENV(SDValue Op, SelectionDAG &DAG) const;
557 SDValue lowerGET_FPMODE(SDValue Op, SelectionDAG &DAG) const;
558 SDValue lowerSET_FPMODE(SDValue Op, SelectionDAG &DAG) const;
559 SDValue lowerRESET_FPMODE(SDValue Op, SelectionDAG &DAG) const;
560
561 SDValue lowerEH_DWARF_CFA(SDValue Op, SelectionDAG &DAG) const;
562 SDValue lowerCTLZ_CTTZ_ZERO_UNDEF(SDValue Op, SelectionDAG &DAG) const;
563
564 SDValue lowerStrictFPExtendOrRoundLike(SDValue Op, SelectionDAG &DAG) const;
565
566 SDValue lowerVectorStrictFSetcc(SDValue Op, SelectionDAG &DAG) const;
567
568 SDValue lowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const;
569
570 SDValue expandUnalignedRVVLoad(SDValue Op, SelectionDAG &DAG) const;
571 SDValue expandUnalignedRVVStore(SDValue Op, SelectionDAG &DAG) const;
572
573 SDValue lowerINIT_TRAMPOLINE(SDValue Op, SelectionDAG &DAG) const;
574 SDValue lowerADJUST_TRAMPOLINE(SDValue Op, SelectionDAG &DAG) const;
575 SDValue lowerPARTIAL_REDUCE_MLA(SDValue Op, SelectionDAG &DAG) const;
576
577 SDValue lowerXAndesBfHCvtBFloat16Load(SDValue Op, SelectionDAG &DAG) const;
578 SDValue lowerXAndesBfHCvtBFloat16Store(SDValue Op, SelectionDAG &DAG) const;
579
580 bool isEligibleForTailCallOptimization(
581 CCState &CCInfo, CallLoweringInfo &CLI, MachineFunction &MF,
582 const SmallVector<CCValAssign, 16> &ArgLocs) const;
583
584 /// Generate error diagnostics if any register used by CC has been marked
585 /// reserved.
586 void validateCCReservedRegs(
587 const SmallVectorImpl<std::pair<llvm::Register, llvm::SDValue>> &Regs,
588 MachineFunction &MF) const;
589
590 bool useRVVForFixedLengthVectorVT(MVT VT) const;
591
592 MVT getVPExplicitVectorLengthTy() const override;
593
594 bool shouldExpandGetVectorLength(EVT TripCountVT, unsigned VF,
595 bool IsScalable) const override;
596
597 /// RVV code generation for fixed length vectors does not lower all
598 /// BUILD_VECTORs. This makes BUILD_VECTOR legalisation a source of stores to
599 /// merge. However, merging them creates a BUILD_VECTOR that is just as
600 /// illegal as the original, thus leading to an infinite legalisation loop.
601 /// NOTE: Once BUILD_VECTOR can be custom lowered for all legal vector types,
602 /// this override can be removed.
603 bool mergeStoresAfterLegalization(EVT VT) const override;
604
605 /// Disable normalizing
606 /// select(N0&N1, X, Y) => select(N0, select(N1, X, Y), Y) and
607 /// select(N0|N1, X, Y) => select(N0, select(N1, X, Y, Y))
608 /// RISC-V doesn't have flags so it's better to perform the and/or in a GPR.
609 bool shouldNormalizeToSelectSequence(LLVMContext &, EVT) const override {
610 return false;
611 }
612
613 /// Disables storing and loading vectors by default when there are function
614 /// calls between the load and store, since these are more expensive than just
615 /// using scalars
616 bool shouldMergeStoreOfLoadsOverCall(EVT SrcVT, EVT MergedVT) const override {
617 return !MergedVT.isVector() || SrcVT.isVector();
618 }
619
620 /// For available scheduling models FDIV + two independent FMULs are much
621 /// faster than two FDIVs.
622 unsigned combineRepeatedFPDivisors() const override;
623
624 SDValue BuildSDIVPow2(SDNode *N, const APInt &Divisor, SelectionDAG &DAG,
625 SmallVectorImpl<SDNode *> &Created) const override;
626
627 bool shouldFoldSelectWithSingleBitTest(EVT VT,
628 const APInt &AndMask) const override;
629
630 unsigned getMinimumJumpTableEntries() const override;
631
632 SDValue emitFlushICache(SelectionDAG &DAG, SDValue InChain, SDValue Start,
633 SDValue End, SDValue Flags, SDLoc DL) const;
634
635 std::pair<const TargetRegisterClass *, uint8_t>
636 findRepresentativeClass(const TargetRegisterInfo *TRI, MVT VT) const override;
637};
638
639namespace RISCVVIntrinsicsTable {
640
642 unsigned IntrinsicID;
645 bool hasScalarOperand() const {
646 // 0xF is not valid. See NoScalarOperand in IntrinsicsRISCV.td.
647 return ScalarOperand != 0xF;
648 }
649 bool hasVLOperand() const {
650 // 0x1F is not valid. See NoVLOperand in IntrinsicsRISCV.td.
651 return VLOperand != 0x1F;
652 }
653};
654
655using namespace RISCV;
656
657#define GET_RISCVVIntrinsicsTable_DECL
658#include "RISCVGenSearchableTables.inc"
659#undef GET_RISCVVIntrinsicsTable_DECL
660
661} // end namespace RISCVVIntrinsicsTable
662
663} // end namespace llvm
664
665#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
Function Alias Analysis Results
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
return RetTy
uint64_t Addr
uint32_t Index
bool End
Definition: ELF_riscv.cpp:480
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
const HexagonInstrInfo * TII
IRTranslator LLVM IR MI
#define RegName(no)
#define I(x, y, z)
Definition: MD5.cpp:58
Register const TargetRegisterInfo * TRI
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
const SmallVectorImpl< MachineOperand > & Cond
This file describes how to lower LLVM code to machine code.
Class for arbitrary precision integers.
Definition: APInt.h:78
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
An instruction that atomically checks whether a specified value is in a memory location,...
Definition: Instructions.h:506
an instruction that atomically reads a memory location, combines it with another value,...
Definition: Instructions.h:709
CCState - This class holds information needed while lowering arguments and return values.
This class represents a function call, abstracting a target machine's calling convention.
This is the shared class of boolean and integer constants.
Definition: Constants.h:87
This is an important base class in LLVM.
Definition: Constant.h:43
This class represents an Operation in the Expression.
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:63
bool hasMinSize() const
Optimize this function for minimum size (-Oz).
Definition: Function.h:703
Common base class shared among various IRBuilders.
Definition: IRBuilder.h:114
A wrapper class for inspecting calls to intrinsic functions.
Definition: IntrinsicInst.h:49
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:68
This class is used to represent ISD::LOAD nodes.
Context object for machine code objects.
Definition: MCContext.h:83
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:34
Machine Value Type.
static MVT getScalableVectorVT(MVT VT, unsigned NumElements)
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
MVT getVectorElementType() const
Instructions::iterator instr_iterator
Function & getFunction()
Return the LLVM function that this machine code represents.
Representation of each machine instruction.
Definition: MachineInstr.h:72
Flags
Flags values. These may be or'd together.
This is an abstract virtual class for memory operations.
static std::pair< unsigned, unsigned > computeVLMAXBounds(MVT ContainerVT, const RISCVSubtarget &Subtarget)
static std::pair< unsigned, unsigned > decomposeSubvectorInsertExtractToSubRegs(MVT VecVT, MVT SubVecVT, unsigned InsertExtractIdx, const RISCVRegisterInfo *TRI)
ArrayRef< MCPhysReg > getRoundingControlRegisters() const override
Returns a 0 terminated array of rounding control registers that can be attached into strict FP call.
static MVT getM1VT(MVT VT)
Given a vector (either fixed or scalable), return the scalable vector corresponding to a vector regis...
InstructionCost getVRGatherVVCost(MVT VT) const
Return the cost of a vrgather.vv instruction for the type VT.
bool getIndexedAddressParts(SDNode *Op, SDValue &Base, SDValue &Offset, ISD::MemIndexedMode &AM, SelectionDAG &DAG) const
static unsigned getSubregIndexByMVT(MVT VT, unsigned Index)
Value * getIRStackGuard(IRBuilderBase &IRB) const override
If the target has a standard location for the stack protector cookie, returns the address of that loc...
bool shouldConvertFpToSat(unsigned Op, EVT FPVT, EVT VT) const override
Should we generate fp_to_si_sat and fp_to_ui_sat from type FPVT to type VT from min(max(fptoi)) satur...
bool storeOfVectorConstantIsCheap(bool IsZero, EVT MemVT, unsigned NumElem, unsigned AddrSpace) const override
Return true if it is expected to be cheaper to do a store of vector constant with the given size and ...
InlineAsm::ConstraintCode getInlineAsmMemConstraint(StringRef ConstraintCode) const override
SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, const SmallVectorImpl< ISD::OutputArg > &Outs, const SmallVectorImpl< SDValue > &OutVals, const SDLoc &DL, SelectionDAG &DAG) const override
This hook must be implemented to lower outgoing return values, described by the Outs array,...
unsigned getMaxSupportedInterleaveFactor() const override
Get the maximum supported factor for interleaved memory accesses.
bool mayBeEmittedAsTailCall(const CallInst *CI) const override
Return true if the target may be able emit the call instruction as a tail call.
MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr &MI, MachineBasicBlock *BB) const override
This method should be implemented by targets that mark instructions with the 'usesCustomInserter' fla...
Instruction * emitLeadingFence(IRBuilderBase &Builder, Instruction *Inst, AtomicOrdering Ord) const override
Inserts in the IR a target-specific intrinsic specifying a fence.
ISD::NodeType getExtendForAtomicOps() const override
Returns how the platform's atomic operations are extended (ZERO_EXTEND, SIGN_EXTEND,...
bool isTruncateFree(Type *SrcTy, Type *DstTy) const override
Return true if it's free to truncate a value of type FromTy to type ToTy.
bool preferZeroCompareBranch() const override
Return true if the heuristic to prefer icmp eq zero should be used in code gen prepare.
bool shouldRemoveExtendFromGSIndex(SDValue Extend, EVT DataVT) const override
Value * emitMaskedAtomicRMWIntrinsic(IRBuilderBase &Builder, AtomicRMWInst *AI, Value *AlignedAddr, Value *Incr, Value *Mask, Value *ShiftAmt, AtomicOrdering Ord) const override
Perform a masked atomicrmw using a target-specific intrinsic.
bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AddrSpace=0, Align Alignment=Align(1), MachineMemOperand::Flags Flags=MachineMemOperand::MONone, unsigned *Fast=nullptr) const override
Returns true if the target allows unaligned memory accesses of the specified type.
const Constant * getTargetConstantFromLoad(LoadSDNode *LD) const override
This method returns the constant pool value that will be loaded by LD.
const RISCVSubtarget & getSubtarget() const
bool lowerDeinterleaveIntrinsicToLoad(Instruction *Load, Value *Mask, IntrinsicInst *DI) const override
Lower a deinterleave intrinsic to a target specific load intrinsic.
TargetLowering::ShiftLegalizationStrategy preferredShiftLegalizationStrategy(SelectionDAG &DAG, SDNode *N, unsigned ExpansionFactor) const override
SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override
This method will be invoked for all target nodes and for any target-independent nodes that the target...
bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override
Return true if folding a constant offset with the given GlobalAddress is legal.
void computeKnownBitsForTargetNode(const SDValue Op, KnownBits &Known, const APInt &DemandedElts, const SelectionDAG &DAG, unsigned Depth) const override
Determine which of the bits specified in Mask are known to be either zero or one and return them in t...
bool preferScalarizeSplat(SDNode *N) const override
bool shouldExtendTypeInLibCall(EVT Type) const override
Returns true if arguments should be extended in lib calls.
bool isLegalAddImmediate(int64_t Imm) const override
Return true if the specified immediate is legal add immediate, that is the target has add instruction...
bool shouldSignExtendTypeInLibCall(Type *Ty, bool IsSigned) const override
Returns true if arguments should be sign-extended in lib calls.
const MCExpr * LowerCustomJumpTableEntry(const MachineJumpTableInfo *MJTI, const MachineBasicBlock *MBB, unsigned uid, MCContext &Ctx) const override
InstructionCost getVRGatherVICost(MVT VT) const
Return the cost of a vrgather.vi (or vx) instruction for the type VT.
bool shouldConvertConstantLoadToIntImm(const APInt &Imm, Type *Ty) const override
Return true if it is beneficial to convert a load of a constant to just the constant itself.
bool targetShrinkDemandedConstant(SDValue Op, const APInt &DemandedBits, const APInt &DemandedElts, TargetLoweringOpt &TLO) const override
bool shouldExpandBuildVectorWithShuffles(EVT VT, unsigned DefinedValues) const override
bool lowerInterleavedStore(Instruction *Store, Value *Mask, ShuffleVectorInst *SVI, unsigned Factor, const APInt &GapMask) const override
Lower an interleaved store into a vssegN intrinsic.
MVT getRegisterTypeForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const override
Return the register type for a given MVT, ensuring vectors are treated as a series of gpr sized integ...
bool decomposeMulByConstant(LLVMContext &Context, EVT VT, SDValue C) const override
Return true if it is profitable to transform an integer multiplication-by-constant into simpler opera...
bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF, bool IsVarArg, const SmallVectorImpl< ISD::OutputArg > &Outs, LLVMContext &Context, const Type *RetTy) const override
This hook should be implemented to check whether the return values described by the Outs array can fi...
bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty, unsigned AS, Instruction *I=nullptr) const override
Return true if the addressing mode represented by AM is legal for this target, for a load/store of th...
bool hasAndNotCompare(SDValue Y) const override
Return true if the target should transform: (X & Y) == Y —> (~X & Y) == 0 (X & Y) !...
bool shouldScalarizeBinop(SDValue VecOp) const override
Try to convert an extract element of a vector binary operation into an extract element followed by a ...
bool isDesirableToCommuteWithShift(const SDNode *N, CombineLevel Level) const override
Return true if it is profitable to move this shift by a constant amount through its operand,...
bool areTwoSDNodeTargetMMOFlagsMergeable(const MemSDNode &NodeX, const MemSDNode &NodeY) const override
Return true if it is valid to merge the TargetMMOFlags in two SDNodes.
bool hasBitTest(SDValue X, SDValue Y) const override
Return true if the target has a bit-test instruction: (X & (1 << Y)) ==/!= 0 This knowledge can be us...
static unsigned computeVLMAX(unsigned VectorBits, unsigned EltSize, unsigned MinSize)
bool shouldExpandCttzElements(EVT VT) const override
Return true if the @llvm.experimental.cttz.elts intrinsic should be expanded using generic code in Se...
bool isCheapToSpeculateCtlz(Type *Ty) const override
Return true if it is cheap to speculate a call to intrinsic ctlz.
Value * emitMaskedAtomicCmpXchgIntrinsic(IRBuilderBase &Builder, AtomicCmpXchgInst *CI, Value *AlignedAddr, Value *CmpVal, Value *NewVal, Value *Mask, AtomicOrdering Ord) const override
Perform a masked cmpxchg using a target-specific intrinsic.
bool isFPImmLegal(const APFloat &Imm, EVT VT, bool ForCodeSize) const override
Returns true if the target can instruction select the specified FP immediate natively.
bool convertSelectOfConstantsToMath(EVT VT) const override
Return true if a select of constants (select Cond, C1, C2) should be transformed into simple math ops...
InstructionCost getLMULCost(MVT VT) const
Return the cost of LMUL for linear operations.
bool supportKCFIBundles() const override
Return true if the target supports kcfi operand bundles.
unsigned getJumpTableEncoding() const override
Return the entry encoding for a jump table in the current function.
bool isMulAddWithConstProfitable(SDValue AddNode, SDValue ConstNode) const override
Return true if it may be profitable to transform (mul (add x, c1), c2) -> (add (mul x,...
InstructionCost getVSlideVICost(MVT VT) const
Return the cost of a vslidedown.vi or vslideup.vi instruction for the type VT.
bool fallBackToDAGISel(const Instruction &Inst) const override
EVT getOptimalMemOpType(LLVMContext &Context, const MemOp &Op, const AttributeList &FuncAttributes) const override
Returns the target specific optimal type for load and store operations as a result of memset,...
EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context, EVT VT) const override
Return the ValueType of the result of SETCC operations.
bool isCtpopFast(EVT VT) const override
Return true if ctpop instruction is fast.
unsigned ComputeNumSignBitsForTargetNode(SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG, unsigned Depth) const override
This method can be implemented by targets that want to expose additional information about sign bits ...
MVT getContainerForFixedLengthVector(MVT VT) const
static unsigned getRegClassIDForVecVT(MVT VT)
Register getExceptionPointerRegister(const Constant *PersonalityFn) const override
If a physical register, this returns the register that receives the exception address on entry to an ...
TargetLowering::AtomicExpansionKind shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const override
Returns how the IR-level AtomicExpand pass should expand the given AtomicRMW, if at all.
bool isExtractSubvectorCheap(EVT ResVT, EVT SrcVT, unsigned Index) const override
Return true if EXTRACT_SUBVECTOR is cheap for extracting this result type from this source type with ...
std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const override
Given a physical register constraint (e.g.
MachineBasicBlock * emitDynamicProbedAlloc(MachineInstr &MI, MachineBasicBlock *MBB) const
MachineMemOperand::Flags getTargetMMOFlags(const Instruction &I) const override
This callback is used to inspect load/store instructions and add target-specific MachineMemOperand fl...
SDValue computeVLMax(MVT VecVT, const SDLoc &DL, SelectionDAG &DAG) const
bool signExtendConstant(const ConstantInt *CI) const override
Return true if this constant should be sign extended when promoting to a larger type.
bool shouldTransformSignedTruncationCheck(EVT XVT, unsigned KeptBits) const override
Should we tranform the IR-optimal check for whether given truncation down into KeptBits would be trun...
bool shouldProduceAndByConstByHoistingConstFromShiftsLHSOfAnd(SDValue X, ConstantSDNode *XC, ConstantSDNode *CC, SDValue Y, unsigned OldShiftOpcode, unsigned NewShiftOpcode, SelectionDAG &DAG) const override
Given the pattern (X & (C l>>/<< Y)) ==/!= 0 return true if it should be transformed into: ((X <</l>>...
bool hasInlineStackProbe(const MachineFunction &MF) const override
True if stack clash protection is enabled for this functions.
bool hasAndNot(SDValue Y) const override
Return true if the target has a bitwise and-not operation: X = ~A & B This can be used to simplify se...
Register getRegisterByName(const char *RegName, LLT VT, const MachineFunction &MF) const override
Returns the register with the specified architectural or ABI name.
InstructionCost getVSlideVXCost(MVT VT) const
Return the cost of a vslidedown.vx or vslideup.vx instruction for the type VT.
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override
This callback is invoked for operations that are unsupported by the target, which are registered to u...
bool isUsedByReturnOnly(SDNode *N, SDValue &Chain) const override
Return true if result of the specified node is used by a return node only.
bool softPromoteHalfType() const override
bool isFMAFasterThanFMulAndFAdd(const MachineFunction &MF, EVT VT) const override
Return true if an FMA operation is faster than a pair of fmul and fadd instructions.
TargetLowering::AtomicExpansionKind shouldExpandAtomicCmpXchgInIR(AtomicCmpXchgInst *CI) const override
Returns how the given atomic cmpxchg should be expanded by the IR-level AtomicExpand pass.
Register getExceptionSelectorRegister(const Constant *PersonalityFn) const override
If a physical register, this returns the register that receives the exception typeid on entry to a la...
bool convertSetCCLogicToBitwiseLogic(EVT VT) const override
Use bitwise logic to make pairs of compares more efficient.
unsigned getCustomCtpopCost(EVT VT, ISD::CondCode Cond) const override
Return the maximum number of "x & (x - 1)" operations that can be done instead of deferring to a cust...
void AdjustInstrPostInstrSelection(MachineInstr &MI, SDNode *Node) const override
This method should be implemented by targets that mark instructions with the 'hasPostISelHook' flag.
bool isShuffleMaskLegal(ArrayRef< int > M, EVT VT) const override
Return true if the given shuffle mask can be codegen'd directly, or if it should be stack expanded.
bool isCheapToSpeculateCttz(Type *Ty) const override
Return true if it is cheap to speculate a call to intrinsic cttz.
bool isLegalICmpImmediate(int64_t Imm) const override
Return true if the specified immediate is legal icmp immediate, that is the target has icmp instructi...
ISD::NodeType getExtendForAtomicCmpSwapArg() const override
Returns how the platform's atomic compare and swap expects its comparison value to be extended (ZERO_...
bool lowerInterleavedLoad(Instruction *Load, Value *Mask, ArrayRef< ShuffleVectorInst * > Shuffles, ArrayRef< unsigned > Indices, unsigned Factor, const APInt &GapMask) const override
Lower an interleaved load into a vlsegN intrinsic.
bool lowerInterleaveIntrinsicToStore(Instruction *Store, Value *Mask, ArrayRef< Value * > InterleaveValues) const override
Lower an interleave intrinsic to a target specific store intrinsic.
bool isLegalScaleForGatherScatter(uint64_t Scale, uint64_t ElemSize) const override
SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, const SmallVectorImpl< ISD::InputArg > &Ins, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl< SDValue > &InVals) const override
This hook must be implemented to lower the incoming (formal) arguments, described by the Ins array,...
void ReplaceNodeResults(SDNode *N, SmallVectorImpl< SDValue > &Results, SelectionDAG &DAG) const override
This callback is invoked when a node result type is illegal for the target, and the operation was reg...
bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallInst &I, MachineFunction &MF, unsigned Intrinsic) const override
Given an intrinsic, checks if on the target the intrinsic will need to map to a MemIntrinsicNode (tou...
unsigned getVectorTypeBreakdownForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT, EVT &IntermediateVT, unsigned &NumIntermediates, MVT &RegisterVT) const override
Certain targets such as MIPS require that some types such as vectors are always broken down into scal...
bool isLegalElementTypeForRVV(EVT ScalarTy) const
bool isVScaleKnownToBeAPowerOfTwo() const override
Return true only if vscale must be a power of two.
int getLegalZfaFPImm(const APFloat &Imm, EVT VT) const
void LowerAsmOperandForConstraint(SDValue Op, StringRef Constraint, std::vector< SDValue > &Ops, SelectionDAG &DAG) const override
Lower the specified operand into the Ops vector.
bool splitValueIntoRegisterParts(SelectionDAG &DAG, const SDLoc &DL, SDValue Val, SDValue *Parts, unsigned NumParts, MVT PartVT, std::optional< CallingConv::ID > CC) const override
Target-specific splitting of values into parts that fit a register storing a legal type.
Instruction * emitTrailingFence(IRBuilderBase &Builder, Instruction *Inst, AtomicOrdering Ord) const override
unsigned getNumRegistersForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const override
Return the number of registers for a given MVT, ensuring vectors are treated as a series of gpr sized...
ConstraintType getConstraintType(StringRef Constraint) const override
getConstraintType - Given a constraint letter, return the type of constraint it is for this target.
bool shouldConsiderGEPOffsetSplit() const override
MachineInstr * EmitKCFICheck(MachineBasicBlock &MBB, MachineBasicBlock::instr_iterator &MBBI, const TargetInstrInfo *TII) const override
bool isLegalInterleavedAccessType(VectorType *VTy, unsigned Factor, Align Alignment, unsigned AddrSpace, const DataLayout &) const
Returns whether or not generating a interleaved load/store intrinsic for this type will be legal.
bool canCreateUndefOrPoisonForTargetNode(SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG, bool PoisonOnly, bool ConsiderFlags, unsigned Depth) const override
Return true if Op can create undef or poison from non-undef & non-poison operands.
bool isIntDivCheap(EVT VT, AttributeList Attr) const override
Return true if integer divide is usually cheaper than a sequence of several shifts,...
SDValue expandIndirectJTBranch(const SDLoc &dl, SDValue Value, SDValue Addr, int JTI, SelectionDAG &DAG) const override
Expands target specific indirect branch for the case of JumpTable expansion.
static unsigned getRegClassIDForLMUL(RISCVVType::VLMUL LMul)
unsigned getNumRegisters(LLVMContext &Context, EVT VT, std::optional< MVT > RegisterVT=std::nullopt) const override
Return the number of registers for a given MVT, for inline assembly.
bool isMultiStoresCheaperThanBitsMerge(EVT LTy, EVT HTy) const override
Return true if it is cheaper to split the store of a merged int val from a pair of smaller values int...
bool getPostIndexedAddressParts(SDNode *N, SDNode *Op, SDValue &Base, SDValue &Offset, ISD::MemIndexedMode &AM, SelectionDAG &DAG) const override
Returns true by value, base pointer and offset pointer and addressing mode by reference if this node ...
bool shouldFormOverflowOp(unsigned Opcode, EVT VT, bool MathUsed) const override
Try to convert math with an overflow comparison into the corresponding DAG node operation.
bool getPreIndexedAddressParts(SDNode *N, SDValue &Base, SDValue &Offset, ISD::MemIndexedMode &AM, SelectionDAG &DAG) const override
Returns true by value, base pointer and offset pointer and addressing mode by reference if the node's...
SDValue joinRegisterPartsIntoValue(SelectionDAG &DAG, const SDLoc &DL, const SDValue *Parts, unsigned NumParts, MVT PartVT, EVT ValueVT, std::optional< CallingConv::ID > CC) const override
Target-specific combining of register parts into its original value.
bool isMaskAndCmp0FoldingBeneficial(const Instruction &AndI) const override
Return if the target supports combining a chain like:
bool isSExtCheaperThanZExt(EVT SrcVT, EVT DstVT) const override
Return true if sign-extension from FromTy to ToTy is cheaper than zero-extension.
bool isLegalStridedLoadStore(EVT DataType, Align Alignment) const
Return true if a stride load store of the given result type and alignment is legal.
static bool isSpreadMask(ArrayRef< int > Mask, unsigned Factor, unsigned &Index)
Match a mask which "spreads" the leading elements of a vector evenly across the result.
static RISCVVType::VLMUL getLMUL(MVT VT)
SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI, SmallVectorImpl< SDValue > &InVals) const override
This hook must be implemented to lower calls into the specified DAG.
bool SimplifyDemandedBitsForTargetNode(SDValue Op, const APInt &DemandedBits, const APInt &DemandedElts, KnownBits &Known, TargetLoweringOpt &TLO, unsigned Depth) const override
Attempt to simplify any target nodes based on the demanded bits/elts, returning true on success.
bool isZExtFree(SDValue Val, EVT VT2) const override
Return true if zero-extending the specific node Val to type VT2 is free (either because it's implicit...
bool shouldFoldSelectWithIdentityConstant(unsigned BinOpcode, EVT VT, unsigned SelectOpcode, SDValue X, SDValue Y) const override
Return true if pulling a binary operation into a select with an identity constant is profitable.
unsigned getStackProbeSize(const MachineFunction &MF, Align StackAlign) const
bool shouldInsertFencesForAtomic(const Instruction *I) const override
Whether AtomicExpandPass should automatically insert fences and reduce ordering for this atomic.
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Definition: SelectionDAG.h:229
MachineFunction & getMachineFunction() const
Definition: SelectionDAG.h:493
This instruction constructs a fixed permutation of two input vectors.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:574
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1197
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
TargetInstrInfo - Interface to description of machine instruction set.
virtual bool shouldFormOverflowOp(unsigned Opcode, EVT VT, bool MathUsed) const
Try to convert math with an overflow comparison into the corresponding DAG node operation.
ShiftLegalizationStrategy
Return the preferred strategy to legalize tihs SHIFT instruction, with ExpansionFactor being the recu...
virtual ShiftLegalizationStrategy preferredShiftLegalizationStrategy(SelectionDAG &DAG, SDNode *N, unsigned ExpansionFactor) const
AtomicExpansionKind
Enum that specifies what an atomic load/AtomicRMWInst is expanded to, if at all.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:83
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
LLVM Value Representation.
Definition: Value.h:75
Base class of all SIMD vector types.
Definition: DerivedTypes.h:430
@ Fast
Attempts to make calls as fast as possible (e.g.
Definition: CallingConv.h:41
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
Definition: ISDOpcodes.h:41
@ SIGN_EXTEND
Conversion operators.
Definition: ISDOpcodes.h:826
MemIndexedMode
MemIndexedMode enum - This enum defines the load / store indexed addressing modes.
Definition: ISDOpcodes.h:1634
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
Definition: ISDOpcodes.h:1685
static constexpr unsigned RVVBitsPerBlock
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:477
bool RISCVCCAssignFn(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State, bool IsRet, Type *OrigTy)
RISCVCCAssignFn - This target-specific function extends the default CCValAssign with additional infor...
AtomicOrdering
Atomic ordering for LLVM's memory model.
CombineLevel
Definition: DAGCombine.h:15
#define N
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
Extended Value Type.
Definition: ValueTypes.h:35
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
Definition: ValueTypes.h:147
bool isScalarInteger() const
Return true if this is an integer, but not a vector.
Definition: ValueTypes.h:157
bool isInteger() const
Return true if this is an integer or a vector integer type.
Definition: ValueTypes.h:152
This structure contains all information that is necessary for lowering calls.