LLVM  16.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"
11 #include "llvm/MC/MCAsmBackend.h"
12 #include "llvm/MC/MCAssembler.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(WinEH::FrameInfo *Frame) override;
31  void emitWindowsUnwindTables() override;
32  void emitCVFPOData(const MCSymbol *ProcSym, SMLoc Loc) override;
33  void finishImpl() override;
34 };
35 
36 void 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 
45 void X86WinCOFFStreamer::emitWindowsUnwindTables(WinEH::FrameInfo *Frame) {
46  EHStreamer.EmitUnwindInfo(*this, Frame, /* HandlerData = */ false);
47 }
48 
49 void X86WinCOFFStreamer::emitWindowsUnwindTables() {
50  if (!getNumWinFrameInfos())
51  return;
52  EHStreamer.Emit(*this);
53 }
54 
55 void X86WinCOFFStreamer::emitCVFPOData(const MCSymbol *ProcSym, SMLoc Loc) {
56  X86TargetStreamer *XTS =
57  static_cast<X86TargetStreamer *>(getTargetStreamer());
58  XTS->emitFPOData(ProcSym, Loc);
59 }
60 
61 void 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 
llvm::MCWinCOFFStreamer
Definition: MCWinCOFFStreamer.h:27
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::MCSymbol
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
llvm::createX86WinCOFFStreamer
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.
Definition: X86WinCOFFStreamer.cpp:69
llvm::MCContext
Context object for machine code objects.
Definition: MCContext.h:76
llvm::EHStreamer
Emits exception handling directives.
Definition: EHStreamer.h:30
MCCodeEmitter.h
llvm::X86::SecondMacroFusionInstKind::AB
@ AB
MCAssembler.h
llvm::MCStreamer
Streaming machine code generation interface.
Definition: MCStreamer.h:212
MCAsmBackend.h
llvm::SMLoc
Represents a location in source code.
Definition: SMLoc.h:23
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::MCStreamer::emitWinEHHandlerData
virtual void emitWinEHHandlerData(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:800
X86MCTargetDesc.h
X86TargetStreamer.h
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::X86TargetStreamer::emitFPOData
virtual bool emitFPOData(const MCSymbol *ProcSym, SMLoc L={})
Definition: X86TargetStreamer.h:27
llvm::move
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:1836
llvm::WinEH::EncodingType::CE
@ CE
Windows NT (Windows on ARM)
llvm::Win64EH::UnwindEmitter
Definition: MCWin64EH.h:53
llvm::MCWinCOFFStreamer::finishImpl
void finishImpl() override
Streamer specific finalization.
Definition: MCWinCOFFStreamer.cpp:361
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
MCWinCOFFStreamer.h
MCObjectWriter.h
std
Definition: BitVector.h:851
llvm::X86TargetStreamer
X86 target streamer implementing x86-only assembly directives.
Definition: X86TargetStreamer.h:17
llvm::WinEH::FrameInfo
Definition: MCWinEH.h:39
MCWin64EH.h