blob: 450e713f27f2e116e4ddd754734f6f22383358f4 [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===-- TargetParser - Parser for target features ---------------*- C++ -*-===//
2//
Andrew Walbran16937d02019-10-22 13:54:20 +01003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006//
7//===----------------------------------------------------------------------===//
8//
9// This file implements a target parser to recognise hardware features such as
10// FPU/CPU/ARCH names as well as specific support such as HDIV, etc.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_SUPPORT_TARGETPARSER_H
15#define LLVM_SUPPORT_TARGETPARSER_H
16
17// FIXME: vector is used because that's what clang uses for subtarget feature
18// lists, but SmallVector would probably be better
19#include "llvm/ADT/Triple.h"
Andrew Walbran16937d02019-10-22 13:54:20 +010020#include "llvm/Support/ARMTargetParser.h"
21#include "llvm/Support/AArch64TargetParser.h"
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010022#include <vector>
23
24namespace llvm {
25class StringRef;
26
Andrew Walbran16937d02019-10-22 13:54:20 +010027// Target specific information in their own namespaces.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020028// (ARM/AArch64/X86 are declared in ARM/AArch64/X86TargetParser.h)
Andrew Walbran16937d02019-10-22 13:54:20 +010029// These should be generated from TableGen because the information is already
30// there, and there is where new information about targets will be added.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010031// FIXME: To TableGen this we need to make some table generated files available
32// even if the back-end is not compiled with LLVM, plus we need to create a new
33// back-end to TableGen to create these clean tables.
Andrew Scull0372a572018-11-16 15:47:06 +000034namespace AMDGPU {
35
36/// GPU kinds supported by the AMDGPU target.
37enum GPUKind : uint32_t {
38 // Not specified processor.
39 GK_NONE = 0,
40
41 // R600-based processors.
42 GK_R600 = 1,
43 GK_R630 = 2,
44 GK_RS880 = 3,
45 GK_RV670 = 4,
46 GK_RV710 = 5,
47 GK_RV730 = 6,
48 GK_RV770 = 7,
49 GK_CEDAR = 8,
50 GK_CYPRESS = 9,
51 GK_JUNIPER = 10,
52 GK_REDWOOD = 11,
53 GK_SUMO = 12,
54 GK_BARTS = 13,
55 GK_CAICOS = 14,
56 GK_CAYMAN = 15,
57 GK_TURKS = 16,
58
59 GK_R600_FIRST = GK_R600,
60 GK_R600_LAST = GK_TURKS,
61
62 // AMDGCN-based processors.
63 GK_GFX600 = 32,
64 GK_GFX601 = 33,
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020065 GK_GFX602 = 34,
Andrew Scull0372a572018-11-16 15:47:06 +000066
67 GK_GFX700 = 40,
68 GK_GFX701 = 41,
69 GK_GFX702 = 42,
70 GK_GFX703 = 43,
71 GK_GFX704 = 44,
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020072 GK_GFX705 = 45,
Andrew Scull0372a572018-11-16 15:47:06 +000073
74 GK_GFX801 = 50,
75 GK_GFX802 = 51,
76 GK_GFX803 = 52,
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020077 GK_GFX805 = 53,
78 GK_GFX810 = 54,
Andrew Scull0372a572018-11-16 15:47:06 +000079
80 GK_GFX900 = 60,
81 GK_GFX902 = 61,
82 GK_GFX904 = 62,
83 GK_GFX906 = 63,
Andrew Walbran3d2c1972020-04-07 12:24:26 +010084 GK_GFX908 = 64,
Andrew Walbran16937d02019-10-22 13:54:20 +010085 GK_GFX909 = 65,
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020086 GK_GFX90C = 66,
Andrew Scull0372a572018-11-16 15:47:06 +000087
Andrew Walbran3d2c1972020-04-07 12:24:26 +010088 GK_GFX1010 = 71,
89 GK_GFX1011 = 72,
90 GK_GFX1012 = 73,
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020091 GK_GFX1030 = 75,
92 GK_GFX1031 = 76,
93 GK_GFX1032 = 77,
94 GK_GFX1033 = 78,
Andrew Walbran3d2c1972020-04-07 12:24:26 +010095
Andrew Scull0372a572018-11-16 15:47:06 +000096 GK_AMDGCN_FIRST = GK_GFX600,
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020097 GK_AMDGCN_LAST = GK_GFX1033,
Andrew Scull0372a572018-11-16 15:47:06 +000098};
99
100/// Instruction set architecture version.
101struct IsaVersion {
102 unsigned Major;
103 unsigned Minor;
104 unsigned Stepping;
105};
106
107// This isn't comprehensive for now, just things that are needed from the
108// frontend driver.
109enum ArchFeatureKind : uint32_t {
110 FEATURE_NONE = 0,
111
112 // These features only exist for r600, and are implied true for amdgcn.
113 FEATURE_FMA = 1 << 1,
114 FEATURE_LDEXP = 1 << 2,
115 FEATURE_FP64 = 1 << 3,
116
117 // Common features.
118 FEATURE_FAST_FMA_F32 = 1 << 4,
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200119 FEATURE_FAST_DENORMAL_F32 = 1 << 5,
120
121 // Wavefront 32 is available.
122 FEATURE_WAVE32 = 1 << 6,
123
124 // Xnack is available.
125 FEATURE_XNACK = 1 << 7,
126
127 // Sram-ecc is available.
128 FEATURE_SRAMECC = 1 << 8,
Andrew Scull0372a572018-11-16 15:47:06 +0000129};
130
131StringRef getArchNameAMDGCN(GPUKind AK);
132StringRef getArchNameR600(GPUKind AK);
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200133StringRef getCanonicalArchName(const Triple &T, StringRef Arch);
Andrew Scull0372a572018-11-16 15:47:06 +0000134GPUKind parseArchAMDGCN(StringRef CPU);
135GPUKind parseArchR600(StringRef CPU);
136unsigned getArchAttrAMDGCN(GPUKind AK);
137unsigned getArchAttrR600(GPUKind AK);
138
139void fillValidArchListAMDGCN(SmallVectorImpl<StringRef> &Values);
140void fillValidArchListR600(SmallVectorImpl<StringRef> &Values);
141
142IsaVersion getIsaVersion(StringRef GPU);
143
144} // namespace AMDGPU
145
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200146namespace RISCV {
147
148enum CPUKind : unsigned {
149#define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH) CK_##ENUM,
150#include "RISCVTargetParser.def"
151};
152
153enum FeatureKind : unsigned {
154 FK_INVALID = 0,
155 FK_NONE = 1,
156 FK_STDEXTM = 1 << 2,
157 FK_STDEXTA = 1 << 3,
158 FK_STDEXTF = 1 << 4,
159 FK_STDEXTD = 1 << 5,
160 FK_STDEXTC = 1 << 6,
161 FK_64BIT = 1 << 7,
162};
163
164bool checkCPUKind(CPUKind Kind, bool IsRV64);
165bool checkTuneCPUKind(CPUKind Kind, bool IsRV64);
166CPUKind parseCPUKind(StringRef CPU);
167CPUKind parseTuneCPUKind(StringRef CPU, bool IsRV64);
168StringRef getMArchFromMcpu(StringRef CPU);
169void fillValidCPUArchList(SmallVectorImpl<StringRef> &Values, bool IsRV64);
170void fillValidTuneCPUArchList(SmallVectorImpl<StringRef> &Values, bool IsRV64);
171bool getCPUFeaturesExceptStdExt(CPUKind Kind, std::vector<StringRef> &Features);
172StringRef resolveTuneCPUAlias(StringRef TuneCPU, bool IsRV64);
173
174} // namespace RISCV
175
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100176} // namespace llvm
177
178#endif