[llvm-commits] CVS: llvm/lib/Target/X86/X86JITInfo.h X86CodeEmitter.cpp X86InstrInfo.h X86TargetMachine.cpp X86TargetMachine.h
Chris Lattner
lattner at cs.uiuc.edu
Fri Dec 19 19:23:01 PST 2003
Changes in directory llvm/lib/Target/X86:
X86JITInfo.h added (r1.1)
X86CodeEmitter.cpp updated: 1.42 -> 1.43
X86InstrInfo.h updated: 1.28 -> 1.29
X86TargetMachine.cpp updated: 1.39 -> 1.40
X86TargetMachine.h updated: 1.18 -> 1.19
---
Log message:
Rip JIT specific stuff out of TargetMachine, as per PR176
---
Diffs of the changes: (+74 -38)
Index: llvm/lib/Target/X86/X86JITInfo.h
diff -c /dev/null llvm/lib/Target/X86/X86JITInfo.h:1.1
*** /dev/null Fri Dec 19 19:22:15 2003
--- llvm/lib/Target/X86/X86JITInfo.h Fri Dec 19 19:22:04 2003
***************
*** 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: llvm/lib/Target/X86/X86CodeEmitter.cpp
diff -u llvm/lib/Target/X86/X86CodeEmitter.cpp:1.42 llvm/lib/Target/X86/X86CodeEmitter.cpp:1.43
--- llvm/lib/Target/X86/X86CodeEmitter.cpp:1.42 Fri Dec 12 13:57:48 2003
+++ llvm/lib/Target/X86/X86CodeEmitter.cpp Fri Dec 19 19:22:04 2003
@@ -53,11 +53,19 @@
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
Index: llvm/lib/Target/X86/X86InstrInfo.h
diff -u llvm/lib/Target/X86/X86InstrInfo.h:1.28 llvm/lib/Target/X86/X86InstrInfo.h:1.29
--- llvm/lib/Target/X86/X86InstrInfo.h:1.28 Tue Nov 11 16:41:33 2003
+++ llvm/lib/Target/X86/X86InstrInfo.h Fri Dec 19 19:22:04 2003
@@ -1,4 +1,4 @@
-//===- X86InstructionInfo.h - X86 Instruction Information ---------*-C++-*-===//
+//===- X86InstrInfo.h - X86 Instruction Information ------------*- C++ -*- ===//
//
// The LLVM Compiler Infrastructure
//
Index: llvm/lib/Target/X86/X86TargetMachine.cpp
diff -u llvm/lib/Target/X86/X86TargetMachine.cpp:1.39 llvm/lib/Target/X86/X86TargetMachine.cpp:1.40
--- llvm/lib/Target/X86/X86TargetMachine.cpp:1.39 Fri Dec 12 23:36:19 2003
+++ llvm/lib/Target/X86/X86TargetMachine.cpp Fri Dec 19 19:22:04 2003
@@ -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 @@
// 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 @@
///
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 @@
/// 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 @@
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 @@
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: llvm/lib/Target/X86/X86TargetMachine.h
diff -u llvm/lib/Target/X86/X86TargetMachine.h:1.18 llvm/lib/Target/X86/X86TargetMachine.h:1.19
--- llvm/lib/Target/X86/X86TargetMachine.h:1.18 Fri Dec 12 01:11:18 2003
+++ llvm/lib/Target/X86/X86TargetMachine.h Fri Dec 19 19:22:04 2003
@@ -18,12 +18,14 @@
#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 @@
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 @@
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
More information about the llvm-commits
mailing list