More changes, mostly cleanups from the last set.

Made some more progress in removing duplicate assembly opcode files.
More improvements to how mipsread and to a lesser extent dbxread work.
See the ChangeLog for details.
This commit is contained in:
Per Bothner
1991-12-27 21:11:37 +00:00
parent f3b7efd5b6
commit aab77d5f23
14 changed files with 103 additions and 172 deletions

View File

@@ -44,7 +44,6 @@ am29k-pinsn.c
am29k-tdep.c
ansidecl.h
arm-convert.s
arm-opcode.h
arm-pinsn.c
arm-tdep.c
arm-xdep.c
@@ -112,7 +111,6 @@ m2-exp.y
m68k-pinsn.c
m68k-stub.c
m68k-tdep.c
m88k-opcode.h
m88k-pinsn.c
m88k-tdep.c
m88k-xdep.c
@@ -131,17 +129,14 @@ munch
news-xdep.c
nindy-share
nindy-tdep.c
np1-opcode.h
ns32k-opcode.h
ns32k-pinsn.c
parse.c
parser-defs.h
partial-stab.h
pn-opcode.h
printcmd.c
procfs.c
putenv.c
pyr-opcode.h
pyr-pinsn.c
pyr-tdep.c
pyr-xdep.c
@@ -179,7 +174,6 @@ symm-xdep.c
symmisc.c
symtab.c
symtab.h
tahoe-opcode.h
tahoe-pinsn.c
target.c
target.h
@@ -235,7 +229,6 @@ valops.c
valprint.c
value.h
values.c
vax-opcode.h
vax-pinsn.c
vx-share
xcoffexec.c

View File

@@ -1,3 +1,44 @@
Fri Dec 27 10:11:33 1991 Per Bothner (bothner at cygnus.com)
* arm-opcode.h, m88k-opcode.h, pn-opcode.h, np1-opcode.h,
pyr-opcode.h, tahoe-opcode, vax-opcode.h: Removed -
these are all essentially the same as the versions
in ../include/opcode. The remaining *-opcode.h here
are not quite so obviously the same, and need study.
* arm-pinsn.c, gould-pinsn.c, m88k-pinsn.c, pyr-pinsn.c,
tahoe-pinsn.c, vax-pinsn.c: Change so these include
opcode/FOO.h (actually ../include/opcode/FOO.h)
instead of the recenntly departed opcode-FOO.h files.
* sparc-pinsn.c: Now that we're using the much tighter
opcode table in ../include/opcode/sparc.h, we shouldn't
need to sort the opcodes before dis-assembly.
* symtab.h, symmisc.c: Make cplus_struct_default be const.
* symtab.h, buildsym.c: Add and use INIT_CPLUS_SPECIFIC macro.
* symmisc.c: Remove unused 'nfields' variable.
* buildsym.h: Add extern decl of unknown_symtype_complaint,
since it used used by partial-stab.h (included two places).
* partial-stab.h: Re-arrange DBXREAD_ONLY #ifdefs so that
we should never hit the default case (until new stab codes
are added). Hence, we can leave the complaint in the
default case in even when DBXREAD_ONLY is off.
* partial_stab.h: Recognize a pair of N_SO stabs (one for the
directory, one for the filename proper) without peeking ahead.
* dbxread.c, mipsread.c: Because of previous change, don't need
ugly CHECK_SECOND_N_SO macro.
* buildsym.h, dbxread.c, mipsread.c: Make next_symbol_text a
macro that invokes a function pointer in next_symbol_text_func.
* mipsread.c: Added comments various places to
explain what is going on.
* mipsread.c (parse_symbol): Support the new (SGI-specific?)
symbol types stStruct, stUnion, and stEnum.
Also, some fixes in the code for dealing with tags.
* mipsread.c: Change handling of startup_file_start and _end
- now just use the textlow and texhigh of a psymtab
to check if we've found the startup-file.
* mipsread.c: Replace s_idx by global cur_sdx in many places.
This is so mips_next_symbol_text can get at it.
Thu Dec 26 19:52:01 1991 Fred Fish (fnf at cygnus.com)
* dbxread.c, symmisc.c: Move add_psymbol_to_plist() from

View File

