Skip to content

Commit d84c30f

Browse files
committed
Remove support for legacy instructions
1 parent 9595e01 commit d84c30f

File tree

3 files changed

+9
-31
lines changed

3 files changed

+9
-31
lines changed

Tools/cases_generator/generate_cases.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class Instruction:
198198
# Parts of the underlying instruction definition
199199
inst: parser.InstDef
200200
register: bool
201-
kind: typing.Literal["inst", "op", "legacy"] # Legacy means no (input -- output)
201+
kind: typing.Literal["inst", "op"]
202202
name: str
203203
block: parser.Block
204204
block_text: list[str] # Block.text, less curlies, less PREDICT() calls
@@ -838,8 +838,6 @@ def get_stack_effect_info(
838838
self, thing: parser.InstDef | parser.Super | parser.Macro
839839
) -> tuple[AnyInstruction | None, str, str]:
840840
def effect_str(effects: list[StackEffect]) -> str:
841-
if getattr(thing, "kind", None) == "legacy":
842-
return str(-1)
843841
n_effect, sym_effect = list_effect_size(effects)
844842
if sym_effect:
845843
return f"{sym_effect} + {n_effect}" if n_effect else sym_effect
@@ -966,15 +964,12 @@ def write_metadata(self) -> None:
966964
def write_metadata_for_inst(self, instr: Instruction) -> None:
967965
"""Write metadata for a single instruction."""
968966
dir_op1 = dir_op2 = dir_op3 = "DIR_NONE"
969-
if instr.kind == "legacy":
970-
assert not instr.register
971-
else:
972-
if instr.register:
973-
directions: list[str] = []
974-
directions.extend("DIR_READ" for _ in instr.input_effects)
975-
directions.extend("DIR_WRITE" for _ in instr.output_effects)
976-
directions.extend("DIR_NONE" for _ in range(3))
977-
dir_op1, dir_op2, dir_op3 = directions[:3]
967+
if instr.register:
968+
directions: list[str] = []
969+
directions.extend("DIR_READ" for _ in instr.input_effects)
970+
directions.extend("DIR_WRITE" for _ in instr.output_effects)
971+
directions.extend("DIR_NONE" for _ in range(3))
972+
dir_op1, dir_op2, dir_op3 = directions[:3]
978973
self.out.emit(
979974
f" [{instr.name}] = {{ {dir_op1}, {dir_op2}, {dir_op3}, true, {INSTR_FMT_PREFIX}{instr.instr_fmt} }},"
980975
)

Tools/cases_generator/parser.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class OpName(Node):
100100
@dataclass
101101
class InstHeader(Node):
102102
register: bool
103-
kind: Literal["inst", "op", "legacy"] # Legacy means no (inputs -- outputs)
103+
kind: Literal["inst", "op"]
104104
name: str
105105
inputs: list[InputEffect]
106106
outputs: list[OutputEffect]
@@ -109,7 +109,7 @@ class InstHeader(Node):
109109
@dataclass
110110
class InstDef(Node):
111111
register: bool
112-
kind: Literal["inst", "op", "legacy"]
112+
kind: Literal["inst", "op"]
113113
name: str
114114
inputs: list[InputEffect]
115115
outputs: list[OutputEffect]
@@ -172,9 +172,6 @@ def inst_header(self) -> InstHeader | None:
172172
if self.expect(lx.RPAREN):
173173
if (tkn := self.peek()) and tkn.kind == lx.LBRACE:
174174
return InstHeader(register, kind, name, inp, outp)
175-
elif self.expect(lx.RPAREN) and kind == "inst":
176-
# No legacy stack effect if kind is "op".
177-
return InstHeader(register, "legacy", name, [], [])
178175
return None
179176

180177
def io_effect(self) -> tuple[list[InputEffect], list[OutputEffect]]:

Tools/cases_generator/test_generator.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,6 @@ def run_cases_test(input: str, expected: str):
6262
# print("End")
6363
assert actual.rstrip() == expected.rstrip()
6464

65-
def test_legacy():
66-
input = """
67-
inst(OP) {
68-
spam();
69-
}
70-
"""
71-
output = """
72-
TARGET(OP) {
73-
spam();
74-
DISPATCH();
75-
}
76-
"""
77-
run_cases_test(input, output)
78-
7965
def test_inst_no_args():
8066
input = """
8167
inst(OP, (--)) {

0 commit comments

Comments
 (0)