summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@suse.de>2009-09-08 09:47:51 +0000
committerAndreas Schwab <schwab@suse.de>2009-09-08 09:47:51 +0000
commitd55e4d419ef8c48853aec7fb8fdf51df6caa0d1f (patch)
tree9b84e4e7d7fd52721ea98cac9ca787f02ac8aeb4
parentee084738a6f38157c3680d1a187f4033ff3541f4 (diff)
downloadgdb-d55e4d419ef8c48853aec7fb8fdf51df6caa0d1f.tar.gz
* z8kgen.c (struct op): Replace unused flavor with id.
(opt): Remove extra xorb entry. (func): Use id field as fallback. (sub): Return new string, caller changed. (internal): Allocate end marker. Assign unique id before sorting. (gas): Likewise. Fix loop end condition. * z8k-opc.h: Regenerate.
-rw-r--r--opcodes/ChangeLog10
-rw-r--r--opcodes/z8k-opc.h8
-rw-r--r--opcodes/z8kgen.c40
3 files changed, 37 insertions, 21 deletions
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index 3b7b4059e58..df6de20dfd7 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,13 @@
+2009-09-08 Andreas Schwab <schwab@linux-m68k.org>
+
+ * z8kgen.c (struct op): Replace unused flavor with id.
+ (opt): Remove extra xorb entry.
+ (func): Use id field as fallback.
+ (sub): Return new string, caller changed.
+ (internal): Allocate end marker. Assign unique id before sorting.
+ (gas): Likewise. Fix loop end condition.
+ * z8k-opc.h: Regenerate.
+
2009-09-08 Alan Modra <amodra@bigpond.net.au>
* ppc-opc.c (powerpc_macros <extrdi>): Allow n+b of 64.
diff --git a/opcodes/z8k-opc.h b/opcodes/z8k-opc.h
index 837dd39c130..acc199cacdf 100644
--- a/opcodes/z8k-opc.h
+++ b/opcodes/z8k-opc.h
@@ -3796,14 +3796,6 @@ const opcode_entry_type z8k_table[] = {
"xorb",OPC_xorb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_REG_BYTE+(ARG_RS),},
{CLASS_BIT+8,CLASS_BIT+8,CLASS_REG+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,203},
-/* 1000 1000 ssss dddd *** xorb rbd,rbs */
-{
-#ifdef NICENAMES
-"xorb rbd,rbs",8,4,0x01,
-#endif
-"xorb",OPC_xorb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_REG_BYTE+(ARG_RS),},
- {CLASS_BIT+8,CLASS_BIT+8,CLASS_REG+(ARG_RS),CLASS_REG+(ARG_RD),0,0,0,0,0,},2,2,203},
-
/* end marker */
{
#ifdef NICENAMES
diff --git a/opcodes/z8kgen.c b/opcodes/z8kgen.c
index 8d418f7be3f..ecb56b7eea4 100644
--- a/opcodes/z8kgen.c
+++ b/opcodes/z8kgen.c
@@ -17,7 +17,7 @@
Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA. */
-/* This program generates z8k-opc.h. Compile with -fwritable-strings. */
+/* This program generates z8k-opc.h. */
#include <stdio.h>
#include "sysdep.h"
@@ -32,7 +32,8 @@ struct op
char type;
char *bits;
char *name;
- char *flavor;
+ /* Unique number for stable sorting. */
+ int id;
};
#define iswhite(x) ((x) == ' ' || (x) == '\t')
@@ -547,7 +548,6 @@ static struct op opt[] =
{"------", 7, 32, "1000 1100 dddd 0001", "ldctlb rbd,ctrl", 0},
{"CZSVDH", 7, 32, "1000 1100 ssss 1001", "ldctlb ctrl,rbs", 0},
- {"*", 4, 8, "1000 1000 ssss dddd", "xorb rbd,rbs", 0},
{"*", 0, 0, 0, 0, 0}
};
@@ -574,7 +574,7 @@ func (const void *p1, const void *p2)
int ret = strcmp (a->name, b->name);
if (ret != 0)
return ret;
- return p1 > p2 ? 1 : -1;
+ return a->id > b->id ? 1 : -1;
}
@@ -826,9 +826,12 @@ chewname (char **name)
return nargs;
}
-static void
+static char *
sub (char *x, char c)
{
+ /* Create copy. */
+ char *ret = xstrdup (x);
+ x = ret;
while (*x)
{
if (x[0] == c && x[1] == c &&
@@ -839,6 +842,7 @@ sub (char *x, char c)
}
x++;
}
+ return ret;
}
@@ -909,9 +913,14 @@ static void
internal (void)
{
int c = count ();
- struct op *new_op = xmalloc (sizeof (struct op) * c);
+ int id;
+ struct op *new_op = xmalloc (sizeof (struct op) * (c + 1));
struct op *p = opt;
- memcpy (new_op, p, c * sizeof (struct op));
+ memcpy (new_op, p, (c + 1) * sizeof (struct op));
+
+ /* Assign unique id. */
+ for (id = 0; id < c; id++)
+ new_op[id].id = id;
/* Sort all names in table alphabetically. */
qsort (new_op, c, sizeof (struct op), func);
@@ -937,15 +946,15 @@ internal (void)
/* Skip the r and sub the string. */
s++;
c = s[1];
- sub (p->bits, c);
+ p->bits = sub (p->bits, c);
}
if (s[0] == '(' && s[3] == ')')
{
- sub (p->bits, s[2]);
+ p->bits = sub (p->bits, s[2]);
}
if (s[0] == '(')
{
- sub (p->bits, s[-1]);
+ p->bits = sub (p->bits, s[-1]);
}
s++;
@@ -962,12 +971,17 @@ static void
gas (void)
{
int c = count ();
+ int id;
struct op *p = opt;
int idx = -1;
char *oldname = "";
- struct op *new_op = xmalloc (sizeof (struct op) * c);
+ struct op *new_op = xmalloc (sizeof (struct op) * (c + 1));
+
+ memcpy (new_op, p, (c + 1) * sizeof (struct op));
- memcpy (new_op, p, c * sizeof (struct op));
+ /* Assign unique id. */
+ for (id = 0; id < c; id++)
+ new_op[id].id = id;
/* Sort all names in table alphabetically. */
qsort (new_op, c, sizeof (struct op), func);
@@ -1284,7 +1298,7 @@ gas (void)
printf ("#ifdef DEFINE_TABLE\n");
printf ("const opcode_entry_type z8k_table[] = {\n");
- while (new_op->flags && new_op->flags[0])
+ while (new_op->flags && new_op->flags[0] != '*')
{
int nargs;
int length;