Skip to content

Commit

Permalink
enc2: make sure checks for AVX xmm/ymm limit at 16 simd regs
Browse files Browse the repository at this point in the history
Change-Id: Iec9aae5a7f8763c11859f9b0712b17e8ac7f3874
(cherry picked from commit 9ceca6e27dc7709a23baa5cfef58436f6ca008b7)
  • Loading branch information
mjcharne authored and markcharney committed Aug 9, 2019
1 parent eb0aa83 commit 12ce9c2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions include/private/xed-enc2-check.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ void xed_enc2_invalid_kreg_not0(xed_uint_t mode, xed_reg_enum_t reg,const char*
void xed_enc2_invalid_mmx(xed_uint_t mode, xed_reg_enum_t reg,const char* argname,const char* pfn);
void xed_enc2_invalid_x87(xed_uint_t mode, xed_reg_enum_t reg,const char* argname,const char* pfn);
void xed_enc2_invalid_xmm(xed_uint_t mode, xed_reg_enum_t reg,const char* argname,const char* pfn);
void xed_enc2_invalid_xmm_avx(xed_uint_t mode, xed_reg_enum_t reg,const char* argname,const char* pfn);
void xed_enc2_invalid_ymm(xed_uint_t mode, xed_reg_enum_t reg,const char* argname,const char* pfn);
void xed_enc2_invalid_ymm_avx(xed_uint_t mode, xed_reg_enum_t reg,const char* argname,const char* pfn);
void xed_enc2_invalid_zmm(xed_uint_t mode, xed_reg_enum_t reg,const char* argname,const char* pfn);
void xed_enc2_invalid_rcsae(xed_uint_t mode, xed_uint_t rcsae,const char* argname,const char* pfn);
void xed_enc2_invalid_scale(xed_uint_t mode, xed_uint_t scale,const char* argname,const char* pfn);
Expand Down
7 changes: 5 additions & 2 deletions pysrc/enc2argcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ def _add_arg_check_function(ii,fo):
dbg(fo.emit())


def _fixup_arg_type(s):
def _fixup_arg_type(ii,s):
if ii.space == 'vex':
if s in ['xmm','ymm']:
return "{}_avx".format(s)
if s == 'kreg!0':
return 'kreg_not0'
return s
Expand Down Expand Up @@ -88,7 +91,7 @@ def _create_enc_arg_check_function(env, ii, encfn):
continue # don't check the integer arguments
else:
chk_fn.add_code_eol(' xed_enc2_invalid_{}({}, {},"{}",pfn)'.format(
_fixup_arg_type(arginfo),
_fixup_arg_type(ii,arginfo),
env.mode,
argname,
argname))
Expand Down
12 changes: 12 additions & 0 deletions src/enc2chk/xed-enc2-check.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,18 @@ void xed_enc2_invalid_xmm(xed_uint_t mode, xed_reg_enum_t reg,const char* argnam
if (mode != 64 && reg >= XED_REG_XMM8)
xed_enc2_error("Bad xmm %s arg_name %s in function %s", xed_reg_enum_t2str(reg), argname, pfn);
}
void xed_enc2_invalid_xmm_avx(xed_uint_t mode, xed_reg_enum_t reg,const char* argname,const char* pfn) {
if (reg < XED_REG_XMM_FIRST || reg > XED_REG_XMM15)
xed_enc2_error("Bad xmm reg %s arg_name %s in function %s", xed_reg_enum_t2str(reg), argname, pfn);
if (mode != 64 && reg >= XED_REG_XMM8)
xed_enc2_error("Bad xmm %s arg_name %s in function %s", xed_reg_enum_t2str(reg), argname, pfn);
}
void xed_enc2_invalid_ymm_avx(xed_uint_t mode, xed_reg_enum_t reg,const char* argname,const char* pfn) {
if (reg < XED_REG_YMM_FIRST || reg > XED_REG_YMM15)
xed_enc2_error("Bad ymm reg %s arg_name %s in function %s", xed_reg_enum_t2str(reg), argname, pfn);
if (mode != 64 && reg >= XED_REG_YMM8)
xed_enc2_error("Bad ymm %s arg_name %s in function %s", xed_reg_enum_t2str(reg), argname, pfn);
}
void xed_enc2_invalid_ymm(xed_uint_t mode, xed_reg_enum_t reg,const char* argname,const char* pfn) {
if (reg < XED_REG_YMM_FIRST || reg > XED_REG_YMM_LAST)
xed_enc2_error("Bad ymm reg %s arg_name %s in function %s", xed_reg_enum_t2str(reg), argname, pfn);
Expand Down

0 comments on commit 12ce9c2

Please sign in to comment.