1*061da546Spatrick //===- lit-cpuid.cpp - Get CPU feature flags for lit exported features ----===// 2*061da546Spatrick // 3*061da546Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*061da546Spatrick // See https://llvm.org/LICENSE.txt for license information. 5*061da546Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*061da546Spatrick // 7*061da546Spatrick //===----------------------------------------------------------------------===// 8*061da546Spatrick // 9*061da546Spatrick // lit-cpuid obtains the feature list for the currently running CPU, and outputs 10*061da546Spatrick // those flags that are interesting for LLDB lit tests. 11*061da546Spatrick // 12*061da546Spatrick //===----------------------------------------------------------------------===// 13*061da546Spatrick 14*061da546Spatrick #include "llvm/ADT/StringMap.h" 15*061da546Spatrick #include "llvm/Support/Host.h" 16*061da546Spatrick #include "llvm/Support/raw_ostream.h" 17*061da546Spatrick 18*061da546Spatrick using namespace llvm; 19*061da546Spatrick main(int argc,char ** argv)20*061da546Spatrickint main(int argc, char **argv) { 21*061da546Spatrick #if defined(__i386__) || defined(_M_IX86) || \ 22*061da546Spatrick defined(__x86_64__) || defined(_M_X64) 23*061da546Spatrick StringMap<bool> features; 24*061da546Spatrick 25*061da546Spatrick if (!sys::getHostCPUFeatures(features)) 26*061da546Spatrick return 1; 27*061da546Spatrick 28*061da546Spatrick if (features["sse"]) 29*061da546Spatrick outs() << "sse\n"; 30*061da546Spatrick if (features["avx"]) 31*061da546Spatrick outs() << "avx\n"; 32*061da546Spatrick if (features["avx512f"]) 33*061da546Spatrick outs() << "avx512f\n"; 34*061da546Spatrick #endif 35*061da546Spatrick 36*061da546Spatrick return 0; 37*061da546Spatrick } 38