public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ARM/heads/morello)] Rename _Unwind_CapWord to _Unwind_Word
@ 2022-03-14 10:36 Matthew Malcomson
  0 siblings, 0 replies; only message in thread
From: Matthew Malcomson @ 2022-03-14 10:36 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:decf889aefba59328117b68ca81fbe525f7687c8

commit decf889aefba59328117b68ca81fbe525f7687c8
Author: Matthew Malcomson <matthew.malcomson@arm.com>
Date:   Mon Mar 7 18:04:44 2022 +0000

    Rename _Unwind_CapWord to _Unwind_Word
    
    This means that the API external applications saw has not changed.
    We have always called these arguments _Unwind_Word, and we maintain
    that.
    
    To summarise the changes in types that we've made in the unwinder for
    Morello:
     - _Unwind_Word and _Unwind_Ptr have both been split into two different
       types.  One for capabilities and one for non-capabilities.
     - _Unwind_Word and _Unwind_Ptr now refer to the capability forms, while
       _Unwind_WordAddr and _Unwind_Address have been introduced to refer to
       the non-capability forms.
     - On non-capability systems the capability and non-capability forms are
       the same as each other.
    (similar change for _Unwind_Word has been made for its signed version
    _Unwind_Sword).
    
    The reason we need the distinction between _Unwind_Word and _Unwind_Ptr
    is that the _Unwind_Ptr type represents a pointer at the language level,
    while an _Unwind_Word represents "whatever type the backend decided to
    use for the unwinder".  Often (e.g. in the case of AArch64 ilp32) this
    is the equivalent of GCC's Pmode rather than ptr_mode (i.e. the type
    that represents an address at the machine level rather than the type
    that represents an address at the language level).
    
    In this patch we assume that pointers for purecap targets are of the
    same mode as the Pmode equivalent for the purecap architecture.  This
    seems to be a safe assumption since otherwise how would a purecap pointer
    be implemented.
    
    Another patch will adjust the meaning of `unwind_word` inside the
    compiler to ensure that it aligns with the meaning we now give it in the
    unwinder.

Diff:
---
 libgcc/config/aarch64/aarch64-unwind.h |  2 +-
 libgcc/unwind-dw2.c                    | 64 +++++++++++++++++-----------------
 libgcc/unwind-generic.h                | 20 ++++++-----
 3 files changed, 45 insertions(+), 41 deletions(-)

