LLVM 20.0.0git
CSKYTargetParser.h
Go to the documentation of this file.
1//===-- CSKYTargetParser - Parser for CSKY target features --------*- C++
2//-*-===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements a target parser to recognise CSKY hardware features
11// such as FPU/CPU/ARCH/extensions and specific support such as HWDIV.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_TARGETPARSER_CSKYTARGETPARSER_H
16#define LLVM_TARGETPARSER_CSKYTARGETPARSER_H
17
19#include <vector>
20
21namespace llvm {
22class StringRef;
23
24namespace CSKY {
25
26// Arch extension modifiers for CPUs.
30 AEK_FPUV2SF = 1 << 1,
31 AEK_FPUV2DF = 1 << 2,
32 AEK_FDIVDU = 1 << 3,
33 AEK_FPUV3HI = 1 << 4,
34 AEK_FPUV3HF = 1 << 5,
35 AEK_FPUV3SF = 1 << 6,
36 AEK_FPUV3DF = 1 << 7,
37 AEK_FLOATE1 = 1 << 8,
38 AEK_FLOAT1E2 = 1 << 9,
39 AEK_FLOAT1E3 = 1 << 10,
40 AEK_FLOAT3E4 = 1 << 11,
41 AEK_FLOAT7E60 = 1 << 12,
42 AEK_HWDIV = 1 << 13,
43 AEK_STLD = 1 << 14,
44 AEK_PUSHPOP = 1 << 15,
45 AEK_EDSP = 1 << 16,
46 AEK_DSP1E2 = 1 << 17,
47 AEK_DSPE60 = 1 << 18,
48 AEK_DSPV2 = 1 << 19,
49 AEK_DSPSILAN = 1 << 20,
50 AEK_ELRW = 1 << 21,
51 AEK_TRUST = 1 << 22,
52 AEK_JAVA = 1 << 23,
53 AEK_CACHE = 1 << 24,
54 AEK_NVIC = 1 << 25,
55 AEK_DOLOOP = 1 << 26,
56 AEK_HIGHREG = 1 << 27,
57 AEK_SMART = 1 << 28,
58 AEK_VDSP2E3 = 1 << 29,
59 AEK_VDSP2E60F = 1 << 30,
60 AEK_VDSPV2 = 1ULL << 31,
61 AEK_HARDTP = 1ULL << 32,
62 AEK_SOFTTP = 1ULL << 33,
63 AEK_ISTACK = 1ULL << 34,
64 AEK_CONSTPOOL = 1ULL << 35,
65 AEK_STACKSIZE = 1ULL << 36,
66 AEK_CCRT = 1ULL << 37,
67 AEK_VDSPV1 = 1ULL << 38,
68 AEK_E1 = 1ULL << 39,
69 AEK_E2 = 1ULL << 40,
70 AEK_2E3 = 1ULL << 41,
71 AEK_MP = 1ULL << 42,
72 AEK_3E3R1 = 1ULL << 43,
73 AEK_3E3R2 = 1ULL << 44,
74 AEK_3E3R3 = 1ULL << 45,
75 AEK_3E7 = 1ULL << 46,
76 AEK_MP1E2 = 1ULL << 47,
77 AEK_7E10 = 1ULL << 48,
78 AEK_10E60 = 1ULL << 49
79
80};
81
82// Arch extension modifiers for CPUs.
94};
95// FPU names.
97#define CSKY_FPU(NAME, KIND, VERSION) KIND,
98#include "CSKYTargetParser.def"
101
102// FPU Version
103enum class FPUVersion {
104 NONE,
105 FPV2,
106 FPV3,
107};
108
109// Arch names.
110enum class ArchKind {
111#define CSKY_ARCH(NAME, ID, ARCH_BASE_EXT) ID,
112#include "CSKYTargetParser.def"
113};
114
115// List of Arch Extension names.
116// FIXME: TableGen this.
117struct ExtName {
118 const char *NameCStr;
121 const char *Feature;
122 const char *NegFeature;
123
125};
126
128#define CSKY_ARCH_EXT_NAME(NAME, ID, FEATURE, NEGFEATURE) \
129 {NAME, sizeof(NAME) - 1, ID, FEATURE, NEGFEATURE},
130#include "CSKYTargetParser.def"
131};
132
133// List of CPU names and their arches.
134template <typename T> struct CpuNames {
135 const char *NameCStr;
139
141};
143#define CSKY_CPU_NAME(NAME, ARCH_ID, DEFAULT_EXT) \
144 {NAME, sizeof(NAME) - 1, CSKY::ArchKind::ARCH_ID, DEFAULT_EXT},
145#include "llvm/TargetParser/CSKYTargetParser.def"
146};
147
148// FIXME: TableGen this.
149// The entries must appear in the order listed in CSKY::CSKYFPUKind for correct
150// indexing
151struct FPUName {
152 const char *NameCStr;
156
158};
159
160static const FPUName FPUNames[] = {
161#define CSKY_FPU(NAME, KIND, VERSION) {NAME, sizeof(NAME) - 1, KIND, VERSION},
162#include "llvm/TargetParser/CSKYTargetParser.def"
163};
164
165// List of canonical arch names.
166template <typename T> struct ArchNames {
167 const char *NameCStr;
172};
174#define CSKY_ARCH(NAME, ID, ARCH_BASE_EXT) \
175 {NAME, sizeof(NAME) - 1, CSKY::ArchKind::ID, ARCH_BASE_EXT},
176#include "llvm/TargetParser/CSKYTargetParser.def"
177};
178
185 std::vector<StringRef> &Features);
186
187// Information by ID
188StringRef getFPUName(unsigned FPUKind);
189FPUVersion getFPUVersion(unsigned FPUKind);
190
191bool getFPUFeatures(CSKYFPUKind Kind, std::vector<StringRef> &Features);
192
193// Parser
198
199} // namespace CSKY
200
201} // namespace llvm
202
203#endif
static cl::opt< std::set< SPIRV::Extension::Extension >, false, SPIRVExtensionsParser > Extensions("spirv-ext", cl::desc("Specify list of enabled SPIR-V extensions"))
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:586
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
StringRef getFPUName(unsigned FPUKind)
StringRef getArchExtFeature(StringRef ArchExt)
bool getExtensionFeatures(uint64_t Extensions, std::vector< StringRef > &Features)
void fillValidCPUArchList(SmallVectorImpl< StringRef > &Values)
const ArchNames< CSKY::ArchKind > ARCHNames[]
bool getFPUFeatures(CSKYFPUKind Kind, std::vector< StringRef > &Features)
uint64_t parseArchExt(StringRef ArchExt)
const CpuNames< CSKY::ArchKind > CPUNames[]
FPUVersion getFPUVersion(unsigned FPUKind)
ArchKind parseCPUArch(StringRef CPU)
ArchKind parseArch(StringRef Arch)
StringRef getDefaultCPU(StringRef Arch)
static const FPUName FPUNames[]
const CSKY::ExtName CSKYARCHExtNames[]
StringRef getArchExtName(uint64_t ArchExtKind)
StringRef getArchName(ArchKind AK)
uint64_t getDefaultExtensions(StringRef CPU)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
StringRef getName() const
StringRef getName() const
StringRef getName() const
StringRef getName() const