aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 8afba59..31ac424 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -6792,9 +6792,10 @@ operation_no_trapping_overflow (tree type, enum tree_code code)
constructed by language-dependent code, not here.) */
/* Construct, lay out and return the type of pointers to TO_TYPE with
- mode MODE. If CAN_ALIAS_ALL is TRUE, indicate this type can
- reference all of memory. If such a type has already been
- constructed, reuse it. */
+ mode MODE. If MODE is VOIDmode, a pointer mode for the address
+ space of TO_TYPE will be picked. If CAN_ALIAS_ALL is TRUE,
+ indicate this type can reference all of memory. If such a type has
+ already been constructed, reuse it. */
tree
build_pointer_type_for_mode (tree to_type, machine_mode mode,
@@ -6806,6 +6807,12 @@ build_pointer_type_for_mode (tree to_type, machine_mode mode,
if (to_type == error_mark_node)
return error_mark_node;
+ if (mode == VOIDmode)
+ {
+ addr_space_t as = TYPE_ADDR_SPACE (to_type);
+ mode = targetm.addr_space.pointer_mode (as);
+ }
+
/* If the pointed-to type has the may_alias attribute set, force
a TYPE_REF_CAN_ALIAS_ALL pointer to be generated. */
if (lookup_attribute ("may_alias", TYPE_ATTRIBUTES (to_type)))
@@ -6857,10 +6864,7 @@ build_pointer_type_for_mode (tree to_type, machine_mode mode,
tree
build_pointer_type (tree to_type)
{
- addr_space_t as = to_type == error_mark_node? ADDR_SPACE_GENERIC
- : TYPE_ADDR_SPACE (to_type);
- machine_mode pointer_mode = targetm.addr_space.pointer_mode (as);
- return build_pointer_type_for_mode (to_type, pointer_mode, false);
+ return build_pointer_type_for_mode (to_type, VOIDmode, false);
}
/* Same as build_pointer_type_for_mode, but for REFERENCE_TYPE. */
@@ -6875,6 +6879,12 @@ build_reference_type_for_mode (tree to_type, machine_mode mode,
if (to_type == error_mark_node)
return error_mark_node;
+ if (mode == VOIDmode)
+ {
+ addr_space_t as = TYPE_ADDR_SPACE (to_type);
+ mode = targetm.addr_space.pointer_mode (as);
+ }
+
/* If the pointed-to type has the may_alias attribute set, force
a TYPE_REF_CAN_ALIAS_ALL pointer to be generated. */
if (lookup_attribute ("may_alias", TYPE_ATTRIBUTES (to_type)))
@@ -6926,10 +6936,7 @@ build_reference_type_for_mode (tree to_type, machine_mode mode,
tree
build_reference_type (tree to_type)
{
- addr_space_t as = to_type == error_mark_node? ADDR_SPACE_GENERIC
- : TYPE_ADDR_SPACE (to_type);
- machine_mode pointer_mode = targetm.addr_space.pointer_mode (as);
- return build_reference_type_for_mode (to_type, pointer_mode, false);
+ return build_reference_type_for_mode (to_type, VOIDmode, false);
}
#define MAX_INT_CACHED_PREC \