13#ifndef LLVM_LIB_TARGET_RISCV_RISCVSUBTARGET_H
14#define LLVM_LIB_TARGET_RISCV_RISCVSUBTARGET_H
31#define GET_RISCV_MACRO_FUSION_PRED_DECL
32#include "RISCVGenMacroFusion.inc"
34#define GET_SUBTARGETINFO_HEADER
35#include "RISCVGenSubtargetInfo.inc"
40namespace RISCVTuneInfoTable {
75#define GET_RISCVTuneInfoTable_DECL
76#include "RISCVGenSearchableTables.inc"
95 virtual void anchor();
97 RISCVProcFamilyEnum RISCVProcFamily =
Others;
98 RISCVVRGatherCostModelEnum RISCVVRGatherCostModel =
Quadratic;
100 bool IsLittleEndian =
true;
102#define GET_SUBTARGETINFO_MACRO(ATTRIBUTE, DEFAULT, GETTER) \
103 bool ATTRIBUTE = DEFAULT;
104#include "RISCVGenSubtargetInfo.inc"
106 unsigned XSfmmTE = 0;
108 unsigned RVVVectorBitsMin;
109 unsigned RVVVectorBitsMax;
112 std::bitset<RISCV::NUM_TARGET_REGS> UserReservedRegister;
113 const RISCVTuneInfoTable::RISCVTuneInfo *TuneInfo;
115 RISCVFrameLowering FrameLowering;
116 RISCVInstrInfo InstrInfo;
117 RISCVTargetLowering TLInfo;
129 RISCVSubtarget(
const Triple &TT, StringRef CPU, StringRef TuneCPU,
130 StringRef FS, StringRef ABIName,
unsigned RVVVectorBitsMin,
140 return &FrameLowering;
144 return &InstrInfo.getRegisterInfo();
155 return Align(TuneInfo->PrefFunctionAlignment);
158 return Align(TuneInfo->PrefLoopAlignment);
169#define GET_SUBTARGETINFO_MACRO(ATTRIBUTE, DEFAULT, GETTER) \
170 bool GETTER() const { return ATTRIBUTE; }
171#include "RISCVGenSubtargetInfo.inc"
177 return HasStdExtC || HasStdExtZcf || HasStdExtZce;
184 return HasStdExtZfhmin || HasStdExtZhinxmin;
187 return HasStdExtZfhmin || HasStdExtZfbfmin;
191 return HasStdExtZbb || HasVendorXTHeadBb ||
192 (HasVendorXCVbitmanip && !IsRV64);
195 return HasStdExtZbb || (HasVendorXCVbitmanip && !IsRV64);
198 return HasStdExtZbb || (HasVendorXCVbitmanip && !IsRV64);
201 return HasStdExtZbb || HasStdExtZbkb || HasVendorXTHeadBb;
204 bool hasBEXTILike()
const {
return HasStdExtZbs || HasVendorXTHeadBs; }
207 return HasStdExtZicond || HasVendorXVentanaCondOps;
212 return (hasConditionalCompressedMoveFusion() && hasStdExtZca()) ||
213 hasShortForwardBranchIALU();
220 return HasStdExtZba || HasVendorXAndesPerf || HasVendorXTHeadBa;
221 return ShAmt <= 31 && HasVendorXqciac;
227 return is64Bit() ? MVT::i64 : MVT::i32;
245 return Align(enableUnalignedScalarMem() ? 1
246 : allowZilsd4ByteAlign() ? 4
256 return VLen == 0 ? ZvlLen : VLen;
260 return VLen == 0 ? 65536 : VLen;
274 if (
auto VLen =
getRealVLen(); VLen &&
X.isScalable()) {
276 X = Quantity::getFixed(
X.getKnownMinValue() * VScale);
288 assert(i.
id() < RISCV::NUM_TARGET_REGS &&
"Register out of range");
289 return UserReservedRegister[i.
id()];
301 return HasStdExtZvfbfmin || HasStdExtZvfbfa;
316 return hasOptimizedNF2SegmentLoadStore();
318 return hasOptimizedNF3SegmentLoadStore();
320 return hasOptimizedNF4SegmentLoadStore();
322 return hasOptimizedNF5SegmentLoadStore();
324 return hasOptimizedNF6SegmentLoadStore();
326 return hasOptimizedNF7SegmentLoadStore();
328 return hasOptimizedNF8SegmentLoadStore();
346 std::unique_ptr<const SelectionDAGTargetInfo>
TSInfo;
386 bool useAA()
const override;
389 return TuneInfo->CacheLineSize;
392 return TuneInfo->PrefetchDistance;
395 unsigned NumStridedMemAccesses,
396 unsigned NumPrefetches,
397 bool HasCall)
const override {
398 return TuneInfo->MinPrefetchStride;
401 return TuneInfo->MaxPrefetchIterationsAhead;
408 return TuneInfo->TailDupAggressiveThreshold;
412 return OptSize ? TuneInfo->MaxStoresPerMemsetOptSize
413 : TuneInfo->MaxStoresPerMemset;
417 return TuneInfo->MaxGluedStoresPerMemcpy;
421 return OptSize ? TuneInfo->MaxStoresPerMemcpyOptSize
422 : TuneInfo->MaxStoresPerMemcpy;
426 return OptSize ? TuneInfo->MaxStoresPerMemmoveOptSize
427 : TuneInfo->MaxStoresPerMemmove;
431 return OptSize ? TuneInfo->MaxLoadsPerMemcmpOptSize
432 : TuneInfo->MaxLoadsPerMemcmp;
436 return TuneInfo->PostRASchedDirection;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file describes how to lower LLVM calls to machine code calls.
#define LLVM_DEPRECATED(MSG, FIX)
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.
static cl::opt< unsigned > RVVVectorLMULMax("riscv-v-fixed-length-vector-lmul-max", cl::desc("The maximum LMUL value to use for fixed length vectors. " "Fractional LMUL values are not supported."), cl::init(8), cl::Hidden)
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
This class provides the information for the target register banks.
RISCVABI::ABI getTargetABI() const
unsigned getMinimumJumpTableEntries() const
RISCVVRGatherCostModelEnum
bool hasStdExtCOrZca() const
const LegalizerInfo * getLegalizerInfo() const override
void overrideSchedPolicy(MachineSchedPolicy &Policy, const SchedRegion &Region) const override
bool enableWritePrefetching() const override
std::unique_ptr< LegalizerInfo > Legalizer
unsigned getMaxLMULForFixedLengthVectors() const
bool hasVInstructionsI64() 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
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
bool isTargetFuchsia() const
bool hasVInstructionsBF16Minimal() const
unsigned getDLenFactor() 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
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
bool hasStdExtCOrZcfOrZce() const
Align getPrefFunctionAlignment() const
bool enablePExtSIMDCodeGen() 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
const RISCVInstrInfo * getInstrInfo() const override
unsigned getCacheLineSize() const override
std::unique_ptr< CallLowering > CallLoweringInfo
bool hasBEXTILike() const
bool hasStdExtCOrZcd() 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 hasCZEROLike() 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...
StringRef - 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.
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
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.