diff --git a/libgcc/config/aarch64/aarch64-unwind.h b/libgcc/config/aarch64/aarch64-unwind.h
index 95fefdb3320..0a68ad77e6c 100644
--- a/libgcc/config/aarch64/aarch64-unwind.h
+++ b/libgcc/config/aarch64/aarch64-unwind.h
@@ -59,7 +59,7 @@ aarch64_cie_signed_with_b_key (struct _Unwind_Context *context)
 static inline void *
 aarch64_demangle_return_addr (struct _Unwind_Context *context,
 			      _Unwind_FrameState *fs __attribute__((unused)),
-			      _Unwind_CapWord addr_word)
+			      _Unwind_Word addr_word)
 {
   void *addr = (void *)addr_word;
   if (context->flags & RA_SIGNED_BIT)
diff --git a/libgcc/unwind-dw2.c b/libgcc/unwind-dw2.c
index 212e2981475..67057a0a230 100644
--- a/libgcc/unwind-dw2.c
+++ b/libgcc/unwind-dw2.c
@@ -85,34 +85,34 @@
     __builtin_expect((x) <= __LIBGCC_DWARF_FRAME_REGISTERS__, 1)
 
 #ifdef REG_VALUE_IN_UNWIND_CONTEXT
-typedef _Unwind_CapWord _Unwind_Context_Reg_Val;
+typedef _Unwind_Word _Unwind_Context_Reg_Val;
 
 #ifndef ASSUME_EXTENDED_UNWIND_CONTEXT
 #define ASSUME_EXTENDED_UNWIND_CONTEXT 1
 #endif
 
-static inline _Unwind_CapWord
+static inline _Unwind_Word
 _Unwind_Get_Unwind_Word (_Unwind_Context_Reg_Val val)
 {
   return val;
 }
 
 static inline _Unwind_Context_Reg_Val
-_Unwind_Get_Unwind_Context_Reg_Val (_Unwind_CapWord val)
+_Unwind_Get_Unwind_Context_Reg_Val (_Unwind_Word val)
 {
   return val;
 }
 #else
 typedef void *_Unwind_Context_Reg_Val;
 
-static inline _Unwind_CapWord
+static inline _Unwind_Word
 _Unwind_Get_Unwind_Word (_Unwind_Context_Reg_Val val)
 {
-  return (_Unwind_CapWord) (_Unwind_Internal_Ptr) val;
+  return (_Unwind_Word) (_Unwind_Internal_Ptr) val;
 }
 
 static inline _Unwind_Context_Reg_Val
-_Unwind_Get_Unwind_Context_Reg_Val (_Unwind_CapWord val)
+_Unwind_Get_Unwind_Context_Reg_Val (_Unwind_Word val)
 {
   return (_Unwind_Context_Reg_Val) (_Unwind_Internal_Ptr) val;
 }
@@ -219,7 +219,7 @@ _Unwind_IsExtendedContext (struct _Unwind_Context *context)
 \f
 /* Get the value of register REGNO as saved in CONTEXT.  */
 
-inline _Unwind_CapWord
+inline _Unwind_Word
 _Unwind_GetGR (struct _Unwind_Context *context, int regno)
 {
   int size, index;
@@ -240,7 +240,7 @@ _Unwind_GetGR (struct _Unwind_Context *context, int regno)
 
 #ifdef DWARF_LAZY_REGISTER_VALUE
   {
-    _Unwind_CapWord value;
+    _Unwind_Word value;
     if (DWARF_LAZY_REGISTER_VALUE (regno, &value))
       return value;
   }
@@ -264,7 +264,7 @@ _Unwind_GetPtr (struct _Unwind_Context *context, int index)
 
 /* Get the value of the CFA as saved in CONTEXT.  */
 
-_Unwind_CapWord
+_Unwind_Word
 _Unwind_GetCFA (struct _Unwind_Context *context)
 {
   return (_Unwind_Ptr) context->cfa;
@@ -273,7 +273,7 @@ _Unwind_GetCFA (struct _Unwind_Context *context)
 /* Overwrite the saved value for register INDEX in CONTEXT with VAL.  */
 
 inline void
-_Unwind_SetGR (struct _Unwind_Context *context, int index, _Unwind_CapWord val)
+_Unwind_SetGR (struct _Unwind_Context *context, int index, _Unwind_Word val)
 {
   int size;
   void *ptr;
@@ -294,8 +294,8 @@ _Unwind_SetGR (struct _Unwind_Context *context, int index, _Unwind_CapWord val)
     * (_Unwind_Ptr *) ptr = val;
   else
     {
-      gcc_assert (size == sizeof(_Unwind_CapWord));
-      * (_Unwind_CapWord *) ptr = val;
+      gcc_assert (size == sizeof(_Unwind_Word));
+      * (_Unwind_Word *) ptr = val;
     }
 }
 
@@ -325,7 +325,7 @@ _Unwind_SetGRPtr (struct _Unwind_Context *context, int index, void *p)
 
 static inline void
 _Unwind_SetGRValue (struct _Unwind_Context *context, int index,
-		    _Unwind_CapWord val)
+		    _Unwind_Word val)
 {
   index = DWARF_REG_TO_UNWIND_COLUMN (index);
   gcc_assert (index < (int) sizeof(dwarf_reg_size_table));
@@ -528,9 +528,9 @@ extract_cie_info (const struct dwarf_cie *cie, struct _Unwind_Context *context,
 /* Decode a DW_OP stack program.  Return the top of stack.  Push INITIAL
    onto the stack to start.  */
 
-static _Unwind_CapWord
+static _Unwind_Word
 execute_stack_op (const unsigned char *op_ptr, const unsigned char *op_end,
-		  struct _Unwind_Context *context, _Unwind_CapWord initial)
+		  struct _Unwind_Context *context, _Unwind_Word initial)
 {
   /* N.b. We make no account for capability architectures which unwind past
      frames in both non-capabiilty mode and capability mode.  I.e. frames which
@@ -542,7 +542,7 @@ execute_stack_op (const unsigned char *op_ptr, const unsigned char *op_end,
      want to read an address-sized object, for others we woud want to read a
      capability-sized object.  */
 
-  _Unwind_CapWord stack[64];	/* ??? Assume this is enough.  */
+  _Unwind_Word stack[64];	/* ??? Assume this is enough.  */
   int stack_elt;
 
   stack[0] = initial;
@@ -551,7 +551,7 @@ execute_stack_op (const unsigned char *op_ptr, const unsigned char *op_end,
   while (op_ptr < op_end)
     {
       enum dwarf_location_atom op = *op_ptr++;
-      _Unwind_CapWord result;
+      _Unwind_Word result;
       _uleb128_t reg, utmp;
       _sleb128_t offset, stmp;
 
@@ -602,7 +602,7 @@ execute_stack_op (const unsigned char *op_ptr, const unsigned char *op_end,
 	     than try to carry on.  If it gets seen by our users we'll look
 	     into why GCC is emitting such a directive.  The `read_pointer`
 	     call crashes for us.  */
-	  result = (_Unwind_CapWord) (_Unwind_Ptr) read_pointer (op_ptr);
+	  result = (_Unwind_Word) (_Unwind_Ptr) read_pointer (op_ptr);
 	  op_ptr += sizeof (void *);
 	  break;
 
@@ -648,11 +648,11 @@ execute_stack_op (const unsigned char *op_ptr, const unsigned char *op_end,
 	  break;
 	case DW_OP_constu:
 	  op_ptr = read_uleb128 (op_ptr, &utmp);
-	  result = (_Unwind_CapWord)utmp;
+	  result = (_Unwind_Word)utmp;
 	  break;
 	case DW_OP_consts:
 	  op_ptr = read_sleb128 (op_ptr, &stmp);
-	  result = (_Unwind_CapSword)stmp;
+	  result = (_Unwind_Sword)stmp;
 	  break;
 
 	case DW_OP_reg0:
@@ -758,7 +758,7 @@ execute_stack_op (const unsigned char *op_ptr, const unsigned char *op_end,
 
 	case DW_OP_swap:
 	  {
-	    _Unwind_CapWord t;
+	    _Unwind_Word t;
 	    gcc_assert (stack_elt >= 2);
 	    t = stack[stack_elt - 1];
 	    stack[stack_elt - 1] = stack[stack_elt - 2];
@@ -768,7 +768,7 @@ execute_stack_op (const unsigned char *op_ptr, const unsigned char *op_end,
 
 	case DW_OP_rot:
 	  {
-	    _Unwind_CapWord t1, t2, t3;
+	    _Unwind_Word t1, t2, t3;
 
 	    gcc_assert (stack_elt >= 3);
 	    t1 = stack[stack_elt - 1];
@@ -825,7 +825,7 @@ execute_stack_op (const unsigned char *op_ptr, const unsigned char *op_end,
 	      break;
 
 	    case DW_OP_abs:
-	      if ((_Unwind_CapSword) result < 0)
+	      if ((_Unwind_Sword) result < 0)
 		result = -result;
 	      break;
 	    case DW_OP_neg:
@@ -877,7 +877,7 @@ execute_stack_op (const unsigned char *op_ptr, const unsigned char *op_end,
 		 Morello, and the unwind information it emits that ends up here
 		 for non-Morello architectures is done in the order that would
 		 satisfy the provenance choice above.  */
-	    _Unwind_CapWord second;
+	    _Unwind_Word second;
 	    _Unwind_WordAddr first;
 	    gcc_assert (stack_elt >= 2);
 	    stack_elt -= 2;
@@ -891,7 +891,7 @@ execute_stack_op (const unsigned char *op_ptr, const unsigned char *op_end,
 		result = second & first;
 		break;
 	      case DW_OP_div:
-		result = (_Unwind_CapSword) second / (_Unwind_SwordAddr) first;
+		result = (_Unwind_Sword) second / (_Unwind_SwordAddr) first;
 		break;
 	      case DW_OP_minus:
 		result = second - first;
@@ -915,7 +915,7 @@ execute_stack_op (const unsigned char *op_ptr, const unsigned char *op_end,
 		result = second >> first;
 		break;
 	      case DW_OP_shra:
-		result = (_Unwind_CapSword) second >> first;
+		result = (_Unwind_Sword) second >> first;
 		break;
 	      case DW_OP_xor:
 		result = second ^ first;
@@ -1026,7 +1026,7 @@ execute_cfa_program (const unsigned char *insn_ptr,
 	{
 	  reg = insn & 0x3f;
 	  insn_ptr = read_uleb128 (insn_ptr, &utmp);
-	  offset = (_Unwind_Sword) utmp * fs->data_align;
+	  offset = (_Unwind_SwordAddr) utmp * fs->data_align;
 	  reg = DWARF_REG_TO_UNWIND_COLUMN (reg);
 	  if (UNWIND_COLUMN_IN_RANGE (reg))
 	    {
@@ -1069,7 +1069,7 @@ execute_cfa_program (const unsigned char *insn_ptr,
 	case DW_CFA_offset_extended:
 	  insn_ptr = read_uleb128 (insn_ptr, &reg);
 	  insn_ptr = read_uleb128 (insn_ptr, &utmp);
-	  offset = (_Unwind_Sword) utmp * fs->data_align;
+	  offset = (_Unwind_SwordAddr) utmp * fs->data_align;
 	  reg = DWARF_REG_TO_UNWIND_COLUMN (reg);
 	  if (UNWIND_COLUMN_IN_RANGE (reg))
 	    {
@@ -1199,14 +1199,14 @@ execute_cfa_program (const unsigned char *insn_ptr,
 	  insn_ptr = read_uleb128 (insn_ptr, &utmp);
 	  fs->regs.cfa_reg = (_Unwind_Reg)utmp;
 	  insn_ptr = read_sleb128 (insn_ptr, &stmp);
-	  fs->regs.cfa_offset = (_Unwind_Sword)stmp;
+	  fs->regs.cfa_offset = (_Unwind_SwordAddr)stmp;
 	  fs->regs.cfa_how = CFA_REG_OFFSET;
 	  fs->regs.cfa_offset *= fs->data_align;
 	  break;
 
 	case DW_CFA_def_cfa_offset_sf:
 	  insn_ptr = read_sleb128 (insn_ptr, &stmp);
-	  fs->regs.cfa_offset = (_Unwind_Sword)stmp;
+	  fs->regs.cfa_offset = (_Unwind_SwordAddr)stmp;
 	  fs->regs.cfa_offset *= fs->data_align;
 	  /* cfa_how deliberately not set.  */
 	  break;
@@ -1214,7 +1214,7 @@ execute_cfa_program (const unsigned char *insn_ptr,
 	case DW_CFA_val_offset:
 	  insn_ptr = read_uleb128 (insn_ptr, &reg);
 	  insn_ptr = read_uleb128 (insn_ptr, &utmp);
-	  offset = (_Unwind_Sword) utmp * fs->data_align;
+	  offset = (_Unwind_SwordAddr) utmp * fs->data_align;
 	  reg = DWARF_REG_TO_UNWIND_COLUMN (reg);
 	  if (UNWIND_COLUMN_IN_RANGE (reg))
 	    {
@@ -1588,7 +1588,7 @@ uw_update_context (struct _Unwind_Context *context, _Unwind_FrameState *fs)
 	 can change from frame to frame.  */
       void *ret_addr;
 #ifdef MD_DEMANGLE_RETURN_ADDR
-      _Unwind_CapWord ra = _Unwind_GetGR (context, fs->retaddr_column);
+      _Unwind_Word ra = _Unwind_GetGR (context, fs->retaddr_column);
       ret_addr = MD_DEMANGLE_RETURN_ADDR (context, fs, ra);
 #else
       ret_addr = _Unwind_GetPtr (context, fs->retaddr_column);
diff --git a/libgcc/unwind-generic.h b/libgcc/unwind-generic.h
index 57e3fe8bcf9..74268462cc7 100644
--- a/libgcc/unwind-generic.h
+++ b/libgcc/unwind-generic.h
@@ -45,10 +45,14 @@ extern "C" {
 
 /* @@@ The IA-64 ABI uses uint64 throughout.  Most places this is
    inefficient for 32-bit and smaller machines.  */
+#ifdef __CHERI_PURE_CAPABILITY__
+typedef __UINTPTR_TYPE__ _Unwind_Word;
+typedef __INTPTR_TYPE__ _Unwind_Sword;
+#else
 typedef unsigned _Unwind_Word __attribute__((__mode__(__unwind_word__)));
-typedef __UINTPTR_TYPE__ _Unwind_CapWord;
 typedef signed _Unwind_Sword __attribute__((__mode__(__unwind_word__)));
-typedef __INTPTR_TYPE__ _Unwind_CapSword;
+#endif
+
 #if defined(__ia64__) && defined(__hpux__)
 typedef unsigned _Unwind_Ptr __attribute__((__mode__(__word__)));
 typedef unsigned _Unwind_Address __attribute__((__mode__(__word__)));
@@ -97,10 +101,10 @@ struct _Unwind_Exception
   _Unwind_Exception_Cleanup_Fn exception_cleanup;
 
 #if !defined (__USING_SJLJ_EXCEPTIONS__) && defined (__SEH__)
-  _Unwind_CapWord private_[6];
+  _Unwind_Word private_[6];
 #else
-  _Unwind_CapWord private_1;
-  _Unwind_CapWord private_2;
+  _Unwind_Word private_1;
+  _Unwind_Word private_2;
 #endif
 
   /* @@@ The IA-64 ABI says that this structure must be double-word aligned.
@@ -171,15 +175,15 @@ _Unwind_Backtrace (_Unwind_Trace_Fn, void *);
    the unwind library and the personality routine and landing pad.  Only
    selected registers may be manipulated.  */
 
-extern _Unwind_CapWord _Unwind_GetGR (struct _Unwind_Context *, int);
-extern void _Unwind_SetGR (struct _Unwind_Context *, int, _Unwind_CapWord);
+extern _Unwind_Word _Unwind_GetGR (struct _Unwind_Context *, int);
+extern void _Unwind_SetGR (struct _Unwind_Context *, int, _Unwind_Word);
 
 extern _Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *);
 extern _Unwind_Ptr _Unwind_GetIPInfo (struct _Unwind_Context *, int *);
 extern void _Unwind_SetIP (struct _Unwind_Context *, _Unwind_Ptr);
 
 /* @@@ Retrieve the CFA of the given context.  */
-extern _Unwind_CapWord _Unwind_GetCFA (struct _Unwind_Context *);
+extern _Unwind_Word _Unwind_GetCFA (struct _Unwind_Context *);
 
 extern void *_Unwind_GetLanguageSpecificData (struct _Unwind_Context *);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-03-14 10:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-14 10:36 [gcc(refs/vendors/ARM/heads/morello)] Rename _Unwind_CapWord to _Unwind_Word Matthew Malcomson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).