Rizin
unix-like reverse engineering framework and cli tools
sparc.h File Reference
#include "ansidecl.h"

Go to the source code of this file.

Classes

struct  sparc_opcode_arch
 
struct  sparc_opcode
 

Macros

#define SPARC_OPCODE_ARCH_MAX   (SPARC_OPCODE_ARCH_BAD - 1)
 
#define SPARC_OPCODE_ARCH_MASK(arch)   (1 << (arch))
 
#define SPARC_OPCODE_ARCH_V9_P(arch)   ((arch) >= SPARC_OPCODE_ARCH_V9)
 
#define SPARC_OPCODE_SUPPORTED(ARCH)   (sparc_opcode_archs[ARCH].supported)
 
#define SPARC_OPCODE_CONFLICT_P(ARCH1, ARCH2)    (((SPARC_OPCODE_SUPPORTED(ARCH1) & SPARC_OPCODE_SUPPORTED(ARCH2)) != SPARC_OPCODE_SUPPORTED(ARCH1)) && ((SPARC_OPCODE_SUPPORTED(ARCH1) & SPARC_OPCODE_SUPPORTED(ARCH2)) != SPARC_OPCODE_SUPPORTED(ARCH2)))
 
#define F_DELAYED   1 /* Delayed branch. */
 
#define F_ALIAS   2 /* Alias for a "real" instruction. */
 
#define F_UNBR   4 /* Unconditional branch. */
 
#define F_CONDBR   8 /* Conditional branch. */
 
#define F_JSR   16 /* Subroutine call. */
 
#define F_FLOAT   32 /* Floating point instruction (not a branch). */
 
#define F_FBR   64 /* Floating point branch. */
 
#define OP2(x)   (((x)&0x7) << 22) /* Op2 field of format2 insns. */
 
#define OP3(x)   (((x)&0x3f) << 19) /* Op3 field of format3 insns. */
 
#define OP(x)   ((unsigned)((x)&0x3) << 30) /* Op field of all insns. */
 
#define OPF(x)   (((x)&0x1ff) << 5) /* Opf field of float insns. */
 
#define OPF_LOW5(x)   OPF((x)&0x1f) /* V9. */
 
#define F3F(x, y, z)   (OP(x) | OP3(y) | OPF(z)) /* Format3 float insns. */
 
#define F3I(x)   (((x)&0x1) << 13) /* Immediate field of format 3 insns. */
 
#define F2(x, y)   (OP(x) | OP2(y)) /* Format 2 insns. */
 
#define F3(x, y, z)   (OP(x) | OP3(y) | F3I(z)) /* Format3 insns. */
 
#define F1(x)   (OP(x))
 
#define DISP30(x)   ((x)&0x3fffffff)
 
#define ASI(x)   (((x)&0xff) << 5) /* Asi field of format3 insns. */
 
#define RS2(x)   ((x)&0x1f) /* Rs2 field. */
 
#define SIMM13(x)   ((x)&0x1fff) /* Simm13 field. */
 
#define RD(x)   (((x)&0x1f) << 25) /* Destination register field. */
 
#define RS1(x)   (((x)&0x1f) << 14) /* Rs1 field. */
 
#define ASI_RS2(x)   (SIMM13(x))
 
#define MEMBAR(x)   ((x)&0x7f)
 
#define SLCPOP(x)   (((x)&0x7f) << 6) /* Sparclet cpop. */
 
#define ANNUL   (1 << 29)
 
#define BPRED   (1 << 19) /* V9. */
 
#define IMMED   F3I(1)
 
#define RD_G0   RD(~0)
 
#define RS1_G0   RS1(~0)
 
#define RS2_G0   RS2(~0)
 

Typedefs

typedef struct sparc_opcode_arch sparc_opcode_arch
 
typedef struct sparc_opcode sparc_opcode
 

Enumerations

enum  sparc_opcode_arch_val {
  SPARC_OPCODE_ARCH_V6 = 0 , SPARC_OPCODE_ARCH_V7 , SPARC_OPCODE_ARCH_V8 , SPARC_OPCODE_ARCH_SPARCLET ,
  SPARC_OPCODE_ARCH_SPARCLITE , SPARC_OPCODE_ARCH_V9 , SPARC_OPCODE_ARCH_V9A , SPARC_OPCODE_ARCH_V9B ,
  SPARC_OPCODE_ARCH_BAD
}
 

