[llvm-commits] CVS: llvm/lib/Target/Sparc/SparcJITInfo.h SparcTargetMachine.cpp SparcTargetMachine.h SparcV9CodeEmitter.cpp

Chris Lattner lattner at cs.uiuc.edu
Fri Dec 19 19:23:10 PST 2003


Changes in directory llvm/lib/Target/Sparc:

SparcJITInfo.h added (r1.1)
SparcTargetMachine.cpp updated: 1.92 -> 1.93
SparcTargetMachine.h updated: 1.1 -> 1.2
SparcV9CodeEmitter.cpp updated: 1.47 -> 1.48

---
Log message:

Rip JIT specific stuff out of TargetMachine, as per PR176


---
Diffs of the changes:  (+61 -25)

Index: llvm/lib/Target/Sparc/SparcJITInfo.h
diff -c /dev/null llvm/lib/Target/Sparc/SparcJITInfo.h:1.1
*** /dev/null	Fri Dec 19 19:22:09 2003
--- llvm/lib/Target/Sparc/SparcJITInfo.h	Fri Dec 19 19:21:59 2003
***************
*** 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: llvm/lib/Target/Sparc/SparcTargetMachine.cpp
diff -u llvm/lib/Target/Sparc/SparcTargetMachine.cpp:1.92 llvm/lib/Target/Sparc/SparcTargetMachine.cpp:1.93
--- llvm/lib/Target/Sparc/SparcTargetMachine.cpp:1.92	Wed Dec 17 16:04:00 2003
+++ llvm/lib/Target/Sparc/SparcTargetMachine.cpp	Fri Dec 19 19:21:59 2003
@@ -73,7 +73,8 @@
     schedInfo(*this),
     regInfo(*this),
     frameInfo(*this),
-    cacheInfo(*this) {
+    cacheInfo(*this),
+    jitInfo(*this) {
 }
 
 // addPassesToEmitAssembly - This method controls the entire code generation
@@ -152,8 +153,8 @@
 // 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 @@
   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 @@
   //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 @@
 // 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: llvm/lib/Target/Sparc/SparcTargetMachine.h
diff -u llvm/lib/Target/Sparc/SparcTargetMachine.h:1.1 llvm/lib/Target/Sparc/SparcTargetMachine.h:1.2
--- llvm/lib/Target/Sparc/SparcTargetMachine.h:1.1	Wed Dec 17 16:04:00 2003
+++ llvm/lib/Target/Sparc/SparcTargetMachine.h	Fri Dec 19 19:21:59 2003
@@ -22,6 +22,7 @@
 #include "SparcInternals.h"
 #include "SparcRegInfo.h"
 #include "SparcFrameInfo.h"
+#include "SparcJITInfo.h"
 
 namespace llvm {
 
@@ -31,6 +32,7 @@
   SparcRegInfo   regInfo;
   SparcFrameInfo frameInfo;
   SparcCacheInfo cacheInfo;
+  SparcJITInfo   jitInfo;
 public:
   SparcTargetMachine();
 
@@ -39,19 +41,11 @@
   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: llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp
diff -u llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp:1.47 llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp:1.48
--- llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp:1.47	Wed Dec 17 16:04:00 2003
+++ llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp	Fri Dec 19 19:21:59 2003
@@ -582,7 +582,7 @@
   }
 }
 
-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;





More information about the llvm-commits mailing list