Rip JIT specific stuff out of TargetMachine, as per PR176
authorChris Lattner <sabre@nondot.org>
Sat, 20 Dec 2003 01:22:19 +0000 (01:22 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 20 Dec 2003 01:22:19 +0000 (01:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10542 91177308-0d34-0410-b5e6-96231b3b80d8

15 files changed:
include/llvm/Target/TargetJITInfo.h [new file with mode: 0644]
include/llvm/Target/TargetMachine.h
lib/ExecutionEngine/JIT/JIT.cpp
lib/ExecutionEngine/JIT/JIT.h
lib/ExecutionEngine/JIT/VM.cpp
lib/ExecutionEngine/JIT/VM.h
lib/Target/SparcV9/SparcV9CodeEmitter.cpp
lib/Target/SparcV9/SparcV9JITInfo.h [new file with mode: 0644]
lib/Target/SparcV9/SparcV9TargetMachine.cpp
lib/Target/SparcV9/SparcV9TargetMachine.h
lib/Target/X86/X86CodeEmitter.cpp
lib/Target/X86/X86InstrInfo.h
lib/Target/X86/X86JITInfo.h [new file with mode: 0644]
lib/Target/X86/X86TargetMachine.cpp
lib/Target/X86/X86TargetMachine.h

diff --git a/include/llvm/Target/TargetJITInfo.h b/include/llvm/Target/TargetJITInfo.h
new file mode 100644 (file)
index 0000000..90fea4e
--- /dev/null
@@ -0,0 +1,54 @@
+//===- Target/TargetJITInfo.h - Target Information for JIT ------*- 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 exposes an abstract interface used by the Just-In-Time code
+// generator to perform target-specific activities, such as emitting stubs.  If
+// a TargetMachine supports JIT code generation, it should provide one of these
+// objects through the getJITInfo() method.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TARGET_TARGETJITINFO_H
+#define LLVM_TARGET_TARGETJITINFO_H
+
+namespace llvm {
+  class Function;
+  class FunctionPassManager;
+  class MachineCodeEmitter;
+
+  /// TargetJITInfo - Target specific information required by the Just-In-Time
+  /// code generator.
+  struct TargetJITInfo {
+    virtual ~TargetJITInfo() {}
+    
+    /// addPassesToJITCompile - Add passes to the specified pass manager to
+    /// implement a fast code generator for this target.
+    ///
+    virtual void addPassesToJITCompile(FunctionPassManager &PM) = 0;
+    
+    /// 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.  This is used for self-modifying
+    /// code.
+    ///
+    virtual void replaceMachineCodeForFunction (void *Old, void *New) = 0;
+    
+    /// 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.  Targets do not need to implement this method, but
+    /// doing so will allow for faster startup of the JIT.
+    ///
+    virtual void *getJITStubForFunction(Function *F, MachineCodeEmitter &MCE) {
+      return 0;
+    }
+  };
+} // End llvm namespace
+
+#endif
index 758feb2088e1f9c89ad24caea121c6b2587b70e7..e326a2b68f512d823278a6c94efcd1763ecae77e 100644 (file)
@@ -21,6 +21,7 @@ namespace llvm {
 
 class TargetInstrInfo;
 class TargetInstrDescriptor;
+class TargetJITInfo;
 class TargetSchedInfo;
 class TargetRegInfo;
 class TargetFrameInfo;
@@ -79,16 +80,16 @@ public:
   ///
   virtual const MRegisterInfo*          getRegisterInfo() const { return 0; }
 
-  // Data storage information
+  /// getJITInfo - If this target supports a JIT, return information for it,
+  /// otherwise return null.
+  ///
+  virtual TargetJITInfo *getJITInfo() { return 0; }
+
+  // Data storage information.  FIXME, this should be moved out to sparc
+  // specific code.
   // 
   virtual unsigned findOptimalStorageSize(const Type* ty) const;
   
-  /// addPassesToJITCompile - Add passes to the specified pass manager to
-  /// implement a fast dynamic compiler for this target.  Return true if this is
-  /// not supported for this target.
-  ///
-  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
   /// of code generation.  This method should return true if assembly emission
@@ -108,24 +109,6 @@ public:
                                           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
index c5a70eade58cc5225d350dcbb9b9127097286cc3..dc9f7a14ffe32a4b6e780b40453e47768c755a76 100644 (file)
@@ -80,19 +80,20 @@ ExecutionEngine *VM::create(ModuleProvider *MP) {
   // Allocate a target...
   TargetMachine *Target = TargetMachineAllocator(*MP->getModule());
   assert(Target && "Could not allocate target machine!");
-  
-  // Create the virtual machine object...
-  return new VM(MP, Target);
+
+  // If the target supports JIT code generation, return a new JIT now.
+  if (TargetJITInfo *TJ = Target->getJITInfo())
+    return new VM(MP, *Target, *TJ);
+  return 0;
 }
 
-VM::VM(ModuleProvider *MP, TargetMachine *tm) : ExecutionEngine(MP), TM(*tm),
-  PM(MP)
-{
+VM::VM(ModuleProvider *MP, TargetMachine &tm, TargetJITInfo &tji)
+  : ExecutionEngine(MP), TM(tm), TJI(tji), PM(MP) {
   setTargetData(TM.getTargetData());
 
   // Initialize MCE
   MCE = createEmitter(*this);
-
+  
   setupPassManager();
 
   emitGlobals();
index dc820670af17685dbc6d2316feb75a32719cab8e..35f7223ae8ced658fc216d9c31723476add63731 100644 (file)
@@ -24,15 +24,18 @@ class Function;
 class GlobalValue;
 class Constant;
 class TargetMachine;
+class TargetJITInfo;
 class MachineCodeEmitter;
 
 class VM : public ExecutionEngine {
   TargetMachine &TM;       // The current target we are compiling to
+  TargetJITInfo &TJI;      // The JITInfo for the target we are compiling to
+  
   FunctionPassManager PM;  // Passes to compile a function
   MachineCodeEmitter *MCE; // MCE object
 
+  VM(ModuleProvider *MP, TargetMachine &tm, TargetJITInfo &tji);
 public:
-  VM(ModuleProvider *MP, TargetMachine *tm);
   ~VM();
 
   /// create - Create an return a new JIT compiler if there is one available
index 29ffa30215087a900196c97f926b5f718d8ca1fb..5dffa5c9136e99aa2c70b72e84bae9fdac018989 100644 (file)
@@ -18,6 +18,7 @@
 #include "llvm/CodeGen/MachineCodeEmitter.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/Target/TargetMachine.h"
+#include "llvm/Target/TargetJITInfo.h"
 using namespace llvm;
 
 VM::~VM() {
@@ -30,11 +31,7 @@ VM::~VM() {
 ///
 void VM::setupPassManager() {
   // Compile LLVM Code down to machine code in the intermediate representation
-  if (TM.addPassesToJITCompile(PM)) {
-    std::cerr << "lli: target '" << TM.getName()
-              << "' doesn't support JIT compilation!\n";
-    abort();
-  }
+  TJI.addPassesToJITCompile(PM);
 
   // Turn the machine code intermediate representation into bytes in memory that
   // may be executed.
@@ -87,7 +84,7 @@ void *VM::getPointerToFunctionOrStub(Function *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))
+  if (void *Ptr = TJI.getJITStubForFunction(F, *MCE))
     return Ptr;
 
   // Otherwise, if the target doesn't support it, just codegen the function.
@@ -112,6 +109,6 @@ void *VM::recompileAndRelinkFunction(Function *F) {
   MachineFunction::destruct(F);
   runJITOnFunction(F);
   assert(Addr && "Code generation didn't add function to GlobalAddress table!");
-  TM.replaceMachineCodeForFunction(OldAddr, Addr);
+  TJI.replaceMachineCodeForFunction(OldAddr, Addr);
   return Addr;
 }
index dc820670af17685dbc6d2316feb75a32719cab8e..35f7223ae8ced658fc216d9c31723476add63731 100644 (file)
@@ -24,15 +24,18 @@ class Function;
 class GlobalValue;
 class Constant;
 class TargetMachine;
+class TargetJITInfo;
 class MachineCodeEmitter;
 
 class VM : public ExecutionEngine {
   TargetMachine &TM;       // The current target we are compiling to
+  TargetJITInfo &TJI;      // The JITInfo for the target we are compiling to
+  
   FunctionPassManager PM;  // Passes to compile a function
   MachineCodeEmitter *MCE; // MCE object
 
+  VM(ModuleProvider *MP, TargetMachine &tm, TargetJITInfo &tji);
 public:
-  VM(ModuleProvider *MP, TargetMachine *tm);
   ~VM();
 
   /// create - Create an return a new JIT compiler if there is one available
index bb4bdaf8a417ea23c658a3a3251c11c7b5d19e64..99f90fffccdf42e453dbde41015e9beb7072df0d 100644 (file)
@@ -582,7 +582,7 @@ inline void SparcV9CodeEmitter::emitFarCall(uint64_t Target, Function *F) {
   }
 }
 
-void SparcTargetMachine::replaceMachineCodeForFunction (void *Old, void *New) {
+void SparcJITInfo::replaceMachineCodeForFunction (void *Old, void *New) {
   assert (TheJITResolver &&
        "Can only call replaceMachineCodeForFunction from within JIT");
   uint64_t Target = (uint64_t)(intptr_t)New;
diff --git a/lib/Target/SparcV9/SparcV9JITInfo.h b/lib/Target/SparcV9/SparcV9JITInfo.h
new file mode 100644 (file)
index 0000000..558d1d4
--- /dev/null
@@ -0,0 +1,47 @@
+//===- SparcJITInfo.h - Sparc implementation of the JIT interface -*-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 contains the Sparc implementation of the TargetJITInfo class.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef SPARCJITINFO_H
+#define SPARCJITINFO_H
+
+#include "llvm/Target/TargetJITInfo.h"
+
+namespace llvm {
+  class TargetMachine;
+  class SparcJITInfo : public TargetJITInfo {
+    TargetMachine &TM;
+  public:
+    SparcJITInfo(TargetMachine &tm) : TM(tm) {}
+
+    /// addPassesToJITCompile - Add passes to the specified pass manager to
+    /// implement a fast dynamic compiler for this target.  Return true if this
+    /// is not supported for this target.
+    ///
+    virtual void addPassesToJITCompile(FunctionPassManager &PM);
+    
+    /// 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.  This is used for self-modifying
+    /// code.
+    ///
+    virtual void replaceMachineCodeForFunction (void *Old, void *New);
+    
+    /// 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);
+  };
+}
+
+#endif
index 5bbed409dc5f14eee10768d13f3367778e8efb17..a122e3c11be22ab7a6fd49b12018e4744758a549 100644 (file)
@@ -73,7 +73,8 @@ SparcTargetMachine::SparcTargetMachine()
     schedInfo(*this),
     regInfo(*this),
     frameInfo(*this),
-    cacheInfo(*this) {
+    cacheInfo(*this),
+    jitInfo(*this) {
 }
 
 // addPassesToEmitAssembly - This method controls the entire code generation
@@ -152,8 +153,8 @@ SparcTargetMachine::addPassesToEmitAssembly(PassManager &PM, std::ostream &Out)
 // addPassesToJITCompile - This method controls the JIT method of code
 // generation for the UltraSparc.
 //
-bool SparcTargetMachine::addPassesToJITCompile(FunctionPassManager &PM) {
-  const TargetData &TD = getTargetData();
+void SparcJITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
+  const TargetData &TD = TM.getTargetData();
 
   PM.add(new TargetData("lli", TD.isLittleEndian(), TD.getPointerSize(),
                         TD.getPointerAlignment(), TD.getDoubleAlignment()));
@@ -173,11 +174,11 @@ bool SparcTargetMachine::addPassesToJITCompile(FunctionPassManager &PM) {
   PM.add(createDecomposeMultiDimRefsPass());
   
   // Construct and initialize the MachineFunction object for this fn.
-  PM.add(createMachineCodeConstructionPass(*this));
+  PM.add(createMachineCodeConstructionPass(TM));
 
   // Specialize LLVM code for this target machine and then
   // run basic dataflow optimizations on LLVM code.
-  PM.add(createPreSelectionPass(*this));
+  PM.add(createPreSelectionPass(TM));
   // Run basic dataflow optimizations on LLVM code
   PM.add(createReassociatePass());
 
@@ -185,15 +186,13 @@ bool SparcTargetMachine::addPassesToJITCompile(FunctionPassManager &PM) {
   //PM.add(createLICMPass());
   //PM.add(createGCSEPass());
 
-  PM.add(createInstructionSelectionPass(*this));
+  PM.add(createInstructionSelectionPass(TM));
 
-  PM.add(getRegisterAllocator(*this));
+  PM.add(getRegisterAllocator(TM));
   PM.add(createPrologEpilogInsertionPass());
 
   if (!DisablePeephole)
-    PM.add(createPeepholeOptsPass(*this));
-
-  return false; // success!
+    PM.add(createPeepholeOptsPass(TM));
 }
 
 //----------------------------------------------------------------------------
@@ -201,10 +200,6 @@ bool SparcTargetMachine::addPassesToJITCompile(FunctionPassManager &PM) {
 // that implements the Sparc backend. (the llvm/CodeGen/Sparc.h interface)
 //----------------------------------------------------------------------------
 
-namespace llvm {
-
-TargetMachine *allocateSparcTargetMachine(const Module &M) {
+TargetMachine *llvm::allocateSparcTargetMachine(const Module &M) {
   return new SparcTargetMachine();
 }
-
-}
index c8a6116186b5bc15f315b27875b134dcfc6e86c0..0dc109dcf42c001935cfbee3244798e6be48846e 100644 (file)
@@ -22,6 +22,7 @@
 #include "SparcInternals.h"
 #include "SparcRegInfo.h"
 #include "SparcFrameInfo.h"
+#include "SparcJITInfo.h"
 
 namespace llvm {
 
@@ -31,6 +32,7 @@ class SparcTargetMachine : public TargetMachine {
   SparcRegInfo   regInfo;
   SparcFrameInfo frameInfo;
   SparcCacheInfo cacheInfo;
+  SparcJITInfo   jitInfo;
 public:
   SparcTargetMachine();
 
@@ -39,19 +41,11 @@ public:
   virtual const TargetRegInfo    &getRegInfo()   const { return regInfo; }
   virtual const TargetFrameInfo  &getFrameInfo() const { return frameInfo; }
   virtual const TargetCacheInfo  &getCacheInfo() const { return cacheInfo; }
+  virtual       TargetJITInfo    *getJITInfo()         { return &jitInfo; }
 
   virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out);
-  virtual bool addPassesToJITCompile(FunctionPassManager &PM);
   virtual bool addPassesToEmitMachineCode(FunctionPassManager &PM,
                                           MachineCodeEmitter &MCE);
-  virtual void replaceMachineCodeForFunction(void *Old, void *New);
-
-  /// 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);
 };
 
 } // End llvm namespace
index 0b8ac110149e7400cfdba261de949ac0fca249c6..1917e626a5bac55ca8c6519f52950403ed5303e1 100644 (file)
@@ -53,13 +53,21 @@ namespace {
   JITResolver *TheJITResolver;
 }
 
-void *X86TargetMachine::getJITStubForFunction(Function *F,
-                                              MachineCodeEmitter &MCE) {
+void *X86JITInfo::getJITStubForFunction(Function *F, MachineCodeEmitter &MCE) {
   if (TheJITResolver == 0)
     TheJITResolver = new JITResolver(MCE);
   return (void*)((unsigned long)TheJITResolver->getLazyResolver(F));
 }
 
+void X86JITInfo::replaceMachineCodeForFunction (void *Old, void *New) {
+  char *OldByte = (char *) Old;
+  *OldByte++ = 0xE9;                // Emit JMP opcode.
+  int32_t *OldWord = (int32_t *) OldByte;
+  int32_t NewAddr = (intptr_t) New;
+  int32_t OldAddr = (intptr_t) OldWord;
+  *OldWord = NewAddr - OldAddr - 4; // Emit PC-relative addr of New code.
+}
+
 /// addFunctionReference - This method is called when we need to emit the
 /// address of a function that has not yet been emitted, so we don't know the
 /// address.  Instead, we emit a call to the CompilationCallback method, and
index 2bf82d16c63865f025c32744ed7692ddcec27aeb..5e371dd99ac9943cf8121015bae700fcf2c22222 100644 (file)
@@ -1,4 +1,4 @@
-//===- X86InstructionInfo.h - X86 Instruction Information ---------*-C++-*-===//
+//===- X86InstrInfo.h - X86 Instruction Information ------------*- C++ -*- ===//
 // 
 //                     The LLVM Compiler Infrastructure
 //
diff --git a/lib/Target/X86/X86JITInfo.h b/lib/Target/X86/X86JITInfo.h
new file mode 100644 (file)
index 0000000..bce6e95
--- /dev/null
@@ -0,0 +1,47 @@
+//===- X86JITInfo.h - X86 implementation of the JIT interface  --*- 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 contains the X86 implementation of the TargetJITInfo class.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef X86JITINFO_H
+#define X86JITINFO_H
+
+#include "llvm/Target/TargetJITInfo.h"
+
+namespace llvm {
+  class TargetMachine;
+  class X86JITInfo : public TargetJITInfo {
+    TargetMachine &TM;
+  public:
+    X86JITInfo(TargetMachine &tm) : TM(tm) {}
+
+    /// addPassesToJITCompile - Add passes to the specified pass manager to
+    /// implement a fast dynamic compiler for this target.  Return true if this
+    /// is not supported for this target.
+    ///
+    virtual void addPassesToJITCompile(FunctionPassManager &PM);
+    
+    /// 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.  This is used for self-modifying
+    /// code.
+    ///
+    virtual void replaceMachineCodeForFunction (void *Old, void *New);
+    
+    /// 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);
+  };
+}
+
+#endif
index fba8e8dc9eacf9a543e1e80a723fa1f4dcdf5dfb..2e989f05336372d0ec52fb2aa9e2c7a87864c2f1 100644 (file)
@@ -21,8 +21,7 @@
 #include "llvm/Transforms/Scalar.h"
 #include "Support/CommandLine.h"
 #include "Support/Statistic.h"
-
-namespace llvm {
+using namespace llvm;
 
 namespace {
   cl::opt<bool> PrintCode("print-machineinstrs",
@@ -36,7 +35,7 @@ namespace {
 // allocateX86TargetMachine - Allocate and return a subclass of TargetMachine
 // that implements the X86 backend.
 //
-TargetMachine *allocateX86TargetMachine(const Module &M) {
+TargetMachine *llvm::allocateX86TargetMachine(const Module &M) {
   return new X86TargetMachine(M);
 }
 
@@ -45,7 +44,8 @@ TargetMachine *allocateX86TargetMachine(const Module &M) {
 ///
 X86TargetMachine::X86TargetMachine(const Module &M)
   : TargetMachine("X86", true, 4, 4, 4, 4, 4),
-    FrameInfo(TargetFrameInfo::StackGrowsDown, 8/*16 for SSE*/, 4) {
+    FrameInfo(TargetFrameInfo::StackGrowsDown, 8/*16 for SSE*/, 4),
+    JITInfo(*this) {
 }
 
 
@@ -108,7 +108,7 @@ bool X86TargetMachine::addPassesToEmitAssembly(PassManager &PM,
 /// implement a fast dynamic compiler for this target.  Return true if this is
 /// not supported for this target.
 ///
-bool X86TargetMachine::addPassesToJITCompile(FunctionPassManager &PM) {
+void X86JITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
   // FIXME: Implement the switch instruction in the instruction selector!
   PM.add(createLowerSwitchPass());
 
@@ -120,9 +120,9 @@ bool X86TargetMachine::addPassesToJITCompile(FunctionPassManager &PM) {
   PM.add(createCFGSimplificationPass());
 
   if (NoPatternISel)
-    PM.add(createX86SimpleInstructionSelector(*this));
+    PM.add(createX86SimpleInstructionSelector(TM));
   else
-    PM.add(createX86PatternInstructionSelector(*this));
+    PM.add(createX86PatternInstructionSelector(TM));
 
   // Run optional SSA-based machine code optimizations next...
   if (!NoSSAPeephole)
@@ -156,18 +156,6 @@ bool X86TargetMachine::addPassesToJITCompile(FunctionPassManager &PM) {
   PM.add(createX86PeepholeOptimizerPass());
 
   if (PrintCode)  // Print the register-allocated code
-    PM.add(createX86CodePrinterPass(std::cerr, *this));
-  return false; // success!
-}
-
-void X86TargetMachine::replaceMachineCodeForFunction (void *Old, void *New) {
-  // FIXME: This code could perhaps live in a more appropriate place.
-  char *OldByte = (char *) Old;
-  *OldByte++ = 0xE9;                // Emit JMP opcode.
-  int32_t *OldWord = (int32_t *) OldByte;
-  int32_t NewAddr = (intptr_t) New;
-  int32_t OldAddr = (intptr_t) OldWord;
-  *OldWord = NewAddr - OldAddr - 4; // Emit PC-relative addr of New code.
+    PM.add(createX86CodePrinterPass(std::cerr, TM));
 }
 
-} // End llvm namespace
index 206ef89a46d48623450c3c8b1d9a3355232c4a4e..fc043500a05a165ef86d1b1c23c5216f21cf8110 100644 (file)
 #include "llvm/Target/TargetFrameInfo.h"
 #include "llvm/PassManager.h"
 #include "X86InstrInfo.h"
+#include "X86JITInfo.h"
 
 namespace llvm {
 
 class X86TargetMachine : public TargetMachine {
-  X86InstrInfo InstrInfo;
+  X86InstrInfo    InstrInfo;
   TargetFrameInfo FrameInfo;
+  X86JITInfo      JITInfo;
 public:
   X86TargetMachine(const Module &M);
 
@@ -33,16 +35,15 @@ public:
     return &InstrInfo.getRegisterInfo();
   }
 
+  virtual TargetJITInfo *getJITInfo() {
+    return &JITInfo;
+  }
+
+
   virtual const TargetSchedInfo &getSchedInfo()  const { abort(); }
   virtual const TargetRegInfo   &getRegInfo()    const { abort(); }
   virtual const TargetCacheInfo  &getCacheInfo() const { abort(); }
 
-  /// addPassesToJITCompile - Add passes to the specified pass manager to
-  /// implement a fast dynamic compiler for this target.  Return true if this is
-  /// not supported for this target.
-  ///
-  virtual bool addPassesToJITCompile(FunctionPassManager &PM);
-
   /// addPassesToEmitMachineCode - Add passes to the specified pass manager to
   /// get machine code emitted.  This uses a MachineCodeEmitter object to handle
   /// actually outputting the machine code and resolving things like the address
@@ -53,14 +54,6 @@ public:
                                           MachineCodeEmitter &MCE);
   
   virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out);
-
-  virtual void replaceMachineCodeForFunction (void *Old, void *New);
-
-  /// 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);
 };
 
 } // End llvm namespace