aboutsummaryrefslogtreecommitdiff
path: root/bfd/xtensa-isa.c
diff options
context:
space:
mode:
authorBob Wilson <bob.wilson@acm.org>2005-03-22 19:31:28 +0000
committerBob Wilson <bob.wilson@acm.org>2005-03-22 19:31:28 +0000
commit1fbc7e7aeebf0d99018625880a99b9483bcd02bd (patch)
treef6f06709d5fe3ada06ca23a4ac1161e78e95ad55 /bfd/xtensa-isa.c
parentafe94956ca3a1be06386077f1732bf1b5a9d9b7d (diff)
downloadgdb-1fbc7e7aeebf0d99018625880a99b9483bcd02bd.zip
gdb-1fbc7e7aeebf0d99018625880a99b9483bcd02bd.tar.gz
gdb-1fbc7e7aeebf0d99018625880a99b9483bcd02bd.tar.bz2
include ChangeLog
* xtensa-isa.h: Update a comment and whitespace. bfd ChangeLog * xtensa-isa.c (xtensa_opcode_lookup, xtensa_state_lookup, xtensa_sysreg_lookup_name, xtensa_interface_lookup, xtensa_funcUnit_lookup): Skip bsearch call if count is zero. (xtensa_opcode_decode): Rearrange code.
Diffstat (limited to 'bfd/xtensa-isa.c')
-rw-r--r--bfd/xtensa-isa.c81
1 files changed, 52 insertions, 29 deletions
diff --git a/bfd/xtensa-isa.c b/bfd/xtensa-isa.c
index 68d33c6..8fb96be 100644
--- a/bfd/xtensa-isa.c
+++ b/bfd/xtensa-isa.c
@@ -63,6 +63,7 @@ xtensa_isa_error_msg (xtensa_isa isa __attribute__ ((unused)))
} \
} while (0)
+
/* Instruction buffers. */
@@ -406,9 +407,9 @@ xtensa_isa_length_from_chars (xtensa_isa isa, const unsigned char *cp)
int
xtensa_isa_num_pipe_stages (xtensa_isa isa)
{
- int num_opcodes, num_uses;
xtensa_opcode opcode;
xtensa_funcUnit_use *use;
+ int num_opcodes, num_uses;
int i, stage, max_stage = XTENSA_UNDEFINED;
num_opcodes = xtensa_isa_num_opcodes (isa);
@@ -653,7 +654,7 @@ xtensa_opcode
xtensa_opcode_lookup (xtensa_isa isa, const char *opname)
{
xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
- xtensa_lookup_entry entry, *result;
+ xtensa_lookup_entry entry, *result = 0;
if (!opname || !*opname)
{
@@ -662,9 +663,13 @@ xtensa_opcode_lookup (xtensa_isa isa, const char *opname)
return XTENSA_UNDEFINED;
}
- entry.key = opname;
- result = bsearch (&entry, intisa->opname_lookup_table, intisa->num_opcodes,
- sizeof (xtensa_lookup_entry), xtensa_isa_name_compare);
+ if (intisa->num_opcodes != 0)
+ {
+ entry.key = opname;
+ result = bsearch (&entry, intisa->opname_lookup_table,
+ intisa->num_opcodes, sizeof (xtensa_lookup_entry),
+ xtensa_isa_name_compare);
+ }
if (!result)
{
@@ -691,12 +696,12 @@ xtensa_opcode_decode (xtensa_isa isa, xtensa_format fmt, int slot,
slot_id = intisa->formats[fmt].slot_id[slot];
opc = (intisa->slots[slot_id].opcode_decode_fn) (slotbuf);
- if (opc == XTENSA_UNDEFINED)
- {
- xtisa_errno = xtensa_isa_bad_opcode;
- strcpy (xtisa_error_msg, "cannot decode opcode");
- }
- return opc;
+ if (opc != XTENSA_UNDEFINED)
+ return opc;
+
+ xtisa_errno = xtensa_isa_bad_opcode;
+ strcpy (xtisa_error_msg, "cannot decode opcode");
+ return XTENSA_UNDEFINED;
}
@@ -1288,6 +1293,7 @@ xtensa_stateOperand_inout (xtensa_isa isa, xtensa_opcode opc, int stOp)
return iclass->stateOperands[stOp].inout;
}
+
/* Interface Operands. */
@@ -1438,6 +1444,7 @@ xtensa_regfile_num_entries (xtensa_isa isa, xtensa_regfile rf)
return intisa->regfiles[rf].num_entries;
}
+
/* Processor States. */
@@ -1457,7 +1464,7 @@ xtensa_state
xtensa_state_lookup (xtensa_isa isa, const char *name)
{
xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
- xtensa_lookup_entry entry, *result;
+ xtensa_lookup_entry entry, *result = 0;
if (!name || !*name)
{
@@ -1466,9 +1473,12 @@ xtensa_state_lookup (xtensa_isa isa, const char *name)
return XTENSA_UNDEFINED;
}
- entry.key = name;
- result = bsearch (&entry, intisa->state_lookup_table, intisa->num_states,
- sizeof (xtensa_lookup_entry), xtensa_isa_name_compare);
+ if (intisa->num_states != 0)
+ {
+ entry.key = name;
+ result = bsearch (&entry, intisa->state_lookup_table, intisa->num_states,
+ sizeof (xtensa_lookup_entry), xtensa_isa_name_compare);
+ }
if (!result)
{
@@ -1509,6 +1519,7 @@ xtensa_state_is_exported (xtensa_isa isa, xtensa_state st)
return 0;
}
+
/* Sysregs. */
@@ -1548,7 +1559,7 @@ xtensa_sysreg
xtensa_sysreg_lookup_name (xtensa_isa isa, const char *name)
{
xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
- xtensa_lookup_entry entry, *result;
+ xtensa_lookup_entry entry, *result = 0;
if (!name || !*name)
{
@@ -1557,9 +1568,13 @@ xtensa_sysreg_lookup_name (xtensa_isa isa, const char *name)
return XTENSA_UNDEFINED;
}
- entry.key = name;
- result = bsearch (&entry, intisa->sysreg_lookup_table, intisa->num_sysregs,
- sizeof (xtensa_lookup_entry), xtensa_isa_name_compare);
+ if (intisa->num_sysregs != 0)
+ {
+ entry.key = name;
+ result = bsearch (&entry, intisa->sysreg_lookup_table,
+ intisa->num_sysregs, sizeof (xtensa_lookup_entry),
+ xtensa_isa_name_compare);
+ }
if (!result)
{
@@ -1600,6 +1615,7 @@ xtensa_sysreg_is_user (xtensa_isa isa, xtensa_sysreg sysreg)
return 0;
}
+
/* Interfaces. */
@@ -1619,7 +1635,7 @@ xtensa_interface
xtensa_interface_lookup (xtensa_isa isa, const char *ifname)
{
xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
- xtensa_lookup_entry entry, *result;
+ xtensa_lookup_entry entry, *result = 0;
if (!ifname || !*ifname)
{
@@ -1628,10 +1644,13 @@ xtensa_interface_lookup (xtensa_isa isa, const char *ifname)
return XTENSA_UNDEFINED;
}
- entry.key = ifname;
- result = bsearch (&entry, intisa->interface_lookup_table,
- intisa->num_interfaces,
- sizeof (xtensa_lookup_entry), xtensa_isa_name_compare);
+ if (intisa->num_interfaces != 0)
+ {
+ entry.key = ifname;
+ result = bsearch (&entry, intisa->interface_lookup_table,
+ intisa->num_interfaces, sizeof (xtensa_lookup_entry),
+ xtensa_isa_name_compare);
+ }
if (!result)
{
@@ -1690,6 +1709,7 @@ xtensa_interface_class_id (xtensa_isa isa, xtensa_interface intf)
return intisa->interfaces[intf].class_id;
}
+
/* Functional Units. */
@@ -1709,7 +1729,7 @@ xtensa_funcUnit
xtensa_funcUnit_lookup (xtensa_isa isa, const char *fname)
{
xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
- xtensa_lookup_entry entry, *result;
+ xtensa_lookup_entry entry, *result = 0;
if (!fname || !*fname)
{
@@ -1718,10 +1738,13 @@ xtensa_funcUnit_lookup (xtensa_isa isa, const char *fname)
return XTENSA_UNDEFINED;
}
- entry.key = fname;
- result = bsearch (&entry, intisa->funcUnit_lookup_table,
- intisa->num_funcUnits,
- sizeof (xtensa_lookup_entry), xtensa_isa_name_compare);
+ if (intisa->num_funcUnits != 0)
+ {
+ entry.key = fname;
+ result = bsearch (&entry, intisa->funcUnit_lookup_table,
+ intisa->num_funcUnits, sizeof (xtensa_lookup_entry),
+ xtensa_isa_name_compare);
+ }
if (!result)
{