27 #include "../../include/disas-asm.h"
28 #include "../../include/sysdep.h"
31 #include "../../include/xtensa-isa.h"
32 #include "../../include/xtensa-isa-internal.h"
53 #define CHECK_ALLOC(MEM,ERRVAL) \
57 xtisa_errno = xtensa_isa_out_of_memory; \
58 strcpy (xtisa_error_msg, "out of memory"); \
63 #define CHECK_ALLOC_FOR_INIT(MEM,ERRVAL,ERRNO_P,ERROR_MSG_P) \
67 xtisa_errno = xtensa_isa_out_of_memory; \
68 strcpy (xtisa_error_msg, "out of memory"); \
69 if (ERRNO_P) *(ERRNO_P) = xtisa_errno; \
70 if (ERROR_MSG_P) *(ERROR_MSG_P) = xtisa_error_msg; \
119 return (byte_index & 0x3) * 8;
140 int fence_post,
start, increment,
i, byte_count;
143 if (num_chars == 0) {
144 num_chars = insn_size;
149 start = insn_size - 1;
170 if (byte_count > num_chars)
177 fence_post =
start + (byte_count * increment);
179 for (
i =
start;
i != fence_post;
i += increment, ++cp)
184 *cp = (insn[word_inx] >> bit_inx) & 0xff;
198 const unsigned char *cp,
202 int max_size, insn_size, fence_post,
start, increment,
i;
212 insn_size = max_size;
215 if (num_chars == 0 || num_chars > insn_size) {
216 num_chars = insn_size;
220 start = max_size - 1;
229 fence_post =
start + (num_chars * increment);
232 for (
i =
start;
i != fence_post;
i += increment, ++cp)
237 insn[word_inx] |= (*cp & 0xff) << bit_inx;
290 for (is_user = 0; is_user < 2; is_user++)
296 errno_p, error_msg_p);
371 for (
n = 0;
n < 2;
n++)
425 int num_opcodes, num_uses;
431 return max_stage + 1;
435 for (opcode = 0; opcode < num_opcodes; opcode++)
438 for (
i = 0;
i < num_uses;
i++)
442 if (stage > max_stage) {
448 return max_stage + 1;
512 #define CHECK_FORMAT(INTISA,FMT,ERRVAL) \
514 if ((FMT) < 0 || (FMT) >= (INTISA)->num_formats) \
516 xtisa_errno = xtensa_isa_bad_format; \
517 strcpy (xtisa_error_msg, "invalid format specifier"); \
523 #define CHECK_SLOT(INTISA,FMT,SLOT,ERRVAL) \
525 if ((SLOT) < 0 || (SLOT) >= (INTISA)->formats[FMT].num_slots) \
527 xtisa_errno = xtensa_isa_bad_slot; \
528 strcpy (xtisa_error_msg, "invalid slot specifier"); \
549 if (!fmtname || !*fmtname)
664 #define CHECK_OPCODE(INTISA,OPC,ERRVAL) \
666 if ((OPC) < 0 || (OPC) >= (INTISA)->num_opcodes) \
668 xtisa_errno = xtensa_isa_bad_opcode; \
669 strcpy (xtisa_error_msg, "invalid opcode specifier"); \
681 if (!opname || !*opname)
749 "opcode \"%s\" is not allowed in slot %d of format \"%s\"",
753 (*encode_fn) (slotbuf);
881 #define CHECK_OPERAND(INTISA,OPC,ICLASS,OPND,ERRVAL) \
883 if ((OPND) < 0 || (OPND) >= (ICLASS)->num_operands) \
885 xtisa_errno = xtensa_isa_bad_operand; \
886 sprintf (xtisa_error_msg, "invalid operand number (%d); " \
887 "opcode \"%s\" has %d operands", (OPND), \
888 (INTISA)->opcodes[(OPC)].name, (ICLASS)->num_operands); \
898 int iclass_id, operand_id;
902 iclass = &intisa->
iclasses[iclass_id];
905 return &intisa->
operands[operand_id];
928 int iclass_id, operand_id;
933 iclass = &intisa->
iclasses[iclass_id];
942 intop = &intisa->
operands[operand_id];
961 iclass = &intisa->
iclasses[iclass_id];
1004 "operand \"%s\" does not exist in slot %d of format \"%s\"",
1008 *valp = (*get_fn) (slotbuf);
1043 "operand \"%s\" does not exist in slot %d of format \"%s\"",
1047 (*set_fn) (slotbuf,
val);
1058 uint32 test_val, orig_val;
1089 for (slot_id = 0; slot_id < intisa->
num_slots; slot_id++)
1096 if (get_fn && set_fn)
1098 (*set_fn) (tmpbuf, *valp);
1099 return ((*get_fn) (tmpbuf) != *valp);
1114 if ((*intop->
encode) (valp)
1115 || (test_val = *valp, (*intop->
decode) (&test_val))
1116 || test_val != orig_val)
1144 if ((*intop->
decode) (valp))
1265 "do_reloc failed for value 0x%08x at PC 0x%08x", *valp,
pc);
1300 "undo_reloc failed for value 0x%08x at PC 0x%08x", *valp,
pc);
1312 #define CHECK_STATE_OPERAND(INTISA,OPC,ICLASS,STOP,ERRVAL) \
1314 if ((STOP) < 0 || (STOP) >= (ICLASS)->num_stateOperands) \
1316 xtisa_errno = xtensa_isa_bad_operand; \
1317 sprintf (xtisa_error_msg, "invalid state operand number (%d); " \
1318 "opcode \"%s\" has %d state operands", (STOP), \
1319 (INTISA)->opcodes[(OPC)].name, (ICLASS)->num_stateOperands); \
1334 iclass = &intisa->
iclasses[iclass_id];
1349 iclass = &intisa->
iclasses[iclass_id];
1359 #define CHECK_INTERFACE_OPERAND(INTISA,OPC,ICLASS,IFOP,ERRVAL) \
1361 if ((IFOP) < 0 || (IFOP) >= (ICLASS)->num_interfaceOperands) \
1363 xtisa_errno = xtensa_isa_bad_operand; \
1364 sprintf (xtisa_error_msg, "invalid interface operand number (%d); " \
1365 "opcode \"%s\" has %d interface operands", (IFOP), \
1366 (INTISA)->opcodes[(OPC)].name, \
1367 (ICLASS)->num_interfaceOperands); \
1383 iclass = &intisa->
iclasses[iclass_id];
1393 #define CHECK_REGFILE(INTISA,RF,ERRVAL) \
1395 if ((RF) < 0 || (RF) >= (INTISA)->num_regfiles) \
1397 xtisa_errno = xtensa_isa_bad_regfile; \
1398 strcpy (xtisa_error_msg, "invalid regfile specifier"); \
1437 if (!shortname || !*shortname)
1513 #define CHECK_STATE(INTISA,ST,ERRVAL) \
1515 if ((ST) < 0 || (ST) >= (INTISA)->num_states) \
1517 xtisa_errno = xtensa_isa_bad_state; \
1518 strcpy (xtisa_error_msg, "invalid state specifier"); \
1601 #define CHECK_SYSREG(INTISA,SYSREG,ERRVAL) \
1603 if ((SYSREG) < 0 || (SYSREG) >= (INTISA)->num_sysregs) \
1605 xtisa_errno = xtensa_isa_bad_sysreg; \
1606 strcpy (xtisa_error_msg, "invalid sysreg specifier"); \
1699 #define CHECK_INTERFACE(INTISA,INTF,ERRVAL) \
1701 if ((INTF) < 0 || (INTF) >= (INTISA)->num_interfaces) \
1703 xtisa_errno = xtensa_isa_bad_interface; \
1704 strcpy (xtisa_error_msg, "invalid interface specifier"); \
1716 if (!ifname || !*ifname)
1738 return result->
u.
intf;
1794 #define CHECK_FUNCUNIT(INTISA,FUN,ERRVAL) \
1796 if ((FUN) < 0 || (FUN) >= (INTISA)->num_funcUnits) \
1798 xtisa_errno = xtensa_isa_bad_funcUnit; \
1799 strcpy (xtisa_error_msg, "invalid functional unit specifier"); \
1830 "functional unit \"%s\" not recognized",
fname);
1834 return result->
u.
fun;
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void start
RZ_API void Ht_() free(HtName_(Ht) *ht)
return memset(p, 0, total)
void * malloc(size_t size)
void * calloc(size_t number, size_t size)
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc static sig const char static mode static oldfd struct tms static buf static getgid static geteuid const char static filename static arg static mask struct ustat static ubuf static getppid static setsid static egid sigset_t static set struct timeval struct timezone static tz fd_set fd_set fd_set struct timeval static timeout const char char static bufsiz const char static swapflags void static offset const char static length static mode static who const char struct statfs static buf unsigned unsigned num
void qsort(void *a, size_t n, size_t es, int(*cmp)(const void *, const void *))
RZ_API int rz_str_casecmp(const char *dst, const char *orig)
union xtensa_arg_internal_struct::@102 u
xtensa_arg_internal * stateOperands
xtensa_interface * interfaceOperands
xtensa_arg_internal * operands
int num_interfaceOperands
xtensa_format_decode_fn format_decode_fn
xtensa_operand_internal * operands
xtensa_lookup_entry * sysreg_lookup_table
xtensa_state_internal * states
xtensa_lookup_entry * state_lookup_table
xtensa_regfile_internal * regfiles
xtensa_opcode_internal * opcodes
xtensa_iclass_internal * iclasses
xtensa_lookup_entry * funcUnit_lookup_table
xtensa_interface_internal * interfaces
xtensa_funcUnit_internal * funcUnits
xtensa_sysreg * sysreg_table[2]
xtensa_sysreg_internal * sysregs
xtensa_lookup_entry * opname_lookup_table
xtensa_length_decode_fn length_decode_fn
xtensa_format_internal * formats
xtensa_slot_internal * slots
xtensa_lookup_entry * interface_lookup_table
union xtensa_lookup_entry_struct::@103 u
xtensa_opcode_encode_fn * encode_fns
xtensa_funcUnit_use * funcUnit_uses
xtensa_immed_encode_fn encode
xtensa_undo_reloc_fn undo_reloc
xtensa_immed_decode_fn decode
xtensa_do_reloc_fn do_reloc
xtensa_set_field_fn * set_field_fns
xtensa_set_slot_fn set_fn
xtensa_opcode_decode_fn opcode_decode_fn
xtensa_get_slot_fn get_fn
xtensa_get_field_fn * get_field_fns
void(* xtensa_set_field_fn)(xtensa_insnbuf, uint32)
#define XTENSA_STATE_IS_SHARED_OR
#define XTENSA_OPERAND_IS_UNKNOWN
#define XTENSA_INTERFACE_HAS_SIDE_EFFECT
#define XTENSA_OPERAND_IS_INVISIBLE
uint32(* xtensa_get_field_fn)(const xtensa_insnbuf)
#define XTENSA_OPCODE_IS_CALL
#define XTENSA_STATE_IS_EXPORTED
void(* xtensa_opcode_encode_fn)(xtensa_insnbuf)
#define XTENSA_OPCODE_IS_LOOP
#define XTENSA_OPERAND_IS_PCRELATIVE
#define XTENSA_OPCODE_IS_JUMP
#define XTENSA_OPERAND_IS_REGISTER
#define XTENSA_OPCODE_IS_BRANCH
const char * xtensa_regfile_shortname(xtensa_isa isa, xtensa_regfile rf)
int xtensa_opcode_num_funcUnit_uses(xtensa_isa isa, xtensa_opcode opc)
int xtensa_operand_is_PCrelative(xtensa_isa isa, xtensa_opcode opc, int opnd)
static int byte_to_word_index(int byte_index)
int xtensa_isa_num_opcodes(xtensa_isa isa)
int xtensa_isa_name_compare(const void *v1, const void *v2)
void xtensa_isa_free(xtensa_isa isa)
#define CHECK_FORMAT(INTISA, FMT, ERRVAL)
int xtensa_format_get_slot(xtensa_isa isa, xtensa_format fmt, int slot, const xtensa_insnbuf insn, xtensa_insnbuf slotbuf)
int xtensa_opcode_is_loop(xtensa_isa isa, xtensa_opcode opc)
int xtensa_operand_encode(xtensa_isa isa, xtensa_opcode opc, int opnd, uint32 *valp)
#define CHECK_STATE(INTISA, ST, ERRVAL)
const char * xtensa_format_name(xtensa_isa isa, xtensa_format fmt)
int xtensa_operand_do_reloc(xtensa_isa isa, xtensa_opcode opc, int opnd, uint32 *valp, uint32 pc)
int xtensa_format_num_slots(xtensa_isa isa, xtensa_format fmt)
int xtensa_opcode_is_branch(xtensa_isa isa, xtensa_opcode opc)
int xtensa_operand_undo_reloc(xtensa_isa isa, xtensa_opcode opc, int opnd, uint32 *valp, uint32 pc)
int xtensa_opcode_is_jump(xtensa_isa isa, xtensa_opcode opc)
int xtensa_format_set_slot(xtensa_isa isa, xtensa_format fmt, int slot, xtensa_insnbuf insn, const xtensa_insnbuf slotbuf)
#define CHECK_STATE_OPERAND(INTISA, OPC, ICLASS, STOP, ERRVAL)
int xtensa_opcode_is_call(xtensa_isa isa, xtensa_opcode opc)
const char * xtensa_regfile_name(xtensa_isa isa, xtensa_regfile rf)
int xtensa_operand_set_field(xtensa_isa isa, xtensa_opcode opc, int opnd, xtensa_format fmt, int slot, xtensa_insnbuf slotbuf, uint32 val)
xtensa_sysreg xtensa_sysreg_lookup(xtensa_isa isa, int num, int is_user)
char xtensa_operand_inout(xtensa_isa isa, xtensa_opcode opc, int opnd)
int xtensa_operand_num_regs(xtensa_isa isa, xtensa_opcode opc, int opnd)
int xtensa_operand_is_register(xtensa_isa isa, xtensa_opcode opc, int opnd)
xtensa_interface xtensa_interface_lookup(xtensa_isa isa, const char *ifname)
xtensa_regfile xtensa_regfile_view_parent(xtensa_isa isa, xtensa_regfile rf)
void xtensa_insnbuf_free(xtensa_isa isa __attribute__((unused)), xtensa_insnbuf buf)
xtensa_state xtensa_state_lookup(xtensa_isa isa, const char *name)
#define CHECK_SYSREG(INTISA, SYSREG, ERRVAL)
int xtensa_isa_num_funcUnits(xtensa_isa isa)
int xtensa_isa_num_formats(xtensa_isa isa)
int xtensa_interface_class_id(xtensa_isa isa, xtensa_interface intf)
int xtensa_isa_num_sysregs(xtensa_isa isa)
#define CHECK_SLOT(INTISA, FMT, SLOT, ERRVAL)
int xtensa_state_is_shared_or(xtensa_isa isa, xtensa_state st)
int xtensa_isa_num_regfiles(xtensa_isa isa)
xtensa_opcode xtensa_opcode_decode(xtensa_isa isa, xtensa_format fmt, int slot, const xtensa_insnbuf slotbuf)
const char * xtensa_operand_name(xtensa_isa isa, xtensa_opcode opc, int opnd)
#define CHECK_ALLOC_FOR_INIT(MEM, ERRVAL, ERRNO_P, ERROR_MSG_P)
int xtensa_opcode_num_operands(xtensa_isa isa, xtensa_opcode opc)
#define CHECK_INTERFACE(INTISA, INTF, ERRVAL)
int xtensa_insnbuf_size(xtensa_isa isa)
xtensa_regfile xtensa_operand_regfile(xtensa_isa isa, xtensa_opcode opc, int opnd)
xtensa_isa_internal xtensa_modules
int xtensa_format_encode(xtensa_isa isa, xtensa_format fmt, xtensa_insnbuf insn)
#define CHECK_OPERAND(INTISA, OPC, ICLASS, OPND, ERRVAL)
const char * xtensa_funcUnit_name(xtensa_isa isa, xtensa_funcUnit fun)
int xtensa_operand_get_field(xtensa_isa isa, xtensa_opcode opc, int opnd, xtensa_format fmt, int slot, const xtensa_insnbuf slotbuf, uint32 *valp)
int xtensa_sysreg_is_user(xtensa_isa isa, xtensa_sysreg sysreg)
int xtensa_regfile_num_entries(xtensa_isa isa, xtensa_regfile rf)
int xtensa_operand_decode(xtensa_isa isa, xtensa_opcode opc, int opnd, uint32 *valp)
xtensa_state xtensa_stateOperand_state(xtensa_isa isa, xtensa_opcode opc, int stOp)
int xtensa_format_length(xtensa_isa isa, xtensa_format fmt)
const char * xtensa_state_name(xtensa_isa isa, xtensa_state st)
int xtensa_insnbuf_to_chars(xtensa_isa isa, const xtensa_insnbuf insn, unsigned char *cp, int num_chars)
int xtensa_isa_num_states(xtensa_isa isa)
int xtensa_interface_num_bits(xtensa_isa isa, xtensa_interface intf)
int xtensa_interface_has_side_effect(xtensa_isa isa, xtensa_interface intf)
#define CHECK_FUNCUNIT(INTISA, FUN, ERRVAL)
int xtensa_opcode_num_interfaceOperands(xtensa_isa isa, xtensa_opcode opc)
char * xtensa_isa_error_msg(xtensa_isa isa __attribute__((unused)))
xtensa_interface xtensa_interfaceOperand_interface(xtensa_isa isa, xtensa_opcode opc, int ifOp)
int xtensa_sysreg_number(xtensa_isa isa, xtensa_sysreg sysreg)
xtensa_regfile xtensa_regfile_lookup(xtensa_isa isa, const char *name)
int xtensa_state_is_exported(xtensa_isa isa, xtensa_state st)
#define CHECK_OPCODE(INTISA, OPC, ERRVAL)
xtensa_format xtensa_format_decode(xtensa_isa isa, const xtensa_insnbuf insn)
void xtensa_insnbuf_from_chars(xtensa_isa isa, xtensa_insnbuf insn, const unsigned char *cp, int num_chars)
int filename_cmp(const char *s1, const char *s2)
xtensa_isa xtensa_isa_init(xtensa_isa_status *errno_p, char **error_msg_p)
xtensa_funcUnit_use * xtensa_opcode_funcUnit_use(xtensa_isa isa, xtensa_opcode opc, int u)
static xtensa_operand_internal * get_operand(xtensa_isa_internal *intisa, xtensa_opcode opc, int opnd)
const char * xtensa_interface_name(xtensa_isa isa, xtensa_interface intf)
int xtensa_regfile_num_bits(xtensa_isa isa, xtensa_regfile rf)
char xtensa_stateOperand_inout(xtensa_isa isa, xtensa_opcode opc, int stOp)
int xtensa_operand_is_visible(xtensa_isa isa, xtensa_opcode opc, int opnd)
xtensa_opcode xtensa_opcode_lookup(xtensa_isa isa, const char *opname)
char xtisa_error_msg[1024]
#define CHECK_ALLOC(MEM, ERRVAL)
#define CHECK_REGFILE(INTISA, RF, ERRVAL)
xtensa_isa_status xtisa_errno
xtensa_regfile xtensa_regfile_lookup_shortname(xtensa_isa isa, const char *shortname)
char xtensa_interface_inout(xtensa_isa isa, xtensa_interface intf)
xtensa_format xtensa_format_lookup(xtensa_isa isa, const char *fmtname)
int xtensa_opcode_encode(xtensa_isa isa, xtensa_format fmt, int slot, xtensa_insnbuf slotbuf, xtensa_opcode opc)
int xtensa_state_num_bits(xtensa_isa isa, xtensa_state st)
int xtensa_isa_length_from_chars(xtensa_isa isa, const unsigned char *cp)
int xtensa_opcode_num_stateOperands(xtensa_isa isa, xtensa_opcode opc)
int xtensa_operand_is_known_reg(xtensa_isa isa, xtensa_opcode opc, int opnd)
#define CHECK_INTERFACE_OPERAND(INTISA, OPC, ICLASS, IFOP, ERRVAL)
xtensa_isa_status xtensa_isa_errno(xtensa_isa isa __attribute__((unused)))
xtensa_funcUnit xtensa_funcUnit_lookup(xtensa_isa isa, const char *fname)
xtensa_opcode xtensa_format_slot_nop_opcode(xtensa_isa isa, xtensa_format fmt, int slot)
int xtensa_isa_num_pipe_stages(xtensa_isa isa)
int xtensa_isa_num_interfaces(xtensa_isa isa)
const char * xtensa_sysreg_name(xtensa_isa isa, xtensa_sysreg sysreg)
xtensa_sysreg xtensa_sysreg_lookup_name(xtensa_isa isa, const char *name)
int xtensa_isa_maxlength(xtensa_isa isa)
static int byte_to_bit_index(int byte_index)
const char * xtensa_opcode_name(xtensa_isa isa, xtensa_opcode opc)
int xtensa_funcUnit_num_copies(xtensa_isa isa, xtensa_funcUnit fun)
xtensa_insnbuf xtensa_insnbuf_alloc(xtensa_isa isa)
enum xtensa_isa_status_enum xtensa_isa_status
@ xtensa_isa_internal_error
@ xtensa_isa_bad_funcUnit
@ xtensa_isa_bad_interface
@ xtensa_isa_buffer_overflow
uint32 xtensa_insnbuf_word
xtensa_insnbuf_word * xtensa_insnbuf