[llvm-commits] CVS: llvm/lib/ExecutionEngine/JIT/VM.cpp VM.h

Chris Lattner lattner at cs.uiuc.edu
Fri Dec 12 01:13:01 PST 2003


Changes in directory llvm/lib/ExecutionEngine/JIT:

VM.cpp updated: 1.15 -> 1.16
VM.h updated: 1.17 -> 1.18

---
Log message:

Implement the ExecutionEngine::getPointerToFunctionOrStub by forwarding the
request on to the TargetMachine if it supports the getJITStubForFunction method


---
Diffs of the changes:  (+23 -0)

Index: llvm/lib/ExecutionEngine/JIT/VM.cpp
diff -u llvm/lib/ExecutionEngine/JIT/VM.cpp:1.15 llvm/lib/ExecutionEngine/JIT/VM.cpp:1.16
--- llvm/lib/ExecutionEngine/JIT/VM.cpp:1.15	Mon Dec  8 02:06:28 2003
+++ llvm/lib/ExecutionEngine/JIT/VM.cpp	Fri Dec 12 01:12:02 2003
@@ -77,6 +77,23 @@
   return Addr;
 }
 
+// getPointerToFunctionOrStub - If the specified function has been
+// code-gen'd, return a pointer to the function.  If not, compile it, or use
+// a stub to implement lazy compilation if available.
+//
+void *VM::getPointerToFunctionOrStub(Function *F) {
+  // If we have already code generated the function, just return the address.
+  std::map<const GlobalValue*, void *>::iterator I = GlobalAddress.find(F);
+  if (I != GlobalAddress.end()) return I->second;
+
+  // If the target supports "stubs" for functions, get a stub now.
+  if (void *Ptr = TM.getJITStubForFunction(F, *MCE))
+    return Ptr;
+
+  // Otherwise, if the target doesn't support it, just codegen the function.
+  return getPointerToFunction(F);
+}
+
 /// recompileAndRelinkFunction - This method is used to force a function
 /// which has already been compiled, to be compiled again, possibly
 /// after it has been modified. Then the entry to the old copy is overwritten


Index: llvm/lib/ExecutionEngine/JIT/VM.h
diff -u llvm/lib/ExecutionEngine/JIT/VM.h:1.17 llvm/lib/ExecutionEngine/JIT/VM.h:1.18
--- llvm/lib/ExecutionEngine/JIT/VM.h:1.17	Tue Nov 11 16:41:33 2003
+++ llvm/lib/ExecutionEngine/JIT/VM.h	Fri Dec 12 01:12:02 2003
@@ -66,6 +66,12 @@
   ///
   void *getPointerToFunction(Function *F);
 
+  /// getPointerToFunctionOrStub - If the specified function has been
+  /// code-gen'd, return a pointer to the function.  If not, compile it, or use
+  /// a stub to implement lazy compilation if available.
+  ///
+  void *getPointerToFunctionOrStub(Function *F);
+
   /// recompileAndRelinkFunction - This method is used to force a function
   /// which has already been compiled, to be compiled again, possibly
   /// after it has been modified. Then the entry to the old copy is overwritten





More information about the llvm-commits mailing list