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) PR5_2 - single operand instructions - one destination #2455

Merged
merged 4 commits into from
Apr 19, 2024

Conversation

KGrykiel
Copy link
Collaborator

next part of PR #2398. added the case where the single operand is a destination + the pop operation

@KGrykiel KGrykiel added the dialects Changes on the dialects label Apr 12, 2024
@KGrykiel KGrykiel self-assigned this Apr 12, 2024
Copy link

codecov bot commented Apr 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.81%. Comparing base (eb83cde) to head (42766fe).
Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2455      +/-   ##
==========================================
+ Coverage   89.77%   89.81%   +0.03%     
==========================================
  Files         350      350              
  Lines       42747    42878     +131     
  Branches     6353     6370      +17     
==========================================
+ Hits        38376    38510     +134     
+ Misses       3434     3423      -11     
- Partials      937      945       +8     

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

@@ -320,6 +320,39 @@ class PushOp(ROperationSrc[GeneralRegisterType]):
name = "x86.push"


class ROperationDst(Generic[R1InvT], SingleOperandInstruction):
Copy link
Member

Choose a reason for hiding this comment

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

This instruction doesn't have any operands, am I missing something?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is by design although worth discussing. The pop function moves data from the top of the stack to a destination register. Whatever is inside the register is irrelevant, so I thought it best to only designate it as a result rather than an operand.

Copy link
Member

Choose a reason for hiding this comment

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

That's exactly the right design, IMO, I don't see why inherit from that class

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oh, right, in that sense. I used the single/double/tripleOperandInstruction classes as a way to differentiate the instructions over how they look in assembly. In the sense how many arguments, whatever that may be, an assembly instruction takes. I suppose pop creates this kind of gray area where the assembly instruction takes an argument (i.e. "pop rax") but it's not really an operand.

In hindsight this might be a little confusing, but I'm not sure how best to handle the software engineering aspect of class hierarchy in this case. Now that I've implemented more instructions since first devising the plan, I couldn't find anything meaningful to put in the single/double/tripleOperandInstruction parent classes so perhaps it's best to get rid of them all together and have everything inherit from x86Instruction directly?

I'm fine with whatever you think is best tbh

Copy link
Member

Choose a reason for hiding this comment

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

I think we might as well get rid of them, we have another bunch of abstract class helpers for the inits already, so we might as well drop the marker classes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, I opened a new issue for removing the parent classes (#2466), I'll do it later because now it would mess up merging for the other PR I have open.

Going forward with this, would you rather I categorize the instructions by the number of arguments the assembly instruction takes or by the actual number of operands including the intrinsic ones? In this example the 'push' instruction for instance could be an ROperation (because in the assembly it would look like 'push rdx') or an RR Operation (because it technically affects 2 registers). What are your thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't think of it as a big taxaonomy, the only reason we added it to riscv was to have less duplication of code for the initializers, I'd just group them by the init signature and not overthink it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think our current parent class naming convention (eg: add rax, rbx: RROperatio) only makes sense when one of the operands is also the result. IMO renaming the parent classes to reflect other cases as well would make more sense. Something like [Result]-[Operands]-Operation (eg: add rax, rbx: R-RR-Operation). So, push would technically be M-R-Operation (because it's dereferencing rsp)?

I think it would be helpful to de-sugar the assembly and keep the information explicitly in the SSA.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's also an option, i can change that in a fell swoop with the removal of the parent classes 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

If not, we can think of push and pop as a mov and do the same thing we do there. Whichever makes more sense.

Base automatically changed from KGrykiel/x86dialect-PRs5 to main April 16, 2024 11:01
@KGrykiel KGrykiel force-pushed the KGrykiel/x86dialect-PRs5_2 branch from 46f8614 to 62a87fe Compare April 16, 2024 11:49
@KGrykiel KGrykiel requested a review from superlopuh April 18, 2024 12:52
@KGrykiel
Copy link
Collaborator Author

@tarinduj @superlopuh let me know if this is what you had in mind regarding %rsp. If so I imagine I'll have to give the same treatment to the 'push' instruction in a different PR.

@KGrykiel KGrykiel merged commit 34fb769 into main Apr 19, 2024
10 checks passed
@KGrykiel KGrykiel deleted the KGrykiel/x86dialect-PRs5_2 branch April 19, 2024 13:19
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
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants