diff options
author | Saleem Abdulrasool <compnerd@compnerd.org> | 2014-04-27 03:48:12 +0000 |
---|---|---|
committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2014-04-27 03:48:12 +0000 |
commit | 6c76c959e405c72574b7e0498ddcaee3e532ca15 (patch) | |
tree | 3ca34bf988b489c2c4981c746496b88b5fce85e0 /lib | |
parent | d54ec77c0d1182ac12df371b0938020bb1676d65 (diff) | |
download | llvm-6c76c959e405c72574b7e0498ddcaee3e532ca15.tar.gz llvm-6c76c959e405c72574b7e0498ddcaee3e532ca15.tar.bz2 llvm-6c76c959e405c72574b7e0498ddcaee3e532ca15.tar.xz |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/MC/WinCOFFStreamer.cpp | 16 | ||||
-rw-r--r-- | lib/Target/X86/MCTargetDesc/CMakeLists.txt | 1 | ||||
-rw-r--r-- | lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp | 2 | ||||
-rw-r--r-- | lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h | 9 | ||||
-rw-r--r-- | lib/Target/X86/MCTargetDesc/X86WinCOFFStreamer.cpp | 51 |
5 files changed, 63 insertions, 16 deletions
diff --git a/lib/MC/WinCOFFStreamer.cpp b/lib/MC/WinCOFFStreamer.cpp index 2d8ca7eb37..ec81dff0c3 100644 --- a/lib/MC/WinCOFFStreamer.cpp +++ b/lib/MC/WinCOFFStreamer.cpp @@ -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; -} } diff --git a/lib/Target/X86/MCTargetDesc/CMakeLists.txt b/lib/Target/X86/MCTargetDesc/CMakeLists.txt index 3f5a0e2baf..129c28d804 100644 --- a/lib/Target/X86/MCTargetDesc/CMakeLists.txt +++ b/lib/Target/X86/MCTargetDesc/CMakeLists.txt @@ -5,6 +5,7 @@ add_llvm_library(LLVMX86Desc X86MCCodeEmitter.cpp X86MachObjectWriter.cpp X86ELFObjectWriter.cpp + X86WinCOFFStreamer.cpp X86WinCOFFObjectWriter.cpp X86MachORelocationInfo.cpp X86ELFRelocationInfo.cpp diff --git a/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp b/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp index fdc234d211..e63036c1a5 100644 --- a/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp +++ b/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp @@ -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); } diff --git a/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h b/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h index 41ae4354cb..8fe40fd236 100644 --- a/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h +++ b/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h @@ -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, diff --git a/lib/Target/X86/MCTargetDesc/X86WinCOFFStreamer.cpp b/lib/Target/X86/MCTargetDesc/X86WinCOFFStreamer.cpp new file mode 100644 index 0000000000..526868487a --- /dev/null +++ b/lib/Target/X86/MCTargetDesc/X86WinCOFFStreamer.cpp @@ -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; +} +} + |