use common instruction groups across all architectures. this adds cs_group_type to capstone.h. suggestion by @zneak
diff --git a/include/arm.h b/include/arm.h
index 5d38bea..e6aed29 100644
--- a/include/arm.h
+++ b/include/arm.h
@@ -808,8 +808,14 @@
//> 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,
@@ -841,8 +847,6 @@
ARM_GRP_DPVFP,
ARM_GRP_V6M,
- ARM_GRP_JUMP, // all jump instructions (conditional+direct+indirect jumps)
-
ARM_GRP_ENDING,
} arm_insn_group;
diff --git a/include/arm64.h b/include/arm64.h
index 06e146f..9f6d558 100644
--- a/include/arm64.h
+++ b/include/arm64.h
@@ -1129,15 +1129,18 @@
//> 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;
diff --git a/include/capstone.h b/include/capstone.h
index a13ec30..9f2d0df 100644
--- a/include/capstone.h
+++ b/include/capstone.h
@@ -125,15 +125,25 @@
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.
diff --git a/include/mips.h b/include/mips.h
index 957bd73..d467f0d 100644
--- a/include/mips.h
+++ b/include/mips.h
@@ -852,9 +852,14 @@
//> 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,
@@ -888,8 +893,6 @@
MIPS_GRP_GP32BIT,
MIPS_GRP_GP64BIT,
- MIPS_GRP_JUMP, // all jump instructions (conditional+direct+indirect jumps)
-
MIPS_GRP_ENDING,
} mips_insn_group;
diff --git a/include/ppc.h b/include/ppc.h
index cf5a50b..d2bff9f 100644
--- a/include/ppc.h
+++ b/include/ppc.h
@@ -1222,9 +1222,14 @@
//> 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,
@@ -1235,8 +1240,6 @@
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;
diff --git a/include/sparc.h b/include/sparc.h
index 5799b2b..60a1e53 100644
--- a/include/sparc.h
+++ b/include/sparc.h
@@ -494,9 +494,14 @@
//> 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,
@@ -504,8 +509,6 @@
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;
diff --git a/include/systemz.h b/include/systemz.h
index 951db52..96c3993 100644
--- a/include/systemz.h
+++ b/include/systemz.h
@@ -806,15 +806,19 @@
//> 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;
diff --git a/include/x86.h b/include/x86.h
index 96d6c41..90dabdc 100644
--- a/include/x86.h
+++ b/include/x86.h
@@ -1561,8 +1561,22 @@
//> 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,
@@ -1604,13 +1618,6 @@
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;
diff --git a/include/xcore.h b/include/xcore.h
index e8545a6..ff6a5d2 100644
--- a/include/xcore.h
+++ b/include/xcore.h
@@ -218,9 +218,11 @@
//> 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;