[Sparc] Fix disassembly of popc instruction.
authorJames Y Knight <jyknight@google.com>
Wed, 5 Aug 2015 17:00:30 +0000 (17:00 +0000)
committerJames Y Knight <jyknight@google.com>
Wed, 5 Aug 2015 17:00:30 +0000 (17:00 +0000)
And add tests.

Patch by David Wiberg!

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

lib/Target/Sparc/SparcInstrInfo.td
test/MC/Disassembler/Sparc/sparc-v9.txt [new file with mode: 0644]
test/MC/Sparc/sparcv9-instructions.s

index 3b9e048ea8b38fe815a75b7378f569a3830596c9..51b71f491440602ea568392a9692c66c1db3dd0f 100644 (file)
@@ -1221,8 +1221,8 @@ let Predicates = [HasV9] in {
 // the top 32-bits before using it.  To do this clearing, we use a SRLri X,0.
 let rs1 = 0 in
   def POPCrr : F3_1<2, 0b101110,
-                    (outs IntRegs:$dst), (ins IntRegs:$src),
-                    "popc $src, $dst", []>, Requires<[HasV9]>;
+                    (outs IntRegs:$rd), (ins IntRegs:$rs2),
+                    "popc $rs2, $rd", []>, Requires<[HasV9]>;
 def : Pat<(ctpop i32:$src),
           (POPCrr (SRLri $src, 0))>;
 
diff --git a/test/MC/Disassembler/Sparc/sparc-v9.txt b/test/MC/Disassembler/Sparc/sparc-v9.txt
new file mode 100644 (file)
index 0000000..b8ca01c
--- /dev/null
@@ -0,0 +1,4 @@
+# RUN: llvm-mc --disassemble %s -triple=sparcv9-unknown-linux | FileCheck %s
+
+# CHECK: popc %g1, %g2
+0x85 0x70 0x00 0x01
index 37f4c8b2f6b90e2b38d9d44957f9f6f77774d4c6..e2cb87e06303476110a741f14c15f87b73d42592 100644 (file)
@@ -21,3 +21,8 @@
         ! V9:      subxcc %g1, %g2, %g3         ! encoding: [0x86,0xe0,0x40,0x02]
         subccc %g1, %g2, %g3
 
+        ! V8:      error: instruction requires a CPU feature not currently enabled
+        ! V8-NEXT: popc %g1, %g2
+        ! V9:      popc %g1, %g2                ! encoding: [0x85,0x70,0x00,0x01]
+        popc %g1, %g2
+