LLVM  4.0.0
X86WinCOFFStreamer.cpp
Go to the documentation of this file.
1 //===-- X86WinCOFFStreamer.cpp - X86 Target WinCOFF Streamer ----*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "X86MCTargetDesc.h"
11 #include "llvm/MC/MCWin64EH.h"
13 
14 using namespace llvm;
15 
16 namespace {
17 class X86WinCOFFStreamer : public MCWinCOFFStreamer {
19 public:
20  X86WinCOFFStreamer(MCContext &C, MCAsmBackend &AB, MCCodeEmitter *CE,
22  : MCWinCOFFStreamer(C, AB, *CE, OS) {}
23 
24  void EmitWinEHHandlerData() override;
25  void EmitWindowsUnwindTables() override;
26  void FinishImpl() override;
27 };
28 
29 void X86WinCOFFStreamer::EmitWinEHHandlerData() {
31 
32  // We have to emit the unwind info now, because this directive
33  // actually switches to the .xdata section!
34  EHStreamer.EmitUnwindInfo(*this, getCurrentWinFrameInfo());
35 }
36 
37 void X86WinCOFFStreamer::EmitWindowsUnwindTables() {
38  if (!getNumWinFrameInfos())
39  return;
40  EHStreamer.Emit(*this);
41 }
42 
43 void X86WinCOFFStreamer::FinishImpl() {
44  EmitFrames(nullptr);
45  EmitWindowsUnwindTables();
46 
48 }
49 }
50 
53  MCCodeEmitter *CE, bool RelaxAll,
55  X86WinCOFFStreamer *S = new X86WinCOFFStreamer(C, AB, CE, OS);
56  S->getAssembler().setRelaxAll(RelaxAll);
57  S->getAssembler().setIncrementalLinkerCompatible(IncrementalLinkerCompatible);
58  return S;
59 }
60 
MCStreamer * createX86WinCOFFStreamer(MCContext &C, MCAsmBackend &AB, raw_pwrite_stream &OS, MCCodeEmitter *CE, bool RelaxAll, bool IncrementalLinkerCompatible)
Construct an X86 Windows COFF machine code streamer which will generate PE/COFF format object files...
virtual void EmitWinEHHandlerData()
Definition: MCStreamer.cpp:564
Emits exception handling directives.
Definition: EHStreamer.h:32
Context object for machine code objects.
Definition: MCContext.h:51
Streaming machine code generation interface.
Definition: MCStreamer.h:161
MCCodeEmitter - Generic instruction encoding interface.
Definition: MCCodeEmitter.h:23
cl::opt< bool > IncrementalLinkerCompatible("incremental-linker-compatible", cl::desc("When used with filetype=obj, ""emit an object file which can be used with an incremental linker"))
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
An abstract base class for streams implementations that also support a pwrite operation.
Definition: raw_ostream.h:333
cl::opt< bool > RelaxAll("mc-relax-all", cl::desc("When used with filetype=obj, ""relax all fixups in the emitted object file"))
Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:36
void FinishImpl() override
Streamer specific finalization.