encode: Support VEX-encoded instructions

This commit is contained in:
Alexis Engelke
2021-01-10 16:03:40 +01:00
parent 9245a97248
commit 1458bf9673
3 changed files with 117 additions and 24 deletions

View File

@@ -484,6 +484,8 @@ def encode_table(entries):
opc_i |= opcode.modreg[0] << 8
opc_flags = ""
opc_flags += ["","|OPC_0F","|OPC_0F38","|OPC_0F3A"][opcode.escape]
if "VSIB" in desc.flags:
opc_flags += "|OPC_VSIB"
if opcode.vex:
hasvex, vecsizes = True, {128, 256}
opc_flags += "|OPC_VEX"
@@ -574,6 +576,7 @@ def encode_table(entries):
tys_i = sum(ty << (4*i) for i, ty in enumerate(tys))
opc_s = hex(opc_i) + opc_flags + prefix[1]
if opsize == 16: opc_s += "|OPC_66"
if vecsize == 256: opc_s += "|OPC_VEXL"
if opsize == 64 and "DEF64" not in desc.flags and "FORCE64" not in desc.flags: opc_s += "|OPC_REXW"
# Construct mnemonic name