MCWin64EH.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //===- MCWin64EH.h - Machine Code Win64 EH support --------------*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file contains declarations to support the Win64 Exception Handling
  10. // scheme in MC.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_MC_MCWIN64EH_H
  14. #define LLVM_MC_MCWIN64EH_H
  15. #include "llvm/MC/MCWinEH.h"
  16. #include "llvm/Support/Win64EH.h"
  17. namespace llvm {
  18. class MCStreamer;
  19. class MCSymbol;
  20. namespace Win64EH {
  21. struct Instruction {
  22. static WinEH::Instruction PushNonVol(MCSymbol *L, unsigned Reg) {
  23. return WinEH::Instruction(Win64EH::UOP_PushNonVol, L, Reg, -1);
  24. }
  25. static WinEH::Instruction Alloc(MCSymbol *L, unsigned Size) {
  26. return WinEH::Instruction(Size > 128 ? UOP_AllocLarge : UOP_AllocSmall, L,
  27. -1, Size);
  28. }
  29. static WinEH::Instruction PushMachFrame(MCSymbol *L, bool Code) {
  30. return WinEH::Instruction(UOP_PushMachFrame, L, -1, Code ? 1 : 0);
  31. }
  32. static WinEH::Instruction SaveNonVol(MCSymbol *L, unsigned Reg,
  33. unsigned Offset) {
  34. return WinEH::Instruction(Offset > 512 * 1024 - 8 ? UOP_SaveNonVolBig
  35. : UOP_SaveNonVol,
  36. L, Reg, Offset);
  37. }
  38. static WinEH::Instruction SaveXMM(MCSymbol *L, unsigned Reg,
  39. unsigned Offset) {
  40. return WinEH::Instruction(Offset > 512 * 1024 - 8 ? UOP_SaveXMM128Big
  41. : UOP_SaveXMM128,
  42. L, Reg, Offset);
  43. }
  44. static WinEH::Instruction SetFPReg(MCSymbol *L, unsigned Reg, unsigned Off) {
  45. return WinEH::Instruction(UOP_SetFPReg, L, Reg, Off);
  46. }
  47. };
  48. class UnwindEmitter : public WinEH::UnwindEmitter {
  49. public:
  50. void Emit(MCStreamer &Streamer) const override;
  51. void EmitUnwindInfo(MCStreamer &Streamer, WinEH::FrameInfo *FI,
  52. bool HandlerData) const override;
  53. };
  54. class ARM64UnwindEmitter : public WinEH::UnwindEmitter {
  55. public:
  56. void Emit(MCStreamer &Streamer) const override;
  57. void EmitUnwindInfo(MCStreamer &Streamer, WinEH::FrameInfo *FI,
  58. bool HandlerData) const override;
  59. };
  60. }
  61. } // end namespace llvm
  62. #endif