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 {
150};
151
152/// Parse \p CPU string into a CPUKind. Will only accept 64-bit capable CPUs if
153/// \p Only64Bit is true.
154CPUKind parseArchX86(StringRef CPU, bool Only64Bit = false);
155CPUKind parseTuneCPU(StringRef CPU, bool Only64Bit = false);
156
157/// Provide a list of valid CPU names. If \p Only64Bit is true, the list will
158/// only contain 64-bit capable CPUs.
160 bool Only64Bit = false);
161/// Provide a list of valid -mtune names.
163 bool Only64Bit = false);
164
165/// Get the key feature prioritizing target multiversioning.
167
168/// Fill in the features that \p CPU supports into \p Features.
169/// "+" will be append in front of each feature if NeedPlus is true.
171 bool NeedPlus = false);
172
173/// Set or clear entries in \p Features that are implied to be enabled/disabled
174/// by the provided \p Feature.
175void updateImpliedFeatures(StringRef Feature, bool Enabled,
176 StringMap<bool> &Features);
177
180std::array<uint32_t, 4> getCpuSupportsMask(ArrayRef<StringRef> FeatureStrs);
182
183} // namespace X86
184} // namespace llvm
185
186#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:586
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:50
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