Rizin
unix-like reverse engineering framework and cli tools
xtensa-isa.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <rz_util.h>
#include "../../include/disas-asm.h"
#include "../../include/sysdep.h"
#include "../../include/xtensa-isa.h"
#include "../../include/xtensa-isa-internal.h"

Go to the source code of this file.

Macros

#define CHECK_ALLOC(MEM, ERRVAL)
 
#define CHECK_ALLOC_FOR_INIT(MEM, ERRVAL, ERRNO_P, ERROR_MSG_P)
 
#define CHECK_FORMAT(INTISA, FMT, ERRVAL)
 
#define CHECK_SLOT(INTISA, FMT, SLOT, ERRVAL)
 
#define CHECK_OPCODE(INTISA, OPC, ERRVAL)
 
#define CHECK_OPERAND(INTISA, OPC, ICLASS, OPND, ERRVAL)
 
#define CHECK_STATE_OPERAND(INTISA, OPC, ICLASS, STOP, ERRVAL)
 
#define CHECK_INTERFACE_OPERAND(INTISA, OPC, ICLASS, IFOP, ERRVAL)
 
#define CHECK_REGFILE(INTISA, RF, ERRVAL)
 
#define CHECK_STATE(INTISA, ST, ERRVAL)
 
#define CHECK_SYSREG(INTISA, SYSREG, ERRVAL)
 
#define CHECK_INTERFACE(INTISA, INTF, ERRVAL)
 
#define CHECK_FUNCUNIT(INTISA, FUN, ERRVAL)
 

Functions

int filename_cmp (const char *s1, const char *s2)
 
xtensa_isa_status xtensa_isa_errno (xtensa_isa isa __attribute__((unused)))
 
char * xtensa_isa_error_msg (xtensa_isa isa __attribute__((unused)))
 
int xtensa_insnbuf_size (xtensa_isa isa)
 
xtensa_insnbuf xtensa_insnbuf_alloc (xtensa_isa isa)
 
void xtensa_insnbuf_free (xtensa_isa isa __attribute__((unused)), xtensa_insnbuf buf)
 
static int byte_to_word_index (int byte_index)
 
static int byte_to_bit_index (int byte_index)
 
int xtensa_insnbuf_to_chars (xtensa_isa isa, const xtensa_insnbuf insn, unsigned char *cp, int num_chars)
 
void xtensa_insnbuf_from_chars (xtensa_isa isa, xtensa_insnbuf insn, const unsigned char *cp, int num_chars)
 
xtensa_isa xtensa_isa_init (xtensa_isa_status *errno_p, char **error_msg_p)
 
void xtensa_isa_free (xtensa_isa isa)
 
int xtensa_isa_name_compare (const void *v1, const void *v2)
 
int xtensa_isa_maxlength (xtensa_isa isa)
 
int xtensa_isa_length_from_chars (xtensa_isa isa, const unsigned char *cp)
 
int xtensa_isa_num_pipe_stages (xtensa_isa isa)
 
int xtensa_isa_num_formats (xtensa_isa isa)
 
int xtensa_isa_num_opcodes (xtensa_isa isa)
 
int xtensa_isa_num_regfiles (xtensa_isa isa)
 
int xtensa_isa_num_states (xtensa_isa isa)
 
int xtensa_isa_num_sysregs (xtensa_isa isa)
 
int xtensa_isa_num_interfaces (xtensa_isa isa)
 
int xtensa_isa_num_funcUnits (xtensa_isa isa)
 
const char * xtensa_format_name (xtensa_isa isa, xtensa_format fmt)
 
xtensa_format xtensa_format_lookup (xtensa_isa isa, const char *fmtname)
 
xtensa_format xtensa_format_decode (xtensa_isa isa, const xtensa_insnbuf insn)
 
int xtensa_format_encode (xtensa_isa isa, xtensa_format fmt, xtensa_insnbuf insn)
 
int xtensa_format_length (xtensa_isa isa, xtensa_format fmt)
 
int xtensa_format_num_slots (xtensa_isa isa, xtensa_format fmt)
 
xtensa_opcode xtensa_format_slot_nop_opcode (xtensa_isa isa, xtensa_format fmt, int slot)
 
int xtensa_format_get_slot (xtensa_isa isa, xtensa_format fmt, int slot, const xtensa_insnbuf insn, xtensa_insnbuf slotbuf)
 
int xtensa_format_set_slot (xtensa_isa isa, xtensa_format fmt, int slot, xtensa_insnbuf insn, const xtensa_insnbuf slotbuf)
 
xtensa_opcode xtensa_opcode_lookup (xtensa_isa isa, const char *opname)
 
xtensa_opcode xtensa_opcode_decode (xtensa_isa isa, xtensa_format fmt, int slot, const xtensa_insnbuf slotbuf)
 
int xtensa_opcode_encode (xtensa_isa isa, xtensa_format fmt, int slot, xtensa_insnbuf slotbuf, xtensa_opcode opc)
 
const char * xtensa_opcode_name (xtensa_isa isa, xtensa_opcode opc)
 
int xtensa_opcode_is_branch (xtensa_isa isa, xtensa_opcode opc)
 
int xtensa_opcode_is_jump (xtensa_isa isa, xtensa_opcode opc)
 
int xtensa_opcode_is_loop (xtensa_isa isa, xtensa_opcode opc)
 
int xtensa_opcode_is_call (xtensa_isa isa, xtensa_opcode opc)
 
int xtensa_opcode_num_operands (xtensa_isa isa, xtensa_opcode opc)
 
int xtensa_opcode_num_stateOperands (xtensa_isa isa, xtensa_opcode opc)
 
int xtensa_opcode_num_interfaceOperands (xtensa_isa isa, xtensa_opcode opc)
 
int xtensa_opcode_num_funcUnit_uses (xtensa_isa isa, xtensa_opcode opc)
 
xtensa_funcUnit_usextensa_opcode_funcUnit_use (xtensa_isa isa, xtensa_opcode opc, int u)
 
static xtensa_operand_internalget_operand (xtensa_isa_internal *intisa, xtensa_opcode opc, int opnd)
 
const char * xtensa_operand_name (xtensa_isa isa, xtensa_opcode opc, int opnd)
 
int xtensa_operand_is_visible (xtensa_isa isa, xtensa_opcode opc, int opnd)
 
char xtensa_operand_inout (xtensa_isa isa, xtensa_opcode opc, int opnd)
 
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_operand_set_field (xtensa_isa isa, xtensa_opcode opc, int opnd, xtensa_format fmt, int slot, xtensa_insnbuf slotbuf, uint32 val)
 
int xtensa_operand_encode (xtensa_isa isa, xtensa_opcode opc, int opnd, uint32 *valp)
 
int xtensa_operand_decode (xtensa_isa isa, xtensa_opcode opc, int opnd, uint32 *valp)
 
int xtensa_operand_is_register (xtensa_isa isa, xtensa_opcode opc, int opnd)
 
xtensa_regfile xtensa_operand_regfile (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_known_reg (xtensa_isa isa, xtensa_opcode opc, int opnd)
 
int xtensa_operand_is_PCrelative (xtensa_isa isa, xtensa_opcode opc, int opnd)
 
int xtensa_operand_do_reloc (xtensa_isa isa, xtensa_opcode opc, int opnd, uint32 *valp, uint32 pc)
 
int xtensa_operand_undo_reloc (xtensa_isa isa, xtensa_opcode opc, int opnd, uint32 *valp, uint32 pc)
 
xtensa_state xtensa_stateOperand_state (xtensa_isa isa, xtensa_opcode opc, int stOp)
 
char xtensa_stateOperand_inout (xtensa_isa isa, xtensa_opcode opc, int stOp)
 
xtensa_interface xtensa_interfaceOperand_interface (xtensa_isa isa, xtensa_opcode opc, int ifOp)
 
xtensa_regfile xtensa_regfile_lookup (xtensa_isa isa, const char *name)
 
xtensa_regfile xtensa_regfile_lookup_shortname (xtensa_isa isa, const char *shortname)
 
const char * xtensa_regfile_name (xtensa_isa isa, xtensa_regfile rf)
 
const char * xtensa_regfile_shortname (xtensa_isa isa, xtensa_regfile rf)
 
xtensa_regfile xtensa_regfile_view_parent (xtensa_isa isa, xtensa_regfile rf)
 
int xtensa_regfile_num_bits (xtensa_isa isa, xtensa_regfile rf)
 
int xtensa_regfile_num_entries (xtensa_isa isa, xtensa_regfile rf)
 
xtensa_state xtensa_state_lookup (xtensa_isa isa, const char *name)
 
const char * xtensa_state_name (xtensa_isa isa, xtensa_state st)
 
int xtensa_state_num_bits (xtensa_isa isa, xtensa_state st)
 
int xtensa_state_is_exported (xtensa_isa isa, xtensa_state st)
 
int xtensa_state_is_shared_or (xtensa_isa isa, xtensa_state st)
 
xtensa_sysreg xtensa_sysreg_lookup (xtensa_isa isa, int num, int is_user)
 
xtensa_sysreg xtensa_sysreg_lookup_name (xtensa_isa isa, const char *name)
 
const char * xtensa_sysreg_name (xtensa_isa isa, xtensa_sysreg sysreg)
 
int xtensa_sysreg_number (xtensa_isa isa, xtensa_sysreg sysreg)
 
int xtensa_sysreg_is_user (xtensa_isa isa, xtensa_sysreg sysreg)
 
xtensa_interface xtensa_interface_lookup (xtensa_isa isa, const char *ifname)
 
const char * xtensa_interface_name (xtensa_isa isa, xtensa_interface intf)
 
int xtensa_interface_num_bits (xtensa_isa isa, xtensa_interface intf)
 
char xtensa_interface_inout (xtensa_isa isa, xtensa_interface intf)
 
int xtensa_interface_has_side_effect (xtensa_isa isa, xtensa_interface intf)
 
int xtensa_interface_class_id (xtensa_isa isa, xtensa_interface intf)
 
xtensa_funcUnit xtensa_funcUnit_lookup (xtensa_isa isa, const char *fname)
 
const char * xtensa_funcUnit_name (xtensa_isa isa, xtensa_funcUnit fun)
 
int xtensa_funcUnit_num_copies (xtensa_isa isa, xtensa_funcUnit fun)
 

Variables

xtensa_isa_status xtisa_errno
 
char xtisa_error_msg [1024]
 
xtensa_isa_internal xtensa_modules
 

Macro Definition Documentation

◆ CHECK_ALLOC

#define CHECK_ALLOC (   MEM,
  ERRVAL 
)
Value:
do { \
if ((MEM) == 0) \
{ \
xtisa_errno = xtensa_isa_out_of_memory; \
strcpy (xtisa_error_msg, "out of memory"); \
return (ERRVAL); \
} \
} while (0)
@ MEM
Definition: inflate.h:51
char xtisa_error_msg[1024]
Definition: xtensa-isa.c:36
@ xtensa_isa_out_of_memory
Definition: xtensa-isa.h:164

Definition at line 53 of file xtensa-isa.c.

◆ CHECK_ALLOC_FOR_INIT

#define CHECK_ALLOC_FOR_INIT (   MEM,
  ERRVAL,
  ERRNO_P,
  ERROR_MSG_P 
)
Value:
do { \
if ((MEM) == 0) \
{ \
xtisa_errno = xtensa_isa_out_of_memory; \
strcpy (xtisa_error_msg, "out of memory"); \
if (ERRNO_P) *(ERRNO_P) = xtisa_errno; \
if (ERROR_MSG_P) *(ERROR_MSG_P) = xtisa_error_msg; \
return (ERRVAL); \
} \
} while (0)
xtensa_isa_status xtisa_errno
Definition: xtensa-isa.c:35

Definition at line 63 of file xtensa-isa.c.

◆ CHECK_FORMAT

#define CHECK_FORMAT (   INTISA,
  FMT,
  ERRVAL 
)
Value:
do { \
if ((FMT) < 0 || (FMT) >= (INTISA)->num_formats) \
{ \
xtisa_errno = xtensa_isa_bad_format; \
strcpy (xtisa_error_msg, "invalid format specifier"); \
return (ERRVAL); \
} \
} while (0)
@ xtensa_isa_bad_format
Definition: xtensa-isa.h:151

Definition at line 512 of file xtensa-isa.c.

◆ CHECK_FUNCUNIT

