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 emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override;
30 void emitWinEHHandlerData(SMLoc Loc) override;
31 void emitWindowsUnwindTables(WinEH::FrameInfo *Frame) override;
32 void emitWindowsUnwindTables() override;
33 void emitCVFPOData(const MCSymbol *ProcSym, SMLoc Loc) override;
34 void finishImpl() override;
35};
36
37void X86WinCOFFStreamer::emitInstruction(const MCInst &Inst,
38 const MCSubtargetInfo &STI) {
39 X86_MC::emitInstruction(*this, Inst, STI);
40}
41
42void X86WinCOFFStreamer::emitWinEHHandlerData(SMLoc Loc) {
44
45 // We have to emit the unwind info now, because this directive
46 // actually switches to the .xdata section.
47 if (WinEH::FrameInfo *CurFrame = getCurrentWinFrameInfo())
48 EHStreamer.EmitUnwindInfo(*this, CurFrame, /* HandlerData = */ true);
49}
50
51void X86WinCOFFStreamer::emitWindowsUnwindTables(WinEH::FrameInfo *Frame) {
52 EHStreamer.EmitUnwindInfo(*this, Frame, /* HandlerData = */ false);
53}
54
55void X86WinCOFFStreamer::emitWindowsUnwindTables() {
56 if (!getNumWinFrameInfos())
57 return;
58 EHStreamer.Emit(*this);
59}
60
61void X86WinCOFFStreamer::emitCVFPOData(const MCSymbol *ProcSym, SMLoc Loc) {
63 static_cast<X86TargetStreamer *>(getTargetStreamer());
64 XTS->emitFPOData(ProcSym, Loc);
65}
66
67void X86WinCOFFStreamer::finishImpl() {
68 emitFrames(nullptr);
69 emitWindowsUnwindTables();
70
72}
73} // namespace
74
76 std::unique_ptr<MCAsmBackend> &&AB,
77 std::unique_ptr<MCObjectWriter> &&OW,
78 std::unique_ptr<MCCodeEmitter> &&CE,
79 bool IncrementalLinkerCompatible) {
80 X86WinCOFFStreamer *S =
81 new X86WinCOFFStreamer(C, std::move(AB), std::move(CE), std::move(OW));
82 S->getAssembler().setIncrementalLinkerCompatible(IncrementalLinkerCompatible);
83 return S;
84}
85
Emits exception handling directives.
Definition: EHStreamer.h:30
Context object for machine code objects.
Definition: MCContext.h:83
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:184
void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override
Emit the given Instruction into the current section.
Streaming machine code generation interface.
Definition: MCStreamer.h:213
virtual void emitWindowsUnwindTables()
virtual void emitWinEHHandlerData(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:805
virtual void emitCVFPOData(const MCSymbol *ProcSym, SMLoc Loc={})
This implements the CodeView '.cv_fpo_data' assembler directive.
Definition: MCStreamer.h:983
Generic base class for all target subtargets.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
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)
void emitInstruction(MCObjectStreamer &, const MCInst &Inst, const MCSubtargetInfo &STI)
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 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