Functions

enum sparc_opcode_arch_val sparc_opcode_lookup_arch (const char *)
 
int sparc_encode_asi (const char *)
 
const char * sparc_decode_asi (int)
 
int sparc_encode_membar (const char *)
 
const char * sparc_decode_membar (int)
 
int sparc_encode_prefetch (const char *)
 
const char * sparc_decode_prefetch (int)
 
int sparc_encode_sparclet_cpreg (const char *)
 
const char * sparc_decode_sparclet_cpreg (int)
 

Variables

const struct sparc_opcode_arch sparc_opcode_archs []
 
const struct sparc_opcode sparc_opcodes []
 
const int sparc_num_opcodes
 

Macro Definition Documentation

◆ ANNUL

#define ANNUL   (1 << 29)

Definition at line 211 of file sparc.h.

◆ ASI

#define ASI (   x)    (((x)&0xff) << 5) /* Asi field of format3 insns. */

Definition at line 202 of file sparc.h.

◆ ASI_RS2

#define ASI_RS2 (   x)    (SIMM13(x))

Definition at line 207 of file sparc.h.

◆ BPRED

#define BPRED   (1 << 19) /* V9. */

Definition at line 212 of file sparc.h.

◆ DISP30

#define DISP30 (   x)    ((x)&0x3fffffff)

Definition at line 201 of file sparc.h.

◆ F1

#define F1 (   x)    (OP(x))

Definition at line 200 of file sparc.h.

◆ F2

#define F2 (   x,
 
)    (OP(x) | OP2(y)) /* Format 2 insns. */

Definition at line 198 of file sparc.h.

◆ F3

#define F3 (   x,
  y,
 
)    (OP(x) | OP3(y) | F3I(z)) /* Format3 insns. */

Definition at line 199 of file sparc.h.

◆ F3F

#define F3F (   x,
  y,
 
)    (OP(x) | OP3(y) | OPF(z)) /* Format3 float insns. */

Definition at line 196 of file sparc.h.

◆ F3I

#define F3I (   x)    (((x)&0x1) << 13) /* Immediate field of format 3 insns. */

Definition at line 197 of file sparc.h.

◆ F_ALIAS

#define F_ALIAS   2 /* Alias for a "real" instruction. */

Definition at line 103 of file sparc.h.

◆ F_CONDBR

#define F_CONDBR   8 /* Conditional branch. */

Definition at line 105 of file sparc.h.

◆ F_DELAYED

#define F_DELAYED   1 /* Delayed branch. */

Definition at line 102 of file sparc.h.

◆ F_FBR

#define F_FBR   64 /* Floating point branch. */

Definition at line 108 of file sparc.h.

◆ F_FLOAT

#define F_FLOAT   32 /* Floating point instruction (not a branch). */

Definition at line 107 of file sparc.h.

◆ F_JSR

#define F_JSR   16 /* Subroutine call. */

Definition at line 106 of file sparc.h.

◆ F_UNBR

#define F_UNBR   4 /* Unconditional branch. */

Definition at line 104 of file sparc.h.

◆ IMMED

#define IMMED   F3I(1)

Definition at line 213 of file sparc.h.

◆ MEMBAR

#define MEMBAR (   x)    ((x)&0x7f)

Definition at line 208 of file sparc.h.

◆ OP

#define OP (   x)    ((unsigned)((x)&0x3) << 30) /* Op field of all insns. */

Definition at line 193 of file sparc.h.

◆ OP2

#define OP2 (   x)    (((x)&0x7) << 22) /* Op2 field of format2 insns. */

Definition at line 191 of file sparc.h.

◆ OP3

#define OP3 (   x)    (((x)&0x3f) << 19) /* Op3 field of format3 insns. */

Definition at line 192 of file sparc.h.

◆ OPF

#define OPF (   x)    (((x)&0x1ff) << 5) /* Opf field of float insns. */

Definition at line 194 of file sparc.h.

◆ OPF_LOW5

#define OPF_LOW5 (   x)    OPF((x)&0x1f) /* V9. */

Definition at line 195 of file sparc.h.

◆ RD

