The inline asm operand modifier 'n' is suppose
authorJack Carter <jcarter@mips.com>
Thu, 21 Jun 2012 21:37:54 +0000 (21:37 +0000)
committerJack Carter <jcarter@mips.com>
Thu, 21 Jun 2012 21:37:54 +0000 (21:37 +0000)
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

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

lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
test/CodeGen/Generic/asm-large-immediate.ll
test/CodeGen/Mips/asm-large-immediate.ll

index 58716b725bfb7cf67d71a51aafe19f9661929dd2..db43b06c70f2253bd951b451956442dadf4c5cc0 100644 (file)
@@ -420,10 +420,15 @@ bool AsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
     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;
index 605665bef6d1909d18a0de0d1c182373135218fe..d5d5eb698123eff0968f0d535c287114392a1374 100644 (file)
@@ -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
 }
 
index d9bb0cab82dd50ac5a860587cea2fad5f025ccb8..246fff615edba739253d8193a46b65903b17221b 100644 (file)
@@ -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
 }