X86/MC/Mach-O: Split out createX86MachObjectWriter().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122246 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2010-12-20 15:07:39 +00:00
parent ee9a2e322a
commit 9b2f25e313
4 changed files with 48 additions and 17 deletions

View File

@ -29,6 +29,7 @@ set(sources
X86ISelLowering.cpp
X86InstrInfo.cpp
X86JITInfo.cpp
X86MachObjectWriter.cpp
X86MCAsmInfo.cpp
X86MCCodeEmitter.cpp
X86MCInstLower.cpp

View File

@ -23,11 +23,13 @@ class FunctionPass;
class JITCodeEmitter;
class MCCodeEmitter;
class MCContext;
class MCObjectWriter;
class MachineCodeEmitter;
class Target;
class TargetAsmBackend;
class X86TargetMachine;
class formatted_raw_ostream;
class raw_ostream;
/// createX86ISelDag - This pass converts a legalized DAG into a
/// X86-specific DAG, ready for instruction scheduling.
@ -74,6 +76,13 @@ FunctionPass *createEmitX86CodeToMemory();
///
FunctionPass *createX86MaxStackAlignmentHeuristicPass();
/// createX86MachObjectWriter - Construct an X86 Mach-O object writer.
MCObjectWriter *createX86MachObjectWriter(raw_ostream &OS,
bool Is64Bit,
uint32_t CPUType,
uint32_t CPUSubtype);
extern Target TheX86_32Target, TheX86_64Target;
} // End llvm namespace

View File

@ -46,13 +46,6 @@ static unsigned getFixupKindLog2Size(unsigned Kind) {
}
namespace {
class X86MachObjectWriter : public MCMachObjectTargetWriter {
public:
X86MachObjectWriter(bool Is64Bit, uint32_t CPUType,
uint32_t CPUSubtype)
: MCMachObjectTargetWriter(Is64Bit, CPUType, CPUSubtype,
/*UseAggressiveSymbolFolding=*/Is64Bit) {}
};
class X86ELFObjectWriter : public MCELFObjectTargetWriter {
public:
@ -357,11 +350,9 @@ public:
: DarwinX86AsmBackend(T) {}
MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
return createMachObjectWriter(new X86MachObjectWriter(
/*Is64Bit=*/false,
object::mach::CTM_i386,
object::mach::CSX86_ALL),
OS, /*IsLittleEndian=*/true);
return createX86MachObjectWriter(OS, /*Is64Bit=*/false,
object::mach::CTM_i386,
object::mach::CSX86_ALL);
}
};
@ -373,11 +364,9 @@ public:
}
MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
return createMachObjectWriter(new X86MachObjectWriter(
/*Is64Bit=*/true,
object::mach::CTM_x86_64,
object::mach::CSX86_ALL),
OS, /*IsLittleEndian=*/true);
return createX86MachObjectWriter(OS, /*Is64Bit=*/true,
object::mach::CTM_x86_64,
object::mach::CSX86_ALL);
}
virtual bool doesSectionRequireSymbols(const MCSection &Section) const {

View File

@ -0,0 +1,32 @@
//===-- X86MachObjectWriter.cpp - X86 Mach-O Writer -----------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "X86.h"
#include "llvm/MC/MCMachObjectWriter.h"
using namespace llvm;
namespace {
class X86MachObjectWriter : public MCMachObjectTargetWriter {
public:
X86MachObjectWriter(bool Is64Bit, uint32_t CPUType,
uint32_t CPUSubtype)
: MCMachObjectTargetWriter(Is64Bit, CPUType, CPUSubtype,
/*UseAggressiveSymbolFolding=*/Is64Bit) {}
};
}
MCObjectWriter *llvm::createX86MachObjectWriter(raw_ostream &OS,
bool Is64Bit,
uint32_t CPUType,
uint32_t CPUSubtype) {
return createMachObjectWriter(new X86MachObjectWriter(Is64Bit,
CPUType,
CPUSubtype),
OS, /*IsLittleEndian=*/true);
}