Skip to content

Commit

Permalink
use common instruction groups across all architectures. this adds cs_…
Browse files Browse the repository at this point in the history
…group_type to capstone.h. suggestion by @zneak
  • Loading branch information
aquynh committed Oct 31, 2014
1 parent 69271dd commit 3ab5091
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 36 deletions.
12 changes: 8 additions & 4 deletions include/arm.h
Original file line number Diff line number Diff line change
Expand Up @@ -808,8 +808,14 @@ typedef enum arm_insn {

//> Group of ARM instructions
typedef enum arm_insn_group {
ARM_GRP_INVALID = 0,
ARM_GRP_CRYPTO,
ARM_GRP_INVALID = 0, // = CS_GRP_INVALID

//> Generic groups
// all jump instructions (conditional+direct+indirect jumps)
ARM_GRP_JUMP, // = CS_GRP_JUMP

//> Architecture-specific groups
ARM_GRP_CRYPTO = 128,
ARM_GRP_DATABARRIER,
ARM_GRP_DIVIDE,
ARM_GRP_FPARMV8,
Expand Down Expand Up @@ -841,8 +847,6 @@ typedef enum arm_insn_group {
ARM_GRP_DPVFP,
ARM_GRP_V6M,

ARM_GRP_JUMP, // all jump instructions (conditional+direct+indirect jumps)

ARM_GRP_ENDING,
} arm_insn_group;

Expand Down
11 changes: 7 additions & 4 deletions include/arm64.h
Original file line number Diff line number Diff line change
Expand Up @@ -1129,15 +1129,18 @@ typedef enum arm64_insn {

//> Group of ARM64 instructions
typedef enum arm64_insn_group {
ARM64_GRP_INVALID = 0,
ARM64_GRP_INVALID = 0, // = CS_GRP_INVALID

ARM64_GRP_CRYPTO,
//> Generic groups
// all jump instructions (conditional+direct+indirect jumps)
ARM64_GRP_JUMP, // = CS_GRP_JUMP

//> Architecture-specific groups
ARM64_GRP_CRYPTO = 128,
ARM64_GRP_FPARMV8,
ARM64_GRP_NEON,
ARM64_GRP_CRC,

ARM64_GRP_JUMP, // all jump instructions (conditional+direct+indirect jumps)

ARM64_GRP_ENDING, // <-- mark the end of the list of groups
} arm64_insn_group;

Expand Down
14 changes: 12 additions & 2 deletions include/capstone.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,25 @@ typedef enum cs_opt_value {
CS_OPT_SYNTAX_NOREGNAME, // Prints register name with only number (CS_OPT_SYNTAX)
} cs_opt_value;

//> Common operand types - to be used consistently across all architectures.
//> Common instruction operand types - to be consistent across all architectures.
typedef enum cs_op_type {
CS_OP_INVALID = 0, // uninitialized/invalid operand.
CS_OP_REG, // Register operand.
CS_OP_IMM, // Immediate operand.
CS_OP_MEM, // Memory operand.
CS_OP_FP, // Floating-point operand.
CS_OP_FP, // Floating-Point operand.
} cs_op_type;

//> Common instruction groups - to be consistent across all architectures.
typedef enum cs_group_type {
CS_GRP_INVALID = 0, // uninitialized/invalid group.
CS_GRP_JUMP, // all jump instructions (conditional+direct+indirect jumps)
CS_GRP_CALL, // all call instructions
CS_GRP_RET, // all return instructions
CS_GRP_INT, // all interrupt instructions (int+syscall)
CS_GRP_IRET, // all interrupt return instructions
} cs_group_type;

/*
User-defined callback function for SKIPDATA option.
See tests/test_skipdata.c for sample code demonstrating this API.
Expand Down
11 changes: 7 additions & 4 deletions include/mips.h
Original file line number Diff line number Diff line change
Expand Up @@ -852,9 +852,14 @@ typedef enum mips_insn {

//> Group of MIPS instructions
typedef enum mips_insn_group {
MIPS_GRP_INVALID = 0,
MIPS_GRP_INVALID = 0, // = CS_GRP_INVALID

MIPS_GRP_BITCOUNT,
//> Generic groups
// all jump instructions (conditional+direct+indirect jumps)
MIPS_GRP_JUMP, // = CS_GRP_JUMP

//> Architecture-specific groups
MIPS_GRP_BITCOUNT = 128,
MIPS_GRP_DSP,
MIPS_GRP_DSPR2,
MIPS_GRP_FPIDX,
Expand Down Expand Up @@ -888,8 +893,6 @@ typedef enum mips_insn_group {
MIPS_GRP_GP32BIT,
MIPS_GRP_GP64BIT,

MIPS_GRP_JUMP, // all jump instructions (conditional+direct+indirect jumps)

MIPS_GRP_ENDING,
} mips_insn_group;

Expand Down
11 changes: 7 additions & 4 deletions include/ppc.h
Original file line number Diff line number Diff line change
Expand Up @@ -1222,9 +1222,14 @@ typedef enum ppc_insn {

//> Group of PPC instructions
typedef enum ppc_insn_group {
PPC_GRP_INVALID = 0,
PPC_GRP_INVALID = 0, // = CS_GRP_INVALID

PPC_GRP_ALTIVEC,
//> Generic groups
// all jump instructions (conditional+direct+indirect jumps)
PPC_GRP_JUMP, // = CS_GRP_JUMP

//> Architecture-specific groups
PPC_GRP_ALTIVEC = 128,
PPC_GRP_MODE32,
PPC_GRP_MODE64,
PPC_GRP_BOOKE,
Expand All @@ -1235,8 +1240,6 @@ typedef enum ppc_insn_group {
PPC_GRP_PPC4XX,
PPC_GRP_PPC6XX,

PPC_GRP_JUMP, // all jump instructions (conditional+direct+indirect jumps)

PPC_GRP_ENDING, // <-- mark the end of the list of groups
} ppc_insn_group;

Expand Down
11 changes: 7 additions & 4 deletions include/sparc.h
Original file line number Diff line number Diff line change
Expand Up @@ -494,18 +494,21 @@ typedef enum sparc_insn {

//> Group of SPARC instructions
typedef enum sparc_insn_group {
SPARC_GRP_INVALID = 0,
SPARC_GRP_INVALID = 0, // = CS_GRP_INVALID

SPARC_GRP_HARDQUAD,
//> Generic groups
// all jump instructions (conditional+direct+indirect jumps)
SPARC_GRP_JUMP, // = CS_GRP_JUMP

//> Architecture-specific groups
SPARC_GRP_HARDQUAD = 128,
SPARC_GRP_V9,
SPARC_GRP_VIS,
SPARC_GRP_VIS2,
SPARC_GRP_VIS3,
SPARC_GRP_32BIT,
SPARC_GRP_64BIT,

SPARC_GRP_JUMP, // all jump instructions (conditional+direct+indirect jumps)

SPARC_GRP_ENDING, // <-- mark the end of the list of groups
} sparc_insn_group;

Expand Down
12 changes: 8 additions & 4 deletions include/systemz.h
Original file line number Diff line number Diff line change
Expand Up @@ -806,15 +806,19 @@ typedef enum sysz_insn {

//> Group of SystemZ instructions
typedef enum sysz_insn_group {
SYSZ_GRP_INVALID = 0,
SYSZ_GRP_DISTINCTOPS,
SYSZ_GRP_INVALID = 0, // = CS_GRP_INVALID

//> Generic groups
// all jump instructions (conditional+direct+indirect jumps)
SYSZ_GRP_JUMP, // = CS_GRP_JUMP

//> Architecture-specific groups
SYSZ_GRP_DISTINCTOPS = 128,
SYSZ_GRP_FPEXTENSION,
SYSZ_GRP_HIGHWORD,
SYSZ_GRP_INTERLOCKEDACCESS1,
SYSZ_GRP_LOADSTOREONCOND,

SYSZ_GRP_JUMP, // all jump instructions (conditional+direct+indirect jumps)

SYSZ_GRP_ENDING, // <-- mark the end of the list of groups
} sysz_insn_group;

Expand Down
23 changes: 15 additions & 8 deletions include/x86.h
Original file line number Diff line number Diff line change
Expand Up @@ -1561,8 +1561,22 @@ typedef enum x86_insn {

//> Group of X86 instructions
typedef enum x86_insn_group {
X86_GRP_INVALID = 0,
X86_GRP_INVALID = 0, // = CS_GRP_INVALID

//> Generic groups
// all jump instructions (conditional+direct+indirect jumps)
X86_GRP_JUMP, // = CS_GRP_JUMP
// all call instructions
X86_GRP_CALL, // = CS_GRP_CALL
// all return instructions
X86_GRP_RET, // = CS_GRP_RET
// all interrupt instructions (int+syscall)
X86_GRP_INT, // = CS_GRP_INT
// all interrupt return instructions
X86_GRP_IRET, // = CS_GRP_IRET

//> Architecture-specific groups
X86_GRP_VM = 128, // all virtualization instructions (VT-x + AMD-V)
X86_GRP_3DNOW,
X86_GRP_AES,
X86_GRP_ADX,
Expand Down Expand Up @@ -1604,13 +1618,6 @@ typedef enum x86_insn_group {
X86_GRP_SMAP,
X86_GRP_NOVLX,

X86_GRP_JUMP, // all jump instructions (conditional+direct+indirect jumps)
X86_GRP_VM, // all virtualization instructions (VT-x + AMD-V)
X86_GRP_INT, // all interrupt instructions (int+syscall)
X86_GRP_IRET, // all interrupt return instructions
X86_GRP_CALL, // all call instructions
X86_GRP_RET, // all call return instructions

X86_GRP_ENDING
} x86_insn_group;

Expand Down
6 changes: 4 additions & 2 deletions include/xcore.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,11 @@ typedef enum xcore_insn {

//> Group of XCore instructions
typedef enum xcore_insn_group {
XCORE_GRP_INVALID = 0,
XCORE_GRP_INVALID = 0, // = CS_GRP_INVALID

XCORE_GRP_JUMP, // all jump instructions (conditional+direct+indirect jumps)
//> Generic groups
// all jump instructions (conditional+direct+indirect jumps)
XCORE_GRP_JUMP, // = CS_GRP_JUMP

XCORE_GRP_ENDING, // <-- mark the end of the list of groups
} xcore_insn_group;
Expand Down

0 comments on commit 3ab5091

Please sign in to comment.