MCPcopy Index your code
hub / github.com/python/cpython / _parse_instruction

Method _parse_instruction

Tools/jit/_optimizers.py:256–287  ·  view source on GitHub ↗
(self, line: str)

Source from the content-addressed store, hash-verified

254 return re.sub(continue_symbol, continue_label, text)
255
256 def _parse_instruction(self, line: str) -> Instruction:
257 target = None
258 if match := self._re_branch.match(line):
259 target = match["target"]
260 name = match["instruction"]
261 if name in self._short_branches:
262 kind = InstructionKind.SHORT_BRANCH
263 else:
264 kind = InstructionKind.LONG_BRANCH
265 elif match := self._re_jump.match(line):
266 target = match["target"]
267 name = line[: -len(target)].strip()
268 kind = InstructionKind.JUMP
269 elif match := self._re_call.match(line):
270 target = match["target"]
271 name = line[: -len(target)].strip()
272 kind = InstructionKind.CALL
273 elif match := self._re_return.match(line):
274 name = line
275 kind = InstructionKind.RETURN
276 elif match := self._re_small_const_1.match(line):
277 target = match["value"]
278 name = match["instruction"]
279 kind = InstructionKind.SMALL_CONST_1
280 elif match := self._re_small_const_2.match(line):
281 target = match["value"]
282 name = match["instruction"]
283 kind = InstructionKind.SMALL_CONST_2
284 else:
285 name, *_ = line.split(" ")
286 kind = InstructionKind.OTHER
287 return Instruction(kind, name, line, target)
288
289 def _invert_branch(self, inst: Instruction, target: str) -> Instruction | None:
290 assert inst.is_branch()

Callers 1

__post_init__Method · 0.95

Calls 4

InstructionClass · 0.70
matchMethod · 0.45
stripMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected