1cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines//===-- ARMWinEH.cpp - Windows on ARM EH Support Functions ------*- C++ -*-===// 2cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines// 3cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines// The LLVM Compiler Infrastructure 4cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines// 5cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines// This file is distributed under the University of Illinois Open Source 6cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines// License. See LICENSE.TXT for details. 7cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines// 8cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines//===----------------------------------------------------------------------===// 9cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines 10cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines#include "llvm/Support/ARMWinEH.h" 11cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines#include "llvm/Support/raw_ostream.h" 12cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines 13cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hinesnamespace llvm { 14cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hinesnamespace ARM { 15cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hinesnamespace WinEH { 16cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hinesstd::pair<uint16_t, uint32_t> SavedRegisterMask(const RuntimeFunction &RF) { 17cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines uint8_t NumRegisters = RF.Reg(); 18cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines uint8_t RegistersVFP = RF.R(); 19cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines uint8_t LinkRegister = RF.L(); 20cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines uint8_t ChainedFrame = RF.C(); 21cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines 22cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines uint16_t GPRMask = (ChainedFrame << 11) | (LinkRegister << 14); 23cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines uint32_t VFPMask = 0; 24cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines 25cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines if (RegistersVFP) 26cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines VFPMask |= (((1 << ((NumRegisters + 1) % 8)) - 1) << 8); 27cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines else 28cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines GPRMask |= (((1 << (NumRegisters + 1)) - 1) << 4); 29cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines 30cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines if (PrologueFolding(RF)) 31cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines GPRMask |= (((1 << (NumRegisters + 1)) - 1) << (~RF.StackAdjust() & 0x3)); 32cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines 33cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines return std::make_pair(GPRMask, VFPMask); 34cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines} 35cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines} 36cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines} 37cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines} 38cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines 39