llvm/llvm/lib/TargetParser/X86TargetParser.cpp

//===-- X86TargetParser - Parser for X86 features ---------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file implements a target parser to recognise X86 hardware features.
//
//===----------------------------------------------------------------------===//

#include "llvm/TargetParser/X86TargetParser.h"
#include "llvm/ADT/Bitset.h"
#include "llvm/ADT/StringSwitch.h"
#include <numeric>

usingnamespacellvm;
usingnamespacellvm::X86;

namespace {

FeatureBitset;

struct ProcInfo {};

struct FeatureInfo {};

} // end anonymous namespace

#define X86_FEATURE
#include "llvm/TargetParser/X86TargetParser.def"

// Pentium with MMX.
constexpr FeatureBitset FeaturesPentiumMMX =;

// Pentium 2 and 3.
constexpr FeatureBitset FeaturesPentium2 =;
constexpr FeatureBitset FeaturesPentium3 =;

// Pentium 4 CPUs
constexpr FeatureBitset FeaturesPentium4 =;
constexpr FeatureBitset FeaturesPrescott =;
constexpr FeatureBitset FeaturesNocona =;

// Basic 64-bit capable CPU.
constexpr FeatureBitset FeaturesX86_64 =;
constexpr FeatureBitset FeaturesX86_64_V2 =;
constexpr FeatureBitset FeaturesX86_64_V3 =;
constexpr FeatureBitset FeaturesX86_64_V4 =;

// Intel Core CPUs
constexpr FeatureBitset FeaturesCore2 =;
constexpr FeatureBitset FeaturesPenryn =;
constexpr FeatureBitset FeaturesNehalem =;
constexpr FeatureBitset FeaturesWestmere =;
constexpr FeatureBitset FeaturesSandyBridge =;
constexpr FeatureBitset FeaturesIvyBridge =;
constexpr FeatureBitset FeaturesHaswell =;
constexpr FeatureBitset FeaturesBroadwell =;

// Intel Knights Landing and Knights Mill
// Knights Landing has feature parity with Broadwell.
constexpr FeatureBitset FeaturesKNL =;
constexpr FeatureBitset FeaturesKNM =;

// Intel Skylake processors.
constexpr FeatureBitset FeaturesSkylakeClient =;
// SkylakeServer inherits all SkylakeClient features except SGX.
// FIXME: That doesn't match gcc.
constexpr FeatureBitset FeaturesSkylakeServer =;
constexpr FeatureBitset FeaturesCascadeLake =;
constexpr FeatureBitset FeaturesCooperLake =;

// Intel 10nm processors.
constexpr FeatureBitset FeaturesCannonlake =;
constexpr FeatureBitset FeaturesICLClient =;
constexpr FeatureBitset FeaturesRocketlake =;
constexpr FeatureBitset FeaturesICLServer =;
constexpr FeatureBitset FeaturesTigerlake =;
constexpr FeatureBitset FeaturesSapphireRapids =;
constexpr FeatureBitset FeaturesGraniteRapids =;

// Intel Atom processors.
// Bonnell has feature parity with Core2 and adds MOVBE.
constexpr FeatureBitset FeaturesBonnell =;
// Silvermont has parity with Westmere and Bonnell plus PRFCHW and RDRND.
constexpr FeatureBitset FeaturesSilvermont =;
constexpr FeatureBitset FeaturesGoldmont =;
constexpr FeatureBitset FeaturesGoldmontPlus =;
constexpr FeatureBitset FeaturesTremont =;
constexpr FeatureBitset FeaturesAlderlake =;
constexpr FeatureBitset FeaturesSierraforest =;
constexpr FeatureBitset FeaturesArrowlakeS =;
constexpr FeatureBitset FeaturesPantherlake =;
constexpr FeatureBitset FeaturesClearwaterforest =;

// Geode Processor.
constexpr FeatureBitset FeaturesGeode =;

// K6 processor.
constexpr FeatureBitset FeaturesK6 =;

// K7 and K8 architecture processors.
constexpr FeatureBitset FeaturesAthlon =;
constexpr FeatureBitset FeaturesAthlonXP =;
constexpr FeatureBitset FeaturesK8 =;
constexpr FeatureBitset FeaturesK8SSE3 =;
constexpr FeatureBitset FeaturesAMDFAM10 =;

// Bobcat architecture processors.
constexpr FeatureBitset FeaturesBTVER1 =;
constexpr FeatureBitset FeaturesBTVER2 =;

