Skip to content
This repository was archived by the owner on Dec 22, 2021. It is now read-only.

Reorganize opcodes by kind and type #48

Merged
merged 2 commits into from
Nov 5, 2018
Merged

Reorganize opcodes by kind and type #48

merged 2 commits into from
Nov 5, 2018

Conversation

tlively
Copy link
Member

@tlively tlively commented Oct 26, 2018

This is yet another opcode renumbering.

I tried to take into account all the comments on #42, particularly @binji's comment about trying to be consistent with the MVP opcode ordering. I also left explicit gaps in the chart for what I think should be reserved opcodes to make the reserved opcodes easier to see and talk about for the time being.

Feedback welcome!

cc @dtig

| `i16x8.all_true` | `0x6e`| - |
| `i32x4.add` | `0x6f`| - |
| - | `0x70`| - |
| - | `0x71`| - |
Copy link
Member Author

Choose a reason for hiding this comment

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

Reserved for saturating adds.

Copy link
Member

Choose a reason for hiding this comment

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

There are no hardware instructions that map to saturating arithmetic for i32x4, and i64x2 types that I know of, so I'm unsure if this will ever be useful - but the opcode space is large enough that this looks ok to me. Same for the other saturating operations below.

| `i16x8.sub_saturate_u` | `0x65`| - |
| `i16x8.mul` | `0x66`| - |
| - | `0x67`| - |
| - | `0x68`| - |
Copy link
Member Author

Choose a reason for hiding this comment

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

Reserved for min/max.

| `i8x16.sub_saturate_u` | `0x56`| - |
| `i8x16.mul` | `0x57`| - |
| - | `0x58`| - |
| - | `0x59`| - |
Copy link
Member Author

Choose a reason for hiding this comment

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

Reserved for min/max.

| - | `0x41`| - |
| - | `0x42`| - |
| - | `0x43`| - |
| - | `0x44`| - |
Copy link
Member Author

Choose a reason for hiding this comment

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

Reserved space for all possible i64x2 comparisons.

| - | `0x71`| - |
| `i32x4.sub` | `0x72`| - |
| - | `0x73`| - |
| - | `0x74`| - |
Copy link
Member Author

Choose a reason for hiding this comment

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

Reserved for saturating subtractions.

| - | `0x74`| - |
| `i32x4.mul` | `0x75`| - |
| - | `0x76`| - |
| - | `0x77`| - |
Copy link
Member Author

Choose a reason for hiding this comment

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

Reserved for min/max.

| `i32x4.all_true` | `0x7d`| - |
| `i64x2.add` | `0x7e`| - |
| - | `0x7f`| - |
| - | `0x80`| - |
Copy link
Member Author

Choose a reason for hiding this comment

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

Reserved for saturating adds.

| - | `0x83`| - |
| - | `0x84`| - |
| - | `0x85`| - |
| - | `0x86`| - |
Copy link
Member Author

Choose a reason for hiding this comment

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

Reserved for saturating subtractions, multiply, and min/max.

@arunetm
Copy link
Collaborator

arunetm commented Oct 30, 2018

@tlively Are you planning to do any further changes to the opcode sequence? Its better to combine all reorganizations that seem fit as a single PR.

This is to make it easier for the toolchain and implementations to incorporate the changes.

@tlively
Copy link
Member Author

tlively commented Oct 30, 2018

@aretmr No, I don't plan further changes. This PR is an attempt to combine and finalize all of the reorganizations that are currently in flight. If anyone has any other ideas for reorganization, we should discuss and incorporate them before merging so we can do just one change to bring everything into alignment everywhere.

Copy link
Member

@dtig dtig left a comment

Choose a reason for hiding this comment

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

This looks much nicer than #42 that I had open, so I'll go ahead and close that in favor of this one.

| `f64x2.splat` | `0x15`| - |
| `f64x2.extract_lane` | `0x16`| i:LaneIdx2 |
| `f64x2.replace_lane` | `0x17`| i:LaneIdx2 |
| `v128.and` | `0x18`| - |
Copy link
Member

Choose a reason for hiding this comment

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

These should be moved to after the comparisons.

| `i16x8.all_true` | `0x6e`| - |
| `i32x4.add` | `0x6f`| - |
| - | `0x70`| - |
| - | `0x71`| - |
Copy link
Member

Choose a reason for hiding this comment

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

There are no hardware instructions that map to saturating arithmetic for i32x4, and i64x2 types that I know of, so I'm unsure if this will ever be useful - but the opcode space is large enough that this looks ok to me. Same for the other saturating operations below.

| `i8x16.shr_s` | `0x5b`| - |
| `i8x16.shr_u` | `0x5c`| - |
| `i8x16.neg` | `0x5d`| - |
| `i8x16.any_true` | `0x5e`| - |
Copy link
Member

Choose a reason for hiding this comment

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

It makes sense to me to consistently adopt use v8x16 for sign agnostic operations, it's a little weird to me that we do this only for v8x16.shuffle. Thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

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

Also think that using v8x16 for only shuffles is weird (see #38), but I think keeping i8x16 and friends for sign-agnostic operations that still only make sense for integer lanes is reasonable. To counter, what do you think of changing shuffle to be v128.shuffle?

Copy link
Member

Choose a reason for hiding this comment

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

Using v8x16.shuffle makes sense because it's a generic byte shuffle, so the name is more indicative than a v128.shuffle, but I don't feel strongly about which way we go here.

@dtig dtig mentioned this pull request Nov 2, 2018
@tlively tlively merged commit a4ab55f into master Nov 5, 2018
@tlively tlively deleted the tlively-opcodes branch November 5, 2018 19:40
| `i8x16.shl` | `0x5a`| - |
| `i8x16.shr_s` | `0x5b`| - |
| `i8x16.shr_u` | `0x5c`| - |
| `i8x16.neg` | `0x5d`| - |
Copy link
Member

Choose a reason for hiding this comment

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

Just noticed this while updating wabt: the MVP instructions group unary and binary ops together by type, but have unary before binary, e.g.:

opcode name
0x67 i32.clz
0x68 i32.ctz
0x69 i32.popcnt
0x6a i32.add
...

| `f32x4.div` | `0x90`| - |
| `f32x4.min` | `0x91`| - |
| `f32x4.max` | `0x92`| - |
| `f32x4.neg` | `0x93`| - |
Copy link
Member

Choose a reason for hiding this comment

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

The MVP instructions have the order abs, neg, sqrt

@tlively
Copy link
Member Author

tlively commented Nov 7, 2018

@binji, I notice the MVP instructions have trunc mixed in with arithmetic floating point ops, but I'm in favor of keeping it and other conversion instructions separate here. Thoughts?

@tlively tlively mentioned this pull request Apr 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants