From: Ulrich Weigand Date: Sat, 16 Jun 2007 17:25:59 +0000 (+0000) Subject: * gdbtypes.c (builtin_type_v2_double, builtin_type_v4_float, X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=794ac4286c05ea60bbe06ad831d6951646aa1486;p=binutils-gdb.git * gdbtypes.c (builtin_type_v2_double, builtin_type_v4_float, builtin_type_v2_int64, builtin_type_v4_int32, builtin_type_v8_int16, builtin_type_v16_int8, builtin_type_v2_float, builtin_type_v2_int32, builtin_type_v4_int16, builtin_type_v8_int8, builtin_type_v4sf, builtin_type_v4si, builtin_type_v16qi, builtin_type_v8qi, builtin_type_v8hi, builtin_type_v4hi, builtin_type_v2si, builtin_type_vec64, builtin_type_vec128): Remove. (init_simd_type): Remove. (init_vector_type): Make global. (build_builtin_type_vec64, build_builtin_type_vec128): Remove. (build_gdbtypes): Do not build vector types. (_initialize_gdbtypes): Do not swap vector types. * gdbtypes.h (builtin_type_v2_double, builtin_type_v4_float, builtin_type_v2_int64, builtin_type_v4_int32, builtin_type_v8_int16, builtin_type_v16_int8, builtin_type_v2_float, builtin_type_v2_int32, builtin_type_v4_int16, builtin_type_v8_int8, builtin_type_v4sf, builtin_type_v4si, builtin_type_v16qi, builtin_type_v8qi, builtin_type_v8hi, builtin_type_v4hi, builtin_type_v2si, builtin_type_vec64, builtin_type_vec128): Remove declarations. (init_vector_type): Add prototype. * i386-tdep.h (struct gdbarch_tdep): Add i386_mmx_type and i386_sse_type members. (i386_mmx_type, i386_sse_type): Change from variables to functions. * i386-tdep.c (i386_mmx_type, i386_sse_type): Remove variables. (i386_init_types): Do not build vector types. (i386_mmx_type, i386_sse_type): New functions. (i386_register_type): Call them instead of using global variables. (i386_gdbarch_init): Use XCALLOC to allocate tdep structure. * amd64-tdep.c (amd64_register_type): Call i386_sse_type instead of using global variable. * rs6000-tdep.h (struct gdbarch_tdep): Add ppc_builtin_type_vec64 and ppc_builtin_type_vec128 members. * rs6000-tdep.c (rs6000_builtin_type_vec64): New function. (rs6000_builtin_type_vec128): Likewise. (rs6000_register_type): Call them instead of using builtin_type_vec64 and builtin_type_vec128. (rs6000_gdbarch_init): Use XCALLOC to allocate tdep structure. * spu-tdep.c (struct gdbarch_tdep): New data type. (spu_builtin_type_vec128): Remove variable. (spu_builtin_type_vec128): New function. (spu_register_type): Call it instead of using global variable. (spu_gdbarch_init): Allocate tdep structure. (spu_init_vector_type): Remove function. (_initialize_spu_tdep): Do not call it. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 284b6f786e9..0c44c6008cd 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,53 @@ +2007-06-16 Ulrich Weigand + + * gdbtypes.c (builtin_type_v2_double, builtin_type_v4_float, + builtin_type_v2_int64, builtin_type_v4_int32, builtin_type_v8_int16, + builtin_type_v16_int8, builtin_type_v2_float, builtin_type_v2_int32, + builtin_type_v4_int16, builtin_type_v8_int8, builtin_type_v4sf, + builtin_type_v4si, builtin_type_v16qi, builtin_type_v8qi, + builtin_type_v8hi, builtin_type_v4hi, builtin_type_v2si, + builtin_type_vec64, builtin_type_vec128): Remove. + (init_simd_type): Remove. + (init_vector_type): Make global. + (build_builtin_type_vec64, build_builtin_type_vec128): Remove. + (build_gdbtypes): Do not build vector types. + (_initialize_gdbtypes): Do not swap vector types. + * gdbtypes.h (builtin_type_v2_double, builtin_type_v4_float, + builtin_type_v2_int64, builtin_type_v4_int32, builtin_type_v8_int16, + builtin_type_v16_int8, builtin_type_v2_float, builtin_type_v2_int32, + builtin_type_v4_int16, builtin_type_v8_int8, builtin_type_v4sf, + builtin_type_v4si, builtin_type_v16qi, builtin_type_v8qi, + builtin_type_v8hi, builtin_type_v4hi, builtin_type_v2si, + builtin_type_vec64, builtin_type_vec128): Remove declarations. + (init_vector_type): Add prototype. + + * i386-tdep.h (struct gdbarch_tdep): Add i386_mmx_type and + i386_sse_type members. + (i386_mmx_type, i386_sse_type): Change from variables to functions. + * i386-tdep.c (i386_mmx_type, i386_sse_type): Remove variables. + (i386_init_types): Do not build vector types. + (i386_mmx_type, i386_sse_type): New functions. + (i386_register_type): Call them instead of using global variables. + (i386_gdbarch_init): Use XCALLOC to allocate tdep structure. + * amd64-tdep.c (amd64_register_type): Call i386_sse_type instead + of using global variable. + + * rs6000-tdep.h (struct gdbarch_tdep): Add ppc_builtin_type_vec64 + and ppc_builtin_type_vec128 members. + * rs6000-tdep.c (rs6000_builtin_type_vec64): New function. + (rs6000_builtin_type_vec128): Likewise. + (rs6000_register_type): Call them instead of using builtin_type_vec64 + and builtin_type_vec128. + (rs6000_gdbarch_init): Use XCALLOC to allocate tdep structure. + + * spu-tdep.c (struct gdbarch_tdep): New data type. + (spu_builtin_type_vec128): Remove variable. + (spu_builtin_type_vec128): New function. + (spu_register_type): Call it instead of using global variable. + (spu_gdbarch_init): Allocate tdep structure. + (spu_init_vector_type): Remove function. + (_initialize_spu_tdep): Do not call it. + 2007-06-16 Ulrich Weigand * amd64-tdep.c (struct amd64_register_info): Remove. diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index 51a7c192643..57f32d2ed03 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -106,7 +106,7 @@ amd64_register_type (struct gdbarch *gdbarch, int regnum) if (regnum >= AMD64_FCTRL_REGNUM && regnum <= AMD64_FCTRL_REGNUM + 7) return builtin_type_int32; if (regnum >= AMD64_XMM0_REGNUM && regnum <= AMD64_XMM0_REGNUM + 15) - return i386_sse_type; + return i386_sse_type (gdbarch); if (regnum == AMD64_MXCSR_REGNUM) return i386_mxcsr_type; diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index d96d5feeadd..8551c06086d 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -76,29 +76,6 @@ struct type *builtin_type_int128; struct type *builtin_type_uint128; struct type *builtin_type_bool; -/* 128 bit long vector types */ -struct type *builtin_type_v2_double; -struct type *builtin_type_v4_float; -struct type *builtin_type_v2_int64; -struct type *builtin_type_v4_int32; -struct type *builtin_type_v8_int16; -struct type *builtin_type_v16_int8; -/* 64 bit long vector types */ -struct type *builtin_type_v2_float; -struct type *builtin_type_v2_int32; -struct type *builtin_type_v4_int16; -struct type *builtin_type_v8_int8; - -struct type *builtin_type_v4sf; -struct type *builtin_type_v4si; -struct type *builtin_type_v16qi; -struct type *builtin_type_v8qi; -struct type *builtin_type_v8hi; -struct type *builtin_type_v4hi; -struct type *builtin_type_v2si; -struct type *builtin_type_vec64; -struct type *builtin_type_vec128; - /* Floatformat pairs. */ const struct floatformat *floatformats_ieee_single[BFD_ENDIAN_UNKNOWN] = { &floatformat_ieee_single_big, @@ -950,33 +927,7 @@ init_flags_type (char *name, int length) return type; } -/* Construct and return a type of the form: - struct NAME { ELT_TYPE ELT_NAME[N]; } - We use these types for SIMD registers. For example, the type of - the SSE registers on the late x86-family processors is: - struct __builtin_v4sf { float f[4]; } - built by the function call: - init_simd_type ("__builtin_v4sf", builtin_type_float, "f", 4) - The type returned is a permanent type, allocated using malloc; it - doesn't live in any objfile's obstack. */ -static struct type * -init_simd_type (char *name, - struct type *elt_type, - char *elt_name, - int n) -{ - struct type *simd_type; - struct type *array_type; - - simd_type = init_composite_type (name, TYPE_CODE_STRUCT); - array_type = create_array_type (0, elt_type, - create_range_type (0, builtin_type_int, - 0, n-1)); - append_composite_type_field (simd_type, elt_name, array_type); - return simd_type; -} - -static struct type * +struct type * init_vector_type (struct type *elt_type, int n) { struct type *array_type; @@ -988,66 +939,6 @@ init_vector_type (struct type *elt_type, int n) return array_type; } -static struct type * -build_builtin_type_vec64 (void) -{ - /* Construct a type for the 64 bit registers. The type we're - building is this: */ -#if 0 - union __gdb_builtin_type_vec64 - { - int64_t uint64; - float v2_float[2]; - int32_t v2_int32[2]; - int16_t v4_int16[4]; - int8_t v8_int8[8]; - }; -#endif - - struct type *t; - - t = init_composite_type ("__gdb_builtin_type_vec64", TYPE_CODE_UNION); - append_composite_type_field (t, "uint64", builtin_type_int64); - append_composite_type_field (t, "v2_float", builtin_type_v2_float); - append_composite_type_field (t, "v2_int32", builtin_type_v2_int32); - append_composite_type_field (t, "v4_int16", builtin_type_v4_int16); - append_composite_type_field (t, "v8_int8", builtin_type_v8_int8); - - TYPE_FLAGS (t) |= TYPE_FLAG_VECTOR; - TYPE_NAME (t) = "builtin_type_vec64"; - return t; -} - -static struct type * -build_builtin_type_vec128 (void) -{ - /* Construct a type for the 128 bit registers. The type we're - building is this: */ -#if 0 - union __gdb_builtin_type_vec128 - { - int128_t uint128; - float v4_float[4]; - int32_t v4_int32[4]; - int16_t v8_int16[8]; - int8_t v16_int8[16]; - }; -#endif - - struct type *t; - - t = init_composite_type ("__gdb_builtin_type_vec128", TYPE_CODE_UNION); - append_composite_type_field (t, "uint128", builtin_type_int128); - append_composite_type_field (t, "v4_float", builtin_type_v4_float); - append_composite_type_field (t, "v4_int32", builtin_type_v4_int32); - append_composite_type_field (t, "v8_int16", builtin_type_v8_int16); - append_composite_type_field (t, "v16_int8", builtin_type_v16_int8); - - TYPE_FLAGS (t) |= TYPE_FLAG_VECTOR; - TYPE_NAME (t) = "builtin_type_vec128"; - return t; -} - /* Smash TYPE to be a type of pointers to members of DOMAIN with type TO_TYPE. A member pointer is a wierd thing -- it amounts to a typed offset into a struct, e.g. "an int at offset 8". A MEMBER @@ -3509,39 +3400,6 @@ Show resolution of opaque struct/class/union types (if set before loading symbol &setlist, &showlist); opaque_type_resolution = 1; - /* Build SIMD types. */ - builtin_type_v4sf - = init_simd_type ("__builtin_v4sf", builtin_type_float, "f", 4); - builtin_type_v4si - = init_simd_type ("__builtin_v4si", builtin_type_int32, "f", 4); - builtin_type_v16qi - = init_simd_type ("__builtin_v16qi", builtin_type_int8, "f", 16); - builtin_type_v8qi - = init_simd_type ("__builtin_v8qi", builtin_type_int8, "f", 8); - builtin_type_v8hi - = init_simd_type ("__builtin_v8hi", builtin_type_int16, "f", 8); - builtin_type_v4hi - = init_simd_type ("__builtin_v4hi", builtin_type_int16, "f", 4); - builtin_type_v2si - = init_simd_type ("__builtin_v2si", builtin_type_int32, "f", 2); - - /* 128 bit vectors. */ - builtin_type_v2_double = init_vector_type (builtin_type_double, 2); - builtin_type_v4_float = init_vector_type (builtin_type_float, 4); - builtin_type_v2_int64 = init_vector_type (builtin_type_int64, 2); - builtin_type_v4_int32 = init_vector_type (builtin_type_int32, 4); - builtin_type_v8_int16 = init_vector_type (builtin_type_int16, 8); - builtin_type_v16_int8 = init_vector_type (builtin_type_int8, 16); - /* 64 bit vectors. */ - builtin_type_v2_float = init_vector_type (builtin_type_float, 2); - builtin_type_v2_int32 = init_vector_type (builtin_type_int32, 2); - builtin_type_v4_int16 = init_vector_type (builtin_type_int16, 4); - builtin_type_v8_int8 = init_vector_type (builtin_type_int8, 8); - - /* Vector types. */ - builtin_type_vec64 = build_builtin_type_vec64 (); - builtin_type_vec128 = build_builtin_type_vec128 (); - /* Pointer/Address types. */ /* NOTE: on some targets, addresses and pointers are not necessarily @@ -3817,24 +3675,6 @@ _initialize_gdbtypes (void) DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_complex); DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_double_complex); DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_string); - DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v4sf); - DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v4si); - DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v16qi); - DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v8qi); - DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v8hi); - DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v4hi); - DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v2si); - DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v2_double); - DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v4_float); - DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v2_int64); - DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v4_int32); - DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v8_int16); - DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v16_int8); - DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v2_float); - DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v2_int32); - DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v8_int8); - DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v4_int16); - DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_vec128); DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_void_data_ptr); DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_void_func_ptr); DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_CORE_ADDR); diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 39ed5ccd15c..3ce5ed698a0 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -1089,31 +1089,6 @@ extern struct type *builtin_type_uint64; extern struct type *builtin_type_int128; extern struct type *builtin_type_uint128; -/* SIMD types. We inherit these names from GCC. */ -extern struct type *builtin_type_v4sf; -extern struct type *builtin_type_v4si; -extern struct type *builtin_type_v16qi; -extern struct type *builtin_type_v8qi; -extern struct type *builtin_type_v8hi; -extern struct type *builtin_type_v4hi; -extern struct type *builtin_type_v2si; - -/* Types for 64 bit vectors. */ -extern struct type *builtin_type_v2_float; -extern struct type *builtin_type_v2_int32; -extern struct type *builtin_type_v4_int16; -extern struct type *builtin_type_v8_int8; -extern struct type *builtin_type_vec64; - -/* Types for 128 bit vectors. */ -extern struct type *builtin_type_v2_double; -extern struct type *builtin_type_v4_float; -extern struct type *builtin_type_v2_int64; -extern struct type *builtin_type_v4_int32; -extern struct type *builtin_type_v8_int16; -extern struct type *builtin_type_v16_int8; -extern struct type *builtin_type_vec128; - /* Explicit floating-point formats. See "floatformat.h". */ extern const struct floatformat *floatformats_ieee_single[BFD_ENDIAN_UNKNOWN]; extern const struct floatformat *floatformats_ieee_double[BFD_ENDIAN_UNKNOWN]; @@ -1225,6 +1200,8 @@ extern void append_composite_type_field (struct type *t, char *name, extern struct type *init_flags_type (char *name, int length); extern void append_flags_type_flag (struct type *type, int bitpos, char *name); +extern struct type *init_vector_type (struct type *elt_type, int n); + extern struct type *lookup_reference_type (struct type *); extern struct type *make_reference_type (struct type *, struct type **); diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 91bce8a4b2a..dc3ca791e46 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -1595,9 +1595,7 @@ i386_return_value (struct gdbarch *gdbarch, struct type *type, /* Type for %eflags. */ struct type *i386_eflags_type; -/* Types for the MMX and SSE registers. */ -struct type *i386_mmx_type; -struct type *i386_sse_type; +/* Type for %mxcsr. */ struct type *i386_mxcsr_type; /* Construct types for ISA-specific registers. */ @@ -1626,52 +1624,6 @@ i386_init_types (void) append_flags_type_flag (type, 21, "ID"); i386_eflags_type = type; - /* The type we're building is this: */ -#if 0 - union __gdb_builtin_type_vec64i - { - int64_t uint64; - int32_t v2_int32[2]; - int16_t v4_int16[4]; - int8_t v8_int8[8]; - }; -#endif - - type = init_composite_type ("__gdb_builtin_type_vec64i", TYPE_CODE_UNION); - append_composite_type_field (type, "uint64", builtin_type_int64); - append_composite_type_field (type, "v2_int32", builtin_type_v2_int32); - append_composite_type_field (type, "v4_int16", builtin_type_v4_int16); - append_composite_type_field (type, "v8_int8", builtin_type_v8_int8); - TYPE_FLAGS (type) |= TYPE_FLAG_VECTOR; - TYPE_NAME (type) = "builtin_type_vec64i"; - i386_mmx_type = type; - - /* The type we're building is this: */ -#if 0 - union __gdb_builtin_type_vec128i - { - int128_t uint128; - int64_t v2_int64[2]; - int32_t v4_int32[4]; - int16_t v8_int16[8]; - int8_t v16_int8[16]; - double v2_double[2]; - float v4_float[4]; - }; -#endif - - type = init_composite_type ("__gdb_builtin_type_vec128i", TYPE_CODE_UNION); - append_composite_type_field (type, "v4_float", builtin_type_v4_float); - append_composite_type_field (type, "v2_double", builtin_type_v2_double); - append_composite_type_field (type, "v16_int8", builtin_type_v16_int8); - append_composite_type_field (type, "v8_int16", builtin_type_v8_int16); - append_composite_type_field (type, "v4_int32", builtin_type_v4_int32); - append_composite_type_field (type, "v2_int64", builtin_type_v2_int64); - append_composite_type_field (type, "uint128", builtin_type_int128); - TYPE_FLAGS (type) |= TYPE_FLAG_VECTOR; - TYPE_NAME (type) = "builtin_type_vec128i"; - i386_sse_type = type; - type = init_flags_type ("builtin_type_i386_mxcsr", 4); append_flags_type_flag (type, 0, "IE"); append_flags_type_flag (type, 1, "DE"); @@ -1690,6 +1642,90 @@ i386_init_types (void) i386_mxcsr_type = type; } +/* Construct vector type for MMX registers. */ +struct type * +i386_mmx_type (struct gdbarch *gdbarch) +{ + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + if (!tdep->i386_mmx_type) + { + /* The type we're building is this: */ +#if 0 + union __gdb_builtin_type_vec64i + { + int64_t uint64; + int32_t v2_int32[2]; + int16_t v4_int16[4]; + int8_t v8_int8[8]; + }; +#endif + + struct type *t; + + t = init_composite_type ("__gdb_builtin_type_vec64i", TYPE_CODE_UNION); + append_composite_type_field (t, "uint64", builtin_type_int64); + append_composite_type_field (t, "v2_int32", + init_vector_type (builtin_type_int32, 2)); + append_composite_type_field (t, "v4_int16", + init_vector_type (builtin_type_int16, 4)); + append_composite_type_field (t, "v8_int8", + init_vector_type (builtin_type_int8, 8)); + + TYPE_FLAGS (t) |= TYPE_FLAG_VECTOR; + TYPE_NAME (t) = "builtin_type_vec64i"; + tdep->i386_mmx_type = t; + } + + return tdep->i386_mmx_type; +} + +struct type * +i386_sse_type (struct gdbarch *gdbarch) +{ + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + if (!tdep->i386_sse_type) + { + /* The type we're building is this: */ +#if 0 + union __gdb_builtin_type_vec128i + { + int128_t uint128; + int64_t v2_int64[2]; + int32_t v4_int32[4]; + int16_t v8_int16[8]; + int8_t v16_int8[16]; + double v2_double[2]; + float v4_float[4]; + }; +#endif + + struct type *t; + + t = init_composite_type ("__gdb_builtin_type_vec128i", TYPE_CODE_UNION); + append_composite_type_field (t, "v4_float", + init_vector_type (builtin_type_float, 4)); + append_composite_type_field (t, "v2_double", + init_vector_type (builtin_type_double, 2)); + append_composite_type_field (t, "v16_int8", + init_vector_type (builtin_type_int8, 16)); + append_composite_type_field (t, "v8_int16", + init_vector_type (builtin_type_int16, 8)); + append_composite_type_field (t, "v4_int32", + init_vector_type (builtin_type_int32, 4)); + append_composite_type_field (t, "v2_int64", + init_vector_type (builtin_type_int64, 2)); + append_composite_type_field (t, "uint128", builtin_type_int128); + + TYPE_FLAGS (t) |= TYPE_FLAG_VECTOR; + TYPE_NAME (t) = "builtin_type_vec128i"; + tdep->i386_sse_type = t; + } + + return tdep->i386_sse_type; +} + /* Return the GDB type object for the "standard" data type of data in register REGNUM. Perhaps %esi and %edi should go here, but potentially they could be used for things other than address. */ @@ -1710,10 +1746,10 @@ i386_register_type (struct gdbarch *gdbarch, int regnum) return builtin_type_i387_ext; if (i386_mmx_regnum_p (gdbarch, regnum)) - return i386_mmx_type; + return i386_mmx_type (gdbarch); if (i386_sse_regnum_p (gdbarch, regnum)) - return i386_sse_type; + return i386_sse_type (gdbarch); #define I387_ST0_REGNUM I386_ST0_REGNUM #define I387_NUM_XMM_REGS (gdbarch_tdep (current_gdbarch)->num_xmm_regs) @@ -2274,7 +2310,7 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) return arches->gdbarch; /* Allocate space for the new architecture. */ - tdep = XMALLOC (struct gdbarch_tdep); + tdep = XCALLOC (1, struct gdbarch_tdep); gdbarch = gdbarch_alloc (&info, tdep); /* General-purpose registers. */ diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h index 3cd5d1f38b8..d07d2c8e2d3 100644 --- a/gdb/i386-tdep.h +++ b/gdb/i386-tdep.h @@ -104,6 +104,10 @@ struct gdbarch_tdep is deprecated, please use `sc_reg_offset' instead. */ int sc_pc_offset; int sc_sp_offset; + + /* ISA-specific data types. */ + struct type *i386_mmx_type; + struct type *i386_sse_type; }; /* Floating-point registers. */ @@ -152,10 +156,11 @@ enum i386_regnum /* Types for i386-specific registers. */ extern struct type *i386_eflags_type; -extern struct type *i386_mmx_type; -extern struct type *i386_sse_type; extern struct type *i386_mxcsr_type; +extern struct type *i386_mmx_type (struct gdbarch *gdbarch); +extern struct type *i386_sse_type (struct gdbarch *gdbarch); + /* Segment selectors. */ #define I386_SEL_RPL 0x0003 /* Requester's Privilege Level mask. */ #define I386_SEL_UPL 0x0003 /* User Privilige Level. */ diff --git a/gdb/ppc-tdep.h b/gdb/ppc-tdep.h index 8d1c8a223a8..6e5d3b23583 100644 --- a/gdb/ppc-tdep.h +++ b/gdb/ppc-tdep.h @@ -186,6 +186,10 @@ struct gdbarch_tdep /* Minimum possible text address. */ CORE_ADDR text_segment_base; + + /* ISA-specific types. */ + struct type *ppc_builtin_type_vec64; + struct type *ppc_builtin_type_vec128; }; diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index c8f748cc0eb..c470ab9325d 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -2024,6 +2024,88 @@ rs6000_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc) return pc; } +/* ISA-specific vector types. */ + +static struct type * +rs6000_builtin_type_vec64 (struct gdbarch *gdbarch) +{ + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + if (!tdep->ppc_builtin_type_vec64) + { + /* The type we're building is this: */ +#if 0 + union __gdb_builtin_type_vec64 + { + int64_t uint64; + float v2_float[2]; + int32_t v2_int32[2]; + int16_t v4_int16[4]; + int8_t v8_int8[8]; + }; +#endif + + struct type *t; + + t = init_composite_type ("__ppc_builtin_type_vec64", TYPE_CODE_UNION); + append_composite_type_field (t, "uint64", builtin_type_int64); + append_composite_type_field (t, "v2_float", + init_vector_type (builtin_type_float, 2)); + append_composite_type_field (t, "v2_int32", + init_vector_type (builtin_type_int32, 2)); + append_composite_type_field (t, "v4_int16", + init_vector_type (builtin_type_int16, 4)); + append_composite_type_field (t, "v8_int8", + init_vector_type (builtin_type_int8, 8)); + + TYPE_FLAGS (t) |= TYPE_FLAG_VECTOR; + TYPE_NAME (t) = "ppc_builtin_type_vec64"; + tdep->ppc_builtin_type_vec64 = t; + } + + return tdep->ppc_builtin_type_vec64; +} + +static struct type * +rs6000_builtin_type_vec128 (struct gdbarch *gdbarch) +{ + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + if (!tdep->ppc_builtin_type_vec128) + { + /* The type we're building is this: */ +#if 0 + union __gdb_builtin_type_vec128 + { + int128_t uint128; + float v4_float[4]; + int32_t v4_int32[4]; + int16_t v8_int16[8]; + int8_t v16_int8[16]; + }; +#endif + + struct type *t; + + t = init_composite_type ("__ppc_builtin_type_vec128", TYPE_CODE_UNION); + append_composite_type_field (t, "uint128", builtin_type_int128); + append_composite_type_field (t, "v4_float", + init_vector_type (builtin_type_float, 4)); + 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)); + + TYPE_FLAGS (t) |= TYPE_FLAG_VECTOR; + TYPE_NAME (t) = "ppc_builtin_type_vec128"; + tdep->ppc_builtin_type_vec128 = t; + } + + return tdep->ppc_builtin_type_vec128; +} + /* Return the size of register REG when words are WORDSIZE bytes long. If REG isn't available with that word size, return 0. */ @@ -2069,12 +2151,12 @@ rs6000_register_type (struct gdbarch *gdbarch, int n) return builtin_type_uint32; case 8: if (tdep->ppc_ev0_regnum <= n && n <= tdep->ppc_ev31_regnum) - return builtin_type_vec64; + return rs6000_builtin_type_vec64 (gdbarch); else return builtin_type_uint64; break; case 16: - return builtin_type_vec128; + return rs6000_builtin_type_vec128 (gdbarch); break; default: internal_error (__FILE__, __LINE__, _("Register %d size %d unknown"), @@ -3364,7 +3446,7 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) info.bfd_arch_info = bfd_get_arch_info (&abfd); mach = info.bfd_arch_info->mach; } - tdep = xmalloc (sizeof (struct gdbarch_tdep)); + tdep = XCALLOC (1, struct gdbarch_tdep); tdep->wordsize = wordsize; /* For e500 executables, the apuinfo section is of help here. Such diff --git a/gdb/spu-tdep.c b/gdb/spu-tdep.c index 7c8b045ea25..bffab70b42c 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 ();