Skip to content

Commit a3af889

Browse files
committed
Consistently rename sup(er), mac(ro)
sup: SuperInstruction mac: MacroInstruction super: Super macro: Macro
1 parent 5c97e3f commit a3af889

File tree

1 file changed

+24
-30
lines changed

1 file changed

+24
-30
lines changed

Tools/cases_generator/generate_cases.py

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -413,13 +413,13 @@ def analyze_supers_and_macros(self) -> None:
413413
"""Analyze each super- and macro instruction."""
414414
self.super_instrs = {}
415415
self.macro_instrs = {}
416-
for name, sup in self.supers.items():
417-
self.super_instrs[name] = self.analyze_super(sup)
416+
for name, super in self.supers.items():
417+
self.super_instrs[name] = self.analyze_super(super)
418418
for name, macro in self.macros.items():
419419
self.macro_instrs[name] = self.analyze_macro(macro)
420420

421-
def analyze_super(self, supe: parser.Super) -> SuperInstruction:
422-
components = self.check_super_components(supe)
421+
def analyze_super(self, super: parser.Super) -> SuperInstruction:
422+
components = self.check_super_components(super)
423423
stack, initial_sp = self.stack_analysis(components)
424424
sp = initial_sp
425425
parts: list[Component] = []
@@ -442,10 +442,10 @@ def analyze_super(self, supe: parser.Super) -> SuperInstruction:
442442
case _:
443443
typing.assert_never(component)
444444
final_sp = sp
445-
return SuperInstruction(supe, stack, initial_sp, final_sp, parts)
445+
return SuperInstruction(super, stack, initial_sp, final_sp, parts)
446446

447-
def analyze_macro(self, supe: parser.Macro) -> MacroInstruction:
448-
components = self.check_macro_components(supe)
447+
def analyze_macro(self, macro: parser.Macro) -> MacroInstruction:
448+
components = self.check_macro_components(macro)
449449
stack, initial_sp = self.stack_analysis(components)
450450
sp = initial_sp
451451
parts: list[Component | parser.CacheEffect] = []
@@ -468,36 +468,30 @@ def analyze_macro(self, supe: parser.Macro) -> MacroInstruction:
468468
case _:
469469
typing.assert_never(component)
470470
final_sp = sp
471-
return MacroInstruction(supe, stack, initial_sp, final_sp, parts)
471+
return MacroInstruction(macro, stack, initial_sp, final_sp, parts)
472472

473-
def check_super_components(self, supe: parser.Super) -> list[Instruction]:
473+
def check_super_components(self, super: parser.Super) -> list[Instruction]:
474474
components: list[Instruction] = []
475-
if not supe.ops:
476-
self.error(f"Super-instruction has no operands", supe)
477-
for op in supe.ops:
475+
if not super.ops:
476+
self.error(f"Super-instruction has no operands", super)
477+
for op in super.ops:
478478
if op.name not in self.instrs:
479-
self.error(f"Unknown instruction {op.name!r}", supe)
479+
self.error(f"Unknown instruction {op.name!r}", super)
480480
else:
481-
instr = self.instrs[op.name]
482-
if instr.kind != "inst":
483-
self.error(
484-
f"Super-instruction operand {instr.name} must be inst, not op",
485-
instr,
486-
)
487-
components.append(instr)
481+
components.append(self.instrs[op.name])
488482
return components
489483

490484
def check_macro_components(
491-
self, supe: parser.Macro
485+
self, macro: parser.Macro
492486
) -> list[InstructionOrCacheEffect]:
493487
components: list[InstructionOrCacheEffect] = []
494-
if not supe.uops:
495-
self.error(f"Macro instruction has no operands", supe)
496-
for uop in supe.uops:
488+
if not macro.uops:
489+
self.error(f"Macro instruction has no operands", macro)
490+
for uop in macro.uops:
497491
match uop:
498492
case parser.OpName(name):
499493
if name not in self.instrs:
500-
self.error(f"Unknown instruction {name!r}", supe)
494+
self.error(f"Unknown instruction {name!r}", macro)
501495
components.append(self.instrs[name])
502496
case parser.CacheEffect():
503497
components.append(uop)
@@ -595,23 +589,23 @@ def write_super(self, sup: SuperInstruction) -> None:
595589
self.write_stack_pokes(sup.stack, sup.initial_sp, sup.final_sp)
596590
self.out.emit("DISPATCH();")
597591

598-
def write_macro(self, macro: MacroInstruction) -> None:
592+
def write_macro(self, mac: MacroInstruction) -> None:
599593
"""Write code for a macro instruction."""
600594
self.out.emit("")
601595

602-
with self.out.block(f"TARGET({macro.name})"):
603-
self.write_stack_vars(macro.stack, macro.initial_sp)
596+
with self.out.block(f"TARGET({mac.name})"):
597+
self.write_stack_vars(mac.stack, mac.initial_sp)
604598

605599
cache_adjust = 0
606-
for part in macro.parts:
600+
for part in mac.parts:
607601
match part:
608602
case parser.CacheEffect(size=size):
609603
cache_adjust += size
610604
case Component() as comp:
611605
comp.write_body(self.out, cache_adjust)
612606
cache_adjust += comp.instr.cache_offset
613607

614-
self.write_stack_pokes(macro.stack, macro.initial_sp, macro.final_sp)
608+
self.write_stack_pokes(mac.stack, mac.initial_sp, mac.final_sp)
615609
if cache_adjust:
616610
self.out.emit(f"next_instr += {cache_adjust};")
617611
self.out.emit(f"DISPATCH();")

0 commit comments

Comments
 (0)