From eae14d64d117e16e474dfcf35353c50ce4a22fb5 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Mon, 7 Sep 2009 12:11:20 +0000 Subject: [PATCH] * z8kgen.c (func): Stabilize qsort of identically named entries. * z8k-opc.h: Regenerate. --- opcodes/ChangeLog | 5 +++++ opcodes/z8k-opc.h | 16 ++++++++-------- opcodes/z8kgen.c | 13 +++++++++---- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index 5c1449c062e..188c41fb3fb 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,8 @@ +2009-09-07 Alan Modra + + * z8kgen.c (func): Stabilize qsort of identically named entries. + * z8k-opc.h: Regenerate. + 2009-09-07 Tristan Gingold * po/opcodes.pot: Regenerate. diff --git a/opcodes/z8k-opc.h b/opcodes/z8k-opc.h index 89738cec7ea..837dd39c130 100644 --- a/opcodes/z8k-opc.h +++ b/opcodes/z8k-opc.h @@ -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}, diff --git a/opcodes/z8kgen.c b/opcodes/z8kgen.c index 2012bc44460..cbd316d3d56 100644 --- a/opcodes/z8kgen.c +++ b/opcodes/z8kgen.c @@ -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"); -- 2.30.2