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) PR18 - m_pop + added rsp dataflow to push #2560

Merged
merged 3 commits into from
May 12, 2024

Conversation

KGrykiel
Copy link
Collaborator

@KGrykiel KGrykiel commented May 10, 2024

Added the memory variant of the pop function and the dataflow of the rsp register for the push operations. Also reformatted a bit to remove unncecessary parent functions as im pretty sure pop and push are unique in their workings.

Do let me know if you know of a better way to do m.pop because the current way is a bit hacked

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

codecov bot commented May 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.75%. Comparing base (eeb7132) to head (db6263a).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2560      +/-   ##
==========================================
- Coverage   89.77%   89.75%   -0.03%     
==========================================
  Files         354      354              
  Lines       44663    44771     +108     
  Branches     6698     6717      +19     
==========================================
+ Hits        40095    40182      +87     
- Misses       3591     3606      +15     
- Partials      977      983       +6     

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


rsp_input = operand_def(GeneralRegisterType("rsp"))
destination = operand_def(
R1InvT
Copy link
Member

Choose a reason for hiding this comment

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

This seems off, shouldn't it be a Generic parameter?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure what you mean? I define operands the same way in all the other instructions inheriting directly from IRDLOperation. It wouldn't let me pass Generic arguments iirc.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, not sure how I missed this. This is a TypeVar, it's designed to be passed to Generic at the type level. When used like this, it's not any different to just passing the bound of the TypeVar, and possibly technically invalid Python, in my understanding. I'd say we should either make the base classes generic in their register types, or switch the operand constraints to pass the bound instead.

rsp_input = operand_def(GeneralRegisterType("rsp"))
destination = operand_def(
R1InvT
) # not an operand, but couldn't think of a better way to make it part of the IR
Copy link
Member

Choose a reason for hiding this comment

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

Can you please describe what's happening and what you're aming for a bit more?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So the problem is that the value within that memory location doesn't matter so it's not really an operand. We did it in a similar way in the register version of pop. In this case however the destination is a memory access, not a register so no SSA value is created either. As such, I didn't see any way to include the information of what the memory access actually is in the IR because it doesn't fit neither operand_def nor result_def.

Copy link
Member

Choose a reason for hiding this comment

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

The register holds a pointer, not a value, right? My understanding right now is that an operand is clearly the way to model this, although maybe I'm missing something. Could you maybe explain the relevant values in registers and memory before and after this instruction is executed? The link in the docstring is not very clear.

@@ -300,59 +300,61 @@ class RR_MovOp(R_RR_Operation[GeneralRegisterType, GeneralRegisterType]):
name = "x86.rr.mov"


class M_R_Operation(Generic[R1InvT], IRDLOperation, X86Instruction, ABC):
@irdl_op_definition
class R_PushOp(IRDLOperation, X86Instruction, ABC):
Copy link
Member

@superlopuh superlopuh May 11, 2024

Choose a reason for hiding this comment

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

This seems to not be an ABC any more

@KGrykiel KGrykiel requested a review from superlopuh May 12, 2024 14:35
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.

LGTM. The whole pointer thing seems pretty standard, there are lots of operations with side effects with similar signatures, like memref.store

Co-authored-by: Sasha Lopoukhine <superlopuh@gmail.com>
@KGrykiel KGrykiel merged commit d20a4e5 into main May 12, 2024
10 checks passed
@KGrykiel KGrykiel deleted the KGrykiel/x86dialect-PRs18 branch May 12, 2024 21:37
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.

2 participants