Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save advancedwebdeveloper/09033869445a09a2e297a73387d46c41 to your computer and use it in GitHub Desktop.
Save advancedwebdeveloper/09033869445a09a2e297a73387d46c41 to your computer and use it in GitHub Desktop.
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/MC/SubtargetFeature.h"
#include "llvm/Support/Host.h"
using namespace llvm;
SubtargetFeatures Features1;
int main (int argc, char **argv)
{
sys::getHostCPUName();
StringMap<bool> HostFeatures;
if (sys::getHostCPUFeatures(HostFeatures))
for (auto &F : HostFeatures)
Features1.AddFeature(F.first(), F.second);
printf("test %s", Features1.getString().c_str());
printf("\nsomething else\n");
return 0;
}
@advancedwebdeveloper
Copy link
Author

advancedwebdeveloper commented Nov 16, 2020

Linux use case:
$clang++-11 -I/usr/include/llvm-c-11 -I/usr/include/llvm-11 -L/usr/lib/i386-linux-gnu/ -lLLVM-11 ~/workarea/llvm_cpu_features_investigation.cpp

MacOS use case (Clang 10):
$clang -I/usr/local/opt/llvm/include/llvm-c -I/usr/local/opt/llvm/include -I/usr/local/Cellar/llvm/11.0.0/ -L/usr/local/opt/llvm/lib -L/usr/local/Cellar/llvm/11.0.0/lib -lLLVM -lstdc++ llvm_cpu_features_investigation.cpp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment