Rename isGVLazyPtr to isGVNonLazyPtr relocation. This represents Mac OS X
authorEvan Cheng <evan.cheng@apple.com>
Wed, 5 Nov 2008 01:50:32 +0000 (01:50 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Wed, 5 Nov 2008 01:50:32 +0000 (01:50 +0000)
indirect gv reference. Please don't call it lazy.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58746 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/MachineRelocation.h
include/llvm/Target/TargetJITInfo.h
lib/ExecutionEngine/JIT/JITEmitter.cpp
lib/Target/X86/X86CodeEmitter.cpp
lib/Target/X86/X86JITInfo.cpp
lib/Target/X86/X86JITInfo.h

index 5c8302a56f7d31280eda40da385a8b8f759faeee..9a812a1fadd5f9d1a1959480ce7f468e5b945b23 100644 (file)
@@ -39,7 +39,7 @@ class MachineRelocation {
   enum AddressType {
     isResult,         // Relocation has be transformed into its result pointer.
     isGV,             // The Target.GV field is valid.
-    isGVLazyPtr,      // Relocation of a lazily resolved GV address.
+    isGVNonLazyPtr,   // Relocation of a Mac OS X NonLazy indirect reference.
     isBB,             // Relocation of BB address.
     isExtSym,         // The Target.ExtSym field is valid.
     isConstPool,      // Relocation of constant pool address.
@@ -56,7 +56,7 @@ class MachineRelocation {
 
   union {
     void *Result;           // If this has been resolved to a resolved pointer
-    GlobalValue *GV;        // If this is a pointer to a GV or a GV lazy ptr
+    GlobalValue *GV;        // If this is a pointer to a GV or a GV nonlazy ptr
     MachineBasicBlock *MBB; // If this is a pointer to a LLVM BB
     const char *ExtSym;     // If this is a pointer to a named symbol
     unsigned Index;         // Constant pool / jump table index
@@ -96,9 +96,9 @@ public:
     return Result;
   }
 
-  /// MachineRelocation::getGVLazyPtr - Return a relocation entry for a
-  /// lazily resolved GlobalValue address.
-  static MachineRelocation getGVLazyPtr(intptr_t offset,
+  /// MachineRelocation::getGVNonLazyPtr - Return a relocation entry for a
+  /// Mac OS X non-lazy GlobalValue indirect reference.
+  static MachineRelocation getGVNonLazyPtr(intptr_t offset,
                                  unsigned RelocationType, 
                                  GlobalValue *GV, intptr_t cst = 0,
                                  bool NeedStub = 0,
@@ -108,7 +108,7 @@ public:
     Result.Offset = offset;
     Result.ConstantVal = cst;
     Result.TargetReloType = RelocationType;
-    Result.AddrType = isGVLazyPtr;
+    Result.AddrType = isGVNonLazyPtr;
     Result.NeedStub = NeedStub;
     Result.GOTRelative = GOTrelative;
     Result.TargetResolve = false;
@@ -221,10 +221,10 @@ public:
     return AddrType == isGV;
   }
 
-  /// isGlobalValueVLazyPtr - Return true if this relocation is the address
-  /// of a lazily resolved GlobalValue.
-  bool isGlobalValueLazyPtr() const {
-    return AddrType == isGVLazyPtr;
+  /// isGlobalValueNonLazyPtr - Return true if this relocation is the address
+  /// of a Mac OS X non-lazy indirect reference.
+  bool isGlobalValueNonLazyPtr() const {
+    return AddrType == isGVNonLazyPtr;
   }
 
   /// isBasicBlock - Return true if this relocation is a basic block reference.
@@ -274,7 +274,7 @@ public:
   /// getGlobalValue - If this is a global value reference, return the
   /// referenced global.
   GlobalValue *getGlobalValue() const {
-    assert((isGlobalValue() || isGlobalValueLazyPtr()) &&
+    assert((isGlobalValue() || isGlobalValueNonLazyPtr()) &&
            "This is not a global value reference!");
     return Target.GV;
   }
index fb89292c537c647c13fc4921446f699548de8d1a..4b81c034662e9f0f7d377d1c65b3c288126210a4 100644 (file)
@@ -40,11 +40,12 @@ namespace llvm {
     ///
     virtual void replaceMachineCodeForFunction(void *Old, void *New) = 0;
 
-    /// emitGlobalValueLazyPtr - Use the specified MachineCodeEmitter object to
-    /// emit a lazy pointer which contains the address of the specified ptr.
-    virtual void *emitGlobalValueLazyPtr(const GlobalValue* GV, void *ptr,
-                                         MachineCodeEmitter &MCE) {
-      assert(0 && "This target doesn't implement emitGlobalValueLazyPtr!");
+    /// emitGlobalValueNonLazyPtr - Use the specified MachineCodeEmitter object
+    /// to emit a Mac OS X non-lazy pointer which contains the address of the
+    /// specified ptr.
+    virtual void *emitGlobalValueNonLazyPtr(const GlobalValue* GV, void *ptr,
+                                            MachineCodeEmitter &MCE) {
+      assert(0 && "This target doesn't implement emitGlobalValueNonLazyPtr!");
       return 0;
     }
 
index 747ac0894a554d18e02ed6ef2053b72aff4a905b..0a61c06ec988f8cf93c86ca7825ff7b84b72cafc 100644 (file)
@@ -59,9 +59,9 @@ namespace {
     /// corresponds to.
     std::map<void*, Function*> StubToFunctionMap;
 
-    /// GlobalToLazyPtrMap - Keep track of the lazy pointer created for a
+    /// GlobalToNonLazyPtrMap - Keep track of the lazy pointer created for a
     /// particular GlobalVariable so that we can reuse them if necessary.
-    std::map<GlobalValue*, void*> GlobalToLazyPtrMap;
+    std::map<GlobalValue*, void*> GlobalToNonLazyPtrMap;
 
   public:
     std::map<Function*, void*>& getFunctionToStubMap(const MutexGuard& locked) {
@@ -75,9 +75,9 @@ namespace {
     }
 
     std::map<GlobalValue*, void*>&
-    getGlobalToLazyPtrMap(const MutexGuard& locked) {
+    getGlobalToNonLazyPtrMap(const MutexGuard& locked) {
       assert(locked.holds(TheJIT->lock));
-      return GlobalToLazyPtrMap;
+      return GlobalToNonLazyPtrMap;
     }
   };
 
@@ -120,9 +120,9 @@ namespace {
     /// specified address, created lazily on demand.
     void *getExternalFunctionStub(void *FnAddr);
 
-    /// getGlobalValueLazyPtr - Return a lazy pointer containing the specified
-    /// GV address.
-    void *getGlobalValueLazyPtr(GlobalValue *V, void *GVAddress);
+    /// getGlobalValueNonLazyPtr - Return a non-lazy pointer containing the
+    /// specified GV address.
+    void *getGlobalValueNonLazyPtr(GlobalValue *V, void *GVAddress);
 
     /// AddCallbackAtLocation - If the target is capable of rewriting an
     /// instruction without the use of a stub, record the location of the use so
@@ -184,23 +184,23 @@ void *JITResolver::getFunctionStub(Function *F) {
   return Stub;
 }
 
-/// getGlobalValueLazyPtr - Return a lazy pointer containing the specified
+/// getGlobalValueNonLazyPtr - Return a lazy pointer containing the specified
 /// GV address.
-void *JITResolver::getGlobalValueLazyPtr(GlobalValue *GV, void *GVAddress) {
+void *JITResolver::getGlobalValueNonLazyPtr(GlobalValue *GV, void *GVAddress) {
   MutexGuard locked(TheJIT->lock);
 
   // If we already have a stub for this global variable, recycle it.
-  void *&LazyPtr = state.getGlobalToLazyPtrMap(locked)[GV];
-  if (LazyPtr) return LazyPtr;
+  void *&NonLazyPtr = state.getGlobalToNonLazyPtrMap(locked)[GV];
+  if (NonLazyPtr) return NonLazyPtr;
 
   // Otherwise, codegen a new lazy pointer.
-  LazyPtr = TheJIT->getJITInfo().emitGlobalValueLazyPtr(GV, GVAddress,
-                                                    *TheJIT->getCodeEmitter());
+  NonLazyPtr = TheJIT->getJITInfo().emitGlobalValueNonLazyPtr(GV, GVAddress,
+                                                     *TheJIT->getCodeEmitter());
 
-  DOUT << "JIT: Stub emitted at [" << LazyPtr << "] for GV '"
+  DOUT << "JIT: Stub emitted at [" << NonLazyPtr << "] for GV '"
        << GV->getName() << "'\n";
 
-  return LazyPtr;
+  return NonLazyPtr;
 }
 
 /// getExternalFunctionStub - Return a stub for the function at the
@@ -570,8 +570,8 @@ namespace {
 
   private:
     void *getPointerToGlobal(GlobalValue *GV, void *Reference, bool NoNeedStub);
-    void *getPointerToGVLazyPtr(GlobalValue *V, void *Reference,
-                                bool NoNeedStub);
+    void *getPointerToGVNonLazyPtr(GlobalValue *V, void *Reference,
+                                   bool NoNeedStub);
     unsigned addSizeOfGlobal(const GlobalVariable *GV, unsigned Size);
     unsigned addSizeOfGlobalsInConstantVal(const Constant *C, unsigned Size);
     unsigned addSizeOfGlobalsInInitializer(const Constant *Init, unsigned Size);
@@ -613,13 +613,13 @@ void *JITEmitter::getPointerToGlobal(GlobalValue *V, void *Reference,
   return Resolver.getFunctionStub(F);
 }
 
-void *JITEmitter::getPointerToGVLazyPtr(GlobalValue *V, void *Reference,
+void *JITEmitter::getPointerToGVNonLazyPtr(GlobalValue *V, void *Reference,
                                         bool DoesntNeedStub) {
   // Make sure GV is emitted first.
   // FIXME: For now, if the GV is an external function we force the JIT to
-  // compile it so the lazy pointer will contain the fully resolved address.
+  // compile it so the non-lazy pointer will contain the fully resolved address.
   void *GVAddress = getPointerToGlobal(V, Reference, true);
-  return Resolver.getGlobalValueLazyPtr(V, GVAddress);
+  return Resolver.getGlobalValueNonLazyPtr(V, GVAddress);
 }
 
 static unsigned GetConstantPoolSizeInBytes(MachineConstantPool *MCP) {
@@ -887,8 +887,8 @@ bool JITEmitter::finishFunction(MachineFunction &F) {
           ResultPtr = getPointerToGlobal(MR.getGlobalValue(),
                                          BufferBegin+MR.getMachineCodeOffset(),
                                          MR.doesntNeedStub());
-        } else if (MR.isGlobalValueLazyPtr()) {
-          ResultPtr = getPointerToGVLazyPtr(MR.getGlobalValue(),
+        } else if (MR.isGlobalValueNonLazyPtr()) {
+          ResultPtr = getPointerToGVNonLazyPtr(MR.getGlobalValue(),
                                           BufferBegin+MR.getMachineCodeOffset(),
                                           MR.doesntNeedStub());
         } else if (MR.isBasicBlock()) {
index 127114614015b5c703f642f858953bead9657d57..fabb67ee2df6bfc98c7343b0ebec5c5a69e1e1a7 100644 (file)
@@ -73,7 +73,7 @@ namespace {
     void emitPCRelativeBlockAddress(MachineBasicBlock *MBB);
     void emitGlobalAddress(GlobalValue *GV, unsigned Reloc,
                            intptr_t Disp = 0, intptr_t PCAdj = 0,
-                           bool NeedStub = false, bool IsLazy = false);
+                           bool NeedStub = false, bool IsNonLazy = false);
     void emitExternalSymbolAddress(const char *ES, unsigned Reloc);
     void emitConstPoolAddress(unsigned CPI, unsigned Reloc, intptr_t Disp = 0,
                               intptr_t PCAdj = 0);
@@ -94,7 +94,7 @@ namespace {
 
     unsigned getX86RegNum(unsigned RegNo) const;
 
-    bool gvNeedsLazyPtr(const GlobalValue *GV);
+    bool gvNeedsNonLazyPtr(const GlobalValue *GV);
   };
   char Emitter::ID = 0;
 }
@@ -155,15 +155,15 @@ void Emitter::emitGlobalAddress(GlobalValue *GV, unsigned Reloc,
                                 intptr_t Disp /* = 0 */,
                                 intptr_t PCAdj /* = 0 */,
                                 bool NeedStub /* = false */,
-                                bool isLazy /* = false */) {
+                                bool isNonLazy /* = false */) {
   intptr_t RelocCST = 0;
   if (Reloc == X86::reloc_picrel_word)
     RelocCST = PICBaseOffset;
   else if (Reloc == X86::reloc_pcrel_word)
     RelocCST = PCAdj;
-  MachineRelocation MR = isLazy 
-    ? MachineRelocation::getGVLazyPtr(MCE.getCurrentPCOffset(), Reloc,
-                                      GV, RelocCST, NeedStub)
+  MachineRelocation MR = isNonLazy 
+    ? MachineRelocation::getGVNonLazyPtr(MCE.getCurrentPCOffset(), Reloc,
+                                         GV, RelocCST, NeedStub)
     : MachineRelocation::getGV(MCE.getCurrentPCOffset(), Reloc,
                                GV, RelocCST, NeedStub);
   MCE.addRelocation(MR);
@@ -263,8 +263,8 @@ static bool isDisp8(int Value) {
   return Value == (signed char)Value;
 }
 
-bool Emitter::gvNeedsLazyPtr(const GlobalValue *GV) {
-  // For Darwin, simulate the linktime GOT by using the same lazy-pointer
+bool Emitter::gvNeedsNonLazyPtr(const GlobalValue *GV) {
+  // For Darwin, simulate the linktime GOT by using the same non-lazy-pointer
   // mechanism as 32-bit mode.
   return (!Is64BitMode || TM.getSubtarget<X86Subtarget>().isTargetDarwin()) &&
     TM.getSubtarget<X86Subtarget>().GVRequiresExtraLoad(GV, TM, false);
@@ -289,9 +289,9 @@ void Emitter::emitDisplacementField(const MachineOperand *RelocOp,
     unsigned rt = Is64BitMode ? X86::reloc_pcrel_word
       : (IsPIC ? X86::reloc_picrel_word : X86::reloc_absolute_word);
     bool NeedStub = isa<Function>(RelocOp->getGlobal());
-    bool isLazy = gvNeedsLazyPtr(RelocOp->getGlobal());
+    bool isNonLazy = gvNeedsNonLazyPtr(RelocOp->getGlobal());
     emitGlobalAddress(RelocOp->getGlobal(), rt, RelocOp->getOffset(),
-                      PCAdj, NeedStub, isLazy);
+                      PCAdj, NeedStub, isNonLazy);
   } else if (RelocOp->isCPI()) {
     unsigned rt = Is64BitMode ? X86::reloc_pcrel_word : X86::reloc_picrel_word;
     emitConstPoolAddress(RelocOp->getIndex(), rt,
@@ -610,9 +610,9 @@ void Emitter::emitInstruction(const MachineInstr &MI,
           rt = X86::reloc_absolute_dword;  // FIXME: add X86II flag?
         if (MO1.isGlobal()) {
           bool NeedStub = isa<Function>(MO1.getGlobal());
-          bool isLazy = gvNeedsLazyPtr(MO1.getGlobal());
+          bool isNonLazy = gvNeedsNonLazyPtr(MO1.getGlobal());
           emitGlobalAddress(MO1.getGlobal(), rt, MO1.getOffset(), 0,
-                            NeedStub, isLazy);
+                            NeedStub, isNonLazy);
         } else if (MO1.isSymbol())
           emitExternalSymbolAddress(MO1.getSymbolName(), rt);
         else if (MO1.isCPI())
@@ -688,9 +688,9 @@ void Emitter::emitInstruction(const MachineInstr &MI,
           rt = X86::reloc_absolute_word;  // FIXME: add X86II flag?
         if (MO1.isGlobal()) {
           bool NeedStub = isa<Function>(MO1.getGlobal());
-          bool isLazy = gvNeedsLazyPtr(MO1.getGlobal());
+          bool isNonLazy = gvNeedsNonLazyPtr(MO1.getGlobal());
           emitGlobalAddress(MO1.getGlobal(), rt, MO1.getOffset(), 0,
-                            NeedStub, isLazy);
+                            NeedStub, isNonLazy);
         } else if (MO1.isSymbol())
           emitExternalSymbolAddress(MO1.getSymbolName(), rt);
         else if (MO1.isCPI())
@@ -726,9 +726,9 @@ void Emitter::emitInstruction(const MachineInstr &MI,
           rt = X86::reloc_absolute_word;  // FIXME: add X86II flag?
         if (MO.isGlobal()) {
           bool NeedStub = isa<Function>(MO.getGlobal());
-          bool isLazy = gvNeedsLazyPtr(MO.getGlobal());
+          bool isNonLazy = gvNeedsNonLazyPtr(MO.getGlobal());
           emitGlobalAddress(MO.getGlobal(), rt, MO.getOffset(), 0,
-                            NeedStub, isLazy);
+                            NeedStub, isNonLazy);
         } else if (MO.isSymbol())
           emitExternalSymbolAddress(MO.getSymbolName(), rt);
         else if (MO.isCPI())
index f8761dc87e2c8721b1d815f94f510939af7a34a5..ee46657431d5bd88142f08c30746fcef769e95ba 100644 (file)
@@ -413,8 +413,8 @@ X86JITInfo::getLazyResolverFunction(JITCompilerFn F) {
   return X86CompilationCallback;
 }
 
-void *X86JITInfo::emitGlobalValueLazyPtr(const GlobalValue* GV, void *ptr,
-                                         MachineCodeEmitter &MCE) {
+void *X86JITInfo::emitGlobalValueNonLazyPtr(const GlobalValue* GV, void *ptr,
+                                            MachineCodeEmitter &MCE) {
 #if defined (X86_64_JIT)
   MCE.startFunctionStub(GV, 8, 8);
   MCE.emitWordLE((unsigned)(intptr_t)ptr);
index 6b8d197846b2e81a48eb6a2a94f492d22f27b4bd..65a417dde84f502c27060400895e123f06652976 100644 (file)
@@ -37,10 +37,11 @@ namespace llvm {
     ///
     virtual void replaceMachineCodeForFunction(void *Old, void *New);
 
-    /// emitGlobalValueLazyPtr - Use the specified MachineCodeEmitter object to
-    /// emit a lazy pointer which contains the address of the specified ptr.
-    virtual void *emitGlobalValueLazyPtr(const GlobalValue* GV, void *ptr,
-                                         MachineCodeEmitter &MCE);
+    /// emitGlobalValueNonLazyPtr - Use the specified MachineCodeEmitter object
+    /// to emit a Mac OS X non-lazy pointer which contains the address of the
+    /// specified ptr.
+    virtual void *emitGlobalValueNonLazyPtr(const GlobalValue* GV, void *ptr,
+                                            MachineCodeEmitter &MCE);
 
     /// emitFunctionStub - Use the specified MachineCodeEmitter object to emit a
     /// small native function that simply calls the function at the specified