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 | |
18 | using namespace llvm; |
19 | |
20 | int main(int argc, char **argv) { |
21 | #if defined(__i386__) || defined(_M_IX86) || \ |
22 | defined(__x86_64__) || defined(_M_X64) |
23 | const StringMap<bool> features = sys::getHostCPUFeatures(); |
24 | if (features.empty()) |
25 | return 1; |
26 | |
27 | if (features.lookup(Key: "sse" )) |
28 | outs() << "sse\n" ; |
29 | if (features.lookup(Key: "avx" )) |
30 | outs() << "avx\n" ; |
31 | if (features.lookup(Key: "avx512f" )) |
32 | outs() << "avx512f\n" ; |
33 | #endif |
34 | |
35 | return 0; |
36 | } |
37 | |