// AMD Bulldozer architecture processors.
constexpr FeatureBitset FeaturesBDVER1 =;
constexpr FeatureBitset FeaturesBDVER2 =;
constexpr FeatureBitset FeaturesBDVER3 =;
constexpr FeatureBitset FeaturesBDVER4 =;

// AMD Zen architecture processors.
constexpr FeatureBitset FeaturesZNVER1 =;
constexpr FeatureBitset FeaturesZNVER2 =;
static constexpr FeatureBitset FeaturesZNVER3 =;
static constexpr FeatureBitset FeaturesZNVER4 =;

static constexpr FeatureBitset FeaturesZNVER5 =;

// D151696 tranplanted Mangling and OnlyForCPUDispatchSpecific from
// X86TargetParser.def to here. They are assigned by following ways:
// 1. Copy the mangling from the original CPU_SPEICIFC MACROs. If no, assign
// to '\0' by default, which means not support cpu_specific/dispatch feature.
// 2. set OnlyForCPUDispatchSpecific as true if this cpu name was not
// listed here before, which means it doesn't support -march, -mtune and so on.
// FIXME: Remove OnlyForCPUDispatchSpecific after all CPUs here support both
// cpu_dispatch/specific() feature and -march, -mtune, and so on.
// clang-format off
constexpr ProcInfo Processors[] =;
// clang-format on

constexpr const char *NoTuneList[] =;

X86::CPUKind llvm::X86::parseArchX86(StringRef CPU, bool Only64Bit) {}

X86::CPUKind llvm::X86::parseTuneCPU(StringRef CPU, bool Only64Bit) {}

void llvm::X86::fillValidCPUArchList(SmallVectorImpl<StringRef> &Values,
                                     bool Only64Bit) {}

void llvm::X86::fillValidTuneCPUList(SmallVectorImpl<StringRef> &Values,
                                     bool Only64Bit) {}

ProcessorFeatures llvm::X86::getKeyFeature(X86::CPUKind Kind) {}

// Features with no dependencies.
constexpr FeatureBitset ImpliedFeatures64BIT =;
constexpr FeatureBitset ImpliedFeaturesADX =;
constexpr FeatureBitset ImpliedFeaturesBMI =;
constexpr FeatureBitset ImpliedFeaturesBMI2 =;
constexpr FeatureBitset ImpliedFeaturesCLDEMOTE =;
constexpr FeatureBitset ImpliedFeaturesCLFLUSHOPT =;
constexpr FeatureBitset ImpliedFeaturesCLWB =;
constexpr FeatureBitset ImpliedFeaturesCLZERO =;
constexpr FeatureBitset ImpliedFeaturesCMOV =;
constexpr FeatureBitset ImpliedFeaturesCMPXCHG16B =;
constexpr FeatureBitset ImpliedFeaturesCMPXCHG8B =;
constexpr FeatureBitset ImpliedFeaturesCRC32 =;
constexpr FeatureBitset ImpliedFeaturesENQCMD =;
constexpr FeatureBitset ImpliedFeaturesFSGSBASE =;
constexpr FeatureBitset ImpliedFeaturesFXSR =;
constexpr FeatureBitset ImpliedFeaturesINVPCID =;
constexpr FeatureBitset ImpliedFeaturesLWP =;
constexpr FeatureBitset ImpliedFeaturesLZCNT =;
constexpr FeatureBitset ImpliedFeaturesMMX =;
constexpr FeatureBitset ImpliedFeaturesMWAITX =;
constexpr FeatureBitset ImpliedFeaturesMOVBE =;
constexpr FeatureBitset ImpliedFeaturesMOVDIR64B =;
constexpr FeatureBitset ImpliedFeaturesMOVDIRI =;
constexpr FeatureBitset ImpliedFeaturesPCONFIG =;
constexpr FeatureBitset ImpliedFeaturesPOPCNT =;
constexpr FeatureBitset ImpliedFeaturesPKU =;
constexpr FeatureBitset ImpliedFeaturesPRFCHW =;
constexpr FeatureBitset ImpliedFeaturesPTWRITE =;
constexpr FeatureBitset ImpliedFeaturesRDPID =;
constexpr FeatureBitset ImpliedFeaturesRDPRU =;
constexpr FeatureBitset ImpliedFeaturesRDRND =;
constexpr FeatureBitset ImpliedFeaturesRDSEED =;
constexpr FeatureBitset ImpliedFeaturesRTM =;
constexpr FeatureBitset ImpliedFeaturesSAHF =;
constexpr FeatureBitset ImpliedFeaturesSERIALIZE =;
constexpr FeatureBitset ImpliedFeaturesSGX =;
constexpr FeatureBitset ImpliedFeaturesSHSTK =;
constexpr FeatureBitset ImpliedFeaturesTBM =;
constexpr FeatureBitset ImpliedFeaturesTSXLDTRK =;
constexpr FeatureBitset ImpliedFeaturesUINTR =;
constexpr FeatureBitset ImpliedFeaturesUSERMSR =;
constexpr FeatureBitset ImpliedFeaturesWAITPKG =;
constexpr FeatureBitset ImpliedFeaturesWBNOINVD =;
constexpr FeatureBitset ImpliedFeaturesVZEROUPPER =;
constexpr FeatureBitset ImpliedFeaturesX87 =;
constexpr FeatureBitset ImpliedFeaturesXSAVE =;
constexpr FeatureBitset ImpliedFeaturesDUMMYFEATURE1 =;
constexpr FeatureBitset ImpliedFeaturesDUMMYFEATURE2 =;

