summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorCarl Meyer <carl@oddbird.net>2023-10-05 22:05:29 (GMT)
committerGitHub <noreply@github.com>2023-10-05 22:05:29 (GMT)
commit3c0f65ebce10d5327e07245f7cf2beb96b18c970 (patch)
tree5358e6d22256a9a2ee1a2643fa5e2b9f7d25f130 /Tools
parentbb057b337008626139d97269485b1dddf70ae427 (diff)
downloadcpython-3c0f65ebce10d5327e07245f7cf2beb96b18c970.zip
cpython-3c0f65ebce10d5327e07245f7cf2beb96b18c970.tar.gz
cpython-3c0f65ebce10d5327e07245f7cf2beb96b18c970.tar.bz2
gh-109287: fix overrides in cases generator (#110419)
Diffstat (limited to 'Tools')
-rw-r--r--Tools/cases_generator/analysis.py11
-rw-r--r--Tools/cases_generator/generate_cases.py17
-rw-r--r--Tools/cases_generator/instructions.py5
3 files changed, 2 insertions, 31 deletions
diff --git a/Tools/cases_generator/analysis.py b/Tools/cases_generator/analysis.py
index 7bbc924..b2fa020 100644
--- a/Tools/cases_generator/analysis.py
+++ b/Tools/cases_generator/analysis.py
@@ -12,7 +12,6 @@ from instructions import (
InstructionOrCacheEffect,
MacroInstruction,
MacroParts,
- OverriddenInstructionPlaceHolder,
PseudoInstruction,
)
import parsing
@@ -66,7 +65,6 @@ class Analyzer:
parsing.InstDef
| parsing.Macro
| parsing.Pseudo
- | OverriddenInstructionPlaceHolder
]
instrs: dict[str, Instruction] # Includes ops
macros: dict[str, parsing.Macro]
@@ -141,7 +139,7 @@ class Analyzer:
match thing:
case parsing.InstDef(name=name):
macro: parsing.Macro | None = None
- if thing.kind == "inst":
+ if thing.kind == "inst" and not thing.override:
macro = parsing.Macro(name, [parsing.OpName(name)])
if name in self.instrs:
if not thing.override:
@@ -150,12 +148,7 @@ class Analyzer:
f"previous definition @ {self.instrs[name].inst.context}",
thing_first_token,
)
- placeholder = OverriddenInstructionPlaceHolder(name=name)
- self.everything[instrs_idx[name]] = placeholder
- if macro is not None:
- self.warning(
- f"Overriding desugared {macro.name} may not work", thing
- )
+ self.everything[instrs_idx[name]] = thing
if name not in self.instrs and thing.override:
raise psr.make_syntax_error(
f"Definition of '{name}' @ {thing.context} is supposed to be "
diff --git a/Tools/cases_generator/generate_cases.py b/Tools/cases_generator/generate_cases.py
index 01ab83b..dbb1641 100644
--- a/Tools/cases_generator/generate_cases.py
+++ b/Tools/cases_generator/generate_cases.py
@@ -26,7 +26,6 @@ from instructions import (
MacroInstruction,
MacroParts,
PseudoInstruction,
- OverriddenInstructionPlaceHolder,
TIER_ONE,
TIER_TWO,
)
@@ -208,8 +207,6 @@ class Generator(Analyzer):
popped_data: list[tuple[AnyInstruction, str]] = []
pushed_data: list[tuple[AnyInstruction, str]] = []
for thing in self.everything:
- if isinstance(thing, OverriddenInstructionPlaceHolder):
- continue
if isinstance(thing, parsing.Macro) and thing.name in self.instrs:
continue
instr, popped, pushed = self.get_stack_effect_info(thing)
@@ -393,8 +390,6 @@ class Generator(Analyzer):
for thing in self.everything:
format: str | None = None
match thing:
- case OverriddenInstructionPlaceHolder():
- continue
case parsing.InstDef():
format = self.instrs[thing.name].instr_fmt
case parsing.Macro():
@@ -492,8 +487,6 @@ class Generator(Analyzer):
# Write metadata for each instruction
for thing in self.everything:
match thing:
- case OverriddenInstructionPlaceHolder():
- continue
case parsing.InstDef():
self.write_metadata_for_inst(self.instrs[thing.name])
case parsing.Macro():
@@ -774,8 +767,6 @@ class Generator(Analyzer):
n_macros = 0
for thing in self.everything:
match thing:
- case OverriddenInstructionPlaceHolder():
- self.write_overridden_instr_place_holder(thing)
case parsing.InstDef():
pass
case parsing.Macro():
@@ -836,14 +827,6 @@ class Generator(Analyzer):
file=sys.stderr,
)
- def write_overridden_instr_place_holder(
- self, place_holder: OverriddenInstructionPlaceHolder
- ) -> None:
- self.out.emit("")
- self.out.emit(
- f"{self.out.comment} TARGET({place_holder.name}) overridden by later definition"
- )
-
def is_super_instruction(mac: MacroInstruction) -> bool:
if (
diff --git a/Tools/cases_generator/instructions.py b/Tools/cases_generator/instructions.py
index bd7b7df..c6b5516 100644
--- a/Tools/cases_generator/instructions.py
+++ b/Tools/cases_generator/instructions.py
@@ -295,11 +295,6 @@ class PseudoInstruction:
instr_flags: InstructionFlags
-@dataclasses.dataclass
-class OverriddenInstructionPlaceHolder:
- name: str
-
-
AnyInstruction = Instruction | MacroInstruction | PseudoInstruction