Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IRfmt derive #20

Closed
wants to merge 35 commits into from
Closed

IRfmt derive #20

wants to merge 35 commits into from

Conversation

urso
Copy link
Contributor

@urso urso commented Jan 12, 2024

No description provided.

@urso urso mentioned this pull request Jan 16, 2024
@vaivaswatha
Copy link
Owner

could we call this IR instead of ASM ? like irfmt, irparser, irprinter etc? assembly traditionally denotes machine instructions.

@urso urso mentioned this pull request Jan 21, 2024
vaivaswatha added a commit that referenced this pull request Jan 28, 2024
Backport from #20 

This PR introduces the `irfmt/printers` module with common printer functions.

In #20 we implement `asm_format` directives as macros. These macros will  use the printer functions defined here (and more to come). As secondary goal we want to make it easier for downstream developers to implement
their own printers, while trying to keep some kind of standardized format. For this reason we also implement Printable for some more IR objects in pliron.

The change also removes the `PrintableIter` trait in favor of the `list_with_sep` and `iter_with_sep` printer functions in the irfmt package. This change ensures that we have a single trait for printing in the library.

As discussed in #21 we do not require developers to add the type_id or
attribute_id manually to the printer anymore. `pliron` now implements a
printer for TypeObj/AttribObj that will always print the IDs.

---------

Co-authored-by: urso <steffen.siering at gmail.com>
Co-authored-by: Vaivaswatha N <[email protected]>
@urso urso changed the title Asmfmt derive IRfmt derive Feb 8, 2024
vaivaswatha pushed a commit that referenced this pull request Feb 8, 2024
This is an intermediary step backporting some changes from #20 into
main.

This PR focuses on moving the existing parsers into the `irfmt::parsers`
module. Idea is to have parsers (and helpers) under the `irfmt` module
for discoverability, similar to the `irfmt::printers` module.

In addition to that I implemented the `Parsable` trait for `AttrObj` and
`Ptr<TypeObj>` by copying the former `attr_parse` and `type_parse`
function as is into the trait. I did this change to improve symmetry: If
a type implements `Printable`, then it should implement `Parsable` as
well.

Besides implementing `Parsable` for the 2 types there is no change in
the implementation logic. Just moving symbols around.

Co-authored-by: urso <steffen.siering at gmail.com>
@urso urso mentioned this pull request Feb 18, 2024
vaivaswatha pushed a commit that referenced this pull request Mar 5, 2024
WIP implementation of Printable derive macro. Still need to add tests
and docstrings. The if format input parser has been updated to use
combine to ensure we have only a single parser combinator library within
the project.

Backport from #20 .

Follow ups
This PR only adds the Printable derive macro interpreting and
translating the ir format input. We still might have to add some of the
directives to pliron. The change is already quite big, so I opted to
split the effort here.

---------

Co-authored-by: urso <steffen.siering at gmail.com>
@vaivaswatha
Copy link
Owner

bd1e89e and 624378e together cover the beginnings of a format derive macro. So closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants