This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Add __builtin_update_setjmp_buf for Ada


This means there's one less complexity for Ada's tree-ssa conversion.

2004-04-26  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>

	* builtins.c (expand_builtin_update_setjmp_buf): New function.
	(expand_builtin, case BUILT_IN_UPDATE_SETJMP_BUF): New case.
	* builtins.def (BUILT_IN_UPDATE_SETJMP_BUF): New code.

*** builtins.c	23 Apr 2004 22:50:06 -0000	1.314
--- builtins.c	26 Apr 2004 17:47:24 -0000
*************** static rtx result_vector (int, rtx);
*** 85,88 ****
--- 85,89 ----
  #endif
  static rtx expand_builtin_setjmp (tree, rtx);
+ static void expand_builtin_update_setjmp_buf (rtx);
  static void expand_builtin_prefetch (tree);
  static rtx expand_builtin_apply_args (void);
*************** expand_builtin_longjmp (rtx buf_addr, rt
*** 739,742 ****
--- 740,777 ----
  }
  
+ /* __builtin_update_setjmp_buf is passed a pointer to an array of five words
+    (not all will be used on all machines) that was passed to __builtin_setjmp.
+    It updates the stack pointer in that block to correspond to the current
+    stack pointer.  */
+ 
+ static void
+ expand_builtin_update_setjmp_buf (rtx buf_addr)
+ {
+   enum machine_mode sa_mode = Pmode;
+   rtx stack_save;
+ 
+ 
+ #ifdef HAVE_save_stack_nonlocal
+   if (HAVE_save_stack_nonlocal)
+     sa_mode = insn_data[(int) CODE_FOR_save_stack_nonlocal].operand[0].mode;
+ #endif
+ #ifdef STACK_SAVEAREA_MODE
+   sa_mode = STACK_SAVEAREA_MODE (SAVE_NONLOCAL);
+ #endif
+ 
+   stack_save
+     = gen_rtx_MEM (sa_mode,
+ 		   memory_address
+ 		   (sa_mode,
+ 		    plus_constant (buf_addr, 2 * GET_MODE_SIZE (Pmode))));
+ 
+ #ifdef HAVE_setjmp
+   if (HAVE_setjmp)
+     emit_insn (gen_setjmp ());
+ #endif
+ 
+   emit_stack_save (SAVE_NONLOCAL, &stack_save, NULL_RTX);
+ }
+ 
  /* Expand a call to __builtin_prefetch.  For a target that does not support
     data prefetch, evaluate the memory address argument in case it has side
*************** expand_builtin (tree exp, rtx target, rt
*** 5621,5624 ****
--- 5656,5672 ----
  	  return const0_rtx;
  	}
+ 
+       /* This updates the setjmp buffer that is its argument with the value
+ 	 of the current stack pointer.  */
+     case BUILT_IN_UPDATE_SETJMP_BUF:
+       if (validate_arglist (arglist, POINTER_TYPE, VOID_TYPE))
+ 	{
+ 	  rtx buf_addr
+ 	    = expand_expr (TREE_VALUE (arglist), NULL_RTX, VOIDmode, 0);
+ 
+ 	  expand_builtin_update_setjmp_buf (buf_addr);
+ 	  return const0_rtx;
+ 	}
+       break;
  
      case BUILT_IN_TRAP:
*** builtins.def	23 Apr 2004 22:50:07 -0000	1.81
--- builtins.def	26 Apr 2004 17:47:25 -0000
*************** DEF_LIB_BUILTIN        (BUILT_IN_STRFTIM
*** 599,602 ****
--- 599,603 ----
  DEF_GCC_BUILTIN        (BUILT_IN_TRAP, "trap", BT_FN_VOID, ATTR_NORETURN_NOTHROW_LIST)
  DEF_GCC_BUILTIN        (BUILT_IN_UNWIND_INIT, "unwind_init", BT_FN_VOID, ATTR_NULL)
+ DEF_GCC_BUILTIN        (BUILT_IN_UPDATE_SETJMP_BUF, "update_setjmp_buf", BT_FN_VOID_PTR_INT, ATTR_NULL)
  DEF_GCC_BUILTIN        (BUILT_IN_VA_COPY, "va_copy", BT_FN_VOID_VALIST_REF_VALIST_ARG, ATTR_NULL)
  DEF_GCC_BUILTIN        (BUILT_IN_VA_END, "va_end", BT_FN_VOID_VALIST_REF, ATTR_NULL)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]