simplify closing paren and (rip) printing.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73841 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2009-06-21 02:22:53 +00:00
parent 4150c086d0
commit e372333597

View File

@ -552,6 +552,10 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
printOffset(MO.getOffset()); printOffset(MO.getOffset());
if (needCloseParen)
O << ')';
bool isRIPRelative = false;
if (isThreadLocal) { if (isThreadLocal) {
TLSModel::Model model = getTLSModel(GVar, TM.getRelocationModel()); TLSModel::Model model = getTLSModel(GVar, TM.getRelocationModel());
switch (model) { switch (model) {
@ -565,7 +569,8 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
case TLSModel::InitialExec: case TLSModel::InitialExec:
if (Subtarget->is64Bit()) { if (Subtarget->is64Bit()) {
assert (!NotRIPRel); assert (!NotRIPRel);
O << "@GOTTPOFF(%rip)"; O << "@GOTTPOFF";
isRIPRelative = true;
} else { } else {
O << "@INDNTPOFF"; O << "@INDNTPOFF";
} }
@ -585,26 +590,22 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
O << "@GOT"; O << "@GOT";
else else
O << "@GOTOFF"; O << "@GOTOFF";
} else if (Subtarget->isPICStyleRIPRel() && !NotRIPRel) { } else if (Subtarget->isPICStyleRIPRel() &&
!NotRIPRel) {
if (TM.getRelocationModel() != Reloc::Static) { if (TM.getRelocationModel() != Reloc::Static) {
if (Subtarget->GVRequiresExtraLoad(GV, TM, false)) if (Subtarget->GVRequiresExtraLoad(GV, TM, false))
O << "@GOTPCREL"; O << "@GOTPCREL";
if (needCloseParen) {
needCloseParen = false;
O << ')';
}
} }
// Use rip when possible to reduce code size, except when isRIPRelative = true;
// index or base register are also part of the address. e.g.
// foo(%rip)(%rcx,%rax,4) is not legal
O << "(%rip)";
} }
} }
if (needCloseParen) // Use rip when possible to reduce code size, except when
O << ')'; // index or base register are also part of the address. e.g.
// foo(%rip)(%rcx,%rax,4) is not legal.
if (isRIPRelative)
O << "(%rip)";
return; return;
} }