#define RD (   x)    (((x)&0x1f) << 25) /* Destination register field. */

Definition at line 205 of file sparc.h.

◆ RD_G0

#define RD_G0   RD(~0)

Definition at line 214 of file sparc.h.

◆ RS1

#define RS1 (   x)    (((x)&0x1f) << 14) /* Rs1 field. */

Definition at line 206 of file sparc.h.

◆ RS1_G0

#define RS1_G0   RS1(~0)

Definition at line 215 of file sparc.h.

◆ RS2

#define RS2 (   x)    ((x)&0x1f) /* Rs2 field. */

Definition at line 203 of file sparc.h.

◆ RS2_G0

#define RS2_G0   RS2(~0)

Definition at line 216 of file sparc.h.

◆ SIMM13

#define SIMM13 (   x)    ((x)&0x1fff) /* Simm13 field. */

Definition at line 204 of file sparc.h.

◆ SLCPOP

#define SLCPOP (   x)    (((x)&0x7f) << 6) /* Sparclet cpop. */

Definition at line 209 of file sparc.h.

◆ SPARC_OPCODE_ARCH_MASK

#define SPARC_OPCODE_ARCH_MASK (   arch)    (1 << (arch))

Definition at line 61 of file sparc.h.

◆ SPARC_OPCODE_ARCH_MAX

#define SPARC_OPCODE_ARCH_MAX   (SPARC_OPCODE_ARCH_BAD - 1)

Definition at line 57 of file sparc.h.

◆ SPARC_OPCODE_ARCH_V9_P

#define SPARC_OPCODE_ARCH_V9_P (   arch)    ((arch) >= SPARC_OPCODE_ARCH_V9)

Definition at line 64 of file sparc.h.

◆ SPARC_OPCODE_CONFLICT_P

#define SPARC_OPCODE_CONFLICT_P (   ARCH1,
  ARCH2 
)     (((SPARC_OPCODE_SUPPORTED(ARCH1) & SPARC_OPCODE_SUPPORTED(ARCH2)) != SPARC_OPCODE_SUPPORTED(ARCH1)) && ((SPARC_OPCODE_SUPPORTED(ARCH1) & SPARC_OPCODE_SUPPORTED(ARCH2)) != SPARC_OPCODE_SUPPORTED(ARCH2)))

Definition at line 87 of file sparc.h.

◆ SPARC_OPCODE_SUPPORTED

#define SPARC_OPCODE_SUPPORTED (   ARCH)    (sparc_opcode_archs[ARCH].supported)

Definition at line 83 of file sparc.h.

Typedef Documentation

◆ sparc_opcode

typedef struct sparc_opcode sparc_opcode

◆ sparc_opcode_arch

Enumeration Type Documentation

◆ sparc_opcode_arch_val

Enumerator
SPARC_OPCODE_ARCH_V6 
SPARC_OPCODE_ARCH_V7 
SPARC_OPCODE_ARCH_V8 
SPARC_OPCODE_ARCH_SPARCLET 
SPARC_OPCODE_ARCH_SPARCLITE 
SPARC_OPCODE_ARCH_V9 
SPARC_OPCODE_ARCH_V9A 
SPARC_OPCODE_ARCH_V9B 
SPARC_OPCODE_ARCH_BAD 

Definition at line 43 of file sparc.h.

43  {
49  /* V9 variants must appear last. */
51  SPARC_OPCODE_ARCH_V9A, /* V9 with ultrasparc additions. */
52  SPARC_OPCODE_ARCH_V9B, /* V9 with ultrasparc and cheetah additions. */
53  SPARC_OPCODE_ARCH_BAD /* Error return from sparc_opcode_lookup_arch. */
54 };
@ SPARC_OPCODE_ARCH_BAD
Definition: sparc.h:53
@ SPARC_OPCODE_ARCH_V9B
Definition: sparc.h:52
@ SPARC_OPCODE_ARCH_V6
Definition: sparc.h:44
@ SPARC_OPCODE_ARCH_V9
Definition: sparc.h:50
@ SPARC_OPCODE_ARCH_SPARCLITE
Definition: sparc.h:48
@ SPARC_OPCODE_ARCH_V8
Definition: sparc.h:46
@ SPARC_OPCODE_ARCH_V7
Definition: sparc.h:45
@ SPARC_OPCODE_ARCH_V9A
Definition: sparc.h:51
@ SPARC_OPCODE_ARCH_SPARCLET
Definition: sparc.h:47

