Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:57:06

0001 //===----------------------------------------------------------------------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //
0008 // C++ ABI Level 1 ABI documented at:
0009 //   https://github.com/ARM-software/abi-aa/blob/main/ehabi32/ehabi32.rst
0010 //
0011 //===----------------------------------------------------------------------===//
0012 
0013 #ifndef __ARM_EHABI_UNWIND_H__
0014 #define __ARM_EHABI_UNWIND_H__
0015 
0016 typedef uint32_t _Unwind_State;
0017 
0018 static const _Unwind_State _US_VIRTUAL_UNWIND_FRAME   = 0;
0019 static const _Unwind_State _US_UNWIND_FRAME_STARTING  = 1;
0020 static const _Unwind_State _US_UNWIND_FRAME_RESUME    = 2;
0021 static const _Unwind_State _US_ACTION_MASK            = 3;
0022 /* Undocumented flag for force unwinding. */
0023 static const _Unwind_State _US_FORCE_UNWIND           = 8;
0024 
0025 typedef uint32_t _Unwind_EHT_Header;
0026 
0027 struct _Unwind_Control_Block;
0028 typedef struct _Unwind_Control_Block _Unwind_Control_Block;
0029 #define _Unwind_Exception _Unwind_Control_Block /* Alias */
0030 typedef uint8_t _Unwind_Exception_Class[8];
0031 
0032 struct _Unwind_Control_Block {
0033   _Unwind_Exception_Class exception_class;
0034   void (*exception_cleanup)(_Unwind_Reason_Code, _Unwind_Control_Block*);
0035 
0036   /* Unwinder cache, private fields for the unwinder's use */
0037   struct {
0038     uint32_t reserved1; /* init reserved1 to 0, then don't touch */
0039     uint32_t reserved2;
0040     uint32_t reserved3;
0041     uint32_t reserved4;
0042     uint32_t reserved5;
0043   } unwinder_cache;
0044 
0045   /* Propagation barrier cache (valid after phase 1): */
0046   struct {
0047     uint32_t sp;
0048     uint32_t bitpattern[5];
0049   } barrier_cache;
0050 
0051   /* Cleanup cache (preserved over cleanup): */
0052   struct {
0053     uint32_t bitpattern[4];
0054   } cleanup_cache;
0055 
0056   /* Pr cache (for pr's benefit): */
0057   struct {
0058     uint32_t fnstart; /* function start address */
0059     _Unwind_EHT_Header* ehtp; /* pointer to EHT entry header word */
0060     uint32_t additional;
0061     uint32_t reserved1;
0062   } pr_cache;
0063 
0064   long long int :0; /* Enforce the 8-byte alignment */
0065 } __attribute__((__aligned__(8)));
0066 
0067 typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)(
0068     _Unwind_State state, _Unwind_Exception *exceptionObject,
0069     struct _Unwind_Context *context);
0070 
0071 #ifdef __cplusplus
0072 extern "C" {
0073 #endif
0074 
0075 //
0076 // The following are the base functions documented by the C++ ABI
0077 //
0078 #ifdef __USING_SJLJ_EXCEPTIONS__
0079 extern _Unwind_Reason_Code
0080     _Unwind_SjLj_RaiseException(_Unwind_Exception *exception_object);
0081 extern void _Unwind_SjLj_Resume(_Unwind_Exception *exception_object);
0082 #else
0083 extern _Unwind_Reason_Code
0084     _Unwind_RaiseException(_Unwind_Exception *exception_object);
0085 extern void _Unwind_Resume(_Unwind_Exception *exception_object);
0086 #endif
0087 extern void _Unwind_DeleteException(_Unwind_Exception *exception_object);
0088 
0089 typedef enum {
0090   _UVRSC_CORE = 0,  /* integer register */
0091   _UVRSC_VFP = 1,   /* vfp */
0092   _UVRSC_WMMXD = 3, /* Intel WMMX data register */
0093   _UVRSC_WMMXC = 4, /* Intel WMMX control register */
0094   _UVRSC_PSEUDO = 5 /* Special purpose pseudo register */
0095 } _Unwind_VRS_RegClass;
0096 
0097 typedef enum {
0098   _UVRSD_UINT32 = 0,
0099   _UVRSD_VFPX = 1,
0100   _UVRSD_UINT64 = 3,
0101   _UVRSD_FLOAT = 4,
0102   _UVRSD_DOUBLE = 5
0103 } _Unwind_VRS_DataRepresentation;
0104 
0105 typedef enum {
0106   _UVRSR_OK = 0,
0107   _UVRSR_NOT_IMPLEMENTED = 1,
0108   _UVRSR_FAILED = 2
0109 } _Unwind_VRS_Result;
0110 
0111 extern void _Unwind_Complete(_Unwind_Exception* exception_object);
0112 
0113 extern _Unwind_VRS_Result
0114 _Unwind_VRS_Get(_Unwind_Context *context, _Unwind_VRS_RegClass regclass,
0115                 uint32_t regno, _Unwind_VRS_DataRepresentation representation,
0116                 void *valuep);
0117 
0118 extern _Unwind_VRS_Result
0119 _Unwind_VRS_Set(_Unwind_Context *context, _Unwind_VRS_RegClass regclass,
0120                 uint32_t regno, _Unwind_VRS_DataRepresentation representation,
0121                 void *valuep);
0122 
0123 extern _Unwind_VRS_Result
0124 _Unwind_VRS_Pop(_Unwind_Context *context, _Unwind_VRS_RegClass regclass,
0125                 uint32_t discriminator,
0126                 _Unwind_VRS_DataRepresentation representation);
0127 
0128 #if defined(_LIBUNWIND_UNWIND_LEVEL1_EXTERNAL_LINKAGE)
0129 #define _LIBUNWIND_EXPORT_UNWIND_LEVEL1 extern
0130 #else
0131 #define _LIBUNWIND_EXPORT_UNWIND_LEVEL1 static __inline__
0132 #endif
0133 
0134 // These are de facto helper functions for ARM, which delegate the function
0135 // calls to _Unwind_VRS_Get/Set().  These are not a part of ARM EHABI
0136 // specification, thus these function MUST be inlined.  Please don't replace
0137 // these with the "extern" function declaration; otherwise, the program
0138 // including this <unwind.h> header won't be ABI compatible and will result in
0139 // link error when we are linking the program with libgcc.
0140 
0141 _LIBUNWIND_EXPORT_UNWIND_LEVEL1
0142 uintptr_t _Unwind_GetGR(struct _Unwind_Context *context, int index) {
0143   uintptr_t value = 0;
0144   _Unwind_VRS_Get(context, _UVRSC_CORE, (uint32_t)index, _UVRSD_UINT32, &value);
0145   return value;
0146 }
0147 
0148 _LIBUNWIND_EXPORT_UNWIND_LEVEL1
0149 void _Unwind_SetGR(struct _Unwind_Context *context, int index,
0150                    uintptr_t value) {
0151   _Unwind_VRS_Set(context, _UVRSC_CORE, (uint32_t)index, _UVRSD_UINT32, &value);
0152 }
0153 
0154 _LIBUNWIND_EXPORT_UNWIND_LEVEL1
0155 uintptr_t _Unwind_GetIP(struct _Unwind_Context *context) {
0156   // remove the thumb-bit before returning
0157   return _Unwind_GetGR(context, 15) & (~(uintptr_t)0x1);
0158 }
0159 
0160 _LIBUNWIND_EXPORT_UNWIND_LEVEL1
0161 void _Unwind_SetIP(struct _Unwind_Context *context, uintptr_t value) {
0162   uintptr_t thumb_bit = _Unwind_GetGR(context, 15) & ((uintptr_t)0x1);
0163   _Unwind_SetGR(context, 15, value | thumb_bit);
0164 }
0165 
0166 #ifdef __cplusplus
0167 }
0168 #endif
0169 
0170 #endif // __ARM_EHABI_UNWIND_H__