#define CHECK_FUNCUNIT (   INTISA,
  FUN,
  ERRVAL 
)
Value:
do { \
if ((FUN) < 0 || (FUN) >= (INTISA)->num_funcUnits) \
{ \
xtisa_errno = xtensa_isa_bad_funcUnit; \
strcpy (xtisa_error_msg, "invalid functional unit specifier"); \
return (ERRVAL); \
} \
} while (0)
@ xtensa_isa_bad_funcUnit
Definition: xtensa-isa.h:161

Definition at line 1794 of file xtensa-isa.c.

◆ CHECK_INTERFACE

#define CHECK_INTERFACE (   INTISA,
  INTF,
  ERRVAL 
)
Value:
do { \
if ((INTF) < 0 || (INTF) >= (INTISA)->num_interfaces) \
{ \
xtisa_errno = xtensa_isa_bad_interface; \
strcpy (xtisa_error_msg, "invalid interface specifier"); \
return (ERRVAL); \
} \
} while (0)
@ xtensa_isa_bad_interface
Definition: xtensa-isa.h:160

Definition at line 1699 of file xtensa-isa.c.

◆ CHECK_INTERFACE_OPERAND

#define CHECK_INTERFACE_OPERAND (   INTISA,
  OPC,
  ICLASS,
  IFOP,
  ERRVAL 
)
Value:
do { \
if ((IFOP) < 0 || (IFOP) >= (ICLASS)->num_interfaceOperands) \
{ \
xtisa_errno = xtensa_isa_bad_operand; \
sprintf (xtisa_error_msg, "invalid interface operand number (%d); " \
"opcode \"%s\" has %d interface operands", (IFOP), \
(INTISA)->opcodes[(OPC)].name, \
(ICLASS)->num_interfaceOperands); \
return (ERRVAL); \
} \
} while (0)
OPCODE_DESC opcodes[]
Definition: avr_esil.c:1270
Definition: z80asm.h:102
@ xtensa_isa_bad_operand
Definition: xtensa-isa.h:154

Definition at line 1359 of file xtensa-isa.c.

◆ CHECK_OPCODE

#define CHECK_OPCODE (   INTISA,
  OPC,
  ERRVAL 
)
Value:
do { \
if ((OPC) < 0 || (OPC) >= (INTISA)->num_opcodes) \
{ \
xtisa_errno = xtensa_isa_bad_opcode; \
strcpy (xtisa_error_msg, "invalid opcode specifier"); \
return (ERRVAL); \
} \
} while (0)
@ xtensa_isa_bad_opcode
Definition: xtensa-isa.h:153

Definition at line 664 of file xtensa-isa.c.

◆ CHECK_OPERAND

#define CHECK_OPERAND (   INTISA,
  OPC,
  ICLASS,
  OPND,
  ERRVAL 
)
Value:
do { \
if ((OPND) < 0 || (OPND) >= (ICLASS)->num_operands) \
{ \
xtisa_errno = xtensa_isa_bad_operand; \
sprintf (xtisa_error_msg, "invalid operand number (%d); " \
"opcode \"%s\" has %d operands", (OPND), \
(INTISA)->opcodes[(OPC)].name, (ICLASS)->num_operands); \
return (ERRVAL); \
} \
} while (0)
#define OPND(x)
Definition: aarch64-tbl.h:33

Definition at line 881 of file xtensa-isa.c.

◆ CHECK_REGFILE

#define CHECK_REGFILE (   INTISA,
  RF,
  ERRVAL 
)
Value:
do { \
if ((RF) < 0 || (RF) >= (INTISA)->num_regfiles) \
{ \
xtisa_errno = xtensa_isa_bad_regfile; \
strcpy (xtisa_error_msg, "invalid regfile specifier"); \
return (ERRVAL); \
} \
} while (0)
@ xtensa_isa_bad_regfile
Definition: xtensa-isa.h:157

Definition at line 1393 of file xtensa-isa.c.

◆ CHECK_SLOT

#define CHECK_SLOT (   INTISA,
  FMT,
  SLOT,
  ERRVAL 
)
Value:
do { \
if ((SLOT) < 0 || (SLOT) >= (INTISA)->formats[FMT].num_slots) \
{ \
xtisa_errno = xtensa_isa_bad_slot; \
strcpy (xtisa_error_msg, "invalid slot specifier"); \
return (ERRVAL); \
} \
} while (0)
@ xtensa_isa_bad_slot
Definition: xtensa-isa.h:152
static xtensa_format_internal formats[]

Definition at line 523 of file xtensa-isa.c.

◆ CHECK_STATE

#define CHECK_STATE (   INTISA,
  ST,
  ERRVAL 
)
Value:
do { \
if ((ST) < 0 || (ST) >= (INTISA)->num_states) \
{ \
xtisa_errno = xtensa_isa_bad_state; \
strcpy (xtisa_error_msg, "invalid state specifier"); \
return (ERRVAL); \
} \
} while (0)
@ xtensa_isa_bad_state
Definition: xtensa-isa.h:159

Definition at line 1513 of file xtensa-isa.c.

◆ CHECK_STATE_OPERAND

#define CHECK_STATE_OPERAND (   INTISA,
  OPC,
  ICLASS,
  STOP,
  ERRVAL 
)
Value:
do { \
if ((STOP) < 0 || (STOP) >= (ICLASS)->num_stateOperands) \
{ \
xtisa_errno = xtensa_isa_bad_operand; \
sprintf (xtisa_error_msg, "invalid state operand number (%d); " \
"opcode \"%s\" has %d state operands", (STOP), \
(INTISA)->opcodes[(OPC)].name, (ICLASS)->num_stateOperands); \
return (ERRVAL); \
} \
} while (0)

Definition at line 1312 of file xtensa-isa.c.

◆ CHECK_SYSREG

#define CHECK_SYSREG (   INTISA,
  SYSREG,
  ERRVAL 
)
Value:
do { \
if ((SYSREG) < 0 || (SYSREG) >= (INTISA)->num_sysregs) \
{ \
xtisa_errno = xtensa_isa_bad_sysreg; \
strcpy (xtisa_error_msg, "invalid sysreg specifier"); \
return (ERRVAL); \
} \
} while (0)
@ xtensa_isa_bad_sysreg
Definition: xtensa-isa.h:158

Definition at line 1601 of file xtensa-isa.c.

Function Documentation

◆ byte_to_bit_index()

static int byte_to_bit_index ( int  byte_index)
inlinestatic

Definition at line 117 of file xtensa-isa.c.

118 {
119  return (byte_index & 0x3) * 8;
120 }

Referenced by xtensa_insnbuf_from_chars(), and xtensa_insnbuf_to_chars().

◆ byte_to_word_index()

static int byte_to_word_index ( int  byte_index)
inlinestatic

Definition at line 110 of file xtensa-isa.c.

111 {
112  return byte_index / sizeof (xtensa_insnbuf_word);
113 }
uint32 xtensa_insnbuf_word
Definition: xtensa-isa.h:178

Referenced by xtensa_insnbuf_from_chars(), and xtensa_insnbuf_to_chars().

◆ filename_cmp()

int filename_cmp ( const char *  s1,
const char *  s2 
)

Definition at line 151 of file elf32-xtensa.c.

152 {
153 #if !defined(HAVE_DOS_BASED_FILE_SYSTEM) \
154  && !defined(HAVE_CASE_INSENSITIVE_FILE_SYSTEM)
155  return strcmp(s1, s2);
156 #else
157  for (;;)
158  {
159  int c1 = *s1;
160  int c2 = *s2;
161 
162 #if defined (HAVE_CASE_INSENSITIVE_FILE_SYSTEM)
163  c1 = TOLOWER (c1);
164  c2 = TOLOWER (c2);
165 #endif
166 
167 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
168  /* On DOS-based file systems, the '/' and the '\' are equivalent. */
169  if (c1 == '/')
170  c1 = '\\';
171  if (c2 == '/')
172  c2 = '\\';
173 #endif
174 
175  if (c1 != c2)
176  return (c1 - c2);
177 
178  if (c1 == '\0')
179  return 0;
180 
181  s1++;
182  s2++;
183  }
184 #endif
185 }
lsl lsr asr ror lsl lsr asr ror lsl lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror c1
lsl lsr asr ror lsl lsr asr ror lsl lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror lsl lsr asr ror c2
#define TOLOWER(c)
Definition: safe-ctype.h:114
#define s1(x)
Definition: sha256.c:60

References c1, c2, s1, s2, and TOLOWER.

Referenced by xtensa_regfile_lookup(), and xtensa_regfile_lookup_shortname().

◆ get_operand()

static xtensa_operand_internal* get_operand ( xtensa_isa_internal intisa,
xtensa_opcode  opc,
int  opnd 
)
static

Definition at line 895 of file xtensa-isa.c.

896 {
897  xtensa_iclass_internal *iclass;
898  int iclass_id, operand_id;
899 
900  CHECK_OPCODE (intisa, opc, NULL);
901  iclass_id = intisa->opcodes[opc].iclass_id;
902  iclass = &intisa->iclasses[iclass_id];
903  CHECK_OPERAND (intisa, opc, iclass, opnd, NULL);
904  operand_id = iclass->operands[opnd].u.operand_id;
905  return &intisa->operands[operand_id];
906 }
#define NULL
Definition: cris-opc.c:27
static ut64 opc
Definition: desil.c:33
union xtensa_arg_internal_struct::@102 u
xtensa_operand_internal * operands
xtensa_opcode_internal * opcodes
xtensa_iclass_internal * iclasses
#define CHECK_OPERAND(INTISA, OPC, ICLASS, OPND, ERRVAL)
Definition: xtensa-isa.c:881
#define CHECK_OPCODE(INTISA, OPC, ERRVAL)
Definition: xtensa-isa.c:664

References CHECK_OPCODE, CHECK_OPERAND, xtensa_opcode_internal_struct::iclass_id, xtensa_isa_internal_struct::iclasses, NULL, opc, xtensa_isa_internal_struct::opcodes, xtensa_arg_internal_struct::operand_id, xtensa_iclass_internal_struct::operands, xtensa_isa_internal_struct::operands, and xtensa_arg_internal_struct::u.

Referenced by xtensa_operand_decode(), xtensa_operand_do_reloc(), xtensa_operand_encode(), xtensa_operand_get_field(), xtensa_operand_is_known_reg(), xtensa_operand_is_PCrelative(), xtensa_operand_is_register(), xtensa_operand_name(), xtensa_operand_num_regs(), xtensa_operand_regfile(), xtensa_operand_set_field(), and xtensa_operand_undo_reloc().

◆ xtensa_format_decode()

xtensa_format xtensa_format_decode ( xtensa_isa  isa,
const xtensa_insnbuf  insn 
)

Definition at line 570 of file xtensa-isa.c.

571 {
572  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
573  xtensa_format fmt;
574 
575  fmt = (intisa->format_decode_fn) (insn);
576  if (fmt != XTENSA_UNDEFINED) {
577  return fmt;
578  }
579 
581  strcpy (xtisa_error_msg, "cannot decode instruction format");
582  return XTENSA_UNDEFINED;
583 }
xtensa_format_decode_fn format_decode_fn
int xtensa_format
Definition: xtensa-isa.h:84
#define XTENSA_UNDEFINED
Definition: xtensa-isa.h:93

References xtensa_isa_internal_struct::format_decode_fn, xtensa_isa_bad_format, XTENSA_UNDEFINED, xtisa_errno, and xtisa_error_msg.

Referenced by print_insn_xtensa(), xtensa_insnbuf_to_chars(), and xtensa_op().

◆ xtensa_format_encode()

int xtensa_format_encode ( xtensa_isa  isa,
xtensa_format  fmt,
xtensa_insnbuf  insn 
)

Definition at line 587 of file xtensa-isa.c.

588 {
589  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
590  CHECK_FORMAT (intisa, fmt, -1);
591  (*intisa->formats[fmt].encode_fn) (insn);
592  return 0;
593 }
xtensa_format_encode_fn encode_fn
xtensa_format_internal * formats
#define CHECK_FORMAT(INTISA, FMT, ERRVAL)
Definition: xtensa-isa.c:512

References CHECK_FORMAT, xtensa_format_internal_struct::encode_fn, and xtensa_isa_internal_struct::formats.

◆ xtensa_format_get_slot()

int xtensa_format_get_slot ( xtensa_isa  isa,
xtensa_format  fmt,
int  slot,
const xtensa_insnbuf  insn,
xtensa_insnbuf  slotbuf 
)

Definition at line 629 of file xtensa-isa.c.

