LLVM 22.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
20#include <vector>
21
22namespace llvm {
23class StringRef;
24
25namespace CSKY {
26
27// Arch extension modifiers for CPUs.
31 AEK_FPUV2SF = 1 << 1,
32 AEK_FPUV2DF = 1 << 2,
33 AEK_FDIVDU = 1 << 3,
34 AEK_FPUV3HI = 1 << 4,
35 AEK_FPUV3HF = 1 << 5,
36 AEK_FPUV3SF = 1 << 6,
37 AEK_FPUV3DF = 1 << 7,
38 AEK_FLOATE1 = 1 << 8,
39 AEK_FLOAT1E2 = 1 << 9,
40 AEK_FLOAT1E3 = 1 << 10,
41 AEK_FLOAT3E4 = 1 << 11,
42 AEK_FLOAT7E60 = 1 << 12,
43 AEK_HWDIV = 1 << 13,
44 AEK_STLD = 1 << 14,
45 AEK_PUSHPOP = 1 << 15,
46 AEK_EDSP = 1 << 16,
47 AEK_DSP1E2 = 1 << 17,
48 AEK_DSPE60 = 1 << 18,
49 AEK_DSPV2 = 1 << 19,
50 AEK_DSPSILAN = 1 << 20,
51 AEK_ELRW = 1 << 21,
52 AEK_TRUST = 1 << 22,
53 AEK_JAVA = 1 << 23,
54 AEK_CACHE = 1 << 24,
55 AEK_NVIC = 1 << 25,
56 AEK_DOLOOP = 1 << 26,
57 AEK_HIGHREG = 1 << 27,
58 AEK_SMART = 1 << 28,
59 AEK_VDSP2E3 = 1 << 29,
60 AEK_VDSP2E60F = 1 << 30,
61 AEK_VDSPV2 = 1ULL << 31,
62 AEK_HARDTP = 1ULL << 32,
63 AEK_SOFTTP = 1ULL << 33,
64 AEK_ISTACK = 1ULL << 34,
65 AEK_CONSTPOOL = 1ULL << 35,
66 AEK_STACKSIZE = 1ULL << 36,
67 AEK_CCRT = 1ULL << 37,
68 AEK_VDSPV1 = 1ULL << 38,
69 AEK_E1 = 1ULL << 39,
70 AEK_E2 = 1ULL << 40,
71 AEK_2E3 = 1ULL << 41,
72 AEK_MP = 1ULL << 42,
73 AEK_3E3R1 = 1ULL << 43,
74 AEK_3E3R2 = 1ULL << 44,
75 AEK_3E3R3 = 1ULL << 45,
76 AEK_3E7 = 1ULL << 46,
77 AEK_MP1E2 = 1ULL << 47,
78 AEK_7E10 = 1ULL << 48,
79 AEK_10E60 = 1ULL << 49
80
81};
82
83// Arch extension modifiers for CPUs.
95};
96// FPU names.
98#define CSKY_FPU(NAME, KIND, VERSION) KIND,
99#include "CSKYTargetParser.def"
100 FK_LAST
102
103// FPU Version
104enum class FPUVersion {
105 NONE,
106 FPV2,
107 FPV3,
108};
109
110// Arch names.
111enum class ArchKind {
112#define CSKY_ARCH(NAME, ID, ARCH_BASE_EXT) ID,
113#include "CSKYTargetParser.def"
114};
115
116// List of Arch Extension names.
117// FIXME: TableGen this.
118struct ExtName {
119 const char *NameCStr;
122 const char *Feature;
123 const char *NegFeature;
124
126};
127
129#define CSKY_ARCH_EXT_NAME(NAME, ID, FEATURE, NEGFEATURE) \
130 {NAME, sizeof(NAME) - 1, ID, FEATURE, NEGFEATURE},
131#include "CSKYTargetParser.def"
132};
133
134// List of CPU names and their arches.
135template <typename T> struct CpuNames {
136 const char *NameCStr;
140
142};
144#define CSKY_CPU_NAME(NAME, ARCH_ID, DEFAULT_EXT) \
145 {NAME, sizeof(NAME) - 1, CSKY::ArchKind::ARCH_ID, DEFAULT_EXT},
146#include "llvm/TargetParser/CSKYTargetParser.def"
147};
148
149// FIXME: TableGen this.
150// The entries must appear in the order listed in CSKY::CSKYFPUKind for correct
151// indexing
152struct FPUName {
153 const char *NameCStr;
157
159};
160
161static const FPUName FPUNames[] = {
162#define CSKY_FPU(NAME, KIND, VERSION) {NAME, sizeof(NAME) - 1, KIND, VERSION},
163#include "llvm/TargetParser/CSKYTargetParser.def"
164};
165
166// List of canonical arch names.
167template <typename T> struct ArchNames {
168 const char *NameCStr;
173};
175#define CSKY_ARCH(NAME, ID, ARCH_BASE_EXT) \
176 {NAME, sizeof(NAME) - 1, CSKY::ArchKind::ID, ARCH_BASE_EXT},
177#include "llvm/TargetParser/CSKYTargetParser.def"
178};
179
186 std::vector<StringRef> &Features);
187
188// Information by ID
189LLVM_ABI StringRef getFPUName(unsigned FPUKind);
190LLVM_ABI FPUVersion getFPUVersion(unsigned FPUKind);
191
193 std::vector<StringRef> &Features);
194
195// Parser
200
201} // namespace CSKY
202
203} // namespace llvm
204
205#endif
#define LLVM_ABI
Definition: Compiler.h:213
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:574
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
LLVM_ABI StringRef getFPUName(unsigned FPUKind)
LLVM_ABI StringRef getArchExtFeature(StringRef ArchExt)
LLVM_ABI bool getExtensionFeatures(uint64_t Extensions, std::vector< StringRef > &Features)
LLVM_ABI void fillValidCPUArchList(SmallVectorImpl< StringRef > &Values)
const ArchNames< CSKY::ArchKind > ARCHNames[]
LLVM_ABI bool getFPUFeatures(CSKYFPUKind Kind, std::vector< StringRef > &Features)
LLVM_ABI uint64_t parseArchExt(StringRef ArchExt)
const CpuNames< CSKY::ArchKind > CPUNames[]
LLVM_ABI FPUVersion getFPUVersion(unsigned FPUKind)
LLVM_ABI ArchKind parseCPUArch(StringRef CPU)
LLVM_ABI ArchKind parseArch(StringRef Arch)
LLVM_ABI StringRef getDefaultCPU(StringRef Arch)
static const FPUName FPUNames[]
const CSKY::ExtName CSKYARCHExtNames[]
LLVM_ABI StringRef getArchExtName(uint64_t ArchExtKind)
LLVM_ABI StringRef getArchName(ArchKind AK)
LLVM_ABI 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