LLVM 24.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;
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
39 const CallBase &I, MachineFunction &MF,
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;
66 bool ForCodeSize) const override;
68 bool ForCodeSize) const override;
70 unsigned Index) const override;
71
72 bool isIntDivCheap(EVT VT, AttributeList Attr) const override;
73
74 bool preferScalarizeSplat(SDNode *N) const override;
75
76 void finalizeLowering(MachineFunction &MF) const override;
77
78 /// Customize the preferred legalization strategy for certain types.
79 LegalizeTypeAction getPreferredVectorAction(MVT VT) const override;
80
81 /// Return the register type for a given MVT, ensuring vectors are treated
82 /// as a series of gpr sized integers.
84 EVT VT) const override;
85
86 /// Return the number of registers for a given MVT, for inline assembly
87 unsigned
88 getNumRegisters(LLVMContext &Context, EVT VT,
89 std::optional<MVT> RegisterVT = std::nullopt) const override;
90
91 /// Return the number of registers for a given MVT, ensuring vectors are
92 /// treated as a series of gpr sized integers.
95 EVT VT) const override;
96
97 bool shouldFoldSelectWithIdentityConstant(unsigned BinOpcode, EVT VT,
98 unsigned SelectOpcode, SDValue X,
99 SDValue Y) const override;
100
101 /// Return true if the given shuffle mask can be codegen'd directly, or if it
102 /// should be stack expanded.
103 bool isShuffleMaskLegal(ArrayRef<int> M, EVT VT) const override;
104
105 bool isVectorClearMaskLegal(ArrayRef<int> M, EVT VT) const override;
106
107 bool isMultiStoresCheaperThanBitsMerge(EVT LTy, EVT HTy) const override {
108 // If the pair to store is a mixture of float and int values, we will
109 // save two bitwise instructions and one float-to-int instruction and
110 // increase one store instruction. There is potentially a more
111 // significant benefit because it avoids the float->int domain switch
112 // for input value. So It is more likely a win.
113 if ((LTy.isFloatingPoint() && HTy.isInteger()) ||
114 (LTy.isInteger() && HTy.isFloatingPoint()))
115 return true;
116 // If the pair only contains int values, we will save two bitwise
117 // instructions and increase one store instruction (costing one more
118 // store buffer). Since the benefit is more blurred we leave such a pair
119 // out until we get testcase to prove it is a win.
120 return false;
121 }
122
123 bool
125 unsigned DefinedValues) const override;
126
127 /// Return the cost of LMUL for linear operations.
129
134
135 // Provide custom lowering hooks for some operations.
136 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
138 SelectionDAG &DAG) const override;
139
140 SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
141
143 const APInt &DemandedElts,
144 TargetLoweringOpt &TLO) const override;
145
148 const APInt &DemandedElts,
149 const SelectionDAG &DAG,
150 unsigned Depth) const override;
151
154 const APInt &DemandedElts,
156 unsigned Depth = 0) const override;
158 const APInt &DemandedElts,
159 const SelectionDAG &DAG,
160 unsigned Depth) const override;
161
163 const APInt &DemandedElts,
165 TargetLoweringOpt &TLO,
166 unsigned Depth) const override;
167
169 SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG,
170 UndefPoisonKind Kind, bool ConsiderFlags, unsigned Depth) const override;
171
172 const Constant *getTargetConstantFromLoad(LoadSDNode *LD) const override;
173
175 getTargetMMOFlags(const Instruction &I) const override;
176
178 getTargetMMOFlags(const MemSDNode &Node) const override;
179
180 bool
182 const MemSDNode &NodeY) const override;
183
184 ConstraintType getConstraintType(StringRef Constraint) const override;
185
187 getInlineAsmMemConstraint(StringRef ConstraintCode) const override;
188
189 std::pair<unsigned, const TargetRegisterClass *>
191 StringRef Constraint, MVT VT) const override;
192
194 std::vector<SDValue> &Ops,
195 SelectionDAG &DAG) const override;
196
199 MachineBasicBlock *BB) const override;
200
202 SDNode *Node) const override;
203
205 EVT VT) const override;
206
207 CondMergingParams
209 const Value *RHS,
210 const Function *F) const override;
211
212 bool shouldFormOverflowOp(unsigned Opcode, EVT VT,
213 bool MathUsed) const override {
214 if (VT == MVT::i8 || VT == MVT::i16)
215 return false;
216
217 return TargetLowering::shouldFormOverflowOp(Opcode, VT, MathUsed);
218 }
219
220 bool storeOfVectorConstantIsCheap(bool IsZero, EVT MemVT, unsigned NumElem,
221 unsigned AddrSpace) const override {
222 // Replacing 4 or more element stores is a net reduction in instructions
223 // even after accounting for the vmv.v.i needed to materialize the zero
224 // vector. MemVT may already be a vector, since memset lowers to LMUL1
225 // stores that we rely on this merge to widen, so use the total element
226 // count.
227 unsigned NumMemElts = MemVT.isVector() ? MemVT.getVectorNumElements() : 1;
228 if (IsZero)
229 return NumElem * NumMemElts >= 4;
230
231 // Materializing a non-zero vector constant isn't free (it may need
232 // several instructions like li + vmv.v.x or a constant-pool load), so stay
233 // conservative and only merge when replacing 4 or more stores.
234 return NumElem >= 4;
235 }
236
237 bool convertSetCCLogicToBitwiseLogic(EVT VT) const override {
238 return VT.isScalarInteger();
239 }
240 bool convertSelectOfConstantsToMath(EVT VT) const override { return true; }
241
242 bool isCtpopFast(EVT VT) const override;
243
244 unsigned getCustomCtpopCost(EVT VT, ISD::CondCode Cond) const override;
245
246 bool preferZeroCompareBranch() const override { return true; }
247
248 bool hasMultipleConditionRegisters(EVT VT) const override;
249
250 // Note that one specific case requires fence insertion for an
251 // AtomicCmpXchgInst but is handled via the RISCVZacasABIFix pass rather
252 // than this hook due to limitations in the interface here.
253 bool shouldInsertFencesForAtomic(const Instruction *I) const override;
254
256 AtomicOrdering Ord) const override;
258 AtomicOrdering Ord) const override;
259
261 EVT VT) const override;
262
264 return ISD::SIGN_EXTEND;
265 }
266
268 ISD::NodeType getExtendForAtomicRMWArg(unsigned Op) const override;
269
271 unsigned KeptBits) const override;
272
275 unsigned ExpansionFactor) const override {
279 ExpansionFactor);
280 }
281
283 CombineLevel Level) const override;
284
285 /// If a physical register, this returns the register that receives the
286 /// exception address on entry to an EH pad.
289 const Constant *PersonalityFn) const override;
290
291 /// If a physical register, this returns the register that receives the
292 /// exception typeid on entry to a landing pad.
295 const Constant *PersonalityFn) const override;
296
297 bool shouldExtendTypeInLibCall(EVT Type) const override;
298 bool shouldSignExtendTypeInLibCall(Type *Ty, bool IsSigned) const override;
299
300 /// Returns the register with the specified architectural or ABI name. This
301 /// method is necessary to lower the llvm.read_register.* and
302 /// llvm.write_register.* intrinsics. Allocatable registers must be reserved
303 /// with the clang -ffixed-xX flag for access to be allowed.
304 Register getRegisterByName(const char *RegName, LLT VT,
305 const MachineFunction &MF) const override;
306
307 // Lower incoming arguments, copy physregs into vregs
309 bool IsVarArg,
311 const SDLoc &DL, SelectionDAG &DAG,
312 SmallVectorImpl<SDValue> &InVals) const override;
314 bool IsVarArg,
316 LLVMContext &Context, const Type *RetTy) const override;
317 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,
319 const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL,
320 SelectionDAG &DAG) const override;
322 SmallVectorImpl<SDValue> &InVals) const override;
323
325 Type *Ty) const override;
326 bool isUsedByReturnOnly(SDNode *N, SDValue &Chain) const override;
327 bool mayBeEmittedAsTailCall(const CallInst *CI) const override;
328 bool shouldConsiderGEPOffsetSplit() const override { return true; }
329
330 bool decomposeMulByConstant(LLVMContext &Context, EVT VT,
331 SDValue C) const override;
332
334 SDValue ConstNode) const override;
335
337 shouldExpandAtomicRMWInIR(const AtomicRMWInst *AI) const override;
339 Value *AlignedAddr, Value *Incr,
340 Value *Mask, Value *ShiftAmt,
341 AtomicOrdering Ord) const override;
343 shouldExpandAtomicCmpXchgInIR(const AtomicCmpXchgInst *CI) const override;
346 Value *AlignedAddr, Value *CmpVal,
347 Value *NewVal, Value *Mask,
348 AtomicOrdering Ord) const override;
349
350 /// Returns true if the target allows unaligned memory accesses of the
351 /// specified type.
353 EVT VT, unsigned AddrSpace = 0, Align Alignment = Align(1),
355 unsigned *Fast = nullptr) const override;
356
358 LLT Ty, unsigned AddrSpace = 0, Align Alignment = Align(1),
360 unsigned *Fast = nullptr) const override;
361
362 EVT getOptimalMemOpType(LLVMContext &Context, const MemOp &Op,
363 const AttributeList &FuncAttributes) const override;
364
366 SelectionDAG & DAG, const SDLoc &DL, SDValue Val, SDValue *Parts,
367 unsigned NumParts, MVT PartVT, std::optional<CallingConv::ID> CC)
368 const override;
369
371 SelectionDAG & DAG, const SDLoc &DL, const SDValue *Parts,
372 unsigned NumParts, MVT PartVT, EVT ValueVT,
373 std::optional<CallingConv::ID> CC) const override;
374
375 // Return the value of VLMax for the given vector type (i.e. SEW and LMUL)
376 SDValue computeVLMax(MVT VecVT, const SDLoc &DL, SelectionDAG &DAG) const;
377
378 static RISCVVType::VLMUL getLMUL(MVT VT);
379 inline static unsigned computeVLMAX(unsigned VectorBits, unsigned EltSize,
380 unsigned MinSize) {
381 // Original equation:
382 // VLMAX = (VectorBits / EltSize) * LMUL
383 // where LMUL = MinSize / RISCV::RVVBitsPerBlock
384 // The following equations have been reordered to prevent loss of precision
385 // when calculating fractional LMUL.
386 return ((VectorBits / EltSize) * MinSize) / RISCV::RVVBitsPerBlock;
387 }
388
389 // Return inclusive (low, high) bounds on the value of VLMAX for the
390 // given scalable container type given known bounds on VLEN.
391 static std::pair<unsigned, unsigned>
392 computeVLMAXBounds(MVT ContainerVT, const RISCVSubtarget &Subtarget);
393
394 /// Given a vector (either fixed or scalable), return the scalable vector
395 /// corresponding to a vector register (i.e. an m1 register group).
396 static MVT getM1VT(MVT VT) {
397 unsigned EltSizeInBits = VT.getVectorElementType().getSizeInBits();
398 assert(EltSizeInBits <= RISCV::RVVBitsPerBlock && "Unexpected vector MVT");
400 RISCV::RVVBitsPerBlock / EltSizeInBits);
401 }
402
403 static unsigned getRegClassIDForLMUL(RISCVVType::VLMUL LMul);
404 static unsigned getSubregIndexByMVT(MVT VT, unsigned Index);
405 static unsigned getRegClassIDForVecVT(MVT VT);
406 static std::pair<unsigned, unsigned>
408 unsigned InsertExtractIdx,
409 const RISCVRegisterInfo *TRI);
411
412 bool shouldRemoveExtendFromGSIndex(SDValue Extend, EVT DataVT) const override;
413
414 bool isLegalElementTypeForRVV(EVT ScalarTy) const;
415
416 bool shouldConvertFpToSat(unsigned Op, EVT FPVT, EVT VT) const override;
417
418 unsigned getJumpTableEncoding() const override;
419
421 const MachineBasicBlock *MBB,
422 unsigned uid,
423 MCContext &Ctx) const override;
424
426 ISD::MemIndexedMode &AM, SelectionDAG &DAG) const;
429 SelectionDAG &DAG) const override;
432 SelectionDAG &DAG) const override;
433
435 uint64_t ElemSize) const override {
436 // Scaled addressing not supported on indexed load/stores
437 return Scale == 1;
438 }
439
440 /// If the target has a standard location for the stack protector cookie,
441 /// returns the address of that location. Otherwise, returns nullptr.
443 const LibcallLoweringInfo &Libcalls) const override;
444
445 /// Returns whether or not generating a interleaved load/store intrinsic for
446 /// this type will be legal.
447 bool isLegalInterleavedAccessType(VectorType *VTy, unsigned Factor,
448 Align Alignment, unsigned AddrSpace,
449 const DataLayout &) const;
450
451 /// Return true if a stride load store of the given result type and
452 /// alignment is legal.
453 bool isLegalStridedLoadStore(EVT DataType, Align Alignment) const;
454
455 /// Return true if a fault-only-first load of the given result type and
456 /// alignment is legal.
457 bool isLegalFirstFaultLoad(EVT DataType, Align Alignment) const;
458
459 unsigned getMaxSupportedInterleaveFactor() const override { return 8; }
460
461 bool fallBackToDAGISel(const Instruction &Inst) const override;
462
465 ArrayRef<unsigned> Indices, unsigned Factor,
466 const APInt &GapMask) const override;
467
469 ShuffleVectorInst *SVI, unsigned Factor,
470 const APInt &GapMask) const override;
471
473 IntrinsicInst *DI,
474 const APInt &GapMask) const override;
475
477 Instruction *Store, Value *Mask,
478 ArrayRef<Value *> InterleaveValues) const override;
479
480 bool supportKCFIBundles() const override { return true; }
481
483 int JTI, SelectionDAG &DAG) const override;
484
487 const TargetInstrInfo *TII) const override;
488
489 /// True if stack clash protection is enabled for this functions.
490 bool hasInlineStackProbe(const MachineFunction &MF) const override;
491
492 unsigned getStackProbeSize(const MachineFunction &MF, Align StackAlign) const;
493
495 MachineBasicBlock *MBB) const;
496
498
499 bool shouldFoldMaskToVariableShiftPair(SDValue Y) const override;
500
501 /// Control the following reassociation of operands: (op (op x, c1), y) -> (op
502 /// (op x, y), c1) where N0 is (op x, c1) and N1 is y.
504 SDValue N1) const override;
505
506 /// Match a mask which "spreads" the leading elements of a vector evenly
507 /// across the result. Factor is the spread amount, and Index is the
508 /// offset applied.
509 static bool isSpreadMask(ArrayRef<int> Mask, unsigned Factor,
510 unsigned &Index);
511
512private:
513 template <class NodeTy>
514 SDValue getAddr(NodeTy *N, SelectionDAG &DAG, bool IsLocal = true,
515 bool IsExternWeak = false) const;
516 SDValue getStaticTLSAddr(GlobalAddressSDNode *N, SelectionDAG &DAG,
517 bool UseGOT) const;
518 SDValue getDynamicTLSAddr(GlobalAddressSDNode *N, SelectionDAG &DAG) const;
519 SDValue getTLSDescAddr(GlobalAddressSDNode *N, SelectionDAG &DAG) const;
520
521 SDValue lowerConstantFP(SDValue Op, SelectionDAG &DAG) const;
522 SDValue lowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
523 SDValue lowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
524 SDValue lowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
525 SDValue lowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
526 SDValue lowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
528 SDValue lowerBRCOND(SDValue Op, SelectionDAG &DAG) const;
529 SDValue lowerVASTART(SDValue Op, SelectionDAG &DAG) const;
532 SDValue lowerShiftLeftParts(SDValue Op, SelectionDAG &DAG) const;
533 SDValue lowerShiftRightParts(SDValue Op, SelectionDAG &DAG, bool IsSRA) const;
534 SDValue lowerSPLAT_VECTOR_PARTS(SDValue Op, SelectionDAG &DAG) const;
535 SDValue lowerVectorMaskSplat(SDValue Op, SelectionDAG &DAG) const;
536 SDValue lowerVectorMaskExt(SDValue Op, SelectionDAG &DAG,
537 int64_t ExtTrueVal) const;
538 SDValue lowerVectorMaskTrunc(SDValue Op, SelectionDAG &DAG) const;
539 SDValue lowerVectorTrunc(SDValue Op, SelectionDAG &DAG) const;
540 SDValue lowerVectorFPExtendOrRound(SDValue Op, SelectionDAG &DAG) const;
541 SDValue lowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
542 SDValue lowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
543 SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
545 SDValue LowerINTRINSIC_VOID(SDValue Op, SelectionDAG &DAG) const;
546 SDValue lowerVPREDUCE(SDValue Op, SelectionDAG &DAG) const;
547 SDValue lowerVECREDUCE(SDValue Op, SelectionDAG &DAG) const;
548 SDValue lowerVectorMaskVecReduction(SDValue Op, SelectionDAG &DAG,
549 bool IsVP) const;
550 SDValue lowerFPVECREDUCE(SDValue Op, SelectionDAG &DAG) const;
551 SDValue lowerINSERT_SUBVECTOR(SDValue Op, SelectionDAG &DAG) const;
552 SDValue lowerEXTRACT_SUBVECTOR(SDValue Op, SelectionDAG &DAG) const;
553 SDValue lowerVECTOR_DEINTERLEAVE(SDValue Op, SelectionDAG &DAG) const;
554 SDValue lowerVECTOR_INTERLEAVE(SDValue Op, SelectionDAG &DAG) const;
555 SDValue lowerSTEP_VECTOR(SDValue Op, SelectionDAG &DAG) const;
556 SDValue lowerVECTOR_REVERSE(SDValue Op, SelectionDAG &DAG) const;
557 SDValue lowerVECTOR_SPLICE(SDValue Op, SelectionDAG &DAG) const;
558 SDValue lowerABS(SDValue Op, SelectionDAG &DAG) const;
559 SDValue lowerMaskedLoad(SDValue Op, SelectionDAG &DAG) const;
560 SDValue lowerLoadFF(SDValue Op, SelectionDAG &DAG) const;
561 SDValue lowerMaskedStore(SDValue Op, SelectionDAG &DAG) const;
562 SDValue lowerVectorCompress(SDValue Op, SelectionDAG &DAG) const;
563 SDValue lowerMaskedGather(SDValue Op, SelectionDAG &DAG) const;
564 SDValue lowerMaskedScatter(SDValue Op, SelectionDAG &DAG) const;
565 SDValue lowerFixedLengthVectorLoadToRVV(SDValue Op, SelectionDAG &DAG) const;
566 SDValue lowerFixedLengthVectorStoreToRVV(SDValue Op, SelectionDAG &DAG) const;
567 SDValue lowerToScalableOp(SDValue Op, SelectionDAG &DAG) const;
568 SDValue LowerIS_FPCLASS(SDValue Op, SelectionDAG &DAG) const;
569 SDValue lowerVPOp(SDValue Op, SelectionDAG &DAG) const;
570 SDValue lowerVPMergeMask(SDValue Op, SelectionDAG &DAG) const;
571 SDValue lowerVPSpliceExperimental(SDValue Op, SelectionDAG &DAG) const;
572 SDValue lowerVPReverseExperimental(SDValue Op, SelectionDAG &DAG) const;
573 SDValue lowerVPStridedLoad(SDValue Op, SelectionDAG &DAG) const;
574 SDValue lowerVPStridedStore(SDValue Op, SelectionDAG &DAG) const;
575 SDValue lowerVPCttzElements(SDValue Op, SelectionDAG &DAG) const;
576 SDValue lowerGET_ROUNDING(SDValue Op, SelectionDAG &DAG) const;
577 SDValue lowerSET_ROUNDING(SDValue Op, SelectionDAG &DAG) const;
578 SDValue lowerGET_FPENV(SDValue Op, SelectionDAG &DAG) const;
579 SDValue lowerSET_FPENV(SDValue Op, SelectionDAG &DAG) const;
580 SDValue lowerRESET_FPENV(SDValue Op, SelectionDAG &DAG) const;
581 SDValue lowerGET_FPMODE(SDValue Op, SelectionDAG &DAG) const;
582 SDValue lowerSET_FPMODE(SDValue Op, SelectionDAG &DAG) const;
583 SDValue lowerRESET_FPMODE(SDValue Op, SelectionDAG &DAG) const;
584
585 SDValue lowerEH_DWARF_CFA(SDValue Op, SelectionDAG &DAG) const;
586 SDValue lowerCTLZ_CTTZ_ZERO_POISON(SDValue Op, SelectionDAG &DAG) const;
587
588 SDValue lowerStrictFPExtendOrRoundLike(SDValue Op, SelectionDAG &DAG) const;
589
590 SDValue lowerVectorStrictFSetcc(SDValue Op, SelectionDAG &DAG) const;
591
592 SDValue lowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const;
593
594 SDValue expandUnalignedRVVLoad(SDValue Op, SelectionDAG &DAG) const;
595 SDValue expandUnalignedRVVStore(SDValue Op, SelectionDAG &DAG) const;
596
597 SDValue expandUnalignedVPLoad(SDValue Op, SelectionDAG &DAG) const;
598 SDValue expandUnalignedVPStore(SDValue Op, SelectionDAG &DAG) const;
599
600 SDValue lowerINIT_TRAMPOLINE(SDValue Op, SelectionDAG &DAG) const;
601 SDValue lowerADJUST_TRAMPOLINE(SDValue Op, SelectionDAG &DAG) const;
602 SDValue lowerPARTIAL_REDUCE_MLA(SDValue Op, SelectionDAG &DAG) const;
604
605 SDValue lowerXAndesBfHCvtBFloat16Load(SDValue Op, SelectionDAG &DAG) const;
606 SDValue lowerXAndesBfHCvtBFloat16Store(SDValue Op, SelectionDAG &DAG) const;
607
608 bool isEligibleForTailCallOptimization(
609 CCState &CCInfo, CallLoweringInfo &CLI, MachineFunction &MF,
610 const SmallVector<CCValAssign, 16> &ArgLocs) const;
611
612 /// Generate error diagnostics if any register used by CC has been marked
613 /// reserved.
614 void validateCCReservedRegs(
615 const SmallVectorImpl<std::pair<llvm::Register, llvm::SDValue>> &Regs,
616 MachineFunction &MF) const;
617
618 bool useRVVForFixedLengthVectorVT(MVT VT) const;
619
620 MVT getVPExplicitVectorLengthTy() const override;
621
622 bool shouldExpandGetVectorLength(EVT TripCountVT, unsigned VF,
623 bool IsScalable) const override;
624
625 bool isProfitableToFoldVScaleAdd(SDValue N) const override;
626
627 /// RVV code generation for fixed length vectors does not lower all
628 /// BUILD_VECTORs. This makes BUILD_VECTOR legalisation a source of stores to
629 /// merge. However, merging them creates a BUILD_VECTOR that is just as
630 /// illegal as the original, thus leading to an infinite legalisation loop.
631 /// NOTE: Once BUILD_VECTOR can be custom lowered for all legal vector types,
632 /// this override can be removed.
633 bool mergeStoresAfterLegalization(EVT VT) const override;
634
635 /// Disable normalizing
636 /// select(N0&N1, X, Y) => select(N0, select(N1, X, Y), Y) and
637 /// select(N0|N1, X, Y) => select(N0, select(N1, X, Y, Y))
638 /// RISC-V doesn't have flags so it's better to perform the and/or in a GPR.
639 bool shouldNormalizeToSelectSequence(LLVMContext &, EVT, EVT) const override {
640 return false;
641 }
642
643 /// Disables storing and loading vectors by default when there are function
644 /// calls between the load and store, since these are more expensive than just
645 /// using scalars
646 bool shouldMergeStoreOfLoadsOverCall(EVT SrcVT, EVT MergedVT) const override {
647 return !MergedVT.isVector() || SrcVT.isVector();
648 }
649
650 /// For available scheduling models FDIV + two independent FMULs are much
651 /// faster than two FDIVs.
652 unsigned combineRepeatedFPDivisors() const override;
653
654 SDValue BuildSDIVPow2(SDNode *N, const APInt &Divisor, SelectionDAG &DAG,
655 SmallVectorImpl<SDNode *> &Created) const override;
656
657 bool shouldFoldSelectWithSingleBitTest(EVT VT,
658 const APInt &AndMask) const override;
659
660 unsigned getMinimumJumpTableEntries() const override;
661
662 SDValue emitFlushICache(SelectionDAG &DAG, SDValue InChain, SDValue Start,
663 SDValue End, SDValue Flags, SDLoc DL) const;
664
665 std::pair<const TargetRegisterClass *, uint8_t>
666 findRepresentativeClass(const TargetRegisterInfo *TRI, MVT VT) const override;
667};
668
669namespace RISCVVIntrinsicsTable {
670
672 unsigned IntrinsicID;
676 bool hasScalarOperand() const {
677 // 0xF is not valid. See NoScalarOperand in IntrinsicsRISCV.td.
678 return ScalarOperand != 0xF;
679 }
680 bool hasVLOperand() const {
681 // 0x1F is not valid. See NoVLOperand in IntrinsicsRISCV.td.
682 return VLOperand != 0x1F;
683 }
684};
685
686using namespace RISCV;
687
688#define GET_RISCVVIntrinsicsTable_DECL
689#include "RISCVGenSearchableTables.inc"
690#undef GET_RISCVVIntrinsicsTable_DECL
691
692} // end namespace RISCVVIntrinsicsTable
693
694} // end namespace llvm
695
696#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
uint64_t uint64_t
uint64_t Imm
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
Function Alias Analysis Results
#define X(NUM, ENUM, NAME)
Definition ELF.h:665
block Block Frequency Analysis
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
const HexagonInstrInfo * TII
IRTranslator LLVM IR MI
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
#define RegName(no)
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
Register const TargetRegisterInfo * TRI
static SDValue lowerSELECT(SDValue Op, SelectionDAG &DAG)
static bool useRVVForFixedLengthVectorVT(MVT VT, const RISCVSubtarget &Subtarget)
SmallVector< MachineOperand, 4 > Cond
RISCVCC::CondCode CC
MachineRegisterInfo & MRI
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
This file describes how to lower LLVM code to machine code.
static SDValue lowerFRAMEADDR(SDValue Op, SelectionDAG &DAG, const VETargetLowering &TLI, const VESubtarget *Subtarget)
static SDValue lowerRETURNADDR(SDValue Op, SelectionDAG &DAG, const VETargetLowering &TLI, const VESubtarget *Subtarget)
static SDValue LowerINTRINSIC_W_CHAIN(SDValue Op, const X86Subtarget &Subtarget, SelectionDAG &DAG)
static SDValue lowerVECTOR_SHUFFLE(SDValue Op, const X86Subtarget &Subtarget, SelectionDAG &DAG)
Top-level lowering for x86 vector shuffles.
Value * RHS
Value * LHS
Class for arbitrary precision integers.
Definition APInt.h:78
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
An instruction that atomically checks whether a specified value is in a memory location,...
an instruction that atomically reads a memory location, combines it with another value,...
CCState - This class holds information needed while lowering arguments and return values.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
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:44
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
bool hasMinSize() const
Optimize this function for minimum size (-Oz).
Definition Function.h:696
Common base class shared among various IRBuilders.
Definition IRBuilder.h:111
A wrapper class for inspecting calls to intrinsic functions.
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:76
Tracks which library functions to use for a particular subtarget or function.
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.
Flags
Flags values. These may be or'd together.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
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
Value * getIRStackGuard(IRBuilderBase &IRB, const LibcallLoweringInfo &Libcalls) const override
If the target has a standard location for the stack protector cookie, returns the address of that loc...
static unsigned getSubregIndexByMVT(MVT VT, unsigned Index)
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.
TargetLowering::AtomicExpansionKind shouldExpandAtomicRMWInIR(const AtomicRMWInst *AI) const override
Returns how the IR-level AtomicExpand pass should expand the given AtomicRMW, if at all.
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.
RISCVTargetLowering(const TargetMachine &TM, const RISCVSubtarget &STI)
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
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.
Register getExceptionSelectorRegister(ExceptionHandling EH, const Constant *PersonalityFn) const override
If a physical register, this returns the register that receives the exception typeid on entry to a la...
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 ...
ISD::NodeType getExtendForAtomicRMWArg(unsigned Op) const override
Returns how the platform's atomic rmw operations expect their input argument to be extended (ZERO_EXT...
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 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 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
void finalizeLowering(MachineFunction &MF) const override
Execute target specific actions to finalize target lowering.
static unsigned getRegClassIDForVecVT(MVT VT)
std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const override
Given a physical register constraint (e.g.
bool hasMultipleConditionRegisters(EVT VT) const override
Does the target have multiple (allocatable) condition registers that can be used to store the results...
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.
bool isReassocProfitable(SelectionDAG &DAG, SDValue N0, SDValue N1) const override
Control the following reassociation of operands: (op (op x, c1), y) -> (op (op x, y),...
TargetLowering::AtomicExpansionKind shouldExpandAtomicCmpXchgInIR(const AtomicCmpXchgInst *CI) const override
Returns how the given atomic cmpxchg should be expanded by the IR-level AtomicExpand pass.
bool shouldFoldMaskToVariableShiftPair(SDValue Y) const override
There are two ways to clear extreme bits (either low or high): Mask: x & (-1 << y) (the instcombine c...
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 canCreateUndefOrPoisonForTargetNode(SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG, UndefPoisonKind Kind, bool ConsiderFlags, unsigned Depth) const override
Return true if Op can create undef or poison from non-undef & non-poison operands.
bool isUsedByReturnOnly(SDNode *N, SDValue &Chain) const override
Return true if result of the specified node is used by a return node only.
bool lowerDeinterleaveIntrinsicToLoad(Instruction *Load, Value *Mask, IntrinsicInst *DI, const APInt &GapMask) const override
Lower a deinterleave intrinsic to a target specific load intrinsic.
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.
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 isVectorClearMaskLegal(ArrayRef< int > M, EVT VT) const override
Similar to isShuffleMaskLegal.
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 isLegalElementTypeForRVV(EVT ScalarTy) const
bool isLegalFirstFaultLoad(EVT DataType, Align Alignment) const
Return true if a fault-only-first load of the given result type and alignment is legal.
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.
void getTgtMemIntrinsic(SmallVectorImpl< IntrinsicInfo > &Infos, const CallBase &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...
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.
CondMergingParams getJumpConditionMergingParams(Instruction::BinaryOps Opc, const Value *LHS, const Value *RHS, const Function *F) const override
bool isIntDivCheap(EVT VT, AttributeList Attr) const override
Return true if integer divide is usually cheaper than a sequence of several shifts,...
LegalizeTypeAction getPreferredVectorAction(MVT VT) const override
Customize the preferred legalization strategy for certain types.
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.
void computeKnownBitsForTargetInstr(GISelValueTracking &Analysis, Register R, KnownBits &Known, const APInt &DemandedElts, const MachineRegisterInfo &MRI, unsigned Depth=0) const override
Determine which of the bits specified in Mask are known to be either zero or one and return them in t...
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.
ExtractSubvectorCost getExtractSubvectorCost(EVT ResVT, EVT SrcVT, unsigned Index) const override
Return the cost of extracting a subvector of type ResVT from a vector of type SrcVT,...
FPImmAction getFPImmAction(const APFloat &Imm, EVT VT, bool ForCodeSize) const override
Returns how the legalizer should materialize the specified FP immediate.
unsigned getStackProbeSize(const MachineFunction &MF, Align StackAlign) const
Register getExceptionPointerRegister(ExceptionHandling EH, const Constant *PersonalityFn) const override
If a physical register, this returns the register that receives the exception address on entry to an ...
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:20
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...
MachineFunction & getMachineFunction() const
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...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
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 unsigned getMinimumJumpTableEntries() const
Return lower limit for number of blocks in a jump table.
ExtractSubvectorCost
Enum that specifies how expensive lowering an EXTRACT_SUBVECTOR is.
FPImmAction
How the legalizer should materialize a floating-point immediate.
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.
virtual MVT getVPExplicitVectorLengthTy() const
Returns the type to be used for the EVL/AVL operand of VP nodes: ISD::VP_UDIV, ISD::VP_SDIV,...
TargetLowering(const TargetLowering &)=delete
virtual unsigned combineRepeatedFPDivisors() const
Indicate whether this target prefers to combine FDIVs with the same divisor.
Primary interface to the complete machine description for the target machine.
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:46
LLVM Value Representation.
Definition Value.h:75
Base class of all SIMD vector types.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
Definition ISDOpcodes.h:43
@ SIGN_EXTEND
Conversion operators.
Definition ISDOpcodes.h:870
MemIndexedMode
MemIndexedMode enum - This enum defines the load / store indexed addressing modes.
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
This namespace contains an enum with a value for every intrinsic/builtin function known by LLVM.
static constexpr unsigned RVVBitsPerBlock
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:577
@ Known
Known to have no common set bits.
@ Load
The value being inserted comes from a load (InsertElement only).
@ Store
The extracted value is stored (ExtractElement only).
AtomicOrdering
Atomic ordering for LLVM's memory model.
CombineLevel
Definition DAGCombine.h:15
@ Fast
Assign the register banks as fast as possible (default).
DWARFExpression::Operation Op
ExceptionHandling
Definition CodeGen.h:54
UndefPoisonKind
Enumeration to track whether we are interested in Undef, Poison, or both.
Definition UndefPoison.h:20
@ End
Run the machine verifier once, at the end of the pipeline.
Definition CodeGen.h:320
#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:155
bool isVector() const
Return true if this is a vector value type.
Definition ValueTypes.h:176
bool isScalarInteger() const
Return true if this is an integer, but not a vector.
Definition ValueTypes.h:165
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
Definition ValueTypes.h:359
bool isInteger() const
Return true if this is an integer or a vector integer type.
Definition ValueTypes.h:160
This structure contains all information that is necessary for lowering calls.