This patch adds a target hook which a target can use to override the alignment of the lock-free atomic type for a given mode.

Andrew


	* hooks.c (hook_uint_mode_0): Return 0 unit hook.
	* hooks.h (hook_uint_mode_0): Prototype.
	* target.def (atomic_align_for_mode): define hook.
	* tm.texi (TARGET_ATOMIC_TYPE_FOR_MODE): Define.
	* doc/tm.texi.in (TARGET_ATOMIC_TYPE_FOR_MODE): Add.

Index: gcc/hooks.c
===================================================================
*** gcc/hooks.c	(revision 201248)
--- gcc/hooks.c	(working copy)
*************** hook_rtx_tree_int_null (tree a ATTRIBUTE
*** 352,357 ****
--- 352,364 ----
    return NULL;
  }
  
+ /* Generic hook that takes a machine mode and returns an unsigned int 0.  */
+ unsigned int
+ hook_uint_mode_0 (enum machine_mode m ATTRIBUTE_UNUSED)
+ {
+   return 0;
+ }
+ 
  /* Generic hook that takes three trees and returns the last one as is.  */
  tree
  hook_tree_tree_tree_tree_3rd_identity (tree a ATTRIBUTE_UNUSED,
Index: gcc/hooks.h
===================================================================
*** gcc/hooks.h	(revision 201248)
--- gcc/hooks.h	(working copy)
*************** extern tree hook_tree_tree_tree_tree_3rd
*** 89,94 ****
--- 89,95 ----
  extern tree hook_tree_tree_int_treep_bool_null (tree, int, tree *, bool);
  
  extern unsigned hook_uint_void_0 (void);
+ extern unsigned int hook_uint_mode_0 (enum machine_mode);
  
  extern bool default_can_output_mi_thunk_no_vcall (const_tree, HOST_WIDE_INT,
  						  HOST_WIDE_INT, const_tree);
Index: gcc/target.def
===================================================================
*** gcc/target.def	(revision 201248)
--- gcc/target.def	(working copy)
*************** DEFHOOKPOD
*** 5116,5122 ****
   @code{atomic_test_and_set} is not exactly 1, i.e. the\
   @code{bool} @code{true}.",
   unsigned char, 1)
!  
  /* Leave the boolean fields at the end.  */
  
  /* True if we can create zeroed data by switching to a BSS section
--- 5116,5134 ----
   @code{atomic_test_and_set} is not exactly 1, i.e. the\
   @code{bool} @code{true}.",
   unsigned char, 1)
! 
! /* Return an unsigned int representing the alignment (in bits) of the atomic
!    type which maps to machine MODE.  This allows alignment to be overridden
!    as needed.  */
! DEFHOOK
! (atomic_align_for_mode,
! "If defined, this function returns an appropriate alignment in bits for an\
!  atomic object of machine_mode @var{mode}.  If 0 is returned then the\
!  default alignment for the specified mode is used. ",
!  unsigned int, (enum machine_mode mode),
!  hook_uint_mode_0)
! 
! 
  /* Leave the boolean fields at the end.  */
  
  /* True if we can create zeroed data by switching to a BSS section
Index: gcc/doc/tm.texi
===================================================================
*** gcc/doc/tm.texi	(revision 201248)
--- gcc/doc/tm.texi	(working copy)
*************** It returns true if the target supports G
*** 11375,11377 ****
--- 11375,11381 ----
  The support includes the assembler, linker and dynamic linker.
  The default value of this hook is based on target's libc.
  @end deftypefn
+ 
+ @deftypefn {Target Hook} {unsigned int} TARGET_ATOMIC_ALIGN_FOR_MODE (enum machine_mode @var{mode})
+ If defined, this function returns an appropriate alignment in bits for an atomic object of machine_mode @var{mode}.  If 0 is returned then the default alignment for the specified mode is used. 
+ @end deftypefn
Index: gcc/doc/tm.texi.in
===================================================================
*** gcc/doc/tm.texi.in	(revision 201248)
--- gcc/doc/tm.texi.in	(working copy)
*************** and the associated definitions of those
*** 8415,8417 ****
--- 8415,8419 ----
  @hook TARGET_ATOMIC_TEST_AND_SET_TRUEVAL
  
  @hook TARGET_HAS_IFUNC_P
+ 
+ @hook TARGET_ATOMIC_ALIGN_FOR_MODE

Reply via email to