LLVM  16.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_SUPPORT_CSKYTARGETPARSER_H
16 #define LLVM_SUPPORT_CSKYTARGETPARSER_H
17 
18 #include "llvm/ADT/Triple.h"
19 #include <vector>
20 
21 namespace llvm {
22 class StringRef;
23 
24 namespace CSKY {
25 
26 // Arch extension modifiers for CPUs.
29  AEK_NONE = 1,
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"
100 };
101 
102 // FPU Version
103 enum class FPUVersion {
104  NONE,
105  FPV2,
106  FPV3,
107 };
108 
109 // Arch names.
110 enum 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.
117 struct ExtName {
118  const char *NameCStr;
119  size_t NameLength;
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.
134 template <typename T> struct CpuNames {
135  const char *NameCStr;
136  size_t NameLength;
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/Support/CSKYTargetParser.def"
146 };
147 
148 // FIXME: TableGen this.
149 // The entries must appear in the order listed in CSKY::CSKYFPUKind for correct
150 // indexing
151 struct FPUName {
152  const char *NameCStr;
153  size_t NameLength;
156 
158 };
159 
160 static const FPUName FPUNames[] = {
161 #define CSKY_FPU(NAME, KIND, VERSION) {NAME, sizeof(NAME) - 1, KIND, VERSION},
162 #include "llvm/Support/CSKYTargetParser.def"
163 };
164 
165 // List of canonical arch names.
166 template <typename T> struct ArchNames {
167  const char *NameCStr;
168  size_t NameLength;
169  T ID;
172 };
174 #define CSKY_ARCH(NAME, ID, ARCH_BASE_EXT) \
175  {NAME, sizeof(NAME) - 1, CSKY::ArchKind::ID, ARCH_BASE_EXT},
176 #include "llvm/Support/CSKYTargetParser.def"
177 };
178 
185  std::vector<StringRef> &Features);
186 
187 // Information by ID
188 StringRef getFPUName(unsigned FPUKind);
190 
191 bool getFPUFeatures(CSKYFPUKind Kind, std::vector<StringRef> &Features);
192 
193 // Parser
198 
199 } // namespace CSKY
200 
201 } // namespace llvm
202 
203 #endif
llvm::CSKY::AEK_VDSPV1
@ AEK_VDSPV1
Definition: CSKYTargetParser.h:67
llvm::CSKY::AEK_NVIC
@ AEK_NVIC
Definition: CSKYTargetParser.h:54
llvm::CSKY::FPUName::NameLength
size_t NameLength
Definition: CSKYTargetParser.h:153
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::CSKY::AEK_FLOAT7E60
@ AEK_FLOAT7E60
Definition: CSKYTargetParser.h:41
llvm::ARM::FPUKind
FPUKind
Definition: ARMTargetParser.h:121
llvm::CSKY::AEK_3E3R1
@ AEK_3E3R1
Definition: CSKYTargetParser.h:72
llvm::CSKY::AEK_MP
@ AEK_MP
Definition: CSKYTargetParser.h:71
llvm::CSKY::AEK_STACKSIZE
@ AEK_STACKSIZE
Definition: CSKYTargetParser.h:65
llvm::CSKY::FPUName::NameCStr
const char * NameCStr
Definition: CSKYTargetParser.h:152
llvm::CSKY::MAEK_MP1E2
@ MAEK_MP1E2
Definition: CSKYTargetParser.h:91
llvm::CSKY::AEK_DOLOOP
@ AEK_DOLOOP
Definition: CSKYTargetParser.h:55
llvm::CSKY::AEK_PUSHPOP
@ AEK_PUSHPOP
Definition: CSKYTargetParser.h:44
llvm::CSKY::AEK_7E10
@ AEK_7E10
Definition: CSKYTargetParser.h:77
llvm::CSKY::AEK_E1
@ AEK_E1
Definition: CSKYTargetParser.h:68
llvm::CSKY::CSKYARCHExtNames
const CSKY::ExtName CSKYARCHExtNames[]
Definition: CSKYTargetParser.h:127
llvm::CSKY::MAEK_3E3R2
@ MAEK_3E3R2
Definition: CSKYTargetParser.h:89
llvm::CSKY::AEK_CONSTPOOL
@ AEK_CONSTPOOL
Definition: CSKYTargetParser.h:64
llvm::CSKY::parseCPUArch
ArchKind parseCPUArch(StringRef CPU)
Definition: CSKYTargetParser.cpp:100
llvm::CSKY::AEK_JAVA
@ AEK_JAVA
Definition: CSKYTargetParser.h:52
llvm::CSKY::AEK_HARDTP
@ AEK_HARDTP
Definition: CSKYTargetParser.h:61
llvm::CSKY::CpuNames::getName
StringRef getName() const
Definition: CSKYTargetParser.h:140
llvm::CSKY::CpuNames
Definition: CSKYTargetParser.h:134
llvm::CSKY::getArchName
StringRef getArchName(ArchKind AK)
Definition: CSKYTargetParser.cpp:75
llvm::CSKY::ArchKind
ArchKind
Definition: CSKYTargetParser.h:110
llvm::CSKY::AEK_FPUV3DF
@ AEK_FPUV3DF
Definition: CSKYTargetParser.h:36
llvm::CSKY::AEK_FPUV2DF
@ AEK_FPUV2DF
Definition: CSKYTargetParser.h:31
llvm::CSKY::CpuNames::ArchID
T ArchID
Definition: CSKYTargetParser.h:137
llvm::CSKY::AEK_HWDIV
@ AEK_HWDIV
Definition: CSKYTargetParser.h:42
llvm::AArch64::Extensions
constexpr ExtensionInfo Extensions[]
Definition: AArch64TargetParser.h:99
llvm::CSKY::ExtName::NameCStr
const char * NameCStr
Definition: CSKYTargetParser.h:118
T
#define T
Definition: Mips16ISelLowering.cpp:341
llvm::CSKY::AEK_MP1E2
@ AEK_MP1E2
Definition: CSKYTargetParser.h:76
llvm::CSKY::AEK_FPUV3HF
@ AEK_FPUV3HF
Definition: CSKYTargetParser.h:34
llvm::CSKY::AEK_FLOAT1E3
@ AEK_FLOAT1E3
Definition: CSKYTargetParser.h:39
llvm::CSKY::CPUNames
const CpuNames< CSKY::ArchKind > CPUNames[]
Definition: CSKYTargetParser.h:142
llvm::CSKY::AEK_3E3R2
@ AEK_3E3R2
Definition: CSKYTargetParser.h:73
llvm::CSKY::MAEK_2E3
@ MAEK_2E3
Definition: CSKYTargetParser.h:86
llvm::CSKY::fillValidCPUArchList
void fillValidCPUArchList(SmallVectorImpl< StringRef > &Values)
Definition: CSKYTargetParser.cpp:117
llvm::CSKY::FPUVersion::FPV3
@ FPV3
llvm::CSKY::AEK_ISTACK
@ AEK_ISTACK
Definition: CSKYTargetParser.h:63
llvm::CSKY::AEK_ELRW
@ AEK_ELRW
Definition: CSKYTargetParser.h:50
llvm::CSKY::AEK_TRUST
@ AEK_TRUST
Definition: CSKYTargetParser.h:51
llvm::CSKY::CpuNames::NameLength
size_t NameLength
Definition: CSKYTargetParser.h:136
llvm::CSKY::getDefaultExtensions
uint64_t getDefaultExtensions(StringRef CPU)
Definition: CSKYTargetParser.cpp:136
llvm::CSKY::AEK_NONE
@ AEK_NONE
Definition: CSKYTargetParser.h:29
llvm::CSKY::MAEK_7E10
@ MAEK_7E10
Definition: CSKYTargetParser.h:92
llvm::CSKY::AEK_DSPSILAN
@ AEK_DSPSILAN
Definition: CSKYTargetParser.h:49
llvm::CSKY::AEK_SOFTTP
@ AEK_SOFTTP
Definition: CSKYTargetParser.h:62
llvm::CSKY::MAEK_E2
@ MAEK_E2
Definition: CSKYTargetParser.h:85
llvm::CSKY::AEK_10E60
@ AEK_10E60
Definition: CSKYTargetParser.h:78
llvm::CSKY::parseArch
ArchKind parseArch(StringRef Arch)
Definition: CSKYTargetParser.cpp:91
llvm::CSKY::AEK_VDSP2E60F
@ AEK_VDSP2E60F
Definition: CSKYTargetParser.h:59
llvm::CSKY::getFPUVersion
FPUVersion getFPUVersion(unsigned FPUKind)
Definition: CSKYTargetParser.cpp:130
llvm::CSKY::FPUVersion::NONE
@ NONE
llvm::CSKY::AEK_DSPV2
@ AEK_DSPV2
Definition: CSKYTargetParser.h:48
llvm::CSKY::MAEK_3E3R1
@ MAEK_3E3R1
Definition: CSKYTargetParser.h:88
llvm::CSKY::ExtName::NameLength
size_t NameLength
Definition: CSKYTargetParser.h:119
llvm::CSKY::ArchNames
Definition: CSKYTargetParser.h:166
llvm::CSKY::AEK_VDSPV2
@ AEK_VDSPV2
Definition: CSKYTargetParser.h:60
llvm::CSKY::ExtName::ID
uint64_t ID
Definition: CSKYTargetParser.h:120
llvm::CSKY::FPUVersion::FPV2
@ FPV2
llvm::CSKY::AEK_STLD
@ AEK_STLD
Definition: CSKYTargetParser.h:43
llvm::CSKY::FPUName::getName
StringRef getName() const
Definition: CSKYTargetParser.h:157
llvm::CSKY::getArchExtName
StringRef getArchExtName(uint64_t ArchExtKind)
Definition: CSKYTargetParser.cpp:145
llvm::CSKY::getExtensionFeatures
bool getExtensionFeatures(uint64_t Extensions, std::vector< StringRef > &Features)
Definition: CSKYTargetParser.cpp:170
llvm::CSKY::ExtName
Definition: CSKYTargetParser.h:117
uint64_t
llvm::CSKY::AEK_3E7
@ AEK_3E7
Definition: CSKYTargetParser.h:75
llvm::CSKY::getDefaultCPU
StringRef getDefaultCPU(StringRef Arch)
Definition: CSKYTargetParser.cpp:80
llvm::CSKY::ExtName::getName
StringRef getName() const
Definition: CSKYTargetParser.h:124
llvm::CSKY::MAEK_MP
@ MAEK_MP
Definition: CSKYTargetParser.h:87
llvm::CSKY::AEK_DSP1E2
@ AEK_DSP1E2
Definition: CSKYTargetParser.h:46
llvm::CSKY::AEK_HIGHREG
@ AEK_HIGHREG
Definition: CSKYTargetParser.h:56
llvm::CSKY::getArchExtFeature
StringRef getArchExtFeature(StringRef ArchExt)
Definition: CSKYTargetParser.cpp:160
llvm::CSKY::AEK_E2
@ AEK_E2
Definition: CSKYTargetParser.h:69
llvm::CSKY::AEK_VDSP2E3
@ AEK_VDSP2E3
Definition: CSKYTargetParser.h:58
llvm::CSKY::ExtName::Feature
const char * Feature
Definition: CSKYTargetParser.h:121
llvm::CSKY::ArchNames::NameCStr
const char * NameCStr
Definition: CSKYTargetParser.h:167
llvm::CSKY::AEK_FLOAT3E4
@ AEK_FLOAT3E4
Definition: CSKYTargetParser.h:40
llvm::CSKY::AEK_EDSP
@ AEK_EDSP
Definition: CSKYTargetParser.h:45
llvm::CSKY::AEK_FDIVDU
@ AEK_FDIVDU
Definition: CSKYTargetParser.h:32
llvm::CSKY::ARCHNames
const ArchNames< CSKY::ArchKind > ARCHNames[]
Definition: CSKYTargetParser.h:173
llvm::CSKY::MultiArchExtKind
MultiArchExtKind
Definition: CSKYTargetParser.h:83
llvm::CSKY::CpuNames::NameCStr
const char * NameCStr
Definition: CSKYTargetParser.h:135
Triple.h
llvm::CSKY::AEK_FLOAT1E2
@ AEK_FLOAT1E2
Definition: CSKYTargetParser.h:38
llvm::CSKY::AEK_FPUV3HI
@ AEK_FPUV3HI
Definition: CSKYTargetParser.h:33
llvm::CSKY::FPUName::FPUVer
FPUVersion FPUVer
Definition: CSKYTargetParser.h:155
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
llvm::CSKY::AEK_FPUV3SF
@ AEK_FPUV3SF
Definition: CSKYTargetParser.h:35
llvm::CSKY::AEK_CACHE
@ AEK_CACHE
Definition: CSKYTargetParser.h:53
llvm::CSKY::ArchExtKind
ArchExtKind
Definition: CSKYTargetParser.h:27
llvm::CSKY::CSKYFPUKind
CSKYFPUKind
Definition: CSKYTargetParser.h:96
llvm::CSKY::FPUName
Definition: CSKYTargetParser.h:151
llvm::CSKY::AEK_FPUV2SF
@ AEK_FPUV2SF
Definition: CSKYTargetParser.h:30
llvm::CSKY::AEK_SMART
@ AEK_SMART
Definition: CSKYTargetParser.h:57
llvm::CSKY::AEK_2E3
@ AEK_2E3
Definition: CSKYTargetParser.h:70
llvm::CSKY::getFPUFeatures
bool getFPUFeatures(CSKYFPUKind Kind, std::vector< StringRef > &Features)
Definition: CSKYTargetParser.cpp:20
llvm::CSKY::AEK_INVALID
@ AEK_INVALID
Definition: CSKYTargetParser.h:28
llvm::CSKY::FPUNames
static const FPUName FPUNames[]
Definition: CSKYTargetParser.h:160
llvm::CSKY::CpuNames::defaultExt
uint64_t defaultExt
Definition: CSKYTargetParser.h:138
llvm::CSKY::ArchNames::getName
StringRef getName() const
Definition: CSKYTargetParser.h:171
llvm::CSKY::FPUVersion
FPUVersion
Definition: CSKYTargetParser.h:103
llvm::CSKY::AEK_FLOATE1
@ AEK_FLOATE1
Definition: CSKYTargetParser.h:37
llvm::CSKY::MAEK_E1
@ MAEK_E1
Definition: CSKYTargetParser.h:84
llvm::CSKY::MAEK_3E7
@ MAEK_3E7
Definition: CSKYTargetParser.h:90
llvm::CSKY::ExtName::NegFeature
const char * NegFeature
Definition: CSKYTargetParser.h:122
llvm::SmallVectorImpl< StringRef >
llvm::CSKY::FPUName::ID
CSKYFPUKind ID
Definition: CSKYTargetParser.h:154
llvm::CSKY::ArchNames::archBaseExt
uint64_t archBaseExt
Definition: CSKYTargetParser.h:170
llvm::CSKY::AEK_CCRT
@ AEK_CCRT
Definition: CSKYTargetParser.h:66
llvm::CSKY::MAEK_10E60
@ MAEK_10E60
Definition: CSKYTargetParser.h:93
llvm::CSKY::getFPUName
StringRef getFPUName(unsigned FPUKind)
Definition: CSKYTargetParser.cpp:124
llvm::CSKY::AEK_3E3R3
@ AEK_3E3R3
Definition: CSKYTargetParser.h:74
llvm::CSKY::parseArchExt
uint64_t parseArchExt(StringRef ArchExt)
Definition: CSKYTargetParser.cpp:109
llvm::CSKY::ArchNames::NameLength
size_t NameLength
Definition: CSKYTargetParser.h:168
llvm::CSKY::AEK_DSPE60
@ AEK_DSPE60
Definition: CSKYTargetParser.h:47
llvm::CSKY::ArchNames::ID
T ID
Definition: CSKYTargetParser.h:169
llvm::CSKY::FK_LAST
@ FK_LAST
Definition: CSKYTargetParser.h:99