hooks.h (hook_uint_mode_0): Add Prototype.

* 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.

From-SVN: r205273
This commit is contained in:
Andrew MacLeod 2013-11-22 16:19:21 +00:00 committed by Andrew Macleod
parent 2fb9a547b4
commit fceec4d3d7
7 changed files with 55 additions and 9 deletions

View File

@ -1,3 +1,13 @@
2013-11-22 Andrew MacLeod <amacleod@redhat.com>
* 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 <amacleod@redhat.com> 2013-11-22 Andrew MacLeod <amacleod@redhat.com>
* gimple.h: Remove all includes. * gimple.h: Remove all includes.

View File

@ -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. The default value of this hook is based on target's libc.
@end deftypefn @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}) @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}}. 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 @end deftypefn

View File

@ -8407,4 +8407,6 @@ and the associated definitions of those functions.
@hook TARGET_HAS_IFUNC_P @hook TARGET_HAS_IFUNC_P
@hook TARGET_ATOMIC_ALIGN_FOR_MODE
@hook TARGET_ATOMIC_ASSIGN_EXPAND_FENV @hook TARGET_ATOMIC_ASSIGN_EXPAND_FENV

View File

@ -358,6 +358,13 @@ hook_rtx_tree_int_null (tree a ATTRIBUTE_UNUSED, int b ATTRIBUTE_UNUSED)
return NULL; 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. */ /* Generic hook that takes three trees and returns the last one as is. */
tree tree
hook_tree_tree_tree_tree_3rd_identity (tree a ATTRIBUTE_UNUSED, hook_tree_tree_tree_tree_3rd_identity (tree a ATTRIBUTE_UNUSED,

View File

@ -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 tree hook_tree_tree_int_treep_bool_null (tree, int, tree *, bool);
extern unsigned hook_uint_void_0 (void); 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, extern bool default_can_output_mi_thunk_no_vcall (const_tree, HOST_WIDE_INT,
HOST_WIDE_INT, const_tree); HOST_WIDE_INT, const_tree);

View File

@ -5297,6 +5297,17 @@ DEFHOOKPOD
@code{bool} @code{true}.", @code{bool} @code{true}.",
unsigned char, 1) 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 DEFHOOK
(atomic_assign_expand_fenv, (atomic_assign_expand_fenv,
"ISO C11 requires atomic compound assignments that may raise floating-point\ "ISO C11 requires atomic compound assignments that may raise floating-point\

View File

@ -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 during initialization of data types to create the 5 basic atomic
types. The generic build_variant_type function requires these to types. The generic build_variant_type function requires these to
already be set up in order to function properly, so cannot be 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 static tree
build_atomic_base (tree type) build_atomic_base (tree type, unsigned int align)
{ {
tree t; tree t;
@ -9564,6 +9565,9 @@ build_atomic_base (tree type)
t = build_variant_type_copy (type); t = build_variant_type_copy (type);
set_type_quals (t, TYPE_QUAL_ATOMIC); set_type_quals (t, TYPE_QUAL_ATOMIC);
if (align)
TYPE_ALIGN (t) = align;
return t; 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 /* Don't call build_qualified type for atomics. That routine does
special processing for atomics, and until they are initialized special processing for atomics, and until they are initialized
it's better not to make that call. */ it's better not to make that call.
atomicQI_type_node = build_atomic_base (unsigned_intQI_type_node); Check to see if there is a target override for atomic types. */
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);
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_public_node = get_identifier ("public");
access_protected_node = get_identifier ("protected"); access_protected_node = get_identifier ("protected");
access_private_node = get_identifier ("private"); access_private_node = get_identifier ("private");