5af28808 Update Auto-Sync to Python 3.13 and tree-sitter-py 24.0 (#2705) 99f018ac Python binding: (#2742) a07baf83 Auto-Sync update Sparc LLVM-18 (#2704) 81c5c93d Enable to generate legacy MC tests for the fuzzer. (#2733) a25d4980 Add warning about naive search and replace to patch reg names. (#2728) 7ac87d17 Print immediate only memory operands for AArch64. (#2732) c34034c8 Add x30 implicit read to the RET alias. (#2739) 95a4ca3e Update source list before installing valgrind. (#2730) 6909724e Make assertion hit warnings optional in release builds. (#2729) fe6bdc6e Make SStream respect the CS_OPT_UNSIGNED flag. (#2723) 21ce3624 Use cs_ac_type for operand access mode in all arches and use cs_xtensa_op_type for Xtensa operand type (#2721) df26583f clang-format: change license to BSD-3-Clause (#2724) 280b749e Remove unused files. (#2709) 87908ece Add flag for the SoftFail case of the LLVM disassembler. (#2707) efc0ba44 Fix missing operand for smstart, due to space replaced by tab (#2720) 2ae64133 Fix missing sp register read in ret instruction (#2719) 8df252a6 Fix arm pop reg access (#2718) 14612272 ARM: fix typo, cspr -> cpsr (#2716) f2f0a3c3 Fix LoongArch ld/st instructions register info (#2701) 829be2bf LoongArch: Compute absolute address for address operand (#2699) 42fbce6c Add jump group for generic jirl (#2698) fc525c73 Apple AArch64 proprietary (#2692) 895f2f2e Build PDB for debugging on Windows (#2685) 5c3aef03 Version: Update to v6.0.0-alpha4 (#2682) 106f7d3b Update read/written registers for x87 comparison instructions (#2680) ebe3ef2a Add workflow for building on Windows (#2675) 72f7d305 Revert "Add a script to compare the inc file content with the latest generate…" (#2678) 5b5c5ed8 Fix nanomips decoding of jalrc (#2672) ae03cca4 Mips32r6_64r632 is for both mips32r6 and mips64r6 (#2673) 21178aea Add a script to compare the inc file content with the latest generated ones. (#2667) 81a6ba03 MIPS: Fix MIPS16 decoding, wrong flags and ghost registers (#2665) 98a393e3 Stringify BH fields when printing ppc details (#2663) 2607d0f3 Remove undefined constants in riscv_const.py (#2660) (#2661) 5058c634 Decode BH field in print_insn_detail_ppc (#2662) 6461ed08 Add Call group to svc, smc and hvc. (#2651) e2f1dc8d Tms32c64x Little Endian (#2648) 5464c91d Fix build for compilers requiring explicit static for inline functions.. (#2645) bb2f6579 Enhance shift value and types of shift instructions. (#2638) cd282ef5 Update operand type enums of all arch modules to the one in `capstone.h` (#2633) dc0c0909 cmake: Fix building capstone as sub-project (#2629) cd8dd20c - Added missing files for sdist archive (#2624) 9affd99b Give the user some guidance where to add missing enumeration values. (#2639) 1bea3fab Add checks for MIPS details on cstest_py (#2640) ace8056c Add aliases mapping for MIPS & test for id, alias_id (#2635) 1abe1868 Build Tarball before DEB/RPM package. (#2627) 0a012190 Switch to ubuntu-24.04-arm runner image (#2625) 4e0b8c48 Fix wrong version requirement of tricore instructions: (#2620) 8ac2843b chore(version): Update Version to 6.0.0-Alpha3 (#2616) d7ef910b Rebased #2570 (#2614) c831cd5e Fix SystemZ macro in Makefile (#2603) 30601176 Apply new EVM opcode updates (#2602) 3c4d7fc8 Add tricore tc1.8 instructions (#2595) 5f290cad Create debian and rpm package on releases (#2590) 0f09210a delete travis (#2600) 5c5f756f Downgrade labeler to v4 due to https://github.com/actions/labeler/issues/710. (#2598) git-subtree-dir: external/capstone git-subtree-split: 5af288083e9f03e32723f9708c305692f866b666
460 lines
7.5 KiB
C
460 lines
7.5 KiB
C
#ifndef CAPSTONE_SH_H
|
|
#define CAPSTONE_SH_H
|
|
|
|
/* Capstone Disassembly Engine */
|
|
/* By Yoshinori Sato, 2022 */
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include "platform.h"
|
|
#include "cs_operand.h"
|
|
|
|
#ifdef _MSC_VER
|
|
#pragma warning(disable:4201)
|
|
#endif
|
|
|
|
/// SH registers and special registers
|
|
typedef enum {
|
|
SH_REG_INVALID = 0,
|
|
|
|
SH_REG_R0,
|
|
SH_REG_R1,
|
|
SH_REG_R2,
|
|
SH_REG_R3,
|
|
SH_REG_R4,
|
|
SH_REG_R5,
|
|
SH_REG_R6,
|
|
SH_RE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
|
|
SH_REG_FV4,
|
|
SH_REG_FV8,
|
|
SH_REG_FV12,
|
|
|
|
SH_REG_XMATRX,
|
|
|
|
SH_REG_PC,
|
|
SH_REG_PR,
|
|
SH_REG_MACH,
|
|
SH_REG_MACL,
|
|
|
|
SH_REG_SR,
|
|
SH_REG_GBR,
|
|
SH_REG_SSR,
|
|
SH_REG_SPC,
|
|
SH_REG_SGR,
|
|
SH_REG_DBR,
|
|
SH_REG_VBR,
|
|
SH_REG_TBR,
|
|
SH_REG_RS,
|
|
SH_REG_RE,
|
|
SH_REG_MOD,
|
|
|
|
SH_REG_FPUL,
|
|
SH_REG_FPSCR,
|
|
|
|
SH_REG_DSP_X0,
|
|
SH_REG_DSP_X1,
|
|
SH_REG_DSP_Y0,
|
|
SH_REG_DSP_Y1,
|
|
SH_REG_DSP_A0,
|
|
SH_REG_DSP_A1,
|
|
SH_REG_DSP_A0G,
|
|
SH_REG_DSP_A1G,
|
|
SH_REG_DSP_M0,
|
|
SH_REG_DSP_M1,
|
|
SH_REG_DSP_DSR,
|
|
|
|
SH_REG_DSP_RSV0,
|
|
SH_REG_DSP_RSV1,
|
|
SH_REG_DSP_RSV2,
|
|
SH_REG_DSP_RSV3,
|
|
SH_REG_DSP_RSV4,
|
|
SH_REG_DSP_RSV5,
|
|
SH_REG_DSP_RSV6,
|
|
SH_REG_DSP_RSV7,
|
|
SH_REG_DSP_RSV8,
|
|
SH_REG_DSP_RSV9,
|
|
SH_REG_DSP_RSVA,
|
|
SH_REG_DSP_RSVB,
|
|
SH_REG_DSP_RSVC,
|
|
SH_REG_DSP_RSVD,
|
|
SH_REG_DSP_RSVE,
|
|
SH_REG_DSP_RSVF,
|
|
|
|
SH_REG_ENDING, // <-- mark the end of the list of registers
|
|
} sh_reg;
|
|
|
|
typedef enum {
|
|
SH_OP_INVALID = CS_OP_INVALID, ///< = CS_OP_INVALID (Uninitialized).
|
|
SH_OP_REG = CS_OP_REG, ///< = CS_OP_REG (Register operand).
|
|
SH_OP_IMM = CS_OP_IMM, ///< = CS_OP_IMM (Immediate operand).
|
|
SH_OP_MEM = CS_OP_MEM, ///< = CS_OP_MEM (Memory operand).
|
|
} sh_op_type;
|
|
|
|
typedef enum {
|
|
SH_OP_MEM_INVALID = 0, /// <= Invalid
|
|
SH_OP_MEM_REG_IND, /// <= Register indirect
|
|
SH_OP_MEM_REG_POST, /// <= Register post increment
|
|
SH_OP_MEM_REG_PRE, /// <= Register pre decrement
|
|
SH_OP_MEM_REG_DISP, /// <= displacement
|
|
SH_OP_MEM_REG_R0, /// <= R0 indexed
|
|
SH_OP_MEM_GBR_DISP, /// <= GBR based displacement
|
|
SH_OP_MEM_GBR_R0, /// <= GBR based R0 indexed
|
|
SH_OP_MEM_PCR, /// <= PC relative
|
|
SH_OP_MEM_TBR_DISP, /// <= TBR based displaysment
|
|
} sh_op_mem_type;
|
|
|
|
typedef struct sh_op_mem {
|
|
sh_op_mem_type address; /// <= memory address
|
|
sh_reg reg; /// <= base register
|
|
uint32_t disp; /// <= displacement
|
|
} sh_op_mem;
|
|
|
|
typedef enum sh_dsp_insn {
|
|
SH_INS_DSP_INVALID = 0,
|
|
SH_INS_DSP_NOP = 1,
|
|
SH_INS_DSP_MOV,
|
|
SH_INS_DSP_PSHL,
|
|
SH_INS_DSP_PSHA,
|
|
SH_INS_DSP_PMULS,
|
|
SH_INS_DSP_PCLR_PMULS,
|
|
SH_INS_DSP_PSUB_PMULS,
|
|
SH_INS_DSP_PADD_PMULS,
|
|
SH_INS_DSP_PSUBC,
|
|
SH_INS_DSP_PADDC,
|
|
SH_INS_DSP_PCMP,
|
|
SH_INS_DSP_PABS,
|
|
SH_INS_DSP_PRND,
|
|
SH_INS_DSP_PSUB,
|
|
SH_INS_DSP_PSUBr,
|
|
SH_INS_DSP_PADD,
|
|
SH_INS_DSP_PAND,
|
|
SH_INS_DSP_PXOR,
|
|
SH_INS_DSP_POR,
|
|
SH_INS_DSP_PDEC,
|
|
SH_INS_DSP_PINC,
|
|
SH_INS_DSP_PCLR,
|
|
SH_INS_DSP_PDMSB,
|
|
SH_INS_DSP_PNEG,
|
|
SH_INS_DSP_PCOPY,
|
|
SH_INS_DSP_PSTS,
|
|
SH_INS_DSP_PLDS,
|
|
SH_INS_DSP_PSWAP,
|
|
SH_INS_DSP_PWAD,
|
|
SH_INS_DSP_PWSB,
|
|
} sh_dsp_insn;
|
|
|
|
typedef enum sh_dsp_operand {
|
|
SH_OP_DSP_INVALID,
|
|
SH_OP_DSP_REG_PRE,
|
|
SH_OP_DSP_REG_IND,
|
|
SH_OP_DSP_REG_POST,
|
|
SH_OP_DSP_REG_INDEX,
|
|
SH_OP_DSP_REG,
|
|
SH_OP_DSP_IMM,
|
|
|
|
} sh_dsp_operand;
|
|
|
|
typedef enum sh_dsp_cc {
|
|
SH_DSP_CC_INVALID,
|
|
SH_DSP_CC_NONE,
|
|
SH_DSP_CC_DCT,
|
|
SH_DSP_CC_DCF,
|
|
} sh_dsp_cc;
|
|
|
|
typedef struct sh_op_dsp {
|
|
sh_dsp_insn insn;
|
|
sh_dsp_operand operand[2];
|
|
sh_reg r[6];
|
|
sh_dsp_cc cc;
|
|
uint8_t imm;
|
|
int size;
|
|
} sh_op_dsp;
|
|
|
|
/// Instruction operand
|
|
typedef struct cs_sh_op {
|
|
sh_op_type type;
|
|
union {
|
|
uint64_t imm; ///< immediate value for IMM operand
|
|
sh_reg reg; ///< register value for REG operand
|
|
sh_op_mem mem; ///< data when operand is targeting memory
|
|
sh_op_dsp dsp; ///< dsp instruction
|
|
};
|
|
} cs_sh_op;
|
|
|
|
/// SH instruction
|
|
typedef enum sh_insn {
|
|
SH_INS_INVALID,
|
|
SH_INS_ADD_r,
|
|
SH_INS_ADD,
|
|
SH_INS_ADDC,
|
|
SH_INS_ADDV,
|
|
SH_INS_AND,
|
|
SH_INS_BAND,
|
|
SH_INS_BANDNOT,
|
|
SH_INS_BCLR,
|
|
SH_INS_BF,
|
|
SH_INS_BF_S,
|
|
SH_INS_BLD,
|
|
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SHLL16,
|
|
SH_INS_SHLL2,
|
|
SH_INS_SHLL8,
|
|
SH_INS_SHLR,
|
|
SH_INS_SHLR16,
|
|
SH_INS_SHLR2,
|
|
SH_INS_SHLR8,
|
|
SH_INS_SLEEP,
|
|
SH_INS_STBANK,
|
|
SH_INS_STC,
|
|
SH_INS_STS,
|
|
SH_INS_SUB,
|
|
SH_INS_SUBC,
|
|
SH_INS_SUBV,
|
|
SH_INS_SWAP_B,
|
|
SH_INS_SWAP_W,
|
|
SH_INS_SYNCO,
|
|
SH_INS_TAS,
|
|
SH_INS_TRAPA,
|
|
SH_INS_TST,
|
|
SH_INS_XOR,
|
|
SH_INS_XTRCT,
|
|
SH_INS_DSP,
|
|
SH_INS_ENDING, // <-- mark the end of the list of instructions
|
|
} sh_insn;
|
|
|
|
/// Instruction structure
|
|
typedef struct cs_sh {
|
|
sh_insn insn;
|
|
uint8_t size;
|
|
uint8_t op_count;
|
|
cs_sh_op operands[3];
|
|
} cs_sh;
|
|
|
|
/// Group of SH instructions
|
|
typedef enum sh_insn_group {
|
|
SH_GRP_INVALID = 0, ///< CS_GRUP_INVALID
|
|
SH_GRP_JUMP, ///< = CS_GRP_JUMP
|
|
SH_GRP_CALL, ///< = CS_GRP_CALL
|
|
SH_GRP_INT, ///< = CS_GRP_INT
|
|
SH_GRP_RET, ///< = CS_GRP_RET
|
|
SH_GRP_IRET, ///< = CS_GRP_IRET
|
|
SH_GRP_PRIVILEGE, ///< = CS_GRP_PRIVILEGE
|
|
SH_GRP_BRANCH_RELATIVE, ///< = CS_GRP_BRANCH_RELATIVE
|
|
|
|
SH_GRP_SH1,
|
|
SH_GRP_SH2,
|
|
SH_GRP_SH2E,
|
|
SH_GRP_SH2DSP,
|
|
SH_GRP_SH2A,
|
|
SH_GRP_SH2AFPU,
|
|
SH_GRP_SH3,
|
|
SH_GRP_SH3DSP,
|
|
SH_GRP_SH4,
|
|
SH_GRP_SH4A,
|
|
|
|
SH_GRP_ENDING,// <-- mark the end of the list of groups
|
|
} sh_insn_group;
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|