631 {
632  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
633  int slot_id;
634 
635  CHECK_FORMAT (intisa, fmt, -1);
636  CHECK_SLOT (intisa, fmt, slot, -1);
637 
638  slot_id = intisa->formats[fmt].slot_id[slot];
639  (*intisa->slots[slot_id].get_fn) (insn, slotbuf);
640  return 0;
641 }
xtensa_slot_internal * slots
#define CHECK_SLOT(INTISA, FMT, SLOT, ERRVAL)
Definition: xtensa-isa.c:523

References CHECK_FORMAT, CHECK_SLOT, xtensa_isa_internal_struct::formats, xtensa_slot_internal_struct::get_fn, xtensa_format_internal_struct::slot_id, and xtensa_isa_internal_struct::slots.

Referenced by print_insn_xtensa(), and xtensa_op().

◆ xtensa_format_length()

int xtensa_format_length ( xtensa_isa  isa,
xtensa_format  fmt 
)

◆ xtensa_format_lookup()

xtensa_format xtensa_format_lookup ( xtensa_isa  isa,
const char *  fmtname 
)

Definition at line 544 of file xtensa-isa.c.

545 {
546  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
547  int fmt;
548 
549  if (!fmtname || !*fmtname)
550  {
552  strcpy (xtisa_error_msg, "invalid format name");
553  return XTENSA_UNDEFINED;
554  }
555 
556  for (fmt = 0; fmt < intisa->num_formats; fmt++)
557  {
558  if (rz_str_casecmp (fmtname, intisa->formats[fmt].name) == 0) {
559  return fmt;
560  }
561  }
562 
564  sprintf (xtisa_error_msg, "format \"%s\" not recognized", fmtname);
565  return XTENSA_UNDEFINED;
566 }
sprintf
Definition: kernel.h:365
RZ_API int rz_str_casecmp(const char *dst, const char *orig)
Definition: str.c:121

References xtensa_isa_internal_struct::formats, xtensa_format_internal_struct::name, xtensa_isa_internal_struct::num_formats, rz_str_casecmp(), sprintf, xtensa_isa_bad_format, XTENSA_UNDEFINED, xtisa_errno, and xtisa_error_msg.

◆ xtensa_format_name()

const char* xtensa_format_name ( xtensa_isa  isa,
xtensa_format  fmt 
)

Definition at line 535 of file xtensa-isa.c.

536 {
537  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
538  CHECK_FORMAT (intisa, fmt, NULL);
539  return intisa->formats[fmt].name;
540 }

References CHECK_FORMAT, xtensa_isa_internal_struct::formats, xtensa_format_internal_struct::name, and NULL.

◆ xtensa_format_num_slots()

int xtensa_format_num_slots ( xtensa_isa  isa,
xtensa_format  fmt 
)

Definition at line 606 of file xtensa-isa.c.

607 {
608  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
609  CHECK_FORMAT (intisa, fmt, XTENSA_UNDEFINED);
610  return intisa->formats[fmt].num_slots;
611 }

References CHECK_FORMAT, xtensa_isa_internal_struct::formats, xtensa_format_internal_struct::num_slots, and XTENSA_UNDEFINED.

Referenced by print_insn_xtensa(), and xtensa_op().

◆ xtensa_format_set_slot()

int xtensa_format_set_slot ( xtensa_isa  isa,
xtensa_format  fmt,
int  slot,
xtensa_insnbuf  insn,
const xtensa_insnbuf  slotbuf 
)

Definition at line 645 of file xtensa-isa.c.

647 {
648  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
649  int slot_id;
650 
651  CHECK_FORMAT (intisa, fmt, -1);
652  CHECK_SLOT (intisa, fmt, slot, -1);
653 
654  slot_id = intisa->formats[fmt].slot_id[slot];
655  (*intisa->slots[slot_id].set_fn) (insn, slotbuf);
656  return 0;
657 }

References CHECK_FORMAT, CHECK_SLOT, xtensa_isa_internal_struct::formats, xtensa_slot_internal_struct::set_fn, xtensa_format_internal_struct::slot_id, and xtensa_isa_internal_struct::slots.

◆ xtensa_format_slot_nop_opcode()

xtensa_opcode xtensa_format_slot_nop_opcode ( xtensa_isa  isa,
xtensa_format  fmt,
int  slot 
)

Definition at line 615 of file xtensa-isa.c.

616 {
617  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
618  int slot_id;
619 
620  CHECK_FORMAT (intisa, fmt, XTENSA_UNDEFINED);
621  CHECK_SLOT (intisa, fmt, slot, XTENSA_UNDEFINED);
622 
623  slot_id = intisa->formats[fmt].slot_id[slot];
624  return xtensa_opcode_lookup (isa, intisa->slots[slot_id].nop_name);
625 }
xtensa_opcode xtensa_opcode_lookup(xtensa_isa isa, const char *opname)
Definition: xtensa-isa.c:676

References CHECK_FORMAT, CHECK_SLOT, xtensa_isa_internal_struct::formats, xtensa_slot_internal_struct::nop_name, xtensa_format_internal_struct::slot_id, xtensa_isa_internal_struct::slots, xtensa_opcode_lookup(), and XTENSA_UNDEFINED.

◆ xtensa_funcUnit_lookup()

xtensa_funcUnit xtensa_funcUnit_lookup ( xtensa_isa  isa,
const char *  fname 
)

Definition at line 1806 of file xtensa-isa.c.

1807 {
1808  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1809  xtensa_lookup_entry entry, *result = 0;
1810 
1811  if (!fname || !*fname)
1812  {
1814  strcpy (xtisa_error_msg, "invalid functional unit name");
1815  return XTENSA_UNDEFINED;
1816  }
1817 
1818  if (intisa->num_funcUnits != 0)
1819  {
1820  entry.key = fname;
1821  result = bsearch (&entry, intisa->funcUnit_lookup_table,
1822  intisa->num_funcUnits, sizeof (xtensa_lookup_entry),
1824  }
1825 
1826  if (!result)
1827  {
1830  "functional unit \"%s\" not recognized", fname);
1831  return XTENSA_UNDEFINED;
1832  }
1833 
1834  return result->u.fun;
1835 }
Definition: zipcmp.c:77
xtensa_lookup_entry * funcUnit_lookup_table
xtensa_funcUnit fun
union xtensa_lookup_entry_struct::@103 u
int xtensa_isa_name_compare(const void *v1, const void *v2)
Definition: xtensa-isa.c:395

References create_tags_rz::fname, xtensa_lookup_entry_struct::fun, xtensa_isa_internal_struct::funcUnit_lookup_table, xtensa_isa_internal_struct::num_funcUnits, sprintf, xtensa_lookup_entry_struct::u, xtensa_isa_bad_funcUnit, xtensa_isa_name_compare(), XTENSA_UNDEFINED, xtisa_errno, and xtisa_error_msg.

◆ xtensa_funcUnit_name()

const char* xtensa_funcUnit_name ( xtensa_isa  isa,
xtensa_funcUnit  fun 
)

Definition at line 1839 of file xtensa-isa.c.

1840 {
1841  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1842  CHECK_FUNCUNIT (intisa, fun, NULL);
1843  return intisa->funcUnits[fun].name;
1844 }
xtensa_funcUnit_internal * funcUnits
#define CHECK_FUNCUNIT(INTISA, FUN, ERRVAL)
Definition: xtensa-isa.c:1794

References CHECK_FUNCUNIT, xtensa_isa_internal_struct::funcUnits, xtensa_funcUnit_internal_struct::name, and NULL.

◆ xtensa_funcUnit_num_copies()

int xtensa_funcUnit_num_copies ( xtensa_isa  isa,
xtensa_funcUnit  fun 
)

◆ xtensa_insnbuf_alloc()

xtensa_insnbuf xtensa_insnbuf_alloc ( xtensa_isa  isa)

Definition at line 88 of file xtensa-isa.c.

89 {
92  CHECK_ALLOC (result, 0);
93  return result;
94 }
void * malloc(size_t size)
Definition: malloc.c:123
int xtensa_insnbuf_size(xtensa_isa isa)
Definition: xtensa-isa.c:80
#define CHECK_ALLOC(MEM, ERRVAL)
Definition: xtensa-isa.c:53
xtensa_insnbuf_word * xtensa_insnbuf
Definition: xtensa-isa.h:179

References CHECK_ALLOC, malloc(), and xtensa_insnbuf_size().

Referenced by print_insn_xtensa(), xtensa_op(), and xtensa_operand_encode().

◆ xtensa_insnbuf_free()

void xtensa_insnbuf_free ( xtensa_isa isa   __attribute__(unused),
xtensa_insnbuf  buf 
)

Definition at line 98 of file xtensa-isa.c.

100 {
101  free (buf);
102 }
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
voidpf void * buf
Definition: ioapi.h:138

References free().

◆ xtensa_insnbuf_from_chars()

void xtensa_insnbuf_from_chars ( xtensa_isa  isa,
xtensa_insnbuf  insn,
const unsigned char *  cp,
int  num_chars 
)

Definition at line 196 of file xtensa-isa.c.

200 {
201  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
202  int max_size, insn_size, fence_post, start, increment, i;
203 
204  max_size = xtensa_isa_maxlength (isa);
205 
206  /* Decode the instruction length so we know how many bytes to read. */
207  insn_size = (intisa->length_decode_fn) (cp);
208  if (insn_size == XTENSA_UNDEFINED)
209  {
210  /* This should never happen when the byte stream contains a
211  valid instruction. Just read the maximum number of bytes.... */
212  insn_size = max_size;
213  }
214 
215  if (num_chars == 0 || num_chars > insn_size) {
216  num_chars = insn_size;
217  }
218 
219  if (intisa->is_big_endian) {
220  start = max_size - 1;
221  increment = -1;
222  }
223  else
224  {
225  start = 0;
226  increment = 1;
227  }
228 
229  fence_post = start + (num_chars * increment);
230  memset (insn, 0, xtensa_insnbuf_size (isa) * sizeof (xtensa_insnbuf_word));
231 
232  for (i = start; i != fence_post; i += increment, ++cp)
233  {
234  int word_inx = byte_to_word_index (i);
235  int bit_inx = byte_to_bit_index (i);
236 
237  insn[word_inx] |= (*cp & 0xff) << bit_inx;
238  }
239 }
lzma_index ** i
Definition: index.h:629
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
Definition: sflib.h:133
return memset(p, 0, total)
xtensa_length_decode_fn length_decode_fn
static int byte_to_word_index(int byte_index)
Definition: xtensa-isa.c:110
int xtensa_isa_maxlength(xtensa_isa isa)
Definition: xtensa-isa.c:405
static int byte_to_bit_index(int byte_index)
Definition: xtensa-isa.c:117

References byte_to_bit_index(), byte_to_word_index(), i, xtensa_isa_internal_struct::is_big_endian, xtensa_isa_internal_struct::length_decode_fn, memset(), start, xtensa_insnbuf_size(), xtensa_isa_maxlength(), and XTENSA_UNDEFINED.

Referenced by print_insn_xtensa(), and xtensa_op().

◆ xtensa_insnbuf_size()

int xtensa_insnbuf_size ( xtensa_isa  isa)

◆ xtensa_insnbuf_to_chars()

int xtensa_insnbuf_to_chars ( xtensa_isa  isa,
const xtensa_insnbuf  insn,
unsigned char *  cp,
int  num_chars 
)

Definition at line 133 of file xtensa-isa.c.

137 {
138  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
139  int insn_size = xtensa_isa_maxlength (isa);
140  int fence_post, start, increment, i, byte_count;
141  xtensa_format fmt;
142 
143  if (num_chars == 0) {
144  num_chars = insn_size;
145  }
146 
147  if (intisa->is_big_endian)
148  {
149  start = insn_size - 1;
150  increment = -1;
151  }
152  else
153  {
154  start = 0;
155  increment = 1;
156  }
157 
158  /* Find the instruction format. Do nothing if the buffer does not contain
159  a valid instruction since we need to know how many bytes to copy. */
160  fmt = xtensa_format_decode (isa, insn);
161  if (fmt == XTENSA_UNDEFINED) {
162  return XTENSA_UNDEFINED;
163  }
164 
165  byte_count = xtensa_format_length (isa, fmt);
166  if (byte_count == XTENSA_UNDEFINED) {
167  return XTENSA_UNDEFINED;
168  }
169 
170  if (byte_count > num_chars)
171  {
173  strcpy (xtisa_error_msg, "output buffer too small for instruction");
174  return XTENSA_UNDEFINED;
175  }
176 
177  fence_post = start + (byte_count * increment);
178 
179  for (i = start; i != fence_post; i += increment, ++cp)
180  {
181  int word_inx = byte_to_word_index (i);
182  int bit_inx = byte_to_bit_index (i);
183 
184  *cp = (insn[word_inx] >> bit_inx) & 0xff;
185  }
186 
187  return byte_count;
188 }
int xtensa_format_length(xtensa_isa isa, xtensa_format fmt)
Definition: xtensa-isa.c:597
xtensa_format xtensa_format_decode(xtensa_isa isa, const xtensa_insnbuf insn)
Definition: xtensa-isa.c:570
@ xtensa_isa_buffer_overflow
Definition: xtensa-isa.h:165

