[llvm-commits] [llvm] r70328 - in /llvm/trunk: lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h test/CodeGen/X86/2009-04-29-InlineAsmPMemoryModifier.ll
Anton Korobeynikov
asl at math.spbu.ru
Tue Apr 28 14:49:33 PDT 2009
Author: asl
Date: Tue Apr 28 16:49:33 2009
New Revision: 70328
URL: http://llvm.org/viewvc/llvm-project?rev=70328&view=rev
Log:
Properly print 'P' modifier on inline asm memory operands.
This should fix PR3379 and PR4064.
Patch inspired by Edwin Török!
Added:
llvm/trunk/test/CodeGen/X86/2009-04-29-InlineAsmPMemoryModifier.ll
Modified:
llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h
Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=70328&r1=70327&r2=70328&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Tue Apr 28 16:49:33 2009
@@ -570,12 +570,13 @@
}
void X86ATTAsmPrinter::printLeaMemReference(const MachineInstr *MI, unsigned Op,
- const char *Modifier){
+ const char *Modifier,
+ bool NotRIPRel) {
MachineOperand BaseReg = MI->getOperand(Op);
MachineOperand IndexReg = MI->getOperand(Op+2);
const MachineOperand &DispSpec = MI->getOperand(Op+3);
- bool NotRIPRel = IndexReg.getReg() || BaseReg.getReg();
+ NotRIPRel |= IndexReg.getReg() || BaseReg.getReg();
if (DispSpec.isGlobal() ||
DispSpec.isCPI() ||
DispSpec.isJTI() ||
@@ -615,14 +616,14 @@
}
void X86ATTAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op,
- const char *Modifier){
+ const char *Modifier, bool NotRIPRel){
assert(isMem(MI, Op) && "Invalid memory reference!");
MachineOperand Segment = MI->getOperand(Op+4);
if (Segment.getReg()) {
printOperand(MI, Op+4, Modifier);
O << ':';
}
- printLeaMemReference(MI, Op, Modifier);
+ printLeaMemReference(MI, Op, Modifier, NotRIPRel);
}
void X86ATTAsmPrinter::printPICJumpTableSetLabel(unsigned uid,
@@ -723,7 +724,7 @@
return false;
case 'P': // Don't print @PLT, but do print as memory.
- printOperand(MI, OpNo, "mem");
+ printOperand(MI, OpNo, "mem", /*NotRIPRel=*/true);
return false;
}
}
@@ -749,7 +750,7 @@
// These only apply to registers, ignore on mem.
break;
case 'P': // Don't print @PLT, but do print as memory.
- printOperand(MI, OpNo, "mem");
+ printMemReference(MI, OpNo, "mem", /*NotRIPRel=*/true);
return false;
}
}
Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h?rev=70328&r1=70327&r2=70328&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h Tue Apr 28 16:49:33 2009
@@ -112,9 +112,9 @@
void printMachineInstruction(const MachineInstr *MI);
void printSSECC(const MachineInstr *MI, unsigned Op);
void printMemReference(const MachineInstr *MI, unsigned Op,
- const char *Modifier=NULL);
+ const char *Modifier=NULL, bool NotRIPRel = false);
void printLeaMemReference(const MachineInstr *MI, unsigned Op,
- const char *Modifier=NULL);
+ const char *Modifier=NULL, bool NotRIPRel = false);
void printPICJumpTableSetLabel(unsigned uid,
const MachineBasicBlock *MBB) const;
void printPICJumpTableSetLabel(unsigned uid, unsigned uid2,
Added: llvm/trunk/test/CodeGen/X86/2009-04-29-InlineAsmPMemoryModifier.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2009-04-29-InlineAsmPMemoryModifier.ll?rev=70328&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/2009-04-29-InlineAsmPMemoryModifier.ll (added)
+++ llvm/trunk/test/CodeGen/X86/2009-04-29-InlineAsmPMemoryModifier.ll Tue Apr 28 16:49:33 2009
@@ -0,0 +1,12 @@
+; RUN: llvm-as < %s | llc -march=x86-64 | grep gs: | not grep rip
+; PR3379
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
+target triple = "x86_64-unknown-linux-gnu"
+ at per_cpu__cpu_number = external global i32 ; <i32*> [#uses=1]
+
+define void @pat_init() nounwind {
+entry:
+ %0 = call i32 asm "movl %gs:${1:P},$0", "=r,*m,~{dirflag},~{fpsr},~{flags}"(i32* @per_cpu__cpu_number) nounwind ; <i32> [#uses=0]
+ unreachable
+}
More information about the llvm-commits
mailing list