MC: create X86WinCOFFStreamer for target specific behaviour

This introduces a target specific streamer, X86WinCOFFStreamer, which handles
the target specific behaviour (e.g. WinEH).  This is mostly to ensure that
differences between ARM and X86 remain disjoint and do not accidentally cross
boundaries.  This is the final staging change for enabling object emission for
Windows on ARM.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207344 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Saleem Abdulrasool 2014-04-27 03:48:12 +00:00
parent d54ec77c0d
commit 6c76c959e4
6 changed files with 63 additions and 24 deletions

View File

@ -773,14 +773,6 @@ MCStreamer *createMachOStreamer(MCContext &Ctx, MCAsmBackend &TAB,
bool RelaxAll = false,
bool LabelSections = false);
/// createWinCOFFStreamer - Create a machine code streamer which will
/// generate Microsoft COFF format object files.
///
/// Takes ownership of \p TAB and \p CE.
MCStreamer *createWinCOFFStreamer(MCContext &Ctx, MCAsmBackend &TAB,
MCCodeEmitter &CE, raw_ostream &OS,
bool RelaxAll = false);
/// createELFStreamer - Create a machine code streamer which will generate
/// ELF format object files.
MCStreamer *createELFStreamer(MCContext &Ctx, MCAsmBackend &TAB,

View File

@ -233,29 +233,15 @@ void MCWinCOFFStreamer::EmitIdent(StringRef IdentString) {
}
void MCWinCOFFStreamer::EmitWin64EHHandlerData() {
MCStreamer::EmitWin64EHHandlerData();
// We have to emit the unwind info now, because this directive
// actually switches to the .xdata section!
MCWin64EHUnwindEmitter::EmitUnwindInfo(*this, getCurrentW64UnwindInfo());
llvm_unreachable("not implemented");
}
void MCWinCOFFStreamer::FinishImpl() {
EmitFrames(nullptr, true);
EmitW64Tables();
MCObjectStreamer::FinishImpl();
}
MCSymbolData &MCWinCOFFStreamer::getOrCreateSymbolData(const MCSymbol *Symbol) {
return getAssembler().getOrCreateSymbolData(*Symbol);
}
MCStreamer *createWinCOFFStreamer(MCContext &Context, MCAsmBackend &MAB,
MCCodeEmitter &CE, raw_ostream &OS,
bool RelaxAll) {
MCWinCOFFStreamer *S = new MCWinCOFFStreamer(Context, MAB, CE, OS);
S->getAssembler().setRelaxAll(RelaxAll);
return S;
}
}

View File

@ -5,6 +5,7 @@ add_llvm_library(LLVMX86Desc
X86MCCodeEmitter.cpp
X86MachObjectWriter.cpp
X86ELFObjectWriter.cpp
X86WinCOFFStreamer.cpp
X86WinCOFFObjectWriter.cpp
X86MachORelocationInfo.cpp
X86ELFRelocationInfo.cpp

View File

@ -364,7 +364,7 @@ static MCStreamer *createMCStreamer(const Target &T, StringRef TT,
return createMachOStreamer(Ctx, MAB, _OS, _Emitter, RelaxAll);
case Triple::COFF:
assert(TheTriple.isOSWindows() && "only Windows COFF is supported");
return createWinCOFFStreamer(Ctx, MAB, *_Emitter, _OS, RelaxAll);
return createX86WinCOFFStreamer(Ctx, MAB, _Emitter, _OS, RelaxAll);
case Triple::ELF:
return createELFStreamer(Ctx, MAB, _OS, _Emitter, RelaxAll, NoExecStack);
}

View File

@ -26,6 +26,7 @@ class MCObjectWriter;
class MCRegisterInfo;
class MCSubtargetInfo;
class MCRelocationInfo;
class MCStreamer;
class Target;
class StringRef;
class raw_ostream;
@ -84,6 +85,14 @@ MCAsmBackend *createX86_32AsmBackend(const Target &T, const MCRegisterInfo &MRI,
MCAsmBackend *createX86_64AsmBackend(const Target &T, const MCRegisterInfo &MRI,
StringRef TT, StringRef CPU);
/// createX86WinCOFFStreamer - Construct an X86 Windows COFF machine code
/// streamer which will generate PE/COFF format object files.
///
/// Takes ownership of \p AB and \p CE.
MCStreamer *createX86WinCOFFStreamer(MCContext &C, MCAsmBackend &AB,
MCCodeEmitter *CE, raw_ostream &OS,
bool RelaxAll);
/// createX86MachObjectWriter - Construct an X86 Mach-O object writer.
MCObjectWriter *createX86MachObjectWriter(raw_ostream &OS,
bool Is64Bit,

View File

@ -0,0 +1,51 @@
//===-- X86WinCOFFStreamer.cpp - X86 Target WinCOFF Streamer ----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "X86MCTargetDesc.h"
#include "llvm/MC/MCWinCOFFStreamer.h"
using namespace llvm;
namespace {
class X86WinCOFFStreamer : public MCWinCOFFStreamer {
public:
X86WinCOFFStreamer(MCContext &C, MCAsmBackend &AB, MCCodeEmitter *CE,
raw_ostream &OS)
: MCWinCOFFStreamer(C, AB, *CE, OS) { }
void EmitWin64EHHandlerData() override;
void FinishImpl() override;
};
void X86WinCOFFStreamer::EmitWin64EHHandlerData() {
MCStreamer::EmitWin64EHHandlerData();
// We have to emit the unwind info now, because this directive
// actually switches to the .xdata section!
MCWin64EHUnwindEmitter::EmitUnwindInfo(*this, getCurrentW64UnwindInfo());
}
void X86WinCOFFStreamer::FinishImpl() {
EmitFrames(nullptr, true);
EmitW64Tables();
MCWinCOFFStreamer::FinishImpl();
}
}
namespace llvm {
MCStreamer *createX86WinCOFFStreamer(MCContext &C, MCAsmBackend &AB,
MCCodeEmitter *CE, raw_ostream &OS,
bool RelaxAll) {
X86WinCOFFStreamer *S = new X86WinCOFFStreamer(C, AB, CE, OS);
S->getAssembler().setRelaxAll(RelaxAll);
return S;
}
}