References byte_to_bit_index(), byte_to_word_index(), i, xtensa_isa_internal_struct::is_big_endian, start, xtensa_format_decode(), xtensa_format_length(), xtensa_isa_buffer_overflow, xtensa_isa_maxlength(), XTENSA_UNDEFINED, xtisa_errno, and xtisa_error_msg.

◆ xtensa_interface_class_id()

int xtensa_interface_class_id ( xtensa_isa  isa,
xtensa_interface  intf 
)

Definition at line 1782 of file xtensa-isa.c.

1783 {
1784  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1786  return intisa->interfaces[intf].class_id;
1787 }
xtensa_interface_internal * interfaces
#define CHECK_INTERFACE(INTISA, INTF, ERRVAL)
Definition: xtensa-isa.c:1699
int FAR intf
Definition: zconf.h:403

References CHECK_INTERFACE, xtensa_interface_internal_struct::class_id, xtensa_isa_internal_struct::interfaces, and XTENSA_UNDEFINED.

◆ xtensa_interface_has_side_effect()

int xtensa_interface_has_side_effect ( xtensa_isa  isa,
xtensa_interface  intf 
)

Definition at line 1770 of file xtensa-isa.c.

1771 {
1772  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1774  if ((intisa->interfaces[intf].flags & XTENSA_INTERFACE_HAS_SIDE_EFFECT) != 0) {
1775  return 1;
1776  }
1777  return 0;
1778 }
#define XTENSA_INTERFACE_HAS_SIDE_EFFECT

References CHECK_INTERFACE, xtensa_interface_internal_struct::flags, xtensa_isa_internal_struct::interfaces, XTENSA_INTERFACE_HAS_SIDE_EFFECT, and XTENSA_UNDEFINED.

◆ xtensa_interface_inout()

char xtensa_interface_inout ( xtensa_isa  isa,
xtensa_interface  intf 
)

Definition at line 1761 of file xtensa-isa.c.

1762 {
1763  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1764  CHECK_INTERFACE (intisa, intf, 0);
1765  return intisa->interfaces[intf].inout;
1766 }

References CHECK_INTERFACE, xtensa_interface_internal_struct::inout, and xtensa_isa_internal_struct::interfaces.

◆ xtensa_interface_lookup()

xtensa_interface xtensa_interface_lookup ( xtensa_isa  isa,
const char *  ifname 
)

Definition at line 1711 of file xtensa-isa.c.

1712 {
1713  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1714  xtensa_lookup_entry entry, *result = 0;
1715 
1716  if (!ifname || !*ifname)
1717  {
1719  strcpy (xtisa_error_msg, "invalid interface name");
1720  return XTENSA_UNDEFINED;
1721  }
1722 
1723  if (intisa->num_interfaces != 0)
1724  {
1725  entry.key = ifname;
1726  result = bsearch (&entry, intisa->interface_lookup_table,
1727  intisa->num_interfaces, sizeof (xtensa_lookup_entry),
1729  }
1730 
1731  if (!result)
1732  {
1734  sprintf (xtisa_error_msg, "interface \"%s\" not recognized", ifname);
1735  return XTENSA_UNDEFINED;
1736  }
1737 
1738  return result->u.intf;
1739 }
xtensa_lookup_entry * interface_lookup_table
xtensa_interface intf

References xtensa_isa_internal_struct::interface_lookup_table, xtensa_lookup_entry_struct::intf, xtensa_isa_internal_struct::num_interfaces, sprintf, xtensa_lookup_entry_struct::u, xtensa_isa_bad_interface, xtensa_isa_name_compare(), XTENSA_UNDEFINED, xtisa_errno, and xtisa_error_msg.

◆ xtensa_interface_name()

const char* xtensa_interface_name ( xtensa_isa  isa,
xtensa_interface  intf 
)

Definition at line 1743 of file xtensa-isa.c.

1744 {
1745  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1746  CHECK_INTERFACE (intisa, intf, NULL);
1747  return intisa->interfaces[intf].name;
1748 }

References CHECK_INTERFACE, xtensa_isa_internal_struct::interfaces, xtensa_interface_internal_struct::name, and NULL.

◆ xtensa_interface_num_bits()

int xtensa_interface_num_bits ( xtensa_isa  isa,
xtensa_interface  intf 
)

◆ xtensa_interfaceOperand_interface()

xtensa_interface xtensa_interfaceOperand_interface ( xtensa_isa  isa,
xtensa_opcode  opc,
int  ifOp 
)

Definition at line 1374 of file xtensa-isa.c.

1376 {
1377  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1378  xtensa_iclass_internal *iclass;
1379  int iclass_id;
1380 
1381  CHECK_OPCODE (intisa, opc, XTENSA_UNDEFINED);
1382  iclass_id = intisa->opcodes[opc].iclass_id;
1383  iclass = &intisa->iclasses[iclass_id];
1384  CHECK_INTERFACE_OPERAND (intisa, opc, iclass, ifOp, XTENSA_UNDEFINED);
1385  return iclass->interfaceOperands[ifOp];
1386 }
#define CHECK_INTERFACE_OPERAND(INTISA, OPC, ICLASS, IFOP, ERRVAL)
Definition: xtensa-isa.c:1359

References CHECK_INTERFACE_OPERAND, CHECK_OPCODE, xtensa_opcode_internal_struct::iclass_id, xtensa_isa_internal_struct::iclasses, xtensa_iclass_internal_struct::interfaceOperands, opc, xtensa_isa_internal_struct::opcodes, and XTENSA_UNDEFINED.

◆ xtensa_isa_errno()

xtensa_isa_status xtensa_isa_errno ( xtensa_isa isa   __attribute__(unused))

Definition at line 40 of file xtensa-isa.c.

41 {
42  return xtisa_errno;
43 }

References xtisa_errno.

◆ xtensa_isa_error_msg()

char* xtensa_isa_error_msg ( xtensa_isa isa   __attribute__(unused))

Definition at line 47 of file xtensa-isa.c.

48 {
49  return xtisa_error_msg;
50 }

References xtisa_error_msg.

◆ xtensa_isa_free()

void xtensa_isa_free ( xtensa_isa  isa)

Definition at line 344 of file xtensa-isa.c.

345 {
346  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
347  int n;
348 
349  /* With this version of the code, the xtensa_isa structure is not
350  dynamically allocated, so this function is not essential. Free
351  the memory allocated by xtensa_isa_init and restore the xtensa_isa
352  structure to its initial state. */
353 
354  if (intisa->opname_lookup_table)
355  {
356  free (intisa->opname_lookup_table);
357  intisa->opname_lookup_table = 0;
358  }
359 
360  if (intisa->state_lookup_table)
361  {
362  free (intisa->state_lookup_table);
363  intisa->state_lookup_table = 0;
364  }
365 
366  if (intisa->sysreg_lookup_table)
367  {
368  free (intisa->sysreg_lookup_table);
369  intisa->sysreg_lookup_table = 0;
370  }
371  for (n = 0; n < 2; n++)
372  {
373  if (intisa->sysreg_table[n])
374  {
375  free (intisa->sysreg_table[n]);
376  intisa->sysreg_table[n] = 0;
377  }
378  }
379 
380  if (intisa->interface_lookup_table)
381  {
382  free (intisa->interface_lookup_table);
383  intisa->interface_lookup_table = 0;
384  }
385 
386  if (intisa->funcUnit_lookup_table)
387  {
388  free (intisa->funcUnit_lookup_table);
389  intisa->funcUnit_lookup_table = 0;
390  }
391 }
int n
Definition: mipsasm.c:19
xtensa_lookup_entry * sysreg_lookup_table
xtensa_lookup_entry * state_lookup_table
xtensa_lookup_entry * opname_lookup_table

References free(), xtensa_isa_internal_struct::funcUnit_lookup_table, xtensa_isa_internal_struct::interface_lookup_table, n, xtensa_isa_internal_struct::opname_lookup_table, xtensa_isa_internal_struct::state_lookup_table, xtensa_isa_internal_struct::sysreg_lookup_table, and xtensa_isa_internal_struct::sysreg_table.

◆ xtensa_isa_init()

xtensa_isa xtensa_isa_init ( xtensa_isa_status errno_p,
char **  error_msg_p 
)

Definition at line 248 of file xtensa-isa.c.

249 {
251  int n, is_user;
252 
253  /* Set up the opcode name lookup table. */
254  isa->opname_lookup_table =
255  bfd_malloc (isa->num_opcodes * sizeof (xtensa_lookup_entry));
256  CHECK_ALLOC_FOR_INIT (isa->opname_lookup_table, NULL, errno_p, error_msg_p);
257  for (n = 0; n < isa->num_opcodes; n++)
258  {
259  isa->opname_lookup_table[n].key = isa->opcodes[n].name;
260  isa->opname_lookup_table[n].u.opcode = n;
261  }
264 
265  /* Set up the state name lookup table. */
266  isa->state_lookup_table =
267  bfd_malloc (isa->num_states * sizeof (xtensa_lookup_entry));
268  CHECK_ALLOC_FOR_INIT (isa->state_lookup_table, NULL, errno_p, error_msg_p);
269  for (n = 0; n < isa->num_states; n++)
270  {
271  isa->state_lookup_table[n].key = isa->states[n].name;
272  isa->state_lookup_table[n].u.state = n;
273  }
274  qsort (isa->state_lookup_table, isa->num_states,
276 
277  /* Set up the sysreg name lookup table. */
278  isa->sysreg_lookup_table =
279  bfd_malloc (isa->num_sysregs * sizeof (xtensa_lookup_entry));
280  CHECK_ALLOC_FOR_INIT (isa->sysreg_lookup_table, NULL, errno_p, error_msg_p);
281  for (n = 0; n < isa->num_sysregs; n++)
282  {
283  isa->sysreg_lookup_table[n].key = isa->sysregs[n].name;
284  isa->sysreg_lookup_table[n].u.sysreg = n;
285  }
288 
289  /* Set up the user & system sysreg number tables. */
290  for (is_user = 0; is_user < 2; is_user++)
291  {
292  isa->sysreg_table[is_user] =
293  bfd_malloc ((isa->max_sysreg_num[is_user] + 1)
294  * sizeof (xtensa_sysreg));
295  CHECK_ALLOC_FOR_INIT (isa->sysreg_table[is_user], NULL,
296  errno_p, error_msg_p);
297 
298  for (n = 0; n <= isa->max_sysreg_num[is_user]; n++) {
299  isa->sysreg_table[is_user][n] = XTENSA_UNDEFINED;
300  }
301  }
302  for (n = 0; n < isa->num_sysregs; n++)
303  {
304  xtensa_sysreg_internal *sreg = &isa->sysregs[n];
305  is_user = sreg->is_user;
306 
307  isa->sysreg_table[is_user][sreg->number] = n;
308  }
309 
310  /* Set up the interface lookup table. */
312  calloc (isa->num_interfaces, sizeof (xtensa_lookup_entry));
314  error_msg_p);
315  for (n = 0; n < isa->num_interfaces; n++)
316  {
318  isa->interface_lookup_table[n].u.intf = n;
319  }
322 
323  /* Set up the funcUnit lookup table. */
324  isa->funcUnit_lookup_table =
325  bfd_malloc (isa->num_funcUnits * sizeof (xtensa_lookup_entry));
327  error_msg_p);
328  for (n = 0; n < isa->num_funcUnits; n++)
329  {
330  isa->funcUnit_lookup_table[n].key = isa->funcUnits[n].name;
331  isa->funcUnit_lookup_table[n].u.fun = n;
332  }
335 
336  isa->insnbuf_size = ((isa->insn_size + sizeof (xtensa_insnbuf_word) - 1) /
337  sizeof (xtensa_insnbuf_word));
338 
339  return (xtensa_isa) isa;
340 }
#define bfd_malloc
Definition: disas-asm.h:42
void * calloc(size_t number, size_t size)
Definition: malloc.c:102
void qsort(void *a, size_t n, size_t es, int(*cmp)(const void *, const void *))
Definition: qsort.h:130
xtensa_state_internal * states
xtensa_sysreg_internal * sysregs
xtensa_opcode opcode
xtensa_state state
xtensa_sysreg sysreg
const char * key
#define CHECK_ALLOC_FOR_INIT(MEM, ERRVAL, ERRNO_P, ERROR_MSG_P)
Definition: xtensa-isa.c:63
xtensa_isa_internal xtensa_modules
int xtensa_sysreg
Definition: xtensa-isa.h:87

