Add features for PPC 4xx and e500/e500mc instructions.
authorJoerg Sonnenberger <joerg@bec.de>
Mon, 4 Aug 2014 15:47:38 +0000 (15:47 +0000)
committerJoerg Sonnenberger <joerg@bec.de>
Mon, 4 Aug 2014 15:47:38 +0000 (15:47 +0000)
Move the test cases for them into separate files.

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

lib/Target/PowerPC/PPC.td
lib/Target/PowerPC/PPCInstrInfo.td
lib/Target/PowerPC/PPCSubtarget.cpp
lib/Target/PowerPC/PPCSubtarget.h
test/MC/Disassembler/PowerPC/ppc64-encoding-4xx.txt [new file with mode: 0644]
test/MC/Disassembler/PowerPC/ppc64-encoding-e500.txt [new file with mode: 0644]
test/MC/Disassembler/PowerPC/ppc64-encoding-ext.txt
test/MC/PowerPC/ppc64-encoding-4xx.s [new file with mode: 0644]
test/MC/PowerPC/ppc64-encoding-e500.s [new file with mode: 0644]
test/MC/PowerPC/ppc64-encoding-ext.s

index 155f3d5b5c18ee6f6547414024fac9c7c8b9b6b0..87691d014b7fd175344e69caf6c1519177e5402c 100644 (file)
@@ -88,6 +88,10 @@ def FeatureLDBRX     : SubtargetFeature<"ldbrx","HasLDBRX", "true",
                                         "Enable the ldbrx instruction">;
 def FeatureBookE     : SubtargetFeature<"booke", "IsBookE", "true",
                                         "Enable Book E instructions">;
+def FeatureE500      : SubtargetFeature<"E500", "IsE500", "true",
+                                        "Enable E500/E500mc instructions">;
+def FeaturePPC4xx    : SubtargetFeature<"ppc4xx", "IsPPC4xx", "true",
+                                        "Enable PPC 4xx instructions">;
 def FeatureQPX       : SubtargetFeature<"qpx","HasQPX", "true",
                                         "Enable QPX instructions">;
 def FeatureVSX       : SubtargetFeature<"vsx","HasVSX", "true",
index d00d9d8cc56117948a7336a5614ba09088ffb2df..f6e3e662b0e4857554a9e6860bb3f5b23586ded8 100644 (file)
@@ -629,6 +629,8 @@ def In32BitMode  : Predicate<"!PPCSubTarget->isPPC64()">;
 def In64BitMode  : Predicate<"PPCSubTarget->isPPC64()">;
 def IsBookE  : Predicate<"PPCSubTarget->isBookE()">;
 def IsNotBookE  : Predicate<"!PPCSubTarget->isBookE()">;
+def IsPPC4xx  : Predicate<"PPCSubTarget->isPPC4xx()">;
+def IsE500  : Predicate<"PPCSubTarget->isE500()">;
 
 //===----------------------------------------------------------------------===//
 // PowerPC Multiclass Definitions.
@@ -3123,13 +3125,15 @@ def RFI : XForm_0<19, 50, (outs), (ins), "rfi", IIC_BrB, []>,
 def RFCI : XForm_0<19, 51, (outs), (ins), "rfci", IIC_BrB, []>,
                    Requires<[IsBookE]>;
 
-def RFDI : XForm_0<19, 39, (outs), (ins), "rfdi", IIC_BrB, []>;
-def RFMCI : XForm_0<19, 38, (outs), (ins), "rfmci", IIC_BrB, []>;
+def RFDI : XForm_0<19, 39, (outs), (ins), "rfdi", IIC_BrB, []>,
+                   Requires<[IsE500]>;
+def RFMCI : XForm_0<19, 38, (outs), (ins), "rfmci", IIC_BrB, []>,
+                    Requires<[IsE500]>;
 
 def MFDCR : XFXForm_1<31, 323, (outs gprc:$RT), (ins i32imm:$SPR),
-                      "mfdcr $RT, $SPR", IIC_SprMFSPR>;
+                      "mfdcr $RT, $SPR", IIC_SprMFSPR>, Requires<[IsPPC4xx]>;
 def MTDCR : XFXForm_1<31, 451, (outs), (ins gprc:$RT, i32imm:$SPR),
