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
Fix moved output names; support object pointers in cache
  • Loading branch information
gvanrossum committed Nov 18, 2022
commit d7ad95004375a146c050e2dfbb28ea1452d7f0f9
36 changes: 25 additions & 11 deletions Tools/cases_generator/generate_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,25 +73,36 @@ def write(self, f: typing.TextIO, indent: str, dedent: int = 0) -> None:
cache_offset = 0
for ceffect in self.cache_effects:
if ceffect.name != UNUSED:
# TODO: if name is 'descr' use PyObject *descr = read_obj(...)
bits = ceffect.size * BITS_PER_CODE_UNIT
f.write(f"{indent} uint{bits}_t {ceffect.name} = ")
if ceffect.size == 1:
f.write(f"*(next_instr + {cache_offset});\n")
if bits == 64:
# NOTE: We assume that 64-bit data in the cache
# is always an object pointer.
# If this becomes false, we need a way to specify
# syntactically what type the cache data is.
f.write(
f"{indent} PyObject *{ceffect.name} = "
f"read_obj(next_instr + {cache_offset});\n"
)
else:
f.write(f"read_u{bits}(next_instr + {cache_offset});\n")
f.write(f"{indent} uint{bits}_t {ceffect.name} = ")
if ceffect.size == 1:
# There is no read_u16() helper function.
f.write(f"*(next_instr + {cache_offset});\n")
else:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, should we just add a read_u16 function to keep things simple? They're not really special anymore now that we've ditched the structs, and we've shown that it would compile the same.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, good idea. Will do.

f.write(f"read_u{bits}(next_instr + {cache_offset});\n")
cache_offset += ceffect.size
assert cache_offset == self.cache_offset

# Write input stack effect variable declarations and initializations
input_names = [seffect.name for seffect in self.input_effects]
for i, seffect in enumerate(reversed(self.input_effects), 1):
if seffect.name != UNUSED:
f.write(f"{indent} PyObject *{seffect.name} = PEEK({i});\n")

# Write output stack effect variable declarations
input_names = {seffect.name for seffect in self.input_effects}
input_names.add(UNUSED)
for seffect in self.output_effects:
if seffect.name not in input_names and seffect.name != UNUSED:
if seffect.name not in input_names:
f.write(f"{indent} PyObject *{seffect.name};\n")

self.write_body(f, indent, dedent)
Expand All @@ -108,10 +119,13 @@ def write(self, f: typing.TextIO, indent: str, dedent: int = 0) -> None:
f.write(f"{indent} STACK_SHRINK({-diff});\n")

# Write output stack effect assignments
for i, output in enumerate(reversed(self.output_effects), 1):
# TODO: Only skip if output occurs at same position as input
if output.name not in input_names and output.name != UNUSED:
f.write(f"{indent} POKE({i}, {output.name});\n")
unmoved_names = {UNUSED}
for ieffect, oeffect in zip(self.input_effects, self.output_effects):
if ieffect.name == oeffect.name:
unmoved_names.add(ieffect.name)
for i, seffect in enumerate(reversed(self.output_effects)):
if seffect.name not in unmoved_names:
f.write(f"{indent} POKE({i+1}, {seffect.name});\n")

# Write cache effect
if self.cache_offset:
Expand Down