References bfd_malloc, calloc(), CHECK_ALLOC_FOR_INIT, xtensa_lookup_entry_struct::fun, xtensa_isa_internal_struct::funcUnit_lookup_table, xtensa_isa_internal_struct::funcUnits, xtensa_isa_internal_struct::insn_size, xtensa_isa_internal_struct::insnbuf_size, xtensa_isa_internal_struct::interface_lookup_table, xtensa_isa_internal_struct::interfaces, xtensa_lookup_entry_struct::intf, xtensa_sysreg_internal_struct::is_user, xtensa_lookup_entry_struct::key, xtensa_isa_internal_struct::max_sysreg_num, n, xtensa_opcode_internal_struct::name, xtensa_interface_internal_struct::name, xtensa_funcUnit_internal_struct::name, xtensa_state_internal_struct::name, xtensa_sysreg_internal_struct::name, NULL, xtensa_isa_internal_struct::num_funcUnits, xtensa_isa_internal_struct::num_interfaces, xtensa_isa_internal_struct::num_opcodes, xtensa_isa_internal_struct::num_states, xtensa_isa_internal_struct::num_sysregs, xtensa_sysreg_internal_struct::number, xtensa_lookup_entry_struct::opcode, xtensa_isa_internal_struct::opcodes, xtensa_isa_internal_struct::opname_lookup_table, qsort(), xtensa_lookup_entry_struct::state, xtensa_isa_internal_struct::state_lookup_table, xtensa_isa_internal_struct::states, xtensa_lookup_entry_struct::sysreg, xtensa_isa_internal_struct::sysreg_lookup_table, xtensa_isa_internal_struct::sysreg_table, xtensa_isa_internal_struct::sysregs, xtensa_lookup_entry_struct::u, xtensa_isa_name_compare(), xtensa_modules, and XTENSA_UNDEFINED.

Referenced by print_insn_xtensa(), and xtensa_op().

◆ xtensa_isa_length_from_chars()

int xtensa_isa_length_from_chars ( xtensa_isa  isa,
const unsigned char *  cp 
)

Definition at line 413 of file xtensa-isa.c.

414 {
415  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
416  return (intisa->length_decode_fn) (cp);
417 }

References xtensa_isa_internal_struct::length_decode_fn.

◆ xtensa_isa_maxlength()

int xtensa_isa_maxlength ( xtensa_isa  isa)

Definition at line 405 of file xtensa-isa.c.

406 {
407  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
408  return intisa->insn_size;
409 }

References xtensa_isa_internal_struct::insn_size.

Referenced by fetch_data(), print_insn_xtensa(), xtensa_insnbuf_from_chars(), and xtensa_insnbuf_to_chars().

◆ xtensa_isa_name_compare()

int xtensa_isa_name_compare ( const void *  v1,
const void *  v2 
)

◆ xtensa_isa_num_formats()

int xtensa_isa_num_formats ( xtensa_isa  isa)

Definition at line 453 of file xtensa-isa.c.

454 {
455  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
456  return intisa->num_formats;
457 }

References xtensa_isa_internal_struct::num_formats.

◆ xtensa_isa_num_funcUnits()

int xtensa_isa_num_funcUnits ( xtensa_isa  isa)

Definition at line 501 of file xtensa-isa.c.

502 {
503  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
504  return intisa->num_funcUnits;
505 }

References xtensa_isa_internal_struct::num_funcUnits.

◆ xtensa_isa_num_interfaces()

int xtensa_isa_num_interfaces ( xtensa_isa  isa)

Definition at line 493 of file xtensa-isa.c.

494 {
495  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
496  return intisa->num_interfaces;
497 }

References xtensa_isa_internal_struct::num_interfaces.

◆ xtensa_isa_num_opcodes()

int xtensa_isa_num_opcodes ( xtensa_isa  isa)

Definition at line 461 of file xtensa-isa.c.

462 {
463  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
464  return intisa->num_opcodes;
465 }

References xtensa_isa_internal_struct::num_opcodes.

Referenced by xtensa_isa_num_pipe_stages().

◆ xtensa_isa_num_pipe_stages()

int xtensa_isa_num_pipe_stages ( xtensa_isa  isa)

Definition at line 421 of file xtensa-isa.c.

422 {
423  xtensa_opcode opcode;
424  xtensa_funcUnit_use *use;
425  int num_opcodes, num_uses;
426  int i, stage;
427  static int max_stage = XTENSA_UNDEFINED;
428 
429  /* Only compute the value once. */
430  if (max_stage != XTENSA_UNDEFINED) {
431  return max_stage + 1;
432  }
433 
434  num_opcodes = xtensa_isa_num_opcodes (isa);
435  for (opcode = 0; opcode < num_opcodes; opcode++)
436  {
437  num_uses = xtensa_opcode_num_funcUnit_uses (isa, opcode);
438  for (i = 0; i < num_uses; i++)
439  {
440  use = xtensa_opcode_funcUnit_use (isa, opcode, i);
441  stage = use->stage;
442  if (stage > max_stage) {
443  max_stage = stage;
444  }
445  }
446  }
447 
448  return max_stage + 1;
449 }
int xtensa_opcode_num_funcUnit_uses(xtensa_isa isa, xtensa_opcode opc)
Definition: xtensa-isa.c:852
int xtensa_isa_num_opcodes(xtensa_isa isa)
Definition: xtensa-isa.c:461
xtensa_funcUnit_use * xtensa_opcode_funcUnit_use(xtensa_isa isa, xtensa_opcode opc, int u)
Definition: xtensa-isa.c:861
int xtensa_opcode
Definition: xtensa-isa.h:83

References i, xtensa_funcUnit_use_struct::stage, xtensa_isa_num_opcodes(), xtensa_opcode_funcUnit_use(), xtensa_opcode_num_funcUnit_uses(), and XTENSA_UNDEFINED.

◆ xtensa_isa_num_regfiles()

int xtensa_isa_num_regfiles ( xtensa_isa  isa)

Definition at line 469 of file xtensa-isa.c.

470 {
471  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
472  return intisa->num_regfiles;
473 }

References xtensa_isa_internal_struct::num_regfiles.

◆ xtensa_isa_num_states()

int xtensa_isa_num_states ( xtensa_isa  isa)

Definition at line 477 of file xtensa-isa.c.

478 {
479  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
480  return intisa->num_states;
481 }

References xtensa_isa_internal_struct::num_states.

◆ xtensa_isa_num_sysregs()

int xtensa_isa_num_sysregs ( xtensa_isa  isa)

Definition at line 485 of file xtensa-isa.c.

486 {
487  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
488  return intisa->num_sysregs;
489 }

References xtensa_isa_internal_struct::num_sysregs.

◆ xtensa_opcode_decode()

xtensa_opcode xtensa_opcode_decode ( xtensa_isa  isa,
xtensa_format  fmt,
int  slot,
const xtensa_insnbuf  slotbuf 
)

Definition at line 708 of file xtensa-isa.c.

710 {
711  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
712  int slot_id;
714 
715  CHECK_FORMAT (intisa, fmt, XTENSA_UNDEFINED);
716  CHECK_SLOT (intisa, fmt, slot, XTENSA_UNDEFINED);
717 
718  slot_id = intisa->formats[fmt].slot_id[slot];
719 
720  opc = (intisa->slots[slot_id].opcode_decode_fn) (slotbuf);
721  if (opc != XTENSA_UNDEFINED) {
722  return opc;
723  }
724 
726  strcpy (xtisa_error_msg, "cannot decode opcode");
727  return XTENSA_UNDEFINED;
728 }
xtensa_opcode_decode_fn opcode_decode_fn

References CHECK_FORMAT, CHECK_SLOT, xtensa_isa_internal_struct::formats, opc, xtensa_slot_internal_struct::opcode_decode_fn, xtensa_format_internal_struct::slot_id, xtensa_isa_internal_struct::slots, xtensa_isa_bad_opcode, XTENSA_UNDEFINED, xtisa_errno, and xtisa_error_msg.

Referenced by print_insn_xtensa(), and xtensa_op().

◆ xtensa_opcode_encode()

int xtensa_opcode_encode ( xtensa_isa  isa,
xtensa_format  fmt,
int  slot,
xtensa_insnbuf  slotbuf,
xtensa_opcode  opc 
)

Definition at line 732 of file xtensa-isa.c.

734 {
735  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
736  int slot_id;
737  xtensa_opcode_encode_fn encode_fn;
738 
739  CHECK_FORMAT (intisa, fmt, -1);
740  CHECK_SLOT (intisa, fmt, slot, -1);
741  CHECK_OPCODE (intisa, opc, -1);
742 
743  slot_id = intisa->formats[fmt].slot_id[slot];
744  encode_fn = intisa->opcodes[opc].encode_fns[slot_id];
745  if (!encode_fn)
746  {
749  "opcode \"%s\" is not allowed in slot %d of format \"%s\"",
750  intisa->opcodes[opc].name, slot, intisa->formats[fmt].name);
751  return -1;
752  }
753  (*encode_fn) (slotbuf);
754  return 0;
755 }
xtensa_opcode_encode_fn * encode_fns
void(* xtensa_opcode_encode_fn)(xtensa_insnbuf)
@ xtensa_isa_wrong_slot
Definition: xtensa-isa.h:162

References CHECK_FORMAT, CHECK_OPCODE, CHECK_SLOT, xtensa_opcode_internal_struct::encode_fns, xtensa_isa_internal_struct::formats, xtensa_format_internal_struct::name, xtensa_opcode_internal_struct::name, opc, xtensa_isa_internal_struct::opcodes, xtensa_format_internal_struct::slot_id, sprintf, xtensa_isa_wrong_slot, xtisa_errno, and xtisa_error_msg.

◆ xtensa_opcode_funcUnit_use()

xtensa_funcUnit_use* xtensa_opcode_funcUnit_use ( xtensa_isa  isa,
xtensa_opcode  opc,
int  u 
)

Definition at line 861 of file xtensa-isa.c.

862 {
863  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
864  CHECK_OPCODE (intisa, opc, NULL);
865  if (u < 0 || u >= intisa->opcodes[opc].num_funcUnit_uses)
866  {
868  sprintf (xtisa_error_msg, "invalid functional unit use number (%d); "
869  "opcode \"%s\" has %d", u, intisa->opcodes[opc].name,
870  intisa->opcodes[opc].num_funcUnit_uses);
871  return NULL;
872  }
873  return &intisa->opcodes[opc].funcUnit_uses[u];
874 }
xtensa_funcUnit_use * funcUnit_uses

References CHECK_OPCODE, xtensa_opcode_internal_struct::funcUnit_uses, xtensa_opcode_internal_struct::name, NULL, xtensa_opcode_internal_struct::num_funcUnit_uses, opc, xtensa_isa_internal_struct::opcodes, sprintf, xtensa_isa_bad_funcUnit, xtisa_errno, and xtisa_error_msg.

Referenced by xtensa_isa_num_pipe_stages().

◆ xtensa_opcode_is_branch()

int xtensa_opcode_is_branch ( xtensa_isa  isa,
xtensa_opcode  opc 
)

Definition at line 768 of file xtensa-isa.c.

769 {
770  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
771  CHECK_OPCODE (intisa, opc, XTENSA_UNDEFINED);
772  if ((intisa->opcodes[opc].flags & XTENSA_OPCODE_IS_BRANCH) != 0) {
773  return 1;
774  }
775  return 0;
776 }
#define XTENSA_OPCODE_IS_BRANCH

References CHECK_OPCODE, xtensa_opcode_internal_struct::flags, opc, xtensa_isa_internal_struct::opcodes, XTENSA_OPCODE_IS_BRANCH, and XTENSA_UNDEFINED.

◆ xtensa_opcode_is_call()

int xtensa_opcode_is_call ( xtensa_isa  isa,
xtensa_opcode  opc 
)

Definition at line 804 of file xtensa-isa.c.

805 {
806  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
807  CHECK_OPCODE (intisa, opc, XTENSA_UNDEFINED);
808  if ((intisa->opcodes[opc].flags & XTENSA_OPCODE_IS_CALL) != 0) {
809  return 1;
810  }
811  return 0;
812 }
#define XTENSA_OPCODE_IS_CALL

