Skip to content

Commit

Permalink
generators/asm_specs: Filter out more XED instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
Serial-ATA committed Sep 12, 2023
1 parent 4430ee9 commit fc7c031
Showing 1 changed file with 74 additions and 5 deletions.
79 changes: 74 additions & 5 deletions generators/asm_specs/x86/x86.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@


def parse_instructions_from(path: Path) -> list[Instruction]:
print("INFO: Parsing Intel XED instruction definitions from: " + str(path.resolve()))
print(
"INFO: Parsing Intel XED instruction definitions from: " + str(path.resolve())
)

instructions = []
unstable_instructions = 0
Expand All @@ -28,16 +30,83 @@ def parse_instructions_from(path: Path) -> list[Instruction]:
parsed_instructions = parser.parse()
if not parsed_instructions:
break
if not parsed_instructions[0].real_opcode:
first_instruction = parsed_instructions[0]

# Skip non-real opcodes
# We keep a separate count of these just for logging purposes
if not first_instruction.real_opcode:
unstable_instructions += 1
continue
if parsed_instructions[0].extension == "3DNOW" or parsed_instructions[0].category == "3DNOW":

# Skip AMD 3DNOW instructions
if (
first_instruction.extension == "3DNOW"
or parsed_instructions[0].category == "3DNOW"
):
skipped_instructions += 1
continue

# Skip undocumented instructions
if first_instruction.comment and "UNDOC" in first_instruction.comment:
skipped_instructions += 1
continue

# No information available about these instructions
if first_instruction.name in [
"UD0",
"UD1",
"PREFETCH_RESERVED",
"PCMPISTRI64",
"VPCMPISTRI64",
"SHL_MEMb_IMMb_C0r6",
"SHL_GPR8_IMMb_C0r6",
"SHL_MEMv_IMMb_C1r6",
"SHL_GPRv_IMMb_C1r6",
"SHL_MEMb_ONE_D0r6",
"SHL_GPR8_ONE_D0r6",
"SHL_GPRv_ONE_D1r6",
"SHL_MEMv_ONE_D1r6",
"SHL_MEMb_CL_D2r6",
"SHL_GPR8_CL_D2r6",
"SHL_MEMv_CL_D3r6",
"TEST_MEMb_IMMb_F6r1",
"SHL_GPRv_CL_D3r6",
"TEST_GPR8_IMMb_F6r1",
"TEST_MEMv_IMMz_F7r1",
"TEST_GPRv_IMMz_F7r1",
"PREFETCHW_0F0Dr3",
]:
skipped_instructions += 1
continue

# No information available about these variants
if first_instruction.name == "NOP" and any(
p
for p in [
"0F0D",
"0F18",
"0F19",
"0F1A",
"0F1B",
"0F1C",
"0F1D",
"0F1E",
]
if p in first_instruction.pattern.iform
):
skipped_instructions += 1
continue

definitions_count += 1
instructions.extend(parsed_instructions)
print("INFO: Parsed {} instructions ({} definitions, {} unstable, {} skipped)".format(len(instructions), definitions_count,
unstable_instructions, skipped_instructions))
print(
"INFO: Parsed {} instructions ({} definitions, {} unstable, {} skipped)".format(
len(instructions),
definitions_count,
unstable_instructions,
skipped_instructions,
)
)
return instructions


Expand Down

0 comments on commit fc7c031

Please sign in to comment.