MCWin64EH.h 2.2 KB

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