diff options
Diffstat (limited to 'gdb/spu-tdep.c')
-rw-r--r-- | gdb/spu-tdep.c | 72 |
1 files changed, 46 insertions, 26 deletions
diff --git a/gdb/spu-tdep.c b/gdb/spu-tdep.c index 7c8b045..bffab70 100644 --- a/gdb/spu-tdep.c +++ b/gdb/spu-tdep.c @@ -46,8 +46,49 @@ #include "spu-tdep.h" + +/* The tdep structure. */ +struct gdbarch_tdep +{ + /* SPU-specific vector type. */ + struct type *spu_builtin_type_vec128; +}; + + /* SPU-specific vector type. */ -struct type *spu_builtin_type_vec128; +static struct type * +spu_builtin_type_vec128 (struct gdbarch *gdbarch) +{ + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + if (!tdep->spu_builtin_type_vec128) + { + struct type *t; + + t = init_composite_type ("__spu_builtin_type_vec128", TYPE_CODE_UNION); + append_composite_type_field (t, "uint128", builtin_type_int128); + append_composite_type_field (t, "v2_int64", + init_vector_type (builtin_type_int64, 2)); + append_composite_type_field (t, "v4_int32", + init_vector_type (builtin_type_int32, 4)); + append_composite_type_field (t, "v8_int16", + init_vector_type (builtin_type_int16, 8)); + append_composite_type_field (t, "v16_int8", + init_vector_type (builtin_type_int8, 16)); + append_composite_type_field (t, "v2_double", + init_vector_type (builtin_type_double, 2)); + append_composite_type_field (t, "v4_float", + init_vector_type (builtin_type_float, 4)); + + TYPE_FLAGS (t) |= TYPE_FLAG_VECTOR; + TYPE_NAME (t) = "spu_builtin_type_vec128"; + + tdep->spu_builtin_type_vec128 = t; + } + + return tdep->spu_builtin_type_vec128; +} + /* The list of available "info spu " commands. */ static struct cmd_list_element *infospucmdlist = NULL; @@ -90,7 +131,7 @@ static struct type * spu_register_type (struct gdbarch *gdbarch, int reg_nr) { if (reg_nr < SPU_NUM_GPRS) - return spu_builtin_type_vec128; + return spu_builtin_type_vec128 (gdbarch); switch (reg_nr) { @@ -1920,6 +1961,7 @@ static struct gdbarch * spu_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { struct gdbarch *gdbarch; + struct gdbarch_tdep *tdep; /* Find a candidate among the list of pre-declared architectures. */ arches = gdbarch_list_lookup_by_info (arches, &info); @@ -1931,7 +1973,8 @@ spu_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) return NULL; /* Yes, create a new architecture. */ - gdbarch = gdbarch_alloc (&info, NULL); + tdep = XCALLOC (1, struct gdbarch_tdep); + gdbarch = gdbarch_alloc (&info, tdep); /* Disassembler. */ set_gdbarch_print_insn (gdbarch, print_insn_spu); @@ -1995,34 +2038,11 @@ spu_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) return gdbarch; } -/* Implement a SPU-specific vector type as replacement - for __gdb_builtin_type_vec128. */ -static void -spu_init_vector_type (void) -{ - struct type *type; - - type = init_composite_type ("__spu_builtin_type_vec128", TYPE_CODE_UNION); - append_composite_type_field (type, "uint128", builtin_type_int128); - append_composite_type_field (type, "v2_int64", builtin_type_v2_int64); - append_composite_type_field (type, "v4_int32", builtin_type_v4_int32); - append_composite_type_field (type, "v8_int16", builtin_type_v8_int16); - append_composite_type_field (type, "v16_int8", builtin_type_v16_int8); - append_composite_type_field (type, "v2_double", builtin_type_v2_double); - append_composite_type_field (type, "v4_float", builtin_type_v4_float); - - TYPE_FLAGS (type) |= TYPE_FLAG_VECTOR; - TYPE_NAME (type) = "spu_builtin_type_vec128"; - spu_builtin_type_vec128 = type; -} - void _initialize_spu_tdep (void) { register_gdbarch_init (bfd_arch_spu, spu_gdbarch_init); - spu_init_vector_type (); - /* Add ourselves to objfile event chain. */ observer_attach_new_objfile (spu_overlay_new_objfile); spu_overlay_data = register_objfile_data (); |