[llvm] r280971 - AArch64 .arch directive - Include default arch attributes with extensions.

Eric Christopher via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 8 10:27:03 PDT 2016


Author: echristo
Date: Thu Sep  8 12:27:03 2016
New Revision: 280971

URL: http://llvm.org/viewvc/llvm-project?rev=280971&view=rev
Log:
AArch64 .arch directive - Include default arch attributes with extensions.

Fix the .arch asm parser to use the full set of features for the architecture
and any extensions on the command line. Add and update testcases accordingly
as well as add an extension that was used but not supported.

Modified:
    llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
    llvm/trunk/test/MC/AArch64/directive-arch-negative.s
    llvm/trunk/test/MC/AArch64/directive-arch.s

Modified: llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp?rev=280971&r1=280970&r2=280971&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp Thu Sep  8 12:27:03 2016
@@ -14,6 +14,7 @@
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/MC/MCContext.h"
@@ -28,6 +29,7 @@
 #include "llvm/MC/MCStreamer.h"
 #include "llvm/MC/MCSubtargetInfo.h"
 #include "llvm/MC/MCSymbol.h"
+#include "llvm/Support/Debug.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/TargetParser.h"
@@ -4193,6 +4195,7 @@ static const struct {
   { "crypto", {AArch64::FeatureCrypto} },
   { "fp", {AArch64::FeatureFPARMv8} },
   { "simd", {AArch64::FeatureNEON} },
+  { "ras", {AArch64::FeatureRAS} },
 
   // FIXME: Unsupported extensions
   { "lse", {} },
@@ -4217,12 +4220,45 @@ bool AArch64AsmParser::parseDirectiveArc
     return false;
   }
 
+  // Get the architecture and extension features.
+  std::vector<const char *> AArch64Features;
+  AArch64::getArchFeatures(ID, AArch64Features);
+  AArch64::getExtensionFeatures(AArch64::getDefaultExtensions("generic", ID),
+                                AArch64Features);
+
   MCSubtargetInfo &STI = copySTI();
-  STI.setDefaultFeatures("", "");
+  std::vector<std::string> ArchFeatures(AArch64Features.begin(), AArch64Features.end());
+  STI.setDefaultFeatures("generic", join(ArchFeatures.begin(), ArchFeatures.end(), ","));
+
+  SmallVector<StringRef, 4> RequestedExtensions;
   if (!ExtensionString.empty())
-    STI.setDefaultFeatures("", ("+" + ExtensionString).str());
-  setAvailableFeatures(ComputeAvailableFeatures(STI.getFeatureBits()));
+    ExtensionString.split(RequestedExtensions, '+');
 
+  FeatureBitset Features = STI.getFeatureBits();
+  for (auto Name : RequestedExtensions) {
+    bool EnableFeature = true;
+
+    if (Name.startswith_lower("no")) {
+      EnableFeature = false;
+      Name = Name.substr(2);
+    }
+
+    for (const auto &Extension : ExtensionMap) {
+      if (Extension.Name != Name)
+        continue;
+
+      if (Extension.Features.none())
+        report_fatal_error("unsupported architectural extension: " + Name);
+
+      FeatureBitset ToggleFeatures = EnableFeature
+                                         ? (~Features & Extension.Features)
+                                         : ( Features & Extension.Features);
+      uint64_t Features =
+          ComputeAvailableFeatures(STI.ToggleFeature(ToggleFeatures));
+      setAvailableFeatures(Features);
+      break;
+    }
+  }
   return false;
 }
 

Modified: llvm/trunk/test/MC/AArch64/directive-arch-negative.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AArch64/directive-arch-negative.s?rev=280971&r1=280970&r2=280971&view=diff
==============================================================================
--- llvm/trunk/test/MC/AArch64/directive-arch-negative.s (original)
+++ llvm/trunk/test/MC/AArch64/directive-arch-negative.s Thu Sep  8 12:27:03 2016
@@ -6,30 +6,27 @@
 # CHECK:	      ^
 
 	.arch armv8
+	aese v0.8h, v1.8h
 
-	fminnm d0, d0, d1
-
-# CHECK: error: instruction requires: fp-armv8
-# CHECK: 	fminnm d0, d0, d1
+# CHECK: error: invalid operand for instruction
+# CHECK: 	aese v0.8h, v1.8h
 # CHECK:	^
 
-	.arch armv8+fp
-
-# CHECK: '+fp' is not a recognized feature for this target (ignoring feature)
-
-	fminnm d0, d0, d1
+// We silently ignore invalid features.
+	.arch armv8+foo
+	aese v0.8h, v1.8h
 
-# CHECK: error: instruction requires: fp-armv8
-# CHECK: 	fminnm d0, d0, d1
+# CHECK: error: invalid operand for instruction
+# CHECK:	aese v0.8h, v1.8h
 # CHECK:	^
 
-	.arch armv8+neon
+	.arch armv8+crypto
 
 	.arch armv8
 
-	fminnm d0, d0, d1
+	aese v0.8h, v1.8h
 
-# CHECK: error: instruction requires: fp-armv8
-# CHECK: 	fminnm d0, d0, d1
+# CHECK: error: invalid operand for instruction
+# CHECK: 	aese v0.8h, v1.8h
 # CHECK:	^
 

Modified: llvm/trunk/test/MC/AArch64/directive-arch.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AArch64/directive-arch.s?rev=280971&r1=280970&r2=280971&view=diff
==============================================================================
--- llvm/trunk/test/MC/AArch64/directive-arch.s (original)
+++ llvm/trunk/test/MC/AArch64/directive-arch.s Thu Sep  8 12:27:03 2016
@@ -3,8 +3,10 @@
 	.arch armv8-a+crypto
 
 	aesd v0.16b, v2.16b
+	eor v0.16b, v0.16b, v2.16b
 
 # CHECK: 	aesd	v0.16b, v2.16b
+# CHECK:        eor     v0.16b, v0.16b, v2.16b
 
 	.arch armv8.1-a+ras
 	esb




More information about the llvm-commits mailing list