X86/Encoding: Support ExternalSymbol operands in emitDisplacementField (for consistency).
authorDaniel Dunbar <daniel@zuster.org>
Tue, 1 Sep 2009 22:06:53 +0000 (22:06 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 1 Sep 2009 22:06:53 +0000 (22:06 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80727 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86CodeEmitter.cpp

index 7e2fd975c1ccf541503f004fcb9153301f891e8a..6367623a01a05524a94afeaac86b330274a0d338 100644 (file)
@@ -337,6 +337,11 @@ void Emitter<CodeEmitter>::emitDisplacementField(const MachineOperand *RelocOp,
     bool Indirect = gvNeedsNonLazyPtr(*RelocOp, TM);
     emitGlobalAddress(RelocOp->getGlobal(), rt, RelocOp->getOffset(),
                       Adj, NeedStub, Indirect);
+  } else if (RelocOp->isSymbol()) {
+    unsigned rt = Is64BitMode ?
+      (IsPCRel ? X86::reloc_pcrel_word : X86::reloc_absolute_word_sext)
+      : (IsPCRel ? X86::reloc_picrel_word : X86::reloc_absolute_word);
+    emitExternalSymbolAddress(RelocOp->getSymbolName(), rt);
   } else if (RelocOp->isCPI()) {
     unsigned rt = Is64BitMode ?
       (IsPCRel ? X86::reloc_pcrel_word : X86::reloc_absolute_word_sext)
@@ -364,6 +369,8 @@ void Emitter<CodeEmitter>::emitMemModRMByte(const MachineInstr &MI,
   // Figure out what sort of displacement we have to handle here.
   if (Op3.isGlobal()) {
     DispForReloc = &Op3;
+  } else if (Op3.isSymbol()) {
+    DispForReloc = &Op3;
   } else if (Op3.isCPI()) {
     if (!MCE.earlyResolveAddresses() || Is64BitMode || IsPIC) {
       DispForReloc = &Op3;