diff --git a/lib/Target/PowerPC/PPCMachOWriter.cpp b/lib/Target/PowerPC/PPCMachOWriter.cpp index ccf2e97a732..d79aa48d362 100644 --- a/lib/Target/PowerPC/PPCMachOWriter.cpp +++ b/lib/Target/PowerPC/PPCMachOWriter.cpp @@ -2,8 +2,8 @@ // // The LLVM Compiler Infrastructure // -// This file was developed by Nate Begeman and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. +// This file was developed by Nate Begeman and is distributed under the +// University of Illinois Open Source License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // @@ -17,6 +17,7 @@ #include "llvm/PassManager.h" #include "llvm/CodeGen/MachOWriter.h" #include "llvm/Support/Compiler.h" +#include "llvm/Target/TargetObjInfo.h" using namespace llvm; namespace { @@ -91,10 +92,10 @@ void PPCMachOWriter::GetTargetRelocation(MachineRelocation &MR, MachORelocation VANILLA(MR.getMachineCodeOffset(), To.Index, false, 2, isExtern, PPC_RELOC_VANILLA); ++From.nreloc; - outword(From.RelocBuffer, VANILLA.r_address); - outword(From.RelocBuffer, VANILLA.getPackedFields()); + TOI->outword(From.RelocBuffer, VANILLA.r_address); + TOI->outword(From.RelocBuffer, VANILLA.getPackedFields()); } - fixword(From.SectionData, Addr, MR.getMachineCodeOffset()); + TOI->fixword(From.SectionData, Addr, MR.getMachineCodeOffset()); break; case PPC::reloc_pcrel_bx: Addr -= MR.getMachineCodeOffset(); @@ -102,12 +103,12 @@ void PPCMachOWriter::GetTargetRelocation(MachineRelocation &MR, Addr &= 0xFFFFFF; Addr <<= 2; Addr |= (From.SectionData[MR.getMachineCodeOffset()] << 24); - fixword(From.SectionData, Addr, MR.getMachineCodeOffset()); + TOI->fixword(From.SectionData, Addr, MR.getMachineCodeOffset()); break; case PPC::reloc_pcrel_bcx: Addr -= MR.getMachineCodeOffset(); Addr &= 0xFFFC; - fixhalf(From.SectionData, Addr, MR.getMachineCodeOffset() + 2); + TOI->fixhalf(From.SectionData, Addr, MR.getMachineCodeOffset() + 2); break; case PPC::reloc_absolute_high: { @@ -117,14 +118,14 @@ void PPCMachOWriter::GetTargetRelocation(MachineRelocation &MR, PPC_RELOC_PAIR); ++From.nreloc; ++From.nreloc; - outword(From.RelocBuffer, HA16.r_address); - outword(From.RelocBuffer, HA16.getPackedFields()); - outword(From.RelocBuffer, PAIR.r_address); - outword(From.RelocBuffer, PAIR.getPackedFields()); + TOI->outword(From.RelocBuffer, HA16.r_address); + TOI->outword(From.RelocBuffer, HA16.getPackedFields()); + TOI->outword(From.RelocBuffer, PAIR.r_address); + TOI->outword(From.RelocBuffer, PAIR.getPackedFields()); } printf("ha16: %x\n", (unsigned)Addr); Addr += 0x8000; - fixhalf(From.SectionData, Addr >> 16, MR.getMachineCodeOffset() + 2); + TOI->fixhalf(From.SectionData, Addr >> 16, MR.getMachineCodeOffset() + 2); break; case PPC::reloc_absolute_low: { @@ -134,13 +135,13 @@ void PPCMachOWriter::GetTargetRelocation(MachineRelocation &MR, PPC_RELOC_PAIR); ++From.nreloc; ++From.nreloc; - outword(From.RelocBuffer, LO16.r_address); - outword(From.RelocBuffer, LO16.getPackedFields()); - outword(From.RelocBuffer, PAIR.r_address); - outword(From.RelocBuffer, PAIR.getPackedFields()); + TOI->outword(From.RelocBuffer, LO16.r_address); + TOI->outword(From.RelocBuffer, LO16.getPackedFields()); + TOI->outword(From.RelocBuffer, PAIR.r_address); + TOI->outword(From.RelocBuffer, PAIR.getPackedFields()); } printf("lo16: %x\n", (unsigned)Addr); - fixhalf(From.SectionData, Addr, MR.getMachineCodeOffset() + 2); + TOI->fixhalf(From.SectionData, Addr, MR.getMachineCodeOffset() + 2); break; } } @@ -150,4 +151,3 @@ MachineRelocation PPCMachOWriter::GetJTRelocation(unsigned Offset, // FIXME: do something about PIC return MachineRelocation::getBB(Offset, PPC::reloc_vanilla, MBB); } - diff --git a/lib/Target/PowerPC/PPCTargetMachine.cpp b/lib/Target/PowerPC/PPCTargetMachine.cpp index 11f334725e1..97b7983b16e 100644 --- a/lib/Target/PowerPC/PPCTargetMachine.cpp +++ b/lib/Target/PowerPC/PPCTargetMachine.cpp @@ -13,6 +13,7 @@ #include "PPC.h" #include "PPCTargetAsmInfo.h" +#include "PPCTargetObjInfo.h" #include "PPCTargetMachine.h" #include "llvm/Module.h" #include "llvm/PassManager.h" @@ -34,6 +35,10 @@ const TargetAsmInfo *PPCTargetMachine::createTargetAsmInfo() const { return new LinuxTargetAsmInfo(*this); } +const TargetObjInfo *PPCTargetMachine::createTargetObjInfo() const { + return new MachOTargetObjInfo(*this); +} + unsigned PPC32TargetMachine::getJITMatchQuality() { #if defined(__POWERPC__) || defined (__ppc__) || defined(_POWER) if (sizeof(void*) == 4) diff --git a/lib/Target/PowerPC/PPCTargetMachine.h b/lib/Target/PowerPC/PPCTargetMachine.h index 777772e1fae..b56892df028 100644 --- a/lib/Target/PowerPC/PPCTargetMachine.h +++ b/lib/Target/PowerPC/PPCTargetMachine.h @@ -39,6 +39,7 @@ class PPCTargetMachine : public LLVMTargetMachine { protected: virtual const TargetAsmInfo *createTargetAsmInfo() const; + virtual const TargetObjInfo *createTargetObjInfo() const; public: PPCTargetMachine(const Module &M, const std::string &FS, bool is64Bit); diff --git a/lib/Target/X86/X86TargetMachine.cpp b/lib/Target/X86/X86TargetMachine.cpp index 8bcda9a290b..194a6778154 100644 --- a/lib/Target/X86/X86TargetMachine.cpp +++ b/lib/Target/X86/X86TargetMachine.cpp @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "X86TargetAsmInfo.h" +#include "X86TargetObjInfo.h" #include "X86TargetMachine.h" #include "X86.h" #include "llvm/Module.h" @@ -42,6 +43,10 @@ const TargetAsmInfo *X86TargetMachine::createTargetAsmInfo() const { return new X86TargetAsmInfo(*this); } +const TargetObjInfo *X86TargetMachine::createTargetObjInfo() const { + return new ELFTargetObjInfo(*this); +} + unsigned X86_32TargetMachine::getJITMatchQuality() { #if defined(i386) || defined(__i386__) || defined(__x86__) || defined(_M_IX86) return 10; diff --git a/lib/Target/X86/X86TargetMachine.h b/lib/Target/X86/X86TargetMachine.h index 05cb9484d63..64ddab561c4 100644 --- a/lib/Target/X86/X86TargetMachine.h +++ b/lib/Target/X86/X86TargetMachine.h @@ -35,6 +35,7 @@ class X86TargetMachine : public LLVMTargetMachine { protected: virtual const TargetAsmInfo *createTargetAsmInfo() const; + virtual const TargetObjInfo *createTargetObjInfo() const; public: X86TargetMachine(const Module &M, const std::string &FS, bool is64Bit);