Implement the ExecutionEngine::getPointerToFunctionOrStub by forwarding the
authorChris Lattner <sabre@nondot.org>
Fri, 12 Dec 2003 07:12:02 +0000 (07:12 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 12 Dec 2003 07:12:02 +0000 (07:12 +0000)
request on to the TargetMachine if it supports the getJITStubForFunction method

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

lib/ExecutionEngine/JIT/JIT.h
lib/ExecutionEngine/JIT/VM.cpp
lib/ExecutionEngine/JIT/VM.h

index 9a17c967c70c51dda91acedebd4cab151aaf44d3..dc820670af17685dbc6d2316feb75a32719cab8e 100644 (file)
@@ -66,6 +66,12 @@ public:
   ///
   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
index e71ec6099d79b1d9b97e5df23782bccd07746c41..29ffa30215087a900196c97f926b5f718d8ca1fb 100644 (file)
@@ -77,6 +77,23 @@ void *VM::getPointerToFunction(Function *F) {
   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 9a17c967c70c51dda91acedebd4cab151aaf44d3..dc820670af17685dbc6d2316feb75a32719cab8e 100644 (file)
@@ -66,6 +66,12 @@ public:
   ///
   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