decode: Move instr-width to legacy path

Very few instructions set use instrwidth, so move this check as well to
the legacy path. The only affected common instructions are RET and
LEAVE.
This commit is contained in:
Alexis Engelke
2023-04-24 08:55:56 +02:00
parent 48f886e130
commit 6abc971576
2 changed files with 7 additions and 7 deletions

View File

@@ -767,9 +767,9 @@ skip_modrm:
return FD_ERR_UD; return FD_ERR_UD;
} }
instr->operandsz = 0;
} else {
instr->operandsz = UNLIKELY(DESC_INSTR_WIDTH(desc)) ? op_size - 1 : 0; instr->operandsz = UNLIKELY(DESC_INSTR_WIDTH(desc)) ? op_size - 1 : 0;
} else {
instr->operandsz = 0;
} }
instr->size = off; instr->size = off;

View File

@@ -276,17 +276,17 @@ class InstrDesc(NamedTuple):
else: # either empty or GP operand size else: # either empty or GP operand size
dynsizes = [OpKind.SZ_OP] dynsizes = [OpKind.SZ_OP]
if "SZ8" in self.flags: if "SZ8" in self.flags:
extraflags["opsize"] = 1
dynsizes = [] dynsizes = []
if "D64" in self.flags: extraflags["opsize"] = 2 if "D64" in self.flags: extraflags["opsize"] = 2
if "F64" in self.flags: extraflags["opsize"] = 3 if "F64" in self.flags: extraflags["opsize"] = 3
extraflags["instr_width"] = "INSTR_WIDTH" in self.flags
extraflags["lock"] = "LOCK" in self.flags extraflags["lock"] = "LOCK" in self.flags
if "SZ8" in self.flags or mnem in ("MOVSX", "MOVZX", "XCHG_NOP", "3DNOW"): if (self.flags & {"SZ8", "INSTR_WIDTH"} or
if "SZ8" not in self.flags and "INSTR_WIDTH" in self.flags: mnem in ("MOVSX", "MOVZX", "XCHG_NOP", "3DNOW")):
raise Exception("legacy instr with +w without SZ8")
extraflags["legacy"] = 1 extraflags["legacy"] = 1
# INSTR_WIDTH defaults to zero, so only enable when SZ8 is unset
if "INSTR_WIDTH" in self.flags and "SZ8" not in self.flags:
extraflags["instr_width"] = 1
imm_byte = self.imm_size(4) == 1 imm_byte = self.imm_size(4) == 1
extraflags["imm_control"] = flags.imm_control | imm_byte extraflags["imm_control"] = flags.imm_control | imm_byte