frontend: Add first operators for the python dialect as well as code generation from AST - #6243
frontend: Add first operators for the python dialect as well as code generation from AST#6243Saderfing wants to merge 15 commits into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #6243 +/- ##
==========================================
- Coverage 87.07% 87.02% -0.05%
==========================================
Files 433 438 +5
Lines 65231 65569 +338
Branches 7464 7490 +26
==========================================
+ Hits 56798 57060 +262
- Misses 6863 6931 +68
- Partials 1570 1578 +8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
this should be in xdsl/dialects/py.py
There was a problem hiding this comment.
xdsl/dialects/py/ directory already exist, should I use it ?
There was a problem hiding this comment.
Oh I forgot about that! That dialect models things closer to the bytecode, whereas your dialect is closer to the high-level AST. I'm now convinced that somewhere in the middle is best. I would probably first refactor the py directory to split it into ops and attrs kind of like riscv, and then add your code there, probably either replacing or extending those classes. The ObjectType is basically your Type, but I prefer the ObjectType name, for example.
There was a problem hiding this comment.
I would just add the name of the class to it
There was a problem hiding this comment.
I would suggest using part of it.
-
PyOperation and PyModuleOp seems nice
-
PyConstOp is not as general as the new PyConstantOp
-
PyBinOp will not do as we will use dunders
Do you agree ?
There was a problem hiding this comment.
Thinking a bit more, it feels like we might actually want two separate dialects. The existing py dialect should be renamed to pybytecode and your dialect should be the new py. I would not change the pybytecode dialect at all, just move it to pybytecode.py in dialects.
| @@ -0,0 +1,267 @@ | |||
| from __future__ import annotations | |||
There was a problem hiding this comment.
please add a file-level doc string describing what the aims are of this dialect. Short is great for now.
| def constr() -> AttrConstraint: | ||
| return AnyAttr() |
There was a problem hiding this comment.
should test for contents of data, right?
|
|
||
|
|
||
| @irdl_attr_definition | ||
| class ConstantValue(Data[Any]): |
There was a problem hiding this comment.
looks like this actually can only print and parse strings?
d692462 to
71e7b62
Compare
Contains a name field to show its content
Python dialect frontend
Implementing the first python attributs (types) and operators in xDSL including:
Implement a code generation from ast representation to the python dialect.