References CHECK_OPCODE, xtensa_opcode_internal_struct::flags, opc, xtensa_isa_internal_struct::opcodes, XTENSA_OPCODE_IS_CALL, and XTENSA_UNDEFINED.

◆ xtensa_opcode_is_jump()

int xtensa_opcode_is_jump ( xtensa_isa  isa,
xtensa_opcode  opc 
)

Definition at line 780 of file xtensa-isa.c.

781 {
782  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
783  CHECK_OPCODE (intisa, opc, XTENSA_UNDEFINED);
784  if ((intisa->opcodes[opc].flags & XTENSA_OPCODE_IS_JUMP) != 0) {
785  return 1;
786  }
787  return 0;
788 }
#define XTENSA_OPCODE_IS_JUMP

References CHECK_OPCODE, xtensa_opcode_internal_struct::flags, opc, xtensa_isa_internal_struct::opcodes, XTENSA_OPCODE_IS_JUMP, and XTENSA_UNDEFINED.

◆ xtensa_opcode_is_loop()

int xtensa_opcode_is_loop ( xtensa_isa  isa,
xtensa_opcode  opc 
)

Definition at line 792 of file xtensa-isa.c.

793 {
794  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
795  CHECK_OPCODE (intisa, opc, XTENSA_UNDEFINED);
796  if ((intisa->opcodes[opc].flags & XTENSA_OPCODE_IS_LOOP) != 0) {
797  return 1;
798  }
799  return 0;
800 }
#define XTENSA_OPCODE_IS_LOOP

References CHECK_OPCODE, xtensa_opcode_internal_struct::flags, opc, xtensa_isa_internal_struct::opcodes, XTENSA_OPCODE_IS_LOOP, and XTENSA_UNDEFINED.

◆ xtensa_opcode_lookup()

xtensa_opcode xtensa_opcode_lookup ( xtensa_isa  isa,
const char *  opname 
)

Definition at line 676 of file xtensa-isa.c.

677 {
678  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
679  xtensa_lookup_entry entry, *result = 0;
680 
681  if (!opname || !*opname)
682  {
684  strcpy (xtisa_error_msg, "invalid opcode name");
685  return XTENSA_UNDEFINED;
686  }
687 
688  if (intisa->num_opcodes != 0)
689  {
690  entry.key = opname;
691  result = bsearch (&entry, intisa->opname_lookup_table,
692  intisa->num_opcodes, sizeof (xtensa_lookup_entry),
694  }
695 
696  if (!result)
697  {
699  sprintf (xtisa_error_msg, "opcode \"%s\" not recognized", opname);
700  return XTENSA_UNDEFINED;
701  }
702 
703  return result->u.opcode;
704 }

References xtensa_isa_internal_struct::num_opcodes, xtensa_lookup_entry_struct::opcode, xtensa_isa_internal_struct::opname_lookup_table, sprintf, xtensa_lookup_entry_struct::u, xtensa_isa_bad_opcode, xtensa_isa_name_compare(), XTENSA_UNDEFINED, xtisa_errno, and xtisa_error_msg.

Referenced by xtensa_format_slot_nop_opcode().

◆ xtensa_opcode_name()

const char* xtensa_opcode_name ( xtensa_isa  isa,
xtensa_opcode  opc 
)

Definition at line 759 of file xtensa-isa.c.

760 {
761  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
762  CHECK_OPCODE (intisa, opc, NULL);
763  return intisa->opcodes[opc].name;
764 }

References CHECK_OPCODE, xtensa_opcode_internal_struct::name, NULL, opc, and xtensa_isa_internal_struct::opcodes.

Referenced by print_insn_xtensa().

◆ xtensa_opcode_num_funcUnit_uses()

int xtensa_opcode_num_funcUnit_uses ( xtensa_isa  isa,
xtensa_opcode  opc 
)

◆ xtensa_opcode_num_interfaceOperands()

int xtensa_opcode_num_interfaceOperands ( xtensa_isa  isa,
xtensa_opcode  opc 
)

◆ xtensa_opcode_num_operands()

int xtensa_opcode_num_operands ( xtensa_isa  isa,
xtensa_opcode  opc 
)

◆ xtensa_opcode_num_stateOperands()

int xtensa_opcode_num_stateOperands ( xtensa_isa  isa,
xtensa_opcode  opc 
)

◆ xtensa_operand_decode()

int xtensa_operand_decode ( xtensa_isa  isa,
xtensa_opcode  opc,
int  opnd,
uint32 valp 
)

Definition at line 1128 of file xtensa-isa.c.

1130 {
1131  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1132  xtensa_operand_internal *intop;
1133 
1134  intop = get_operand (intisa, opc, opnd);
1135  if (!intop) {
1136  return -1;
1137  }
1138 
1139  /* Use identity function for "default" operands. */
1140  if (!intop->decode) {
1141  return 0;
1142  }
1143 
1144  if ((*intop->decode) (valp))
1145  {
1147  sprintf (xtisa_error_msg, "cannot decode operand value 0x%08x", *valp);
1148  return -1;
1149  }
1150  return 0;
1151 }
static xtensa_operand_internal * get_operand(xtensa_isa_internal *intisa, xtensa_opcode opc, int opnd)
Definition: xtensa-isa.c:895
@ xtensa_isa_bad_value
Definition: xtensa-isa.h:167

References xtensa_operand_internal_struct::decode, get_operand(), opc, sprintf, xtensa_isa_bad_value, xtisa_errno, and xtisa_error_msg.

Referenced by esil_branch_check_bit_imm(), esil_set_shift_amount_imm(), esil_shift_logic_imm(), and print_xtensa_operand().

◆ xtensa_operand_do_reloc()

int xtensa_operand_do_reloc ( xtensa_isa  isa,
xtensa_opcode  opc,
int  opnd,
uint32 valp,
uint32  pc 
)

Definition at line 1239 of file xtensa-isa.c.

1241 {
1242  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1243  xtensa_operand_internal *intop;
1244 
1245  intop = get_operand (intisa, opc, opnd);
1246  if (!intop) {
1247  return -1;
1248  }
1249 
1250  if ((intop->flags & XTENSA_OPERAND_IS_PCRELATIVE) == 0) {
1251  return 0;
1252  }
1253 
1254  if (!intop->do_reloc)
1255  {
1257  strcpy (xtisa_error_msg, "operand missing do_reloc function");
1258  return -1;
1259  }
1260 
1261  if ((*intop->do_reloc) (valp, pc))
1262  {
1265  "do_reloc failed for value 0x%08x at PC 0x%08x", *valp, pc);
1266  return -1;
1267  }
1268 
1269  return 0;
1270 }
#define XTENSA_OPERAND_IS_PCRELATIVE
@ xtensa_isa_internal_error
Definition: xtensa-isa.h:166

References xtensa_operand_internal_struct::do_reloc, xtensa_operand_internal_struct::flags, get_operand(), opc, pc, sprintf, xtensa_isa_bad_value, xtensa_isa_internal_error, XTENSA_OPERAND_IS_PCRELATIVE, xtisa_errno, and xtisa_error_msg.

◆ xtensa_operand_encode()

int xtensa_operand_encode ( xtensa_isa  isa,
xtensa_opcode  opc,
int  opnd,
uint32 valp 
)

Definition at line 1053 of file xtensa-isa.c.

1055 {
1056  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1057  xtensa_operand_internal *intop;
1058  uint32 test_val, orig_val;
1059 
1060  intop = get_operand (intisa, opc, opnd);
1061  if (!intop) {
1062  return -1;
1063  }
1064 
1065  if (!intop->encode)
1066  {
1067  /* This is a default operand for a field. How can we tell if the
1068  value fits in the field? Write the value into the field,
1069  read it back, and then make sure we get the same value. */
1070  static xtensa_insnbuf tmpbuf = 0;
1071  int slot_id;
1072 
1073  if (!tmpbuf)
1074  {
1075  tmpbuf = xtensa_insnbuf_alloc (isa);
1076  CHECK_ALLOC (tmpbuf, -1);
1077  }
1078 
1079  /* A default operand is always associated with a field,
1080  but check just to be sure.... */
1081  if (intop->field_id == XTENSA_UNDEFINED)
1082  {
1084  strcpy (xtisa_error_msg, "operand has no field");
1085  return -1;
1086  }
1087 
1088  /* Find some slot that includes the field. */
1089  for (slot_id = 0; slot_id < intisa->num_slots; slot_id++)
1090  {
1091  xtensa_get_field_fn get_fn =
1092  intisa->slots[slot_id].get_field_fns[intop->field_id];
1093  xtensa_set_field_fn set_fn =
1094  intisa->slots[slot_id].set_field_fns[intop->field_id];
1095 
1096  if (get_fn && set_fn)
1097  {
1098  (*set_fn) (tmpbuf, *valp);
1099  return ((*get_fn) (tmpbuf) != *valp);
1100  }
1101  }
1102 
1103  /* Couldn't find any slot containing the field.... */
1105  strcpy (xtisa_error_msg, "field does not exist in any slot");
1106  return -1;
1107  }
1108 
1109  /* Encode the value. In some cases, the encoding function may detect
1110  errors, but most of the time the only way to determine if the value
1111  was successfully encoded is to decode it and check if it matches
1112  the original value. */
1113  orig_val = *valp;
1114  if ((*intop->encode) (valp)
1115  || (test_val = *valp, (*intop->decode) (&test_val))
1116  || test_val != orig_val)
1117  {
1119  sprintf (xtisa_error_msg, "cannot encode operand value 0x%08x", *valp);
1120  return -1;
1121  }
1122 
1123  return 0;
1124 }
xtensa_set_field_fn * set_field_fns
xtensa_get_field_fn * get_field_fns
void(* xtensa_set_field_fn)(xtensa_insnbuf, uint32)
uint32(* xtensa_get_field_fn)(const xtensa_insnbuf)
xtensa_insnbuf xtensa_insnbuf_alloc(xtensa_isa isa)
Definition: xtensa-isa.c:88
@ xtensa_isa_no_field
Definition: xtensa-isa.h:163
#define uint32
Definition: xtensa-isa.h:39

References CHECK_ALLOC, xtensa_operand_internal_struct::decode, xtensa_operand_internal_struct::encode, xtensa_operand_internal_struct::field_id, xtensa_slot_internal_struct::get_field_fns, get_operand(), xtensa_isa_internal_struct::num_slots, opc, xtensa_slot_internal_struct::set_field_fns, xtensa_isa_internal_struct::slots, sprintf, uint32, xtensa_insnbuf_alloc(), xtensa_isa_bad_value, xtensa_isa_internal_error, xtensa_isa_no_field, XTENSA_UNDEFINED, xtisa_errno, and xtisa_error_msg.

◆ xtensa_operand_get_field()

int xtensa_operand_get_field ( xtensa_isa  isa,
xtensa_opcode  opc,
int  opnd,
xtensa_format  fmt,
int  slot,
const xtensa_insnbuf  slotbuf,
uint32 valp 
)

Definition at line 975 of file xtensa-isa.c.

978 {
979  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
981  int slot_id;
982  xtensa_get_field_fn get_fn;
983 
984  intop = get_operand (intisa, opc, opnd);
985  if (!intop) {
986  return -1;
987  }
988 
989  CHECK_FORMAT (intisa, fmt, -1);
990  CHECK_SLOT (intisa, fmt, slot, -1);
991 
992  slot_id = intisa->formats[fmt].slot_id[slot];
993  if (intop->field_id == XTENSA_UNDEFINED)
994  {
996  strcpy (xtisa_error_msg, "implicit operand has no field");
997  return -1;
998  }
999  get_fn = intisa->slots[slot_id].get_field_fns[intop->field_id];
1000  if (!get_fn)
1001  {
1004  "operand \"%s\" does not exist in slot %d of format \"%s\"",
1005  intop->name, slot, intisa->formats[fmt].name);
1006  return -1;
1007  }
1008  *valp = (*get_fn) (slotbuf);
1009  return 0;
1010 }

References CHECK_FORMAT, CHECK_SLOT, xtensa_operand_internal_struct::field_id, xtensa_isa_internal_struct::formats, xtensa_slot_internal_struct::get_field_fns, get_operand(), xtensa_format_internal_struct::name, xtensa_operand_internal_struct::name, opc, xtensa_format_internal_struct::slot_id, xtensa_isa_internal_struct::slots, sprintf, xtensa_isa_no_field, xtensa_isa_wrong_slot, XTENSA_UNDEFINED, xtisa_errno, and xtisa_error_msg.

