-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Opcode metadata auto generation #6174
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
Draft
ShaharNaveh
wants to merge
44
commits into
RustPython:main
Choose a base branch
from
ShaharNaveh:instruction-autogen
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
21d9632
POC: automated instruction gen
ShaharNaveh f6ab8d2
Add generated file
ShaharNaveh b8ebe9b
Add note about pseudos opcode
ShaharNaveh 8510815
Use `properties.oparg` instead
ShaharNaveh bcea0bf
Sort by id. impl TryFrom
ShaharNaveh c7ffa2a
Have `is_valid` as a seperate method
ShaharNaveh f1948c6
Include in tree
ShaharNaveh 84c7f45
Impl `has_X` methods
ShaharNaveh 9adf908
is_pseudo
ShaharNaveh 99ed360
Set `Self::`
ShaharNaveh 56c0dc8
refactor
ShaharNaveh 3fdc479
impl num_{pushed,popped}
ShaharNaveh 5cf1888
Resolve some errors
ShaharNaveh eaee21e
Sort like cpython does it
ShaharNaveh acd74c7
Make more things compile
ShaharNaveh f71ad1b
Don't use the new Instruction yet
ShaharNaveh b860f65
pivot to only generating opcodeid atm
ShaharNaveh ff4fb09
Remove `enum` related code
ShaharNaveh 493da32
Use `OpcodeId` in `_opcode`
ShaharNaveh 657660f
add auto generated file to .gitattributes
ShaharNaveh eacab03
clippy
ShaharNaveh 7b36086
Apply coderabbit suggestion
ShaharNaveh dd761d0
Switch back to enum
ShaharNaveh aeedbdc
Re-add `num_{popped,pushed}`
ShaharNaveh 33a90f3
Improve `_opcode.stack_effect`
ShaharNaveh 4a11f38
Add missing dis attrs for tests
ShaharNaveh 029e534
Unmark passing tests
ShaharNaveh 11369f8
More changes to `dis.py` from 3.13.7
ShaharNaveh a5813ea
Add reason for failing tests
ShaharNaveh 6e6accd
Base `Opcode` impl
ShaharNaveh f8a887a
clippy
ShaharNaveh a2014b5
Fix another test
ShaharNaveh 6c48b49
clippy
ShaharNaveh 46f3e29
clippy
ShaharNaveh 742b709
cspell
ShaharNaveh 2a8fb1e
Add `new_unchecked`
ShaharNaveh 465528e
More docs
ShaharNaveh e437232
unused import
ShaharNaveh 1ae0c7e
nits
ShaharNaveh 28bab70
Trigger CI
ShaharNaveh fe3f94a
Merge remote-tracking branch 'upstream/main' into instruction-autogen
ShaharNaveh aca4508
Use `num_enum` for opcode enums
ShaharNaveh 3daec5a
Remove unused code
ShaharNaveh 9436354
typo
ShaharNaveh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ cellvar | |
| cellvars | ||
| cmpop | ||
| denom | ||
| deopt | ||
| dictoffset | ||
| elts | ||
| excepthandler | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| use crate::marshal::MarshalError; | ||
| pub use crate::opcodes::{PseudoOpcode, RealOpcode}; | ||
|
|
||
| #[derive(Copy, Clone, Debug, Eq, PartialEq)] | ||
| pub enum Opcode { | ||
| Real(RealOpcode), | ||
| Pseudo(PseudoOpcode), | ||
| } | ||
|
|
||
| impl TryFrom<u16> for Opcode { | ||
| type Error = MarshalError; | ||
|
|
||
| fn try_from(raw: u16) -> Result<Self, Self::Error> { | ||
| // Try first pseudo opcode. If not, fallback to real opcode. | ||
| PseudoOpcode::try_from(raw) | ||
| .map(Opcode::Pseudo) | ||
| .or_else(|_| { | ||
| Self::try_from(u8::try_from(raw).map_err(|_| Self::Error::InvalidBytecode)?) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| impl TryFrom<u8> for Opcode { | ||
| type Error = MarshalError; | ||
|
|
||
| fn try_from(raw: u8) -> Result<Self, Self::Error> { | ||
| // u8 can never be a pseudo. | ||
| RealOpcode::try_from(raw).map(Opcode::Real) | ||
| } | ||
| } | ||
|
|
||
| macro_rules! impl_try_from { | ||
| ($struct_name:ident, $($t:ty),+ $(,)?) => { | ||
| $( | ||
| impl TryFrom<$t> for $struct_name { | ||
| type Error = MarshalError; | ||
|
|
||
| fn try_from(raw: $t) -> Result<Self, Self::Error> { | ||
| Self::try_from(u16::try_from(raw).map_err(|_| Self::Error::InvalidBytecode)?) | ||
| } | ||
| } | ||
| )+ | ||
| }; | ||
| } | ||
|
|
||
| impl_try_from!( | ||
| Opcode, i8, i16, i32, i64, i128, isize, u32, u64, u128, usize | ||
| ); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.