1 //===-- TargetParser - Parser for target features ---------------*- C++ -*-===//
3 // 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
7 //===----------------------------------------------------------------------===//
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.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_SUPPORT_TARGETPARSER_H
15 #define LLVM_SUPPORT_TARGETPARSER_H
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"
20 #include "llvm/Support/ARMTargetParser.h"
21 #include "llvm/Support/AArch64TargetParser.h"
27 // Target specific information in their own namespaces.
28 // (ARM/AArch64 are declared in ARM/AArch64TargetParser.h)
29 // These should be generated from TableGen because the information is already
30 // there, and there is where new information about targets will be added.
31 // 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.
36 // This should be kept in sync with libcc/compiler-rt as its included by clang
37 // as a proxy for what's in libgcc/compiler-rt.
38 enum ProcessorVendors : unsigned {
40 #define X86_VENDOR(ENUM, STRING) \
42 #include "llvm/Support/X86TargetParser.def"
46 // This should be kept in sync with libcc/compiler-rt as its included by clang
47 // as a proxy for what's in libgcc/compiler-rt.
48 enum ProcessorTypes : unsigned {
50 #define X86_CPU_TYPE(ARCHNAME, ENUM) \
52 #include "llvm/Support/X86TargetParser.def"
56 // This should be kept in sync with libcc/compiler-rt as its included by clang
57 // as a proxy for what's in libgcc/compiler-rt.
58 enum ProcessorSubtypes : unsigned {
60 #define X86_CPU_SUBTYPE(ARCHNAME, ENUM) \
62 #include "llvm/Support/X86TargetParser.def"
66 // This should be kept in sync with libcc/compiler-rt as it should be used
67 // by clang as a proxy for what's in libgcc/compiler-rt.
68 enum ProcessorFeatures {
69 #define X86_FEATURE(VAL, ENUM) \
71 #include "llvm/Support/X86TargetParser.def"
79 /// GPU kinds supported by the AMDGPU target.
80 enum GPUKind : uint32_t {
81 // Not specified processor.
84 // R600-based processors.
102 GK_R600_FIRST = GK_R600,
103 GK_R600_LAST = GK_TURKS,
105 // AMDGCN-based processors.
131 GK_AMDGCN_FIRST = GK_GFX600,
132 GK_AMDGCN_LAST = GK_GFX1012,
135 /// Instruction set architecture version.
142 // This isn't comprehensive for now, just things that are needed from the
144 enum ArchFeatureKind : uint32_t {
147 // These features only exist for r600, and are implied true for amdgcn.
148 FEATURE_FMA = 1 << 1,
149 FEATURE_LDEXP = 1 << 2,
150 FEATURE_FP64 = 1 << 3,
153 FEATURE_FAST_FMA_F32 = 1 << 4,
154 FEATURE_FAST_DENORMAL_F32 = 1 << 5
157 StringRef getArchNameAMDGCN(GPUKind AK);
158 StringRef getArchNameR600(GPUKind AK);
159 StringRef getCanonicalArchName(StringRef Arch);
160 GPUKind parseArchAMDGCN(StringRef CPU);
161 GPUKind parseArchR600(StringRef CPU);
162 unsigned getArchAttrAMDGCN(GPUKind AK);
163 unsigned getArchAttrR600(GPUKind AK);
165 void fillValidArchListAMDGCN(SmallVectorImpl<StringRef> &Values);
166 void fillValidArchListR600(SmallVectorImpl<StringRef> &Values);
168 IsaVersion getIsaVersion(StringRef GPU);
170 } // namespace AMDGPU