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