[PATCH] D83079: [clang][aarch64] Generate preprocessor macros for -march=armv8.6a+sve.

Sander de Smalen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 8 09:46:17 PDT 2020


sdesmalen added inline comments.


================
Comment at: clang/lib/Driver/ToolChains/Arch/AArch64.cpp:369
+  if (llvm::is_contained(Features, "+v8.6a")) {
+    if (!llvm::is_contained(Features, "-i8mm") &&
+        !llvm::is_contained(Features, "+noi8mm"))
----------------
fpetrogalli wrote:
> sdesmalen wrote:
> > Is this correct and/or necessary? I would expect LLVM to just handle features in the order they're passed, and the architecture version is always processed first, e.g. `-march=armv8.6-a+noi8mm` will always first process `armv8.6a` before processing features like `noi8mm`.
> I was expecting that too, but in in this place the `+i8mm` is added after whatever the user have passed to -march, which means that without this extra check the user input `-mattr=armv8.6a+sve+noimm8` becomes broken because we are adding `-target-feature=+i8mm` after `-i8mm`.  This behavior is guarded by a regression tests that starts failing if I don't use these extra checks. This was not needed in the original place were I added the functionality because the `+i8mm` was being added right after `+v8.6a` and before splitting up the `+sve+noi8mm`, so that the user input was the one (un)setting the feature.
As you said, we end up with a Feature list as follows:

  parsing(-march=armv8.6-a+noi8mm)
  => Features = [ v8.6a ]

  parsing(+noi8mm)
  => Features = [ v8.6a, -i8mm ]

  Then going through the feature list again:
  => Features = [ v8.6a, -i8mm, +i8mm ]
                  ^^^^^          ^^^^
                    \_____________/
                       adds +i8mm

To fix that, you can insert these features into the list straight after "+v8.6a", instead of appending at the end of the Features list. Either that, or calling `llvm::AArch64::getDefaultExtensions() + llvm::AArch64::getExtensionFeatures()` in `getAArch64ArchFeaturesFromMarch` like is done in `DecodeAArch64Mcpu`, which should do all this for free. That seems like a more invasive change though that you shouldn't try to do in this patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83079/new/

https://reviews.llvm.org/D83079





More information about the cfe-commits mailing list