]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Remove support for legacy bytecode instructions (#105705)
authorGuido van Rossum <guido@python.org>
Mon, 12 Jun 2023 18:19:04 +0000 (11:19 -0700)
committerGitHub <noreply@github.com>
Mon, 12 Jun 2023 18:19:04 +0000 (18:19 +0000)
(A legacy instruction is of the form `instr(FOOBAR)`,
i.e. missing the `(... -- ...)` stack/cache effect annotation.)

Tools/cases_generator/generate_cases.py
Tools/cases_generator/parser.py
Tools/cases_generator/test_generator.py

index 69216c17ed87806043306005fa49beba9223ce49..3a003b3fba26009635ed4ebb9fd208d38d44c421 100644 (file)
@@ -230,7 +230,7 @@ class Instruction:
 
     # Parts of the underlying instruction definition
     inst: parser.InstDef
-    kind: typing.Literal["inst", "op", "legacy"]  # Legacy means no (input -- output)
+    kind: typing.Literal["inst", "op"]
     name: str
     block: parser.Block
     block_text: list[str]  # Block.text, less curlies, less PREDICT() calls
@@ -856,8 +856,6 @@ class Analyzer:
         self, thing: parser.InstDef | parser.Macro | parser.Pseudo
     ) -> tuple[AnyInstruction | None, str, str]:
         def effect_str(effects: list[StackEffect]) -> str:
-            if getattr(thing, "kind", None) == "legacy":
-                return str(-1)
             n_effect, sym_effect = list_effect_size(effects)
             if sym_effect:
                 return f"{sym_effect} + {n_effect}" if n_effect else sym_effect
index 2c75989a7e8ab4956ddcc9da8bebceff3b09cf52..ac77e7eae81ad36b877ec5cae0bd1f607f3a6968 100644 (file)
@@ -101,7 +101,7 @@ UOp = OpName | CacheEffect
 class InstHeader(Node):
     override: bool
     register: bool
-    kind: Literal["inst", "op", "legacy"]  # Legacy means no (inputs -- outputs)
+    kind: Literal["inst", "op"]
     name: str
     inputs: list[InputEffect]
     outputs: list[OutputEffect]
@@ -111,7 +111,7 @@ class InstHeader(Node):
 class InstDef(Node):
     override: bool
     register: bool
-    kind: Literal["inst", "op", "legacy"]
+    kind: Literal["inst", "op"]
     name: str
     inputs: list[InputEffect]
     outputs: list[OutputEffect]
@@ -174,9 +174,6 @@ class Parser(PLexer):
                     if self.expect(lx.RPAREN):
                         if (tkn := self.peek()) and tkn.kind == lx.LBRACE:
                             return InstHeader(override, register, kind, name, inp, outp)
-                elif self.expect(lx.RPAREN) and kind == "inst":
-                    # No legacy stack effect if kind is "op".
-                    return InstHeader(override, register, "legacy", name, [], [])
         return None
 
     def io_effect(self) -> tuple[list[InputEffect], list[OutputEffect]]:
index 036094ac8ef487ad6ada26de61ea5ff01550bfe9..412d3d1459005027b88e3963ec1250c76f51c5e0 100644 (file)
@@ -62,20 +62,6 @@ def run_cases_test(input: str, expected: str):
     #     print("End")
     assert actual.rstrip() == expected.rstrip()
 
-def test_legacy():
-    input = """
-        inst(OP) {
-            spam();
-        }
-    """
-    output = """
-        TARGET(OP) {
-            spam();
-            DISPATCH();
-        }
-    """
-    run_cases_test(input, output)
-
 def test_inst_no_args():
     input = """
         inst(OP, (--)) {