// Not really CPU features, but need to be in the table because clang uses
// target features to communicate them to the backend.
constexpr FeatureBitset ImpliedFeaturesRETPOLINE_EXTERNAL_THUNK =;
constexpr FeatureBitset ImpliedFeaturesRETPOLINE_INDIRECT_BRANCHES =;
constexpr FeatureBitset ImpliedFeaturesRETPOLINE_INDIRECT_CALLS =;
constexpr FeatureBitset ImpliedFeaturesLVI_CFI =;
constexpr FeatureBitset ImpliedFeaturesLVI_LOAD_HARDENING =;

// XSAVE features are dependent on basic XSAVE.
constexpr FeatureBitset ImpliedFeaturesXSAVEC =;
constexpr FeatureBitset ImpliedFeaturesXSAVEOPT =;
constexpr FeatureBitset ImpliedFeaturesXSAVES =;

// SSE/AVX/AVX512F chain.
constexpr FeatureBitset ImpliedFeaturesSSE =;
constexpr FeatureBitset ImpliedFeaturesSSE2 =;
constexpr FeatureBitset ImpliedFeaturesSSE3 =;
constexpr FeatureBitset ImpliedFeaturesSSSE3 =;
constexpr FeatureBitset ImpliedFeaturesSSE4_1 =;
constexpr FeatureBitset ImpliedFeaturesSSE4_2 =;
constexpr FeatureBitset ImpliedFeaturesAVX =;
constexpr FeatureBitset ImpliedFeaturesAVX2 =;
constexpr FeatureBitset ImpliedFeaturesEVEX512 =;
constexpr FeatureBitset ImpliedFeaturesAVX512F =;

// Vector extensions that build on SSE or AVX.
constexpr FeatureBitset ImpliedFeaturesAES =;
constexpr FeatureBitset ImpliedFeaturesF16C =;
constexpr FeatureBitset ImpliedFeaturesFMA =;
constexpr FeatureBitset ImpliedFeaturesGFNI =;
constexpr FeatureBitset ImpliedFeaturesPCLMUL =;
constexpr FeatureBitset ImpliedFeaturesSHA =;
constexpr FeatureBitset ImpliedFeaturesVAES =;
constexpr FeatureBitset ImpliedFeaturesVPCLMULQDQ =;
constexpr FeatureBitset ImpliedFeaturesSM3 =;
constexpr FeatureBitset ImpliedFeaturesSM4 =;

// AVX512 features.
constexpr FeatureBitset ImpliedFeaturesAVX512CD =;
constexpr FeatureBitset ImpliedFeaturesAVX512BW =;
constexpr FeatureBitset ImpliedFeaturesAVX512DQ =;
constexpr FeatureBitset ImpliedFeaturesAVX512VL =;

constexpr FeatureBitset ImpliedFeaturesAVX512BF16 =;
constexpr FeatureBitset ImpliedFeaturesAVX512BITALG =;
constexpr FeatureBitset ImpliedFeaturesAVX512IFMA =;
constexpr FeatureBitset ImpliedFeaturesAVX512VNNI =;
constexpr FeatureBitset ImpliedFeaturesAVX512VPOPCNTDQ =;
constexpr FeatureBitset ImpliedFeaturesAVX512VBMI =;
constexpr FeatureBitset ImpliedFeaturesAVX512VBMI2 =;
constexpr FeatureBitset ImpliedFeaturesAVX512VP2INTERSECT =;

