1//===- lit-cpuid.cpp - Get CPU feature flags for lit exported features ----===//
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// lit-cpuid obtains the feature list for the currently running CPU, and outputs
10// those flags that are interesting for LLDB lit tests.
11//
12//===----------------------------------------------------------------------===//
13
14#include "llvm/ADT/StringMap.h"
15#include "llvm/Support/raw_ostream.h"
16#include "llvm/TargetParser/Host.h"
17
18using namespace llvm;
19
20int main(int argc, char **argv) {
21#if defined(__i386__) || defined(_M_IX86) || \
22 defined(__x86_64__) || defined(_M_X64)
23 StringMap<bool> features;
24
25 if (!sys::getHostCPUFeatures(Features&: features))
26 return 1;
27
28 if (features["sse"])
29 outs() << "sse\n";
30 if (features["avx"])
31 outs() << "avx\n";
32 if (features["avx512f"])
33 outs() << "avx512f\n";
34#endif
35
36 return 0;
37}
38

source code of lldb/utils/lit-cpuid/lit-cpuid.cpp