Skip to content

Commit

Permalink
i#2974 add trace support for AArch64, part 1: cbr inversion for AArch…
Browse files Browse the repository at this point in the history
…64 (#5042)

This patch added implementation for instr_invert_cbr() on AArch64 as well as
changing the implementation of instr_set_predicate by clearing the predicate
bits before setting them.

Issues: #2974, #1569
  • Loading branch information
Vincent-lau authored Aug 11, 2021
1 parent eb89394 commit b38ed40
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
15 changes: 14 additions & 1 deletion core/ir/aarch64/instr.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,20 @@ instr_is_undefined(instr_t *instr)
void
instr_invert_cbr(instr_t *instr)
{
ASSERT_NOT_IMPLEMENTED(false); /* FIXME i#1569 */
int opc = instr_get_opcode(instr);
dr_pred_type_t pred = instr_get_predicate(instr);
CLIENT_ASSERT(instr_is_cbr(instr), "instr_invert_cbr: instr not a cbr");
if (opc == OP_cbnz) {
instr_set_opcode(instr, OP_cbz);
} else if (opc == OP_cbz) {
instr_set_opcode(instr, OP_cbnz);
} else if (opc == OP_tbnz) {
instr_set_opcode(instr, OP_tbz);
} else if (opc == OP_tbz) {
instr_set_opcode(instr, OP_tbnz);
} else {
instr_set_predicate(instr, instr_invert_predicate(pred));
}
}

bool
Expand Down
3 changes: 2 additions & 1 deletion core/ir/instr_shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,8 @@ instr_get_predicate(instr_t *instr)
instr_t *
instr_set_predicate(instr_t *instr, dr_pred_type_t pred)
{
instr->prefixes |= ((pred << PREFIX_PRED_BITPOS) & PREFIX_PRED_MASK);
instr->prefixes = ((instr->prefixes & ~PREFIX_PRED_MASK) |
((pred << PREFIX_PRED_BITPOS) & PREFIX_PRED_MASK));
return instr;
}

Expand Down

0 comments on commit b38ed40

Please sign in to comment.