aboutsummaryrefslogtreecommitdiff
path: root/gcc/go/gofrontend/gogo-tree.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/go/gofrontend/gogo-tree.cc')
-rw-r--r--gcc/go/gofrontend/gogo-tree.cc135
1 files changed, 0 insertions, 135 deletions
diff --git a/gcc/go/gofrontend/gogo-tree.cc b/gcc/go/gofrontend/gogo-tree.cc
index 0c5cb67..94d1c4d 100644
--- a/gcc/go/gofrontend/gogo-tree.cc
+++ b/gcc/go/gofrontend/gogo-tree.cc
@@ -1974,141 +1974,6 @@ Gogo::slice_constructor(tree slice_type_tree, tree values, tree count,
return build_constructor(slice_type_tree, init);
}
-// Build a map descriptor for a map of type MAPTYPE.
-
-tree
-Gogo::map_descriptor(Map_type* maptype)
-{
- if (this->map_descriptors_ == NULL)
- this->map_descriptors_ = new Map_descriptors(10);
-
- std::pair<const Map_type*, tree> val(maptype, NULL);
- std::pair<Map_descriptors::iterator, bool> ins =
- this->map_descriptors_->insert(val);
- Map_descriptors::iterator p = ins.first;
- if (!ins.second)
- {
- if (p->second == error_mark_node)
- return error_mark_node;
- go_assert(p->second != NULL_TREE && DECL_P(p->second));
- return build_fold_addr_expr(p->second);
- }
-
- Type* keytype = maptype->key_type();
- Type* valtype = maptype->val_type();
-
- std::string mangled_name = ("__go_map_" + maptype->mangled_name(this));
-
- tree id = get_identifier_from_string(mangled_name);
-
- // Get the type of the map descriptor. This is __go_map_descriptor
- // in libgo/map.h.
-
- tree struct_type = this->map_descriptor_type();
-
- // The map entry type is a struct with three fields. This struct is
- // specific to MAPTYPE. Build it.
-
- tree map_entry_type = make_node(RECORD_TYPE);
-
- Btype* bkey_type = keytype->get_backend(this);
- Btype* bval_type = valtype->get_backend(this);
- map_entry_type = Gogo::builtin_struct(NULL, "__map", map_entry_type, 3,
- "__next",
- build_pointer_type(map_entry_type),
- "__key",
- type_to_tree(bkey_type),
- "__val",
- type_to_tree(bval_type));
- if (map_entry_type == error_mark_node)
- {
- p->second = error_mark_node;
- return error_mark_node;
- }
-
- tree map_entry_key_field = DECL_CHAIN(TYPE_FIELDS(map_entry_type));
- go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(map_entry_key_field)),
- "__key") == 0);
-
- tree map_entry_val_field = DECL_CHAIN(map_entry_key_field);
- go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(map_entry_val_field)),
- "__val") == 0);
-
- // Initialize the entries.
-
- tree map_descriptor_field = TYPE_FIELDS(struct_type);
- go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(map_descriptor_field)),
- "__map_descriptor") == 0);
- tree entry_size_field = DECL_CHAIN(map_descriptor_field);
- go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(entry_size_field)),
- "__entry_size") == 0);
- tree key_offset_field = DECL_CHAIN(entry_size_field);
- go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(key_offset_field)),
- "__key_offset") == 0);
- tree val_offset_field = DECL_CHAIN(key_offset_field);
- go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(val_offset_field)),
- "__val_offset") == 0);
-
- VEC(constructor_elt, gc)* descriptor = VEC_alloc(constructor_elt, gc, 6);
-
- constructor_elt* elt = VEC_quick_push(constructor_elt, descriptor, NULL);
- elt->index = map_descriptor_field;
- elt->value = maptype->type_descriptor_pointer(this, BUILTINS_LOCATION);
-
- elt = VEC_quick_push(constructor_elt, descriptor, NULL);
- elt->index = entry_size_field;
- elt->value = TYPE_SIZE_UNIT(map_entry_type);
-
- elt = VEC_quick_push(constructor_elt, descriptor, NULL);
- elt->index = key_offset_field;
- elt->value = byte_position(map_entry_key_field);
-
- elt = VEC_quick_push(constructor_elt, descriptor, NULL);
- elt->index = val_offset_field;
- elt->value = byte_position(map_entry_val_field);
-
- tree constructor = build_constructor(struct_type, descriptor);
-
- tree decl = build_decl(BUILTINS_LOCATION, VAR_DECL, id, struct_type);
- TREE_STATIC(decl) = 1;
- TREE_USED(decl) = 1;
- TREE_READONLY(decl) = 1;
- TREE_CONSTANT(decl) = 1;
- DECL_INITIAL(decl) = constructor;
- make_decl_one_only(decl, DECL_ASSEMBLER_NAME(decl));
- resolve_unique_section(decl, 1, 0);
-
- rest_of_decl_compilation(decl, 1, 0);
-
- go_preserve_from_gc(decl);
- p->second = decl;
-
- return build_fold_addr_expr(decl);
-}
-
-// Return a tree for the type of a map descriptor. This is struct
-// __go_map_descriptor in libgo/runtime/map.h. This is the same for
-// all map types.
-
-tree
-Gogo::map_descriptor_type()
-{
- static tree struct_type;
- Type* tdt = Type::make_type_descriptor_type();
- tree dtype = type_to_tree(tdt->get_backend(this));
- dtype = build_qualified_type(dtype, TYPE_QUAL_CONST);
- return Gogo::builtin_struct(&struct_type, "__go_map_descriptor", NULL_TREE,
- 4,
- "__map_descriptor",
- build_pointer_type(dtype),
- "__entry_size",
- sizetype,
- "__key_offset",
- sizetype,
- "__val_offset",
- sizetype);
-}
-
// Build an interface method table for a type: a list of function
// pointers, one for each interface method. This is used for
// interfaces.