]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/MC/MCWin64EH.h
Merge ^/head r274961 through r276418.
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / MC / MCWin64EH.h
1 //===- MCWin64EH.h - Machine Code Win64 EH 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 // This file contains declarations to support the Win64 Exception Handling
11 // scheme in MC.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_MC_MCWIN64EH_H
16 #define LLVM_MC_MCWIN64EH_H
17
18 #include "llvm/MC/MCWinEH.h"
19 #include "llvm/Support/Win64EH.h"
20 #include <vector>
21
22 namespace llvm {
23   class StringRef;
24   class MCStreamer;
25   class MCSymbol;
26
27 namespace Win64EH {
28 struct Instruction {
29   static WinEH::Instruction PushNonVol(MCSymbol *L, unsigned Reg) {
30     return WinEH::Instruction(Win64EH::UOP_PushNonVol, L, Reg, -1);
31   }
32   static WinEH::Instruction Alloc(MCSymbol *L, unsigned Size) {
33     return WinEH::Instruction(Size > 128 ? UOP_AllocLarge : UOP_AllocSmall, L,
34                               -1, Size);
35   }
36   static WinEH::Instruction PushMachFrame(MCSymbol *L, bool Code) {
37     return WinEH::Instruction(UOP_PushMachFrame, L, -1, Code ? 1 : 0);
38   }
39   static WinEH::Instruction SaveNonVol(MCSymbol *L, unsigned Reg,
40                                        unsigned Offset) {
41     return WinEH::Instruction(Offset > 512 * 1024 - 8 ? UOP_SaveNonVolBig
42                                                       : UOP_SaveNonVol,
43                               L, Reg, Offset);
44   }
45   static WinEH::Instruction SaveXMM(MCSymbol *L, unsigned Reg,
46                                     unsigned Offset) {
47     return WinEH::Instruction(Offset > 512 * 1024 - 8 ? UOP_SaveXMM128Big
48                                                       : UOP_SaveXMM128,
49                               L, Reg, Offset);
50   }
51   static WinEH::Instruction SetFPReg(MCSymbol *L, unsigned Reg, unsigned Off) {
52     return WinEH::Instruction(UOP_SetFPReg, L, Reg, Off);
53   }
54 };
55 }
56
57   struct MCWinFrameInfo {
58     MCWinFrameInfo()
59       : Begin(nullptr), End(nullptr),ExceptionHandler(nullptr),
60         Function(nullptr), PrologEnd(nullptr), Symbol(nullptr),
61         HandlesUnwind(false), HandlesExceptions(false), LastFrameInst(-1),
62         ChainedParent(nullptr), Instructions() {}
63     MCSymbol *Begin;
64     MCSymbol *End;
65     const MCSymbol *ExceptionHandler;
66     const MCSymbol *Function;
67     MCSymbol *PrologEnd;
68     MCSymbol *Symbol;
69     bool HandlesUnwind;
70     bool HandlesExceptions;
71     int LastFrameInst;
72     MCWinFrameInfo *ChainedParent;
73     std::vector<WinEH::Instruction> Instructions;
74   };
75
76   class MCWin64EHUnwindEmitter {
77   public:
78     static StringRef GetSectionSuffix(const MCSymbol *func);
79     //
80     // This emits the unwind info sections (.pdata and .xdata in PE/COFF).
81     //
82     static void Emit(MCStreamer &streamer);
83     static void EmitUnwindInfo(MCStreamer &streamer, MCWinFrameInfo *info);
84   };
85 } // end namespace llvm
86
87 #endif