diff options
| author | Andreas T Jonsson <mail@andreasjonsson.se> | 2024-05-10 09:04:52 +0200 |
|---|---|---|
| committer | Andreas T Jonsson <mail@andreasjonsson.se> | 2024-05-10 09:04:52 +0200 |
| commit | b72c2edabbc9087b07a30b781de1925d6570dd62 (patch) | |
| tree | 0e96f43038901ec8c6f6b015071c1803a2166d41 /misc/featuregen/featuregen.cpp | |
| parent | 273e4c6b4ce6f1060870782c8e780fe2b371ede4 (diff) | |
| parent | 41bd8cf7143902db59c02c56fc5318a7e749d7a5 (diff) | |
Merge branch 'master' into netbsd
Diffstat (limited to 'misc/featuregen/featuregen.cpp')
| -rw-r--r-- | misc/featuregen/featuregen.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/misc/featuregen/featuregen.cpp b/misc/featuregen/featuregen.cpp new file mode 100644 index 000000000..a1d00ab31 --- /dev/null +++ b/misc/featuregen/featuregen.cpp @@ -0,0 +1,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; +} |