Function Documentation

◆ sparc_decode_asi()

const char* sparc_decode_asi ( int  value)

Definition at line 2051 of file sparc-opc.c.

2052 {
2053  return lookup_value (asi_table, value);
2054 }
static int value
Definition: cmd_api.c:93
static const char * lookup_value(const arg *table, int value)
Definition: sparc-opc.c:1860
static arg asi_table[]
Definition: sparc-opc.c:1875

References asi_table, lookup_value(), and value.

Referenced by print_insn_sparc().

◆ sparc_decode_membar()

const char* sparc_decode_membar ( int  value)

Definition at line 2081 of file sparc-opc.c.

2082 {
2083  return lookup_value (membar_table, value);
2084 }
static arg membar_table[]
Definition: sparc-opc.c:2058

References lookup_value(), membar_table, and value.

Referenced by print_insn_sparc().

◆ sparc_decode_prefetch()

const char* sparc_decode_prefetch ( int  value)

Definition at line 2115 of file sparc-opc.c.

2116 {
2117  return lookup_value (prefetch_table, value);
2118 }
static arg prefetch_table[]
Definition: sparc-opc.c:2088

References lookup_value(), prefetch_table, and value.

Referenced by print_insn_sparc().

◆ sparc_decode_sparclet_cpreg()

const char* sparc_decode_sparclet_cpreg ( int  value)

Definition at line 2145 of file sparc-opc.c.

2146 {
2148 }
static arg sparclet_cpreg_table[]
Definition: sparc-opc.c:2122

References lookup_value(), sparclet_cpreg_table, and value.

Referenced by print_insn_sparc().

◆ sparc_encode_asi()

int sparc_encode_asi ( const char *  name)

Definition at line 2043 of file sparc-opc.c.

2044 {
2045  return lookup_name (asi_table, name);
2046 }
static int lookup_name(const arg *table, const char *name)
Definition: sparc-opc.c:1844
Definition: z80asm.h:102

References asi_table, and lookup_name().

◆ sparc_encode_membar()

int sparc_encode_membar ( const char *  name)

Definition at line 2073 of file sparc-opc.c.

2074 {
2075  return lookup_name (membar_table, name);
2076 }

References lookup_name(), and membar_table.

◆ sparc_encode_prefetch()

int sparc_encode_prefetch ( const char *  name)

Definition at line 2107 of file sparc-opc.c.

2108 {
2109  return lookup_name (prefetch_table, name);
2110 }

References lookup_name(), and prefetch_table.

◆ sparc_encode_sparclet_cpreg()

int sparc_encode_sparclet_cpreg ( const char *  name)

Definition at line 2137 of file sparc-opc.c.

2138 {
2140 }

References lookup_name(), and sparclet_cpreg_table.

◆ sparc_opcode_lookup_arch()

enum sparc_opcode_arch_val sparc_opcode_lookup_arch ( const char *  name)

Definition at line 1 of file sparc-opc.c.

95 {
96  const struct sparc_opcode_arch *p;
97 
98  for (p = &sparc_opcode_archs[0]; p->name; ++p) {
99  if (strcmp (name, p->name) == 0) {
100  return (enum sparc_opcode_arch_val) (p - &sparc_opcode_archs[0]);
101  }
102  }
103 
104  return SPARC_OPCODE_ARCH_BAD;
105 }
void * p
Definition: libc.cpp:67
sparc_opcode_arch_val
Definition: sparc.h:43
const struct sparc_opcode_arch sparc_opcode_archs[]
Definition: sparc-opc.c:75

Variable Documentation

◆ sparc_num_opcodes

const int sparc_num_opcodes
extern

Definition at line 1831 of file sparc-opc.c.

Referenced by print_insn_sparc().

◆ sparc_opcode_archs

const struct sparc_opcode_arch sparc_opcode_archs[]
extern

Definition at line 1 of file sparc-opc.c.

◆ sparc_opcodes

const struct sparc_opcode sparc_opcodes[]
extern

Definition at line 1 of file sparc-opc.c.

Referenced by print_insn_sparc().