This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [Patch] opcodes/z8k-opc.h regenerated
On Mon, Sep 07, 2009 at 09:07:43PM +0930, Alan Modra wrote:
> It's qsort instability. These two entries have the same name
>
> {"------", 5, 8, "1100 dddd imm8", "ldb rbd,imm8", 0},
> {"------", 7, 8, "0010 0000 0000 dddd imm8 imm8", "ldb rbd,imm8", 0},
>
> as do these two..
>
> {"-ZSP--", 4, 8, "1000 1000 ssss dddd", "xorb rbd,rbs", 0},
> {"*", 4, 8, "1000 1000 ssss dddd", "xorb rbd,rbs", 0},
>
> I'll commit a patch to fix the instability.
* z8kgen.c (func): Stabilize qsort of identically named entries.
* z8k-opc.h: Regenerate.
Index: opcodes/z8kgen.c
===================================================================
RCS file: /cvs/src/src/opcodes/z8kgen.c,v
retrieving revision 1.16
diff -u -p -r1.16 z8kgen.c
--- opcodes/z8kgen.c 29 Aug 2009 22:11:02 -0000 1.16
+++ opcodes/z8kgen.c 7 Sep 2009 11:50:11 -0000
@@ -567,9 +567,14 @@ count (void)
}
static int
-func (struct op *a, struct op *b)
+func (const void *p1, const void *p2)
{
- return strcmp ((a)->name, (b)->name);
+ const struct op *a = p1;
+ const struct op *b = p2;
+ int ret = strcmp (a->name, b->name);
+ if (ret != 0)
+ return ret;
+ return p1 > p2;
}
@@ -909,7 +914,7 @@ internal (void)
memcpy (new_op, p, c * sizeof (struct op));
/* Sort all names in table alphabetically. */
- qsort (new_op, c, sizeof (struct op), (int (*)(const void *, const void *))func);
+ qsort (new_op, c, sizeof (struct op), func);
p = new_op;
while (p->flags && p->flags[0] != '*')
@@ -965,7 +970,7 @@ gas (void)
memcpy (new_op, p, c * sizeof (struct op));
/* Sort all names in table alphabetically. */
- qsort (new_op, c, sizeof (struct op), (int (*)(const void *, const void *)) func);
+ qsort (new_op, c, sizeof (struct op), func);
printf ("/* DO NOT EDIT! -*- buffer-read-only: t -*-\n");
printf (" This file is automatically generated by z8kgen. */\n\n");
Index: opcodes/z8k-opc.h
===================================================================
RCS file: /cvs/src/src/opcodes/z8k-opc.h,v
retrieving revision 1.13
diff -u -p -r1.13 z8k-opc.h
--- opcodes/z8k-opc.h 7 Sep 2009 08:14:09 -0000 1.13
+++ opcodes/z8k-opc.h 7 Sep 2009 11:50:10 -0000
@@ -1820,21 +1820,21 @@ const opcode_entry_type z8k_table[] = {
"ldb",OPC_ldb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_X+(ARG_RS),},
{CLASS_BIT+6,CLASS_BIT+0,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_ADDRESS+(ARG_SRC),0,0,0,0,},2,4,74},
-/* 0010 0000 0000 dddd imm8 imm8 *** ldb rbd,imm8 */
+/* 1100 dddd imm8 *** ldb rbd,imm8 */
{
#ifdef NICENAMES
-"ldb rbd,imm8",8,7,0x00,
+"ldb rbd,imm8",8,5,0x00,
#endif
"ldb",OPC_ldb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM+(ARG_IMM8),},
- {CLASS_BIT+2,CLASS_BIT+0,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM8),CLASS_IMM+(ARG_IMM8),0,0,0,},2,4,74},
+ {CLASS_BIT+0xc,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM8),0,0,0,0,0,0,},2,2,74},
-/* 1100 dddd imm8 *** ldb rbd,imm8 */
+/* 0010 0000 0000 dddd imm8 imm8 *** ldb rbd,imm8 */
{
#ifdef NICENAMES
-"ldb rbd,imm8",8,5,0x00,
+"ldb rbd,imm8",8,7,0x00,
#endif
"ldb",OPC_ldb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM+(ARG_IMM8),},
- {CLASS_BIT+0xc,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM8),0,0,0,0,0,0,},2,2,74},
+ {CLASS_BIT+2,CLASS_BIT+0,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_IMM+(ARG_IMM8),CLASS_IMM+(ARG_IMM8),0,0,0,},2,4,74},
/* 1010 0000 ssss dddd *** ldb rbd,rbs */
{
@@ -3791,7 +3791,7 @@ const opcode_entry_type z8k_table[] = {
/* 1000 1000 ssss dddd *** xorb rbd,rbs */
{
#ifdef NICENAMES
-"xorb rbd,rbs",8,4,0x01,
+"xorb rbd,rbs",8,4,0x1c,
#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},
@@ -3799,7 +3799,7 @@ const opcode_entry_type z8k_table[] = {
/* 1000 1000 ssss dddd *** xorb rbd,rbs */
{
#ifdef NICENAMES
-"xorb rbd,rbs",8,4,0x1c,
+"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},
--
Alan Modra
Australia Development Lab, IBM