-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
x64: Add support for the shld
instruction
#10233
Conversation
I'm opening this as a draft PR because #10232 should land first and this should rebase on top of that. In talking with Andrew I temporarily came up with the "solution" in this PR but our conclusion was that #10232 was the better way to go in terms of robustly supporting this encoding pattern in x64 instructions. |
(also cc @abrown) |
Subscribe to Label Action
This issue or pull request has been labeled: "cranelift", "cranelift:area:x64", "isle"
Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
This commit is similar to bytecodealliance#10229 except that it uses the x64 `shld` instruction. This instruction was not previously supported by Cranelift so I opted to add support via the new `cranelift-assembler-x64` crate instead of trying to fit it into the existing `emit.rs`/`MInst` infrastructure. This was a good learning experience for myself and was also fun to do!
a3834d2
to
67789fe
Compare
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.
Makes sense to me!
.operands | ||
.iter() | ||
.rev() |
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.
Huh... let's try this but I'm not sure.
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.
Heh agreed! I figure we'll need to add more heuristics here eventually to figure out how to print and still match att/capstone ordering.
@@ -332,7 +335,7 @@ impl From<[u8; 3]> for Opcodes { | |||
fn from(bytes: [u8; 3]) -> Opcodes { | |||
let [a, b, c] = bytes; | |||
match (LegacyPrefix::try_from(a), b, c) { | |||
(Ok(prefix), 0x0f, primary) => Opcodes { prefix, escape: false, primary, secondary: None }, | |||
(Ok(prefix), 0x0f, primary) => Opcodes { prefix, escape: true, primary, secondary: None }, |
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.
Good catch!
This commit is similar to #10229 except that it uses the x64
shld
instruction. This instruction was not previously supported by Cranelift so I opted to add support via the newcranelift-assembler-x64
crate instead of trying to fit it into the existingemit.rs
/MInst
infrastructure. This was a good learning experience for myself and was also fun to do!