-/**
- * The obstack and pset where the arch data is stored.
- */
-typedef struct _arch_data_t {
- struct obstack obst; /**< Here is the data allocated. */
- pset *header_set; /**< Here reside copies of the headers. */
-} arch_data_t;
-
-/**
- * Get the storage (obstack and pset) for the arch objects.
- * @return A struct containing both, the obst and pset where
- * the objects are allocated and their pointer are recorded.
- */
-static INLINE arch_data_t *get_arch_data(void)
-{
- static arch_data_t arch_data;
- static int inited = 0;
-
- if(!inited) {
- obstack_init(&arch_data.obst);
- arch_data.header_set = new_pset(cmp_header, 512);
- inited = 1;
- }
-
- return &arch_data;
-}
-
-/**
- * Dump all arch objects in the arch_data collection.
- */
-static void dump_arch_data(void)
-{
- void *p;
- arch_data_t *d = get_arch_data();
- static const char *kind_names[] = {
-#define ARCH_OBJ(name,in_list) #name,
-#include "bearch_obj.def"
-#undef ARCH_OBJ
- ""
- };
-
- printf("arch set:\n");
- for(p = pset_first(d->header_set); p; p = pset_next(d->header_set)) {
- arch_header_t *header = p;
- printf("%20s %10s %10s\n", kind_names[header->kind], header->name,
- header->isa ? header->isa->header.name : "");
- }
-}
-
-typedef struct _obj_info_t {
- const char *name;
- int listed_in_isa;
- size_t size;
-} obj_info_t;
-
-static const obj_info_t obj_info[] = {
-#define ARCH_OBJ(name,listed_in_isa) { #name, listed_in_isa, sizeof(arch_ ## name ## _t) },
-#include "bearch_obj.def"
-#undef ARCH_OBJ
- { 0 }
-};
-
-/**
- * Insert an arch object to the global arch obj storage.
- *
- * If the object has already been created there, nothing is done and
- * the old object is created.
- *
- * @param kind The kind of the arch object.
- * @param isa The isa the object belongs to or NULL if it is the isa
- * itself.
- * @param name The name of the object.
- * @return A pointer to the object.
- */
-static INLINE void *_arch_data_insert(arch_kind_t kind, arch_isa_t *isa,
- const char *name, size_t size)
-{
- arch_data_t *ad = get_arch_data();
- const obj_info_t *info = &obj_info[kind];
- arch_header_t *header = obstack_alloc(&ad->obst, size);
- arch_header_t *res = NULL;
-
- memset(header, 0, size);
- header->name = name;
- header->kind = kind;
- header->isa = isa;
- header->is_new = 1;
-
- res = pset_insert(ad->header_set, header, hash_header(header));
-
- /*
- * If the object is newly created and thus not yet present
- * in the set, add it to the isa
- * The inserted object was no isa, list it in the isa if this is
- * desired.
- */
- if(res->is_new && isa && info->listed_in_isa) {
- list_add(&res->list, &isa->heads[kind]);
- }
-
- /* if it was in the set, remove it from the obstack */
- if(!res->is_new)
- obstack_free(&ad->obst, header);
-
- /* Mark the object as NOT new. */
- res->is_new = 0;
-
- return res;
-}
-
-#define arch_data_insert(type_suffix, isa, name) \
- _arch_data_insert(arch_kind_ ## type_suffix, isa, name, sizeof(arch_ ## type_suffix ## _t))
-
-static INLINE void *_arch_data_find(arch_kind_t kind, const arch_isa_t *isa, const char *name)
-{
- arch_header_t header;
-
- header.kind = kind;
- header.isa = (arch_isa_t *) isa;
- header.name = name;
-
- return pset_find(get_arch_data()->header_set, &header, hash_header(&header));
-}
-
-#define arch_data_find(type_suffix, isa, name) \
- _arch_data_find(arch_kind_ ## type_suffix, isa, name)
-
-arch_isa_t *arch_add_isa(const char *name)
-{
- arch_isa_t *isa;
- int i;