From 2c2fb823b91ab5aa19e495e5f8af32e368bac031 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Fri, 26 Jun 2009 22:00:19 +0000 Subject: [PATCH] Add x86 support for 'n' inline asm modifier. This will be handled target independently as part of MC work. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74336 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp | 11 +++++++++++ test/CodeGen/X86/inline-asm-modifier-n.ll | 8 ++++++++ 2 files changed, 19 insertions(+) create mode 100644 test/CodeGen/X86/inline-asm-modifier-n.ll diff --git a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp index 27f95d8759a..369daf0de04 100644 --- a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp +++ b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp @@ -840,6 +840,17 @@ bool X86ATTAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, case 'P': // Don't print @PLT, but do print as memory. printOperand(MI, OpNo, "mem", /*NotRIPRel=*/true); return false; + + case 'n': { // Negate the immediate or print a '-' before the operand. + // Note: this is a temporary solution. It should be handled target + // independently as part of the 'MC' work. + const MachineOperand &MO = MI->getOperand(OpNo); + if (MO.isImm()) { + O << -MO.getImm(); + return false; + } + O << '-'; + } } } diff --git a/test/CodeGen/X86/inline-asm-modifier-n.ll b/test/CodeGen/X86/inline-asm-modifier-n.ll new file mode 100644 index 00000000000..97eac388677 --- /dev/null +++ b/test/CodeGen/X86/inline-asm-modifier-n.ll @@ -0,0 +1,8 @@ +; RUN: llvm-as < %s | llc -march=x86 | grep { 37} +; rdar://7008959 + +define void @bork() nounwind { +entry: + tail call void asm sideeffect "BORK ${0:n}", "i,~{dirflag},~{fpsr},~{flags}"(i32 -37) nounwind + ret void +}