Skip to content

Commit 21ac056

Browse files
committed
use common operand types across all architectures. this adds cs_op_type to capstone.h. suggestion by @zneak
1 parent 6c0dd63 commit 21ac056

File tree

10 files changed

+49
-39
lines changed

10 files changed

+49
-39
lines changed

arch/ARM/ARMBaseInfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#ifndef CS_ARMBASEINFO_H
2121
#define CS_ARMBASEINFO_H
2222

23+
#include "../../include/capstone.h"
2324
#include "../../include/arm.h"
2425

2526
// Defines symbolic names for ARM registers. This defines a mapping from

include/arm.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,13 @@ typedef enum arm_sysreg {
9999

100100
//> Operand type for instruction's operands
101101
typedef enum arm_op_type {
102-
ARM_OP_INVALID = 0, // Uninitialized.
103-
ARM_OP_REG, // Register operand.
104-
ARM_OP_CIMM, // C-Immediate (coprocessor registers)
102+
ARM_OP_INVALID = CS_OP_INVALID, // Uninitialized.
103+
ARM_OP_REG = CS_OP_REG, // Register operand.
104+
ARM_OP_IMM = CS_OP_IMM, // Immediate operand.
105+
ARM_OP_MEM = CS_OP_MEM, // Memory operand
106+
ARM_OP_FP = CS_OP_FP, // Floating-Point immediate operand.
107+
ARM_OP_CIMM = 64, // C-Immediate (coprocessor registers)
105108
ARM_OP_PIMM, // P-Immediate (coprocessor registers)
106-
ARM_OP_IMM, // Immediate operand.
107-
ARM_OP_FP, // Floating-Point immediate operand.
108-
ARM_OP_MEM, // Memory operand
109109
ARM_OP_SETEND, // operand for SETEND instruction
110110
ARM_OP_SYSREG, // MSR/MSR special register operand
111111
} arm_op_type;

include/arm64.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,12 @@ typedef enum arm64_barrier_op {
232232

233233
//> Operand type for instruction's operands
234234
typedef enum arm64_op_type {
235-
ARM64_OP_INVALID = 0, // Uninitialized.
236-
ARM64_OP_REG, // Register operand.
237-
ARM64_OP_CIMM, // C-Immediate
238-
ARM64_OP_IMM, // Immediate operand.
239-
ARM64_OP_FP, // Floating-Point immediate operand.
240-
ARM64_OP_MEM, // Memory operand
235+
ARM64_OP_INVALID = CS_OP_INVALID, // Uninitialized.
236+
ARM64_OP_REG = CS_OP_REG, // Register operand.
237+
ARM64_OP_IMM = CS_OP_IMM, // Immediate operand.
238+
ARM64_OP_MEM = CS_OP_MEM, // Memory operand
239+
ARM64_OP_FP = CS_OP_FP, // Floating-Point immediate operand.
240+
ARM64_OP_CIMM = 64, // C-Immediate
241241
ARM64_OP_REG_MRS, // MRS register operand.
242242
ARM64_OP_REG_MSR, // MSR register operand.
243243
ARM64_OP_PSTATE, // PState operand.

include/capstone.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,15 @@ typedef enum cs_opt_value {
125125
CS_OPT_SYNTAX_NOREGNAME, // Prints register name with only number (CS_OPT_SYNTAX)
126126
} cs_opt_value;
127127

128+
//> Common operand types - to be used consistently across all architectures.
129+
typedef enum cs_op_type {
130+
CS_OP_INVALID = 0, // uninitialized/invalid operand.
131+
CS_OP_REG, // Register operand.
132+
CS_OP_IMM, // Immediate operand.
133+
CS_OP_MEM, // Memory operand.
134+
CS_OP_FP, // Floating-point operand.
135+
} cs_op_type;
136+
128137
/*
129138
User-defined callback function for SKIPDATA option.
130139
See tests/test_skipdata.c for sample code demonstrating this API.

include/mips.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ extern "C" {
2121

2222
//> Operand type for instruction's operands
2323
typedef enum mips_op_type {
24-
MIPS_OP_INVALID = 0, // Uninitialized.
25-
MIPS_OP_REG, // Register operand.
26-
MIPS_OP_IMM, // Immediate operand.
27-
MIPS_OP_MEM, // Memory operand
24+
MIPS_OP_INVALID = CS_OP_INVALID, // Uninitialized.
25+
MIPS_OP_REG = CS_OP_REG, // Register operand.
26+
MIPS_OP_IMM = CS_OP_IMM, // Immediate operand.
27+
MIPS_OP_MEM = CS_OP_MEM, // Memory operand
2828
} mips_op_type;
2929

3030
// Instruction's operand referring to memory

include/ppc.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ typedef enum ppc_bh {
4141

4242
//> Operand type for instruction's operands
4343
typedef enum ppc_op_type {
44-
PPC_OP_INVALID = 0, // Uninitialized.
45-
PPC_OP_REG, // Register operand.
46-
PPC_OP_IMM, // Immediate operand.
47-
PPC_OP_MEM, // Memory operand
48-
PPC_OP_CRX, // Condition Register field
44+
PPC_OP_INVALID = CS_OP_INVALID, // Uninitialized.
45+
PPC_OP_REG = CS_OP_REG, // Register operand.
46+
PPC_OP_IMM = CS_OP_IMM, // Immediate operand.
47+
PPC_OP_MEM = CS_OP_MEM, // Memory operand
48+
PPC_OP_CRX = 64, // Condition Register field
4949
} ppc_op_type;
5050

5151
// Instruction's operand referring to memory

include/sparc.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ typedef enum sparc_hint {
6969

7070
//> Operand type for instruction's operands
7171
typedef enum sparc_op_type {
72-
SPARC_OP_INVALID = 0, // Uninitialized.
73-
SPARC_OP_REG, // Register operand.
74-
SPARC_OP_IMM, // Immediate operand.
75-
SPARC_OP_MEM, // Memory operand
72+
SPARC_OP_INVALID = CS_OP_INVALID, // Uninitialized.
73+
SPARC_OP_REG = CS_OP_REG, // Register operand.
74+
SPARC_OP_IMM = CS_OP_IMM, // Immediate operand.
75+
SPARC_OP_MEM = CS_OP_MEM, // Memory operand
7676
} sparc_op_type;
7777

7878
// Instruction's operand referring to memory

include/systemz.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ typedef enum sysz_cc {
3737

3838
//> Operand type for instruction's operands
3939
typedef enum sysz_op_type {
40-
SYSZ_OP_INVALID = 0, // Uninitialized.
41-
SYSZ_OP_REG, // Register operand.
42-
SYSZ_OP_ACREG, // Access register operand.
43-
SYSZ_OP_IMM, // Immediate operand.
44-
SYSZ_OP_MEM, // Memory operand
40+
SYSZ_OP_INVALID = CS_OP_INVALID, // Uninitialized.
41+
SYSZ_OP_REG = CS_OP_REG, // Register operand.
42+
SYSZ_OP_IMM = CS_OP_IMM, // Immediate operand.
43+
SYSZ_OP_MEM = CS_OP_MEM, // Memory operand
44+
SYSZ_OP_ACREG = 64, // Access register operand.
4545
} sysz_op_type;
4646

4747
// Instruction's operand referring to memory

include/x86.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ typedef enum x86_reg {
6969

7070
//> Operand type for instruction's operands
7171
typedef enum x86_op_type {
72-
X86_OP_INVALID = 0, // Uninitialized.
73-
X86_OP_REG, // Register operand.
74-
X86_OP_IMM, // Immediate operand.
75-
X86_OP_FP, // Floating-Point immediate operand.
76-
X86_OP_MEM, // Memory operand
72+
X86_OP_INVALID = CS_OP_INVALID, // Uninitialized.
73+
X86_OP_REG = CS_OP_REG, // Register operand.
74+
X86_OP_IMM = CS_OP_IMM, // Immediate operand.
75+
X86_OP_MEM = CS_OP_MEM, // Memory operand
76+
X86_OP_FP = CS_OP_FP, // Floating-Point operand.
7777
} x86_op_type;
7878

7979
//> AVX broadcast type

include/xcore.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ extern "C" {
1717

1818
//> Operand type for instruction's operands
1919
typedef enum xcore_op_type {
20-
XCORE_OP_INVALID = 0, // Uninitialized.
21-
XCORE_OP_REG, // Register operand.
22-
XCORE_OP_IMM, // Immediate operand.
23-
XCORE_OP_MEM, // Memory operand
20+
XCORE_OP_INVALID = CS_OP_INVALID, // Uninitialized.
21+
XCORE_OP_REG = CS_OP_REG, // Register operand.
22+
XCORE_OP_IMM = CS_OP_IMM, // Immediate operand.
23+
XCORE_OP_MEM = CS_OP_MEM, // Memory operand
2424
} xcore_op_type;
2525

2626
// Instruction's operand referring to memory

0 commit comments

Comments
 (0)