Skip to content

Commit

Permalink
use common operand types across all architectures. this adds cs_op_ty…
Browse files Browse the repository at this point in the history
…pe to capstone.h. suggestion by @zneak
  • Loading branch information
aquynh committed Oct 31, 2014
1 parent 6c0dd63 commit 21ac056
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 39 deletions.
1 change: 1 addition & 0 deletions arch/ARM/ARMBaseInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions include/arm.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ typedef enum arm_sysreg {

//> 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;
Expand Down
12 changes: 6 additions & 6 deletions include/arm64.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,12 @@ typedef enum arm64_barrier_op {

//> 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.
Expand Down
9 changes: 9 additions & 0 deletions include/capstone.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ 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.
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.
Expand Down
8 changes: 4 additions & 4 deletions include/mips.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ extern "C" {

//> 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
Expand Down
10 changes: 5 additions & 5 deletions include/ppc.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ typedef enum ppc_bh {

//> 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
Expand Down
8 changes: 4 additions & 4 deletions include/sparc.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ typedef enum sparc_hint {

//> 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
Expand Down
10 changes: 5 additions & 5 deletions include/systemz.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ typedef enum sysz_cc {

//> 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
Expand Down
10 changes: 5 additions & 5 deletions include/x86.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ typedef enum x86_reg {

//> 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
Expand Down
8 changes: 4 additions & 4 deletions include/xcore.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ extern "C" {

//> 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
Expand Down

0 comments on commit 21ac056

Please sign in to comment.