} \
} while (0)
+
\f
/* Instruction buffers. */
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);
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)
{
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)
{
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;
}
return iclass->stateOperands[stOp].inout;
}
+
\f
/* Interface Operands. */
return intisa->regfiles[rf].num_entries;
}
+
\f
/* Processor States. */
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)
{
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)
{
return 0;
}
+
\f
/* Sysregs. */
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)
{
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)
{
return 0;
}
+
\f
/* Interfaces. */
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)
{
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)
{
return intisa->interfaces[intf].class_id;
}
+
\f
/* Functional Units. */
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)
{
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)
{