[llvm-dev] How to find out the default CPU / Features String for a given triple?

David Spickett via llvm-dev llvm-dev at lists.llvm.org
Fri Jan 24 03:33:34 PST 2020

For CPU generic AArch64 target parser will choose armv8-a:

Which will expand to features crypto, floating point and simd.

So I'd expect a much smaller list of features, and v8.5-a doesn't sound correct either way for generic. Though your generated file's entry for "generic" looks okay at first glance:

For the triple "aarch64v8.1a-unknown-linux-unknown" you mentioned, clang does use the generic CPU name:
$ ./clang -target aarch64v8.1a-unknown-linux-unknown /tmp/test.c -o /dev/null -###
<...>"-target-cpu" "generic" "-target-feature" "+neon" <...>

There is no similar option to llvm-mc to tell you what features it actually expands to. You could look at the test file for some hints:

Though I don't think it's exhaustive. If you don't mind the hassle, adding some logging to llvm-mc might be the way to go if you can find the place with the final list of features.

David Spickett.

From: Andrew Kelley
Sent: Thursday, 23 January 2020 16:22
To: David Spickett; LLVM Dev
Subject: Re: [llvm-dev] How to find out the default CPU / Features String for a given triple?

On 1/23/20 5:04 AM, David Spickett wrote:
> Hi Andrew,
> What tools are you passing this triple to, and where did you get the
> list of features you showed? (looks like an MC level list to me)


  /// createTargetMachine - Create a target specific machine implementation
  /// for the specified \p Triple.
  /// \param TT This argument is used to determine the target machine
  /// feature set; it should always be provided. Generally this should be
  /// either the target triple from the module, or the target triple of the
  /// host if that does not exist.
  TargetMachine *createTargetMachine(StringRef TT, StringRef CPU,
                            StringRef Features,
                            const TargetOptions &Options,
                            Optional<Reloc::Model> RM,
                            Optional<CodeModel::Model> CM = None,
                            CodeGenOpt::Level OL = CodeGenOpt::Default,
                            bool JIT = false) const;

The list of features I showed comes from LLVM's
lib/Target/AArch64/AArch64.td file, processed into this file:

Next, the "generic" CPU is chosen, the feature corresponding to the
sub-arch (v8_5a) is added to the set given by the CPU, and then the set
is recursively populated with feature dependencies.

I'm trying to find out how to check my work here, and make sure the list
of features matches what LLVM chooses when empty strings are passed for
CPU and Features.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200124/2831cb97/attachment.html>

More information about the llvm-dev mailing list