Referenced by esil_abs_neg(), esil_add_imm(), esil_add_sub(), esil_bitwise_op(), esil_branch_check_bit(), esil_branch_check_bit_imm(), esil_branch_check_mask(), esil_branch_compare(), esil_branch_compare_imm(), esil_branch_compare_single(), esil_call(), esil_callx(), esil_extract_unsigned(), esil_load_imm(), esil_load_relative(), esil_move(), esil_move_conditional(), esil_move_imm(), esil_set_shift_amount(), esil_set_shift_amount_imm(), esil_shift_logic_imm(), esil_shift_logic_sar(), esil_store_imm(), print_insn_xtensa(), and xtensa_check_stack_op().

◆ xtensa_operand_inout()

char xtensa_operand_inout ( xtensa_isa  isa,
xtensa_opcode  opc,
int  opnd 
)

Definition at line 952 of file xtensa-isa.c.

953 {
954  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
955  xtensa_iclass_internal *iclass;
956  int iclass_id;
957  char inout;
958 
959  CHECK_OPCODE (intisa, opc, 0);
960  iclass_id = intisa->opcodes[opc].iclass_id;
961  iclass = &intisa->iclasses[iclass_id];
962  CHECK_OPERAND (intisa, opc, iclass, opnd, 0);
963  inout = iclass->operands[opnd].inout;
964 
965  /* Special case for "sout" operands. */
966  if (inout == 's') {
967  return 'o';
968  }
969 
970  return inout;
971 }

References CHECK_OPCODE, CHECK_OPERAND, xtensa_opcode_internal_struct::iclass_id, xtensa_isa_internal_struct::iclasses, xtensa_arg_internal_struct::inout, opc, xtensa_isa_internal_struct::opcodes, and xtensa_iclass_internal_struct::operands.

◆ xtensa_operand_is_known_reg()

int xtensa_operand_is_known_reg ( xtensa_isa  isa,
xtensa_opcode  opc,
int  opnd 
)

Definition at line 1203 of file xtensa-isa.c.

1204 {
1205  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1206  xtensa_operand_internal *intop;
1207 
1208  intop = get_operand (intisa, opc, opnd);
1209  if (!intop) {
1210  return XTENSA_UNDEFINED;
1211  }
1212 
1213  if ((intop->flags & XTENSA_OPERAND_IS_UNKNOWN) == 0) {
1214  return 1;
1215  }
1216  return 0;
1217 }
#define XTENSA_OPERAND_IS_UNKNOWN

References xtensa_operand_internal_struct::flags, get_operand(), opc, XTENSA_OPERAND_IS_UNKNOWN, and XTENSA_UNDEFINED.

◆ xtensa_operand_is_PCrelative()

int xtensa_operand_is_PCrelative ( xtensa_isa  isa,
xtensa_opcode  opc,
int  opnd 
)

Definition at line 1221 of file xtensa-isa.c.

1222 {
1223  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1224  xtensa_operand_internal *intop;
1225 
1226  intop = get_operand (intisa, opc, opnd);
1227  if (!intop) {
1228  return XTENSA_UNDEFINED;
1229  }
1230 
1231  if ((intop->flags & XTENSA_OPERAND_IS_PCRELATIVE) != 0) {
1232  return 1;
1233  }
1234  return 0;
1235 }

References xtensa_operand_internal_struct::flags, get_operand(), opc, XTENSA_OPERAND_IS_PCRELATIVE, and XTENSA_UNDEFINED.

Referenced by print_xtensa_operand().

◆ xtensa_operand_is_register()

int xtensa_operand_is_register ( xtensa_isa  isa,
xtensa_opcode  opc,
int  opnd 
)

Definition at line 1155 of file xtensa-isa.c.

1156 {
1157  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1158  xtensa_operand_internal *intop;
1159 
1160  intop = get_operand (intisa, opc, opnd);
1161  if (!intop) {
1162  return XTENSA_UNDEFINED;
1163  }
1164 
1165  if ((intop->flags & XTENSA_OPERAND_IS_REGISTER) != 0) {
1166  return 1;
1167  }
1168  return 0;
1169 }
#define XTENSA_OPERAND_IS_REGISTER

References xtensa_operand_internal_struct::flags, get_operand(), opc, XTENSA_OPERAND_IS_REGISTER, and XTENSA_UNDEFINED.

Referenced by print_xtensa_operand().

◆ xtensa_operand_is_visible()

int xtensa_operand_is_visible ( xtensa_isa  isa,
xtensa_opcode  opc,
int  opnd 
)

Definition at line 924 of file xtensa-isa.c.

925 {
926  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
927  xtensa_iclass_internal *iclass;
928  int iclass_id, operand_id;
930 
931  CHECK_OPCODE (intisa, opc, XTENSA_UNDEFINED);
932  iclass_id = intisa->opcodes[opc].iclass_id;
933  iclass = &intisa->iclasses[iclass_id];
934  CHECK_OPERAND (intisa, opc, iclass, opnd, XTENSA_UNDEFINED);
935 
936  /* Special case for "sout" operands. */
937  if (iclass->operands[opnd].inout == 's') {
938  return 0;
939  }
940 
941  operand_id = iclass->operands[opnd].u.operand_id;
942  intop = &intisa->operands[operand_id];
943 
944  if ((intop->flags & XTENSA_OPERAND_IS_INVISIBLE) == 0) {
945  return 1;
946  }
947  return 0;
948 }
#define XTENSA_OPERAND_IS_INVISIBLE

References CHECK_OPCODE, CHECK_OPERAND, xtensa_operand_internal_struct::flags, xtensa_opcode_internal_struct::iclass_id, xtensa_isa_internal_struct::iclasses, xtensa_arg_internal_struct::inout, opc, xtensa_isa_internal_struct::opcodes, xtensa_arg_internal_struct::operand_id, xtensa_iclass_internal_struct::operands, xtensa_isa_internal_struct::operands, xtensa_arg_internal_struct::u, XTENSA_OPERAND_IS_INVISIBLE, and XTENSA_UNDEFINED.

Referenced by print_insn_xtensa().

◆ xtensa_operand_name()

const char* xtensa_operand_name ( xtensa_isa  isa,
xtensa_opcode  opc,
int  opnd 
)

Definition at line 910 of file xtensa-isa.c.

911 {
912  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
914 
915  intop = get_operand (intisa, opc, opnd);
916  if (!intop) {
917  return NULL;
918  }
919  return intop->name;
920 }

References get_operand(), xtensa_operand_internal_struct::name, NULL, and opc.

◆ xtensa_operand_num_regs()

int xtensa_operand_num_regs ( xtensa_isa  isa,
xtensa_opcode  opc,
int  opnd 
)

Definition at line 1188 of file xtensa-isa.c.

1189 {
1190  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1191  xtensa_operand_internal *intop;
1192 
1193  intop = get_operand (intisa, opc, opnd);
1194  if (!intop) {
1195  return XTENSA_UNDEFINED;
1196  }
1197 
1198  return intop->num_regs;
1199 }

References get_operand(), xtensa_operand_internal_struct::num_regs, opc, and XTENSA_UNDEFINED.

Referenced by print_xtensa_operand().

◆ xtensa_operand_regfile()

◆ xtensa_operand_set_field()

int xtensa_operand_set_field ( xtensa_isa  isa,
xtensa_opcode  opc,
int  opnd,
xtensa_format  fmt,
int  slot,
xtensa_insnbuf  slotbuf,
uint32  val 
)

Definition at line 1014 of file xtensa-isa.c.

1017 {
1018  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1019  xtensa_operand_internal *intop;
1020  int slot_id;
1021  xtensa_set_field_fn set_fn;
1022 
1023  intop = get_operand (intisa, opc, opnd);
1024  if (!intop) {
1025  return -1;
1026  }
1027 
1028  CHECK_FORMAT (intisa, fmt, -1);
1029  CHECK_SLOT (intisa, fmt, slot, -1);
1030 
1031  slot_id = intisa->formats[fmt].slot_id[slot];
1032  if (intop->field_id == XTENSA_UNDEFINED)
1033  {
1035  strcpy (xtisa_error_msg, "implicit operand has no field");
1036  return -1;
1037  }
1038  set_fn = intisa->slots[slot_id].set_field_fns[intop->field_id];
1039  if (!set_fn)
1040  {
1043  "operand \"%s\" does not exist in slot %d of format \"%s\"",
1044  intop->name, slot, intisa->formats[fmt].name);
1045  return -1;
1046  }
1047  (*set_fn) (slotbuf, val);
1048  return 0;
1049 }
ut16 val
Definition: armass64_const.h:6

References CHECK_FORMAT, CHECK_SLOT, xtensa_operand_internal_struct::field_id, xtensa_isa_internal_struct::formats, get_operand(), xtensa_format_internal_struct::name, xtensa_operand_internal_struct::name, opc, xtensa_slot_internal_struct::set_field_fns, xtensa_format_internal_struct::slot_id, xtensa_isa_internal_struct::slots, sprintf, val, xtensa_isa_no_field, xtensa_isa_wrong_slot, XTENSA_UNDEFINED, xtisa_errno, and xtisa_error_msg.

◆ xtensa_operand_undo_reloc()

int xtensa_operand_undo_reloc ( xtensa_isa  isa,
xtensa_opcode  opc,
int  opnd,
uint32 valp,
uint32  pc 
)

Definition at line 1274 of file xtensa-isa.c.

1276 {
1277  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1278  xtensa_operand_internal *intop;
1279 
1280  intop = get_operand (intisa, opc, opnd);
1281  if (!intop) {
1282  return -1;
1283  }
1284 
1285  if ((intop->flags & XTENSA_OPERAND_IS_PCRELATIVE) == 0) {
1286  return 0;
1287  }
1288 
1289  if (!intop->undo_reloc)
1290  {
1292  strcpy (xtisa_error_msg, "operand missing undo_reloc function");
1293  return -1;
1294  }
1295 
1296  if ((*intop->undo_reloc) (valp, pc))
1297  {
1300  "undo_reloc failed for value 0x%08x at PC 0x%08x", *valp, pc);
1301  return -1;
1302  }
1303 
1304  return 0;
1305 }

References xtensa_operand_internal_struct::flags, get_operand(), opc, pc, sprintf, xtensa_operand_internal_struct::undo_reloc, xtensa_isa_bad_value, xtensa_isa_internal_error, XTENSA_OPERAND_IS_PCRELATIVE, xtisa_errno, and xtisa_error_msg.

Referenced by print_xtensa_operand().

◆ xtensa_regfile_lookup()

xtensa_regfile xtensa_regfile_lookup ( xtensa_isa  isa,
const char *  name 
)

Definition at line 1405 of file xtensa-isa.c.

1406 {
1407  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1408  int n;
1409 
1410  if (!name || !*name)
1411  {
1413  strcpy (xtisa_error_msg, "invalid regfile name");
1414  return XTENSA_UNDEFINED;
1415  }
1416 
1417  /* The expected number of regfiles is small; use a linear search. */
1418  for (n = 0; n < intisa->num_regfiles; n++)
1419  {
1420  if (!filename_cmp (intisa->regfiles[n].name, name)) {
1421  return n;
1422  }
1423  }
1424 
1426  sprintf (xtisa_error_msg, "regfile \"%s\" not recognized", name);
1427  return XTENSA_UNDEFINED;
1428 }
xtensa_regfile_internal * regfiles
int filename_cmp(const char *s1, const char *s2)
Definition: elf32-xtensa.c:151

References filename_cmp(), n, xtensa_regfile_internal_struct::name, xtensa_isa_internal_struct::num_regfiles, xtensa_isa_internal_struct::regfiles, sprintf, xtensa_isa_bad_regfile, XTENSA_UNDEFINED, xtisa_errno, and xtisa_error_msg.

◆ xtensa_regfile_lookup_shortname()

xtensa_regfile xtensa_regfile_lookup_shortname ( xtensa_isa  isa,
const char *  shortname 
)

Definition at line 1432 of file xtensa-isa.c.

1433 {
1434  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1435  int n;
1436 
1437  if (!shortname || !*shortname)
1438  {
1440  strcpy (xtisa_error_msg, "invalid regfile shortname");
1441  return XTENSA_UNDEFINED;
1442  }
1443 
1444  /* The expected number of regfiles is small; use a linear search. */
1445  for (n = 0; n < intisa->num_regfiles; n++)
1446  {
1447  /* Ignore regfile views since they always have the same shortnames
1448  as their parents. */
1449  if (intisa->regfiles[n].parent != n) {
1450  continue;
1451  }
1452  if (!filename_cmp (intisa->regfiles[n].shortname, shortname)) {
1453  return n;
1454  }
1455  }
1456 
1458  sprintf (xtisa_error_msg, "regfile shortname \"%s\" not recognized",
1459  shortname);
1460  return XTENSA_UNDEFINED;
1461 }

