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_SUPPORT_X86TARGETPARSER_H 14#define LLVM_SUPPORT_X86TARGETPARSER_H 15 16#include "llvm/ADT/SmallVector.h" 17#include "llvm/ADT/StringMap.h" 18 19namespace llvm { 20class StringRef; 21 22namespace X86 { 23 24// This should be kept in sync with libcc/compiler-rt as its included by clang 25// as a proxy for what's in libgcc/compiler-rt. 26enum ProcessorVendors : unsigned { 27 VENDOR_DUMMY, 28#define X86_VENDOR(ENUM, STRING) \ 29 ENUM, 30#include "llvm/Support/X86TargetParser.def" 31 VENDOR_OTHER 32}; 33 34// This should be kept in sync with libcc/compiler-rt as its included by clang 35// as a proxy for what's in libgcc/compiler-rt. 36enum ProcessorTypes : unsigned { 37 CPU_TYPE_DUMMY, 38#define X86_CPU_TYPE(ENUM, STRING) \ 39 ENUM, 40#include "llvm/Support/X86TargetParser.def" 41 CPU_TYPE_MAX 42}; 43 44// This should be kept in sync with libcc/compiler-rt as its included by clang 45// as a proxy for what's in libgcc/compiler-rt. 46enum ProcessorSubtypes : unsigned { 47 CPU_SUBTYPE_DUMMY, 48#define X86_CPU_SUBTYPE(ENUM, STRING) \ 49 ENUM, 50#include "llvm/Support/X86TargetParser.def" 51 CPU_SUBTYPE_MAX 52}; 53 54// This should be kept in sync with libcc/compiler-rt as it should be used 55// by clang as a proxy for what's in libgcc/compiler-rt. 56enum ProcessorFeatures { 57#define X86_FEATURE(ENUM, STRING) FEATURE_##ENUM, 58#include "llvm/Support/X86TargetParser.def" 59 CPU_FEATURE_MAX 60}; 61 62enum CPUKind { 63 CK_None, 64 CK_i386, 65 CK_i486, 66 CK_WinChipC6, 67 CK_WinChip2, 68 CK_C3, 69 CK_i586, 70 CK_Pentium, 71 CK_PentiumMMX, 72 CK_PentiumPro, 73 CK_i686, 74 CK_Pentium2, 75 CK_Pentium3, 76 CK_PentiumM, 77 CK_C3_2, 78 CK_Yonah, 79 CK_Pentium4, 80 CK_Prescott, 81 CK_Nocona, 82 CK_Core2, 83 CK_Penryn, 84 CK_Bonnell, 85 CK_Silvermont, 86 CK_Goldmont, 87 CK_GoldmontPlus, 88 CK_Tremont, 89 CK_Nehalem, 90 CK_Westmere, 91 CK_SandyBridge, 92 CK_IvyBridge, 93 CK_Haswell, 94 CK_Broadwell, 95 CK_SkylakeClient, 96 CK_SkylakeServer, 97 CK_Cascadelake, 98 CK_Cooperlake, 99 CK_Cannonlake, 100 CK_IcelakeClient, 101 CK_Rocketlake, 102 CK_IcelakeServer, 103 CK_Tigerlake, 104 CK_SapphireRapids, 105 CK_Alderlake, 106 CK_KNL, 107 CK_KNM, 108 CK_Lakemont, 109 CK_K6, 110 CK_K6_2, 111 CK_K6_3, 112 CK_Athlon, 113 CK_AthlonXP, 114 CK_K8, 115 CK_K8SSE3, 116 CK_AMDFAM10, 117 CK_BTVER1, 118 CK_BTVER2, 119 CK_BDVER1, 120 CK_BDVER2, 121 CK_BDVER3, 122 CK_BDVER4, 123 CK_ZNVER1, 124 CK_ZNVER2, 125 CK_ZNVER3, 126 CK_x86_64, 127 CK_x86_64_v2, 128 CK_x86_64_v3, 129 CK_x86_64_v4, 130 CK_Geode, 131}; 132 133/// Parse \p CPU string into a CPUKind. Will only accept 64-bit capable CPUs if 134/// \p Only64Bit is true. 135CPUKind parseArchX86(StringRef CPU, bool Only64Bit = false); 136CPUKind parseTuneCPU(StringRef CPU, bool Only64Bit = false); 137 138/// Provide a list of valid CPU names. If \p Only64Bit is true, the list will 139/// only contain 64-bit capable CPUs. 140void fillValidCPUArchList(SmallVectorImpl<StringRef> &Values, 141 bool Only64Bit = false); 142/// Provide a list of valid -mtune names. 143void fillValidTuneCPUList(SmallVectorImpl<StringRef> &Values, 144 bool Only64Bit = false); 145 146/// Get the key feature prioritizing target multiversioning. 147ProcessorFeatures getKeyFeature(CPUKind Kind); 148 149/// Fill in the features that \p CPU supports into \p Features. 150void getFeaturesForCPU(StringRef CPU, SmallVectorImpl<StringRef> &Features); 151 152/// Set or clear entries in \p Features that are implied to be enabled/disabled 153/// by the provided \p Feature. 154void updateImpliedFeatures(StringRef Feature, bool Enabled, 155 StringMap<bool> &Features); 156 157} // namespace X86 158} // namespace llvm 159 160#endif 161