[ARM64] Support crc predicate on ARM64.
authorKevin Qin <Kevin.Qin@arm.com>
Fri, 25 Apr 2014 09:25:42 +0000 (09:25 +0000)
committerKevin Qin <Kevin.Qin@arm.com>
Fri, 25 Apr 2014 09:25:42 +0000 (09:25 +0000)
According to the specification, CRC is an optional extension of the
architecture.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207214 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM64/ARM64.td
lib/Target/ARM64/ARM64InstrFormats.td
lib/Target/ARM64/ARM64InstrInfo.td
lib/Target/ARM64/ARM64Subtarget.cpp
lib/Target/ARM64/ARM64Subtarget.h
test/CodeGen/ARM64/crc32.ll
test/MC/ARM64/basic-a64-instructions.s
test/MC/ARM64/diagno-predicate.s
test/MC/Disassembler/ARM64/crc32.txt

index 69a126ce6a857970a87e3b53a321c974ea7f40f8..653f157415831d3df305f903565f30b21d892bd4 100644 (file)
@@ -29,6 +29,9 @@ def FeatureNEON : SubtargetFeature<"neon", "HasNEON", "true",
 def FeatureCrypto : SubtargetFeature<"crypto", "HasCrypto", "true",
   "Enable cryptographic instructions">;
 
+def FeatureCRC : SubtargetFeature<"crc", "HasCRC", "true",
+  "Enable ARMv8 CRC-32 checksum instructions">;
+
 /// Cyclone has register move instructions which are "free".
 def FeatureZCRegMove : SubtargetFeature<"zcm", "HasZeroCycleRegMove", "true",
                                         "Has zereo-cycle register moves">;
@@ -63,22 +66,27 @@ def ProcA53     : SubtargetFeature<"a53", "ARMProcFamily", "CortexA53",
                                    "Cortex-A53 ARM processors",
                                    [FeatureFPARMv8,
                                    FeatureNEON,
-                                   FeatureCrypto]>;
+                                   FeatureCrypto,
+                                   FeatureCRC]>;
 
 def ProcA57     : SubtargetFeature<"a57", "ARMProcFamily", "CortexA57",
                                    "Cortex-A57 ARM processors",
                                    [FeatureFPARMv8,
                                    FeatureNEON,
-                                   FeatureCrypto]>;
+                                   FeatureCrypto,
+                                   FeatureCRC]>;
 
 def ProcCyclone : SubtargetFeature<"cyclone", "ARMProcFamily", "Cyclone",
                                    "Cyclone",
                                    [FeatureFPARMv8,
                                    FeatureNEON,
                                    FeatureCrypto,
+                                   FeatureCRC,
                                    FeatureZCRegMove, FeatureZCZeroing]>;
 
-def : ProcessorModel<"generic", NoSchedModel, [FeatureFPARMv8, FeatureNEON]>;
+def : ProcessorModel<"generic", NoSchedModel, [FeatureFPARMv8,
+                                              FeatureNEON,
+                                              FeatureCRC]>;
 
 def : ProcessorModel<"cortex-a53", CortexA53Model, [ProcA53]>;
 def : ProcessorModel<"cortex-a57", NoSchedModel, [ProcA57]>;
index 94fc2e0ab9f5970c4c6ed416673fa8f38888f1bf..2db7449d6aae39f9c00be99ff5a81c5a70c342ed 100644 (file)
@@ -1243,6 +1243,7 @@ class BaseCRC32<bit sf, bits<2> sz, bit C, RegisterClass StreamReg,
   let Inst{11-10} = sz;
   let Inst{9-5} = Rn;
   let Inst{4-0} = Rd;
+  let Predicates = [HasCRC];
 }
 
 //---
index e4b47d7355d9dc7de1b858ce13c97f6c30bb0c7d..ddcedee04c36ea9c5f143fb51e4bd11dc6509c56 100644 (file)
@@ -18,8 +18,10 @@ def HasFPARMv8       : Predicate<"Subtarget->hasFPARMv8()">,
                                AssemblerPredicate<"FeatureFPARMv8", "fp-armv8">;
 def HasNEON          : Predicate<"Subtarget->hasNEON()">,
                                  AssemblerPredicate<"FeatureNEON", "neon">;