References filename_cmp(), n, xtensa_isa_internal_struct::num_regfiles, xtensa_regfile_internal_struct::parent, xtensa_isa_internal_struct::regfiles, xtensa_regfile_internal_struct::shortname, sprintf, xtensa_isa_bad_regfile, XTENSA_UNDEFINED, xtisa_errno, and xtisa_error_msg.

◆ xtensa_regfile_name()

const char* xtensa_regfile_name ( xtensa_isa  isa,
xtensa_regfile  rf 
)

Definition at line 1465 of file xtensa-isa.c.

1466 {
1467  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1468  CHECK_REGFILE (intisa, rf, NULL);
1469  return intisa->regfiles[rf].name;
1470 }
#define CHECK_REGFILE(INTISA, RF, ERRVAL)
Definition: xtensa-isa.c:1393

References CHECK_REGFILE, xtensa_regfile_internal_struct::name, NULL, and xtensa_isa_internal_struct::regfiles.

◆ xtensa_regfile_num_bits()

int xtensa_regfile_num_bits ( xtensa_isa  isa,
xtensa_regfile  rf 
)

◆ xtensa_regfile_num_entries()

int xtensa_regfile_num_entries ( xtensa_isa  isa,
xtensa_regfile  rf 
)

◆ xtensa_regfile_shortname()

◆ xtensa_regfile_view_parent()

xtensa_regfile xtensa_regfile_view_parent ( xtensa_isa  isa,
xtensa_regfile  rf 
)

Definition at line 1483 of file xtensa-isa.c.

1484 {
1485  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1486  CHECK_REGFILE (intisa, rf, XTENSA_UNDEFINED);
1487  return intisa->regfiles[rf].parent;
1488 }

References CHECK_REGFILE, xtensa_regfile_internal_struct::parent, xtensa_isa_internal_struct::regfiles, and XTENSA_UNDEFINED.

◆ xtensa_state_is_exported()

int xtensa_state_is_exported ( xtensa_isa  isa,
xtensa_state  st 
)

Definition at line 1574 of file xtensa-isa.c.

1575 {
1576  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1577  CHECK_STATE (intisa, st, XTENSA_UNDEFINED);
1578  if ((intisa->states[st].flags & XTENSA_STATE_IS_EXPORTED) != 0) {
1579  return 1;
1580  }
1581  return 0;
1582 }
#define XTENSA_STATE_IS_EXPORTED
#define CHECK_STATE(INTISA, ST, ERRVAL)
Definition: xtensa-isa.c:1513

References CHECK_STATE, xtensa_state_internal_struct::flags, xtensa_isa_internal_struct::states, XTENSA_STATE_IS_EXPORTED, and XTENSA_UNDEFINED.

◆ xtensa_state_is_shared_or()

int xtensa_state_is_shared_or ( xtensa_isa  isa,
xtensa_state  st 
)

Definition at line 1586 of file xtensa-isa.c.

1587 {
1588  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1589  CHECK_STATE (intisa, st, XTENSA_UNDEFINED);
1590  if ((intisa->states[st].flags & XTENSA_STATE_IS_SHARED_OR) != 0) {
1591  return 1;
1592  }
1593  return 0;
1594 }
#define XTENSA_STATE_IS_SHARED_OR

References CHECK_STATE, xtensa_state_internal_struct::flags, xtensa_isa_internal_struct::states, XTENSA_STATE_IS_SHARED_OR, and XTENSA_UNDEFINED.

◆ xtensa_state_lookup()

xtensa_state xtensa_state_lookup ( xtensa_isa  isa,
const char *  name 
)

Definition at line 1525 of file xtensa-isa.c.

1526 {
1527  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1528  xtensa_lookup_entry entry, *result = 0;
1529 
1530  if (!name || !*name)
1531  {
1533  strcpy (xtisa_error_msg, "invalid state name");
1534  return XTENSA_UNDEFINED;
1535  }
1536 
1537  if (intisa->num_states != 0)
1538  {
1539  entry.key = name;
1540  result = bsearch (&entry, intisa->state_lookup_table, intisa->num_states,
1542  }
1543 
1544  if (!result)
1545  {
1547  sprintf (xtisa_error_msg, "state \"%s\" not recognized", name);
1548  return XTENSA_UNDEFINED;
1549  }
1550 
1551  return result->u.state;
1552 }
const char * name
Definition: op.c:541

References name, xtensa_isa_internal_struct::num_states, sprintf, xtensa_lookup_entry_struct::state, xtensa_isa_internal_struct::state_lookup_table, xtensa_lookup_entry_struct::u, xtensa_isa_bad_state, xtensa_isa_name_compare(), XTENSA_UNDEFINED, xtisa_errno, and xtisa_error_msg.

◆ xtensa_state_name()

const char* xtensa_state_name ( xtensa_isa  isa,
xtensa_state  st 
)

Definition at line 1556 of file xtensa-isa.c.

1557 {
1558  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1559  CHECK_STATE (intisa, st, NULL);
1560  return intisa->states[st].name;
1561 }

References CHECK_STATE, xtensa_state_internal_struct::name, NULL, and xtensa_isa_internal_struct::states.

◆ xtensa_state_num_bits()

int xtensa_state_num_bits ( xtensa_isa  isa,
xtensa_state  st 
)

Definition at line 1565 of file xtensa-isa.c.

1566 {
1567  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1568  CHECK_STATE (intisa, st, XTENSA_UNDEFINED);
1569  return intisa->states[st].num_bits;
1570 }

References CHECK_STATE, xtensa_state_internal_struct::num_bits, xtensa_isa_internal_struct::states, and XTENSA_UNDEFINED.

◆ xtensa_stateOperand_inout()

char xtensa_stateOperand_inout ( xtensa_isa  isa,
xtensa_opcode  opc,
int  stOp 
)

Definition at line 1341 of file xtensa-isa.c.

1342 {
1343  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1344  xtensa_iclass_internal *iclass;
1345  int iclass_id;
1346 
1347  CHECK_OPCODE (intisa, opc, 0);
1348  iclass_id = intisa->opcodes[opc].iclass_id;
1349  iclass = &intisa->iclasses[iclass_id];
1350  CHECK_STATE_OPERAND (intisa, opc, iclass, stOp, 0);
1351  return iclass->stateOperands[stOp].inout;
1352 }
xtensa_arg_internal * stateOperands
#define CHECK_STATE_OPERAND(INTISA, OPC, ICLASS, STOP, ERRVAL)
Definition: xtensa-isa.c:1312

References CHECK_OPCODE, CHECK_STATE_OPERAND, xtensa_opcode_internal_struct::iclass_id, xtensa_isa_internal_struct::iclasses, xtensa_arg_internal_struct::inout, opc, xtensa_isa_internal_struct::opcodes, and xtensa_iclass_internal_struct::stateOperands.

◆ xtensa_stateOperand_state()

xtensa_state xtensa_stateOperand_state ( xtensa_isa  isa,
xtensa_opcode  opc,
int  stOp 
)

Definition at line 1326 of file xtensa-isa.c.

1327 {
1328  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1329  xtensa_iclass_internal *iclass;
1330  int iclass_id;
1331 
1332  CHECK_OPCODE (intisa, opc, XTENSA_UNDEFINED);
1333  iclass_id = intisa->opcodes[opc].iclass_id;
1334  iclass = &intisa->iclasses[iclass_id];
1335  CHECK_STATE_OPERAND (intisa, opc, iclass, stOp, XTENSA_UNDEFINED);
1336  return iclass->stateOperands[stOp].u.state;
1337 }

References CHECK_OPCODE, CHECK_STATE_OPERAND, xtensa_opcode_internal_struct::iclass_id, xtensa_isa_internal_struct::iclasses, opc, xtensa_isa_internal_struct::opcodes, xtensa_arg_internal_struct::state, xtensa_iclass_internal_struct::stateOperands, xtensa_arg_internal_struct::u, and XTENSA_UNDEFINED.

◆ xtensa_sysreg_is_user()

int xtensa_sysreg_is_user ( xtensa_isa  isa,
xtensa_sysreg  sysreg 
)

Definition at line 1684 of file xtensa-isa.c.

1685 {
1686  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1687  CHECK_SYSREG (intisa, sysreg, XTENSA_UNDEFINED);
1688  if (intisa->sysregs[sysreg].is_user) {
1689  return 1;
1690  }
1691  return 0;
1692 }
#define CHECK_SYSREG(INTISA, SYSREG, ERRVAL)
Definition: xtensa-isa.c:1601

References CHECK_SYSREG, xtensa_sysreg_internal_struct::is_user, xtensa_isa_internal_struct::sysregs, and XTENSA_UNDEFINED.

◆ xtensa_sysreg_lookup()

xtensa_sysreg xtensa_sysreg_lookup ( xtensa_isa  isa,
int  num,
int  is_user 
)

Definition at line 1613 of file xtensa-isa.c.

1614 {
1615  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1616 
1617  if (is_user != 0) {
1618  is_user = 1;
1619  }
1620 
1621  if (num < 0 || num > intisa->max_sysreg_num[is_user]
1622  || intisa->sysreg_table[is_user][num] == XTENSA_UNDEFINED)
1623  {
1625  strcpy (xtisa_error_msg, "sysreg not recognized");
1626  return XTENSA_UNDEFINED;
1627  }
1628 
1629  return intisa->sysreg_table[is_user][num];
1630 }
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
Definition: sflib.h:126

References xtensa_isa_internal_struct::max_sysreg_num, num, xtensa_isa_internal_struct::sysreg_table, xtensa_isa_bad_sysreg, XTENSA_UNDEFINED, xtisa_errno, and xtisa_error_msg.

◆ xtensa_sysreg_lookup_name()

xtensa_sysreg xtensa_sysreg_lookup_name ( xtensa_isa  isa,
const char *  name 
)

Definition at line 1634 of file xtensa-isa.c.

1635 {
1636  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1637  xtensa_lookup_entry entry, *result = 0;
1638 
1639  if (!name || !*name)
1640  {
1642  strcpy (xtisa_error_msg, "invalid sysreg name");
1643  return XTENSA_UNDEFINED;
1644  }
1645 
1646  if (intisa->num_sysregs != 0)
1647  {
1648  entry.key = name;
1649  result = bsearch (&entry, intisa->sysreg_lookup_table,
1650  intisa->num_sysregs, sizeof (xtensa_lookup_entry),
1652  }
1653 
1654  if (!result)
1655  {
1657  sprintf (xtisa_error_msg, "sysreg \"%s\" not recognized", name);
1658  return XTENSA_UNDEFINED;
1659  }
1660 
1661  return result->u.sysreg;
1662 }

References name, xtensa_isa_internal_struct::num_sysregs, sprintf, xtensa_lookup_entry_struct::sysreg, xtensa_isa_internal_struct::sysreg_lookup_table, xtensa_lookup_entry_struct::u, xtensa_isa_bad_sysreg, xtensa_isa_name_compare(), XTENSA_UNDEFINED, xtisa_errno, and xtisa_error_msg.

◆ xtensa_sysreg_name()

const char* xtensa_sysreg_name ( xtensa_isa  isa,
xtensa_sysreg  sysreg 
)

Definition at line 1666 of file xtensa-isa.c.

1667 {
1668  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1669  CHECK_SYSREG (intisa, sysreg, NULL);
1670  return intisa->sysregs[sysreg].name;
1671 }

References CHECK_SYSREG, xtensa_sysreg_internal_struct::name, NULL, and xtensa_isa_internal_struct::sysregs.

◆ xtensa_sysreg_number()

int xtensa_sysreg_number ( xtensa_isa  isa,
xtensa_sysreg  sysreg 
)

Definition at line 1675 of file xtensa-isa.c.

1676 {
1677  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
1678  CHECK_SYSREG (intisa, sysreg, XTENSA_UNDEFINED);
1679  return intisa->sysregs[sysreg].number;
1680 }

References CHECK_SYSREG, xtensa_sysreg_internal_struct::number, xtensa_isa_internal_struct::sysregs, and XTENSA_UNDEFINED.

Variable Documentation

◆ xtensa_modules

xtensa_isa_internal xtensa_modules
extern

Definition at line 21455 of file xtensa-modules.c.

Referenced by xtensa_isa_init().

◆ xtisa_errno

◆ xtisa_error_msg