Create the specified TargetObjInfo and use it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33291 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bill Wendling 2007-01-17 03:51:37 +00:00
parent cc91f5862c
commit 22fb30231b
5 changed files with 30 additions and 18 deletions

View File

@ -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);
}

View File

@ -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)

View File

@ -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);

View File

@ -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;

View File

@ -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);