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

dialects: (x86) PR1 - Registers #2333

Merged
merged 12 commits into from
Mar 20, 2024
Merged

dialects: (x86) PR1 - Registers #2333

merged 12 commits into from
Mar 20, 2024

Conversation

KGrykiel
Copy link
Collaborator

This is the first of several pull requests that are intended to upstream the work from the KGrykiel/x86dialect branch. In this one I set up registers that are going to be used by the x86 dialect

@KGrykiel KGrykiel requested review from compor and tarinduj March 12, 2024 14:40
@KGrykiel KGrykiel self-assigned this Mar 12, 2024
@tarinduj tarinduj requested a review from superlopuh March 12, 2024 14:42
Copy link

codecov bot commented Mar 12, 2024

Codecov Report

Attention: Patch coverage is 91.89189% with 9 lines in your changes are missing coverage. Please review.

Project coverage is 89.56%. Comparing base (d51bcd0) to head (df1730d).
Report is 7 commits behind head on main.

Files Patch % Lines
xdsl/dialects/x86/register.py 83.01% 6 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2333      +/-   ##
==========================================
+ Coverage   89.53%   89.56%   +0.02%     
==========================================
  Files         335      341       +6     
  Lines       40327    40530     +203     
  Branches     6028     6037       +9     
==========================================
+ Hits        36108    36301     +193     
- Misses       3347     3353       +6     
- Partials      872      876       +4     

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

Copy link
Collaborator

@AntonLydike AntonLydike left a comment

Choose a reason for hiding this comment

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

LGTM! I assume there are more register types coming later on?

@KGrykiel
Copy link
Collaborator Author

yep, AVX registers are coming as well

Copy link
Collaborator

@webmiche webmiche left a comment

Choose a reason for hiding this comment

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

Could you add some tests for this? At least instantiate some of the registers in a filecheck test or something.

If you don't want to, feel free to move this to the experimental folder.

@webmiche
Copy link
Collaborator

(Sidenote: our naming standard says that the dialect name should be in brackets 😉 )

xdsl/dialects/x86.py Outdated Show resolved Hide resolved
xdsl/dialects/x86.py Outdated Show resolved Hide resolved
xdsl/dialects/x86.py Outdated Show resolved Hide resolved
@KGrykiel KGrykiel changed the title dialects: x86 dialect PR1 - Registers dialects: (x86) PR1 - Registers Mar 12, 2024
@KGrykiel
Copy link
Collaborator Author

Could you add some tests for this? At least instantiate some of the registers in a filecheck test or something.

If you don't want to, feel free to move this to the experimental folder.

I have some tests that use the register class, they'll be added in later PRs 👍

@superlopuh
Copy link
Member

Can you please add the tests in this PR so that we can review them at the same time as the code they're testing?

@KGrykiel
Copy link
Collaborator Author

the tests make use of the registers, but are for specific instructions so I can't add them until i also add the instructions. Unless you'd like me to write a test just for initialising a register?

@webmiche
Copy link
Collaborator

Yes, please, I think that would make sense 👍

@superlopuh superlopuh changed the title dialects: (x86) PR1 - Registers dialects: [x86] PR1 - Registers Mar 13, 2024
@superlopuh superlopuh changed the title dialects: [x86] PR1 - Registers dialects: (x86) PR1 - Registers Mar 13, 2024
@KGrykiel KGrykiel requested review from superlopuh and webmiche March 13, 2024 16:46
@KGrykiel
Copy link
Collaborator Author

let me know if this is what you had in mind

KGrykiel and others added 2 commits March 13, 2024 16:59
Co-authored-by: Sasha Lopoukhine <superlopuh@gmail.com>
@KGrykiel KGrykiel requested a review from superlopuh March 14, 2024 12:45
@KGrykiel
Copy link
Collaborator Author

formatting fails because of a star import in init, but not sure how to avoid it.

@KGrykiel KGrykiel requested a review from superlopuh March 14, 2024 19:19
@superlopuh
Copy link
Member

Looking great! Can you please take a look at the codecov, and cover the remaining lines? We don't always do this, but it feels like for such a foundational type it would be good to cover all the bases. For example, we don't have any tests for parsing and printing, but it would be good to add a filecheck test for these. Something like this:

%a = "test.op"() -> !x86.reg<rax>

@KGrykiel
Copy link
Collaborator Author

I have a filecheck coming up in next PRs that has just that by using the newly implemented instructions, so that base should be covered 👍

Copy link
Collaborator

@webmiche webmiche left a comment

Choose a reason for hiding this comment

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

A couple more comments from my side.

tests/dialects/test_x86.py Outdated Show resolved Hide resolved
from xdsl.utils.exceptions import VerifyException


class X86RegisterType(RegisterType):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do you have both x86RegisterType or GeneralRegisterType and both have the same description?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

x86RegisterType is the parent class for multiple types of register collections. Other than GeneralRegisterType, AVXRegisterType will also inherit from it. A similar system has been implemented in the riscv dialect

Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you somehow represent this in the documentation? One might be an abstract registertype, the other one a specifically scalar registertype

Copy link
Member

Choose a reason for hiding this comment

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

Ah, that's a good idea

Suggested change
class X86RegisterType(RegisterType):
import abc
class X86RegisterType(RegisterType, abc.ABC):

Having it marked as explicitly abstract and not possible to instantiate would be useful in itself

xdsl/dialects/x86/register.py Show resolved Hide resolved
@superlopuh
Copy link
Member

I appreciate that they'll be further covered in downstream PRs, but it would still be worth adding the tests for the code being added in the same PR, so we can review the two together. I don't know what the tests are that are still upcoming, so I cannot say now whether they will cover the functionality introduced here in the future.

@KGrykiel
Copy link
Collaborator Author

Ok, will add a filecheck now as well then 🫡

@KGrykiel KGrykiel requested review from webmiche and superlopuh March 18, 2024 13:15
KGrykiel and others added 2 commits March 18, 2024 14:58
Co-authored-by: Sasha Lopoukhine <superlopuh@gmail.com>
Copy link
Member

@superlopuh superlopuh left a comment

Choose a reason for hiding this comment

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

Looks perfect, thank you!

Copy link
Collaborator

@webmiche webmiche left a comment

Choose a reason for hiding this comment

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

Nice, LGTM now. I agree that marking the X86RegisterType as an ABC would make a lot of sense, but if you don't think so, that's fine as well.

@AntonLydike AntonLydike added the dialects Changes on the dialects label Mar 19, 2024
@KGrykiel KGrykiel merged commit 3db731f into main Mar 20, 2024
10 checks passed
@KGrykiel KGrykiel deleted the KGrykiel/x86dialect-PRs branch March 20, 2024 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dialects Changes on the dialects
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants