LEA: allow immediate syntax; ignore operand size entirely

The memory operand size of LEA doesn't matter in any way as it isn't
"real memory". Add an ANYSIZE option to ignore sizes entirely.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin (Intel) 2019-08-14 15:23:00 -07:00
parent a635809620
commit 02b60ddd1c
4 changed files with 11 additions and 4 deletions

View file

@ -2440,6 +2440,9 @@ static enum match_result matches(const struct itemplate *itemp,
case IF_GENBIT(IF_SZ):
asize = BITS512;
break;
case IF_GENBIT(IF_ANYSIZE):
asize = SIZE_MASK;
break;
case IF_GENBIT(IF_SIZE):
switch (bits) {
case 16:

View file

@ -71,7 +71,7 @@ static inline int iflag_cmp(const iflag_t *a, const iflag_t *b)
IF_GEN_HELPER(xor, ^)
/* Some helpers which are to work with predefined masks */
#define IF_SMASK (IFM_SB|IFM_SW|IFM_SD|IFM_SQ|IFM_SO|IFM_SY|IFM_SZ|IFM_SIZE)
#define IF_SMASK (IFM_SB|IFM_SW|IFM_SD|IFM_SQ|IFM_SO|IFM_SY|IFM_SZ|IFM_SIZE|IFM_ANYSIZE)
#define IF_ARMASK (IFM_AR0|IFM_AR1|IFM_AR2|IFM_AR3|IFM_AR4)
#define _itemp_smask(idx) (insns_flags[(idx)].field[0] & IF_SMASK)

View file

@ -16,6 +16,7 @@ if_("SY", "Unsized operands can't be non-yword");
if_("SZ", "Unsized operands can't be non-zword");
if_("SIZE", "Unsized operands must match the bitsize");
if_("SX", "Unsized operands not allowed");
if_("ANYSIZE", "Ignore operand size even if explicit");
if_("AR0", "SB, SW, SD applies to argument 0");
if_("AR1", "SB, SW, SD applies to argument 1");
if_("AR2", "SB, SW, SD applies to argument 2");

View file

@ -732,9 +732,12 @@ LAR reg64,reg32 [rm: o64 0f 02 /r] X64,PROT
LAR reg64,reg64 [rm: o64 0f 02 /r] X64,PROT
LDS reg16,mem [rm: o16 c5 /r] 8086,NOLONG
LDS reg32,mem [rm: o32 c5 /r] 386,NOLONG
LEA reg16,mem [rm: o16 8d /r] 8086
LEA reg32,mem [rm: o32 8d /r] 386
LEA reg64,mem [rm: o64 8d /r] X64
LEA reg16,mem [rm: o16 8d /r] 8086,ANYSIZE
LEA reg32,mem [rm: o32 8d /r] 386,ANYSIZE
LEA reg64,mem [rm: o64 8d /r] X64,ANYSIZE
LEA reg16,imm [rm: o16 8d /r] 8086,ND,ANYSIZE
LEA reg32,imm [rm: o32 8d /r] 386,ND,ANYSIZE
LEA reg64,imm [rm: o64 8d /r] X64,ND,ANYSIZE
LEAVE void [ c9] 186
LES reg16,mem [rm: o16 c4 /r] 8086,NOLONG
LES reg32,mem [rm: o32 c4 /r] 386,NOLONG