LLVM 19.0.0git
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"
12#include "llvm/MC/MCAssembler.h"
15#include "llvm/MC/MCWin64EH.h"
17
18using namespace llvm;
19
20namespace {
21class X86WinCOFFStreamer : public MCWinCOFFStreamer {
23public:
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(WinEH::FrameInfo *Frame) override;
31 void emitWindowsUnwindTables() override;
32 void emitCVFPOData(const MCSymbol *ProcSym, SMLoc Loc) override;
33 void finishImpl() override;
34};
35
36void X86WinCOFFStreamer::emitWinEHHandlerData(SMLoc Loc) {
38
39 // We have to emit the unwind info now, because this directive
40 // actually switches to the .xdata section.
41 if (WinEH::FrameInfo *CurFrame = getCurrentWinFrameInfo())
42 EHStreamer.EmitUnwindInfo(*this, CurFrame, /* HandlerData = */ true);
43}
44
45void X86WinCOFFStreamer::emitWindowsUnwindTables(WinEH::FrameInfo *Frame) {
46 EHStreamer.EmitUnwindInfo(*this, Frame, /* HandlerData = */ false);
47}
48
49void X86WinCOFFStreamer::emitWindowsUnwindTables() {
50 if (!getNumWinFrameInfos())
51 return;
52 EHStreamer.Emit(*this);
53}
54
55void X86WinCOFFStreamer::emitCVFPOData(const MCSymbol *ProcSym, SMLoc Loc) {
57 static_cast<X86TargetStreamer *>(getTargetStreamer());
58 XTS->emitFPOData(ProcSym, Loc);
59}
60
61void X86WinCOFFStreamer::finishImpl() {
62 emitFrames(nullptr);
63 emitWindowsUnwindTables();
64
66}
67} // namespace
68
70 std::unique_ptr<MCAsmBackend> &&AB,
71 std::unique_ptr<MCObjectWriter> &&OW,
72 std::unique_ptr<MCCodeEmitter> &&CE,
73 bool RelaxAll,
74 bool IncrementalLinkerCompatible) {
75 X86WinCOFFStreamer *S =
76 new X86WinCOFFStreamer(C, std::move(AB), std::move(CE), std::move(OW));
77 S->getAssembler().setRelaxAll(RelaxAll);
78 S->getAssembler().setIncrementalLinkerCompatible(IncrementalLinkerCompatible);
79 return S;
80}
81
Emits exception handling directives.
Definition: EHStreamer.h:30
Context object for machine code objects.
Definition: MCContext.h:81
Streaming machine code generation interface.
Definition: MCStreamer.h:212
virtual void emitWindowsUnwindTables()
virtual void emitWinEHHandlerData(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:808
virtual void emitCVFPOData(const MCSymbol *ProcSym, SMLoc Loc={})
This implements the CodeView '.cv_fpo_data' assembler directive.
Definition: MCStreamer.h:1018
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:40
void finishImpl() override
Streamer specific finalization.
void emitWinEHHandlerData(SMLoc Loc) override
Represents a location in source code.
Definition: SMLoc.h:23
X86 target streamer implementing x86-only assembly directives.
virtual bool emitFPOData(const MCSymbol *ProcSym, SMLoc L={})
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
@ CE
Windows NT (Windows on ARM)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
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.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1849
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858