LLVM 19.0.0git
ARMWinEH.cpp
Go to the documentation of this file.
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
10
11namespace llvm {
12namespace ARM {
13namespace WinEH {
14std::pair<uint16_t, uint32_t> SavedRegisterMask(const RuntimeFunction &RF,
15 bool Prologue) {
16 uint8_t NumRegisters = RF.Reg();
17 uint8_t RegistersVFP = RF.R();
18 uint8_t LinkRegister = RF.L();
19 uint8_t ChainedFrame = RF.C();
20
21 uint16_t GPRMask = (ChainedFrame << 11);
22 uint32_t VFPMask = 0;
23
24 if (Prologue) {
25 GPRMask |= (LinkRegister << 14);
26 } else {
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
33 }
34
35 if (RegistersVFP)
36 VFPMask |= (((1 << ((NumRegisters + 1) % 8)) - 1) << 8);
37 else
38 GPRMask |= (((1 << (NumRegisters + 1)) - 1) << 4);
39
40 if ((PrologueFolding(RF) && Prologue) || (EpilogueFolding(RF) && !Prologue))
41 GPRMask |= (((1 << ((RF.StackAdjust() & 0x3) + 1)) - 1)
42 << (~RF.StackAdjust() & 0x3));
43
44 return std::make_pair(GPRMask, VFPMask);
45}
46} // namespace WinEH
47} // namespace ARM
48} // namespace llvm
49
RuntimeFunction - An entry in the table of procedure data (.pdata)
Definition: ARMWinEH.h:103
uint16_t StackAdjust() const
Definition: ARMWinEH.h:178
bool EpilogueFolding(const RuntimeFunction &RF)
Epilogue - pseudo-flag derived from Stack Adjust indicating that the epilogue has stack adjustment co...
Definition: ARMWinEH.h:193
std::pair< uint16_t, uint32_t > SavedRegisterMask(const RuntimeFunction &RF, bool Prologue=true)
SavedRegisterMask - Utility function to calculate the set of saved general purpose (r0-r15) and VFP (...
Definition: ARMWinEH.cpp:14
bool PrologueFolding(const RuntimeFunction &RF)
PrologueFolding - pseudo-flag derived from Stack Adjust indicating that the prologue has stack adjust...
Definition: ARMWinEH.h:188
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ WinEH
Windows Exception Handling.