Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i#4504: Implement instr_invert_predicate for AArch64 #4637

Merged
merged 7 commits into from
Jan 4, 2021
22 changes: 22 additions & 0 deletions core/ir/aarch64/instr.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,3 +536,25 @@ instr_is_gather(instr_t *instr)
ASSERT_NOT_IMPLEMENTED(false);
return false;
}

dr_pred_type_t
instr_invert_predicate(dr_pred_type_t pred)
{
switch (pred) {
case DR_PRED_EQ: return DR_PRED_NE;
case DR_PRED_NE: return DR_PRED_EQ;
case DR_PRED_CS: return DR_PRED_CC;
case DR_PRED_CC: return DR_PRED_CS;
case DR_PRED_MI: return DR_PRED_PL;
case DR_PRED_PL: return DR_PRED_MI;
case DR_PRED_VS: return DR_PRED_VC;
case DR_PRED_VC: return DR_PRED_VS;
case DR_PRED_HI: return DR_PRED_LS;
case DR_PRED_LS: return DR_PRED_HI;
case DR_PRED_GE: return DR_PRED_LT;
case DR_PRED_LT: return DR_PRED_GE;
case DR_PRED_GT: return DR_PRED_LE;
case DR_PRED_LE: return DR_PRED_GT;
default: CLIENT_ASSERT(false, "Incorrect predicate value"); return DR_PRED_NONE;
}
}
9 changes: 7 additions & 2 deletions core/ir/instr.h
Original file line number Diff line number Diff line change
Expand Up @@ -1351,17 +1351,22 @@ DR_API
*/
const char *
instr_predicate_name(dr_pred_type_t pred);
#endif

#ifdef AARCHXX
DR_API
/**
* Returns the DR_PRED_ constant that represents the opposite condition
* from \p pred. A valid conditional branch predicate must be passed (i.e.,
* not #DR_PRED_NONE, DR_PRED_AL, or DR_PRED_OP).
* \note ARM-only.
* not #DR_PRED_NONE, DR_PRED_AL, or DR_PRED_OP for ARM and not #DR_PRED_NONE,
* DR_PRED_AL, or DR_PRED_NV for AArch64).
yury-khrustalev marked this conversation as resolved.
Show resolved Hide resolved
* \note ARM- and AArch64-only.
*/
dr_pred_type_t
instr_invert_predicate(dr_pred_type_t pred);
#endif

#ifdef ARM
DR_API
/**
* Assumes that \p it_instr's opcode is #OP_it. Returns the number of instructions
Expand Down