} \
} 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)
{
typedef struct xtensa_isa_opaque { int unused; } *xtensa_isa;
-/* Opcodes, formats, regfiles, states, sysregs, ctypes, and protos are
+/* Most of the Xtensa ISA entities (e.g., opcodes, regfiles, etc.) are
represented here using sequential integers beginning with 0. The
specific values are only fixed for a particular instantiation of an
xtensa_isa structure, so these values should only be used
extern char *
xtensa_isa_error_msg (xtensa_isa isa);
+
\f
/* Instruction buffers. */
xtensa_insnbuf_from_chars (xtensa_isa isa, xtensa_insnbuf insn,
const unsigned char *cp, int num_chars);
+
\f
/* ISA information. */
extern int
xtensa_isa_num_funcUnits (xtensa_isa isa);
+
\f
/* Instruction formats. */
xtensa_format_set_slot (xtensa_isa isa, xtensa_format fmt, int slot,
xtensa_insnbuf insn, const xtensa_insnbuf slotbuf);
+
\f
/* Opcode information. */
extern int
xtensa_opcode_num_operands (xtensa_isa isa, xtensa_opcode opc);
-
extern int
xtensa_opcode_num_stateOperands (xtensa_isa isa, xtensa_opcode opc);
extern xtensa_funcUnit_use *
xtensa_opcode_funcUnit_use (xtensa_isa isa, xtensa_opcode opc, int u);
+
\f
/* Operand information. */
xtensa_operand_undo_reloc (xtensa_isa isa, xtensa_opcode opc, int opnd,
uint32 *valp, uint32 pc);
+
\f
/* State Operands. */
extern char
xtensa_stateOperand_inout (xtensa_isa isa, xtensa_opcode opc, int stOp);
+
\f
/* Interface Operands. */
xtensa_interfaceOperand_interface (xtensa_isa isa, xtensa_opcode opc,
int ifOp);
+
\f
/* Register Files. */
extern int
xtensa_regfile_num_entries (xtensa_isa isa, xtensa_regfile rf);
+
\f
/* Processor States. */
extern int
xtensa_state_is_exported (xtensa_isa isa, xtensa_state st);
+
\f
/* Sysregs ("special registers" and "user registers"). */
extern int
xtensa_sysreg_is_user (xtensa_isa isa, xtensa_sysreg sysreg);
+
\f
/* Interfaces. */
extern int
xtensa_interface_class_id (xtensa_isa isa, xtensa_interface intf);
+
\f
/* Functional Units. */