LLVM  8.0.0svn
MCWinEH.h
Go to the documentation of this file.
1 //===- MCWinEH.h - Windows Unwinding Support --------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_MC_MCWINEH_H
11 #define LLVM_MC_MCWINEH_H
12 
13 #include "llvm/ADT/MapVector.h"
14 #include <vector>
15 
16 namespace llvm {
17 class MCSection;
18 class MCStreamer;
19 class MCSymbol;
20 
21 namespace WinEH {
22 struct Instruction {
23  const MCSymbol *Label;
24  unsigned Offset;
25  unsigned Register;
26  unsigned Operation;
27 
28  Instruction(unsigned Op, MCSymbol *L, unsigned Reg, unsigned Off)
29  : Label(L), Offset(Off), Register(Reg), Operation(Op) {}
30 };
31 
32 struct FrameInfo {
33  const MCSymbol *Begin = nullptr;
34  const MCSymbol *End = nullptr;
35  const MCSymbol *FuncletOrFuncEnd = nullptr;
36  const MCSymbol *ExceptionHandler = nullptr;
37  const MCSymbol *Function = nullptr;
38  const MCSymbol *PrologEnd = nullptr;
39  const MCSymbol *Symbol = nullptr;
40  const MCSection *TextSection = nullptr;
41 
42  bool HandlesUnwind = false;
43  bool HandlesExceptions = false;
44 
45  int LastFrameInst = -1;
46  const FrameInfo *ChainedParent = nullptr;
47  std::vector<Instruction> Instructions;
49 
50  FrameInfo() = default;
51  FrameInfo(const MCSymbol *Function, const MCSymbol *BeginFuncEHLabel)
52  : Begin(BeginFuncEHLabel), Function(Function) {}
53  FrameInfo(const MCSymbol *Function, const MCSymbol *BeginFuncEHLabel,
54  const FrameInfo *ChainedParent)
55  : Begin(BeginFuncEHLabel), Function(Function),
56  ChainedParent(ChainedParent) {}
57 };
58 
60 public:
61  virtual ~UnwindEmitter();
62 
63  /// This emits the unwind info sections (.pdata and .xdata in PE/COFF).
64  virtual void Emit(MCStreamer &Streamer) const = 0;
65  virtual void EmitUnwindInfo(MCStreamer &Streamer, FrameInfo *FI) const = 0;
66 };
67 }
68 }
69 
70 #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:24
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:42
unsigned Reg
FrameInfo(const MCSymbol *Function, const MCSymbol *BeginFuncEHLabel, const FrameInfo *ChainedParent)
Definition: MCWinEH.h:53
This class implements a map that also provides access to all stored values in a deterministic order...
Definition: MapVector.h:38
std::vector< Instruction > Instructions
Definition: MCWinEH.h:47
Streaming machine code generation interface.
Definition: MCStreamer.h:189
Instruction(unsigned Op, MCSymbol *L, unsigned Reg, unsigned Off)
Definition: MCWinEH.h:28
const MCSymbol * Label
Definition: MCWinEH.h:23
MapVector< MCSymbol *, std::vector< Instruction > > EpilogMap
Definition: MCWinEH.h:48
FrameInfo(const MCSymbol *Function, const MCSymbol *BeginFuncEHLabel)
Definition: MCWinEH.h:51
static void EmitUnwindInfo(MCStreamer &streamer, WinEH::FrameInfo *info)
Definition: MCWin64EH.cpp:155