From: amacleod Date: Fri, 22 Nov 2013 16:19:21 +0000 (+0000) Subject: * hooks.h (hook_uint_mode_0): Add Prototype. X-Git-Tag: upstream/4.9.2~2708 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1e6e32b604687b63f6dd158e911f00536f214798;p=platform%2Fupstream%2Flinaro-gcc.git * hooks.h (hook_uint_mode_0): Add Prototype. * hooks.c (hook_uint_mode_0): New default function. * target.def (atomic_align_for_mode): New target hook. * tree.c (build_atomic_base): Add alignment override parameter. (build_common_tree_nodes): Use atomic alignment override. * doc/tm.texi.in (TARGET_ATOMIC_ALIGN_FOR_MODE): Define. * doc/tm.texi (TARGET_ATOMIC_ALIGN_FOR_MODE): Add description. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205273 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cd1fbc5..4a5c9a1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,15 @@ 2013-11-22 Andrew MacLeod + * hooks.h (hook_uint_mode_0): Add Prototype. + * hooks.c (hook_uint_mode_0): New default function. + * target.def (atomic_align_for_mode): New target hook. + * tree.c (build_atomic_base): Add alignment override parameter. + (build_common_tree_nodes): Use atomic alignment override. + * doc/tm.texi.in (TARGET_ATOMIC_ALIGN_FOR_MODE): Define. + * doc/tm.texi (TARGET_ATOMIC_ALIGN_FOR_MODE): Add description. + +2013-11-22 Andrew MacLeod + * gimple.h: Remove all includes. (recalculate_side_effects): Move prototype to gimplify.h. * Makefile.in (PLUGIN_HEADERS): Add flattened gimple.h includes. diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 35cfa99..925d93f 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -11500,6 +11500,10 @@ 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 + @deftypefn {Target Hook} void TARGET_ATOMIC_ASSIGN_EXPAND_FENV (tree *@var{hold}, tree *@var{clear}, tree *@var{update}) ISO C11 requires atomic compound assignments that may raise floating-point exceptions to raise exceptions corresponding to the arithmetic operation whose result was successfully stored in a compare-and-exchange sequence. This requires code equivalent to calls to @code{feholdexcept}, @code{feclearexcept} and @code{feupdateenv} to be generated at appropriate points in the compare-and-exchange sequence. This hook should set @code{*@var{hold}} to an expression equivalent to the call to @code{feholdexcept}, @code{*@var{clear}} to an expression equivalent to the call to @code{feclearexcept} and @code{*@var{update}} to an expression equivalent to the call to @code{feupdateenv}. The three expressions are @code{NULL_TREE} on entry to the hook and may be left as @code{NULL_TREE} if no code is required in a particular place. The default implementation leaves all three expressions as @code{NULL_TREE}. The @code{__atomic_feraiseexcept} function from @code{libatomic} may be of use as part of the code generated in @code{*@var{update}}. @end deftypefn diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index b10ecd7..edca600 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -8407,4 +8407,6 @@ and the associated definitions of those functions. @hook TARGET_HAS_IFUNC_P +@hook TARGET_ATOMIC_ALIGN_FOR_MODE + @hook TARGET_ATOMIC_ASSIGN_EXPAND_FENV diff --git a/gcc/hooks.c b/gcc/hooks.c index 9f53007..ce59503 100644 --- a/gcc/hooks.c +++ b/gcc/hooks.c @@ -358,6 +358,13 @@ hook_rtx_tree_int_null (tree a ATTRIBUTE_UNUSED, int b ATTRIBUTE_UNUSED) 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, diff --git a/gcc/hooks.h b/gcc/hooks.h index 38454fb..43191c0 100644 --- a/gcc/hooks.h +++ b/gcc/hooks.h @@ -92,6 +92,7 @@ extern tree hook_tree_tree_tree_tree_3rd_identity (tree, tree, tree); 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); diff --git a/gcc/target.def b/gcc/target.def index f6e42a1..cde4fb4 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -5297,6 +5297,17 @@ DEFHOOKPOD @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) + DEFHOOK (atomic_assign_expand_fenv, "ISO C11 requires atomic compound assignments that may raise floating-point\ diff --git a/gcc/tree.c b/gcc/tree.c index e81662e..d363cfc 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -9550,10 +9550,11 @@ make_or_reuse_accum_type (unsigned size, int unsignedp, int satp) during initialization of data types to create the 5 basic atomic types. The generic build_variant_type function requires these to already be set up in order to function properly, so cannot be - called from there. */ + called from there. If ALIGN is non-zero, then ensure alignment is + overridden to this value. */ static tree -build_atomic_base (tree type) +build_atomic_base (tree type, unsigned int align) { tree t; @@ -9564,6 +9565,9 @@ build_atomic_base (tree type) t = build_variant_type_copy (type); set_type_quals (t, TYPE_QUAL_ATOMIC); + if (align) + TYPE_ALIGN (t) = align; + return t; } @@ -9651,14 +9655,21 @@ build_common_tree_nodes (bool signed_char, bool short_double) /* Don't call build_qualified type for atomics. That routine does special processing for atomics, and until they are initialized - it's better not to make that call. */ - - atomicQI_type_node = build_atomic_base (unsigned_intQI_type_node); - atomicHI_type_node = build_atomic_base (unsigned_intHI_type_node); - atomicSI_type_node = build_atomic_base (unsigned_intSI_type_node); - atomicDI_type_node = build_atomic_base (unsigned_intDI_type_node); - atomicTI_type_node = build_atomic_base (unsigned_intTI_type_node); - + it's better not to make that call. + + Check to see if there is a target override for atomic types. */ + + atomicQI_type_node = build_atomic_base (unsigned_intQI_type_node, + targetm.atomic_align_for_mode (QImode)); + atomicHI_type_node = build_atomic_base (unsigned_intHI_type_node, + targetm.atomic_align_for_mode (HImode)); + atomicSI_type_node = build_atomic_base (unsigned_intSI_type_node, + targetm.atomic_align_for_mode (SImode)); + atomicDI_type_node = build_atomic_base (unsigned_intDI_type_node, + targetm.atomic_align_for_mode (DImode)); + atomicTI_type_node = build_atomic_base (unsigned_intTI_type_node, + targetm.atomic_align_for_mode (TImode)); + access_public_node = get_identifier ("public"); access_protected_node = get_identifier ("protected"); access_private_node = get_identifier ("private");