Path: blob/main/contrib/llvm-project/libunwind/include/unwind_arm_ehabi.h
35148 views
//===----------------------------------------------------------------------===//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//7// C++ ABI Level 1 ABI documented at:8// https://github.com/ARM-software/abi-aa/blob/main/ehabi32/ehabi32.rst9//10//===----------------------------------------------------------------------===//1112#ifndef __ARM_EHABI_UNWIND_H__13#define __ARM_EHABI_UNWIND_H__1415typedef uint32_t _Unwind_State;1617static const _Unwind_State _US_VIRTUAL_UNWIND_FRAME = 0;18static const _Unwind_State _US_UNWIND_FRAME_STARTING = 1;19static const _Unwind_State _US_UNWIND_FRAME_RESUME = 2;20static const _Unwind_State _US_ACTION_MASK = 3;21/* Undocumented flag for force unwinding. */22static const _Unwind_State _US_FORCE_UNWIND = 8;2324typedef uint32_t _Unwind_EHT_Header;25/*26* gcc_personality_v0 references 'struct _Unwind_Exception' all over the place.27* Nothing in libunwind cares about 'struct _Unwind_Control_Block,' so make it28* the alias of struct _Unwind_Exception, instead of the other way around.29*/30struct _Unwind_Exception;31typedef struct _Unwind_Exception _Unwind_Exception;32typedef struct _Unwind_Exception _Unwind_Control_Block; /* Alias */33typedef uint8_t _Unwind_Exception_Class[8];3435struct _Unwind_Exception {36_Unwind_Exception_Class exception_class;37void (*exception_cleanup)(_Unwind_Reason_Code, _Unwind_Control_Block*);3839/* Unwinder cache, private fields for the unwinder's use */40struct {41uint32_t reserved1; /* init reserved1 to 0, then don't touch */42uint32_t reserved2;43uint32_t reserved3;44uint32_t reserved4;45uint32_t reserved5;46} unwinder_cache;4748/* Propagation barrier cache (valid after phase 1): */49struct {50uint32_t sp;51uint32_t bitpattern[5];52} barrier_cache;5354/* Cleanup cache (preserved over cleanup): */55struct {56uint32_t bitpattern[4];57} cleanup_cache;5859/* Pr cache (for pr's benefit): */60struct {61uint32_t fnstart; /* function start address */62_Unwind_EHT_Header* ehtp; /* pointer to EHT entry header word */63uint32_t additional;64uint32_t reserved1;65} pr_cache;6667long long int :0; /* Enforce the 8-byte alignment */68} __attribute__((__aligned__(8)));6970typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)(71_Unwind_State state, _Unwind_Exception *exceptionObject,72struct _Unwind_Context *context);7374#ifdef __cplusplus75extern "C" {76#endif7778//79// The following are the base functions documented by the C++ ABI80//81#ifdef __USING_SJLJ_EXCEPTIONS__82extern _Unwind_Reason_Code83_Unwind_SjLj_RaiseException(_Unwind_Exception *exception_object);84extern void _Unwind_SjLj_Resume(_Unwind_Exception *exception_object);85#else86extern _Unwind_Reason_Code87_Unwind_RaiseException(_Unwind_Exception *exception_object);88extern void _Unwind_Resume(_Unwind_Exception *exception_object);89#endif90extern void _Unwind_DeleteException(_Unwind_Exception *exception_object);9192typedef enum {93_UVRSC_CORE = 0, /* integer register */94_UVRSC_VFP = 1, /* vfp */95_UVRSC_WMMXD = 3, /* Intel WMMX data register */96_UVRSC_WMMXC = 4, /* Intel WMMX control register */97_UVRSC_PSEUDO = 5 /* Special purpose pseudo register */98} _Unwind_VRS_RegClass;99100typedef enum {101_UVRSD_UINT32 = 0,102_UVRSD_VFPX = 1,103_UVRSD_UINT64 = 3,104_UVRSD_FLOAT = 4,105_UVRSD_DOUBLE = 5106} _Unwind_VRS_DataRepresentation;107108typedef enum {109_UVRSR_OK = 0,110_UVRSR_NOT_IMPLEMENTED = 1,111_UVRSR_FAILED = 2112} _Unwind_VRS_Result;113114extern void _Unwind_Complete(_Unwind_Exception* exception_object);115116extern _Unwind_VRS_Result117_Unwind_VRS_Get(_Unwind_Context *context, _Unwind_VRS_RegClass regclass,118uint32_t regno, _Unwind_VRS_DataRepresentation representation,119void *valuep);120121extern _Unwind_VRS_Result122_Unwind_VRS_Set(_Unwind_Context *context, _Unwind_VRS_RegClass regclass,123uint32_t regno, _Unwind_VRS_DataRepresentation representation,124void *valuep);125126extern _Unwind_VRS_Result127_Unwind_VRS_Pop(_Unwind_Context *context, _Unwind_VRS_RegClass regclass,128uint32_t discriminator,129_Unwind_VRS_DataRepresentation representation);130131#if defined(_LIBUNWIND_UNWIND_LEVEL1_EXTERNAL_LINKAGE)132#define _LIBUNWIND_EXPORT_UNWIND_LEVEL1 extern133#else134#define _LIBUNWIND_EXPORT_UNWIND_LEVEL1 static __inline__135#endif136137// These are de facto helper functions for ARM, which delegate the function138// calls to _Unwind_VRS_Get/Set(). These are not a part of ARM EHABI139// specification, thus these function MUST be inlined. Please don't replace140// these with the "extern" function declaration; otherwise, the program141// including this <unwind.h> header won't be ABI compatible and will result in142// link error when we are linking the program with libgcc.143144_LIBUNWIND_EXPORT_UNWIND_LEVEL1145uintptr_t _Unwind_GetGR(struct _Unwind_Context *context, int index) {146uintptr_t value = 0;147_Unwind_VRS_Get(context, _UVRSC_CORE, (uint32_t)index, _UVRSD_UINT32, &value);148return value;149}150151_LIBUNWIND_EXPORT_UNWIND_LEVEL1152void _Unwind_SetGR(struct _Unwind_Context *context, int index,153uintptr_t value) {154_Unwind_VRS_Set(context, _UVRSC_CORE, (uint32_t)index, _UVRSD_UINT32, &value);155}156157_LIBUNWIND_EXPORT_UNWIND_LEVEL1158uintptr_t _Unwind_GetIP(struct _Unwind_Context *context) {159// remove the thumb-bit before returning160return _Unwind_GetGR(context, 15) & (~(uintptr_t)0x1);161}162163_LIBUNWIND_EXPORT_UNWIND_LEVEL1164void _Unwind_SetIP(struct _Unwind_Context *context, uintptr_t value) {165uintptr_t thumb_bit = _Unwind_GetGR(context, 15) & ((uintptr_t)0x1);166_Unwind_SetGR(context, 15, value | thumb_bit);167}168169#ifdef __cplusplus170}171#endif172173#endif // __ARM_EHABI_UNWIND_H__174175176