13#ifndef LLVM_LIB_TARGET_RISCV_RISCVSUBTARGET_H
14#define LLVM_LIB_TARGET_RISCV_RISCVSUBTARGET_H
36#define OPTIONS_STRUCT_DECL
37#include "RISCVOptions.inc"
39#define GET_RISCV_MACRO_FUSION_PRED_DECL
40#include "RISCVGenMacroFusion.inc"
42#define GET_SUBTARGETINFO_HEADER
43#include "RISCVGenSubtargetInfo.inc"
48namespace RISCVTuneInfoTable {
89#define GET_RISCVTuneInfoTable_DECL
90#include "RISCVGenSearchableTables.inc"
108 const RISCVOptions &CLOpts;
110 virtual void anchor();
112 RISCVProcFamilyEnum RISCVProcFamily =
Others;
113 RISCVVRGatherCostModelEnum RISCVVRGatherCostModel =
Quadratic;
115 bool IsLittleEndian =
true;
117#define GET_SUBTARGETINFO_MACRO(ATTRIBUTE, DEFAULT, GETTER) \
118 bool ATTRIBUTE = DEFAULT;
119#include "RISCVGenSubtargetInfo.inc"
121 unsigned XSfmmTE = 0;
123 unsigned RVVVectorBitsMin;
124 unsigned RVVVectorBitsMax;
127 std::bitset<RISCV::NUM_TARGET_REGS> UserReservedRegister;
128 const RISCVTuneInfoTable::RISCVTuneInfo *TuneInfo;
130 RISCVFrameLowering FrameLowering;
131 RISCVInstrInfo InstrInfo;
132 RISCVTargetLowering TLInfo;
144 RISCVSubtarget(
const Triple &TT, StringRef CPU, StringRef TuneCPU,
145 StringRef FS, StringRef ABIName,
unsigned RVVVectorBitsMin,
146 unsigned RVVVectorLMULMax,
const TargetMachine &TM);
155 return &FrameLowering;
157 const RISCVOptions &
getCLOpts()
const {
return CLOpts; }
160 return &InstrInfo.getRegisterInfo();
173 return Align(TuneInfo->PrefFunctionAlignment);
176 return Align(TuneInfo->PrefLoopAlignment);
187#define GET_SUBTARGETINFO_MACRO(ATTRIBUTE, DEFAULT, GETTER) \
188 bool GETTER() const { return ATTRIBUTE; }
189#include "RISCVGenSubtargetInfo.inc"
192 return HasStdExtYCapMode || HasStdExtZyhybrid;
199 return HasStdExtZfhmin || HasStdExtZhinxmin;
202 return HasStdExtZfhmin || HasStdExtZfbfmin;
205 bool hasCLZLike()
const {
return HasStdExtZbb || HasVendorXTHeadBb; }
207 return HasStdExtZbb || (HasVendorXCVbitmanip && !IsRV64);
210 return HasStdExtZbb || (HasVendorXCVbitmanip && !IsRV64);
213 return HasStdExtZbb || HasStdExtZbkb || HasVendorXTHeadBb;
216 return HasStdExtP || ((HasVendorXCVbitmanip || HasVendorXqcibm) && !IsRV64);
219 bool hasBEXTILike()
const {
return HasStdExtZbs || HasVendorXTHeadBs; }
223 return (hasConditionalCompressedMoveFusion() && hasStdExtZca()) ||
224 hasShortForwardBranchIALU();
231 return HasStdExtZba || HasVendorXAndesPerf || HasVendorXTHeadBa;
232 return ShAmt <= 31 && HasVendorXqciac;
238 return is64Bit() ? MVT::i64 : MVT::i32;
256 if (enableUnalignedScalarMem())
259 if (allowZilsdWordAlign())
271 return VLen == 0 ? ZvlLen : VLen;
275 return VLen == 0 ? 65536 : VLen;
289 if (
auto VLen =
getRealVLen(); VLen &&
X.isScalable()) {
291 X = Quantity::getFixed(
X.getKnownMinValue() * VScale);
299 assert(i.
id() < RISCV::NUM_TARGET_REGS &&
"Register out of range");
300 return UserReservedRegister[i.
id()];
305 return &RISCV::FPR128RegClass;
307 return &RISCV::FPR64RegClass;
309 return &RISCV::FPR32RegClass;
316 return hasStdExtD() && (
is64Bit() || hasStdExtZcf()) && hasStdExtZcd();
325 return HasStdExtZvfbfmin || HasStdExtZvfbfa;
340 return hasOptimizedNF2SegmentLoadStore();
342 return hasOptimizedNF3SegmentLoadStore();
344 return hasOptimizedNF4SegmentLoadStore();
346 return hasOptimizedNF5SegmentLoadStore();
348 return hasOptimizedNF6SegmentLoadStore();
350 return hasOptimizedNF7SegmentLoadStore();
352 return hasOptimizedNF8SegmentLoadStore();
371 std::unique_ptr<const SelectionDAGTargetInfo>
TSInfo;
415 bool useAA()
const override;
418 return TuneInfo->CacheLineSize;
421 return TuneInfo->PrefetchDistance;
424 unsigned NumStridedMemAccesses,
425 unsigned NumPrefetches,
426 bool HasCall)
const override {
427 return TuneInfo->MinPrefetchStride;
430 return TuneInfo->MaxPrefetchIterationsAhead;
437 return TuneInfo->TailDupAggressiveThreshold;
441 return OptSize ? TuneInfo->MaxStoresPerMemsetOptSize
442 : TuneInfo->MaxStoresPerMemset;
446 return TuneInfo->MaxGluedStoresPerMemcpy;
450 return OptSize ? TuneInfo->MaxStoresPerMemcpyOptSize
451 : TuneInfo->MaxStoresPerMemcpy;
455 return OptSize ? TuneInfo->MaxStoresPerMemmoveOptSize
456 : TuneInfo->MaxStoresPerMemmove;
460 return OptSize ? TuneInfo->MaxLoadsPerMemcmpOptSize
461 : TuneInfo->MaxLoadsPerMemcmp;
465 return TuneInfo->MaxVectorCoalesceElts;
469 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
const RISCVOptions & getCLOpts() const
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 hasYInstructions() 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.
bool isSoftFP(ABI TargetABI)
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.