Skip to content
This repository has been archived by the owner on Jun 20, 2019. It is now read-only.

Commit

Permalink
Add lang_hook get alias set.
Browse files Browse the repository at this point in the history
  • Loading branch information
Iain Buclaw committed Dec 5, 2013
1 parent 4113119 commit 926baf6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
5 changes: 5 additions & 0 deletions gcc/d/ChangeLog
@@ -1,3 +1,8 @@
2013-12-05 Iain Buclaw <ibuclaw@gdcproject.org>

* d-lang.cc(d_init_options_struct): Don't define strict aliasing.
(d_get_alias_set): New function to return language-specific alias set.

2013-12-04 Iain Buclaw <ibuclaw@gdcproject.org>

* d-codegen.cc(maybe_set_builtin_frontend): Assert that all runtime
Expand Down
29 changes: 26 additions & 3 deletions gcc/d/d-lang.cc
Expand Up @@ -73,6 +73,7 @@ const attribute_spec d_attribute_table[] =
#undef LANG_HOOKS_COMMON_ATTRIBUTE_TABLE
#undef LANG_HOOKS_ATTRIBUTE_TABLE
#undef LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE
#undef LANG_HOOKS_GET_ALIAS_SET
#undef LANG_HOOKS_TYPES_COMPATIBLE_P
#undef LANG_HOOKS_BUILTIN_FUNCTION
#undef LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE
Expand All @@ -96,6 +97,7 @@ const attribute_spec d_attribute_table[] =
#define LANG_HOOKS_COMMON_ATTRIBUTE_TABLE d_builtins_attribute_table
#define LANG_HOOKS_ATTRIBUTE_TABLE d_attribute_table
#define LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE d_format_attribute_table
#define LANG_HOOKS_GET_ALIAS_SET d_get_alias_set
#define LANG_HOOKS_TYPES_COMPATIBLE_P d_types_compatible_p
#define LANG_HOOKS_BUILTIN_FUNCTION d_builtin_function
#define LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE d_builtin_function
Expand Down Expand Up @@ -195,9 +197,6 @@ d_init_options_struct (gcc_options *opts)

// Honour left to right code evaluation.
opts->x_flag_evaluation_order = 1;

// Default to using strict aliasing.
opts->x_flag_strict_aliasing = 1;
}

static void
Expand Down Expand Up @@ -1549,6 +1548,30 @@ d_getdecls (void)
}


// Get the alias set corresponding to a type or expression.
// Return -1 if we don't do anything special.

static alias_set_type
d_get_alias_set (tree t)
{
// Permit type-punning when accessing a union, provided the access
// is directly through the union.
for (tree u = t; handled_component_p (u); u = TREE_OPERAND (u, 0))
{
if (TREE_CODE (u) == COMPONENT_REF
&& TREE_CODE (TREE_TYPE (TREE_OPERAND (u, 0))) == UNION_TYPE)
return 0;
}

// That's all the expressions we handle.
if (!TYPE_P (t))
return get_alias_set (TREE_TYPE (t));

// For now in D, assume everything aliases everything else,
// until we define some solid rules.
return 0;
}

static int
d_types_compatible_p (tree t1, tree t2)
{
Expand Down

0 comments on commit 926baf6

Please sign in to comment.