1/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2|* *|
3|* Subtarget Enumeration Source Fragment *|
4|* *|
5|* Automatically generated file, do not edit! *|
6|* *|
7\*===----------------------------------------------------------------------===*/
8
9#ifdef GET_SUBTARGETINFO_ENUM
10#undef GET_SUBTARGETINFO_ENUM
11
12namespace llvm {
13
14namespace LoongArch {
15
16enum {
17 Feature32Bit = 0,
18 Feature32S = 1,
19 Feature64Bit = 2,
20 FeatureBasicD = 3,
21 FeatureBasicF = 4,
22 FeatureDiv32 = 5,
23 FeatureExtLASX = 6,
24 FeatureExtLBT = 7,
25 FeatureExtLSX = 8,
26 FeatureExtLVZ = 9,
27 FeatureFrecipe = 10,
28 FeatureLAMCAS = 11,
29 FeatureLAM_BH = 12,
30 FeatureLD_SEQ_SA = 13,
31 FeatureRelax = 14,
32 FeatureSCQ = 15,
33 FeatureUAL = 16,
34 LaGlobalWithAbs = 17,
35 LaGlobalWithPcrel = 18,
36 LaLocalWithAbs = 19,
37 TunePreferWInst = 20,
38 NumSubtargetFeatures = 21
39};
40
41} // namespace LoongArch
42
43} // namespace llvm
44
45#endif // GET_SUBTARGETINFO_ENUM
46
47#ifdef GET_SUBTARGETINFO_MACRO
48
49GET_SUBTARGETINFO_MACRO(Has32S, false, has32S)
50GET_SUBTARGETINFO_MACRO(HasBasicD, false, hasBasicD)
51GET_SUBTARGETINFO_MACRO(HasBasicF, false, hasBasicF)
52GET_SUBTARGETINFO_MACRO(HasDiv32, false, hasDiv32)
53GET_SUBTARGETINFO_MACRO(HasExtLASX, false, hasExtLASX)
54GET_SUBTARGETINFO_MACRO(HasExtLBT, false, hasExtLBT)
55GET_SUBTARGETINFO_MACRO(HasExtLSX, false, hasExtLSX)
56GET_SUBTARGETINFO_MACRO(HasExtLVZ, false, hasExtLVZ)
57GET_SUBTARGETINFO_MACRO(HasFrecipe, false, hasFrecipe)
58GET_SUBTARGETINFO_MACRO(HasLA32, false, hasLA32)
59GET_SUBTARGETINFO_MACRO(HasLA64, false, hasLA64)
60GET_SUBTARGETINFO_MACRO(HasLAMCAS, false, hasLAMCAS)
61GET_SUBTARGETINFO_MACRO(HasLAM_BH, false, hasLAM_BH)
62GET_SUBTARGETINFO_MACRO(HasLD_SEQ_SA, false, hasLD_SEQ_SA)
63GET_SUBTARGETINFO_MACRO(HasLaGlobalWithAbs, false, hasLaGlobalWithAbs)
64GET_SUBTARGETINFO_MACRO(HasLaGlobalWithPcrel, false, hasLaGlobalWithPcrel)
65GET_SUBTARGETINFO_MACRO(HasLaLocalWithAbs, false, hasLaLocalWithAbs)
66GET_SUBTARGETINFO_MACRO(HasLinkerRelax, false, hasLinkerRelax)
67GET_SUBTARGETINFO_MACRO(HasSCQ, false, hasSCQ)
68GET_SUBTARGETINFO_MACRO(HasUAL, false, hasUAL)
69GET_SUBTARGETINFO_MACRO(PreferWInst, false, preferWInst)
70
71#undef GET_SUBTARGETINFO_MACRO
72#endif // GET_SUBTARGETINFO_MACRO
73
74#ifdef GET_SUBTARGETINFO_MC_DESC
75#undef GET_SUBTARGETINFO_MC_DESC
76
77namespace llvm {
78
79// Sorted (by key) array of values for CPU features.
80extern const llvm::SubtargetFeatureKVStorage< 21, 1017> LoongArchFeatureKVStorage = {
81 {
82 { sizeof(SubtargetFeatureKV) * 21 + 1, sizeof(SubtargetFeatureKV) * 21 + 7, LoongArch::Feature32Bit, { { { 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } } },
83 { sizeof(SubtargetFeatureKV) * 20 + 56, sizeof(SubtargetFeatureKV) * 20 + 60, LoongArch::Feature32S, { { { 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } } },
84 { sizeof(SubtargetFeatureKV) * 19 + 102, sizeof(SubtargetFeatureKV) * 19 + 108, LoongArch::Feature64Bit, { { { 0x2ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } } },
85 { sizeof(SubtargetFeatureKV) * 18 + 157, sizeof(SubtargetFeatureKV) * 18 + 159, LoongArch::FeatureBasicD, { { { 0x10ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } } },
86 { sizeof(SubtargetFeatureKV) * 17 + 197, sizeof(SubtargetFeatureKV) * 17 + 203, LoongArch::FeatureDiv32, { { { 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } } },
87 { sizeof(SubtargetFeatureKV) * 16 + 277, sizeof(SubtargetFeatureKV) * 16 + 279, LoongArch::FeatureBasicF, { { { 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } } },
88 { sizeof(SubtargetFeatureKV) * 15 + 317, sizeof(SubtargetFeatureKV) * 15 + 325, LoongArch::FeatureFrecipe, { { { 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } } },
89 { sizeof(SubtargetFeatureKV) * 14 + 378, sizeof(SubtargetFeatureKV) * 14 + 397, LoongArch::LaGlobalWithAbs, { { { 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } } },
90 { sizeof(SubtargetFeatureKV) * 13 + 424, sizeof(SubtargetFeatureKV) * 13 + 445, LoongArch::LaGlobalWithPcrel, { { { 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } } },
91 { sizeof(SubtargetFeatureKV) * 12 + 474, sizeof(SubtargetFeatureKV) * 12 + 492, LoongArch::LaLocalWithAbs, { { { 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } } },
92 { sizeof(SubtargetFeatureKV) * 11 + 518, sizeof(SubtargetFeatureKV) * 11 + 525, LoongArch::FeatureLAM_BH, { { { 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } } },
93 { sizeof(SubtargetFeatureKV) * 10 + 585, sizeof(SubtargetFeatureKV) * 10 + 592, LoongArch::FeatureLAMCAS, { { { 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } } },
94 { sizeof(SubtargetFeatureKV) * 9 + 621, sizeof(SubtargetFeatureKV) * 9 + 626, LoongArch::FeatureExtLASX, { { { 0x100ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } } },
95 { sizeof(SubtargetFeatureKV) * 8 + 668, sizeof(SubtargetFeatureKV) * 8 + 672, LoongArch::FeatureExtLBT, { { { 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } } },
96 { sizeof(SubtargetFeatureKV) * 7 + 718, sizeof(SubtargetFeatureKV) * 7 + 728, LoongArch::FeatureLD_SEQ_SA, { { { 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } } },
97 { sizeof(SubtargetFeatureKV) * 6 + 784, sizeof(SubtargetFeatureKV) * 6 + 788, LoongArch::FeatureExtLSX, { { { 0x8ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } } },
98 { sizeof(SubtargetFeatureKV) * 5 + 820, sizeof(SubtargetFeatureKV) * 5 + 824, LoongArch::FeatureExtLVZ, { { { 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } } },
99 { sizeof(SubtargetFeatureKV) * 4 + 866, sizeof(SubtargetFeatureKV) * 4 + 880, LoongArch::TunePreferWInst, { { { 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } } },
100 { sizeof(SubtargetFeatureKV) * 3 + 914, sizeof(SubtargetFeatureKV) * 3 + 920, LoongArch::FeatureRelax, { { { 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } } },
101 { sizeof(SubtargetFeatureKV) * 2 + 945, sizeof(SubtargetFeatureKV) * 2 + 949, LoongArch::FeatureSCQ, { { { 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } } },
102 { sizeof(SubtargetFeatureKV) * 1 + 974, sizeof(SubtargetFeatureKV) * 1 + 978, LoongArch::FeatureUAL, { { { 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } } },
103 },
104 "\000" "32bit\000LA32 Basic Integer and Privilege Instruction Set\000" ""
105 "32s\000LA32 Standard Basic Instruction Extension\000" "64bit\000LA64 Ba"
106 "sic Integer and Privilege Instruction Set\000d\000'D' (Double-Precision"
107 " Floating-Point)\000div32\000Assume div.w[u] and mod.w[u] can handle in"
108 "puts that are not sign-extended\000f\000'F' (Single-Precision Floating-"
109 "Point)\000frecipe\000Support frecipe.{s/d} and frsqrte.{s/d} instructio"
110 "ns\000la-global-with-abs\000Expand la.global as la.abs\000la-global-wit"
111 "h-pcrel\000Expand la.global as la.pcrel\000la-local-with-abs\000Expand "
112 "la.local as la.abs\000lam-bh\000Support amswap[_db].{b/h} and amadd[_db"
113 "].{b/h} instructions\000lamcas\000Support amcas[_db].{b/h/w/d}\000lasx\000"
114 "'LASX' (Loongson Advanced SIMD Extension)\000lbt\000'LBT' (Loongson Bin"
115 "ary Translation Extension)\000ld-seq-sa\000Don't use a same-address loa"
116 "d-load barrier (dbar 0x700)\000lsx\000'LSX' (Loongson SIMD Extension)\000"
117 "lvz\000'LVZ' (Loongson Virtualization Extension)\000prefer-w-inst\000Pr"
118 "efer instructions with W suffix\000relax\000Enable Linker relaxation\000"
119 "scq\000Support sc.q instruction\000ual\000Allow memory accesses to be u"
120 "naligned\000"};
121
122#ifdef DBGFIELD
123#error "<target>GenSubtargetInfo.inc requires a DBGFIELD macro"
124#endif
125#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
126#define DBGFIELD(x) x,
127#define DBGVAL_OR_NULLPTR(x) x
128#else
129#define DBGFIELD(x)
130#define DBGVAL_OR_NULLPTR(x) nullptr
131#endif
132
133// ===============================================================
134// Data tables for the new per-operand machine model.
135
136static_assert(0 <= UINT8_MAX, "NumWriteProcResEntries does not fit in uint8_t");
137static_assert(0 <= UINT8_MAX, "NumWriteLatencyEntries does not fit in uint8_t");
138
139// {ProcResourceIdx, ReleaseAtCycle, AcquireAtCycle}
140extern const llvm::MCWriteProcResEntry LoongArchWriteProcResTable[] = {
141 { 0, 0, 0 }, // Invalid
142}; // LoongArchWriteProcResTable
143
144// {Cycles, WriteResourceID}
145extern const llvm::MCWriteLatencyEntry LoongArchWriteLatencyTable[] = {
146 { 0, 0}, // Invalid
147}; // LoongArchWriteLatencyTable
148
149// {UseIdx, WriteResourceID, Cycles}
150extern const llvm::MCReadAdvanceEntry LoongArchReadAdvanceTable[] = {
151 {0, 0, 0}, // Invalid
152}; // LoongArchReadAdvanceTable
153
154#ifdef __GNUC__
155#pragma GCC diagnostic push
156#pragma GCC diagnostic ignored "-Woverlength-strings"
157#endif
158static constexpr char LoongArchSchedClassNamesStorage[] =
159 "\0"
160 "InvalidSchedClass\0"
161 ;
162#ifdef __GNUC__
163#pragma GCC diagnostic pop
164#endif
165
166static constexpr llvm::StringTable
167LoongArchSchedClassNames = LoongArchSchedClassNamesStorage;
168
169extern const llvm::MCSchedModel LoongArchSchedModels[] = {
170{ // NoSchedModel
171 MCSchedModel::DefaultIssueWidth,
172 MCSchedModel::DefaultMicroOpBufferSize,
173 MCSchedModel::DefaultLoopMicroOpBufferSize,
174 MCSchedModel::DefaultLoadLatency,
175 MCSchedModel::DefaultHighLatency,
176 MCSchedModel::DefaultMispredictPenalty,
177 false, // PostRAScheduler
178 false, // CompleteModel
179 false, // EnableIntervals
180 0, // Processor ID
181 nullptr, nullptr, 0, 0, // No instruction-level machine model.
182 DBGVAL_OR_NULLPTR(&LoongArchSchedClassNames), // SchedClassNames
183 nullptr, // No Itinerary
184 nullptr // No extra processor descriptor
185 },
186};
187
188#undef DBGFIELD
189
190#undef DBGVAL_OR_NULLPTR
191
192// Sorted (by key) array of values for CPU subtype.
193extern const llvm::SubtargetSubTypeKVStorage< 7, 72> LoongArchSubTypeKVStorage = {
194 {
195 { sizeof(SubtargetSubTypeKV) * 7 + 1, { { { 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } }, { { { 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } }, 0 },
196 { sizeof(SubtargetSubTypeKV) * 6 + 9, { { { 0x1ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } }, { { { 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } }, 0 },
197 { sizeof(SubtargetSubTypeKV) * 5 + 22, { { { 0x10104ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } }, { { { 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } }, 0 },
198 { sizeof(SubtargetSubTypeKV) * 4 + 35, { { { 0x102c4ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } }, { { { 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } }, 0 },
199 { sizeof(SubtargetSubTypeKV) * 3 + 41, { { { 0x1bee4ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } }, { { { 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } }, 0 },
200 { sizeof(SubtargetSubTypeKV) * 2 + 47, { { { 0x1ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } }, { { { 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } }, 0 },
201 { sizeof(SubtargetSubTypeKV) * 1 + 59, { { { 0x1000cULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } }, { { { 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, 0x0ULL, } } }, 0 },
202 },
203 "\000generic\000generic-la32\000generic-la64\000la464\000la664\000loonga"
204 "rch32\000loongarch64\000"};
205
206namespace LoongArch_MC {
207
208unsigned resolveVariantSchedClassImpl(unsigned SchedClass,
209 const MCInst *MI, const MCInstrInfo *MCII, const MCSubtargetInfo &STI, unsigned CPUID) {
210 // Don't know how to resolve this scheduling class.
211 return 0;
212}
213
214} // namespace LoongArch_MC
215struct LoongArchGenMCSubtargetInfo : public MCSubtargetInfo {
216 LoongArchGenMCSubtargetInfo(const Triple &TT,
217 StringRef CPU, StringRef TuneCPU, StringRef FS,
218 StringTable PN,
219 ArrayRef<SubtargetFeatureKV> PF,
220 ArrayRef<SubtargetSubTypeKV> PD,
221 const MCSchedModel *PSM,
222 const MCWriteProcResEntry *WPR,
223 const MCWriteLatencyEntry *WL,
224 const MCReadAdvanceEntry *RA, const InstrStage *IS,
225 const unsigned *OC, const unsigned *FP) :
226 MCSubtargetInfo(TT, CPU, TuneCPU, FS, PN, PF, PD, PSM,
227 WPR, WL, RA, IS, OC, FP) { }
228
229 unsigned resolveVariantSchedClass(unsigned SchedClass,
230 const MCInst *MI, const MCInstrInfo *MCII,
231 unsigned CPUID) const final {
232 return LoongArch_MC::resolveVariantSchedClassImpl(SchedClass, MI, MCII, *this, CPUID);
233 }
234 unsigned getHwModeSet() const final;
235 unsigned getHwMode(enum HwModeType type = HwMode_Default) const final;
236};
237unsigned LoongArchGenMCSubtargetInfo::getHwModeSet() const {
238 [[maybe_unused]] const FeatureBitset &FB = getFeatureBits();
239 // Collect HwModes and store them as a bit set.
240 unsigned Modes = 0;
241 if (FB[LoongArch::Feature64Bit]) Modes |= (1 << 0);
242 return Modes;
243}
244unsigned LoongArchGenMCSubtargetInfo::getHwMode(enum HwModeType type) const {
245 unsigned Modes = getHwModeSet();
246
247 if (!Modes)
248 return Modes;
249
250 switch (type) {
251 case HwMode_Default:
252 return llvm::countr_zero(Modes) + 1;
253 case HwMode_ValueType:
254 Modes &= 1;
255 if (!Modes)
256 return Modes;
257 if (!llvm::has_single_bit<unsigned>(Modes))
258 llvm_unreachable("Two or more HwModes for ValueType were found!");
259 return llvm::countr_zero(Modes) + 1;
260 case HwMode_RegInfo:
261 Modes &= 1;
262 if (!Modes)
263 return Modes;
264 if (!llvm::has_single_bit<unsigned>(Modes))
265 llvm_unreachable("Two or more HwModes for RegInfo were found!");
266 return llvm::countr_zero(Modes) + 1;
267 case HwMode_EncodingInfo:
268 // No HwMode for EncodingInfo.
269 return 0;
270 }
271 llvm_unreachable("unexpected HwModeType");
272 return 0; // should not get here
273}
274
275static inline MCSubtargetInfo *createLoongArchMCSubtargetInfoImpl(const Triple &TT, StringRef CPU, StringRef TuneCPU, StringRef FS) {
276 return new LoongArchGenMCSubtargetInfo(TT, CPU, TuneCPU, FS, StringTable(LoongArchSubTypeKVStorage.Strings), LoongArchFeatureKVStorage.Features, LoongArchSubTypeKVStorage.SubTypes, LoongArchSchedModels,
277 LoongArchWriteProcResTable, LoongArchWriteLatencyTable, LoongArchReadAdvanceTable,
278 nullptr, nullptr, nullptr);
279}
280
281
282} // namespace llvm
283
284#endif // GET_SUBTARGETINFO_MC_DESC
285
286#ifdef GET_SUBTARGETINFO_TARGET_DESC
287#undef GET_SUBTARGETINFO_TARGET_DESC
288
289#include "llvm/ADT/BitmaskEnum.h"
290#include "llvm/Support/Debug.h"
291#include "llvm/Support/raw_ostream.h"
292
293// ParseSubtargetFeatures - Parses features string setting specified
294// subtarget options.
295void llvm::LoongArchSubtarget::ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS) {
296 LLVM_DEBUG(dbgs() << "\nFeatures:" << FS);
297 LLVM_DEBUG(dbgs() << "\nCPU:" << CPU);
298 LLVM_DEBUG(dbgs() << "\nTuneCPU:" << TuneCPU << "\n\n");
299 InitMCProcessorInfo(CPU, TuneCPU, FS);
300 const FeatureBitset &Bits = getFeatureBits();
301 if (Bits[LoongArch::Feature32Bit]) HasLA32 = true;
302 if (Bits[LoongArch::Feature32S]) Has32S = true;
303 if (Bits[LoongArch::Feature64Bit]) HasLA64 = true;
304 if (Bits[LoongArch::FeatureBasicD]) HasBasicD = true;
305 if (Bits[LoongArch::FeatureBasicF]) HasBasicF = true;
306 if (Bits[LoongArch::FeatureDiv32]) HasDiv32 = true;
307 if (Bits[LoongArch::FeatureExtLASX]) HasExtLASX = true;
308 if (Bits[LoongArch::FeatureExtLBT]) HasExtLBT = true;
309 if (Bits[LoongArch::FeatureExtLSX]) HasExtLSX = true;
310 if (Bits[LoongArch::FeatureExtLVZ]) HasExtLVZ = true;
311 if (Bits[LoongArch::FeatureFrecipe]) HasFrecipe = true;
312 if (Bits[LoongArch::FeatureLAMCAS]) HasLAMCAS = true;
313 if (Bits[LoongArch::FeatureLAM_BH]) HasLAM_BH = true;
314 if (Bits[LoongArch::FeatureLD_SEQ_SA]) HasLD_SEQ_SA = true;
315 if (Bits[LoongArch::FeatureRelax]) HasLinkerRelax = true;
316 if (Bits[LoongArch::FeatureSCQ]) HasSCQ = true;
317 if (Bits[LoongArch::FeatureUAL]) HasUAL = true;
318 if (Bits[LoongArch::LaGlobalWithAbs]) HasLaGlobalWithAbs = true;
319 if (Bits[LoongArch::LaGlobalWithPcrel]) HasLaGlobalWithPcrel = true;
320 if (Bits[LoongArch::LaLocalWithAbs]) HasLaLocalWithAbs = true;
321 if (Bits[LoongArch::TunePreferWInst]) PreferWInst = true;
322}
323
324#endif // GET_SUBTARGETINFO_TARGET_DESC
325
326#ifdef GET_SUBTARGETINFO_HEADER
327#undef GET_SUBTARGETINFO_HEADER
328
329namespace llvm {
330
331class DFAPacketizer;
332namespace LoongArch_MC {
333
334unsigned resolveVariantSchedClassImpl(unsigned SchedClass, const MCInst *MI, const MCInstrInfo *MCII, const MCSubtargetInfo &STI, unsigned CPUID);
335
336} // namespace LoongArch_MC
337struct LoongArchGenSubtargetInfo : public TargetSubtargetInfo {
338 explicit LoongArchGenSubtargetInfo(const Triple &TT, StringRef CPU, StringRef TuneCPU, StringRef FS);
339public:
340 unsigned resolveSchedClass(unsigned SchedClass, const MachineInstr *DefMI, const TargetSchedModel *SchedModel) const final;
341 unsigned resolveVariantSchedClass(unsigned SchedClass, const MCInst *MI, const MCInstrInfo *MCII, unsigned CPUID) const final;
342 DFAPacketizer *createDFAPacketizer(const InstrItineraryData *IID) const;
343 enum class LoongArchHwModeBits : unsigned {
344 DefaultMode = 0,
345 LA64 = (1 << 0),
346
347 LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/LA64),
348 };
349 unsigned getHwModeSet() const final;
350 unsigned getHwMode(enum HwModeType type = HwMode_Default) const final;
351 const FeatureBitset &getInlineIgnoreFeatures() const override;
352 const FeatureBitset &getInlineInverseFeatures() const override;
353 const FeatureBitset &getInlineMustMatchFeatures() const override;
354};
355
356} // namespace llvm
357
358#endif // GET_SUBTARGETINFO_HEADER
359
360#ifdef GET_SUBTARGETINFO_CTOR
361#undef GET_SUBTARGETINFO_CTOR
362
363#include "llvm/CodeGen/TargetSchedule.h"
364
365namespace llvm {
366
367extern const llvm::StringRef LoongArchNames[];
368extern const llvm::SubtargetFeatureKVStorage<21, 1017> LoongArchFeatureKVStorage;
369extern const llvm::SubtargetSubTypeKVStorage<7, 72> LoongArchSubTypeKVStorage;
370extern const llvm::MCSchedModel LoongArchSchedModels[];
371extern const llvm::MCWriteProcResEntry LoongArchWriteProcResTable[];
372extern const llvm::MCWriteLatencyEntry LoongArchWriteLatencyTable[];
373extern const llvm::MCReadAdvanceEntry LoongArchReadAdvanceTable[];
374LoongArchGenSubtargetInfo::LoongArchGenSubtargetInfo(const Triple &TT, StringRef CPU, StringRef TuneCPU, StringRef FS)
375 : TargetSubtargetInfo(TT, CPU, TuneCPU, FS, StringTable(LoongArchSubTypeKVStorage.Strings), ArrayRef(LoongArchFeatureKVStorage.Features), ArrayRef(LoongArchSubTypeKVStorage.SubTypes), LoongArchSchedModels,
376 LoongArchWriteProcResTable, LoongArchWriteLatencyTable, LoongArchReadAdvanceTable,
377 nullptr, nullptr, nullptr) {}
378
379unsigned LoongArchGenSubtargetInfo
380::resolveSchedClass(unsigned SchedClass, const MachineInstr *MI, const TargetSchedModel *SchedModel) const {
381 report_fatal_error("Expected a variant SchedClass");
382} // LoongArchGenSubtargetInfo::resolveSchedClass
383
384unsigned LoongArchGenSubtargetInfo
385::resolveVariantSchedClass(unsigned SchedClass, const MCInst *MI, const MCInstrInfo *MCII, unsigned CPUID) const {
386 return LoongArch_MC::resolveVariantSchedClassImpl(SchedClass, MI, MCII, *this, CPUID);
387} // LoongArchGenSubtargetInfo::resolveVariantSchedClass
388
389unsigned LoongArchGenSubtargetInfo::getHwModeSet() const {
390 [[maybe_unused]] const auto *Subtarget =
391 static_cast<const LoongArchSubtarget *>(this);
392 // Collect HwModes and store them as a bit set.
393 unsigned Modes = 0;
394 if ((Subtarget->is64Bit())) Modes |= (1 << 0);
395 return Modes;
396}
397unsigned LoongArchGenSubtargetInfo::getHwMode(enum HwModeType type) const {
398 unsigned Modes = getHwModeSet();
399
400 if (!Modes)
401 return Modes;
402
403 switch (type) {
404 case HwMode_Default:
405 return llvm::countr_zero(Modes) + 1;
406 case HwMode_ValueType:
407 Modes &= 1;
408 if (!Modes)
409 return Modes;
410 if (!llvm::has_single_bit<unsigned>(Modes))
411 llvm_unreachable("Two or more HwModes for ValueType were found!");
412 return llvm::countr_zero(Modes) + 1;
413 case HwMode_RegInfo:
414 Modes &= 1;
415 if (!Modes)
416 return Modes;
417 if (!llvm::has_single_bit<unsigned>(Modes))
418 llvm_unreachable("Two or more HwModes for RegInfo were found!");
419 return llvm::countr_zero(Modes) + 1;
420 case HwMode_EncodingInfo:
421 // No HwMode for EncodingInfo.
422 return 0;
423 }
424 llvm_unreachable("unexpected HwModeType");
425 return 0; // should not get here
426}
427const FeatureBitset &LoongArchGenSubtargetInfo::getInlineIgnoreFeatures() const {
428 static constexpr FeatureBitset Features = {
429 };
430 return Features;
431}
432
433const FeatureBitset &LoongArchGenSubtargetInfo::getInlineInverseFeatures() const {
434 static constexpr FeatureBitset Features = {
435 };
436 return Features;
437}
438
439const FeatureBitset &LoongArchGenSubtargetInfo::getInlineMustMatchFeatures() const {
440 static constexpr FeatureBitset Features = {
441 };
442 return Features;
443}
444
445
446} // namespace llvm
447
448#endif // GET_SUBTARGETINFO_CTOR
449
450#ifdef GET_STIPREDICATE_DECLS_FOR_MC_ANALYSIS
451#undef GET_STIPREDICATE_DECLS_FOR_MC_ANALYSIS
452
453
454#endif // GET_STIPREDICATE_DECLS_FOR_MC_ANALYSIS
455
456#ifdef GET_STIPREDICATE_DEFS_FOR_MC_ANALYSIS
457#undef GET_STIPREDICATE_DEFS_FOR_MC_ANALYSIS
458
459
460#endif // GET_STIPREDICATE_DEFS_FOR_MC_ANALYSIS
461
462