MCWin64EH.h 2.6 KB

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