[llvm-commits] [llvm] r158939 - in /llvm/trunk: lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp test/CodeGen/Generic/asm-large-immediate.ll test/CodeGen/Mips/asm-large-immediate.ll

Jack Carter jcarter at mips.com
Thu Jun 21 14:37:54 PDT 2012


Author: jacksprat
Date: Thu Jun 21 16:37:54 2012
New Revision: 158939

URL: http://llvm.org/viewvc/llvm-project?rev=158939&view=rev
Log:
The inline asm operand modifier 'n' is suppose 
to be generic across architectures. It has the
following description in the gnu sources:

    Negate the immediate constant

Several Architectures such as x86 have local implementations
of operand modifier 'n' which go beyond the above description
slightly. This won't affect them.

Affected files:

    lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
        Added 'n' to the switch cases.

    test/CodeGen/Generic/asm-large-immediate.ll
        Generic compiled test (x86 for me)

    test/CodeGen/Mips/asm-large-immediate.ll
        Mips compiled version of the generic one

Contributer: Jack Carter


Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
    llvm/trunk/test/CodeGen/Generic/asm-large-immediate.ll
    llvm/trunk/test/CodeGen/Mips/asm-large-immediate.ll

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp?rev=158939&r1=158938&r2=158939&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp Thu Jun 21 16:37:54 2012
@@ -420,10 +420,15 @@
     default:
       return true;  // Unknown modifier.
     case 'c': // Substitute immediate value without immediate syntax
-      if ((MO.getType()) != MachineOperand::MO_Immediate)
+      if (MO.getType() != MachineOperand::MO_Immediate)
         return true;
       O << MO.getImm();
       return false;
+    case 'n':  // Negate the immediate constant.
+      if (MO.getType() != MachineOperand::MO_Immediate)
+        return true;
+      O << -MO.getImm();
+      return false;
     }
   }
   return true;

Modified: llvm/trunk/test/CodeGen/Generic/asm-large-immediate.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Generic/asm-large-immediate.ll?rev=158939&r1=158938&r2=158939&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/Generic/asm-large-immediate.ll (original)
+++ llvm/trunk/test/CodeGen/Generic/asm-large-immediate.ll Thu Jun 21 16:37:54 2012
@@ -1,8 +1,11 @@
-; RUN: llc < %s | grep 68719476738
+; RUN: llc < %s | FileCheck %s
 
 define void @test() {
 entry:
+; CHECK: /* result: 68719476738 */
         tail call void asm sideeffect "/* result: ${0:c} */", "i,~{dirflag},~{fpsr},~{flags}"( i64 68719476738 )
+; CHECK: /* result: -68719476738 */
+        tail call void asm sideeffect "/* result: ${0:n} */", "i,~{dirflag},~{fpsr},~{flags}"( i64 68719476738 )
         ret void
 }
 

Modified: llvm/trunk/test/CodeGen/Mips/asm-large-immediate.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/asm-large-immediate.ll?rev=158939&r1=158938&r2=158939&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/Mips/asm-large-immediate.ll (original)
+++ llvm/trunk/test/CodeGen/Mips/asm-large-immediate.ll Thu Jun 21 16:37:54 2012
@@ -1,10 +1,10 @@
-; RUNx: llc -march=mipsel < %s | grep 68719476738
-
 ; RUN: llc -march=mipsel < %s | FileCheck %s
 define void @test() {
 entry:
 ; CHECK: /* result: 68719476738 */
         tail call void asm sideeffect "/* result: ${0:c} */", "i,~{dirflag},~{fpsr},~{flags}"( i64 68719476738 )
+; CHECK: /* result: -68719476738 */
+        tail call void asm sideeffect "/* result: ${0:n} */", "i,~{dirflag},~{fpsr},~{flags}"( i64 68719476738 )
         ret void
 }
 





More information about the llvm-commits mailing list