This is an archive of the discontinued LLVM Phabricator instance.

[Driver,AArch64] Add support for -mcpu=native.
ClosedPublic

Authored by fhahn on Jul 4 2018, 4:20 AM.

Details

Summary

This patches adds support for passing -mcpu=native for AArch64. It will
get turned into the host CPU name, before we get the target features.

CPU = native is handled in a similar fashion in
getAArch64MicroArchFetauresFromMtune and getAArch64TargetCPU already.

Having a good test case for this is hard, as it depends on the host CPU
of the machine running the test. But we can check that native has been
replaced with something else.

When cross-compiling, we will get a CPU name from the host architecture
and get the clang compiler does not support '-mcpu=native' as error
message, which seems reasonable to me.

Diff Detail

Event Timeline

fhahn created this revision.Jul 4 2018, 4:20 AM

Looks ok to me. I've checked that gcc also supports -mcpu=native on an AArch64 machine. It also supports -march=native. While I don't think that this is necessary to support it for this patch is it worth considering as well?

fhahn added a comment.Jul 4 2018, 10:07 AM

Looks ok to me. I've checked that gcc also supports -mcpu=native on an AArch64 machine. It also supports -march=native. While I don't think that this is necessary to support it for this patch is it worth considering as well?

Yep it should be possible to add support for -march=native by getting the host CPU and then getting the architecture version of the host CPU. I would prefer to do that in a separate patch, which I can put together tomorrow.

peter.smith accepted this revision.Jul 6 2018, 2:00 AM

Looks good to me.

This revision is now accepted and ready to land.Jul 6 2018, 2:00 AM
This revision was automatically updated to reflect the committed changes.