Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Maxim Grigoriev <maxim@tensilica.com>
To: gdb-patches@sources.redhat.com
Subject: Add Xtensa register groups for coprocessors
Date: Wed, 08 Aug 2007 23:23:00 -0000	[thread overview]
Message-ID: <46BA506E.6090605@hq.tensilica.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 130 bytes --]

This patch adds support for Xtensa-specific register groups associated 
with co-processors.

I've committed this patch.

-- Maxim

[-- Attachment #2: xtensa-patch.diff --]
[-- Type: text/x-patch, Size: 4716 bytes --]

2007-08-08  Maxim Grigoriev  <maxim2405@gmail.com>

	* xtensa-tdep.h (XTENSA_MAX_COPROCESSOR): New.
	(xtensa_register_group_t): Add entries for coprocessors.
	* xtensa-tdep.c (xtensa_init_reggroups): New register groups.
	(xtensa_add_reggroups): Likewise.
	(xtensa_register_reggroup_p): Likewise.
	(xtensa_coprocessor_register_group): New function.
	(xtensa_cp): New.

Index: gdb/xtensa-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/xtensa-tdep.h,v
retrieving revision 1.4
diff -u -r1.4 xtensa-tdep.h
--- gdb/xtensa-tdep.h	31 May 2007 17:32:21 -0000	1.4
+++ gdb/xtensa-tdep.h	8 Aug 2007 23:05:23 -0000
@@ -44,6 +44,8 @@
 
 /*  Xtensa register group.  */
 
+#define XTENSA_MAX_COPROCESSOR	0x08  /* Number of Xtensa coprocessors.  */
+
 typedef enum 
 {
   xtRegisterGroupUnknown = 0,
@@ -58,6 +60,16 @@
   xtRegisterGroupFloat		= 0x0400,    /* Floating Point.  */
   xtRegisterGroupVectra		= 0x0800,    /* Vectra.  */
   xtRegisterGroupSystem		= 0x1000,    /* System.  */
+
+  xtRegisterGroupCP0	    = 0x01000000,    /* CP0.  */
+  xtRegisterGroupCP1	    = 0x02000000,    /* CP1.  */
+  xtRegisterGroupCP2	    = 0x04000000,    /* CP2.  */
+  xtRegisterGroupCP3	    = 0x08000000,    /* CP3.  */
+  xtRegisterGroupCP4	    = 0x10000000,    /* CP4.  */
+  xtRegisterGroupCP5	    = 0x20000000,    /* CP5.  */
+  xtRegisterGroupCP6	    = 0x40000000,    /* CP6.  */
+  xtRegisterGroupCP7	    = 0x80000000,    /* CP7.  */
+
 } xtensa_register_group_t;
 
 
Index: gdb/xtensa-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/xtensa-tdep.c,v
retrieving revision 1.9
diff -u -r1.9 xtensa-tdep.c
--- gdb/xtensa-tdep.c	18 Jun 2007 17:45:26 -0000	1.9
+++ gdb/xtensa-tdep.c	8 Aug 2007 23:05:30 -0000
@@ -658,6 +658,7 @@
 static struct reggroup *xtensa_ar_reggroup;
 static struct reggroup *xtensa_user_reggroup;
 static struct reggroup *xtensa_vectra_reggroup;
+static struct reggroup *xtensa_cp[XTENSA_MAX_COPROCESSOR];
 
 static void
 xtensa_init_reggroups (void)
@@ -665,25 +666,51 @@
   xtensa_ar_reggroup = reggroup_new ("ar", USER_REGGROUP);
   xtensa_user_reggroup = reggroup_new ("user", USER_REGGROUP);
   xtensa_vectra_reggroup = reggroup_new ("vectra", USER_REGGROUP);
-}
 
+  xtensa_cp[0] = reggroup_new ("cp0", USER_REGGROUP);
+  xtensa_cp[1] = reggroup_new ("cp1", USER_REGGROUP);
+  xtensa_cp[2] = reggroup_new ("cp2", USER_REGGROUP);
+  xtensa_cp[3] = reggroup_new ("cp3", USER_REGGROUP);
+  xtensa_cp[4] = reggroup_new ("cp4", USER_REGGROUP);
+  xtensa_cp[5] = reggroup_new ("cp5", USER_REGGROUP);
+  xtensa_cp[6] = reggroup_new ("cp6", USER_REGGROUP);
+  xtensa_cp[7] = reggroup_new ("cp7", USER_REGGROUP);
+}
 
 static void
 xtensa_add_reggroups (struct gdbarch *gdbarch)
 {
+  int i;
+
+  /* Predefined groups.  */
   reggroup_add (gdbarch, all_reggroup);
   reggroup_add (gdbarch, save_reggroup);
   reggroup_add (gdbarch, restore_reggroup);
   reggroup_add (gdbarch, system_reggroup);
-  reggroup_add (gdbarch, vector_reggroup);		/* vectra */
-  reggroup_add (gdbarch, general_reggroup);		/* core */
-  reggroup_add (gdbarch, float_reggroup);		/* float */
-
-  reggroup_add (gdbarch, xtensa_ar_reggroup);		/* ar */
-  reggroup_add (gdbarch, xtensa_user_reggroup);		/* user */
-  reggroup_add (gdbarch, xtensa_vectra_reggroup);	/* vectra */
+  reggroup_add (gdbarch, vector_reggroup);
+  reggroup_add (gdbarch, general_reggroup);
+  reggroup_add (gdbarch, float_reggroup);
+
+  /* Xtensa-specific groups.  */
+  reggroup_add (gdbarch, xtensa_ar_reggroup);
+  reggroup_add (gdbarch, xtensa_user_reggroup);
+  reggroup_add (gdbarch, xtensa_vectra_reggroup);
+
+  for (i = 0; i < XTENSA_MAX_COPROCESSOR; i++)
+    reggroup_add (gdbarch, xtensa_cp[i]);
 }
 
+static int 
+xtensa_coprocessor_register_group (struct reggroup *group)
+{
+  int i;
+
+  for (i = 0; i < XTENSA_MAX_COPROCESSOR; i++)
+    if (group == xtensa_cp[i])
+      return i;
+
+  return -1;
+}
 
 #define SAVE_REST_FLAGS	(XTENSA_REGISTER_FLAGS_READABLE \
 			| XTENSA_REGISTER_FLAGS_WRITABLE \
@@ -700,6 +727,7 @@
   xtensa_register_t* reg = &REGMAP[regnum];
   xtensa_register_type_t type = reg->type;
   xtensa_register_group_t rg = reg->group;
+  int cp_number;
 
   /* First, skip registers that are not visible to this target
      (unknown and unmapped registers when not using ISS).  */
@@ -725,6 +753,8 @@
   if (group == save_reggroup || group == restore_reggroup)
     return (regnum < gdbarch_num_regs (current_gdbarch)
 	    && (reg->flags & SAVE_REST_FLAGS) == SAVE_REST_VALID);
+  if ((cp_number = xtensa_coprocessor_register_group (group)) >= 0)
+    return rg & (xtRegisterGroupCP0 << cp_number);
   else
     return 1;
 }

                 reply	other threads:[~2007-08-08 23:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46BA506E.6090605@hq.tensilica.com \
    --to=maxim@tensilica.com \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox