10b57cec5SDimitry Andric //===- MCWin64EH.h - Machine Code Win64 EH support --------------*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 90b57cec5SDimitry Andric // This file contains declarations to support the Win64 Exception Handling 100b57cec5SDimitry Andric // scheme in MC. 110b57cec5SDimitry Andric // 120b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 130b57cec5SDimitry Andric 140b57cec5SDimitry Andric #ifndef LLVM_MC_MCWIN64EH_H 150b57cec5SDimitry Andric #define LLVM_MC_MCWIN64EH_H 160b57cec5SDimitry Andric 170b57cec5SDimitry Andric #include "llvm/MC/MCWinEH.h" 180b57cec5SDimitry Andric #include "llvm/Support/Win64EH.h" 190b57cec5SDimitry Andric 200b57cec5SDimitry Andric namespace llvm { 210b57cec5SDimitry Andric class MCStreamer; 220b57cec5SDimitry Andric class MCSymbol; 230b57cec5SDimitry Andric 240b57cec5SDimitry Andric namespace Win64EH { 250b57cec5SDimitry Andric struct Instruction { PushNonVolInstruction260b57cec5SDimitry Andric static WinEH::Instruction PushNonVol(MCSymbol *L, unsigned Reg) { 270b57cec5SDimitry Andric return WinEH::Instruction(Win64EH::UOP_PushNonVol, L, Reg, -1); 280b57cec5SDimitry Andric } AllocInstruction290b57cec5SDimitry Andric static WinEH::Instruction Alloc(MCSymbol *L, unsigned Size) { 300b57cec5SDimitry Andric return WinEH::Instruction(Size > 128 ? UOP_AllocLarge : UOP_AllocSmall, L, 310b57cec5SDimitry Andric -1, Size); 320b57cec5SDimitry Andric } PushMachFrameInstruction330b57cec5SDimitry Andric static WinEH::Instruction PushMachFrame(MCSymbol *L, bool Code) { 340b57cec5SDimitry Andric return WinEH::Instruction(UOP_PushMachFrame, L, -1, Code ? 1 : 0); 350b57cec5SDimitry Andric } SaveNonVolInstruction360b57cec5SDimitry Andric static WinEH::Instruction SaveNonVol(MCSymbol *L, unsigned Reg, 370b57cec5SDimitry Andric unsigned Offset) { 380b57cec5SDimitry Andric return WinEH::Instruction(Offset > 512 * 1024 - 8 ? UOP_SaveNonVolBig 390b57cec5SDimitry Andric : UOP_SaveNonVol, 400b57cec5SDimitry Andric L, Reg, Offset); 410b57cec5SDimitry Andric } SaveXMMInstruction420b57cec5SDimitry Andric static WinEH::Instruction SaveXMM(MCSymbol *L, unsigned Reg, 430b57cec5SDimitry Andric unsigned Offset) { 440b57cec5SDimitry Andric return WinEH::Instruction(Offset > 512 * 1024 - 8 ? UOP_SaveXMM128Big 450b57cec5SDimitry Andric : UOP_SaveXMM128, 460b57cec5SDimitry Andric L, Reg, Offset); 470b57cec5SDimitry Andric } SetFPRegInstruction480b57cec5SDimitry Andric static WinEH::Instruction SetFPReg(MCSymbol *L, unsigned Reg, unsigned Off) { 490b57cec5SDimitry Andric return WinEH::Instruction(UOP_SetFPReg, L, Reg, Off); 500b57cec5SDimitry Andric } 510b57cec5SDimitry Andric }; 520b57cec5SDimitry Andric 530b57cec5SDimitry Andric class UnwindEmitter : public WinEH::UnwindEmitter { 540b57cec5SDimitry Andric public: 550b57cec5SDimitry Andric void Emit(MCStreamer &Streamer) const override; 56e8d8bef9SDimitry Andric void EmitUnwindInfo(MCStreamer &Streamer, WinEH::FrameInfo *FI, 57e8d8bef9SDimitry Andric bool HandlerData) const override; 580b57cec5SDimitry Andric }; 590b57cec5SDimitry Andric 60*81ad6265SDimitry Andric class ARMUnwindEmitter : public WinEH::UnwindEmitter { 610b57cec5SDimitry Andric public: 620b57cec5SDimitry Andric void Emit(MCStreamer &Streamer) const override; 63e8d8bef9SDimitry Andric void EmitUnwindInfo(MCStreamer &Streamer, WinEH::FrameInfo *FI, 64e8d8bef9SDimitry Andric bool HandlerData) const override; 650b57cec5SDimitry Andric }; 660b57cec5SDimitry Andric 67*81ad6265SDimitry Andric class ARM64UnwindEmitter : public WinEH::UnwindEmitter { 68*81ad6265SDimitry Andric public: 69*81ad6265SDimitry Andric void Emit(MCStreamer &Streamer) const override; 70*81ad6265SDimitry Andric void EmitUnwindInfo(MCStreamer &Streamer, WinEH::FrameInfo *FI, 71*81ad6265SDimitry Andric bool HandlerData) const override; 72*81ad6265SDimitry Andric }; 730b57cec5SDimitry Andric } 740b57cec5SDimitry Andric } // end namespace llvm 750b57cec5SDimitry Andric 760b57cec5SDimitry Andric #endif 77