Path: blob/main/contrib/llvm-project/llvm/lib/Support/ARMWinEH.cpp
35233 views
//===-- ARMWinEH.cpp - Windows on ARM EH Support Functions ------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "llvm/Support/ARMWinEH.h"910namespace llvm {11namespace ARM {12namespace WinEH {13std::pair<uint16_t, uint32_t> SavedRegisterMask(const RuntimeFunction &RF,14bool Prologue) {15uint8_t NumRegisters = RF.Reg();16uint8_t RegistersVFP = RF.R();17uint8_t LinkRegister = RF.L();18uint8_t ChainedFrame = RF.C();1920uint16_t GPRMask = (ChainedFrame << 11);21uint32_t VFPMask = 0;2223if (Prologue) {24GPRMask |= (LinkRegister << 14);25} else {26// If Ret != 0, we pop into Lr and return later27if (RF.Ret() != ReturnType::RT_POP)28GPRMask |= (LinkRegister << 14);29else if (!RF.H()) // If H == 0, we pop directly into Pc30GPRMask |= (LinkRegister << 15);31// else, Ret == 0 && H == 1, we pop into Pc separately afterwards32}3334if (RegistersVFP)35VFPMask |= (((1 << ((NumRegisters + 1) % 8)) - 1) << 8);36else37GPRMask |= (((1 << (NumRegisters + 1)) - 1) << 4);3839if ((PrologueFolding(RF) && Prologue) || (EpilogueFolding(RF) && !Prologue))40GPRMask |= (((1 << ((RF.StackAdjust() & 0x3) + 1)) - 1)41<< (~RF.StackAdjust() & 0x3));4243return std::make_pair(GPRMask, VFPMask);44}45} // namespace WinEH46} // namespace ARM47} // namespace llvm48495051