LLVM  9.0.0svn
X86WinCOFFStreamer.cpp
Go to the documentation of this file.
1 //===-- X86WinCOFFStreamer.cpp - X86 Target WinCOFF Streamer ----*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "X86MCTargetDesc.h"
10 #include "X86TargetStreamer.h"
11 #include "llvm/MC/MCAsmBackend.h"
12 #include "llvm/MC/MCCodeEmitter.h"
13 #include "llvm/MC/MCObjectWriter.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,
25  std::unique_ptr<MCObjectWriter> OW)
26  : MCWinCOFFStreamer(C, std::move(AB), std::move(CE), std::move(OW)) {}
27 
28  void EmitWinEHHandlerData(SMLoc Loc) override;
29  void EmitWindowsUnwindTables() override;
30  void EmitCVFPOData(const MCSymbol *ProcSym, SMLoc Loc) override;
31  void FinishImpl() override;
32 };
33 
34 void X86WinCOFFStreamer::EmitWinEHHandlerData(SMLoc Loc) {
36 
37  // We have to emit the unwind info now, because this directive
38  // actually switches to the .xdata section!
39  EHStreamer.EmitUnwindInfo(*this, getCurrentWinFrameInfo());
40 }
41 
42 void X86WinCOFFStreamer::EmitWindowsUnwindTables() {
43  if (!getNumWinFrameInfos())
44  return;
45  EHStreamer.Emit(*this);
46 }
47 
48 void X86WinCOFFStreamer::EmitCVFPOData(const MCSymbol *ProcSym, SMLoc Loc) {
49  X86TargetStreamer *XTS =
50  static_cast<X86TargetStreamer *>(getTargetStreamer());
51  XTS->emitFPOData(ProcSym, Loc);
52 }
53 
54 void X86WinCOFFStreamer::FinishImpl() {
55  EmitFrames(nullptr);
56  EmitWindowsUnwindTables();
57 
59 }
60 }
61 
63  std::unique_ptr<MCAsmBackend> &&AB,
64  std::unique_ptr<MCObjectWriter> &&OW,
65  std::unique_ptr<MCCodeEmitter> &&CE,
66  bool RelaxAll,
67  bool IncrementalLinkerCompatible) {
68  X86WinCOFFStreamer *S =
69  new X86WinCOFFStreamer(C, std::move(AB), std::move(CE), std::move(OW));
70  S->getAssembler().setRelaxAll(RelaxAll);
71  S->getAssembler().setIncrementalLinkerCompatible(IncrementalLinkerCompatible);
72  return S;
73 }
74 
uint64_t CallInst * C
void FinishImpl() override
Streamer specific finalization.
This class represents lattice values for constants.
Definition: AllocatorList.h:23
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
Definition: BitVector.h:937
Emits exception handling directives.
Definition: EHStreamer.h:30
Context object for machine code objects.
Definition: MCContext.h:62
Streaming machine code generation interface.
Definition: MCStreamer.h:188
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:700
X86 target streamer implementing x86-only assembly directives.
Represents a location in source code.
Definition: SMLoc.h:23