Added LLVM project notice to the top of every C++ source file.
[oota-llvm.git] / lib / Target / X86 / X86TargetMachine.cpp
index dcc9beaf9d02bcd89cc73655a4d96695366bc57c..d094d900665f65202994433d2ef7cd4e7eb73d31 100644 (file)
@@ -1,5 +1,12 @@
 //===-- X86TargetMachine.cpp - Define TargetMachine for the X86 -----------===//
 // 
+//                     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 defines the X86 specific subclass of TargetMachine.
 //
 //===----------------------------------------------------------------------===//
@@ -33,12 +40,7 @@ TargetMachine *allocateX86TargetMachine(const Module &M) {
 /// X86TargetMachine ctor - Create an ILP32 architecture model
 ///
 X86TargetMachine::X86TargetMachine(const Module &M)
-  : TargetMachine("X86", 
-                 M.getEndianness() != Module::BigEndian,
-                  M.getPointerSize() != Module::Pointer64 ? 4 : 8,
-                  M.getPointerSize() != Module::Pointer64 ? 4 : 8,
-                  M.getPointerSize() != Module::Pointer64 ? 4 : 8,
-                  4, M.getPointerSize() != Module::Pointer64 ? 4 : 8),
+  : TargetMachine("X86", true, 4, 4, 4, 4, 4),
     FrameInfo(TargetFrameInfo::StackGrowsDown, 8/*16 for SSE*/, 4) {
 }
 
@@ -142,3 +144,12 @@ bool X86TargetMachine::addPassesToJITCompile(FunctionPassManager &PM) {
   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 = (int32_t) New;
+  int32_t OldAddr = (int32_t) OldWord;
+  *OldWord = NewAddr - OldAddr - 4; // Emit PC-relative addr of New code.
+}