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