[all-commits] [llvm/llvm-project] f0e6c4: [AArch64] Allow users-facing feature names in clan...

David Green via All-commits all-commits at lists.llvm.org
Tue Nov 8 11:30:38 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f0e6c403c2d399e4fd821aa5a7e4a20534494c71
      https://github.com/llvm/llvm-project/commit/f0e6c403c2d399e4fd821aa5a7e4a20534494c71
  Author: David Green <david.green at arm.com>
  Date:   2022-11-08 (Tue, 08 Nov 2022)

  Changed paths:
    M clang/lib/Basic/Targets/AArch64.cpp
    M clang/test/CodeGen/aarch64-targetattr.c
    M clang/test/Sema/aarch64-fp16-target.c

  Log Message:
  -----------
  [AArch64] Allow users-facing feature names in clang target attributes

D133848 added support for the GCC format of target("..") attributes. The
supported formats to match gcc are:
//  "arch=<arch>" - parsed to features as per -march=..
//  "cpu=<cpu>" - parsed to features as per -mcpu=.., with CPU set to <cpu>
//  "tune=<cpu>" - TuneCPU set to <cpu>
//  "+feature", "+nofeature" - Add (or remove) feature.

We also support the existing formats, previously accepted by clang, for
compatibility with the existing code and intrinsics code:
//  "feature", "no-feature" - Add (or remove) feature.

The clang formats would accept and use internal feature names
("fullfp16"/"neon"/"sve") as opposed to the user facing names
("fp16"/"simd"/"sve"). Usually they use the same names, but can be
different for cases like fp, fullfp16 and mte (among others).

This patch makes the clang format also except the user facing names, by
parsing the features through getArchExtFeature. There is a fallback if
the name is not recognized (like "fullfp16"), where we add the existing
string which should then be checked later for consistency. This allows
the internal names to be used as before, so long as they are recognized
as internal names. (Note that we currently don't have an implementation
of isValidFeatureName. The backend will currently give an error like
"'-sid' is not a recognized feature for this target (ignoring feature)."
This should be improved in a later patch once an implementation of
isValidFeatureName in clang is present).

Differential Revision: https://reviews.llvm.org/D137617




More information about the All-commits mailing list