1760c2415Smrg // Exception handling and frame unwind runtime interface routines.
2*0bfacb9bSmrg // Copyright (C) 2011-2020 Free Software Foundation, Inc.
3760c2415Smrg 
4760c2415Smrg // GCC is free software; you can redistribute it and/or modify it under
5760c2415Smrg // the terms of the GNU General Public License as published by the Free
6760c2415Smrg // Software Foundation; either version 3, or (at your option) any later
7760c2415Smrg // version.
8760c2415Smrg 
9760c2415Smrg // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
10760c2415Smrg // WARRANTY; without even the implied warranty of MERCHANTABILITY or
11760c2415Smrg // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12760c2415Smrg // for more details.
13760c2415Smrg 
14760c2415Smrg // Under Section 7 of GPL version 3, you are granted additional
15760c2415Smrg // permissions described in the GCC Runtime Library Exception, version
16760c2415Smrg // 3.1, as published by the Free Software Foundation.
17760c2415Smrg 
18760c2415Smrg // You should have received a copy of the GNU General Public License and
19760c2415Smrg // a copy of the GCC Runtime Library Exception along with this program;
20760c2415Smrg // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
21760c2415Smrg // <http://www.gnu.org/licenses/>.
22760c2415Smrg 
23760c2415Smrg // extern(C) interface for the ARM EABI unwinder library.
24760c2415Smrg // This corresponds to unwind-arm.h
25760c2415Smrg 
26760c2415Smrg module gcc.unwind.arm;
27760c2415Smrg 
28760c2415Smrg import gcc.config;
29760c2415Smrg 
30760c2415Smrg version (ARM):
31760c2415Smrg static if (GNU_ARM_EABI_Unwinder):
32760c2415Smrg 
33760c2415Smrg public import gcc.unwind.arm_common;
34760c2415Smrg import gcc.unwind.pe;
35760c2415Smrg 
36760c2415Smrg extern (C):
37760c2415Smrg @nogc:
38760c2415Smrg 
39760c2415Smrg enum int UNWIND_STACK_REG = 13;
40760c2415Smrg // Use IP as a scratch register within the personality routine.
41760c2415Smrg enum int UNWIND_POINTER_REG = 12;
42760c2415Smrg 
43760c2415Smrg version (linux)
44760c2415Smrg     enum _TTYPE_ENCODING = (DW_EH_PE_pcrel | DW_EH_PE_indirect);
45760c2415Smrg else version (NetBSD)
46760c2415Smrg     enum _TTYPE_ENCODING = (DW_EH_PE_pcrel | DW_EH_PE_indirect);
47760c2415Smrg else version (FreeBSD)
48760c2415Smrg     enum _TTYPE_ENCODING = (DW_EH_PE_pcrel | DW_EH_PE_indirect);
49760c2415Smrg else version (Symbian)
50760c2415Smrg     enum _TTYPE_ENCODING = (DW_EH_PE_absptr);
51760c2415Smrg else version (uClinux)
52760c2415Smrg     enum _TTYPE_ENCODING = (DW_EH_PE_absptr);
53760c2415Smrg else
54760c2415Smrg     enum _TTYPE_ENCODING = (DW_EH_PE_pcrel);
55760c2415Smrg 
56760c2415Smrg // Return the address of the instruction, not the actual IP value.
_Unwind_GetIP(_Unwind_Context * context)57760c2415Smrg _Unwind_Word _Unwind_GetIP(_Unwind_Context* context)
58760c2415Smrg {
59760c2415Smrg     return _Unwind_GetGR(context, 15) & ~ cast(_Unwind_Word) 1;
60760c2415Smrg }
61760c2415Smrg 
_Unwind_SetIP(_Unwind_Context * context,_Unwind_Word val)62760c2415Smrg void _Unwind_SetIP(_Unwind_Context* context, _Unwind_Word val)
63760c2415Smrg {
64760c2415Smrg     return _Unwind_SetGR(context, 15, val | (_Unwind_GetGR(context, 15) & 1));
65760c2415Smrg }
66760c2415Smrg 
_Unwind_GetIPInfo(_Unwind_Context * context,int * ip_before_insn)67760c2415Smrg _Unwind_Word _Unwind_GetIPInfo(_Unwind_Context* context, int* ip_before_insn)
68760c2415Smrg {
69760c2415Smrg     *ip_before_insn = 0;
70760c2415Smrg     return _Unwind_GetIP(context);
71760c2415Smrg }
72