LLVM  6.0.0svn
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 "X86TargetStreamer.h"
12 #include "llvm/MC/MCAsmBackend.h"
13 #include "llvm/MC/MCCodeEmitter.h"
14 #include "llvm/MC/MCWin64EH.h"
16 
17 using namespace llvm;
18 
19 namespace {
20 class X86WinCOFFStreamer : public MCWinCOFFStreamer {
22 public:
23  X86WinCOFFStreamer(MCContext &C, std::unique_ptr<MCAsmBackend> AB,
24  std::unique_ptr<MCCodeEmitter> CE, raw_pwrite_stream &OS)
25  : MCWinCOFFStreamer(C, std::move(AB), std::move(CE), OS) {}
26 
27  void EmitWinEHHandlerData(SMLoc Loc) override;
28  void EmitWindowsUnwindTables() override;
29  void EmitCVFPOData(const MCSymbol *ProcSym, SMLoc Loc) override;
30  void FinishImpl() override;
31 };
32 
33 void X86WinCOFFStreamer::EmitWinEHHandlerData(SMLoc Loc) {
35 
36  // We have to emit the unwind info now, because this directive
37  // actually switches to the .xdata section!
38  EHStreamer.EmitUnwindInfo(*this, getCurrentWinFrameInfo());
39 }
40 
41 void X86WinCOFFStreamer::EmitWindowsUnwindTables() {
42  if (!getNumWinFrameInfos())
43  return;
44  EHStreamer.Emit(*this);
45 }
46 
47 void X86WinCOFFStreamer::EmitCVFPOData(const MCSymbol *ProcSym, SMLoc Loc) {
48  X86TargetStreamer *XTS =
49  static_cast<X86TargetStreamer *>(getTargetStreamer());
50  XTS->emitFPOData(ProcSym, Loc);
51 }
52 
53 void X86WinCOFFStreamer::FinishImpl() {
54  EmitFrames(nullptr);
55  EmitWindowsUnwindTables();
56 
58 }
59 }
60 
62  std::unique_ptr<MCAsmBackend> &&AB,
64  std::unique_ptr<MCCodeEmitter> &&CE,
65  bool RelaxAll,
66  bool IncrementalLinkerCompatible) {
67  X86WinCOFFStreamer *S =
68  new X86WinCOFFStreamer(C, std::move(AB), std::move(CE), OS);
69  S->getAssembler().setRelaxAll(RelaxAll);
70  S->getAssembler().setIncrementalLinkerCompatible(IncrementalLinkerCompatible);
71  return S;
72 }
73 
uint64_t CallInst * C
void FinishImpl() override
Streamer specific finalization.
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:42
Definition: BitVector.h:920
Emits exception handling directives.
Definition: EHStreamer.h:31
MCStreamer * createX86WinCOFFStreamer(MCContext &C, std::unique_ptr< MCAsmBackend > &&AB, raw_pwrite_stream &OS, std::unique_ptr< MCCodeEmitter > &&CE, bool RelaxAll, bool IncrementalLinkerCompatible)
Construct an X86 Windows COFF machine code streamer which will generate PE/COFF format object files...
Context object for machine code objects.
Definition: MCContext.h:59
Streaming machine code generation interface.
Definition: MCStreamer.h:169
virtual bool emitFPOData(const MCSymbol *ProcSym, SMLoc L={})=0
virtual void EmitWinEHHandlerData(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:634
X86 target streamer implementing x86-only assembly directives.
An abstract base class for streams implementations that also support a pwrite operation.
Definition: raw_ostream.h:337
Represents a location in source code.
Definition: SMLoc.h:24