mirror of
https://github.com/capstone-engine/capstone.git
synced 2024-11-26 23:10:32 +00:00
Merge pull request #2121 from Rot127/arm-implicit-reads
[ARM] Add CPSR implicit read for every instruction with predicate
This commit is contained in:
commit
c4947a9ec3
22
Mapping.c
22
Mapping.c
@ -85,6 +85,25 @@ void map_add_implicit_write(MCInst *MI, uint32_t Reg)
|
||||
}
|
||||
}
|
||||
|
||||
/// Adds a register to the implicit read register list.
|
||||
/// It will not add the same register twice.
|
||||
void map_add_implicit_read(MCInst *MI, uint32_t Reg)
|
||||
{
|
||||
if (!MI->flat_insn->detail)
|
||||
return;
|
||||
|
||||
uint16_t *regs_read = MI->flat_insn->detail->regs_read;
|
||||
for (int i = 0; i < MAX_IMPL_W_REGS; ++i) {
|
||||
if (i == MI->flat_insn->detail->regs_read_count) {
|
||||
regs_read[i] = Reg;
|
||||
MI->flat_insn->detail->regs_read_count++;
|
||||
return;
|
||||
}
|
||||
if (regs_read[i] == Reg)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// Removes a register from the implicit write register list.
|
||||
void map_remove_implicit_write(MCInst *MI, uint32_t Reg)
|
||||
{
|
||||
@ -160,7 +179,8 @@ void map_implicit_writes(MCInst *MI, const insn_map *imap)
|
||||
}
|
||||
|
||||
/// Adds a given group to @MI->flat_insn.
|
||||
void add_group(MCInst *MI, unsigned /* arch_group */ group) {
|
||||
void add_group(MCInst *MI, unsigned /* arch_group */ group)
|
||||
{
|
||||
#ifndef CAPSTONE_DIET
|
||||
if (!MI->flat_insn->detail)
|
||||
return;
|
||||
|
@ -21,9 +21,9 @@ typedef struct insn_map {
|
||||
unsigned short mapid; // The Capstone instruction id
|
||||
#ifndef CAPSTONE_DIET
|
||||
uint16_t regs_use[MAX_IMPL_R_REGS]; ///< list of implicit registers used by
|
||||
///< this instruction
|
||||
///< this instruction
|
||||
uint16_t regs_mod[MAX_IMPL_W_REGS]; ///< list of implicit registers modified
|
||||
///< by this instruction
|
||||
///< by this instruction
|
||||
unsigned char groups
|
||||
[MAX_NUM_GROUPS]; ///< list of group this instruction belong to
|
||||
bool branch; // branch instruction?
|
||||
@ -47,7 +47,7 @@ typedef struct {
|
||||
uint8_t /* cs_ac_type */ access; ///< The access type (read, write)
|
||||
uint8_t /* cs_data_type */
|
||||
dtypes[MAX_NO_DATA_TYPES]; ///< List of op types. Terminated by
|
||||
///< CS_DATA_TYPE_LAST
|
||||
///< CS_DATA_TYPE_LAST
|
||||
} mapping_op;
|
||||
|
||||
#define MAX_NO_INSN_MAP_OPS 16
|
||||
@ -98,6 +98,7 @@ int name2id(const name_map *map, int max, const char *name);
|
||||
const char *id2name(const name_map *map, int max, const unsigned int id);
|
||||
|
||||
void map_add_implicit_write(MCInst *MI, uint32_t Reg);
|
||||
void map_add_implicit_read(MCInst *MI, uint32_t Reg);
|
||||
void map_remove_implicit_write(MCInst *MI, uint32_t Reg);
|
||||
|
||||
void map_implicit_reads(MCInst *MI, const insn_map *imap);
|
||||
|
@ -868,6 +868,8 @@ static void add_cs_detail_general(MCInst *MI, arm_op_group op_group,
|
||||
return;
|
||||
}
|
||||
ARM_get_detail(MI)->cc = CC;
|
||||
if (CC != ARMCC_AL)
|
||||
map_add_implicit_read(MI, ARM_REG_CPSR);
|
||||
break;
|
||||
}
|
||||
case ARM_OP_GROUP_VPTPredicateOperand: {
|
||||
|
Loading…
Reference in New Issue
Block a user