use common operand types across all architectures. this adds cs_op_type to capstone.h. suggestion by @zneak
diff --git a/arch/ARM/ARMBaseInfo.h b/arch/ARM/ARMBaseInfo.h
index 7e50396..752c94e 100644
--- a/arch/ARM/ARMBaseInfo.h
+++ b/arch/ARM/ARMBaseInfo.h
@@ -20,6 +20,7 @@
#ifndef CS_ARMBASEINFO_H
#define CS_ARMBASEINFO_H
+#include "../../include/capstone.h"
#include "../../include/arm.h"
// Defines symbolic names for ARM registers. This defines a mapping from
diff --git a/include/arm.h b/include/arm.h
index fd2b138..fecc6a3 100644
--- a/include/arm.h
+++ b/include/arm.h
@@ -99,13 +99,13 @@
//> Operand type for instruction's operands
typedef enum arm_op_type {
- ARM_OP_INVALID = 0, // Uninitialized.
- ARM_OP_REG, // Register operand.
- ARM_OP_CIMM, // C-Immediate (coprocessor registers)
+ ARM_OP_INVALID = CS_OP_INVALID, // Uninitialized.
+ ARM_OP_REG = CS_OP_REG, // Register operand.
+ ARM_OP_IMM = CS_OP_IMM, // Immediate operand.
+ ARM_OP_MEM = CS_OP_MEM, // Memory operand
+ ARM_OP_FP = CS_OP_FP, // Floating-Point immediate operand.
+ ARM_OP_CIMM = 64, // C-Immediate (coprocessor registers)
ARM_OP_PIMM, // P-Immediate (coprocessor registers)
- ARM_OP_IMM, // Immediate operand.
- ARM_OP_FP, // Floating-Point immediate operand.
- ARM_OP_MEM, // Memory operand
ARM_OP_SETEND, // operand for SETEND instruction
ARM_OP_SYSREG, // MSR/MSR special register operand
} arm_op_type;
diff --git a/include/arm64.h b/include/arm64.h
index 47a6adb..8dcf969 100644
--- a/include/arm64.h
+++ b/include/arm64.h
@@ -232,12 +232,12 @@
//> Operand type for instruction's operands
typedef enum arm64_op_type {
- ARM64_OP_INVALID = 0, // Uninitialized.
- ARM64_OP_REG, // Register operand.
- ARM64_OP_CIMM, // C-Immediate
- ARM64_OP_IMM, // Immediate operand.
- ARM64_OP_FP, // Floating-Point immediate operand.
- ARM64_OP_MEM, // Memory operand
+ ARM64_OP_INVALID = CS_OP_INVALID, // Uninitialized.
+ ARM64_OP_REG = CS_OP_REG, // Register operand.
+ ARM64_OP_IMM = CS_OP_IMM, // Immediate operand.
+ ARM64_OP_MEM = CS_OP_MEM, // Memory operand
+ ARM64_OP_FP = CS_OP_FP, // Floating-Point immediate operand.
+ ARM64_OP_CIMM = 64, // C-Immediate
ARM64_OP_REG_MRS, // MRS register operand.
ARM64_OP_REG_MSR, // MSR register operand.
ARM64_OP_PSTATE, // PState operand.
diff --git a/include/capstone.h b/include/capstone.h
index 13d03cf..a13ec30 100644
--- a/include/capstone.h
+++ b/include/capstone.h
@@ -125,6 +125,15 @@
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.
+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_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 45eedd9..0d816e1 100644
--- a/include/mips.h
+++ b/include/mips.h
@@ -21,10 +21,10 @@
//> Operand type for instruction's operands
typedef enum mips_op_type {
- MIPS_OP_INVALID = 0, // Uninitialized.
- MIPS_OP_REG, // Register operand.
- MIPS_OP_IMM, // Immediate operand.
- MIPS_OP_MEM, // Memory operand
+ MIPS_OP_INVALID = CS_OP_INVALID, // Uninitialized.
+ MIPS_OP_REG = CS_OP_REG, // Register operand.
+ MIPS_OP_IMM = CS_OP_IMM, // Immediate operand.
+ MIPS_OP_MEM = CS_OP_MEM, // Memory operand
} mips_op_type;
// Instruction's operand referring to memory
diff --git a/include/ppc.h b/include/ppc.h
index e955c42..e71138b 100644
--- a/include/ppc.h
+++ b/include/ppc.h
@@ -41,11 +41,11 @@
//> Operand type for instruction's operands
typedef enum ppc_op_type {
- PPC_OP_INVALID = 0, // Uninitialized.
- PPC_OP_REG, // Register operand.
- PPC_OP_IMM, // Immediate operand.
- PPC_OP_MEM, // Memory operand
- PPC_OP_CRX, // Condition Register field
+ PPC_OP_INVALID = CS_OP_INVALID, // Uninitialized.
+ PPC_OP_REG = CS_OP_REG, // Register operand.
+ PPC_OP_IMM = CS_OP_IMM, // Immediate operand.
+ PPC_OP_MEM = CS_OP_MEM, // Memory operand
+ PPC_OP_CRX = 64, // Condition Register field
} ppc_op_type;
// Instruction's operand referring to memory
diff --git a/include/sparc.h b/include/sparc.h
index dedde37..c0c8516 100644
--- a/include/sparc.h
+++ b/include/sparc.h
@@ -69,10 +69,10 @@
//> Operand type for instruction's operands
typedef enum sparc_op_type {
- SPARC_OP_INVALID = 0, // Uninitialized.
- SPARC_OP_REG, // Register operand.
- SPARC_OP_IMM, // Immediate operand.
- SPARC_OP_MEM, // Memory operand
+ SPARC_OP_INVALID = CS_OP_INVALID, // Uninitialized.
+ SPARC_OP_REG = CS_OP_REG, // Register operand.
+ SPARC_OP_IMM = CS_OP_IMM, // Immediate operand.
+ SPARC_OP_MEM = CS_OP_MEM, // Memory operand
} sparc_op_type;
// Instruction's operand referring to memory
diff --git a/include/systemz.h b/include/systemz.h
index ea7624b..0f9dcd7 100644
--- a/include/systemz.h
+++ b/include/systemz.h
@@ -37,11 +37,11 @@
//> Operand type for instruction's operands
typedef enum sysz_op_type {
- SYSZ_OP_INVALID = 0, // Uninitialized.
- SYSZ_OP_REG, // Register operand.
- SYSZ_OP_ACREG, // Access register operand.
- SYSZ_OP_IMM, // Immediate operand.
- SYSZ_OP_MEM, // Memory operand
+ SYSZ_OP_INVALID = CS_OP_INVALID, // Uninitialized.
+ SYSZ_OP_REG = CS_OP_REG, // Register operand.
+ SYSZ_OP_IMM = CS_OP_IMM, // Immediate operand.
+ SYSZ_OP_MEM = CS_OP_MEM, // Memory operand
+ SYSZ_OP_ACREG = 64, // Access register operand.
} sysz_op_type;
// Instruction's operand referring to memory
diff --git a/include/x86.h b/include/x86.h
index 734d7a9..ecb072e 100644
--- a/include/x86.h
+++ b/include/x86.h
@@ -69,11 +69,11 @@
//> Operand type for instruction's operands
typedef enum x86_op_type {
- X86_OP_INVALID = 0, // Uninitialized.
- X86_OP_REG, // Register operand.
- X86_OP_IMM, // Immediate operand.
- X86_OP_FP, // Floating-Point immediate operand.
- X86_OP_MEM, // Memory operand
+ X86_OP_INVALID = CS_OP_INVALID, // Uninitialized.
+ X86_OP_REG = CS_OP_REG, // Register operand.
+ X86_OP_IMM = CS_OP_IMM, // Immediate operand.
+ X86_OP_MEM = CS_OP_MEM, // Memory operand
+ X86_OP_FP = CS_OP_FP, // Floating-Point operand.
} x86_op_type;
//> AVX broadcast type
diff --git a/include/xcore.h b/include/xcore.h
index 0429864..a843e69 100644
--- a/include/xcore.h
+++ b/include/xcore.h
@@ -17,10 +17,10 @@
//> Operand type for instruction's operands
typedef enum xcore_op_type {
- XCORE_OP_INVALID = 0, // Uninitialized.
- XCORE_OP_REG, // Register operand.
- XCORE_OP_IMM, // Immediate operand.
- XCORE_OP_MEM, // Memory operand
+ XCORE_OP_INVALID = CS_OP_INVALID, // Uninitialized.
+ XCORE_OP_REG = CS_OP_REG, // Register operand.
+ XCORE_OP_IMM = CS_OP_IMM, // Immediate operand.
+ XCORE_OP_MEM = CS_OP_MEM, // Memory operand
} xcore_op_type;
// Instruction's operand referring to memory