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/Support/Win64EH.h"
25 class MCWin64EHInstruction {
27 typedef Win64EH::UnwindOpcodes OpType;
33 MCWin64EHInstruction(OpType Op, unsigned Reg)
34 : Operation(Op), Offset(0), Register(Reg) {
35 assert(Op == Win64EH::UOP_PushNonVol);
37 MCWin64EHInstruction(unsigned Size)
38 : Operation(Size>128 ? Win64EH::UOP_AllocLarge : Win64EH::UOP_AllocSmall),
40 MCWin64EHInstruction(OpType Op, unsigned Reg,
42 : Operation(Op), Offset(Off), Register(Reg) {
43 assert(Op == Win64EH::UOP_SetFPReg ||
44 Op == Win64EH::UOP_SaveNonVol ||
45 Op == Win64EH::UOP_SaveNonVolBig ||
46 Op == Win64EH::UOP_SaveXMM128 ||
47 Op == Win64EH::UOP_SaveXMM128Big);
49 MCWin64EHInstruction(OpType Op, bool Code)
50 : Operation(Op), Offset(Code ? 1 : 0) {
51 assert(Op == Win64EH::UOP_PushMachFrame);
53 OpType getOperation() const { return Operation; }
54 unsigned getOffset() const { return Offset; }
55 unsigned getSize() const { return Offset; }
56 unsigned getRegister() const { return Register; }
57 bool isPushCodeFrame() const { return Offset == 1; }
60 struct MCWin64EHUnwindInfo {
61 MCWin64EHUnwindInfo() : Begin(0), End(0), ExceptionHandler(0),
62 Function(0), PrologEnd(0), HandlesUnwind(false),
63 HandlesExceptions(false), LastFrameInst(-1),
64 ChainedParent(0), Instructions(), Emitted(false) {}
67 const MCSymbol *ExceptionHandler;
68 const MCSymbol *Function;
71 bool HandlesExceptions;
73 MCWin64EHUnwindInfo *ChainedParent;
74 std::vector<MCWin64EHInstruction> Instructions;
78 class MCWin64EHUnwindEmitter {
81 // This emits the unwind info sections (.pdata and .xdata in PE/COFF).
83 static void Emit(MCStreamer &streamer);
84 static void EmitUnwindInfo(MCStreamer &streamer, MCWin64EHUnwindInfo *info);
86 } // end namespace llvm