[llvm] r324476 - [mips] Handle 'M' and 'L' operand codes for memory operands

Simon Atanasyan via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 7 04:36:33 PST 2018


Author: atanasyan
Date: Wed Feb  7 04:36:33 2018
New Revision: 324476

URL: http://llvm.org/viewvc/llvm-project?rev=324476&view=rev
Log:
[mips] Handle 'M' and 'L' operand codes for memory operands

Both operand codes now work the same way in case of register or memory
operands. It print high-order or low-order word in a double-word
register or memory location.

Modified:
    llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp
    llvm/trunk/test/CodeGen/Mips/inlineasmmemop.ll

Modified: llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp?rev=324476&r1=324475&r2=324476&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp Wed Feb  7 04:36:33 2018
@@ -576,17 +576,27 @@ bool MipsAsmPrinter::PrintAsmMemoryOpera
   assert(OffsetMO.isImm() && "Unexpected offset for inline asm memory operand.");
   int Offset = OffsetMO.getImm();
 
-  // Currently we are expecting either no ExtraCode or 'D'
+  // Currently we are expecting either no ExtraCode or 'D','M','L'.
   if (ExtraCode) {
-    if (ExtraCode[0] == 'D')
+    switch (ExtraCode[0]) {
+    case 'D':
       Offset += 4;
-    else
+      break;
+    case 'M':
+      if (Subtarget->isLittle())
+        Offset += 4;
+      break;
+    case 'L':
+      if (!Subtarget->isLittle())
+        Offset += 4;
+      break;
+    default:
       return true; // Unknown modifier.
-    // FIXME: M = high order bits
-    // FIXME: L = low order bits
+    }
   }
 
-  O << Offset << "($" << MipsInstPrinter::getRegisterName(BaseMO.getReg()) << ")";
+  O << Offset << "($" << MipsInstPrinter::getRegisterName(BaseMO.getReg())
+    << ")";
 
   return false;
 }

Modified: llvm/trunk/test/CodeGen/Mips/inlineasmmemop.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/inlineasmmemop.ll?rev=324476&r1=324475&r2=324476&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/Mips/inlineasmmemop.ll (original)
+++ llvm/trunk/test/CodeGen/Mips/inlineasmmemop.ll Wed Feb  7 04:36:33 2018
@@ -1,4 +1,7 @@
-; RUN: llc -march=mipsel -relocation-model=pic < %s | FileCheck %s
+; RUN: llc -march=mips -relocation-model=pic < %s \
+; RUN:   | FileCheck --check-prefixes=CHECK,EB %s
+; RUN: llc -march=mipsel -relocation-model=pic < %s \
+; RUN:   | FileCheck --check-prefixes=CHECK,EL %s
 
 ; Simple memory
 @g1 = external global i32
@@ -35,6 +38,18 @@ entry:
 ; CHECK: lw ${{[0-9]+}}, 12(${{[0-9]+}})
 ; CHECK: #NO_APP
 
+; "M": High-order word of a double word.
+; CHECK: #APP
+; EB:    lw ${{[0-9]+}}, 12(${{[0-9]+}})
+; EL:    lw ${{[0-9]+}}, 16(${{[0-9]+}})
+; CHECK: #NO_APP
+
+; "L": Low-order word of a double word.
+; CHECK: #APP
+; EB:    lw ${{[0-9]+}}, 16(${{[0-9]+}})
+; EL:    lw ${{[0-9]+}}, 12(${{[0-9]+}})
+; CHECK: #NO_APP
+
 @b = common global [20 x i32] zeroinitializer, align 4
 
 define void @main() {
@@ -43,5 +58,10 @@ entry:
   tail call void asm sideeffect "    lw    $0, ${1:D}", "r,*m,~{$11}"(i32 undef, i32* getelementptr inbounds ([20 x i32], [20 x i32]* @b, i32 0, i32 3))
 ; First word. Notice, no 'D':
   tail call void asm sideeffect "    lw    $0, ${1}", "r,*m,~{$11}"(i32 undef, i32* getelementptr inbounds ([20 x i32], [20 x i32]* @b, i32 0, i32 3))
+
+; High-order part.
+  tail call void asm sideeffect "    lw    $0, ${1:M}", "r,*m,~{$11}"(i32 undef, i32* getelementptr inbounds ([20 x i32], [20 x i32]* @b, i32 0, i32 3))
+; Low-order part.
+  tail call void asm sideeffect "    lw    $0, ${1:L}", "r,*m,~{$11}"(i32 undef, i32* getelementptr inbounds ([20 x i32], [20 x i32]* @b, i32 0, i32 3))
   ret void
 }




More information about the llvm-commits mailing list