gh-128563: Move GO_TO_INSTRUCTION and PREDICT to cases generator (GH-129115)

This commit is contained in:
Ken Jin 2025-01-22 09:22:25 +08:00 committed by GitHub
parent 767cf70844
commit 86c1a60d5a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 47 additions and 59 deletions

View file

@ -127,6 +127,7 @@ class Emitter:
"DISPATCH": self.dispatch,
"INSTRUCTION_SIZE": self.instruction_size,
"POP_INPUT": self.pop_input,
"GO_TO_INSTRUCTION": self.go_to_instruction,
}
self.out = out
@ -402,6 +403,23 @@ class Emitter:
self._print_storage(storage)
return True
def go_to_instruction(
self,
tkn: Token,
tkn_iter: TokenIterator,
uop: Uop,
storage: Storage,
inst: Instruction | None,
) -> bool:
next(tkn_iter)
name = next(tkn_iter)
next(tkn_iter)
next(tkn_iter)
assert name.kind == "IDENTIFIER"
self.emit("\n")
self.emit(f"goto PREDICTED_{name.text};\n")
return True
def emit_save(self, storage: Storage) -> None:
storage.save(self.out)
self._print_storage(storage)