Skip to content

Commit

Permalink
Turn opmask_with_dsts()/is_evex_mask condition into an assertion.
Browse files Browse the repository at this point in the history
opmask_with_dsts() covers both Intel and AT&T syntax, non-x86 syntaxes should never have is_evex_mask == true, and DR syntax should never get into this function.
  • Loading branch information
khuey committed Dec 19, 2024
1 parent 94bf526 commit 4219250
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions core/ir/disassemble_shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,9 @@ instr_disassemble_opnds_noimplicit(char *buf, size_t bufsz, size_t *sofar DR_PAR
*/
optype = 0;
});
bool is_evex_mask = optype_is_evex_mask_arch(optype) && opmask_with_dsts();
bool is_evex_mask = optype_is_evex_mask_arch(optype);
CLIENT_ASSERT(!is_evex_mask || opmask_with_dsts(),
"Anything here with evex mask should be opmask_with_dsts()");
if (!is_evex_mask) {
print_to_buffer(buf, bufsz, sofar, "");
printing = opnd_disassemble_noimplicit(buf, bufsz, sofar, dcontext, instr,
Expand Down Expand Up @@ -1077,7 +1079,9 @@ instr_disassemble_opnds_noimplicit(char *buf, size_t bufsz, size_t *sofar DR_PAR
(i == 0 && opnd_is_reg(opnd) && reg_is_fp(opnd_get_reg(opnd))));
});
if (print) {
bool is_evex_mask = optype_is_evex_mask_arch(optype) && opmask_with_dsts();
bool is_evex_mask = optype_is_evex_mask_arch(optype);
CLIENT_ASSERT(!is_evex_mask || opmask_with_dsts(),
"Anything here with evex mask should be opmask_with_dsts()");
print_to_buffer(buf, bufsz, sofar, is_evex_mask ? " {" : "");
prev = opnd_disassemble_noimplicit(buf, bufsz, sofar, dcontext, instr, optype,
opnd, prev && !is_evex_mask,
Expand All @@ -1092,8 +1096,10 @@ instr_disassemble_opnds_noimplicit(char *buf, size_t bufsz, size_t *sofar DR_PAR
CLIENT_ASSERT(IF_X86_ELSE(true, false), "evex mask can only exist for x86.");
optype = instr_info_opnd_type(info, !dsts_first(), mask_index);
CLIENT_ASSERT(!instr_is_opmask(instr) && opnd_is_reg(opnd) &&
reg_is_opmask(opnd_get_reg(opnd)) && opmask_with_dsts(),
reg_is_opmask(opnd_get_reg(opnd)),
"evex mask must always be the first source.");
CLIENT_ASSERT(opmask_with_dsts(),
"Anything here with evex mask should be opmask_with_dsts()");
print_to_buffer(buf, bufsz, sofar, " {");
opnd_disassemble_noimplicit(buf, bufsz, sofar, dcontext, instr, optype, opnd,
false, multiple_encodings, dsts_first(), &mask_index);
Expand Down

0 comments on commit 4219250

Please sign in to comment.