LLVM  4.0.0
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 <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  const unsigned Offset;
24  const unsigned Register;
25  const 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 *ExceptionHandler = nullptr;
35  const MCSymbol *Function = nullptr;
36  const MCSymbol *PrologEnd = nullptr;
37  const MCSymbol *Symbol = nullptr;
38  const MCSection *TextSection = nullptr;
39 
40  bool HandlesUnwind = false;
41  bool HandlesExceptions = false;
42 
43  int LastFrameInst = -1;
44  const FrameInfo *ChainedParent = nullptr;
45  std::vector<Instruction> Instructions;
46 
47  FrameInfo() = default;
48  FrameInfo(const MCSymbol *Function, const MCSymbol *BeginFuncEHLabel)
49  : Begin(BeginFuncEHLabel), Function(Function) {}
50  FrameInfo(const MCSymbol *Function, const MCSymbol *BeginFuncEHLabel,
51  const FrameInfo *ChainedParent)
52  : Begin(BeginFuncEHLabel), Function(Function),
53  ChainedParent(ChainedParent) {}
54 };
55 
57 public:
58  virtual ~UnwindEmitter();
59 
60  /// This emits the unwind info sections (.pdata and .xdata in PE/COFF).
61  virtual void Emit(MCStreamer &Streamer) const = 0;
62  virtual void EmitUnwindInfo(MCStreamer &Streamer, FrameInfo *FI) const = 0;
63 };
64 }
65 }
66 
67 #endif
MachineLoop * L
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:40
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:39
const MCSymbol * End
Definition: MCWinEH.h:33
const unsigned Register
Definition: MCWinEH.h:24
FrameInfo(const MCSymbol *Function, const MCSymbol *BeginFuncEHLabel, const FrameInfo *ChainedParent)
Definition: MCWinEH.h:50
virtual void Emit(MCStreamer &Streamer) const =0
This emits the unwind info sections (.pdata and .xdata in PE/COFF).
std::vector< Instruction > Instructions
Definition: MCWinEH.h:45
Reg
All possible values of the reg field in the ModR/M byte.
Streaming machine code generation interface.
Definition: MCStreamer.h:161
const FrameInfo * ChainedParent
Definition: MCWinEH.h:44
const MCSymbol * Symbol
Definition: MCWinEH.h:37
const MCSymbol * Begin
Definition: MCWinEH.h:32
const MCSymbol * PrologEnd
Definition: MCWinEH.h:36
virtual void EmitUnwindInfo(MCStreamer &Streamer, FrameInfo *FI) const =0
Instruction(unsigned Op, MCSymbol *L, unsigned Reg, unsigned Off)
Definition: MCWinEH.h:27
const MCSection * TextSection
Definition: MCWinEH.h:38
const MCSymbol * Label
Definition: MCWinEH.h:22
const unsigned Offset
Definition: MCWinEH.h:23
const unsigned Operation
Definition: MCWinEH.h:25
FrameInfo(const MCSymbol *Function, const MCSymbol *BeginFuncEHLabel)
Definition: MCWinEH.h:48
const MCSymbol * ExceptionHandler
Definition: MCWinEH.h:34