LLVM  8.0.1
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/MCObjectWriter.h"
15 #include "llvm/MC/MCWin64EH.h"
17 
18 using namespace llvm;
19 
20 namespace {
21 class X86WinCOFFStreamer : public MCWinCOFFStreamer {
23 public:
24  X86WinCOFFStreamer(MCContext &C, std::unique_ptr<MCAsmBackend> AB,
25  std::unique_ptr<MCCodeEmitter> CE,
26  std::unique_ptr<MCObjectWriter> OW)
27  : MCWinCOFFStreamer(C, std::move(AB), std::move(CE), std::move(OW)) {}
28 
29  void EmitWinEHHandlerData(SMLoc Loc) override;
30  void EmitWindowsUnwindTables() override;
31  void EmitCVFPOData(const MCSymbol *ProcSym, SMLoc Loc) override;
32  void FinishImpl() override;
33 };
34 
35 void X86WinCOFFStreamer::EmitWinEHHandlerData(SMLoc Loc) {
37 
38  // We have to emit the unwind info now, because this directive
39  // actually switches to the .xdata section!
40  EHStreamer.EmitUnwindInfo(*this, getCurrentWinFrameInfo());
41 }
42 
43 void X86WinCOFFStreamer::EmitWindowsUnwindTables() {
44  if (!getNumWinFrameInfos())
45  return;
46  EHStreamer.Emit(*this);
47 }
48 
49 void X86WinCOFFStreamer::EmitCVFPOData(const MCSymbol *ProcSym, SMLoc Loc) {
50  X86TargetStreamer *XTS =
51  static_cast<X86TargetStreamer *>(getTargetStreamer());
52  XTS->emitFPOData(ProcSym, Loc);
53 }
54 
55 void X86WinCOFFStreamer::FinishImpl() {
56  EmitFrames(nullptr);
57  EmitWindowsUnwindTables();
58 
60 }
61 }
62 
64  std::unique_ptr<MCAsmBackend> &&AB,
65  std::unique_ptr<MCObjectWriter> &&OW,
66  std::unique_ptr<MCCodeEmitter> &&CE,
67  bool RelaxAll,
68  bool IncrementalLinkerCompatible) {
69  X86WinCOFFStreamer *S =
70  new X86WinCOFFStreamer(C, std::move(AB), std::move(CE), std::move(OW));
71  S->getAssembler().setRelaxAll(RelaxAll);
72  S->getAssembler().setIncrementalLinkerCompatible(IncrementalLinkerCompatible);
73  return S;
74 }
75 
uint64_t CallInst * C
void FinishImpl() override
Streamer specific finalization.
This class represents lattice values for constants.
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:938
Emits exception handling directives.
Definition: EHStreamer.h:31
Context object for machine code objects.
Definition: MCContext.h:63
Streaming machine code generation interface.
Definition: MCStreamer.h:189
virtual bool emitFPOData(const MCSymbol *ProcSym, SMLoc L={})=0
MCStreamer * createX86WinCOFFStreamer(MCContext &C, std::unique_ptr< MCAsmBackend > &&AB, std::unique_ptr< MCObjectWriter > &&OW, 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...
virtual void EmitWinEHHandlerData(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:701
X86 target streamer implementing x86-only assembly directives.
Represents a location in source code.
Definition: SMLoc.h:24