// FIXME: These two aren't really implemented and just exist in the feature
// list for __builtin_cpu_supports. So omit their dependencies.
constexpr FeatureBitset ImpliedFeaturesAVX5124FMAPS =;
constexpr FeatureBitset ImpliedFeaturesAVX5124VNNIW =;

// SSE4_A->FMA4->XOP chain.
constexpr FeatureBitset ImpliedFeaturesSSE4_A =;
constexpr FeatureBitset ImpliedFeaturesFMA4 =;
constexpr FeatureBitset ImpliedFeaturesXOP =;

// AMX Features
constexpr FeatureBitset ImpliedFeaturesAMX_TILE =;
constexpr FeatureBitset ImpliedFeaturesAMX_BF16 =;
constexpr FeatureBitset ImpliedFeaturesAMX_FP16 =;
constexpr FeatureBitset ImpliedFeaturesAMX_INT8 =;
constexpr FeatureBitset ImpliedFeaturesAMX_COMPLEX =;
constexpr FeatureBitset ImpliedFeaturesHRESET =;

constexpr FeatureBitset ImpliedFeaturesPREFETCHI =;
constexpr FeatureBitset ImpliedFeaturesCMPCCXADD =;
constexpr FeatureBitset ImpliedFeaturesRAOINT =;
constexpr FeatureBitset ImpliedFeaturesAVXVNNIINT16 =;
constexpr FeatureBitset ImpliedFeaturesAVXVNNIINT8 =;
constexpr FeatureBitset ImpliedFeaturesAVXIFMA =;
constexpr FeatureBitset ImpliedFeaturesAVXNECONVERT =;
constexpr FeatureBitset ImpliedFeaturesSHA512 =;
constexpr FeatureBitset ImpliedFeaturesAVX512FP16 =;
// Key Locker Features
constexpr FeatureBitset ImpliedFeaturesKL =;
constexpr FeatureBitset ImpliedFeaturesWIDEKL =;

// AVXVNNI Features
constexpr FeatureBitset ImpliedFeaturesAVXVNNI =;

// AVX10 Features
constexpr FeatureBitset ImpliedFeaturesAVX10_1 =;
constexpr FeatureBitset ImpliedFeaturesAVX10_1_512 =;
constexpr FeatureBitset ImpliedFeaturesAVX10_2 =;
constexpr FeatureBitset ImpliedFeaturesAVX10_2_512 =;

// APX Features
constexpr FeatureBitset ImpliedFeaturesEGPR =;
constexpr FeatureBitset ImpliedFeaturesPush2Pop2 =;
constexpr FeatureBitset ImpliedFeaturesPPX =;
constexpr FeatureBitset ImpliedFeaturesNDD =;
constexpr FeatureBitset ImpliedFeaturesCCMP =;
constexpr FeatureBitset ImpliedFeaturesNF =;
constexpr FeatureBitset ImpliedFeaturesCF =;
constexpr FeatureBitset ImpliedFeaturesZU =;

constexpr FeatureInfo FeatureInfos[X86::CPU_FEATURE_MAX] =;

void llvm::X86::getFeaturesForCPU(StringRef CPU,
                                  SmallVectorImpl<StringRef> &EnabledFeatures,
                                  bool NeedPlus) {}

// For each feature that is (transitively) implied by this feature, set it.
static void getImpliedEnabledFeatures(FeatureBitset &Bits,
                                      const FeatureBitset &Implies) {}

/// Create bit vector of features that are implied disabled if the feature
/// passed in Value is disabled.
static void getImpliedDisabledFeatures(FeatureBitset &Bits, unsigned Value) {}

void llvm::X86::updateImpliedFeatures(
    StringRef Feature, bool Enabled,
    StringMap<bool> &Features) {}

char llvm::X86::getCPUDispatchMangling(StringRef CPU) {}

bool llvm::X86::validateCPUSpecificCPUDispatch(StringRef Name) {}

std::array<uint32_t, 4>
llvm::X86::getCpuSupportsMask(ArrayRef<StringRef> FeatureStrs) {}

unsigned llvm::X86::getFeaturePriority(ProcessorFeatures Feat) {}