Skip to content

Commit

Permalink
Add CS only groups
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 committed Oct 12, 2023
1 parent c8b2f1d commit b7622dc
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions arch/AArch64/AArch64Mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,29 @@ static void patch_cs_reg_alias(char *asm_str)
}
}

/// Adds group to the instruction which are not defined in LLVM.
static void AArch64_add_cs_groups(MCInst *MI)
{
unsigned Opcode = MI->flat_insn->id;
switch (Opcode) {
default:
return;
case AArch64_INS_SVC:
add_group(MI, AArch64_GRP_INT);
break;
case AArch64_INS_SMC:
case AArch64_INS_MSR:
case AArch64_INS_MRS:
add_group(MI, AArch64_GRP_PRIVILEGE);
break;
case AArch64_INS_RET:
case AArch64_INS_RETAA:
case AArch64_INS_RETAB:
add_group(MI, AArch64_GRP_RET);
break;
}
}

void AArch64_printer(MCInst *MI, SStream *O, void * /* MCRegisterInfo* */ info) {
MCRegisterInfo *MRI = (MCRegisterInfo *)info;
MI->MRI = MRI;
Expand All @@ -286,6 +309,7 @@ void AArch64_printer(MCInst *MI, SStream *O, void * /* MCRegisterInfo* */ info)
int syntax_opt = MI->csh->syntax;
if (syntax_opt & CS_OPT_SYNTAX_CS_REG_ALIAS)
patch_cs_reg_alias(O->buffer);
AArch64_add_cs_groups(MI);
}

// given internal insn id, return public instruction info
Expand Down

0 comments on commit b7622dc

Please sign in to comment.