convert a helper method to be a static function instead of a

template.  Also convert it to take a MachineOperand instead of a GV*


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75227 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2009-07-10 05:27:43 +00:00
parent bfa5cf144a
commit 8a537121cb

View File

@ -97,8 +97,6 @@ template<class CodeEmitter>
intptr_t PCAdj = 0); intptr_t PCAdj = 0);
unsigned getX86RegNum(unsigned RegNo) const; unsigned getX86RegNum(unsigned RegNo) const;
bool gvNeedsNonLazyPtr(const GlobalValue *GV);
}; };
template<class CodeEmitter> template<class CodeEmitter>
@ -293,12 +291,17 @@ static bool isDisp8(int Value) {
return Value == (signed char)Value; return Value == (signed char)Value;
} }
template<class CodeEmitter> static bool gvNeedsNonLazyPtr(const MachineOperand &GVOp,
bool Emitter<CodeEmitter>::gvNeedsNonLazyPtr(const GlobalValue *GV) { const TargetMachine &TM) {
// For Darwin, simulate the linktime GOT by using the same non-lazy-pointer const GlobalValue *GV = GVOp.getGlobal();
// For Darwin-64, simulate the linktime GOT by using the same non-lazy-pointer
// mechanism as 32-bit mode. // mechanism as 32-bit mode.
return (!Is64BitMode || TM.getSubtarget<X86Subtarget>().isTargetDarwin()) && if (TM.getSubtarget<X86Subtarget>().is64Bit() &&
TM.getSubtarget<X86Subtarget>().GVRequiresExtraLoad(GV, TM, false); !TM.getSubtarget<X86Subtarget>().isTargetDarwin())
return false;
return TM.getSubtarget<X86Subtarget>().GVRequiresExtraLoad(GV, TM, false);
} }
template<class CodeEmitter> template<class CodeEmitter>
@ -321,7 +324,7 @@ void Emitter<CodeEmitter>::emitDisplacementField(const MachineOperand *RelocOp,
unsigned rt = Is64BitMode ? X86::reloc_pcrel_word unsigned rt = Is64BitMode ? X86::reloc_pcrel_word
: (IsPIC ? X86::reloc_picrel_word : X86::reloc_absolute_word); : (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->getGlobal()); bool Indirect = gvNeedsNonLazyPtr(*RelocOp, TM);
emitGlobalAddress(RelocOp->getGlobal(), rt, RelocOp->getOffset(), emitGlobalAddress(RelocOp->getGlobal(), rt, RelocOp->getOffset(),
PCAdj, NeedStub, Indirect); PCAdj, NeedStub, Indirect);
} else if (RelocOp->isCPI()) { } else if (RelocOp->isCPI()) {
@ -638,7 +641,7 @@ void Emitter<CodeEmitter>::emitInstruction(
rt = X86::reloc_absolute_dword; // FIXME: add X86II flag? rt = X86::reloc_absolute_dword; // FIXME: add X86II flag?
if (MO1.isGlobal()) { if (MO1.isGlobal()) {
bool NeedStub = isa<Function>(MO1.getGlobal()); bool NeedStub = isa<Function>(MO1.getGlobal());
bool Indirect = gvNeedsNonLazyPtr(MO1.getGlobal()); bool Indirect = gvNeedsNonLazyPtr(MO1, TM);
emitGlobalAddress(MO1.getGlobal(), rt, MO1.getOffset(), 0, emitGlobalAddress(MO1.getGlobal(), rt, MO1.getOffset(), 0,
NeedStub, Indirect); NeedStub, Indirect);
} else if (MO1.isSymbol()) } else if (MO1.isSymbol())
@ -742,7 +745,7 @@ void Emitter<CodeEmitter>::emitInstruction(
rt = X86::reloc_absolute_word; // FIXME: add X86II flag? rt = X86::reloc_absolute_word; // FIXME: add X86II flag?
if (MO1.isGlobal()) { if (MO1.isGlobal()) {
bool NeedStub = isa<Function>(MO1.getGlobal()); bool NeedStub = isa<Function>(MO1.getGlobal());
bool Indirect = gvNeedsNonLazyPtr(MO1.getGlobal()); bool Indirect = gvNeedsNonLazyPtr(MO1, TM);
emitGlobalAddress(MO1.getGlobal(), rt, MO1.getOffset(), 0, emitGlobalAddress(MO1.getGlobal(), rt, MO1.getOffset(), 0,
NeedStub, Indirect); NeedStub, Indirect);
} else if (MO1.isSymbol()) } else if (MO1.isSymbol())
@ -781,7 +784,7 @@ void Emitter<CodeEmitter>::emitInstruction(
rt = X86::reloc_absolute_word; // FIXME: add X86II flag? rt = X86::reloc_absolute_word; // FIXME: add X86II flag?
if (MO.isGlobal()) { if (MO.isGlobal()) {
bool NeedStub = isa<Function>(MO.getGlobal()); bool NeedStub = isa<Function>(MO.getGlobal());
bool Indirect = gvNeedsNonLazyPtr(MO.getGlobal()); bool Indirect = gvNeedsNonLazyPtr(MO, TM);
emitGlobalAddress(MO.getGlobal(), rt, MO.getOffset(), 0, emitGlobalAddress(MO.getGlobal(), rt, MO.getOffset(), 0,
NeedStub, Indirect); NeedStub, Indirect);
} else if (MO.isSymbol()) } else if (MO.isSymbol())