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;
129 std::bitset<32> UserReservedXRegs;
130 const RISCVTuneInfoTable::RISCVTuneInfo *TuneInfo;
132 RISCVFrameLowering FrameLowering;
133 RISCVInstrInfo InstrInfo;
134 RISCVTargetLowering TLInfo;
146 RISCVSubtarget(
const Triple &TT, StringRef CPU, StringRef TuneCPU,
147 StringRef FS, StringRef ABIName,
unsigned RVVVectorBitsMin,
148 unsigned RVVVectorLMULMax,
const TargetMachine &TM);
157 return &FrameLowering;
159 const RISCVOptions &
getCLOpts()
const {
return CLOpts; }
162 return &InstrInfo.getRegisterInfo();
175 return Align(TuneInfo->PrefFunctionAlignment);
178 return Align(TuneInfo->PrefLoopAlignment);
189#define GET_SUBTARGETINFO_MACRO(ATTRIBUTE, DEFAULT, GETTER) \
190 bool GETTER() const { return ATTRIBUTE; }
191#include "RISCVGenSubtargetInfo.inc"
194 return HasStdExtYCapMode || HasStdExtZyhybrid;
201 return HasStdExtZfhmin || HasStdExtZhinxmin;
204 return HasStdExtZfhmin || HasStdExtZfbfmin;
207 bool hasCLZLike()
const {
return HasStdExtZbb || HasVendorXTHeadBb; }
209 return HasStdExtZbb || (HasVendorXCVbitmanip && !IsRV64);
212 return HasStdExtZbb || (HasVendorXCVbitmanip && !IsRV64);
215 return HasStdExtZbb || HasStdExtZbkb || HasVendorXTHeadBb;
218 return HasStdExtP || ((HasVendorXCVbitmanip || HasVendorXqcibm) && !IsRV64);
221 bool hasBEXTILike()
const {
return HasStdExtZbs || HasVendorXTHeadBs; }
225 return (hasConditionalCompressedMoveFusion() && hasStdExtZca()) ||
226 hasShortForwardBranchIALU();
233 return HasStdExtZba || HasVendorXAndesPerf || HasVendorXTHeadBa;
234 return ShAmt <= 31 && HasVendorXqciac;
240 return is64Bit() ? MVT::i64 : MVT::i32;
258 if (enableUnalignedScalarMem())
261 if (allowZilsdWordAlign())
273 return VLen == 0 ? ZvlLen : VLen;
277 return VLen == 0 ? 65536 : VLen;
291 if (
auto VLen =
getRealVLen(); VLen &&
X.isScalable()) {
293 X = Quantity::getFixed(
X.getKnownMinValue() * VScale);
303 return UserReservedXRegs;
306 assert(i.
id() < RISCV::NUM_TARGET_REGS &&
"Register out of range");
312 return &RISCV::FPR128RegClass;
314 return &RISCV::FPR64RegClass;
316 return &RISCV::FPR32RegClass;
323 return hasStdExtD() && (
is64Bit() || hasStdExtZcf()) && hasStdExtZcd();
332 return HasStdExtZvfbfmin || HasStdExtZvfbfa;
347 return hasOptimizedNF2SegmentLoadStore();
349 return hasOptimizedNF3SegmentLoadStore();
351 return hasOptimizedNF4SegmentLoadStore();
353 return hasOptimizedNF5SegmentLoadStore();
355 return hasOptimizedNF6SegmentLoadStore();
357 return hasOptimizedNF7SegmentLoadStore();
359 return hasOptimizedNF8SegmentLoadStore();
378 std::unique_ptr<const SelectionDAGTargetInfo>
TSInfo;
422 bool useAA()
const override;
425 return TuneInfo->CacheLineSize;
428 return TuneInfo->PrefetchDistance;
431 unsigned NumStridedMemAccesses,
432 unsigned NumPrefetches,
433 bool HasCall)
const override {
434 return TuneInfo->MinPrefetchStride;
437 return TuneInfo->MaxPrefetchIterationsAhead;
444 return TuneInfo->TailDupAggressiveThreshold;
448 return OptSize ? TuneInfo->MaxStoresPerMemsetOptSize
449 : TuneInfo->MaxStoresPerMemset;
453 return TuneInfo->MaxGluedStoresPerMemcpy;
457 return OptSize ? TuneInfo->MaxStoresPerMemcpyOptSize
458 : TuneInfo->MaxStoresPerMemcpy;
462 return OptSize ? TuneInfo->MaxStoresPerMemmoveOptSize
463 : TuneInfo->MaxStoresPerMemmove;
467 return OptSize ? TuneInfo->MaxLoadsPerMemcmpOptSize
468 : TuneInfo->MaxLoadsPerMemcmp;
472 return TuneInfo->MaxVectorCoalesceElts;
476 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
const std::bitset< 32 > & getUserReservedXRegs() const
Returns the X registers reserved by the reserve-xN features, indexed by N.
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.
bool isRegisterReservedByUser(MCRegister Reg) const
Returns true if Reg is, or overlaps, a register reserved by the reserve-xN features,...
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.