summaryrefslogtreecommitdiffstats
path: root/Tools/cases_generator/parser.py
Commit message (Collapse)AuthorAgeFilesLines
* gh-102021 : Allow multiple input files for interpreter loop generator (#102022)Jacob Bower2023-03-041-7/+10
| | | The input files no longer use `-i`.
* gh-98831: Modernize FORMAT_VALUE (#101628)Guido van Rossum2023-02-081-1/+8
| | | Generator update: support balanced parentheses and brackets in conditions and size expressions.
* gh-98831: Support conditional effects; use for LOAD_ATTR (#101333)Guido van Rossum2023-01-301-22/+27
|
* GH-98831: Implement array support in cases generator (#100912)Guido van Rossum2023-01-171-12/+48
| | | | | | | | You can now write things like this: ``` inst(BUILD_STRING, (pieces[oparg] -- str)) { ... } inst(LIST_APPEND, (list, unused[oparg-1], v -- list, unused[oparg-1])) { ... } ``` Note that array output effects are only partially supported (they must be named `unused` or correspond to an input effect).
* GH-98831: Identify instructions that don't use oparg (#100957)Guido van Rossum2023-01-141-1/+1
| | | | | | | For these the instr_format field uses IX instead of IB. Register instructions use IX, IB, IBBX, IBBB, etc. Also: Include the closing '}' in Block.tokens, for completeness
* GH-98831: Update generate_cases.py: register inst, opcode_metadata.h (#100735)Guido van Rossum2023-01-051-7/+12
| | | | | | | | (These aren't used yet, but may be coming soon, and it's easier to keep this tool the same between branches.) Added a sanity check for all this to compile.c. Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
* GH-98831: Typed stack effects, and more instructions converted (#99764)Guido van Rossum2022-12-081-21/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Stack effects can now have a type, e.g. `inst(X, (left, right -- jump/uint64_t)) { ... }`. Instructions converted to the non-legacy format: * COMPARE_OP * COMPARE_OP_FLOAT_JUMP * COMPARE_OP_INT_JUMP * COMPARE_OP_STR_JUMP * STORE_ATTR * DELETE_ATTR * STORE_GLOBAL * STORE_ATTR_INSTANCE_VALUE * STORE_ATTR_WITH_HINT * STORE_ATTR_SLOT, and complete the store_attr family * Complete the store_subscr family: STORE_SUBSCR{,DICT,LIST_INT} (STORE_SUBSCR was alread half converted, but wasn't using cache effects yet.) * DELETE_SUBSCR * PRINT_EXPR * INTERPRETER_EXIT (a bit weird, ends in return) * RETURN_VALUE * GET_AITER (had to restructure it some) The original had mysterious `SET_TOP(NULL)` before `goto error`. I assume those just account for `obj` having been decref'ed, so I got rid of them in favor of the cleanup implied by `ERROR_IF()`. * LIST_APPEND (a bit unhappy with it) * SET_ADD (also a bit unhappy with it) Various other improvements/refactorings as well.
* GH-98831: Support cache effects in super- and macro instructions (#99601)Guido van Rossum2022-12-031-47/+102
|
* GH-98831: Add `macro` and `op` and their implementation to DSL (#99495)Guido van Rossum2022-11-231-11/+21
| | | | | | | | | | | | | | Newly supported interpreter definition syntax: - `op(NAME, (input_stack_effects -- output_stack_effects)) { ... }` - `macro(NAME) = OP1 + OP2;` Also some other random improvements: - Convert `WITH_EXCEPT_START` to use stack effects - Fix lexer to balk at unrecognized characters, e.g. `@` - Fix moved output names; support object pointers in cache - Introduce `error()` method to print errors - Introduce read_uint16(p) as equivalent to `*p` Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
* GH-98831: Refactor and fix cases generator (#99526)Guido van Rossum2022-11-181-31/+19
| | | | Also complete cache effects for BINARY_SUBSCR family.
* GH-98831: Implement basic cache effects (#99313)Guido van Rossum2022-11-161-48/+76
|
* GH-98831: Simple input-output stack effects for bytecodes.c (#99120)Guido van Rossum2022-11-081-21/+49
|
* GH-98831: Implement super-instruction generation (#99084)Guido van Rossum2022-11-061-4/+32
| | | Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
* GH-98831: "Generate" the interpreter (#98830)Guido van Rossum2022-11-031-0/+222
The switch cases (really TARGET(opcode) macros) have been moved from ceval.c to generated_cases.c.h. That file is generated from instruction definitions in bytecodes.c (which impersonates a C file so the C code it contains can be edited without custom support in e.g. VS Code). The code generator lives in Tools/cases_generator (it has a README.md explaining how it works). The DSL used to describe the instructions is a work in progress, described in https://github.com/faster-cpython/ideas/blob/main/3.12/interpreter_definition.md. This is surely a work-in-progress. An easy next step could be auto-generating super-instructions. **IMPORTANT: Merge Conflicts** If you get a merge conflict for instruction implementations in ceval.c, your best bet is to port your changes to bytecodes.c. That file looks almost the same as the original cases, except instead of `TARGET(NAME)` it uses `inst(NAME)`, and the trailing `DISPATCH()` call is omitted (the code generator adds it automatically).