<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
For CPU generic AArch64 target parser will choose armv8-a:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<a href="https://github.com/llvm/llvm-project/blob/master/llvm/lib/Support/AArch64TargetParser.cpp#L51" id="LPNoLP488715">https://github.com/llvm/llvm-project/blob/master/llvm/lib/Support/AArch64TargetParser.cpp#L51</a></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Which will expand to features crypto, floating point and simd.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<a href="https://github.com/llvm/llvm-project/blob/master/llvm/include/llvm/Support/AArch64TargetParser.def#L20" id="LPlnk543328">https://github.com/llvm/llvm-project/blob/master/llvm/include/llvm/Support/AArch64TargetParser.def#L20</a></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
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:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<a href="https://github.com/ziglang/zig/blob/c86589a738e5053a26b2be7d156bcfee1565f00b/lib/std/target/aarch64.zig#L1340" id="LPlnk518547">https://github.com/ziglang/zig/blob/c86589a738e5053a26b2be7d156bcfee1565f00b/lib/std/target/aarch64.zig#L1340</a><br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
For the triple "<font size="2"><span style="font-size:11pt"><span>a</span>arch64v8.1a-unknown-linux-unknown</span></font>" you mentioned, clang does use the generic CPU name:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>$ ./clang -target aarch64v8.1a-unknown-linux-unknown /tmp/test.c -o /dev/null -###</span><br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<...>"-target-cpu" "generic" "-target-feature" "+neon"<span></span> <...></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
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:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<a href="https://github.com/llvm/llvm-project/blob/master/llvm/unittests/Support/TargetParserTest.cpp" id="LPlnk132619">https://github.com/llvm/llvm-project/blob/master/llvm/unittests/Support/TargetParserTest.cpp</a></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
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.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thanks,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
David Spickett.<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0);">
<br>
<hr tabindex="-1" style="display:inline-block; width:98%;">
<b>From:</b> Andrew Kelley<br>
<b>Sent:</b> Thursday, 23 January 2020 16:22<br>
<b>To:</b> David Spickett; LLVM Dev<br>
<b>Subject:</b> Re: [llvm-dev] How to find out the default CPU / Features String for a given triple?
<div><br>
</div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">On 1/23/20 5:04 AM, David Spickett wrote:<br>
> Hi Andrew,<br>
> <br>
> What tools are you passing this triple to, and where did you get the<br>
> list of features you showed? (looks like an MC level list to me)<br>
<br>
include/llvm/Support/TargetRegistry.h<br>
<br>
  /// createTargetMachine - Create a target specific machine implementation<br>
  /// for the specified \p Triple.<br>
  ///<br>
  /// \param TT This argument is used to determine the target machine<br>
  /// feature set; it should always be provided. Generally this should be<br>
  /// either the target triple from the module, or the target triple of the<br>
  /// host if that does not exist.<br>
  TargetMachine *createTargetMachine(StringRef TT, StringRef CPU,<br>
                            StringRef Features,<br>
                            const TargetOptions &Options,<br>
                            Optional<Reloc::Model> RM,<br>
                            Optional<CodeModel::Model> CM = None,<br>
                            CodeGenOpt::Level OL = CodeGenOpt::Default,<br>
                            bool JIT = false) const;<br>
<br>
<br>
<br>
The list of features I showed comes from LLVM's<br>
lib/Target/AArch64/AArch64.td file, processed into this file:<br>
<a href="https://github.com/ziglang/zig/blob/c86589a738e5053a26b2be7d156bcfee1565f00b/lib/std/target/aarch64.zig" target="_blank" rel="noopener noreferrer" data-auth="NotApplicable">https://github.com/ziglang/zig/blob/c86589a738e5053a26b2be7d156bcfee1565f00b/lib/std/target/aarch64.zig</a><br>
<br>
Next, the "generic" CPU is chosen, the feature corresponding to the<br>
sub-arch (v8_5a) is added to the set given by the CPU, and then the set<br>
is recursively populated with feature dependencies.<br>
<br>
I'm trying to find out how to check my work here, and make sure the list<br>
of features matches what LLVM chooses when empty strings are passed for<br>
CPU and Features.<br>
<br>
</div>
</span></font></div>
</body>
</html>