This is an archive of the discontinued LLVM Phabricator instance.

[X86] Support -march=x86-64-v[234]
ClosedPublic

Authored by MaskRay on Oct 10 2020, 4:13 PM.

Details

Summary

PR47686. These micro-architecture levels are defined in the x86-64 psABI:

https://gitlab.com/x86-psABIs/x86-64-ABI/-/commit/77566eb03bc6a326811cb7e9

GCC 11 will support these levels.

Note, -mtune=x86-64-v[234] are invalid and __builtin_cpu_is cannot be
used on them.

Diff Detail

Event Timeline

MaskRay created this revision.Oct 10 2020, 4:13 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptOct 10 2020, 4:13 PM
MaskRay requested review of this revision.Oct 10 2020, 4:13 PM
MaskRay added inline comments.Oct 10 2020, 5:08 PM
clang/test/Preprocessor/predefined-arch-macros-x86.c
21

I'll add it after D89198 is accepted.

Don't we need a change to X86.td too?

MaskRay updated this revision to Diff 297444.Oct 10 2020, 11:30 PM

Update X86.td ProcModel
Update llvm/test/CodeGen/X86/cpus-other.ll

MaskRay added inline comments.Oct 10 2020, 11:31 PM
llvm/lib/Target/X86/X86.td
581

X86_64V2Features = NHMFeatures + SSE2.

Since SSE2 is implied by SSE4.2 , this transformation is sound.

This revision is now accepted and ready to land.Oct 10 2020, 11:48 PM
RKSimon requested changes to this revision.Oct 11 2020, 12:26 AM

Please can you add an entry to the 12.00 release notes describing this? Maybe somewhere in the clang docs as well?

This revision now requires changes to proceed.Oct 11 2020, 12:26 AM
MaskRay updated this revision to Diff 297469.Oct 11 2020, 8:48 AM

Add release note
Fix F16C and BMI of x86-64-v3

MaskRay updated this revision to Diff 297473.Oct 11 2020, 9:49 AM

Test LAHF_SAHF
Update clang/docs/ReleaseNotes.rst
Update clang/test/CodeGen/attr-target-x86.c to test X86.td changes. Ideally "target-features" should be testable with llc to have better layering

Test LAHF_SAHF
Update clang/docs/ReleaseNotes.rst
Update clang/test/CodeGen/attr-target-x86.c to test X86.td changes. Ideally "target-features" should be testable with llc to have better layering

How does attr-target-x86.c test the X86.td changes?

MaskRay added a comment.EditedOct 11 2020, 11:37 AM

Test LAHF_SAHF
Update clang/docs/ReleaseNotes.rst
Update clang/test/CodeGen/attr-target-x86.c to test X86.td changes. Ideally "target-features" should be testable with llc to have better layering

How does attr-target-x86.c test the X86.td changes?

I was wrong. __attribute__((target("arch=..."))) cannot test features in X86.td. X86TargetParser.cpp implements the feature propagation mechanism.

I have checked the introduction of cooperlake, tigerlake, sapphirerapids and many other commits to X86.td, "what features are enabled in a processor" is mostly under-tested.

RKSimon added inline comments.Oct 12 2020, 2:30 AM
clang/docs/ReleaseNotes.rst
191–196

Fix the bullet point: '-'

Please can you extend this and describe whats in each level? It'd be good to have this in a longer term doc as well as the release notes will get wiped at 13.0.

MaskRay marked an inline comment as done.Oct 12 2020, 8:55 AM
MaskRay added inline comments.
clang/docs/ReleaseNotes.rst
191–196

Extended a bit. I think it is sufficient to include a link https://gitlab.com/x86-psABIs/x86-64-ABI/-/commit/77566eb03bc6a326811cb7e9

MaskRay marked an inline comment as done.Oct 12 2020, 8:55 AM

I'd prefer that our docs explicitly state what we've implemented instead of just referencing an external webpage.

Please add the full explanation to UserManual.rst under the "CPU Architectures Features and Limitations" x86 section for long term reference - the release notes can then just summarize it (and link to UserManual).

Sorry for pressuring on this but the lack of clear documentation on these abstractions is something that worries me.

MaskRay updated this revision to Diff 297612.Oct 12 2020, 9:34 AM

Update clang/docs/UsersManual.rst

MaskRay updated this revision to Diff 297613.Oct 12 2020, 9:36 AM

ReleaseNotes.rst: use ` :doc:UsersManual` ``

RKSimon accepted this revision.Oct 12 2020, 10:20 AM

LGTM - thank you!

This revision is now accepted and ready to land.Oct 12 2020, 10:20 AM
This revision was landed with ongoing or failed builds.Oct 12 2020, 10:30 AM
This revision was automatically updated to reflect the committed changes.