Re: [RFA] SSE register type fix

Martin M. Hunt
2002-05-27T09:17:39Z

OK, I finally just checked this in as-is. If we decide on a new name scheme,
we can update later.

Martin

On Friday 17 May 2002 12:45 pm, Elena Zannoni wrote:
> Martin M. Hunt writes:
> > This patch adds better support for displaying SSE2 registers and changes
> > support for SSE registers. It also allows them to work with the latest
> > Insight.
> >
> > Previously registers were displayed as:
> > (gdb) p $xmm0
> > $1 = {f = {0, 0, 0, 0}}
> >
> > With this patch they will be printed as:
> >
> > (gdb) p $xmm0
> > $1 = {v4_float = {0, 0, 0, 0}, v2_double = {0, 0}, v16_int8 = '\0'
> > <repeats 15 times>, v8_int16 = {0, 0, 0, 0, 0, 0, 0, 0}, v4_int32 = {0,
> > 0, 0, 0}, v2_int64 = {0, 0}, uint128 =
> > 0x00000000000000000000000000000000}
> >
> > or you can do
> >
> > (gdb) p $xmm0.v4_float
> > $2 = {0, 0, 0, 0}
> >
> > Right now the code prints the register as if it were SSE2. For SSE
> > registers, only v4_float is actually used.
>
> I know zilch about SSE registers, but the gdbtypes.c and gdbtypes.h
> changes make sense and are approved....
>
> However... can we now remove the old machinery for creating the old
> style types? The v4si, v2si, etc types? I think the sse regs were the
> only ones using it.
>
> However #2... what's the 'i' in vec128i for? Intel? I would think that 'i'
> would be more like 'integer', i.e. vectors w/o floating point variants.
> Maybe we need a new naming scheme. Groan.
>
> Hey, how about some kind soul adding tests for these registers in the
> new gdb.arch directory? I think it would be possible to clone the
> altivec-regs files.
>
>
> Elena
>
> > --
> > Martin Hunt
> > GDB Engineer
> > Red Hat, Inc.
> >
> > 2002-05-17 Martin M. Hunt <hunt@redhat.com>
> >
> > * i386-tdep.c (i386_register_virtual_type): Return
> > builtin_type_vec128i for SSE registers.
> >
> > * gdbtypes.h (builtin_type_vec128i): Declare.
> >
> > * gdbtypes.c (build_builtin_type_vec128i): New function.
> > (builtin_type_v2_double, builtin_type_v4_int64): New types.
> > (builtin_type_vec128i): New type for SSE2 128-bit registers.
> > (build_gdbtypes): Initialize new builtin vector types.
> > (_initialize_gdbtypes): Register new vector types with gdbarch.
> >
> >
> > Index: i386-tdep.c
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/i386-tdep.c,v
> > retrieving revision 1.54
> > diff -u -u -r1.54 i386-tdep.c
> > --- i386-tdep.c 9 May 2002 13:53:36 -0000 1.54
> > +++ i386-tdep.c 17 May 2002 19:15:01 -0000
> > @@ -1058,7 +1058,7 @@
> > return builtin_type_i387_ext;
> >
> > if (IS_SSE_REGNUM (regnum))
> > - return builtin_type_v4sf;
> > + return builtin_type_vec128i;
> >
> > return builtin_type_int;
> > }
> > Index: gdbtypes.h
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/gdbtypes.h,v
> > retrieving revision 1.31
> > diff -u -u -r1.31 gdbtypes.h
> > --- gdbtypes.h 16 May 2002 03:59:58 -0000 1.31
> > +++ gdbtypes.h 17 May 2002 19:15:01 -0000
> > @@ -963,6 +963,7 @@
> >
> > /* Type for 128 bit vectors. */
> > extern struct type *builtin_type_vec128;
> > +extern struct type *builtin_type_vec128i;
> >
> > /* Explicit floating-point formats. See "floatformat.h". */
> > extern struct type *builtin_type_ieee_single_big;
> > Index: gdbtypes.c
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/gdbtypes.c,v
> > retrieving revision 1.51
> > diff -u -u -r1.51 gdbtypes.c
> > --- gdbtypes.c 14 May 2002 18:30:50 -0000 1.51
> > +++ gdbtypes.c 17 May 2002 19:15:02 -0000
> > @@ -73,7 +73,9 @@
> > 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;
> > @@ -91,6 +93,7 @@
> > struct type *builtin_type_v4hi;
> > struct type *builtin_type_v2si;
> > struct type *builtin_type_vec128;
> > +struct type *builtin_type_vec128i;
> > struct type *builtin_type_ieee_single_big;
> > struct type *builtin_type_ieee_single_little;
> > struct type *builtin_type_ieee_double_big;
> > @@ -844,6 +847,24 @@
> > return t;
> > }
> >
> > +static struct type *
> > +build_builtin_type_vec128i (void)
> > +{
> > + /* 128-bit Intel SIMD registers */
> > + struct type *t;
> > +
> > + t = init_composite_type ("__gdb_builtin_type_vec128i",
> > TYPE_CODE_UNION); + append_composite_type_field (t, "v4_float",
> > builtin_type_v4_float); + append_composite_type_field (t, "v2_double",
> > builtin_type_v2_double); + append_composite_type_field (t, "v16_int8",
> > builtin_type_v16_int8); + append_composite_type_field (t, "v8_int16",
> > builtin_type_v8_int16); + append_composite_type_field (t, "v4_int32",
> > builtin_type_v4_int32); + append_composite_type_field (t, "v2_int64",
> > builtin_type_v2_int64); + append_composite_type_field (t, "uint128",
> > builtin_type_int128); +
> > + return t;
> > +}
> > +
> > /* Smash TYPE to be a type of members of DOMAIN with type TO_TYPE.
> > A MEMBER is a wierd thing -- it amounts to a typed offset into
> > a struct, e.g. "an int at offset 8". A MEMBER TYPE doesn't
> > @@ -3300,7 +3321,9 @@
> > = 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);
> > @@ -3312,6 +3335,7 @@
> >
> > /* Vector types. */
> > builtin_type_vec128 = build_builtin_type_vec128 ();
> > + builtin_type_vec128i = build_builtin_type_vec128i ();
> >
> > /* Pointer/Address types. */
> >
> > @@ -3400,7 +3424,9 @@
> > register_gdbarch_swap (&builtin_type_v8hi, sizeof (struct type *),
> > NULL); register_gdbarch_swap (&builtin_type_v4hi, sizeof (struct type
> > *), NULL); register_gdbarch_swap (&builtin_type_v2si, sizeof (struct
> > type *), NULL); + register_gdbarch_swap (&builtin_type_v2_double,
> > sizeof (struct type *), NULL); register_gdbarch_swap
> > (&builtin_type_v4_float, sizeof (struct type *), NULL); +
> > register_gdbarch_swap (&builtin_type_v2_int64, sizeof (struct type *),
> > NULL); register_gdbarch_swap (&builtin_type_v4_int32, sizeof (struct
> > type *), NULL); register_gdbarch_swap (&builtin_type_v8_int16, sizeof
> > (struct type *), NULL); register_gdbarch_swap (&builtin_type_v16_int8,
> > sizeof (struct type *), NULL); @@ -3409,6 +3435,7 @@
> > register_gdbarch_swap (&builtin_type_v8_int8, sizeof (struct type *),
> > NULL); register_gdbarch_swap (&builtin_type_v4_int16, sizeof (struct
> > type *), NULL); register_gdbarch_swap (&builtin_type_vec128, sizeof
> > (struct type *), NULL); + register_gdbarch_swap (&builtin_type_vec128i,
> > sizeof (struct type *), NULL); REGISTER_GDBARCH_SWAP
> > (builtin_type_void_data_ptr);
> > REGISTER_GDBARCH_SWAP (builtin_type_void_func_ptr);
> > REGISTER_GDBARCH_SWAP (builtin_type_CORE_ADDR);