@@ -23,7 +23,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "defs.h"
#include "symtab.h"
#include "arm-opcode.h"
#include "opcode/arm.h"
extern char *reg_names[];

View File

@@ -1704,7 +1704,7 @@ read_type (pp)
type = dbx_alloc_type (typenums);
TYPE_CODE (type) = code;
TYPE_NAME (type) = type_name;
TYPE_CPLUS_SPECIFIC(type) = &cplus_struct_default;
INIT_CPLUS_SPECIFIC(type);
TYPE_FLAGS (type) |= TYPE_FLAG_STUB;
add_undefined_type (type);
@@ -1921,7 +1921,7 @@ read_struct_type (pp, type)
int nfn_fields = 0;
TYPE_CODE (type) = TYPE_CODE_STRUCT;
TYPE_CPLUS_SPECIFIC(type) = &cplus_struct_default;
INIT_CPLUS_SPECIFIC(type);
/* First comes the total size in bytes. */

View File

@@ -302,3 +302,11 @@ struct subfile_stack
};
EXTERN struct subfile_stack *subfile_stack;
extern struct complaint unknown_symtype_complaint;
#define next_symbol_text() (*next_symbol_text_func)()
/* Function to invoke get the next symbol. Return the symbol name. */
EXTERN char * (*next_symbol_text_func)();

View File

