Add new getJITStubForFunction method, which may optionally be implemented by
[oota-llvm.git] / include / llvm / Target / TargetMachine.h
index 041a724b0c37f0cd6f50fa9027c2525882d5c9cb..758feb2088e1f9c89ad24caea121c6b2587b70e7 100644 (file)
@@ -1,4 +1,11 @@
-//===-- llvm/Target/TargetMachine.h - General Target Information -*- C++ -*-==//
+//===-- llvm/Target/TargetMachine.h - Target Information --------*- C++ -*-===//
+// 
+//                     The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// 
+//===----------------------------------------------------------------------===//
 //
 // This file describes the general parts of a Target machine.
 //
@@ -8,7 +15,9 @@
 #define LLVM_TARGET_TARGETMACHINE_H
 
 #include "llvm/Target/TargetData.h"
-#include "Support/NonCopyable.h"
+#include <cassert>
+
+namespace llvm {
 
 class TargetInstrInfo;
 class TargetInstrDescriptor;
@@ -16,9 +25,9 @@ class TargetSchedInfo;
 class TargetRegInfo;
 class TargetFrameInfo;
 class TargetCacheInfo;
-class TargetOptInfo;
 class MachineCodeEmitter;
 class MRegisterInfo;
+class FunctionPassManager;
 class PassManager;
 class Pass;
 
@@ -28,10 +37,12 @@ class Pass;
 /// the target machine.  All target-specific information should be accessible
 /// through this interface.
 /// 
-class TargetMachine : public NonCopyableV {
+class TargetMachine {
   const std::string Name;
-  const TargetData DataLayout;         // Calculates type size & alignment
+  const TargetData DataLayout;          // Calculates type size & alignment
   
+  TargetMachine(const TargetMachine&);   // DO NOT IMPLEMENT
+  void operator=(const TargetMachine&);  // DO NOT IMPLEMENT
 protected:
   TargetMachine(const std::string &name, // Can only create subclasses...
                bool LittleEndian = false,
@@ -60,7 +71,6 @@ public:
   virtual const TargetRegInfo&          getRegInfo()   const = 0;
   virtual const TargetFrameInfo&        getFrameInfo() const = 0;
   virtual const TargetCacheInfo&        getCacheInfo() const = 0;
-  virtual const TargetOptInfo&          getOptInfo()   const = 0;
   const TargetData &getTargetData() const { return DataLayout; }
 
   /// getRegisterInfo - If register information is available, return it.  If
@@ -77,7 +87,7 @@ public:
   /// implement a fast dynamic compiler for this target.  Return true if this is
   /// not supported for this target.
   ///
-  virtual bool addPassesToJITCompile(PassManager &PM) { return true; }
+  virtual bool addPassesToJITCompile(FunctionPassManager &PM) { return true; }
 
   /// addPassesToEmitAssembly - Add passes to the specified pass manager to get
   /// assembly langage code emitted.  Typically this will involve several steps
@@ -89,15 +99,35 @@ public:
   }
 
   /// addPassesToEmitMachineCode - Add passes to the specified pass manager to
-  /// get machine code emitted.  This uses a MAchineCodeEmitter object to handle
+  /// get machine code emitted.  This uses a MachineCodeEmitter object to handle
   /// actually outputting the machine code and resolving things like the address
   /// of functions.  This method should returns true if machine code emission is
   /// not supported.
   ///
-  virtual bool addPassesToEmitMachineCode(PassManager &PM,
+  virtual bool addPassesToEmitMachineCode(FunctionPassManager &PM,
                                           MachineCodeEmitter &MCE) {
     return true;
   }
+
+  /// replaceMachineCodeForFunction - Make it so that calling the
+  /// function whose machine code is at OLD turns into a call to NEW,
+  /// perhaps by overwriting OLD with a branch to NEW.
+  ///
+  /// FIXME: this is JIT-specific.
+  ///
+  virtual void replaceMachineCodeForFunction (void *Old, void *New) {
+    assert (0 && "Current target cannot replace machine code for functions");
+  }
+
+  /// getJITStubForFunction - Create or return a stub for the specified
+  /// function.  This stub acts just like the specified function, except that it
+  /// allows the "address" of the function to be taken without having to
+  /// generate code for it.
+  virtual void *getJITStubForFunction(Function *F, MachineCodeEmitter &MCE) {
+    return 0;
+  }
 };
 
+} // End llvm namespace
+
 #endif