[ARM64] Port over the PostEncoderMethod fix for SMULH/UMULH from AArch64.
authorBradley Smith <bradley.smith@arm.com>
Wed, 9 Apr 2014 14:43:15 +0000 (14:43 +0000)
committerBradley Smith <bradley.smith@arm.com>
Wed, 9 Apr 2014 14:43:15 +0000 (14:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205877 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM64/ARM64InstrFormats.td
lib/Target/ARM64/MCTargetDesc/ARM64MCCodeEmitter.cpp
test/MC/Disassembler/ARM64/canonical-form.txt

index 16db02ed27579f64813fde3e17c7393ebaee7aed..00658edefa52bbdd356681ee3c1cc4f7b959fca8 100644 (file)
@@ -1200,9 +1200,13 @@ class MulHi<bits<3> opc, string asm, SDNode OpNode>
   let Inst{31-24} = 0b10011011;
   let Inst{23-21} = opc;
   let Inst{20-16} = Rm;
-  let Inst{15-10} = 0b011111;
+  let Inst{15}    = 0;
   let Inst{9-5}   = Rn;
   let Inst{4-0}   = Rd;
+
+  // The Ra field of SMULH and UMULH is unused: it should be assembled as 31
+  // (i.e. all bits 1) but is ignored by the processor.
+  let PostEncoderMethod = "fixMulHigh";
 }
 
 class MulAccumWAlias<string asm, Instruction inst>
index 48172d894aa7c8f0afbe5b1e677bf35dfed45b0d..5d4651cf274c2b33a8870f4cf6692ffdbd3f93e0 100644 (file)
@@ -177,6 +177,9 @@ public:
                          SmallVectorImpl<MCFixup> &Fixups,
                          const MCSubtargetInfo &STI) const;
 
+  unsigned fixMulHigh(const MCInst &MI, unsigned EncodedValue,
+                      const MCSubtargetInfo &STI) const;
+
   template<int hasRs, int hasRt2> unsigned
   fixLoadStoreExclusive(const MCInst &MI, unsigned EncodedValue,
                         const MCSubtargetInfo &STI) const;
@@ -565,6 +568,16 @@ void ARM64MCCodeEmitter::EncodeInstruction(const MCInst &MI, raw_ostream &OS,
   ++MCNumEmitted; // Keep track of the # of mi's emitted.
 }
 
+unsigned
+ARM64MCCodeEmitter::fixMulHigh(const MCInst &MI,
+                               unsigned EncodedValue,
+                               const MCSubtargetInfo &STI) const {
+  // The Ra field of SMULH and UMULH is unused: it should be assembled as 31
+  // (i.e. all bits 1) but is ignored by the processor.
+  EncodedValue |= 0x1f << 10;
+  return EncodedValue;
+}
+
 template<int hasRs, int hasRt2> unsigned
 ARM64MCCodeEmitter::fixLoadStoreExclusive(const MCInst &MI,
                                           unsigned EncodedValue,
index 6aaa5da3987fc7b7cabdbf12b2a3cead31c2929a..ccc93e6e956b9c25ff3bcdc265a6a3c4d7b20cb6 100644 (file)
@@ -3,3 +3,7 @@
 0x00 0x08 0x00 0xc8
 
 # CHECK: stxr  w0, x0, [x0]
+
+0x00 0x00 0x40 0x9b
+
+# CHECK: smulh x0, x0, x0