@@ -560,11 +560,8 @@ fill_symbuf (sym_bfd)
(a \ at the end of the text of a name)
call this function to get the continuation. */
#ifdef READ_MIPS_FORMAT
extern char *next_symbol_text ();
#else
char *
next_symbol_text ()
dbx_next_symbol_text ()
{
if (symbuf_idx == symbuf_end)
fill_symbuf (symfile_bfd);
@@ -572,7 +569,6 @@ next_symbol_text ()
SWAP_SYMBOL(&symbuf[symbuf_idx], symfile_bfd);
return symbuf[symbuf_idx++].n_strx + stringtab_global;
}
#endif
/* Initializes storage for all of the partial symbols that will be
created by read_dbx_symtab and subsidiaries. */
@@ -734,6 +730,7 @@ read_dbx_symtab (addr, objfile, stringtab, stringtab_size, nlistlen,
symfile_bfd = objfile->obfd; /* For next_text_symbol */
abfd = objfile->obfd;
symbuf_end = symbuf_idx = 0;
next_symbol_text_func = dbx_next_symbol_text;
for (symnum = 0; symnum < nlistlen; symnum++)
{
@@ -775,23 +772,11 @@ read_dbx_symtab (addr, objfile, stringtab, stringtab_size, nlistlen,
#define CUR_SYMBOL_TYPE bufp->n_type
#define CUR_SYMBOL_VALUE bufp->n_value
#define DBXREAD_ONLY
#define CHECK_SECOND_N_SO() \
if (symbuf_idx == symbuf_end) \
fill_symbuf (abfd);\
bufp = &symbuf[symbuf_idx];\
/* n_type is only a char, so swapping swapping is irrelevant. */\
if (CUR_SYMBOL_TYPE == (unsigned char)N_SO)\
{\
SWAP_SYMBOL (bufp, abfd);\
SET_NAMESTRING ();\
valu = CUR_SYMBOL_VALUE;\
symbuf_idx++;\
symnum++;\
}
#define START_PSYMTAB(ofile,addr,fname,low,symoff,global_syms,static_syms)\
start_psymtab(ofile, addr, fname, low, symoff, global_syms, static_syms)
#define END_PSYMTAB(pst,ilist,ninc,c_off,c_text,dep_list,n_deps)\
end_psymtab(pst,ilist,ninc,c_off,c_text,dep_list,n_deps)
#include "partial-stab.h"
}
@@ -1149,6 +1134,8 @@ dbx_psymtab_to_symtab (pst)
/* FIXME POKING INSIDE BFD DATA STRUCTURES */
symbol_size = obj_symbol_entry_size (sym_bfd);
next_symbol_text_func = dbx_next_symbol_text;
/* FIXME, this uses internal BFD variables. See above in
dbx_symbol_file_open where the macro is defined! */
psymtab_to_symtab_1 (pst, stringtab, stsize,

View File

@@ -7,7 +7,7 @@ am29k-tdep.o : am29k-tdep.c defs.h xm.h config.status tm.h config.status gdbcore
${srcdir}/../include/ansidecl.h ${srcdir}/../include/obstack.h frame.h value.h symtab.h \
inferior.h breakpoint.h
arm-pinsn.o : arm-pinsn.c defs.h xm.h config.status tm.h config.status symtab.h ${srcdir}/../include/obstack.h \
arm-opcode.h
${srcdir}/../include/opcode/arm.h
arm-tdep.o : arm-tdep.c defs.h xm.h config.status tm.h config.status frame.h inferior.h breakpoint.h \
value.h symtab.h ${srcdir}/../include/obstack.h arm-opcode.h gdbcore.h \
${srcdir}/../include/bfd.h ${srcdir}/../include/ansidecl.h
@@ -73,7 +73,7 @@ findvar.o : findvar.c defs.h xm.h config.status tm.h config.status symtab.h ${sr
inferior.h breakpoint.h target.h
gould-pinsn.o : gould-pinsn.c defs.h xm.h config.status tm.h config.status symtab.h \
${srcdir}/../include/obstack.h frame.h gdbcore.h ${srcdir}/../include/bfd.h \
${srcdir}/../include/ansidecl.h np1-opcode.h
${srcdir}/../include/ansidecl.h ${srcdir}/../include/opcode/np1.h
gould-xdep.o : gould-xdep.c defs.h xm.h config.status tm.h config.status frame.h inferior.h \
breakpoint.h value.h symtab.h ${srcdir}/../include/obstack.h gdbcore.h \
${srcdir}/../include/bfd.h ${srcdir}/../include/ansidecl.h
@@ -123,8 +123,8 @@ m68k-pinsn.o : m68k-pinsn.c defs.h xm.h config.status tm.h config.status symtab.
${srcdir}/../include/bfd.h ${srcdir}/../include/ansidecl.h
m68k-tdep.o : m68k-tdep.c defs.h xm.h config.status tm.h config.status ieee-float.h frame.h symtab.h \
${srcdir}/../include/obstack.h
m88k-pinsn.o : m88k-pinsn.c m88k-opcode.h defs.h xm.h config.status tm.h config.status symtab.h \
${srcdir}/../include/obstack.h
m88k-pinsn.o : m88k-pinsn.c ${srcdir}/../include/opcode/m88k.h defs.h xm.h config.status tm.h config.status \
symtab.h ${srcdir}/../include/obstack.h
m88k-tdep.o : m88k-tdep.c defs.h xm.h config.status tm.h config.status frame.h inferior.h breakpoint.h \
value.h symtab.h ${srcdir}/../include/obstack.h gdbcore.h ${srcdir}/../include/bfd.h \
${srcdir}/../include/ansidecl.h /usr/include/setjmp.h
@@ -172,7 +172,8 @@ printcmd.o : printcmd.c defs.h xm.h config.status tm.h config.status frame.h sym
${srcdir}/../include/bfd.h ${srcdir}/../include/ansidecl.h gdbcmd.h command.h target.h
procfs.o : procfs.c defs.h xm.h config.status tm.h config.status
pyr-pinsn.o : pyr-pinsn.c defs.h xm.h config.status tm.h config.status symtab.h ${srcdir}/../include/obstack.h \
pyr-opcode.h gdbcore.h ${srcdir}/../include/bfd.h ${srcdir}/../include/ansidecl.h
${srcdir}/../include/opcode/pyr.h gdbcore.h ${srcdir}/../include/bfd.h \
${srcdir}/../include/ansidecl.h
pyr-tdep.o : pyr-tdep.c defs.h xm.h config.status tm.h config.status
pyr-xdep.o : pyr-xdep.c defs.h xm.h config.status tm.h config.status frame.h inferior.h breakpoint.h \
value.h symtab.h ${srcdir}/../include/obstack.h gdbcore.h ${srcdir}/../include/bfd.h \
@@ -245,7 +246,7 @@ symtab.o : symtab.c defs.h xm.h config.status tm.h config.status symtab.h ${srcd
gdbcore.h ${srcdir}/../include/bfd.h ${srcdir}/../include/ansidecl.h frame.h target.h \
value.h symfile.h gdbcmd.h command.h regex.h language.h
tahoe-pinsn.o : tahoe-pinsn.c defs.h xm.h config.status tm.h config.status symtab.h \
${srcdir}/../include/obstack.h tahoe-opcode.h
${srcdir}/../include/obstack.h ${srcdir}/../include/opcode/tahoe.h
target.o : target.c defs.h xm.h config.status tm.h config.status target.h ${srcdir}/../include/bfd.h \
${srcdir}/../include/ansidecl.h ${srcdir}/../include/obstack.h gdbcmd.h command.h symtab.h \
inferior.h breakpoint.h value.h frame.h symfile.h
@@ -270,7 +271,7 @@ values.o : values.c defs.h xm.h config.status tm.h config.status symtab.h ${srcd
value.h gdbcore.h ${srcdir}/../include/bfd.h ${srcdir}/../include/ansidecl.h frame.h \
command.h gdbcmd.h
vax-pinsn.o : vax-pinsn.c defs.h xm.h config.status tm.h config.status symtab.h ${srcdir}/../include/obstack.h \
vax-opcode.h
${srcdir}/../include/opcode/vax.h
xdr_ld.o : ${srcdir}/vx-share/xdr_ld.c ${srcdir}/vx-share/vxWorks.h ${srcdir}/vx-share/vxTypes.h \
/usr/include/rpc/rpc.h ${srcdir}/vx-share/xdr_ld.h
xdr_ptrace.o : ${srcdir}/vx-share/xdr_ptrace.c

View File

@@ -23,9 +23,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "frame.h"
#include "gdbcore.h"
#if defined GOULD_PN
#include "pn-opcode.h"
#include "opcode/pn.h"
#else
#include "np1-opcode.h"
#include "opcode/np1.h"
#endif
/* GOULD RISC instructions are never longer than this many bytes. */

View File

@@ -20,7 +20,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <stdio.h>
#include "m88k-opcode.h"
#include "opcode/m88k.h"
#include "defs.h"
#include "symtab.h"

View File

@@ -32,7 +32,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
* Standard, external, non-debugger, symbols
*/
#ifdef DBXREAD_ONLY
case N_TEXT | N_EXT:
case N_NBTEXT | N_EXT:
case N_NBDATA | N_EXT:
@@ -41,6 +40,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
case N_ABS | N_EXT:
case N_DATA | N_EXT:
case N_BSS | N_EXT:
#ifdef DBXREAD_ONLY
CUR_SYMBOL_VALUE += addr; /* Relocate */
@@ -49,7 +49,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
bss_ext_symbol:
record_misc_function (namestring, CUR_SYMBOL_VALUE,
CUR_SYMBOL_TYPE); /* Always */
#endif /* DBXREAD_ONLY */
continue;
/* Standard, local, non-debugger, symbols */
@@ -64,6 +64,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
case N_FN:
case N_FN_SEQ:
case N_TEXT:
#ifdef DBXREAD_ONLY
CUR_SYMBOL_VALUE += addr; /* Relocate */
SET_NAMESTRING();
if ((namestring[0] == '-' && namestring[1] == 'l')
@@ -93,9 +94,11 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
past_first_source_file = 1;
last_o_file_start = CUR_SYMBOL_VALUE;
}
#endif /* DBXREAD_ONLY */
continue;
case N_DATA:
#ifdef DBXREAD_ONLY
CUR_SYMBOL_VALUE += addr; /* Relocate */
SET_NAMESTRING ();
/* Check for __DYNAMIC, which is used by Sun shared libraries.
@@ -108,9 +111,11 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
record_misc_function (namestring, CUR_SYMBOL_VALUE,
CUR_SYMBOL_TYPE); /* Always */
}
#endif /* DBXREAD_ONLY */
continue;
case N_UNDF | N_EXT:
#ifdef DBXREAD_ONLY
if (CUR_SYMBOL_VALUE != 0) {
/* This is a "Fortran COMMON" symbol. See if the target
environment knows where it has been relocated to. */
@@ -125,8 +130,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
CUR_SYMBOL_VALUE = reladdr;
goto bss_ext_symbol;
}
#endif /* DBXREAD_ONLY */
continue; /* Just undefined, not COMMON */
#endif
/* Lots of symbol types we can just ignore. */
@@ -169,13 +174,27 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
SET_NAMESTRING();
/* Peek at the next symbol. If it is also an N_SO, the
first one just indicates the directory. */
CHECK_SECOND_N_SO();
valu += addr; /* Relocate */
if (pst && past_first_source_file)
{
/* Some compilers (including gcc) emit a pair of initial N_SOs.
The first one is a directory name; the second the file name.
If pst exists, is empty, and has a filename ending in '/',
we assume the previous N_SO was a directory name. */
if (global_psymbols.next
== (global_psymbols.list + pst->globals_offset)
&& static_psymbols.next
== (static_psymbols.list + pst->statics_offset)
&& pst->filename && pst->filename[0]
&& pst->filename[strlen(pst->filename)-1] == '/') {
/* Just replace the directory name with the real filename. */
pst->filename =
(char *) obstack_alloc (psymbol_obstack,
strlen (namestring) + 1);
strcpy (pst->filename, namestring);
continue;
}
END_PSYMTAB (pst, psymtab_include_list, includes_used,
first_symnum * symbol_size, valu,
dependency_list, dependencies_used);
@@ -193,8 +212,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
continue;
}
#ifdef DBXREAD_ONLY
case N_BINCL:
#ifdef DBXREAD_ONLY
/* Add this bincl to the bincl_list for future EXCLs. No
need to save the string; it'll be around until
read_dbx_symtab function returns */
@@ -217,8 +236,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
includes_used * sizeof (char *));
}
#endif /* DBXREAD_ONLY */
continue;
#endif
case N_SOL:
/* Mark down an include file in the current psymtab */
@@ -261,6 +280,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
includes_used * sizeof (char *));
}
continue;
case N_LSYM: /* Typedef or automatic variable. */
case N_STSYM: /* Data seg var -- static */
case N_LCSYM: /* BSS " */
@@ -294,7 +314,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
VAR_NAMESPACE, LOC_TYPEDEF,
static_psymbols, CUR_SYMBOL_VALUE);
check_enum:
#ifdef DBXREAD_ONLY
/* If this is an enumerated type, we need to
add all the enum constants to the partial symbol
table. This does not cover enums without names, e.g.
@@ -353,7 +372,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
p++;
}
}
#endif
continue;
case 'c':
/* Constant, e.g. from "const" in Pascal. */
@@ -467,8 +485,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
continue;
}
#ifdef DBXREAD_ONLY
case N_EXCL:
#ifdef DBXREAD_ONLY
SET_NAMESTRING();
@@ -519,12 +537,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
error ("Invalid symbol data: \"repeated\" header file not previously seen, at symtab pos %d.",
symnum);
}
#endif /* DBXREAD_ONLY */
continue;
#endif
case N_RBRAC:
#ifdef HANDLE_RBRAC
HANDLE_RBRAC(CUR_SYMBOL_VALUE);
continue;
#endif
case N_EINCL:
case N_DSLINE:
@@ -551,10 +570,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
continue;
default:
#ifdef DBXREAD_ONLY
/* If we haven't found it yet, ignore it. It's probably some
new type we don't know about yet. */
complain (&unknown_symtype_complaint, local_hex_string(CUR_SYMBOL_TYPE));
#endif
continue;
}

