-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
GH-98831: Identify instructions that don't use oparg #100957
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
Changes from 3 commits
6f88a1d
eeba509
2abfe9a
bfcbffb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -168,9 +168,14 @@ def __init__(self, inst: parser.InstDef): | |
break | ||
self.unmoved_names = frozenset(unmoved_names) | ||
if self.register: | ||
fmt = "IBBB" | ||
num_regs = len(self.input_effects) + len(self.output_effects) | ||
num_dummies = (num_regs // 2) * 2 + 2 - num_regs | ||
fmt = "I" + "B"*num_regs + "_"*num_dummies | ||
gvanrossum marked this conversation as resolved.
Show resolved
Hide resolved
|
||
else: | ||
fmt = "IB" | ||
if variable_used(inst.block, "oparg"): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't know the actual opcode values yet, do we? If so, maybe we want to warn or something if this conflicts with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alas, we don't. I'd have to load opcode.py using the hack from your PR, which feels more infrastructure than I want to invest in for now (nothing is using the opcode metadata yet). |
||
fmt = "IB" | ||
else: | ||
fmt = "I_" | ||
cache = "C" | ||
for ce in self.cache_effects: | ||
for _ in range(ce.size): | ||
|
@@ -894,6 +899,11 @@ def always_exits(lines: list[str]) -> bool: | |
) | ||
|
||
|
||
def variable_used(block: parser.Block, name: str) -> bool: | ||
"""Determine whether a variable with a given name is used in a block.""" | ||
return any(token.kind == "IDENTIFIER" and token.text == name for token in block.tokens) | ||
|
||
|
||
def main(): | ||
"""Parse command line, parse input, analyze, write output.""" | ||
args = arg_parser.parse_args() # Prints message and sys.exit(2) on error | ||
|
Uh oh!
There was an error while loading. Please reload this page.