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

Add support for binary/octal literals to ISLE #6234

Merged
merged 3 commits into from
Apr 18, 2023

Conversation

alexcrichton
Copy link
Member

In a number of x64-changes recently some u8 immediates are interpreted as four bit-packed 2-bit numbers and I have a tough time going between hex and these bit-packed numbers. I've been writing 0xAA == 0b... in comments to indicate the intent but I figured it'd be a bit clearer if the binary literal was accepted directly!

This is a minor update to the ISLE lexer to allow for binary 0b00... and octal 0o00... literals in the same manner as hex literals. Some comments in the x64 backend are then removed to use the binary literal syntax directly.

In a number of x64-changes recently some u8 immediates are interpreted
as four bit-packed 2-bit numbers and I have a tough time going between
hex and these bit-packed numbers. I've been writing `0xAA == 0b...` in
comments to indicate the intent but I figured it'd be a bit clearer if
the binary literal was accepted directly!

This is a minor update to the ISLE lexer to allow for binary `0b00...`
and octal `0o00...` literals in the same manner as hex literals. Some
comments in the x64 backend are then removed to use the binary literal
syntax directly.
@alexcrichton alexcrichton requested a review from a team as a code owner April 18, 2023 19:44
@alexcrichton alexcrichton requested review from abrown and removed request for a team April 18, 2023 19:44
Copy link
Member

@cfallin cfallin left a comment

Choose a reason for hiding this comment

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

Nice improvement, thanks!

If it's not too much, would you mind adding uses of a binary and octal literal to the ISLE testsuite (the slightly-misnamed cranelift/isle/isle/isle_examples)? The run/iconst.isle / run/iconst_main.rs test does a bunch of assertions with hex literals so seems like a good place for this.

@cfallin
Copy link
Member

cfallin commented Apr 18, 2023

Also a sentence somewhere in the language reference to note that binary + octal are accepted would be good, I think.

@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator cranelift:area:x64 Issues related to x64 codegen isle Related to the ISLE domain-specific language labels Apr 18, 2023
@github-actions
Copy link

Subscribe to Label Action

cc @cfallin, @fitzgen

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:

  • cfallin: isle
  • fitzgen: isle

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

@alexcrichton alexcrichton added this pull request to the merge queue Apr 18, 2023
Merged via the queue into bytecodealliance:main with commit b6bb6a1 Apr 18, 2023
@alexcrichton alexcrichton deleted the binary-literals branch April 18, 2023 23:49
eduardomourar pushed a commit to eduardomourar/wasmtime that referenced this pull request Apr 28, 2023
* Add support for binary/octal literals to ISLE

In a number of x64-changes recently some u8 immediates are interpreted
as four bit-packed 2-bit numbers and I have a tough time going between
hex and these bit-packed numbers. I've been writing `0xAA == 0b...` in
comments to indicate the intent but I figured it'd be a bit clearer if
the binary literal was accepted directly!

This is a minor update to the ISLE lexer to allow for binary `0b00...`
and octal `0o00...` literals in the same manner as hex literals. Some
comments in the x64 backend are then removed to use the binary literal
syntax directly.

* Update ISLE reference for octal/binary

* Update ISLE tests for octal/binary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cranelift:area:x64 Issues related to x64 codegen cranelift Issues related to the Cranelift code generator isle Related to the ISLE domain-specific language
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants