<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 id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<p style="margin-top:0; margin-bottom:0">Hi Manoj,</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">I tried a few other options myself:</p>
<p style="margin-top:0; margin-bottom:0">* function 'target' attribute - the list of extensions this supports isn't complete and it doesn't enable the ACLE macros needed for intrinsics</p>
<p style="margin-top:0; margin-bottom:0">* manually defining ACLE macros - this allows intrinsics and is additive but assumes that you're not relying on codegen to emit instructions. I don't think it helps the bug linked from the GN source either. (<a href="https://crbug.com/934016" class="OWAAutoLink">https://crbug.com/934016</a>)</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">So what you have is the best we can do right now.</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">Looking forward the problem I have with a '-mcrypto' is two fold:</p>
<p style="margin-top:0; margin-bottom:0">* What about other optional extensions? We'd need to add one for each, or at least every one people ask for and ideally get that into GCC too.</p>
<p style="margin-top:0; margin-bottom:0">* crypto specifically can mean different things depending on the base architecture. From Clang's point of view that's fine as it just adds a target feature 'crypto'. However later we might want to allow people to select
 which set of crypto extensions is added and we hit the same issue. (maybe you'd go with -mcrypto as an 'auto' and -mcrypto8.4-a etc, which is also ugly)</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">The other option would be to allow -march without a base architecture. E.g.</p>
<p style="margin-top:0; margin-bottom:0">-march=armv8-a+crc -march=+crypto</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">Or have them combine into some common set, which breaks existing behaviour:</p>
<p style="margin-top:0; margin-bottom:0">-march=armv8-a+crc -march=armv8.4-a+dsp -> -march=amv8-a+dsp+crc</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">Which gets into a lot of issues around how you choose the set of features. Smallest subset to target the minimal core, or largest to allow CPU detection code to compile?</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">So allowing march=+<ext> is the one that won't break existing builds but would be Clang only for now. I don't know enough to say whether the other Architectures would be able to support that.</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">My instinct is that this is something the build system needs to handle since it presumably has to support GCC as well. I understand that still leaves you specifying a base architecture per file, when you'd rather pull
 that from the main march.</p>
<p style="margin-top:0; margin-bottom:0">(plus you're putting arch specific special cases in your build config, which isn't great either)</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">>>> <span>As a result,  one of the "-march" options either specified by Chrome OS or crc32c build has to lose the race as there was no other way to specify crc+crypto additively.</span></p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">Is this not deterministic? I would assume either Chrome OS always wins or crc32c always wins. Tell me if I'm wrong.</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">Thanks,</p>
<p style="margin-top:0; margin-bottom:0">David Spickett.<br>
</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> Manoj Gupta <manojgupta@google.com><br>
<b>Sent:</b> 10 April 2019 17:15:00<br>
<b>To:</b> David Spickett<br>
<b>Cc:</b> cfe-dev@lists.llvm.org; llvm-dev@lists.llvm.org; nd; Peter Smith<br>
<b>Subject:</b> Re: [llvm-dev] [RFC] New Clang target selection options for ARM/AArch64</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div dir="ltr">
<div dir="ltr"><br>
</div>
<br>
<div class="x_gmail_quote">
<div dir="ltr" class="x_gmail_attr">On Wed, Apr 10, 2019 at 9:03 AM David Spickett <<a href="mailto:David.Spickett@arm.com">David.Spickett@arm.com</a>> wrote:<br>
</div>
<blockquote class="x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div id="x_gmail-m_1059601026612498003divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<p style="margin-top:0px; margin-bottom:0px">Hi Manoj,</p>
<p style="margin-top:0px; margin-bottom:0px"><br>
</p>
<p style="margin-top:0px; margin-bottom:0px">Not too late at all, we have not got to that point of the work yet.</p>
<p style="margin-top:0px; margin-bottom:0px"><br>
</p>
<p style="margin-top:0px; margin-bottom:0px">Are there examples of this kind of build setup that are available publicly? I think I understand the problem but it'd help to see one in action. To see if there are any other Arm extensions that are already being
 added like this and whether those systems support GCC and how.</p>
<p style="margin-top:0px; margin-bottom:0px"><br>
</p>
</div>
</div>
</blockquote>
<div>One example where we had to use "-Xclang -target-feature ... " is here:</div>
<div><a href="https://chromium.googlesource.com/chromium/src/+/refs/heads/master/third_party/crc32c/BUILD.gn#120">https://chromium.googlesource.com/chromium/src/+/refs/heads/master/third_party/crc32c/BUILD.gn#120</a></div>
<div><br>
</div>
<div>This had to be done because Chrome OS build system passes the exact "-march=value" depending on the ISA supported by Chromebook but crc32c wants crc+crypto for runtime cpu detection based code.</div>
<div><br>
</div>
<div>As a result,  one of the "-march" options either specified by Chrome OS or crc32c build has to lose the race as there was no other way to specify crc+crypto additively.<br>
</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Manoj</div>
<div> </div>
<blockquote class="x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div id="x_gmail-m_1059601026612498003divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<p style="margin-top:0px; margin-bottom:0px"></p>
<p style="margin-top:0px; margin-bottom:0px">Thanks,</p>
<p style="margin-top:0px; margin-bottom:0px">David Spickett.<br>
</p>
</div>
<hr style="display:inline-block; width:98%">
<div id="x_gmail-m_1059601026612498003divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> Manoj Gupta <<a href="mailto:manojgupta@google.com" target="_blank">manojgupta@google.com</a>><br>
<b>Sent:</b> 10 April 2019 16:34:16<br>
<b>To:</b> David Spickett<br>
<b>Cc:</b> <a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>;
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>; nd<br>
<b>Subject:</b> Re: [llvm-dev] [RFC] New Clang target selection options for ARM/AArch64</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div dir="ltr"><br>
</div>
<br>
<div class="x_gmail-m_1059601026612498003x_gmail_quote">
<div dir="ltr" class="x_gmail-m_1059601026612498003x_gmail_attr">On Fri, Sep 21, 2018 at 3:06 AM David Spickett via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
</div>
<blockquote class="x_gmail-m_1059601026612498003x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div id="x_gmail-m_1059601026612498003x_gmail-m_-4597810131691798127divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<p style="margin-top:0px; margin-bottom:0px"></p>
<div>Hi,</div>
<div><br>
</div>
<div>Below is a document detailing changes we'd like to make to Clang/LLVM to improve the usability of the target options for ARM and AArch64.</div>
<div><br>
</div>
<div>To keep things simple the proposed changes are listed at the start and you can find the supporting examples at the end of the document.</div>
<div><br>
</div>
<div>I look forward to your feedback.</div>
<div><br>
</div>
<div>Thanks,</div>
<div>David Spickett.</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>RFC New Clang target feature selection options for ARM/AArch64<br>
--------------------------------------------------------------<br>
<br>
In this RFC we propose changes to ARM and AArch64 target selection. With the top level goals to:<br>
- validate that given options make sense within architectural restrictions<br>
- make option discovery and documentation easier<br>
- unify the list of extensions that command lines and asm directives use<br>
- bring the options closer to GCC's where appropriate<br>
<br>
Current Options Comparison<br>
--------------------------<br>
<br>
                       | GCC           | Clang         |<br>
                       |-------------------------------|<br>
                       | ARM | AArch64 | ARM | AArch64 |<br>
|----------------------|-----|---------|-----|---------|<br>
| -march with '+<ext>' | Y   | Y       | Y   | Y       |<br>
| checks extensions    | Y   | N       | N   | N       |<br>
| .arch with '+<ext>'  | N   | N       | N   | Y       |<br>
| .arch_extension      | Y   | Y       | Y   | N       |<br>
| .fpu                 | Y   | N       | Y   | N       |<br>
| -mfpu                | Y   | N       | Y   | N       |<br>
| checks FPUs          | N   | n/a     | N   | n/a     |<br>
|----------------------|-----|---------|-----|---------|<br>
<br>
Examples of each of these can be found at the end of this document.<br>
<br>
Problems With the Current Options<br>
---------------------------------<br>
<br>
- You cannot select all extensions through an assembly directive, since the AsmParser's list is a separate subset of the complete one in TargetParser.<br>
- Combinations of options are not checked for compatibility.<br>
- Many extensions are tied to their base architecture, though it is valid to add them individually to a previous v8.x-a architecture.<br>
- Users need to work out what FPU they need for ARM, this should be implied by the selected arch and extensions.<br>
- Discovery of valid extensions is difficult, both for the user and for the purposes of generating documentation.<br>
<br>
Proposed solution<br>
------------------<br>
<br>
ARM and AArch64:<br>
- Make the TargetParser the single source for extension names, removing the AsmParser tables.<br>
- Reject unknown extension names with a diagnostic that includes a list of valid extensions for that architecture/CPU.<br>
- Reject invalid combinations of architecture/CPU and extensions with an error diagnostic.<br>
- Add independent subtarget features for each extension so that v8.x+1-a extensions can be used individually with earlier v8.x-a architectures where allowed.<br>
- Emit a warning when a mandatory feature of the base architecture is enabled with '+extension', or disabled with '+noextension'. (and ignore the option)<br>
- Errors caused by the solution above should be able to be downgraded to warnings with the usual -W* options. This applies only to cases where there is a reasonable interpretation of the options chosen.<br>
<br>
ARM:<br>
- Allow all possible ARM extensions in the '.arch_extension' directive, without the '+' syntax<br>
(allow them to be recognised, they could still be rejected for compatibility).<br>
- Add an 'auto' value for -mfpu and make it the default. Meaning that the FPU is implied by mcpu/march. If mfpu is not auto, it should override other options and a warning should be emitted.<br>
- Reject invalid mfpu and march/mcpu combinations with an error diagnostic.<br>
- Reject invalid arch/cpu and extension combinations with an error diagnostic.<br>
<br>
Optional features<br>
-----------------<br>
<br>
AArch64:<br>
- add the '.arch_extension' directive, with the same behaviour as ARM (no '+', one extension per directive). This brings Clang in line with GCC which has this directive for both architectures. Clang does however allow you to achieve the same thing by using
 '+' with '.arch'.<br>
<br>
ARM:<br>
- Allow '+' in '.arch' and '.cpu'. GCC does not allow this, but it would make ARM/AArch64 more consistent within Clang.<br>
<br>
Options Comparison With the Proposed Solution<br>
----------------------------------------------<br>
<br>
Anything in brackets has changed from the previous table.<br>
<br>
                       | GCC           | Clang             |<br>
                       |-----------------------------------|<br>
                       | ARM | AArch64 | ARM     | AArch64 |<br>
|----------------------|-----|---------|---------|---------|<br>
| -march with '+<ext>' | Y   | Y       | Y       | Y       |<br>
| checks extensions    | Y   | N       | (Y)     | (Y)     |<br>
| .arch with '+<ext>'  | N   | N       | (Y)     | Y       | (optional)<br>
| .arch_extension      | Y   | Y       | Y       | (Y)     | (optional)<br>
| -mfpu                | Y   | N       | Y       | N       |<br>
| .fpu                 | Y   | N       | Y       | N       |<br>
| checks FPUs          | N   | n/a     | (Y)     | n/a     |<br>
|----------------------|-----|---------|---------|---------|<br>
<br>
Implementation<br>
--------------<br>
<br>
Use of Table-gen<br>
================<br>
<br>
The current implementation of TargetParser has a number of FIXME comments saying that it should be changed to use tablegen instead of pre processor macros. There are several advantages of porting TargetParser to tablegen:<br>
- more readable than the current macros<br>
- allows default/optional values more easily<br>
- we can generate code and documentation from the same source<br>
- easier to add new properties<br>
<br>
Drawbacks:<br>
- it requires a new tablegen backend to generate the include files<br>
- additional indirection which could make debugging and future changes more difficult<br>
<br>
We think the benefits outweigh the disadvantages in this case.<br>
<br>
To do this, we would need to move TargetParser to break the cyclic dependency of LLVMSupport -> llvm-tblgen -> LLVMSupport. There are 2 options for this:<br>
1. create a new LLVMTargetParser library that contains all parsers for architectures that use it.<br>
2. put the TargetParser for each backend in the library group for that backend. This requires one of:<br>
    * Relaxing the requirement that target parsers must be built even if the backend is not.<br>
    * Modifying the CMake scripts to build the target parsers even if the backend is not being built.<br>
<br>
Option 1 is simpler but option 2 would allow us to make use of the existing tablegen files in the backends so it is preferred.<br>
<br>
Using existing SubTarget features<br>
=================================<br>
<br>
If we go with option 2 above, we can reuse the existing subtarget features to work out any dependencies.<br>
<br>
We have a prototype that took option 1 above. The command line is converted into a sequence of options and resolved by the LLVM backend. This means that Clang does not know exactly what will be enabled. It needs to know this to output the correct pre processor
 feature test macros.<br>
<br>
Consider this AArch64 march:<br>
-march=armv8.4-a+crypto+nosha2<br>
<br>
The base arch is armv8.4-a, the crypto extension turns on AES/SHA2/SHA3/SM4. The nosha2 disables SHA2/SHA3 (since SHA3 is dependant on SHA2). Each of these features has an ACLE feature test macro, so Clang needs to know that nosha2 also disables SHA3.<br>
<br>
New Errors and Warnings<br>
=======================<br>
<br>
Whether these are errors or warnings by default is up for debate. This is a suggestion to begin with.<br>
(these apply to cmd lines and directives unless stated)<br>
<br>
Errors:<br>
- unknown extension in an assembly directive (currently fails silently)<br>
- extension incompatible with base arch, message shows the base arch it requires.<br>
- extension requires another which is disabled later, message shows which one is required.<br>
- extension requires another which is not enabled, message shows requirements.<br>
- ARM mfpu option is not 'auto' and is incompatible with the base arch, message shows list of valid FPUs.<br>
<br>
Warnings:<br>
- ARM mfpu option is not auto and another option implies a different FPU than the mfpu value. The mfpu value will be used, and the message will show what was overridden.<br>
- mandatory feature of the base arch is enabled with '+' (option is redundant so is ignored)<br>
- mandatory feature of a base arch is disabled with '+no<feature>' (option makes no sense so the extension remains enabled)<br>
<br>
Proposed diagnostic names: (in the same order as above)<br>
- "target-feature" (top level group)<br>
    - "incompatible-feature"<br>
      - "extension-requirement-disabled"<br>
    - "extension-requires"<br>
    - "incompatible-fpu"<br>
    - "implied-fpu-unused"<br>
    - "mandatory-feature-ignored"<br>
    - "mandatory-feature-disabled"<br>
<br>
"Negative" Backend Features<br>
===========================<br>
<br>
There are a couple of features in ARM which remove capabilities rather than adding them. These are 'd16' (removes the top 16 D registers) and 'fp-only-sp' (removes double precision).<br>
It would simplify the implementation if those were replaced with positive options. As in one that adds the top 16 D registers and one that enables double precision operations.<br>
<br>
This is a relatively simple change to LLVM but it will effect a large number of tests and would be a breaking change for users of LLVM as a library.<br>
<br>
.arch_extension Directive<br>
=========================<br>
<br>
Regardless of '.arch_extension' being added to AArch64, it has some issues that need to be addressed for the rest of these changes.
<br>
<br>
Extensions can now have different meanings based on the base architecture they apply to. For example on AArch64, 'crypto' means different things for v8.{1,2,3}-a than v8.4-a. The former adds 'sha2' and 'aes', the latter adds those and 'sm4' and 'sha3' on top.<br>
<br>
We can handle this in a few of ways:<br>
- Remove .arch_extension in favour of .arch. This conflicts with the option above to add it to AArch64 to bring us in line with GCC, and will break a lot of code written for older versions of Clang.<br>
- Only accept options which do not vary with base architecture. For ARM, only the FPU options vary, and there is the .fpu directive for those. If we do decide to add .arch_extension to AArch64 this will mean that things like crypto will only be valid in .arch.<br>
- Track the current base target, as implied by the command line or the last .arch/.cpu directive. This makes the directives as similar to the command lines as they can be without breaking backwards compatibility.<br>
<br>
The last option makes the most sense to us, certainly if we want to add .arch_extension to AArch64 in a straightforward way.<br>
<br>
ARM Assembly Directives<br>
=======================<br>
<br>
As discussed for AArch64 the ARM assembly directives ('.arch', '.cpu', '.fpu', '.arch_extension') should be updated to use the new target parser. Giving them access to a complete list of features.<br>
<br>
'.arch' and '.cpu' supporting the '+' syntax is mentioned as an optional goal above. This makes ARM/AArch64 consistent within Clang but breaks from GCC's features.<br>
<br>
Current Command Line Option Examples<br>
------------------------------------<br>
<br>
Clang ARM<br>
=========<br>
<br>
Extensions can be used with '+<{no}extension>' syntax on march or mcpu, there is no checking that the combinations are valid. The FPU is selected with -mfpu and this is not validated either.<br>
<br>
$ ./clang --target=arm-arm-none-eabi -march=armv8.2-a -mfpu=none -c /tmp/test.c -o /tmp/test.o<br>
$ ./clang --target=arm-arm-none-eabi -mcpu=cortex-a53+dotprod -c /tmp/test.c -o /tmp/test.o<br>
(can't use dotprod with v8-a)<br>
<br>
$ ./clang --target=arm-arm-none-eabi -march=armv7-m -mfpu=neon-fp16 -c /tmp/test.c -o /tmp/test.o<br>
(should be invalid but is allowed)<br>
<br>
GCC ARM<br>
=======<br>
<br>
For GCC it is the same except that mfpu defaults to 'auto', meaning that the value is implied by other options. Extensions are checked for compatibility with the base architecture but FPUs are not.<br>
<br>
$ ./arm-eabi-gcc -mcpu=cortex-a53 -mfpu=neon -c /tmp/test.c -o /tmp/test.o<br>
$ ./arm-eabi-gcc -march=armv8-a -mfpu=auto -c /tmp/test.c -o /tmp/test.o<br>
<br>
$ ./arm-eabi-gcc -march=armv8-a+dotprod -c /tmp/test.c -o /tmp/test.o<br>
arm-eabi-gcc: error: 'armv8-a' does not support feature 'dotprod'<br>
arm-eabi-gcc: note: valid feature names are: crc simd crypto nocrypto nofp<br>
<br>
$ ./arm-eabi-gcc -march=armv7-m -mfpu=neon-fp16 -c /tmp/test.c -o /tmp/test.o<br>
(same example given for Clang above, should be invalid)<br>
<br>
Clang AArch64<br>
=============<br>
<br>
The '+' syntax still applies but mfpu is replaced with '+' extensions.<br>
<br>
$ ./clang --target=aarch64-arm-none-eabi -march=armv8.2-a -mfpu=none -c /tmp/test.c -o /tmp/test.o<br>
clang-7: warning: argument unused during compilation: '-mfpu=none' [-Wunused-command-line-argument]<br>
$ ./clang --target=aarch64-arm-none-eabi -march=armv8.2-a+nofp -c /tmp/test.c -o /tmp/test.o<br>
$ ./clang --target=aarch64-arm-none-eabi -march=armv8-a+crypto -c /tmp/test.c -o /tmp/test.o<br>
<br>
Dependencies within extensions are not checked. For example crypto requires simd, but it can be disabled in the same march option.<br>
<br>
$ ./clang --target=aarch64-arm-none-eabi -march=armv8-a+crypto+nosimd -c /tmp/test.c -o /tmp/test.o<br>
<br>
</div>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>It is a bit late to reply but can the options be specified independently of "-march". i.e.  -march=armv8-a -mcrypto -mnosimd etc. similar to "-msse", "-mavx" on x86.</div>
<div>This is for situations where certain packages e.g. media packages want to enable certain features based on runtime cpu detection.</div>
<div>To enable e.g. "crypto", they are also forced to choose a march, but that could override the architecture specified by the build system </div>
<div>( or could get overridden by the -march specified by build system). e.g. it makes little sense for "-march=armv8-a+extension" to override the build system "-march=armv8.3-a"</div>
<div> and vice-versa when the only desire is to enable the specific extension additively.</div>
<div><br>
</div>
<div>The additive alternative is to use "-Xclang -target-feature -Xclang +feature" which is pretty ugly.</div>
<div><br>
</div>
<div>Thanks</div>
<div><br>
</div>
<blockquote class="x_gmail-m_1059601026612498003x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div id="x_gmail-m_1059601026612498003x_gmail-m_-4597810131691798127divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<div>Dependencies between an extension and the base arch are not checked either. Dot product cannot be used with v8.0-a but it is allowed.<br>
<br>
$ ./clang --target=aarch64-arm-none-eabi -march=armv8-a+dotprod -c /tmp/test.c -o /tmp/test.o<br>
<br>
GCC AArch64<br>
===========<br>
<br>
For GCC AArch64 mfpu is also dropped in favour of '+' extensions.<br>
<br>
$ ./aarch64-elf-gcc -march=armv8.2-a -mfpu=none -c /tmp/test.c -o /tmp/test.o<br>
aarch64-elf-gcc: error: unrecognized command line option '-mfpu=none'; did you mean '-gz=none'?<br>
<br>
Extensions are rejected if not recognised but not checked for compatibility. Hence the Clang crypto/simd example above is allowed with GCC too.<br>
<br>
$ ./aarch64-elf-gcc -march=armv8.2-a+food -c /tmp/test.c -o /tmp/test.o<br>
cc1: error: invalid feature modifier in '-march=armv8.2-a+food'<br>
$ ./aarch64-elf-gcc -march=armv8.2-a+dotprod -c /tmp/test.c -o /tmp/test.o<br>
$ ./aarch64-elf-gcc -march=armv8-a+dotprod -c /tmp/test.c -o /tmp/test.o<br>
(should not be allowed)<br>
$ ./aarch64-elf-gcc -march=armv8-a+crypto+nosimd -c /tmp/test.c -o /tmp/test.o<br>
(should not be allowed)<br>
<br>
Current Assembly Directive Examples<br>
-----------------------------------<br>
<br>
Clang .arch/.arch_extension<br>
===========================<br>
<br>
AArch64 uses .arch and '+' syntax, ARM uses .arch_extension/.arch and does not support '+' syntax in either.<br>
<br>
In both arches, the list of possible extensions is not complete since it is separate from the one in TargetParser. So there is no way to enable dotprod (amongst other things) with a directive.<br>
<br>
(example is using AArch64)<br>
.arch armv8.2-a # error: instruction requires: dotprod<br>
udot v0.2s, v1.8b, v2.8b<br>
<br>
.arch armv8.2-a+dotprod # error: instruction requires: dotprod<br>
udot v0.2s, v1.8b, v2.8b<br>
<br>
ARM uses the .arch_extension directive which is one extension per use, with no '+'.<br>
<br>
.arch armv7-a #error: instruction requires: crc armv8<br>
CRC32B r0, r1, r2<br>
<br>
.arch armv8-a+crc #error: Unknown arch name<br>
CRC32B r0, r1, r2<br>
<br>
.arch armv8-a # no error<br>
.arch_extension crc<br>
CRC32B r0, r1, r2<br>
<br>
You can see here that though ARM march/mcpu would understand +crc, the assembly directive does not.<br>
<br>
ARM does check validity of extensions provided with '.arch_extension'.<br>
<br>
.arch armv7-a<br>
.arch_extension crc <br>
CRC32B r0, r1, r2<br>
<br>
main.s:20:17: error: architectural extension 'crc' is not allowed for the current base architecture<br>
.arch_extension crc<br>
<br>
AArch64 only rejects known extensions that aren't supported at all.<br>
<br>
.arch armv8-a+pan # unsupported architectural extension: pan<br>
nop<br>
<br>
Neither ARM or AArch64 know about the inter dependencies between extensions. So the example from the command lines applies here too.<br>
<br>
(example is using AArch64)<br>
.arch armv8-a+crypto+nosimd # no error/warning, crypto requires simd<br>
nop<br>
<br>
GCC .arch/.arch_extension<br>
=========================<br>
<br>
GCC is more consistent across the two arches, both use .arch and .arch_extension. Neither understand the '+' syntax.<br>
<br>
.arch armv8-a+crc # invalid<br>
<br>
.arch armv8-a # valid<br>
.arch_extension crc<br>
<br>
.arch_extension crc # valid<br>
.arch_extension crc+crypto #invalid<br>
<br>
For extensions that vary based on base architecture, GCC tracks the last known arch.<br>
<br>
Clang .fpu<br>
==========<br>
<br>
.fpu is only available for ARM. Values are not checked for compatibility, only rejected if completely unknown.<br>
<br>
./clang --target=aarch64-arm-none-eabi -march=armv8-a -c /tmp/test.s -o /tmp/test.o<br>
/tmp/test.s:1:1: error: unknown directive<br>
.fpu neon <br>
^<br>
<br>
$ ./clang --target=arm-arm-none-eabi -march=armv7-m -c /tmp/test.s -o /tmp/test.o<br>
/tmp/test.s:1:6: error: Unknown FPU name<br>
.fpu clearly-not-valid<br>
     ^<br>
<br>
(same example as 'Clang ARM' command lines, should be invalid)<br>
$ cat /tmp/test.s<br>
.fpu neon-fp16<br>
$ ./clang --target=arm-arm-none-eabi -march=armv7-m -c /tmp/test.s -o /tmp/test.o<br>
<br>
GCC .fpu<br>
========<br>
<br>
.fpu is provided for ARM only and the FPU names are not checked against the base arch or CPU.<br>
<br>
This is correctly rejected from a command line:<br>
$ ./arm-eabi-gcc -march=armv6zk+neon -c /tmp/test.s -o /tmp/test.o<br>
arm-eabi-gcc: error: 'armv6zk' does not support feature 'neon'<br>
arm-eabi-gcc: note: valid feature names are: fp nofp vfpv2<br>
<br>
Whereas the directive is accepted:<br>
$ cat /tmp/test.s<br>
.fpu neon<br>
nop<br>
$ ./arm-eabi-gcc -march=armv6zk -c /tmp/test.s -o /tmp/test.o<br>
<br>
For AArch64 .fpu is removed in favour of .arch_extension. Instead of directly selecting an FPU it is implied by the extensions used.<br>
<br>
$ cat /tmp/test.s<br>
.fpu neon<br>
$ ./aarch64-elf-gcc -march=armv8-a+simd -c /tmp/test.s -o /tmp/test.o<br>
/tmp/test.s: Assembler messages:<br>
/tmp/test.s:1: Error: unknown pseudo-op: `.fpu'<br>
<br>
$ cat /tmp/test.s<br>
.arch_extension simd <br>
$ ./aarch64-elf-gcc -march=armv8-a -c /tmp/test.s -o /tmp/test.o<br>
<br>
References<br>
----------<br>
<br>
Crypto extension requires SIMD: <a href="http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0500e/CJHDEBAF.html" target="_blank">
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0500e/CJHDEBAF.html</a><br>
GCC ARM options: <a href="https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html" target="_blank">
https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html</a><br>
GCC ARM directives: <a href="https://sourceware.org/binutils/docs/as/ARM-Directives.html" target="_blank">
https://sourceware.org/binutils/docs/as/ARM-Directives.html</a><br>
GCC AArch64 options: <a href="https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html" target="_blank">
https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html</a><br>
GCC AArch64 directives: <a href="https://sourceware.org/binutils/docs/as/AArch64-Directives.html" target="_blank">
https://sourceware.org/binutils/docs/as/AArch64-Directives.html</a></div>
<br>
<p></p>
</div>
</div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</body>
</html>