1 //===- MCWin64EH.h - Machine Code Win64 EH support --------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains declarations to support the Win64 Exception Handling
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_MC_MCWIN64EH_H
16 #define LLVM_MC_MCWIN64EH_H
18 #include "llvm/MC/MCWinEH.h"
19 #include "llvm/Support/Win64EH.h"
29 static WinEH::Instruction PushNonVol(MCSymbol *L, unsigned Reg) {
30 return WinEH::Instruction(Win64EH::UOP_PushNonVol, L, Reg, -1);
32 static WinEH::Instruction Alloc(MCSymbol *L, unsigned Size) {
33 return WinEH::Instruction(Size > 128 ? UOP_AllocLarge : UOP_AllocSmall, L,
36 static WinEH::Instruction PushMachFrame(MCSymbol *L, bool Code) {
37 return WinEH::Instruction(UOP_PushMachFrame, L, -1, Code ? 1 : 0);
39 static WinEH::Instruction SaveNonVol(MCSymbol *L, unsigned Reg,
41 return WinEH::Instruction(Offset > 512 * 1024 - 8 ? UOP_SaveNonVolBig
45 static WinEH::Instruction SaveXMM(MCSymbol *L, unsigned Reg,
47 return WinEH::Instruction(Offset > 512 * 1024 - 8 ? UOP_SaveXMM128Big
51 static WinEH::Instruction SetFPReg(MCSymbol *L, unsigned Reg, unsigned Off) {
52 return WinEH::Instruction(UOP_SetFPReg, L, Reg, Off);
57 struct 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() {}
65 const MCSymbol *ExceptionHandler;
66 const MCSymbol *Function;
70 bool HandlesExceptions;
72 MCWinFrameInfo *ChainedParent;
73 std::vector<WinEH::Instruction> Instructions;
76 class MCWin64EHUnwindEmitter {
78 static StringRef GetSectionSuffix(const MCSymbol *func);
80 // This emits the unwind info sections (.pdata and .xdata in PE/COFF).
82 static void Emit(MCStreamer &streamer);
83 static void EmitUnwindInfo(MCStreamer &streamer, MCWinFrameInfo *info);
85 } // end namespace llvm