LLVM  10.0.0svn
MCWinEH.h
Go to the documentation of this file.
1 //===- MCWinEH.h - Windows Unwinding Support --------------------*- 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 #ifndef LLVM_MC_MCWINEH_H
10 #define LLVM_MC_MCWINEH_H
11 
12 #include "llvm/ADT/MapVector.h"
13 #include <vector>
14 
15 namespace llvm {
16 class MCSection;
17 class MCStreamer;
18 class MCSymbol;
19 
20 namespace WinEH {
21 struct Instruction {
22  const MCSymbol *Label;
23  unsigned Offset;
24  unsigned Register;
25  unsigned Operation;
26 
27  Instruction(unsigned Op, MCSymbol *L, unsigned Reg, unsigned Off)
28  : Label(L), Offset(Off), Register(Reg), Operation(Op) {}
29 };
30 
31 struct FrameInfo {
32  const MCSymbol *Begin = nullptr;
33  const MCSymbol *End = nullptr;
34  const MCSymbol *FuncletOrFuncEnd = nullptr;
35  const MCSymbol *ExceptionHandler = nullptr;
36  const MCSymbol *Function = nullptr;
37  const MCSymbol *PrologEnd = nullptr;
38  const MCSymbol *Symbol = nullptr;
39  const MCSection *TextSection = nullptr;
40 
41  bool HandlesUnwind = false;
42  bool HandlesExceptions = false;
43 
44  int LastFrameInst = -1;
45  const FrameInfo *ChainedParent = nullptr;
46  std::vector<Instruction> Instructions;
48 
49  FrameInfo() = default;
50  FrameInfo(const MCSymbol *Function, const MCSymbol *BeginFuncEHLabel)
51  : Begin(BeginFuncEHLabel), Function(Function) {}
52  FrameInfo(const MCSymbol *Function, const MCSymbol *BeginFuncEHLabel,
53  const FrameInfo *ChainedParent)
54  : Begin(BeginFuncEHLabel), Function(Function),
55  ChainedParent(ChainedParent) {}
56 };
57 
59 public:
60  virtual ~UnwindEmitter();
61 
62  /// This emits the unwind info sections (.pdata and .xdata in PE/COFF).
63  virtual void Emit(MCStreamer &Streamer) const = 0;
64  virtual void EmitUnwindInfo(MCStreamer &Streamer, FrameInfo *FI) const = 0;
65 };
66 }
67 }
68 
69 #endif
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:39
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
unsigned Reg
FrameInfo(const MCSymbol *Function, const MCSymbol *BeginFuncEHLabel, const FrameInfo *ChainedParent)
Definition: MCWinEH.h:52
This class implements a map that also provides access to all stored values in a deterministic order...
Definition: MapVector.h:37
std::vector< Instruction > Instructions
Definition: MCWinEH.h:46
Streaming machine code generation interface.
Definition: MCStreamer.h:190
Instruction(unsigned Op, MCSymbol *L, unsigned Reg, unsigned Off)
Definition: MCWinEH.h:27
const MCSymbol * Label
Definition: MCWinEH.h:22
MapVector< MCSymbol *, std::vector< Instruction > > EpilogMap
Definition: MCWinEH.h:47
Windows Exception Handling.
FrameInfo(const MCSymbol *Function, const MCSymbol *BeginFuncEHLabel)
Definition: MCWinEH.h:50
static void EmitUnwindInfo(MCStreamer &streamer, WinEH::FrameInfo *info)
Definition: MCWin64EH.cpp:154