-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-105481: refactor instr flag related code into a new InstructionFlags class #105950
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like refactoring this, but I'd like to go a little beyond just packaging up the old code in a class.
@@ -803,7 +861,7 @@ def analyze_macro(self, macro: parser.Macro) -> MacroInstruction: | |||
for _ in range(ce.size): | |||
format += cache | |||
cache = "0" | |||
flags |= instr.flags | |||
flags.add(instr.instr_flags) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point, in my optimizer work, I have a need to prevent one flag ("IS_UOP") from being propagated. How would you do that using the new API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add an arg to this function to tell it which flags to skip?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, something like exclude: set[str] | None = None
would work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add it when we need it. I don't like adding code that is neither used nor tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can add it after I merge your code into gh-105924.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
It's doing this now that I removed the hash and eq:
|
Oh dang. Dataclasses don't generate a hash by default. You can either put the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works too!
I changed it to not hash the data class object but the bitmap representation. It's just for an assertion that all the flags of a pseudo-op's targets are the same. |
This will help later when we want to use the flags for things like generating hasarg, etc.