-                      "mtdcr $SPR, $RT", IIC_SprMTSPR>;
+                      "mtdcr $SPR, $RT", IIC_SprMTSPR>, Requires<[IsPPC4xx]>;
 
 //===----------------------------------------------------------------------===//
 // PowerPC Assembler Instruction Aliases
index b39fe10bc13e8b2d6dde82b17e1b7da38b1121fb..f8059dacdfd7b9fe65ca7ef46a14fa0d5c2931ec 100644 (file)
@@ -136,6 +136,8 @@ void PPCSubtarget::initializeEnvironment() {
   HasPOPCNTD = false;
   HasLDBRX = false;
   IsBookE = false;
+  IsPPC4xx = false;
+  IsE500 = false;
   DeprecatedMFTB = false;
   DeprecatedDST = false;
   HasLazyResolverStubs = false;
index 8c4f583bdb8fcb1cd80de472c426ae4a07597f45..d5d4ab265ae994491661570e9dc06d1fd42b0f28 100644 (file)
@@ -97,6 +97,8 @@ protected:
   bool HasPOPCNTD;
   bool HasLDBRX;
   bool IsBookE;
+  bool IsE500;
+  bool IsPPC4xx;
   bool DeprecatedMFTB;
   bool DeprecatedDST;
   bool HasLazyResolverStubs;
@@ -218,6 +220,8 @@ public:
   bool hasPOPCNTD() const { return HasPOPCNTD; }
   bool hasLDBRX() const { return HasLDBRX; }
   bool isBookE() const { return IsBookE; }
+  bool isPPC4xx() const { return IsPPC4xx; }
+  bool isE500() const { return IsE500; }
   bool isDeprecatedMFTB() const { return DeprecatedMFTB; }
   bool isDeprecatedDST() const { return DeprecatedDST; }
 
diff --git a/test/MC/Disassembler/PowerPC/ppc64-encoding-4xx.txt b/test/MC/Disassembler/PowerPC/ppc64-encoding-4xx.txt
new file mode 100644 (file)
index 0000000..9eca272
--- /dev/null
@@ -0,0 +1,6 @@
+# RUN: llvm-mc --disassemble %s -triple powerpc64-unknown-unknown -mcpu=pwr7 | FileCheck %s
+
+# CHECK: mfdcr 3, 178
+0x7c 0x72 0x2a 0x86
+# CHECK: mtdcr 178, 3
+0x7c 0x72 0x2b 0x86
diff --git a/test/MC/Disassembler/PowerPC/ppc64-encoding-e500.txt b/test/MC/Disassembler/PowerPC/ppc64-encoding-e500.txt
new file mode 100644 (file)
index 0000000..ef013d7
--- /dev/null
@@ -0,0 +1,7 @@
+# RUN: llvm-mc --disassemble %s -triple powerpc64-unknown-unknown -mcpu=pwr7 | FileCheck %s
+
+# CHECK: rfdi
+0x4c 0x00 0x00 0x4e
+# CHECK: rfmci
+0x4c 0x00 0x00 0x4c
+
index 1031ffd09b81018666314ab8db854c906c334019..45f4d3e045e563bebdc3a9cd78a53264b1df69e3 100644 (file)
 # CHECK: mtcrf 255, 2
 0x7c 0x4f 0xf1 0x20
 
-# CHECK: rfdi
-0x4c 0x00 0x00 0x4e
-# CHECK: rfmci
-0x4c 0x00 0x00 0x4c
-
 # CHECK: dss 3
 0x7c 0x60 0x06 0x6c
 # CHECK: dssall
 # CHECK: dststt 12, 11, 3
 0x7e 0x6c 0x5a 0xec
 
-# CHECK: mfdcr 3, 178
-0x7c 0x72 0x2a 0x86
-# CHECK: mtdcr 178, 3
-0x7c 0x72 0x2b 0x86
-
 # CHECK: tlbia
 0x7c 0x00 0x02 0xe4
diff --git a/test/MC/PowerPC/ppc64-encoding-4xx.s b/test/MC/PowerPC/ppc64-encoding-4xx.s
new file mode 100644 (file)
index 0000000..c53a251
--- /dev/null
@@ -0,0 +1,11 @@
+# RUN: llvm-mc -triple powerpc64-unknown-unknown --show-encoding %s | FileCheck -check-prefix=CHECK-BE %s
+# RUN: llvm-mc -triple powerpc64le-unknown-unknown --show-encoding %s | FileCheck -check-prefix=CHECK-LE %s
+
+# Instructions specific to the PowerPC 4xx embedded controllers:
+
+# CHECK-BE: mfdcr 3, 178                     # encoding: [0x7c,0x72,0x2a,0x86]
+# CHECK-LE: mfdcr 3, 178                     # encoding: [0x86,0x2a,0x72,0x7c]
+            mfdcr 3,178
+# CHECK-BE: mtdcr 178, 3                     # encoding: [0x7c,0x72,0x2b,0x86]
+# CHECK-LE: mtdcr 178, 3                     # encoding: [0x86,0x2b,0x72,0x7c]
+            mtdcr 178,3
diff --git a/test/MC/PowerPC/ppc64-encoding-e500.s b/test/MC/PowerPC/ppc64-encoding-e500.s
new file mode 100644 (file)
index 0000000..fee91ee
--- /dev/null
@@ -0,0 +1,11 @@
+# RUN: llvm-mc -triple powerpc64-unknown-unknown --show-encoding %s | FileCheck -check-prefix=CHECK-BE %s
+# RUN: llvm-mc -triple powerpc64le-unknown-unknown --show-encoding %s | FileCheck -check-prefix=CHECK-LE %s
+
+# Instructions specific to the e500 / e500mc cores:
+
+# CHECK-BE: rfdi                            # encoding: [0x4c,0x00,0x00,0x4e]
+# CHECK-LE: rfdi                            # encoding: [0x4e,0x00,0x00,0x4c]
+            rfdi
+# CHECK-BE: rfmci                            # encoding: [0x4c,0x00,0x00,0x4c]
+# CHECK-LE: rfmci                            # encoding: [0x4c,0x00,0x00,0x4c]
+            rfmci
index 18f09d01a6af00d1c4a0b2fe281db74200444673..99a698d3a55ca88dae5f9608ef2bfdc1da7d734f 100644 (file)
 # CHECK-LE: mtspr 275, 4                    # encoding: [0xa6,0x43,0x93,0x7c]
             mtsprg3 %r4
 
-# e500/e500mc instructions:
-# CHECK-BE: rfdi                            # encoding: [0x4c,0x00,0x00,0x4e]
-# CHECK-LE: rfdi                            # encoding: [0x4e,0x00,0x00,0x4c]
-            rfdi
-# CHECK-BE: rfmci                            # encoding: [0x4c,0x00,0x00,0x4c]
-# CHECK-LE: rfmci                            # encoding: [0x4c,0x00,0x00,0x4c]
-            rfmci
-
 # Altivec Data Stream instruction:
 # CHECK-BE: dss 3                            # encoding: [0x7c,0x60,0x06,0x6c]
 # CHECK-LE: dss 3                            # encoding: [0x6c,0x06,0x60,0x7c]
 # CHECK-LE: dststt 12, 11, 3                 # encoding: [0xec,0x5a,0x6c,0x7e]
             dststt %r12, %r11, 3
 
-# PPC 403 support
-# CHECK-BE: mfdcr 3, 178                     # encoding: [0x7c,0x72,0x2a,0x86]
-# CHECK-LE: mfdcr 3, 178                     # encoding: [0x86,0x2a,0x72,0x7c]
-            mfdcr 3,178
-# CHECK-BE: mtdcr 178, 3                     # encoding: [0x7c,0x72,0x2b,0x86]
-# CHECK-LE: mtdcr 178, 3                     # encoding: [0x86,0x2b,0x72,0x7c]
-            mtdcr 178,3
-
 # CHECK-BE: tlbia                            # encoding: [0x7c,0x00,0x02,0xe4]
 # CHECK-LE: tlbia                            # encoding: [0xe4,0x02,0x00,0x7c]
             tlbia