[llvm-commits] [llvm] r156577 - in /llvm/trunk: lib/Target/Mips/MipsAsmPrinter.cpp test/CodeGen/Mips/inlineasm-operand-code.ll

Eric Christopher echristo at apple.com
Thu May 10 14:48:22 PDT 2012


Author: echristo
Date: Thu May 10 16:48:22 2012
New Revision: 156577

URL: http://llvm.org/viewvc/llvm-project?rev=156577&view=rev
Log:
Add support for the 'X' inline asm operand modifier.

Patch by Jack Carter.

Added:
    llvm/trunk/test/CodeGen/Mips/inlineasm-operand-code.ll
Modified:
    llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp

Modified: llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp?rev=156577&r1=156576&r2=156577&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp Thu May 10 16:48:22 2012
@@ -382,14 +382,26 @@
 }
 
 // Print out an operand for an inline asm expression.
-bool MipsAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
+bool MipsAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNum,
                                      unsigned AsmVariant,const char *ExtraCode,
                                      raw_ostream &O) {
   // Does this asm operand have a single letter operand modifier?
-  if (ExtraCode && ExtraCode[0])
-    return true; // Unknown modifier.
+  if (ExtraCode && ExtraCode[0]) {
+    if (ExtraCode[1] != 0) return true; // Unknown modifier.
+
+    const MachineOperand &MO = MI->getOperand(OpNum);
+    switch (ExtraCode[0]) {
+      default:
+        return true;  // Unknown modifier.
+      case 'X': // hex const int
+        if ((MO.getType()) != MachineOperand::MO_Immediate)
+          return true;
+        O << "0x" << StringRef(utohexstr(MO.getImm())).lower();
+        return false;
+    }
+  }
 
-  printOperand(MI, OpNo, O);
+  printOperand(MI, OpNum, O);
   return false;
 }
 

Added: llvm/trunk/test/CodeGen/Mips/inlineasm-operand-code.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/inlineasm-operand-code.ll?rev=156577&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/Mips/inlineasm-operand-code.ll (added)
+++ llvm/trunk/test/CodeGen/Mips/inlineasm-operand-code.ll Thu May 10 16:48:22 2012
@@ -0,0 +1,15 @@
+; Positive test for inline register constraints
+;
+; RUN: llc -march=mipsel < %s  | FileCheck %s
+
+define i32 @main() nounwind {
+entry:
+
+; X with -3
+;CHECK:	#APP
+;CHECK:	addi ${{[0-9]+}},${{[0-9]+}},0xfffffffffffffffd
+;CHECK:	#NO_APP
+  tail call i32 asm sideeffect "addi $0,$1,${2:X}", "=r,r,I"(i32 7, i32 -3) nounwind
+
+  ret i32 0
+}





More information about the llvm-commits mailing list