Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7fb598a
Add macro() and op() DSL features
gvanrossum Nov 14, 2022
edae5af
Improve code generation for super/macro instructions
gvanrossum Nov 15, 2022
881357e
Move super code generation into a helper
gvanrossum Nov 16, 2022
0f12c40
Reduce the fiddling with integers in super analysis
gvanrossum Nov 16, 2022
babdbf9
Do the super/macro analysis at analysis time
gvanrossum Nov 16, 2022
2fa0a04
Convert WITH_EXCEPT_START, fix generator to make it work
gvanrossum Nov 16, 2022
cb0c874
Fix lexer to balk at unrecognized characters, e.g. '@'
gvanrossum Nov 16, 2022
fe0d336
Fix typo in comment
gvanrossum Nov 17, 2022
d84a5c3
Code review from GH-99526
gvanrossum Nov 18, 2022
d7ad950
Fix moved output names; support object pointers in cache
gvanrossum Nov 18, 2022
a034675
Tune README
gvanrossum Nov 18, 2022
1aafac8
Introduce error() method to print errors
gvanrossum Nov 18, 2022
20062f4
Check components of super/macro ops
gvanrossum Nov 18, 2022
7194723
Fix crash when WITH_EXCEPT_START errors out
gvanrossum Nov 18, 2022
cb62653
Merge branch 'main' into macro-ops
gvanrossum Nov 19, 2022
b74aa6a
Don't use typing.Dict
gvanrossum Nov 22, 2022
a0feff9
Kill more "unused" literals
gvanrossum Nov 22, 2022
a2e9991
Don't over-use f-strings
gvanrossum Nov 22, 2022
240126b
Avoid compiler warning on unused variable
gvanrossum Nov 22, 2022
6640706
Merge remote-tracking branch 'origin/main' into macro-ops
gvanrossum Nov 22, 2022
7afa58c
Introduce read_uint16(p) as equivalent to *p
gvanrossum Nov 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Introduce error() method to print errors
  • Loading branch information
gvanrossum committed Nov 18, 2022
commit 1aafac8c3bd72a051aa77ece1c544388a8525591
45 changes: 23 additions & 22 deletions Tools/cases_generator/generate_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,10 @@ def super_macro_analysis(
lowest = current = highest = 0
for instr in components:
if instr.cache_effects:
print(
a.error(
f"Super-instruction {self.name!r} has cache effects in {instr.name!r}",
file=sys.stderr,
instr,
)
a.errors += 1
current -= len(instr.input_effects)
lowest = min(lowest, current)
current += len(instr.output_effects)
Expand All @@ -239,7 +238,18 @@ class Analyzer:

filename: str
src: str
errors: int = 0 # TODO: add a method to print an error message
errors: int = 0

def error(self, msg: str, node: parser.Node) -> None:
lineno = 0
if context := node.context:
# Use line number of first non-comment in the node
for token in context.owner.tokens[context.begin : context.end]:
lineno = token.line
if token.kind != "COMMENT":
break
print(f"{self.filename}:{lineno}: {msg}", file=sys.stderr)
self.errors += 1

def __init__(self, filename: str):
"""Read the input file."""
Expand Down Expand Up @@ -303,11 +313,10 @@ def find_predictions(self) -> None:
if target_instr := self.instrs.get(target):
target_instr.predicted = True
else:
print(
self.error(
f"Unknown instruction {target!r} predicted in {instr.name!r}",
file=sys.stderr,
instr, # TODO: Use better location
)
self.errors += 1

def map_families(self) -> None:
"""Make instruction names back to their family, if they have one."""
Expand All @@ -316,11 +325,10 @@ def map_families(self) -> None:
if member_instr := self.instrs.get(member):
member_instr.family = family
else:
print(
self.error(
f"Unknown instruction {member!r} referenced in family {family.name!r}",
file=sys.stderr,
family,
)
self.errors += 1

def check_families(self) -> None:
"""Check each family:
Expand All @@ -331,13 +339,11 @@ def check_families(self) -> None:
"""
for family in self.families.values():
if len(family.members) < 2:
print(f"Family {family.name!r} has insufficient members")
self.errors += 1
self.error(f"Family {family.name!r} has insufficient members", family)
members = [member for member in family.members if member in self.instrs]
if members != family.members:
unknown = set(family.members) - set(members)
print(f"Family {family.name!r} has unknown members: {unknown}")
self.errors += 1
self.error(f"Family {family.name!r} has unknown members: {unknown}", family)
if len(members) < 2:
continue
head = self.instrs[members[0]]
Expand All @@ -350,18 +356,13 @@ def check_families(self) -> None:
i = len(instr.input_effects)
o = len(instr.output_effects)
if (c, i, o) != (cache, input, output):
self.errors += 1
print(
self.error(
f"Family {family.name!r} has inconsistent "
f"(cache, inputs, outputs) effects:",
file=sys.stderr,
)
print(
f"(cache, inputs, outputs) effects:\n"
f" {family.members[0]} = {(cache, input, output)}; "
f"{member} = {(c, i, o)}",
file=sys.stderr,
family,
)
self.errors += 1

def analyze_supers(self) -> None:
"""Analyze each super instruction."""
Expand Down