llvm.org GIT mirror llvm / 9ed2f80
Rename isGVNonLazyPtr to isIndirectSym to reflect how it will be used. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58949 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 12 years ago
8 changed file(s) with 53 addition(s) and 53 deletion(s). Raw diff Collapse all Expand all
3838 enum AddressType {
3939 isResult, // Relocation has be transformed into its result pointer.
4040 isGV, // The Target.GV field is valid.
41 isGVNonLazyPtr, // Relocation of a Mac OS X NonLazy indirect reference.
41 isIndirectSym, // Relocation of an indirect symbol.
4242 isBB, // Relocation of BB address.
4343 isExtSym, // The Target.ExtSym field is valid.
4444 isConstPool, // Relocation of constant pool address.
5555
5656 union {
5757 void *Result; // If this has been resolved to a resolved pointer
58 GlobalValue *GV; // If this is a pointer to a GV or a GV nonlazy ptr
58 GlobalValue *GV; // If this is a pointer to a GV or an indirect ref.
5959 MachineBasicBlock *MBB; // If this is a pointer to a LLVM BB
6060 const char *ExtSym; // If this is a pointer to a named symbol
6161 unsigned Index; // Constant pool / jump table index
9595 return Result;
9696 }
9797
98 /// MachineRelocation::getGVNonLazyPtr - Return a relocation entry for a
99 /// Mac OS X non-lazy GlobalValue indirect reference.
100 static MachineRelocation getGVNonLazyPtr(intptr_t offset,
101 unsigned RelocationType,
102 GlobalValue *GV, intptr_t cst = 0,
103 bool NeedStub = 0,
104 bool GOTrelative = 0) {
105 assert((RelocationType & ~63) == 0 && "Relocation type too large!");
106 MachineRelocation Result;
107 Result.Offset = offset;
108 Result.ConstantVal = cst;
109 Result.TargetReloType = RelocationType;
110 Result.AddrType = isGVNonLazyPtr;
98 /// MachineRelocation::getIndirectSymbol - Return a relocation entry for an
99 /// indirect symbol.
100 static MachineRelocation getIndirectSymbol(intptr_t offset,
101 unsigned RelocationType,
102 GlobalValue *GV, intptr_t cst = 0,
103 bool NeedStub = 0,
104 bool GOTrelative = 0) {
105 assert((RelocationType & ~63) == 0 && "Relocation type too large!");
106 MachineRelocation Result;
107 Result.Offset = offset;
108 Result.ConstantVal = cst;
109 Result.TargetReloType = RelocationType;
110 Result.AddrType = isIndirectSym;
111111 Result.NeedStub = NeedStub;
112112 Result.GOTRelative = GOTrelative;
113113 Result.TargetResolve = false;
221221 return AddrType == isGV;
222222 }
223223
224 /// isGlobalValueNonLazyPtr - Return true if this relocation is the address
225 /// of a Mac OS X non-lazy indirect reference.
226 bool isGlobalValueNonLazyPtr() const {
227 return AddrType == isGVNonLazyPtr;
224 /// isIndirectSymbol - Return true if this relocation is the address an
225 /// indirect symbol
226 bool isIndirectSymbol() const {
227 return AddrType == isIndirectSym;
228228 }
229229
230230 /// isBasicBlock - Return true if this relocation is a basic block reference.
274274 /// getGlobalValue - If this is a global value reference, return the
275275 /// referenced global.
276276 GlobalValue *getGlobalValue() const {
277 assert((isGlobalValue() || isGlobalValueNonLazyPtr()) &&
277 assert((isGlobalValue() || isIndirectSymbol()) &&
278278 "This is not a global value reference!");
279279 return Target.GV;
280280 }
3939 ///
4040 virtual void replaceMachineCodeForFunction(void *Old, void *New) = 0;
4141
42 /// emitGlobalValueNonLazyPtr - Use the specified MachineCodeEmitter object
43 /// to emit a Mac OS X non-lazy pointer which contains the address of the
44 /// specified ptr.
45 virtual void *emitGlobalValueNonLazyPtr(const GlobalValue* GV, void *ptr,
46 MachineCodeEmitter &MCE) {
47 assert(0 && "This target doesn't implement emitGlobalValueNonLazyPtr!");
42 /// emitGlobalValueIndirectSym - Use the specified MachineCodeEmitter object
43 /// to emit an indirect symbol which contains the address of the specified
44 /// ptr.
45 virtual void *emitGlobalValueIndirectSym(const GlobalValue* GV, void *ptr,
46 MachineCodeEmitter &MCE) {
47 assert(0 && "This target doesn't implement emitGlobalValueIndirectSym!");
4848 return 0;
4949 }
5050
336336 if (GV) {
337337 assert(!ACPV->isStub() && "Don't know how to deal this yet!");
338338 if (ACPV->isNonLazyPointer())
339 MCE.addRelocation(MachineRelocation::getGVNonLazyPtr(
339 MCE.addRelocation(MachineRelocation::getIndirectSymbol(
340340 MCE.getCurrentPCOffset(), ARM::reloc_arm_machine_cp_entry, GV,
341341 (intptr_t)ACPV, false));
342342 else
128128 return ARMCompilationCallback;
129129 }
130130
131 void *ARMJITInfo::emitGlobalValueNonLazyPtr(const GlobalValue *GV, void *Ptr,
132 MachineCodeEmitter &MCE) {
131 void *ARMJITInfo::emitGlobalValueIndirectSym(const GlobalValue *GV, void *Ptr,
132 MachineCodeEmitter &MCE) {
133133 MCE.startGVStub(GV, 4, 4);
134134 MCE.emitWordLE((intptr_t)Ptr);
135135 return MCE.finishGVStub(GV);
5050 ///
5151 virtual void replaceMachineCodeForFunction(void *Old, void *New);
5252
53 /// emitGlobalValueNonLazyPtr - Use the specified MachineCodeEmitter object
54 /// to emit a Mac OS X non-lazy pointer which contains the address of the
55 /// specified ptr.
56 virtual void *emitGlobalValueNonLazyPtr(const GlobalValue *GV, void *Ptr,
53 /// emitGlobalValueIndirectSym - Use the specified MachineCodeEmitter object
54 /// to emit an indirect symbol which contains the address of the specified
55 /// ptr.
56 virtual void *emitGlobalValueIndirectSym(const GlobalValue* GV, void *ptr,
5757 MachineCodeEmitter &MCE);
5858
5959 /// emitFunctionStub - Use the specified MachineCodeEmitter object to emit a
7272 void emitPCRelativeBlockAddress(MachineBasicBlock *MBB);
7373 void emitGlobalAddress(GlobalValue *GV, unsigned Reloc,
7474 intptr_t Disp = 0, intptr_t PCAdj = 0,
75 bool NeedStub = false, bool IsNonLazy = false);
75 bool NeedStub = false, bool Indirect = false);
7676 void emitExternalSymbolAddress(const char *ES, unsigned Reloc);
7777 void emitConstPoolAddress(unsigned CPI, unsigned Reloc, intptr_t Disp = 0,
7878 intptr_t PCAdj = 0);
154154 intptr_t Disp /* = 0 */,
155155 intptr_t PCAdj /* = 0 */,
156156 bool NeedStub /* = false */,
157 bool isNonLazy /* = false */) {
157 bool Indirect /* = false */) {
158158 intptr_t RelocCST = 0;
159159 if (Reloc == X86::reloc_picrel_word)
160160 RelocCST = PICBaseOffset;
161161 else if (Reloc == X86::reloc_pcrel_word)
162162 RelocCST = PCAdj;
163 MachineRelocation MR = isNonLazy
164 ? MachineRelocation::getGVNonLazyPtr(MCE.getCurrentPCOffset(), Reloc,
165 GV, RelocCST, NeedStub)
163 MachineRelocation MR = Indirect
164 ? MachineRelocation::getIndirectSymbol(MCE.getCurrentPCOffset(), Reloc,
165 GV, RelocCST, NeedStub)
166166 : MachineRelocation::getGV(MCE.getCurrentPCOffset(), Reloc,
167167 GV, RelocCST, NeedStub);
168168 MCE.addRelocation(MR);
288288 unsigned rt = Is64BitMode ? X86::reloc_pcrel_word
289289 : (IsPIC ? X86::reloc_picrel_word : X86::reloc_absolute_word);
290290 bool NeedStub = isa(RelocOp->getGlobal());
291 bool isNonLazy = gvNeedsNonLazyPtr(RelocOp->getGlobal());
291 bool Indirect = gvNeedsNonLazyPtr(RelocOp->getGlobal());
292292 emitGlobalAddress(RelocOp->getGlobal(), rt, RelocOp->getOffset(),
293 PCAdj, NeedStub, isNonLazy);
293 PCAdj, NeedStub, Indirect);
294294 } else if (RelocOp->isCPI()) {
295295 unsigned rt = Is64BitMode ? X86::reloc_pcrel_word : X86::reloc_picrel_word;
296296 emitConstPoolAddress(RelocOp->getIndex(), rt,
609609 rt = X86::reloc_absolute_dword; // FIXME: add X86II flag?
610610 if (MO1.isGlobal()) {
611611 bool NeedStub = isa(MO1.getGlobal());
612 bool isNonLazy = gvNeedsNonLazyPtr(MO1.getGlobal());
612 bool Indirect = gvNeedsNonLazyPtr(MO1.getGlobal());
613613 emitGlobalAddress(MO1.getGlobal(), rt, MO1.getOffset(), 0,
614 NeedStub, isNonLazy);
614 NeedStub, Indirect);
615615 } else if (MO1.isSymbol())
616616 emitExternalSymbolAddress(MO1.getSymbolName(), rt);
617617 else if (MO1.isCPI())
687687 rt = X86::reloc_absolute_word; // FIXME: add X86II flag?
688688 if (MO1.isGlobal()) {
689689 bool NeedStub = isa(MO1.getGlobal());
690 bool isNonLazy = gvNeedsNonLazyPtr(MO1.getGlobal());
690 bool Indirect = gvNeedsNonLazyPtr(MO1.getGlobal());
691691 emitGlobalAddress(MO1.getGlobal(), rt, MO1.getOffset(), 0,
692 NeedStub, isNonLazy);
692 NeedStub, Indirect);
693693 } else if (MO1.isSymbol())
694694 emitExternalSymbolAddress(MO1.getSymbolName(), rt);
695695 else if (MO1.isCPI())
725725 rt = X86::reloc_absolute_word; // FIXME: add X86II flag?
726726 if (MO.isGlobal()) {
727727 bool NeedStub = isa(MO.getGlobal());
728 bool isNonLazy = gvNeedsNonLazyPtr(MO.getGlobal());
728 bool Indirect = gvNeedsNonLazyPtr(MO.getGlobal());
729729 emitGlobalAddress(MO.getGlobal(), rt, MO.getOffset(), 0,
730 NeedStub, isNonLazy);
730 NeedStub, Indirect);
731731 } else if (MO.isSymbol())
732732 emitExternalSymbolAddress(MO.getSymbolName(), rt);
733733 else if (MO.isCPI())
412412 return X86CompilationCallback;
413413 }
414414
415 void *X86JITInfo::emitGlobalValueNonLazyPtr(const GlobalValue* GV, void *ptr,
416 MachineCodeEmitter &MCE) {
415 void *X86JITInfo::emitGlobalValueIndirectSym(const GlobalValue* GV, void *ptr,
416 MachineCodeEmitter &MCE) {
417417 #if defined (X86_64_JIT)
418418 MCE.startGVStub(GV, 8, 8);
419419 MCE.emitWordLE((unsigned)(intptr_t)ptr);
3636 ///
3737 virtual void replaceMachineCodeForFunction(void *Old, void *New);
3838
39 /// emitGlobalValueNonLazyPtr - Use the specified MachineCodeEmitter object
40 /// to emit a Mac OS X non-lazy pointer which contains the address of the
41 /// specified ptr.
42 virtual void *emitGlobalValueNonLazyPtr(const GlobalValue* GV, void *ptr,
43 MachineCodeEmitter &MCE);
39 /// emitGlobalValueIndirectSym - Use the specified MachineCodeEmitter object
40 /// to emit an indirect symbol which contains the address of the specified
41 /// ptr.
42 virtual void *emitGlobalValueIndirectSym(const GlobalValue* GV, void *ptr,
43 MachineCodeEmitter &MCE);
4444
4545 /// emitFunctionStub - Use the specified MachineCodeEmitter object to emit a
4646 /// small native function that simply calls the function at the specified