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

core: store blocks as doubly-linked list on Region [2/2] #2795

Merged
merged 6 commits into from
Jul 1, 2024

Conversation

superlopuh
Copy link
Member

This migrates the blocks to be a doubly linked list.

@superlopuh superlopuh added the core xDSL core (ir, textual format, ...) label Jun 27, 2024
@superlopuh superlopuh self-assigned this Jun 27, 2024
Copy link

codecov bot commented Jun 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.81%. Comparing base (1a33911) to head (10c317e).

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #2795    +/-   ##
========================================
  Coverage   89.80%   89.81%            
========================================
  Files         396      396            
  Lines       48836    49010   +174     
  Branches     7480     7503    +23     
========================================
+ Hits        43857    44018   +161     
- Misses       3796     3803     +7     
- Partials     1183     1189     +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@math-fehr math-fehr left a comment

Choose a reason for hiding this comment

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

Makes sense to me, though I think we really should abstract away the double linked list.
I'm pretty sure we can abstract a DoubleLinkedList[T] class that will contain almost all of the logic, and then with a bit of inheritance we can get back what you have (in both blocks and operations).
Otherwise, I'm fine merging it like it is

@@ -283,46 +283,34 @@ def insert_op_before(op: Operation, new_op: Operation):
def move_region_contents_to_new_regions(region: Region) -> Region:
"""Move the region blocks to a new region."""
new_region = Region()
for block in region.blocks:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice

@superlopuh
Copy link
Member Author

It would be nice to have such an abstraction, but I would say that this is something we want to hide from users, at least the mutability aspect. Let's chat about this at some point.


def __len__(self):
return len(self._blocks)
i = 0
for _ in self:
Copy link
Contributor

Choose a reason for hiding this comment

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

why this way?

Copy link
Member Author

Choose a reason for hiding this comment

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

as opposed to enumerating or while (next := next.next) is not None?

Base automatically changed from sasha/ir/region-blocks to main June 29, 2024 07:35
@superlopuh superlopuh merged commit 043b8e8 into main Jul 1, 2024
10 checks passed
@superlopuh superlopuh deleted the sasha/ir/region-blocks-dll branch July 1, 2024 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core xDSL core (ir, textual format, ...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants