[PATCH] D34686: [AArch64] Add hasFP16VectorArithmetic helper function. NFCI

Sjoerd Meijer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 28 03:51:56 PDT 2017


SjoerdMeijer updated this revision to Diff 104380.
SjoerdMeijer added a comment.

Thanks! I am now using llvm::AArch64::ArchKind. And I agree that the check for setting __ARM_FEATURE_QRDMX is suspicious. I will address this separately.


https://reviews.llvm.org/D34686

Files:
  lib/Basic/Targets.cpp


Index: lib/Basic/Targets.cpp
===================================================================
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -6186,9 +6186,8 @@
   unsigned CRC;
   unsigned Crypto;
   unsigned Unaligned;
-  unsigned V8_1A;
-  unsigned V8_2A;
   unsigned HasFullFP16;
+  llvm::AArch64::ArchKind ArchKind;
 
   static const Builtin::Info BuiltinInfo[];
 
@@ -6254,6 +6253,18 @@
            static_cast<unsigned>(llvm::AArch64::ArchKind::AK_INVALID);
   }
 
+  bool hasFP16VectorArithmetic() const {
+    if (FPU != NeonMode || !HasFullFP16)
+      return false;
+
+    switch(ArchKind) {
+    default:
+      return false;
+    case llvm::AArch64::ArchKind::AK_ARMV8_2A:
+      return true;
+    }
+  }
+
   void getTargetDefines(const LangOptions &Opts,
                         MacroBuilder &Builder) const override {
     // Target identification.
@@ -6318,9 +6329,10 @@
     if (Unaligned)
       Builder.defineMacro("__ARM_FEATURE_UNALIGNED", "1");
 
-    if (V8_1A)
+    if (ArchKind == llvm::AArch64::ArchKind::AK_ARMV8_1A)
       Builder.defineMacro("__ARM_FEATURE_QRDMX", "1");
-    if (V8_2A && FPU == NeonMode && HasFullFP16)
+
+    if (hasFP16VectorArithmetic())
       Builder.defineMacro("__ARM_FEATURE_FP16_VECTOR_ARITHMETIC", "1");
 
     // All of the __sync_(bool|val)_compare_and_swap_(1|2|4|8) builtins work.
@@ -6348,9 +6360,8 @@
     CRC = 0;
     Crypto = 0;
     Unaligned = 1;
-    V8_1A = 0;
-    V8_2A = 0;
     HasFullFP16 = 0;
+    ArchKind = llvm::AArch64::ArchKind::AK_ARMV8A;
 
     for (const auto &Feature : Features) {
       if (Feature == "+neon")
@@ -6362,9 +6373,9 @@
       if (Feature == "+strict-align")
         Unaligned = 0;
       if (Feature == "+v8.1a")
-        V8_1A = 1;
+        ArchKind = llvm::AArch64::ArchKind::AK_ARMV8_1A;
       if (Feature == "+v8.2a")
-        V8_2A = 1;
+        ArchKind = llvm::AArch64::ArchKind::AK_ARMV8_2A;
       if (Feature == "+fullfp16")
         HasFullFP16 = 1;
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34686.104380.patch
Type: text/x-patch
Size: 1983 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170628/82e2736a/attachment-0001.bin>


More information about the cfe-commits mailing list