LLVM API Documentation

MCWin64EH.h
Go to the documentation of this file.
00001 //===- MCWin64EH.h - Machine Code Win64 EH 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 // This file contains declarations to support the Win64 Exception Handling
00011 // scheme in MC.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #ifndef LLVM_MC_MCWIN64EH_H
00016 #define LLVM_MC_MCWIN64EH_H
00017 
00018 #include "llvm/MC/MCWinEH.h"
00019 #include "llvm/Support/Win64EH.h"
00020 #include <vector>
00021 
00022 namespace llvm {
00023 class MCStreamer;
00024 class MCSymbol;
00025 
00026 namespace Win64EH {
00027 struct Instruction {
00028   static WinEH::Instruction PushNonVol(MCSymbol *L, unsigned Reg) {
00029     return WinEH::Instruction(Win64EH::UOP_PushNonVol, L, Reg, -1);
00030   }
00031   static WinEH::Instruction Alloc(MCSymbol *L, unsigned Size) {
00032     return WinEH::Instruction(Size > 128 ? UOP_AllocLarge : UOP_AllocSmall, L,
00033                               -1, Size);
00034   }
00035   static WinEH::Instruction PushMachFrame(MCSymbol *L, bool Code) {
00036     return WinEH::Instruction(UOP_PushMachFrame, L, -1, Code ? 1 : 0);
00037   }
00038   static WinEH::Instruction SaveNonVol(MCSymbol *L, unsigned Reg,
00039                                        unsigned Offset) {
00040     return WinEH::Instruction(Offset > 512 * 1024 - 8 ? UOP_SaveNonVolBig
00041                                                       : UOP_SaveNonVol,
00042                               L, Reg, Offset);
00043   }
00044   static WinEH::Instruction SaveXMM(MCSymbol *L, unsigned Reg,
00045                                     unsigned Offset) {
00046     return WinEH::Instruction(Offset > 512 * 1024 - 8 ? UOP_SaveXMM128Big
00047                                                       : UOP_SaveXMM128,
00048                               L, Reg, Offset);
00049   }
00050   static WinEH::Instruction SetFPReg(MCSymbol *L, unsigned Reg, unsigned Off) {
00051     return WinEH::Instruction(UOP_SetFPReg, L, Reg, Off);
00052   }
00053 };
00054 
00055 class UnwindEmitter : public WinEH::UnwindEmitter {
00056 public:
00057   void Emit(MCStreamer &Streamer) const override;
00058   void EmitUnwindInfo(MCStreamer &Streamer, WinEH::FrameInfo *FI) const override;
00059 };
00060 }
00061 } // end namespace llvm
00062 
00063 #endif