* [RFA] gdbtypes.[ch] rs6000-tdep.c--AltiVec regs types
@ 2002-01-11 15:20 Elena Zannoni
2002-01-11 15:28 ` Daniel Jacobowitz
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Elena Zannoni @ 2002-01-11 15:20 UTC (permalink / raw)
To: gdb-patches
This patch provides a builtin union type for the AltiVec registers,
so that the printing of such regs is a bit more enlightening, like:
(gdb) p $vr0
$2 = {uint128 = 0x00000064000000c80000012c00000190,
v4sf = {f = {1.40129846e-43, 2.80259693e-43, 4.20389539e-43, 5.60519386e-43}},
v4si = {f = {100, 200, 300, 400}},
v8hi = {f = {0, 100, 0, 200, 0, 300, 0, 400}},
v16qi = {f = "\0\0\0d\0\0\0È\0\0\001,\0\0\001\220"}}
(gdb) p $vr0.v4si
$3 = {f = {100, 200, 300, 400}}
(gdb) p $vr0.v4si.f[2]
$4 = 300
(gdb) p $vr0.v4si.f[2]=444
$5 = 444
Elena
2002-01-11 Elena Zannoni <ezannoni@redhat.com>
[Based on work by Jim Blandy]
* rs6000-tdep.c: Declare predifined type for AltiVec registers.
(build_builtin_type_powerpc_altivec): New function.
(rs6000_register_virtual_type): Change type of AltiVec register to
new builtin type.
(_initialize_rs6000_tdep): Create the altivec register builtin
type structure.
* gdbtypes.h (builtin_type_v16qi, builtin_type_v8hi): Export.
* gdbtypes.c (builtin_type_v16qi, builtin_type_v8hi): New SIMD
types.
(build_gdbtypes): Initialize builtin_type_v16qi and
builtin_type_v8hi.
(_initialize_gdbtypes): Register builtin_type_v16qi and
builtin_type_v8hi with gdbarch.
Index: gdbtypes.c
===================================================================
RCS file: /cvs/uberbaum/gdb/gdbtypes.c,v
retrieving revision 1.35
diff -u -p -r1.35 gdbtypes.c
--- gdbtypes.c 2001/12/20 03:26:08 1.35
+++ gdbtypes.c 2002/01/11 21:56:13
@@ -73,7 +73,9 @@ struct type *builtin_type_uint128;
struct type *builtin_type_bool;
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_ieee_single_big;
@@ -3163,8 +3165,12 @@ build_gdbtypes (void)
= 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
@@ -3252,7 +3258,9 @@ _initialize_gdbtypes (void)
register_gdbarch_swap (&builtin_type_uint128, sizeof (struct type *), NULL);
register_gdbarch_swap (&builtin_type_v4sf, sizeof (struct type *), NULL);
register_gdbarch_swap (&builtin_type_v4si, sizeof (struct type *), NULL);
+ register_gdbarch_swap (&builtin_type_v16qi, sizeof (struct type *), NULL);
register_gdbarch_swap (&builtin_type_v8qi, sizeof (struct type *), NULL);
+ 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_void_data_ptr);
Index: gdbtypes.h
===================================================================
RCS file: /cvs/uberbaum/gdb/gdbtypes.h,v
retrieving revision 1.21
diff -u -p -r1.21 gdbtypes.h
--- gdbtypes.h 2001/12/10 06:17:01 1.21
+++ gdbtypes.h 2002/01/11 21:56:15
@@ -946,7 +946,9 @@ 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;
Index: rs6000-tdep.c
===================================================================
RCS file: /cvs/uberbaum/gdb/rs6000-tdep.c,v
retrieving revision 1.35
diff -u -p -r1.35 rs6000-tdep.c
--- rs6000-tdep.c 2002/01/06 04:50:56 1.35
+++ rs6000-tdep.c 2002/01/11 21:56:17
@@ -83,6 +83,10 @@ struct reg
unsigned char fpr; /* whether register is floating-point */
};
+/* Create some pre-defined types. */
+static struct type *builtin_type_powerpc_altivec;
+
/* Return the current architecture's gdbarch_tdep structure. */
#define TDEP gdbarch_tdep (current_gdbarch)
@@ -1530,6 +1534,52 @@ rs6000_register_raw_size (int n)
return regsize (reg, tdep->wordsize);
}
+static struct type *
+build_builtin_type_powerpc_altivec (void)
+{
+ /* Construct a type for the AltiVec registers. The type we're building
+ is this: */
+#if 0
+ union __gdb_builtin_type_powerpc_altivec
+ {
+ struct __builtin_v16qi v16qi;
+ struct __builtin_v8hi v8hi;
+ struct __builtin_v4si v4si;
+ struct __builtin_v4sf v4sf;
+ uint128_t uint128;
+ };
+#endif
+
+ struct type *t;
+ struct field *f;
+
+ f = (struct field *) xmalloc (sizeof (*f) * 5);
+ memset (f, 0, sizeof (*f) * 5);
+
+ FIELD_TYPE (f[0]) = builtin_type_int128;
+ FIELD_NAME (f[0]) = "uint128";
+
+ FIELD_TYPE (f[1]) = builtin_type_v4sf;
+ FIELD_NAME (f[1]) = "v4sf";
+
+ FIELD_TYPE (f[2]) = builtin_type_v4si;
+ FIELD_NAME (f[2]) = "v4si";
+
+ FIELD_TYPE (f[3]) = builtin_type_v8hi;
+ FIELD_NAME (f[3]) = "v8hi";
+
+ FIELD_TYPE (f[4]) = builtin_type_v16qi;
+ FIELD_NAME (f[4]) = "v16qi";
+
+ /* Build a union type with those fields. */
+ t = init_type (TYPE_CODE_UNION, 16, 0, 0, 0);
+ TYPE_NFIELDS (t) = 5;
+ TYPE_FIELDS (t) = f;
+ TYPE_TAG_NAME (t) = "__gdb_builtin_type_powerpc_altivec";
+
+ return t;
+}
+
/* Return the GDB type object for the "standard" data type
of data in register N. */
@@ -1550,7 +1600,7 @@ rs6000_register_virtual_type (int n)
return builtin_type_int64;
break;
case 16:
- return builtin_type_int128;
+ return builtin_type_powerpc_altivec;
break;
default:
return builtin_type_int32;
@@ -2653,6 +2703,8 @@ _initialize_rs6000_tdep (void)
{
register_gdbarch_init (bfd_arch_rs6000, rs6000_gdbarch_init);
register_gdbarch_init (bfd_arch_powerpc, rs6000_gdbarch_init);
+
+ builtin_type_powerpc_altivec = build_builtin_type_powerpc_altivec ();
/* Add root prefix command for "info powerpc" commands */
add_prefix_cmd ("powerpc", class_info, rs6000_info_powerpc_command,
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [RFA] gdbtypes.[ch] rs6000-tdep.c--AltiVec regs types
2002-01-11 15:20 [RFA] gdbtypes.[ch] rs6000-tdep.c--AltiVec regs types Elena Zannoni
@ 2002-01-11 15:28 ` Daniel Jacobowitz
2002-01-11 15:47 ` Michael Snyder
2002-01-11 17:04 ` Andrew Cagney
2002-01-14 16:41 ` Elena Zannoni
2 siblings, 1 reply; 10+ messages in thread
From: Daniel Jacobowitz @ 2002-01-11 15:28 UTC (permalink / raw)
To: gdb-patches
On Fri, Jan 11, 2002 at 05:32:45PM -0500, Elena Zannoni wrote:
>
> This patch provides a builtin union type for the AltiVec registers,
> so that the printing of such regs is a bit more enlightening, like:
>
>
> (gdb) p $vr0
> $2 = {uint128 = 0x00000064000000c80000012c00000190,
> v4sf = {f = {1.40129846e-43, 2.80259693e-43, 4.20389539e-43, 5.60519386e-43}},
> v4si = {f = {100, 200, 300, 400}},
> v8hi = {f = {0, 100, 0, 200, 0, 300, 0, 400}},
> v16qi = {f = "\0\0\0d\0\0\0Ã\0\0\001,\0\0\001\220"}}
> (gdb) p $vr0.v4si
> $3 = {f = {100, 200, 300, 400}}
> (gdb) p $vr0.v4si.f[2]
> $4 = 300
> (gdb) p $vr0.v4si.f[2]=444
> $5 = 444
Why is the .f necessary? Why not make $vr0.v4si an array rather than
struct type?
> 2002-01-11 Elena Zannoni <ezannoni@redhat.com>
>
> [Based on work by Jim Blandy]
>
> * rs6000-tdep.c: Declare predifined type for AltiVec registers.
Typo - predefined.
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [RFA] gdbtypes.[ch] rs6000-tdep.c--AltiVec regs types
2002-01-11 15:28 ` Daniel Jacobowitz
@ 2002-01-11 15:47 ` Michael Snyder
2002-01-11 15:55 ` Daniel Jacobowitz
2002-01-14 8:12 ` Elena Zannoni
0 siblings, 2 replies; 10+ messages in thread
From: Michael Snyder @ 2002-01-11 15:47 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
Daniel Jacobowitz wrote:
>
> On Fri, Jan 11, 2002 at 05:32:45PM -0500, Elena Zannoni wrote:
> >
> > This patch provides a builtin union type for the AltiVec registers,
> > so that the printing of such regs is a bit more enlightening, like:
> >
> >
> > (gdb) p $vr0
> > $2 = {uint128 = 0x00000064000000c80000012c00000190,
> > v4sf = {f = {1.40129846e-43, 2.80259693e-43, 4.20389539e-43, 5.60519386e-43}},
> > v4si = {f = {100, 200, 300, 400}},
> > v8hi = {f = {0, 100, 0, 200, 0, 300, 0, 400}},
> > v16qi = {f = "\0\0\0d\0\0\0È\0\0\001,\0\0\001\220"}}
> > (gdb) p $vr0.v4si
> > $3 = {f = {100, 200, 300, 400}}
> > (gdb) p $vr0.v4si.f[2]
> > $4 = 300
> > (gdb) p $vr0.v4si.f[2]=444
> > $5 = 444
>
> Why is the .f necessary? Why not make $vr0.v4si an array rather than
> struct type?
I know this is historical (it's been done the same way for other
targets),
and I'm guessing it's because a struct type can be passed by value,
while
an array type is always passed by reference. You want a type that can
be passed to a function.
I should know this (I've dealt with it before), but my
memory cache is shrinking with age and misuse. ;-(
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [RFA] gdbtypes.[ch] rs6000-tdep.c--AltiVec regs types
2002-01-11 15:47 ` Michael Snyder
@ 2002-01-11 15:55 ` Daniel Jacobowitz
2002-01-14 8:12 ` Elena Zannoni
1 sibling, 0 replies; 10+ messages in thread
From: Daniel Jacobowitz @ 2002-01-11 15:55 UTC (permalink / raw)
To: gdb-patches
On Fri, Jan 11, 2002 at 03:42:16PM -0800, Michael Snyder wrote:
> Daniel Jacobowitz wrote:
> >
> > On Fri, Jan 11, 2002 at 05:32:45PM -0500, Elena Zannoni wrote:
> > >
> > > This patch provides a builtin union type for the AltiVec registers,
> > > so that the printing of such regs is a bit more enlightening, like:
> > >
> > >
> > > (gdb) p $vr0
> > > $2 = {uint128 = 0x00000064000000c80000012c00000190,
> > > v4sf = {f = {1.40129846e-43, 2.80259693e-43, 4.20389539e-43, 5.60519386e-43}},
> > > v4si = {f = {100, 200, 300, 400}},
> > > v8hi = {f = {0, 100, 0, 200, 0, 300, 0, 400}},
> > > v16qi = {f = "\0\0\0d\0\0\0Ã\0\0\001,\0\0\001\220"}}
> > > (gdb) p $vr0.v4si
> > > $3 = {f = {100, 200, 300, 400}}
> > > (gdb) p $vr0.v4si.f[2]
> > > $4 = 300
> > > (gdb) p $vr0.v4si.f[2]=444
> > > $5 = 444
> >
> > Why is the .f necessary? Why not make $vr0.v4si an array rather than
> > struct type?
>
> I know this is historical (it's been done the same way for other
> targets),
> and I'm guessing it's because a struct type can be passed by value,
> while
> an array type is always passed by reference. You want a type that can
> be passed to a function.
>
> I should know this (I've dealt with it before), but my
> memory cache is shrinking with age and misuse. ;-(
Hmm, could we accomplish this with an analogue to anonymous unions, I
wonder?... a question for another time.
union altivec_register {
struct v4sf { float v4sf[4]; };
...
};
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [RFA] gdbtypes.[ch] rs6000-tdep.c--AltiVec regs types
2002-01-11 15:47 ` Michael Snyder
2002-01-11 15:55 ` Daniel Jacobowitz
@ 2002-01-14 8:12 ` Elena Zannoni
1 sibling, 0 replies; 10+ messages in thread
From: Elena Zannoni @ 2002-01-14 8:12 UTC (permalink / raw)
To: Michael Snyder; +Cc: Daniel Jacobowitz, gdb-patches
Michael Snyder writes:
> Daniel Jacobowitz wrote:
> >
> > On Fri, Jan 11, 2002 at 05:32:45PM -0500, Elena Zannoni wrote:
> > >
> > > This patch provides a builtin union type for the AltiVec registers,
> > > so that the printing of such regs is a bit more enlightening, like:
> > >
> > >
> > > (gdb) p $vr0
> > > $2 = {uint128 = 0x00000064000000c80000012c00000190,
> > > v4sf = {f = {1.40129846e-43, 2.80259693e-43, 4.20389539e-43, 5.60519386e-43}},
> > > v4si = {f = {100, 200, 300, 400}},
> > > v8hi = {f = {0, 100, 0, 200, 0, 300, 0, 400}},
> > > v16qi = {f = "\0\0\0d\0\0\0È\0\0\001,\0\0\001\220"}}
> > > (gdb) p $vr0.v4si
> > > $3 = {f = {100, 200, 300, 400}}
> > > (gdb) p $vr0.v4si.f[2]
> > > $4 = 300
> > > (gdb) p $vr0.v4si.f[2]=444
> > > $5 = 444
> >
> > Why is the .f necessary? Why not make $vr0.v4si an array rather than
> > struct type?
>
> I know this is historical (it's been done the same way for other
> targets),
> and I'm guessing it's because a struct type can be passed by value,
> while
> an array type is always passed by reference. You want a type that can
> be passed to a function.
>
> I should know this (I've dealt with it before), but my
> memory cache is shrinking with age and misuse. ;-(
Yes, I found an old ChangeLog entry about this, saying the following:
"The compiler needs to use a struct because arrays aren't assignable,
and the compiler and the debugger should agree."
Elena
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFA] gdbtypes.[ch] rs6000-tdep.c--AltiVec regs types
2002-01-11 15:20 [RFA] gdbtypes.[ch] rs6000-tdep.c--AltiVec regs types Elena Zannoni
2002-01-11 15:28 ` Daniel Jacobowitz
@ 2002-01-11 17:04 ` Andrew Cagney
2002-01-11 20:47 ` Elena Zannoni
2002-01-14 16:41 ` Elena Zannoni
2 siblings, 1 reply; 10+ messages in thread
From: Andrew Cagney @ 2002-01-11 17:04 UTC (permalink / raw)
To: Elena Zannoni; +Cc: gdb-patches
Your post prompted me to dig. It is just that I kind of regret this
exposure of a GCC internal naming convention (SI, QI, FI, HI, ...) to
the innocent end user. Is the convention really set in stone or can we
reform our ways? :-)
The relevant thread is:
http://sources.redhat.com/ml/gdb-patches/1999-q4/msg00316.html
As an aside, it did take a few years but there are now both more
explicit builtin fp types (see builtin_type_ieee ...); and implemented
the virtual to raw register mapping the thread talks about for MMX. The
i386 MMX registers can finally be implemented as (looks in sandpit, for
wip code):
static void
i386_register_read (struct gdbarch *gdbarch, int regnum, char *buf)
{
if (is_mmx_regnum (regnum))
{
char *mmx_buf = alloca (MAX_REGISTER_RAW_SIZE);
int fpnum = mmnum_to_fpnum (regnum);
regcache_read (fpnum, mmx_buf);
/* Extract (always little endian). */
memcpy (buf, mmx_buf, REGISTER_RAW_SIZE (regnum));
}
else
regcache_read (regnum, buf);
}
(probably time to submit that patch).
Anyway, regarding your patch, perhaps move the construct to
gdbtypes.[hc] to encourage its re-use by other Altivecish targets.
Andrew
PS: Check the man page for [x]calloc() GDB could benefit from its use.
Two questions.
> +static struct type *
> +build_builtin_type_powerpc_altivec (void)
> +{
> + /* Construct a type for the AltiVec registers. The type we're building
> + is this: */
> +#if 0
> + union __gdb_builtin_type_powerpc_altivec
> + {
> + struct __builtin_v16qi v16qi;
> + struct __builtin_v8hi v8hi;
> + struct __builtin_v4si v4si;
> + struct __builtin_v4sf v4sf;
> + uint128_t uint128;
> + };
> +#endif
> +
> + struct type *t;
> + struct field *f;
> +
> + f = (struct field *) xmalloc (sizeof (*f) * 5);
> + memset (f, 0, sizeof (*f) * 5);
> +
> + FIELD_TYPE (f[0]) = builtin_type_int128;
> + FIELD_NAME (f[0]) = "uint128";
> +
> + FIELD_TYPE (f[1]) = builtin_type_v4sf;
> + FIELD_NAME (f[1]) = "v4sf";
> +
> + FIELD_TYPE (f[2]) = builtin_type_v4si;
> + FIELD_NAME (f[2]) = "v4si";
> +
> + FIELD_TYPE (f[3]) = builtin_type_v8hi;
> + FIELD_NAME (f[3]) = "v8hi";
> +
> + FIELD_TYPE (f[4]) = builtin_type_v16qi;
> + FIELD_NAME (f[4]) = "v16qi";
> +
> + /* Build a union type with those fields. */
> + t = init_type (TYPE_CODE_UNION, 16, 0, 0, 0);
> + TYPE_NFIELDS (t) = 5;
> + TYPE_FIELDS (t) = f;
> + TYPE_TAG_NAME (t) = "__gdb_builtin_type_powerpc_altivec";
> +
> + return t;
> +}
> +
>
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [RFA] gdbtypes.[ch] rs6000-tdep.c--AltiVec regs types
2002-01-11 17:04 ` Andrew Cagney
@ 2002-01-11 20:47 ` Elena Zannoni
0 siblings, 0 replies; 10+ messages in thread
From: Elena Zannoni @ 2002-01-11 20:47 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Elena Zannoni, gdb-patches
Andrew Cagney writes:
> Your post prompted me to dig. It is just that I kind of regret this
> exposure of a GCC internal naming convention (SI, QI, FI, HI, ...) to
> the innocent end user. Is the convention really set in stone or can we
> reform our ways? :-)
Actually I wish we could make it more readable. Or at least add some
comments in gdbtypes.c. Or some intenal doco.
>
> The relevant thread is:
> http://sources.redhat.com/ml/gdb-patches/1999-q4/msg00316.html
>
Was this discussion a precursor to Pseudoregs? It reads that way.
> As an aside, it did take a few years but there are now both more
> explicit builtin fp types (see builtin_type_ieee ...); and implemented
> the virtual to raw register mapping the thread talks about for MMX. The
> i386 MMX registers can finally be implemented as (looks in sandpit, for
> wip code):
>
> static void
> i386_register_read (struct gdbarch *gdbarch, int regnum, char *buf)
> {
> if (is_mmx_regnum (regnum))
> {
> char *mmx_buf = alloca (MAX_REGISTER_RAW_SIZE);
> int fpnum = mmnum_to_fpnum (regnum);
> regcache_read (fpnum, mmx_buf);
> /* Extract (always little endian). */
> memcpy (buf, mmx_buf, REGISTER_RAW_SIZE (regnum));
> }
> else
> regcache_read (regnum, buf);
> }
>
> (probably time to submit that patch).
>
>
> Anyway, regarding your patch, perhaps move the construct to
> gdbtypes.[hc] to encourage its re-use by other Altivecish targets.
>
Ah, I see, there are other target specific types in there.
> Andrew
>
> PS: Check the man page for [x]calloc() GDB could benefit from its use.
>
>
>
> Two questions.
>
> > +static struct type *
> > +build_builtin_type_powerpc_altivec (void)
> > +{
> > + /* Construct a type for the AltiVec registers. The type we're building
> > + is this: */
> > +#if 0
> > + union __gdb_builtin_type_powerpc_altivec
> > + {
> > + struct __builtin_v16qi v16qi;
> > + struct __builtin_v8hi v8hi;
> > + struct __builtin_v4si v4si;
> > + struct __builtin_v4sf v4sf;
> > + uint128_t uint128;
> > + };
> > +#endif
> > +
> > + struct type *t;
> > + struct field *f;
> > +
> > + f = (struct field *) xmalloc (sizeof (*f) * 5);
> > + memset (f, 0, sizeof (*f) * 5);
> > +
> > + FIELD_TYPE (f[0]) = builtin_type_int128;
> > + FIELD_NAME (f[0]) = "uint128";
> > +
> > + FIELD_TYPE (f[1]) = builtin_type_v4sf;
> > + FIELD_NAME (f[1]) = "v4sf";
> > +
> > + FIELD_TYPE (f[2]) = builtin_type_v4si;
> > + FIELD_NAME (f[2]) = "v4si";
> > +
> > + FIELD_TYPE (f[3]) = builtin_type_v8hi;
> > + FIELD_NAME (f[3]) = "v8hi";
> > +
> > + FIELD_TYPE (f[4]) = builtin_type_v16qi;
> > + FIELD_NAME (f[4]) = "v16qi";
> > +
> > + /* Build a union type with those fields. */
> > + t = init_type (TYPE_CODE_UNION, 16, 0, 0, 0);
> > + TYPE_NFIELDS (t) = 5;
> > + TYPE_FIELDS (t) = f;
> > + TYPE_TAG_NAME (t) = "__gdb_builtin_type_powerpc_altivec";
> > +
> > + return t;
> > +}
> > +
> >
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFA] gdbtypes.[ch] rs6000-tdep.c--AltiVec regs types
2002-01-11 15:20 [RFA] gdbtypes.[ch] rs6000-tdep.c--AltiVec regs types Elena Zannoni
2002-01-11 15:28 ` Daniel Jacobowitz
2002-01-11 17:04 ` Andrew Cagney
@ 2002-01-14 16:41 ` Elena Zannoni
2002-01-14 18:13 ` Kevin Buettner
2 siblings, 1 reply; 10+ messages in thread
From: Elena Zannoni @ 2002-01-14 16:41 UTC (permalink / raw)
To: gdb-patches
Elena Zannoni writes:
>
> This patch provides a builtin union type for the AltiVec registers,
> so that the printing of such regs is a bit more enlightening, like:
>
>
> (gdb) p $vr0
> $2 = {uint128 = 0x00000064000000c80000012c00000190,
> v4sf = {f = {1.40129846e-43, 2.80259693e-43, 4.20389539e-43, 5.60519386e-43}},
> v4si = {f = {100, 200, 300, 400}},
> v8hi = {f = {0, 100, 0, 200, 0, 300, 0, 400}},
> v16qi = {f = "\0\0\0d\0\0\0È\0\0\001,\0\0\001\220"}}
> (gdb) p $vr0.v4si
> $3 = {f = {100, 200, 300, 400}}
> (gdb) p $vr0.v4si.f[2]
> $4 = 300
> (gdb) p $vr0.v4si.f[2]=444
> $5 = 444
>
>
> Elena
>
Resubmitting, moved type creation code to gdbtypes.c, used xcalloc().
OK?
Elena
2002-01-14 Elena Zannoni <ezannoni@redhat.com>
* gdbtypes.h (builtin_type_v16qi, builtin_type_v8hi): Export.
(builtin_type_powerpc_altivec): Export.
* gdbtypes.c (builtin_type_v16qi, builtin_type_v8hi): New SIMD
types.
(builtin_type_powerpc_altivec): New builtin type for AltiVec
registers.
(build_gdbtypes): Initialize builtin_type_v16qi and
builtin_type_v8hi.
(build_builtin_type_powerpc_altivec): New function.
(_initialize_gdbtypes): Register builtin_type_v16qi and
builtin_type_v8hi with gdbarch. Create the altivec register
builtin type structure.
* rs6000-tdep.c (rs6000_register_virtual_type): Change type of
AltiVec register to new builtin type.
Index: gdbtypes.c
===================================================================
RCS file: /cvs/uberbaum/gdb/gdbtypes.c,v
retrieving revision 1.35
diff -u -p -r1.35 gdbtypes.c
--- gdbtypes.c 2001/12/20 03:26:08 1.35
+++ gdbtypes.c 2002/01/14 23:57:04
@@ -73,7 +73,9 @@ struct type *builtin_type_uint128;
struct type *builtin_type_bool;
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_ieee_single_big;
@@ -92,6 +94,7 @@ struct type *builtin_type_ia64_spill_big
struct type *builtin_type_ia64_spill_little;
struct type *builtin_type_ia64_quad_big;
struct type *builtin_type_ia64_quad_little;
+struct type *builtin_type_powerpc_altivec;
struct type *builtin_type_void_data_ptr;
struct type *builtin_type_void_func_ptr;
struct type *builtin_type_CORE_ADDR;
@@ -785,7 +788,51 @@ init_simd_type (char *name,
return t;
}
+static struct type *
+build_builtin_type_powerpc_altivec (void)
+{
+ /* Construct a type for the AltiVec registers. The type we're building
+ is this: */
+#if 0
+ union __gdb_builtin_type_powerpc_altivec
+ {
+ struct __builtin_v16qi v16qi;
+ struct __builtin_v8hi v8hi;
+ struct __builtin_v4si v4si;
+ struct __builtin_v4sf v4sf;
+ uint128_t uint128;
+ };
+#endif
+
+ struct type *t;
+ struct field *f;
+
+ f = (struct field *) xcalloc (5, sizeof (*f));
+
+ FIELD_TYPE (f[0]) = builtin_type_int128;
+ FIELD_NAME (f[0]) = "uint128";
+ FIELD_TYPE (f[1]) = builtin_type_v4sf;
+ FIELD_NAME (f[1]) = "v4sf";
+
+ FIELD_TYPE (f[2]) = builtin_type_v4si;
+ FIELD_NAME (f[2]) = "v4si";
+
+ FIELD_TYPE (f[3]) = builtin_type_v8hi;
+ FIELD_NAME (f[3]) = "v8hi";
+
+ FIELD_TYPE (f[4]) = builtin_type_v16qi;
+ FIELD_NAME (f[4]) = "v16qi";
+
+ /* Build a union type with those fields. */
+ t = init_type (TYPE_CODE_UNION, 16, 0, 0, 0);
+ TYPE_NFIELDS (t) = 5;
+ TYPE_FIELDS (t) = f;
+ TYPE_TAG_NAME (t) = "__gdb_builtin_type_powerpc_altivec";
+
+ 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
@@ -3163,8 +3210,12 @@ build_gdbtypes (void)
= 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
@@ -3252,7 +3303,9 @@ _initialize_gdbtypes (void)
register_gdbarch_swap (&builtin_type_uint128, sizeof (struct type *), NULL);
register_gdbarch_swap (&builtin_type_v4sf, sizeof (struct type *), NULL);
register_gdbarch_swap (&builtin_type_v4si, sizeof (struct type *), NULL);
+ register_gdbarch_swap (&builtin_type_v16qi, sizeof (struct type *), NULL);
register_gdbarch_swap (&builtin_type_v8qi, sizeof (struct type *), NULL);
+ 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_void_data_ptr);
@@ -3313,6 +3366,9 @@ _initialize_gdbtypes (void)
builtin_type_ia64_quad_little =
init_type (TYPE_CODE_FLT, floatformat_ia64_quad_little.totalsize / 8,
0, "builtin_type_ia64_quad_little", NULL);
+
+ builtin_type_powerpc_altivec
+ = build_builtin_type_powerpc_altivec ();
add_show_from_set (
add_set_cmd ("overload", no_class, var_zinteger, (char *) &overload_debug,
Index: gdbtypes.h
===================================================================
RCS file: /cvs/uberbaum/gdb/gdbtypes.h,v
retrieving revision 1.21
diff -u -p -r1.21 gdbtypes.h
--- gdbtypes.h 2001/12/10 06:17:01 1.21
+++ gdbtypes.h 2002/01/14 23:57:09
@@ -946,9 +946,14 @@ 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;
+
+/* Type for AltiVec registers on PowerPC. */
+extern struct type *builtin_type_powerpc_altivec;
/* Explicit floating-point formats. See "floatformat.h". */
extern struct type *builtin_type_ieee_single_big;
Index: rs6000-tdep.c
===================================================================
RCS file: /cvs/uberbaum/gdb/rs6000-tdep.c,v
retrieving revision 1.35
diff -u -p -r1.35 rs6000-tdep.c
--- rs6000-tdep.c 2002/01/06 04:50:56 1.35
+++ rs6000-tdep.c 2002/01/14 23:57:11
@@ -1550,7 +1550,7 @@ rs6000_register_virtual_type (int n)
return builtin_type_int64;
break;
case 16:
- return builtin_type_int128;
+ return builtin_type_powerpc_altivec;
break;
default:
return builtin_type_int32;
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [RFA] gdbtypes.[ch] rs6000-tdep.c--AltiVec regs types
2002-01-14 16:41 ` Elena Zannoni
@ 2002-01-14 18:13 ` Kevin Buettner
2002-01-15 11:39 ` Elena Zannoni
0 siblings, 1 reply; 10+ messages in thread
From: Kevin Buettner @ 2002-01-14 18:13 UTC (permalink / raw)
To: Elena Zannoni, gdb-patches
On Jan 14, 6:54pm, Elena Zannoni wrote:
> Resubmitting, moved type creation code to gdbtypes.c, used xcalloc().
>
> OK?
The parts that I can approve are okay with me.
Kevin
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFA] gdbtypes.[ch] rs6000-tdep.c--AltiVec regs types
2002-01-14 18:13 ` Kevin Buettner
@ 2002-01-15 11:39 ` Elena Zannoni
0 siblings, 0 replies; 10+ messages in thread
From: Elena Zannoni @ 2002-01-15 11:39 UTC (permalink / raw)
To: Kevin Buettner; +Cc: Elena Zannoni, gdb-patches
Kevin Buettner writes:
> On Jan 14, 6:54pm, Elena Zannoni wrote:
>
> > Resubmitting, moved type creation code to gdbtypes.c, used xcalloc().
> >
> > OK?
>
> The parts that I can approve are okay with me.
>
> Kevin
OK, I checked in the following: I changed the name from
builtin_type_powerpc_altivec to builtin_type_vec128, so that it
can be used by other targets.
Elena
2002-01-15 Elena Zannoni <ezannoni@redhat.com>
[Based on work by Jim Blandy]
* gdbtypes.h (builtin_type_v16qi, builtin_type_v8hi): Export.
(builtin_type_vec128): Export.
* gdbtypes.c (builtin_type_v16qi, builtin_type_v8hi): New SIMD
types.
(builtin_type_vec128): New builtin type for 128 bit vector
registers.
(build_gdbtypes): Initialize builtin_type_v16qi and
builtin_type_v8hi. Create the vec128 register builtin type
structure.
(build_builtin_type_vec128): New function.
(_initialize_gdbtypes): Register builtin_type_v16qi and
builtin_type_v8hi with gdbarch. Same for builtin_type_vec128.
* rs6000-tdep.c (rs6000_register_virtual_type): Change type of
AltiVec register to new builtin type.
Index: gdbtypes.c
===================================================================
RCS file: /cvs/uberbaum/gdb/gdbtypes.c,v
retrieving revision 1.35
diff -u -p -r1.35 gdbtypes.c
--- gdbtypes.c 2001/12/20 03:26:08 1.35
+++ gdbtypes.c 2002/01/15 16:46:48
@@ -73,9 +73,12 @@ struct type *builtin_type_uint128;
struct type *builtin_type_bool;
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_vec128;
struct type *builtin_type_ieee_single_big;
struct type *builtin_type_ieee_single_little;
struct type *builtin_type_ieee_double_big;
@@ -785,7 +788,51 @@ init_simd_type (char *name,
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
+ {
+ struct __builtin_v16qi v16qi;
+ struct __builtin_v8hi v8hi;
+ struct __builtin_v4si v4si;
+ struct __builtin_v4sf v4sf;
+ uint128_t uint128;
+ };
+#endif
+
+ struct type *t;
+ struct field *f;
+
+ f = (struct field *) xcalloc (5, sizeof (*f));
+
+ FIELD_TYPE (f[0]) = builtin_type_int128;
+ FIELD_NAME (f[0]) = "uint128";
+ FIELD_TYPE (f[1]) = builtin_type_v4sf;
+ FIELD_NAME (f[1]) = "v4sf";
+
+ FIELD_TYPE (f[2]) = builtin_type_v4si;
+ FIELD_NAME (f[2]) = "v4si";
+
+ FIELD_TYPE (f[3]) = builtin_type_v8hi;
+ FIELD_NAME (f[3]) = "v8hi";
+
+ FIELD_TYPE (f[4]) = builtin_type_v16qi;
+ FIELD_NAME (f[4]) = "v16qi";
+
+ /* Build a union type with those fields. */
+ t = init_type (TYPE_CODE_UNION, 16, 0, 0, 0);
+ TYPE_NFIELDS (t) = 5;
+ TYPE_FIELDS (t) = f;
+ TYPE_TAG_NAME (t) = "__gdb_builtin_type_vec128";
+
+ 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
@@ -3163,13 +3210,21 @@ build_gdbtypes (void)
= 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);
+ /* Vector types. */
+ builtin_type_vec128
+ = build_builtin_type_vec128 ();
+
/* Pointer/Address types. */
/* NOTE: on some targets, addresses and pointers are not necessarily
@@ -3252,9 +3307,12 @@ _initialize_gdbtypes (void)
register_gdbarch_swap (&builtin_type_uint128, sizeof (struct type *), NULL);
register_gdbarch_swap (&builtin_type_v4sf, sizeof (struct type *), NULL);
register_gdbarch_swap (&builtin_type_v4si, sizeof (struct type *), NULL);
+ register_gdbarch_swap (&builtin_type_v16qi, sizeof (struct type *), NULL);
register_gdbarch_swap (&builtin_type_v8qi, sizeof (struct type *), NULL);
+ 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_vec128, 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);
Index: gdbtypes.h
===================================================================
RCS file: /cvs/uberbaum/gdb/gdbtypes.h,v
retrieving revision 1.21
diff -u -p -r1.21 gdbtypes.h
--- gdbtypes.h 2001/12/10 06:17:01 1.21
+++ gdbtypes.h 2002/01/15 16:46:49
@@ -946,9 +946,14 @@ 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;
+
+/* Type for 128 bit vectors. */
+extern struct type *builtin_type_vec128;
/* Explicit floating-point formats. See "floatformat.h". */
extern struct type *builtin_type_ieee_single_big;
Index: rs6000-tdep.c
===================================================================
RCS file: /cvs/uberbaum/gdb/rs6000-tdep.c,v
retrieving revision 1.35
diff -u -p -r1.35 rs6000-tdep.c
--- rs6000-tdep.c 2002/01/06 04:50:56 1.35
+++ rs6000-tdep.c 2002/01/15 16:46:51
@@ -1550,7 +1550,7 @@ rs6000_register_virtual_type (int n)
return builtin_type_int64;
break;
case 16:
- return builtin_type_int128;
+ return builtin_type_vec128;
break;
default:
return builtin_type_int32;
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2002-01-15 19:39 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-11 15:20 [RFA] gdbtypes.[ch] rs6000-tdep.c--AltiVec regs types Elena Zannoni
2002-01-11 15:28 ` Daniel Jacobowitz
2002-01-11 15:47 ` Michael Snyder
2002-01-11 15:55 ` Daniel Jacobowitz
2002-01-14 8:12 ` Elena Zannoni
2002-01-11 17:04 ` Andrew Cagney
2002-01-11 20:47 ` Elena Zannoni
2002-01-14 16:41 ` Elena Zannoni
2002-01-14 18:13 ` Kevin Buettner
2002-01-15 11:39 ` Elena Zannoni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox