blob: 831f95cd4b0b143bcfbe179684cceb087a080f2d [file] [log] [blame]
Saleem Abdulrasoolb3271032014-06-02 01:17:49 +00001//===-- ARMWinEH.cpp - Windows on ARM EH Support Functions ------*- C++ -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Saleem Abdulrasoolb3271032014-06-02 01:17:49 +00006//
7//===----------------------------------------------------------------------===//
8
9#include "llvm/Support/ARMWinEH.h"
10#include "llvm/Support/raw_ostream.h"
11
12namespace llvm {
13namespace ARM {
14namespace WinEH {
15std::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();
20
21 uint16_t GPRMask = (ChainedFrame << 11) | (LinkRegister << 14);
22 uint32_t VFPMask = 0;
23
24 if (RegistersVFP)
25 VFPMask |= (((1 << ((NumRegisters + 1) % 8)) - 1) << 8);
26 else
27 GPRMask |= (((1 << (NumRegisters + 1)) - 1) << 4);
28
29 if (PrologueFolding(RF))
30 GPRMask |= (((1 << (NumRegisters + 1)) - 1) << (~RF.StackAdjust() & 0x3));
31
32 return std::make_pair(GPRMask, VFPMask);
33}
Alexander Kornienkof00654e2015-06-23 09:49:53 +000034}
35}
36}
Saleem Abdulrasoolb3271032014-06-02 01:17:49 +000037