This is needed for -C target-cpu=help and -C target-feature=help in rustc
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Time | Test | |
---|---|---|
15,410 ms | x64 debian > LLVM.Bindings/Go::go.test | |
70 ms | x64 windows > LLVM.CodeGen/XCore::threads.ll |
Event Timeline
LGTM. I'm not particularly familiar with this code, but don't see an issue with exposing this information. Currently MCSubtargetInfo directly incorporates the logic for printing a help text to the error stream, which is very dubious design. It should be possible to obtain the same information for printing a help text manually.
llvm/include/llvm/MC/MCSubtargetInfo.h | ||
---|---|---|
229 | Can you add doc-comments for the new functions? |
I’m not against this, but do want to mention the help text is incorrect for x86-64. It lists CPUs that don’t support 64-bit. Using one of those CPUs will trigger a fatal error. A better list is fillValidCPUList from X86TargetParser.cpp in lib/Support. It takes a mode argument. That’s the interface clang uses.
I filed https://github.com/rust-lang/rust/issues/81148 about improving the list the Rust uses.
The fillValidCPUArchList() interface looks pretty annoying in that it's non-virtual. One needs to call different helper functions for each target.
The current situation with TargetParser is indeed a bit unfortunate/half baked/unfinished. But I think it wold be preferable to improve the ergonomics of fillValidCPUArchList, rather than introducing a separate interface that duplicates the functionality and sometimes provides incorrect results. IMO there should be one interface used by frontends to obtain the information about supported CPUs.
Can you add doc-comments for the new functions?