Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,18 @@ void map_groups(MCInst *MI, const insn_map *imap)
#endif // CAPSTONE_DIET
}

/// Copies the opcode encoding info from @imap to @MI->flat_insn.
void map_opcode_encoding(MCInst *MI, const insn_map *imap)
{
#ifndef CAPSTONE_DIET
if (!MI->flat_insn->detail)
return;

unsigned Opcode = MCInst_getOpcode(MI);
MI->flat_insn->detail->opcode_encoding = imap[Opcode].opcode_encoding;
#endif
}

// Search for the CS instruction id for the given @MC_Opcode in @imap.
// return -1 if none is found.
unsigned int find_cs_id(unsigned MC_Opcode, const insn_map *imap,
Expand Down Expand Up @@ -304,6 +316,18 @@ const cs_ac_type mapping_get_op_access(MCInst *MI, unsigned OpNum,
return access;
}

const cs_operand_encoding
mapping_get_op_encoding(MCInst *MI, unsigned OpNum,
const map_insn_ops *insn_ops_map, size_t map_size)
{
assert(MI);
assert(MI->Opcode < map_size);
assert(OpNum < sizeof(insn_ops_map[MI->Opcode].ops) /
sizeof(insn_ops_map[MI->Opcode].ops[0]));

return insn_ops_map[MI->Opcode].ops[OpNum].encoding;
}

/// Returns the operand at detail->arch.operands[op_count + offset]
/// Or NULL if detail is not set.
#define DEFINE_get_detail_op(arch, ARCH) \
Expand Down
14 changes: 13 additions & 1 deletion Mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ typedef struct insn_map {
union {
ppc_suppl_info ppc;
} suppl_info; // Supplementary information for each instruction.
cs_opcode_encoding opcode_encoding; // the opcode encoding info of the instruction
#endif
} insn_map;

Expand All @@ -51,6 +52,7 @@ typedef struct {
uint8_t /* cs_data_type */
dtypes[MAX_NO_DATA_TYPES]; ///< List of op types. Terminated by
///< CS_DATA_TYPE_LAST
cs_operand_encoding encoding; ///< The encoding of the operand
} mapping_op;

#define MAX_NO_INSN_MAP_OPS 16
Expand All @@ -71,6 +73,10 @@ const cs_ac_type mapping_get_op_access(MCInst *MI, unsigned OpNum,
const map_insn_ops *insn_ops_map,
size_t map_size);

const cs_operand_encoding
mapping_get_op_encoding(MCInst *MI, unsigned OpNum,
const map_insn_ops *insn_ops_map, size_t map_size);

/// Macro for easier access of operand types from the map.
/// Assumes the istruction operands map is called "insn_operands"
/// Only usable by `auto-sync` archs!
Expand All @@ -86,6 +92,10 @@ const cs_ac_type mapping_get_op_access(MCInst *MI, unsigned OpNum,
sizeof(insn_operands) / \
sizeof(insn_operands[0]))

#define map_get_op_encoding(MI, OpNum) \
mapping_get_op_encoding(MI, OpNum, insn_operands, \
sizeof(insn_operands) / sizeof(insn_operands[0]))

///< Map for ids to their string
typedef struct name_map {
unsigned int id;
Expand All @@ -112,6 +122,8 @@ void add_group(MCInst *MI, unsigned /* arch_group */ group);

void map_groups(MCInst *MI, const insn_map *imap);

void map_opcode_encoding(MCInst *MI, const insn_map *imap);

void map_cs_id(MCInst *MI, const insn_map *imap, unsigned int imap_size);

#define DECL_get_detail_op(arch, ARCH) \
Expand Down Expand Up @@ -206,4 +218,4 @@ bool map_use_alias_details(const MCInst *MI);

void map_set_alias_id(MCInst *MI, const SStream *O, const name_map *alias_mnem_id_map, int map_size);

#endif // CS_MAPPING_H
#endif // CS_MAPPING_H
46,834 changes: 23,417 additions & 23,417 deletions arch/AArch64/AArch64GenCSMappingInsnOp.inc

Large diffs are not rendered by default.

Loading