blob: a1d00ab31c184df7239a1ad1238560a6ba52497d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#include <llvm/MC/MCSubtargetInfo.h>
#include <llvm/MC/TargetRegistry.h>
#include <llvm/Support/raw_ostream.h>
#include <llvm/ADT/ArrayRef.h>
#include <llvm/Support/InitLLVM.h>
#include <llvm/Support/TargetSelect.h>
// Dumps the default set of supported features for the given microarch.
int main(int argc, char **argv) {
if (argc < 3) {
llvm::errs() << "Error: first arg should be triple, second should be microarch\n";
return 1;
}
llvm::InitializeAllTargets();
llvm::InitializeAllTargetMCs();
std::string error;
const llvm::Target* target = llvm::TargetRegistry::lookupTarget(argv[1], error);
if (!target) {
llvm::errs() << "Error: " << error << "\n";
return 1;
}
auto STI = target->createMCSubtargetInfo(argv[1], argv[2], "");
std::string plus = "+";
llvm::ArrayRef<llvm::SubtargetFeatureKV> features = STI->getAllProcessorFeatures();
for (const auto& feature : features) {
if (STI->checkFeatures(plus + feature.Key)) {
llvm::outs() << feature.Key << "\n";
}
}
return 0;
}
|