13#ifndef LLVM_LIB_TARGET_RISCV_RISCVSUBTARGET_H
14#define LLVM_LIB_TARGET_RISCV_RISCVSUBTARGET_H
34#define GET_RISCV_MACRO_FUSION_PRED_DECL
35#include "RISCVGenMacroFusion.inc"
37#define GET_SUBTARGETINFO_HEADER
38#include "RISCVGenSubtargetInfo.inc"
43namespace RISCVTuneInfoTable {
84#define GET_RISCVTuneInfoTable_DECL
85#include "RISCVGenSearchableTables.inc"
103 virtual void anchor();
105 RISCVProcFamilyEnum RISCVProcFamily =
Others;
106 RISCVVRGatherCostModelEnum RISCVVRGatherCostModel =
Quadratic;
108 bool IsLittleEndian =
true;
110#define GET_SUBTARGETINFO_MACRO(ATTRIBUTE, DEFAULT, GETTER) \
111 bool ATTRIBUTE = DEFAULT;
112#include "RISCVGenSubtargetInfo.inc"
114 unsigned XSfmmTE = 0;
116 unsigned RVVVectorBitsMin;
117 unsigned RVVVectorBitsMax;
120 std::bitset<RISCV::NUM_TARGET_REGS> UserReservedRegister;
121 const RISCVTuneInfoTable::RISCVTuneInfo *TuneInfo;
123 RISCVFrameLowering FrameLowering;
124 RISCVInstrInfo InstrInfo;
125 RISCVTargetLowering TLInfo;
137 RISCVSubtarget(
const Triple &TT, StringRef CPU, StringRef TuneCPU,
138 StringRef FS, StringRef ABIName,
unsigned RVVVectorBitsMin,
139 unsigned RVVVectorLMULMax,
const TargetMachine &TM);
148 return &FrameLowering;
152 return &InstrInfo.getRegisterInfo();
165 return Align(TuneInfo->PrefFunctionAlignment);
168 return Align(TuneInfo->PrefLoopAlignment);
179#define GET_SUBTARGETINFO_MACRO(ATTRIBUTE, DEFAULT, GETTER) \
180 bool GETTER() const { return ATTRIBUTE; }
181#include "RISCVGenSubtargetInfo.inc"
188 return HasStdExtZfhmin || HasStdExtZhinxmin;
191 return HasStdExtZfhmin || HasStdExtZfbfmin;
194 bool hasCLZLike()
const {
return HasStdExtZbb || HasVendorXTHeadBb; }
196 return HasStdExtZbb || (HasVendorXCVbitmanip && !IsRV64);
199 return HasStdExtZbb || (HasVendorXCVbitmanip && !IsRV64);
202 return HasStdExtZbb || HasStdExtZbkb || HasVendorXTHeadBb;
205 return HasStdExtP || ((HasVendorXCVbitmanip || HasVendorXqcibm) && !IsRV64);
208 bool hasBEXTILike()
const {
return HasStdExtZbs || HasVendorXTHeadBs; }
212 return (hasConditionalCompressedMoveFusion() && hasStdExtZca()) ||
213 hasShortForwardBranchIALU();
220 return HasStdExtZba || HasVendorXAndesPerf || HasVendorXTHeadBa;
221 return ShAmt <= 31 && HasVendorXqciac;
227 return is64Bit() ? MVT::i64 : MVT::i32;
245 if (enableUnalignedScalarMem())
248 if (allowZilsdWordAlign())
260 return VLen == 0 ? ZvlLen : VLen;
264 return VLen == 0 ? 65536 : VLen;
278 if (
auto VLen =
getRealVLen(); VLen &&
X.isScalable()) {
280 X = Quantity::getFixed(
X.getKnownMinValue() * VScale);
292 assert(i.
id() < RISCV::NUM_TARGET_REGS &&
"Register out of range");
293 return UserReservedRegister[i.
id()];
298 return &RISCV::FPR128RegClass;
300 return &RISCV::FPR64RegClass;
302 return &RISCV::FPR32RegClass;
315 return HasStdExtZvfbfmin || HasStdExtZvfbfa;
330 return hasOptimizedNF2SegmentLoadStore();
332 return hasOptimizedNF3SegmentLoadStore();
334 return hasOptimizedNF4SegmentLoadStore();
336 return hasOptimizedNF5SegmentLoadStore();
338 return hasOptimizedNF6SegmentLoadStore();
340 return hasOptimizedNF7SegmentLoadStore();
342 return hasOptimizedNF8SegmentLoadStore();
361 std::unique_ptr<const SelectionDAGTargetInfo>
TSInfo;
405 bool useAA()
const override;
408 return TuneInfo->CacheLineSize;
411 return TuneInfo->PrefetchDistance;
414 unsigned NumStridedMemAccesses,
415 unsigned NumPrefetches,
416 bool HasCall)
const override {
417 return TuneInfo->MinPrefetchStride;
420 return TuneInfo->MaxPrefetchIterationsAhead;
427 return TuneInfo->TailDupAggressiveThreshold;
431 return OptSize ? TuneInfo->MaxStoresPerMemsetOptSize
432 : TuneInfo->MaxStoresPerMemset;
436 return TuneInfo->MaxGluedStoresPerMemcpy;
440 return OptSize ? TuneInfo->MaxStoresPerMemcpyOptSize
441 : TuneInfo->MaxStoresPerMemcpy;
445 return OptSize ? TuneInfo->MaxStoresPerMemmoveOptSize
446 : TuneInfo->MaxStoresPerMemmove;
450 return OptSize ? TuneInfo->MaxLoadsPerMemcmpOptSize
451 : TuneInfo->MaxLoadsPerMemcmp;
455 return TuneInfo->MaxVectorCoalesceElts;
459 return TuneInfo->PostRASchedDirection;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file describes how to lower LLVM calls to machine code calls.
This file describes how to lower LLVM inline asm to machine code INLINEASM.
Interface for Targets to specify which operations they can successfully select and how the others sho...
static const unsigned MaxInterleaveFactor
Maximum vectorization interleave count.
This file declares the targeting of the RegisterBankInfo class for RISC-V.
This class provides the information for the target register banks.
RISCVABI::ABI getTargetABI() const
unsigned getMinimumJumpTableEntries() const
RISCVVRGatherCostModelEnum
const LegalizerInfo * getLegalizerInfo() const override
bool isJumpExpensive() const
void overrideSchedPolicy(MachineSchedPolicy &Policy, const SchedRegion &Region) const override
bool enableWritePrefetching() const override
std::unique_ptr< LegalizerInfo > Legalizer
bool hasVInstructionsI64() const
bool isPExtPackedDoubleType(MVT VT) const
unsigned getMaxPrefetchIterationsAhead() const override
bool hasVInstructionsF64() const
unsigned getMaxStoresPerMemcpy(bool OptSize) const
bool hasStdExtDOrZdinx() const
unsigned getMaxLoadsPerMemcmp(bool OptSize) const
bool hasStdExtZfhOrZhinx() const
bool hasShlAdd(int64_t ShAmt) const
bool useDFAforSMS() const override
unsigned getTailDupAggressiveThreshold() const
unsigned getRealMinVLen() const
unsigned getMaxStoresPerMemset(bool OptSize) const
bool useMIPSLoadStorePairs() const
const InlineAsmLowering * getInlineAsmLowering() const override
Quantity expandVScale(Quantity X) const
If the ElementCount or TypeSize X is scalable and VScale (VLEN) is exactly known, returns X converted...
bool useRVVForFixedLengthVectors() const
RISCVVRGatherCostModelEnum getVRGatherCostModel() const
MISched::Direction getPostRASchedDirection() const
std::unique_ptr< InlineAsmLowering > InlineAsmLoweringInfo
bool isPExtPackedType(MVT VT) const
unsigned getLoadLatency() const override
bool isTargetFuchsia() const
bool hasVInstructionsBF16Minimal() const
unsigned getDLenFactor() const
TargetRegisterClass const * getLargestFPRegClass() const
unsigned getMaxStoresPerMemmove(bool OptSize) const
unsigned getMinRVVVectorSizeInBits() const
std::unique_ptr< InstructionSelector > InstSelector
bool hasVInstructionsF16Minimal() const
RISCVSubtarget(const Triple &TT, StringRef CPU, StringRef TuneCPU, StringRef FS, StringRef ABIName, unsigned RVVVectorBitsMin, unsigned RVVVectorLMULMax, const TargetMachine &TM)
unsigned getMaxGluedStoresPerMemcpy() const
bool hasConditionalMoveFusion() const
bool useMIPSCCMovInsn() const
bool hasVInstructionsF16() const
unsigned getMispredictionPenalty() const override
bool hasVInstructionsBF16() const
const RISCVRegisterBankInfo * getRegBankInfo() const override
const CallLowering * getCallLowering() const override
bool enableMachineScheduler() const override
InstructionSelector * getInstructionSelector() const override
unsigned getMaxBuildIntsCost() const
Align getPrefLoopAlignment() const
std::unique_ptr< const SelectionDAGTargetInfo > TSInfo
bool hasVInstructions() const
bool useAA() const override
Enable use of alias analysis during code generation (during MI scheduling, DAGCombine,...
bool isRegisterReservedByUser(Register i) const override
bool hasVInstructionsAnyF() const
std::optional< unsigned > getRealVLen() const
bool isXRaySupported() const override
bool enableMachinePipeliner() const override
bool hasOptimizedSegmentLoadStore(unsigned NF) const
bool useConstantPoolForLargeInts() const
bool isLittleEndian() const
Align getPrefFunctionAlignment() const
~RISCVSubtarget() override
RISCVProcFamilyEnum getProcFamily() const
Returns RISC-V processor family.
unsigned getMaxRVVVectorSizeInBits() const
bool hasStdExtZfhminOrZhinxmin() const
unsigned getRealMaxVLen() const
unsigned getMinPrefetchStride(unsigned NumMemAccesses, unsigned NumStridedMemAccesses, unsigned NumPrefetches, bool HasCall) const override
void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS)
const RISCVRegisterInfo * getRegisterInfo() const override
Align getZilsdAlign() const
std::unique_ptr< RISCVRegisterBankInfo > RegBankInfo
void mirFileLoaded(MachineFunction &MF) const override
const RISCVInstrInfo * getInstrInfo() const override
unsigned getCacheLineSize() const override
std::unique_ptr< CallLowering > CallLoweringInfo
bool hasBEXTILike() const
uint8_t getMaxVectorCoalesceElts() const
bool hasVInstructionsFullMultiply() const
const RISCVTargetLowering * getTargetLowering() const override
void overridePostRASchedPolicy(MachineSchedPolicy &Policy, const SchedRegion &Region) const override
bool hasVInstructionsF32() const
unsigned getMaxInterleaveFactor() const
bool enableSubRegLiveness() const override
const SelectionDAGTargetInfo * getSelectionDAGInfo() const override
bool isTargetAndroid() const
bool hasStdExtFOrZfinx() const
bool enablePostRAScheduler() const override
bool hasStdExtZvl() const
bool hasHalfFPLoadStoreMove() const
const RISCVFrameLowering * getFrameLowering() const override
unsigned getPrefetchDistance() const override
Wrapper class representing virtual and physical registers.
constexpr unsigned id() const
Targets can subclass this to parameterize the SelectionDAG lowering and instruction selection process...
Represent a constant reference to a string, i.e.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static constexpr unsigned RVVBitsPerBlock
This is an optimization pass for GlobalISel generic memory operations.
MCRegisterClass TargetRegisterClass
This struct is a compact representation of a valid (non-zero power of two) alignment.
Define a generic scheduling policy for targets that don't provide their own MachineSchedStrategy.
uint16_t PrefetchDistance
uint8_t PrefLoopAlignment
unsigned MaxStoresPerMemmoveOptSize
unsigned MaxGluedStoresPerMemcpy
uint8_t MaxVectorCoalesceElts
unsigned MaxStoresPerMemmove
unsigned MaxLoadsPerMemcmpOptSize
uint8_t PrefFunctionAlignment
unsigned MaxPrefetchIterationsAhead
unsigned TailDupAggressiveThreshold
uint16_t MinPrefetchStride
unsigned MaxLoadsPerMemcmp
unsigned MinimumJumpTableEntries
unsigned MaxStoresPerMemset
unsigned MaxStoresPerMemsetOptSize
unsigned MaxStoresPerMemcpy
unsigned MaxStoresPerMemcpyOptSize
MISched::Direction PostRASchedDirection
A region of an MBB for scheduling.