ARMWinEH.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //===-- ARMWinEH.cpp - Windows on ARM EH Support Functions ------*- 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. #include "llvm/Support/ARMWinEH.h"
  9. namespace llvm {
  10. namespace ARM {
  11. namespace WinEH {
  12. std::pair<uint16_t, uint32_t> SavedRegisterMask(const RuntimeFunction &RF,
  13. bool Prologue) {
  14. uint8_t NumRegisters = RF.Reg();
  15. uint8_t RegistersVFP = RF.R();
  16. uint8_t LinkRegister = RF.L();
  17. uint8_t ChainedFrame = RF.C();
  18. uint16_t GPRMask = (ChainedFrame << 11);
  19. uint32_t VFPMask = 0;
  20. if (Prologue) {
  21. GPRMask |= (LinkRegister << 14);
  22. } else {
  23. // If Ret != 0, we pop into Lr and return later
  24. if (RF.Ret() != ReturnType::RT_POP)
  25. GPRMask |= (LinkRegister << 14);
  26. else if (!RF.H()) // If H == 0, we pop directly into Pc
  27. GPRMask |= (LinkRegister << 15);
  28. // else, Ret == 0 && H == 1, we pop into Pc separately afterwards
  29. }
  30. if (RegistersVFP)
  31. VFPMask |= (((1 << ((NumRegisters + 1) % 8)) - 1) << 8);
  32. else
  33. GPRMask |= (((1 << (NumRegisters + 1)) - 1) << 4);
  34. if ((PrologueFolding(RF) && Prologue) || (EpilogueFolding(RF) && !Prologue))
  35. GPRMask |= (((1 << ((RF.StackAdjust() & 0x3) + 1)) - 1)
  36. << (~RF.StackAdjust() & 0x3));
  37. return std::make_pair(GPRMask, VFPMask);
  38. }
  39. } // namespace WinEH
  40. } // namespace ARM
  41. } // namespace llvm