LLVM 20.0.0git
X86TargetParser.h
Go to the documentation of this file.
1//===-- X86TargetParser - Parser for X86 features ---------------*- C++ -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements a target parser to recognise X86 hardware features.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_TARGETPARSER_X86TARGETPARSER_H
14#define LLVM_TARGETPARSER_X86TARGETPARSER_H
15
16#include "llvm/ADT/ArrayRef.h"
17#include "llvm/ADT/StringMap.h"
18#include <array>
19
20namespace llvm {
21template <typename T> class SmallVectorImpl;
22class StringRef;
23
24namespace X86 {
25
26// This should be kept in sync with libcc/compiler-rt as its included by clang
27// as a proxy for what's in libgcc/compiler-rt.
28enum ProcessorVendors : unsigned {
30#define X86_VENDOR(ENUM, STRING) \
31 ENUM,
32#include "llvm/TargetParser/X86TargetParser.def"
34};
35
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.
38enum ProcessorTypes : unsigned {
40#define X86_CPU_TYPE(ENUM, STRING) \
41 ENUM,
42#include "llvm/TargetParser/X86TargetParser.def"
44};
45
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.
48enum ProcessorSubtypes : unsigned {
50#define X86_CPU_SUBTYPE(ENUM, STRING) \
51 ENUM,
52#include "llvm/TargetParser/X86TargetParser.def"
54};
55
56// This should be kept in sync with libcc/compiler-rt as it should be used
57// by clang as a proxy for what's in libgcc/compiler-rt.
59#define X86_FEATURE(ENUM, STRING) FEATURE_##ENUM,
60#include "llvm/TargetParser/X86TargetParser.def"
62
63#define X86_MICROARCH_LEVEL(ENUM, STRING, PRIORITY) FEATURE_##ENUM = PRIORITY,
64#include "llvm/TargetParser/X86TargetParser.def"
65};
66
67enum CPUKind {
152};
153
154/// Parse \p CPU string into a CPUKind. Will only accept 64-bit capable CPUs if
155/// \p Only64Bit is true.
156CPUKind parseArchX86(StringRef CPU, bool Only64Bit = false);
157CPUKind parseTuneCPU(StringRef CPU, bool Only64Bit = false);
158
159/// Provide a list of valid CPU names. If \p Only64Bit is true, the list will
160/// only contain 64-bit capable CPUs.
162 bool Only64Bit = false);
163/// Provide a list of valid -mtune names.
165 bool Only64Bit = false);
166
167/// Get the key feature prioritizing target multiversioning.
169
170/// Fill in the features that \p CPU supports into \p Features.
171/// "+" will be append in front of each feature if NeedPlus is true.
173 bool NeedPlus = false);
174
175/// Set or clear entries in \p Features that are implied to be enabled/disabled
176/// by the provided \p Feature.
177void updateImpliedFeatures(StringRef Feature, bool Enabled,
178 StringMap<bool> &Features);
179
182std::array<uint32_t, 4> getCpuSupportsMask(ArrayRef<StringRef> FeatureStrs);
184
185} // namespace X86
186} // namespace llvm
187
188#endif
This file defines the StringMap class.
std::string Name
static bool Enabled
Definition: Statistic.cpp:46
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:573
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition: StringMap.h:128
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
std::array< uint32_t, 4 > getCpuSupportsMask(ArrayRef< StringRef > FeatureStrs)
char getCPUDispatchMangling(StringRef Name)
CPUKind parseTuneCPU(StringRef CPU, bool Only64Bit=false)
void updateImpliedFeatures(StringRef Feature, bool Enabled, StringMap< bool > &Features)
Set or clear entries in Features that are implied to be enabled/disabled by the provided Feature.
CPUKind parseArchX86(StringRef CPU, bool Only64Bit=false)
Parse CPU string into a CPUKind.
void fillValidTuneCPUList(SmallVectorImpl< StringRef > &Values, bool Only64Bit=false)
Provide a list of valid -mtune names.
void getFeaturesForCPU(StringRef CPU, SmallVectorImpl< StringRef > &Features, bool NeedPlus=false)
Fill in the features that CPU supports into Features.
unsigned getFeaturePriority(ProcessorFeatures Feat)
void fillValidCPUArchList(SmallVectorImpl< StringRef > &Values, bool Only64Bit=false)
Provide a list of valid CPU names.
bool validateCPUSpecificCPUDispatch(StringRef Name)
ProcessorFeatures getKeyFeature(CPUKind Kind)
Get the key feature prioritizing target multiversioning.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18