LLVM API Documentation
00001 //===- MCWinEH.h - Windows Unwinding Support --------------------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 00010 #ifndef LLVM_MC_MCWINEH_H 00011 #define LLVM_MC_MCWINEH_H 00012 00013 #include <vector> 00014 00015 namespace llvm { 00016 class MCContext; 00017 class MCSection; 00018 class MCStreamer; 00019 class MCSymbol; 00020 class StringRef; 00021 00022 namespace WinEH { 00023 struct Instruction { 00024 const MCSymbol *Label; 00025 const unsigned Offset; 00026 const unsigned Register; 00027 const unsigned Operation; 00028 00029 Instruction(unsigned Op, MCSymbol *L, unsigned Reg, unsigned Off) 00030 : Label(L), Offset(Off), Register(Reg), Operation(Op) {} 00031 }; 00032 00033 struct FrameInfo { 00034 const MCSymbol *Begin; 00035 const MCSymbol *End; 00036 const MCSymbol *ExceptionHandler; 00037 const MCSymbol *Function; 00038 const MCSymbol *PrologEnd; 00039 const MCSymbol *Symbol; 00040 00041 bool HandlesUnwind; 00042 bool HandlesExceptions; 00043 00044 int LastFrameInst; 00045 const FrameInfo *ChainedParent; 00046 std::vector<Instruction> Instructions; 00047 00048 FrameInfo() 00049 : Begin(nullptr), End(nullptr), ExceptionHandler(nullptr), 00050 Function(nullptr), PrologEnd(nullptr), Symbol(nullptr), 00051 HandlesUnwind(false), HandlesExceptions(false), LastFrameInst(-1), 00052 ChainedParent(nullptr), Instructions() {} 00053 FrameInfo(const MCSymbol *Function, const MCSymbol *BeginFuncEHLabel) 00054 : Begin(BeginFuncEHLabel), End(nullptr), ExceptionHandler(nullptr), 00055 Function(Function), PrologEnd(nullptr), Symbol(nullptr), 00056 HandlesUnwind(false), HandlesExceptions(false), LastFrameInst(-1), 00057 ChainedParent(nullptr), Instructions() {} 00058 FrameInfo(const MCSymbol *Function, const MCSymbol *BeginFuncEHLabel, 00059 const FrameInfo *ChainedParent) 00060 : Begin(BeginFuncEHLabel), End(nullptr), ExceptionHandler(nullptr), 00061 Function(Function), PrologEnd(nullptr), Symbol(nullptr), 00062 HandlesUnwind(false), HandlesExceptions(false), LastFrameInst(-1), 00063 ChainedParent(ChainedParent), Instructions() {} 00064 }; 00065 00066 class UnwindEmitter { 00067 public: 00068 static const MCSection *getPDataSection(const MCSymbol *Function, 00069 MCContext &Context); 00070 static const MCSection *getXDataSection(const MCSymbol *Function, 00071 MCContext &Context); 00072 00073 virtual ~UnwindEmitter() { } 00074 00075 // 00076 // This emits the unwind info sections (.pdata and .xdata in PE/COFF). 00077 // 00078 virtual void Emit(MCStreamer &Streamer) const = 0; 00079 virtual void EmitUnwindInfo(MCStreamer &Streamer, FrameInfo *FI) const = 0; 00080 }; 00081 } 00082 } 00083 00084 #endif