Simplify.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80729 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2009-09-01 22:07:06 +00:00
parent 6b677b33c0
commit 0378b72609

View File

@ -324,37 +324,27 @@ void Emitter<CodeEmitter>::emitDisplacementField(const MachineOperand *RelocOp,
// Otherwise, this is something that requires a relocation. Emit it as such // Otherwise, this is something that requires a relocation. Emit it as such
// now. // now.
unsigned RelocType = Is64BitMode ?
(IsPCRel ? X86::reloc_pcrel_word : X86::reloc_absolute_word_sext)
: (IsPIC ? X86::reloc_picrel_word : X86::reloc_absolute_word);
if (RelocOp->isGlobal()) { if (RelocOp->isGlobal()) {
// In 64-bit static small code model, we could potentially emit absolute. // In 64-bit static small code model, we could potentially emit absolute.
// But it's probably not beneficial. If the MCE supports using RIP directly // But it's probably not beneficial. If the MCE supports using RIP directly
// do it, otherwise fallback to absolute (this is determined by IsPCRel). // do it, otherwise fallback to absolute (this is determined by IsPCRel).
// 89 05 00 00 00 00 mov %eax,0(%rip) # PC-relative // 89 05 00 00 00 00 mov %eax,0(%rip) # PC-relative
// 89 04 25 00 00 00 00 mov %eax,0x0 # Absolute // 89 04 25 00 00 00 00 mov %eax,0x0 # Absolute
unsigned rt = Is64BitMode ?
(IsPCRel ? X86::reloc_pcrel_word : X86::reloc_absolute_word_sext)
: (IsPIC ? X86::reloc_picrel_word : X86::reloc_absolute_word);
bool NeedStub = isa<Function>(RelocOp->getGlobal()); bool NeedStub = isa<Function>(RelocOp->getGlobal());
bool Indirect = gvNeedsNonLazyPtr(*RelocOp, TM); bool Indirect = gvNeedsNonLazyPtr(*RelocOp, TM);
emitGlobalAddress(RelocOp->getGlobal(), rt, RelocOp->getOffset(), emitGlobalAddress(RelocOp->getGlobal(), RelocType, RelocOp->getOffset(),
Adj, NeedStub, Indirect); Adj, NeedStub, Indirect);
} else if (RelocOp->isSymbol()) { } else if (RelocOp->isSymbol()) {
unsigned rt = Is64BitMode ? emitExternalSymbolAddress(RelocOp->getSymbolName(), RelocType);
(IsPCRel ? X86::reloc_pcrel_word : X86::reloc_absolute_word_sext)
: (IsPIC ? X86::reloc_picrel_word : X86::reloc_absolute_word);
emitExternalSymbolAddress(RelocOp->getSymbolName(), rt);
} else if (RelocOp->isCPI()) { } else if (RelocOp->isCPI()) {
unsigned rt = Is64BitMode ? emitConstPoolAddress(RelocOp->getIndex(), RelocType,
(IsPCRel ? X86::reloc_pcrel_word : X86::reloc_absolute_word_sext)
: (IsPIC ? X86::reloc_picrel_word : X86::reloc_absolute_word);
emitConstPoolAddress(RelocOp->getIndex(), rt,
RelocOp->getOffset(), Adj); RelocOp->getOffset(), Adj);
} else if (RelocOp->isJTI()) {
unsigned rt = Is64BitMode ?
(IsPCRel ? X86::reloc_pcrel_word : X86::reloc_absolute_word_sext)
: (IsPIC ? X86::reloc_picrel_word : X86::reloc_absolute_word);
emitJumpTableAddress(RelocOp->getIndex(), rt, Adj);
} else { } else {
llvm_unreachable("Unknown value to relocate!"); assert(RelocOp->isJTI() && "Unexpected machine operand!");
emitJumpTableAddress(RelocOp->getIndex(), RelocType, Adj);
} }
} }