-def HasCrypto          : Predicate<"Subtarget->hasCrypto()">,
+def HasCrypto        : Predicate<"Subtarget->hasCrypto()">,
                                  AssemblerPredicate<"FeatureCrypto", "crypto">;
+def HasCRC           : Predicate<"Subtarget->hasCRC()">,
+                                 AssemblerPredicate<"FeatureCRC", "crc">;
 
 //===----------------------------------------------------------------------===//
 // ARM64-specific DAG Nodes.
index abe8e054ddf4352757464679c6a8f4df6a968aa6..e7cafbb3047052d580a18becf4ae52b6bea19fbd 100644 (file)
@@ -29,7 +29,7 @@ using namespace llvm;
 ARM64Subtarget::ARM64Subtarget(const std::string &TT, const std::string &CPU,
                                const std::string &FS, bool LittleEndian)
     : ARM64GenSubtargetInfo(TT, CPU, FS), ARMProcFamily(Others),
-      HasFPARMv8(false), HasNEON(false), HasCrypto(false),
+      HasFPARMv8(false), HasNEON(false), HasCrypto(false), HasCRC(false),
       HasZeroCycleRegMove(false), HasZeroCycleZeroing(false),
       CPUString(CPU), TargetTriple(TT), IsLittleEndian(LittleEndian) {
   // Determine default and user-specified characteristics
index 1977e0bf05a01c65df885b0af3c021a1f6fbd877..031068c4b86a95cffb7dae452f12e246a7ee8751 100644 (file)
@@ -35,6 +35,7 @@ protected:
   bool HasFPARMv8;
   bool HasNEON;
   bool HasCrypto;
+  bool HasCRC;
 
   // HasZeroCycleRegMove - Has zero-cycle register mov instructions.
   bool HasZeroCycleRegMove;
@@ -66,6 +67,7 @@ public:
   bool hasFPARMv8() const { return HasFPARMv8; }
   bool hasNEON() const { return HasNEON; }
   bool hasCrypto() const { return HasCrypto; }
+  bool hasCRC() const { return HasCRC; }
 
   bool isLittleEndian() const { return IsLittleEndian; }
 
index 609eb44122b6539659afe4ca1aba3893ef08354a..5d759dcce71ceef5265864d816c2c3a2b1d28099 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc -march=arm64 -o - %s | FileCheck %s
+; RUN: llc -march=arm64 -mattr=+crc -o - %s | FileCheck %s
 
 define i32 @test_crc32b(i32 %cur, i8 %next) {
 ; CHECK-LABEL: test_crc32b:
index 99b438d64ba8d93b2a514712ee126be8654793d9..2f58eadfc8462c73a660c8b5567bea857abb1ff1 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: llvm-mc -triple arm64 -show-encoding < %s | FileCheck %s
+// RUN: llvm-mc -triple arm64 -mattr=+crc -show-encoding < %s | FileCheck %s
 
         crc32b  w5, w7, w20
         crc32h  w28, wzr, w30
index 399a85c631c883db32abf9cb7f615bd5bb133902..3b757e836d390e087e56f1e379c8ef347e583c82 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: not llvm-mc  -triple arm64-linux-gnu -mattr=-fp-armv8 < %s 2> %t
+// RUN: not llvm-mc  -triple arm64-linux-gnu -mattr=-fp-armv8,-crc < %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-ERROR < %t %s
 
 
         pmull v0.1q, v1.1d, v2.1d
 // CHECK-ERROR: error: instruction requires: crypto
 // CHECK-ERROR-NEXT:        pmull v0.1q, v1.1d, v2.1d
+// CHECK-ERROR-NEXT:        ^
+
+        crc32b  w5, w7, w20
+// CHECK-ERROR: error: instruction requires: crc
+// CHECK-ERROR-NEXT:        crc32b  w5, w7, w20
 // CHECK-ERROR-NEXT:        ^
 
index ef0a26e5629bda3a1010a1b0d5eeaf274e0ea6db..51717ee28627ad46199704a93830ad77edded8f0 100644 (file)
@@ -1,4 +1,4 @@
-# RUN: llvm-mc -triple=arm64 -disassemble < %s | FileCheck %s
+# RUN: llvm-mc -triple=arm64 -mattr=+crc -disassemble < %s | FileCheck %s
 
 # CHECK: crc32b  w5, w7, w20
 # CHECK: crc32h  w28, wzr, w30