summaryrefslogtreecommitdiff
path: root/gcc/java/constants.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/java/constants.c')
-rw-r--r--gcc/java/constants.c42
1 files changed, 23 insertions, 19 deletions
diff --git a/gcc/java/constants.c b/gcc/java/constants.c
index d97e8c07e80..32fc854c9db 100644
--- a/gcc/java/constants.c
+++ b/gcc/java/constants.c
@@ -386,29 +386,35 @@ alloc_class_constant (tree clas)
IDENTIFIER_LENGTH(class_name))));
}
-/* Return a reference to the data array of the current constant pool. */
+/* Return the decl of the data array of the current constant pool. */
static tree
build_constant_data_ref (void)
{
- tree cpool_data_ref = NULL_TREE;
+ tree decl = TYPE_CPOOL_DATA_REF (output_class);
- if (TYPE_CPOOL_DATA_REF (output_class))
- cpool_data_ref = TYPE_CPOOL_DATA_REF (output_class);
-
- if (cpool_data_ref == NULL_TREE)
+ if (decl == NULL_TREE)
{
- tree decl;
+ tree type;
tree decl_name = mangled_classname ("_CD_", output_class);
- decl = build_decl (VAR_DECL, decl_name,
- build_array_type (ptr_type_node,
- one_elt_array_domain_type));
+
+ /* Build a type with unspecified bounds. The will make sure
+ that targets do the right thing with whatever size we end
+ up with at the end. Using bounds that are too small risks
+ assuming the data is in the small data section. */
+ type = build_array_type (ptr_type_node, NULL_TREE);
+
+ /* We need to lay out the type ourselves, since build_array_type
+ thinks the type is incomplete. */
+ layout_type (type);
+
+ decl = build_decl (VAR_DECL, decl_name, type);
TREE_STATIC (decl) = 1;
make_decl_rtl (decl, NULL);
- TYPE_CPOOL_DATA_REF (output_class) = cpool_data_ref
- = build1 (ADDR_EXPR, ptr_type_node, decl);
+ TYPE_CPOOL_DATA_REF (output_class) = decl;
}
- return cpool_data_ref;
+
+ return decl;
}
/* Get the pointer value at the INDEX'th element of the constant pool. */
@@ -416,11 +422,9 @@ build_constant_data_ref (void)
tree
build_ref_from_constant_pool (int index)
{
- tree t = build_constant_data_ref ();
- index *= int_size_in_bytes (ptr_type_node);
- t = fold (build (PLUS_EXPR, ptr_type_node,
- t, build_int_2 (index, 0)));
- return build1 (INDIRECT_REF, ptr_type_node, t);
+ tree d = build_constant_data_ref ();
+ tree i = build_int_2 (index, 0);
+ return build (ARRAY_REF, TREE_TYPE (TREE_TYPE (d)), d, i);
}
/* Build an initializer for the constants field of the current constant pool.
@@ -456,7 +460,7 @@ build_constants_constructor (void)
tags_list = tree_cons (NULL_TREE, get_tag_node (0), tags_list);
data_list = tree_cons (NULL_TREE, null_pointer_node, data_list);
- data_decl = TREE_OPERAND (build_constant_data_ref (), 0);
+ data_decl = build_constant_data_ref ();
TREE_TYPE (data_decl) = build_array_type (ptr_type_node, index_type),
DECL_INITIAL (data_decl) = build_constructor (TREE_TYPE (data_decl),
data_list);