This is an archive of the discontinued LLVM Phabricator instance.

Add accessors for MCSubtargetInfo CPU and Feature tables
AcceptedPublic

Authored by jrmuizel on Dec 23 2020, 6:10 PM.

Details

Summary

This is needed for -C target-cpu=help and -C target-feature=help in rustc

Diff Detail

Event Timeline

jrmuizel created this revision.Dec 23 2020, 6:10 PM
jrmuizel requested review of this revision.Dec 23 2020, 6:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 23 2020, 6:10 PM
nikic accepted this revision.Jan 17 2021, 1:51 AM

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.

This revision is now accepted and ready to land.Jan 17 2021, 1:51 AM

@nikic can you land this?

fhahn added a subscriber: fhahn.Jan 17 2021, 6:28 AM
fhahn added inline comments.
llvm/include/llvm/MC/MCSubtargetInfo.h
229

Can you add doc-comments for the new functions?

jrmuizel updated this revision to Diff 317217.Jan 17 2021, 6:56 AM

Add comments

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.

jrmuizel updated this revision to Diff 317250.Jan 17 2021, 5:04 PM

Update the doc comments to be less wrong.

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.

The fillValidCPUArchList() interface looks pretty annoying in that it's non-virtual. One needs to call different helper functions for each target.

fhahn added a comment.Jan 20 2021, 7:48 AM

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.

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.