[llvm-commits] [llvm] r58882 - in /llvm/trunk/lib/Target/ARM: ARMCodeEmitter.cpp ARMJITInfo.cpp ARMJITInfo.h

Evan Cheng evan.cheng at apple.com
Fri Nov 7 17:31:27 PST 2008


Author: evancheng
Date: Fri Nov  7 19:31:27 2008
New Revision: 58882

URL: http://llvm.org/viewvc/llvm-project?rev=58882&view=rev
Log:
Handle ARM machine constantpool entry with non-lazy ptr.

Modified:
    llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp
    llvm/trunk/lib/Target/ARM/ARMJITInfo.cpp
    llvm/trunk/lib/Target/ARM/ARMJITInfo.h

Modified: llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp?rev=58882&r1=58881&r2=58882&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp Fri Nov  7 19:31:27 2008
@@ -336,8 +336,13 @@
     GlobalValue *GV = ACPV->getGV();
     if (GV) {
       assert(!ACPV->isStub() && "Don't know how to deal this yet!");
-      emitGlobalAddress(GV, ARM::reloc_arm_machine_cp_entry, false,
-                        (intptr_t)ACPV);
+      if (ACPV->isNonLazyPointer())
+        MCE.addRelocation(MachineRelocation::getGVNonLazyPtr(
+                  MCE.getCurrentPCOffset(), ARM::reloc_arm_machine_cp_entry, GV,
+                  (intptr_t)ACPV, false));
+      else 
+        emitGlobalAddress(GV, ARM::reloc_arm_machine_cp_entry,
+                          ACPV->isStub(), (intptr_t)ACPV);
      } else  {
       assert(!ACPV->isNonLazyPointer() && "Don't know how to deal this yet!");
       emitExternalSymbolAddress(ACPV->getSymbol(), ARM::reloc_arm_absolute);

Modified: llvm/trunk/lib/Target/ARM/ARMJITInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMJITInfo.cpp?rev=58882&r1=58881&r2=58882&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMJITInfo.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMJITInfo.cpp Fri Nov  7 19:31:27 2008
@@ -133,14 +133,21 @@
   return ARMCompilationCallback;
 }
 
+void *ARMJITInfo::emitGlobalValueNonLazyPtr(const GlobalValue *GV, void *Ptr,
+                                            MachineCodeEmitter &MCE) {
+  MCE.startFunctionStub(GV, 4, 4);  // FIXME: Rename this.
+  MCE.emitWordLE((intptr_t)Ptr);
+  return MCE.finishFunctionStub(GV);
+}
+
 void *ARMJITInfo::emitFunctionStub(const Function* F, void *Fn,
                                    MachineCodeEmitter &MCE) {
   unsigned addr = (intptr_t)Fn;
   // If this is just a call to an external function, emit a branch instead of a
   // call.  The code is the same except for one bit of the last instruction.
   if (Fn != (void*)(intptr_t)ARMCompilationCallback) {
-    // branch to the corresponding function addr
-    // the stub is 8-byte size and 4-aligned
+    // Branch to the corresponding function addr.
+    // The stub is 8-byte size and 4-aligned.
     MCE.startFunctionStub(F, 8, 4);
     MCE.emitWordLE(0xe51ff004); // LDR PC, [PC,#-4]
     MCE.emitWordLE(addr);       // addr of function
@@ -150,8 +157,8 @@
     // This stub sets the return address to restart the stub, so that
     // the new branch will be invoked when we come back.
     //
-    // branch and link to the compilation callback.
-    // the stub is 16-byte size and 4-byte aligned.
+    // Branch and link to the compilation callback.
+    // The stub is 16-byte size and 4-byte aligned.
     MCE.startFunctionStub(F, 16, 4);
     // Save LR so the callback can determine which stub called it.
     // The compilation callback is responsible for popping this prior

Modified: llvm/trunk/lib/Target/ARM/ARMJITInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMJITInfo.h?rev=58882&r1=58881&r2=58882&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMJITInfo.h (original)
+++ llvm/trunk/lib/Target/ARM/ARMJITInfo.h Fri Nov  7 19:31:27 2008
@@ -49,6 +49,12 @@
     ///
     virtual void replaceMachineCodeForFunction(void *Old, void *New);
 
+    /// 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
     /// address.





More information about the llvm-commits mailing list