View File

@@ -21,7 +21,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "defs.h"
#include "symtab.h"
#include "pyr-opcode.h"
#include "opcode/pyr.h"
#include "gdbcore.h"

View File

@@ -26,9 +26,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "string.h"
#include "target.h"
extern void qsort ();
extern char *reg_names[];
#define freg_names (&reg_names[4 * 8])
@@ -92,8 +89,6 @@ is_delayed_branch (insn)
return 0;
}
static int opcodes_sorted = 0;
/* Print one instruction from MEMADDR on STREAM. */
int
print_insn (memaddr, stream)
@@ -104,14 +99,6 @@ print_insn (memaddr, stream)
register unsigned int i;
if (!opcodes_sorted)
{
static int compare_opcodes ();
qsort ((char *) sparc_opcodes, NUMOPCODES,
sizeof (sparc_opcodes[0]), compare_opcodes);
opcodes_sorted = 1;
}
read_memory (memaddr, &insn, sizeof (insn));
for (i = 0; i < NUMOPCODES; ++i)
@@ -231,6 +218,7 @@ print_insn (memaddr, stream)
/* Check to see whether we have a 1+i, and take
note of that fact.
FIXME: No longer true/relavant ???
Note: because of the way we sort the table,
we will be matching 1+i rather than i+1,
so it is OK to assume that i is after +,
@@ -358,107 +346,3 @@ print_insn (memaddr, stream)
printf_filtered ("%#8x", insn.code);
return sizeof (insn);
}
/* Compare opcodes A and B. */
static int
compare_opcodes (a, b)
char *a, *b;
{
struct sparc_opcode *op0 = (struct sparc_opcode *) a;
struct sparc_opcode *op1 = (struct sparc_opcode *) b;
unsigned long int match0 = op0->match, match1 = op1->match;
unsigned long int lose0 = op0->lose, lose1 = op1->lose;
register unsigned int i;
/* If a bit is set in both match and lose, there is something
wrong with the opcode table. */
if (match0 & lose0)
{
fprintf (stderr, "Internal error: bad sparc-opcode.h: \"%s\", %#.8lx, %#.8lx\n",
op0->name, match0, lose0);
op0->lose &= ~op0->match;
lose0 = op0->lose;
}
if (match1 & lose1)
{
fprintf (stderr, "Internal error: bad sparc-opcode.h: \"%s\", %#.8lx, %#.8lx\n",
op1->name, match1, lose1);
op1->lose &= ~op1->match;
lose1 = op1->lose;
}
/* Because the bits that are variable in one opcode are constant in
another, it is important to order the opcodes in the right order. */
for (i = 0; i < 32; ++i)
{
unsigned long int x = 1 << i;
int x0 = (match0 & x) != 0;
int x1 = (match1 & x) != 0;
if (x0 != x1)
return x1 - x0;
}
for (i = 0; i < 32; ++i)
{
unsigned long int x = 1 << i;
int x0 = (lose0 & x) != 0;
int x1 = (lose1 & x) != 0;
if (x0 != x1)
return x1 - x0;
}
/* They are functionally equal. So as long as the opcode table is
valid, we can put whichever one first we want, on aesthetic grounds. */
/* Our first aesthetic ground is that aliases defer to real insns. */
{
int alias_diff = (op0->flags & F_ALIAS) - (op1->flags & F_ALIAS);
if (alias_diff != 0)
/* Put the one that isn't an alias first. */
return alias_diff;
}
/* Except for the above aliases, two "identical" instructions had
better have the same opcode. This is a sanity check on the table. */
if (0 != strcmp (op0->name, op1->name))
fprintf (stderr, "Internal error: bad sparc-opcode.h: \"%s\" == \"%s\"\n",
op0->name, op1->name);
/* Fewer arguments are preferred. */
{
int length_diff = strlen (op0->args) - strlen (op1->args);
if (length_diff != 0)
/* Put the one with fewer arguments first. */
return length_diff;
}
/* Put 1+i before i+1. */
{
char *p0 = (char *) strchr(op0->args, '+');
char *p1 = (char *) strchr(op1->args, '+');
if (p0 && p1)
{
/* There is a plus in both operands. Note that a plus
sign cannot be the first character in args,
so the following [-1]'s are valid. */
if (p0[-1] == 'i' && p1[1] == 'i')
/* op0 is i+1 and op1 is 1+i, so op1 goes first. */
return 1;
if (p0[1] == 'i' && p1[-1] == 'i')
/* op0 is 1+i and op1 is i+1, so op0 goes first. */
return -1;
}
}
/* They are, as far as we can tell, identical.
Since qsort may have rearranged the table partially, there is
no way to tell which one was first in the opcode table as
written, so just say there are equal. */
return 0;
}

View File

@@ -22,7 +22,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <stdio.h>
#include "defs.h"
#include "symtab.h"
#include "tahoe-opcode.h"
#include "opcode/tahoe.h"
/* Tahoe instructions are never longer than this. */
#define MAXLEN 62

View File

@@ -21,7 +21,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "defs.h"
#include "symtab.h"
#include "vax-opcode.h"
#include "opcode/vax.h"
/* Vax instructions are never longer than this. */
#define MAXLEN 62