LLVM  14.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/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(WinEH::FrameInfo *Frame) 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  if (WinEH::FrameInfo *CurFrame = getCurrentWinFrameInfo())
41  EHStreamer.EmitUnwindInfo(*this, CurFrame, /* HandlerData = */ true);
42 }
43 
44 void X86WinCOFFStreamer::EmitWindowsUnwindTables(WinEH::FrameInfo *Frame) {
45  EHStreamer.EmitUnwindInfo(*this, Frame, /* HandlerData = */ false);
46 }
47 
48 void X86WinCOFFStreamer::EmitWindowsUnwindTables() {
49  if (!getNumWinFrameInfos())
50  return;
51  EHStreamer.Emit(*this);
52 }
53 
54 void X86WinCOFFStreamer::EmitCVFPOData(const MCSymbol *ProcSym, SMLoc Loc) {
55  X86TargetStreamer *XTS =
56  static_cast<X86TargetStreamer *>(getTargetStreamer());
57  XTS->emitFPOData(ProcSym, Loc);
58 }
59 
60 void X86WinCOFFStreamer::finishImpl() {
61  emitFrames(nullptr);
62  EmitWindowsUnwindTables();
63 
65 }
66 } // namespace
67 
69  std::unique_ptr<MCAsmBackend> &&AB,
70  std::unique_ptr<MCObjectWriter> &&OW,
71  std::unique_ptr<MCCodeEmitter> &&CE,
72  bool RelaxAll,
73  bool IncrementalLinkerCompatible) {
74  X86WinCOFFStreamer *S =
75  new X86WinCOFFStreamer(C, std::move(AB), std::move(CE), std::move(OW));
76  S->getAssembler().setRelaxAll(RelaxAll);
77  S->getAssembler().setIncrementalLinkerCompatible(IncrementalLinkerCompatible);
78  return S;
79 }
80 
llvm::MCWinCOFFStreamer
Definition: MCWinCOFFStreamer.h:27
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
llvm::MCSymbol
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
llvm::MCStreamer::EmitWinEHHandlerData
virtual void EmitWinEHHandlerData(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:789
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:68
llvm::MCContext
Context object for machine code objects.
Definition: MCContext.h:72
llvm::EHStreamer
Emits exception handling directives.
Definition: EHStreamer.h:30
MCCodeEmitter.h
llvm::X86::SecondMacroFusionInstKind::AB
@ AB
llvm::MCStreamer
Streaming machine code generation interface.
Definition: MCStreamer.h:199
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::X86TargetStreamer::emitFPOData
virtual bool emitFPOData(const MCSymbol *ProcSym, SMLoc L={})=0
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::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:1658
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:364
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:838
llvm::X86TargetStreamer
X86 target streamer implementing x86-only assembly directives.
Definition: X86TargetStreamer.h:17
llvm::WinEH::FrameInfo
Definition: MCWinEH.h:39
MCWin64EH.h