-
Notifications
You must be signed in to change notification settings - Fork 452
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
Merge SIMD proposal #1391
Merge SIMD proposal #1391
Conversation
…o_int64 and of_int64
Implement i16x8 operations
Implement add sub neg for i8x16, this passes simd_i8x16_arith.wast.
Merge upstream
This passes simd_i8x16_arith2.wast.
Add i64x2.{neg,add,sub,mul}, now simd/simd_i64x2_arith.wast passes.
* Update v128.const implementation status for v8 * Add note about Chrome version
Not, and, or, xor, andnot. Create V128 submodule for vector bitwise ops, converting to i64x2 for the actual operations
{i8x16,i16x8,i32x4}_{any_true,all_true} v128.bitselect is used in the tests (simd_boolean.wast) so implemented here using a new AST node, Ternary. Bitselect is the only ternary instruction now.
Packed data is not defined anywhere. We can specify SIMD as a i128 (128-bit integer). Later when specifying the SIMD instructions, we can use some "expansions" to expand i128 into the required lane shapes. Also, use v128 instead of s128, v128 is already commonly used in many places in this proposal, in the BinarySIMD.md, SIMD.md, and reference interpreter.
i8x16, i16x8, i32x4, i64x2, f32x4, f64x2 splats. Implemented using Convert ast as a splat essentially takes a value of every other type to V128.
shr_u is a bit more tricky due for I8 and I16. E.g. -128 in I8 has all top bits set (sign extended) in an int32, and shr_u using Int's implementation will result in 0xffffffc0, instead of 0x000000c0. But we can't simply change the implementation, since parsing relies on this behavior. I'll figure that out in a later patch.
Lost the token in the parser during rebases.
i8x16, i16x8, i32x4, i64x2 eq, ne, lt_s, lt_u, le_s, le_u, gt_s, gt_u, ge_s, ge_u. Implemented in terms of Binary operations, since they return the same v128 type, rather than a boolean like for I32 and I64. Lanes that compare true return all 1s, otherwise all 0s.
f32x4, f64x2 eq, ne, lt, le, gt, ge. Similar to integer comparisons, this is implemented with the Binary ast node.
This got lost in the rebase too, and WebAssembly#277 only partially fixed it.
The Bytes [0] functions we use require 4.08.1. This should only be set on SIMD repo, since bytes is only used for SIMD implementation. By the time we would like to merge this back into main spec, 4.08.1 should hopefully be widespread enough for us to bump minimum version of OCaml for spec to 4.08.1 too. [0] https://caml.inria.fr/pub/docs/manual-ocaml/libref/Bytes.html see "Binary encoding/decoding of integers"
i8x16, i16x8, i64x2, f64x2. Created a new extractop that is based on v128op. Use extension type to determine signed or unsigned extract (only used for i8x16 and i16x8).
Decided to cheat a little bit, and squeeze v8x16.swizzle into the i8x16 ast node, so that we don't have to create a new v8x16 data type. Semantically it means the same thing, v8x16 is called that way since it doesn't treat the underlying data as any particular type, so treating it as int will work too.
The error messages don't match the tests yet (simd_lane.wast), that still needs to be worked out in WebAssembly#287.
- lane indices are u8 (nats), negative values are now parse errors ("unexpected token"), as are values with a positive sign +0x1 - changed a bunch of "expected i8 literal" to "unexpected token", in order to differentiate these syntax errors we probably need to change the parser to match on a bunch of EXTRACT_LANE <token we don't care about> - some "type mismatch" are now unexpected token Fixed WebAssembly#287
Merge upstream
It was incorrectly using the non-saturing versions, leading to runtime traps.
* Extract lane, parse error for i8x16 and i16x8 * Parse error if simd lane index cannot fit in u8 * Validate lane index in extract and replace
I can use the "Squash and merge" button when merging this PR, that should achieve the same thing? |
I suppose that works, yes. Thanks. |
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.
Thanks for putting this together! Please wait for a review from @rossberg as well.
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.
Thanks! This PR is so large that the GitHub UI broke down on me...
I focussed on the places where this PR changes existing spec text and discovered a few small oversights that should be easy to fix.
Perhaps more seriously, I noticed only now that the implementation of packed int types in the interpreter is probably insufficient/incorrect as is. Better to fix this before landing.
Do you prefer I make changes as commits to this PR, or make changes to upstream simd repo, then update this PR? (the end result will be the same, a single commit to merge simd, but thinking which would be easier for your to review) Edit: made a PR to simd repository here WebAssembly/simd#527 |
Based on comments from WebAssembly/spec#1391.
Based on comments from WebAssembly#1391.
Previously, i8 and i16 was careless w.r.t. the top bits, because they were only used by v128, which uses Bytes.get/set that appropriate masks the top bits when storing into the byte array. With this change, i8 and i16 are self contained small integers implemented using int32. They are always stored signed-extended, e.g. INT8_MIN (-128) is stored as 0xffffff80. This requires adding sign-extension operation (Rep.sx) in a couple of places, that will make sure to extend the sign bit to the rest of the int32. Also add a small, non-exhaustive test for these small integers in a new file tests/smallint.ml. This is the first ml test we are adding (all previous tests are wasm/wast tests that we run using the interpreter), so there are some modifications to the Makefile to build and run this test (make smallinttest, make test will also run it). This test is in the tests/ folder to avoid a conflict with a Makefile goal test/x to run x.wast in ../test/core, otherwise it tries to run smallint.ml as a wast test. Co-authored-by: Andreas Rossberg <rossberg@mpi-sws.org>
Merge upstream
This is good to review, thanks! |
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.
Excellent, thanks a lot!
"+100,917 -690" -- just wow.
For fun, lines of changes, breakdown by filetype: awk scriptgit show f5a260a --stat | awk '$1 ~ /.wast$/ { wast += $3 }wast: 81666 (most of which are generated by py scripts) |
@@ -34,12 +35,14 @@ or *external references* pointing to an uninterpreted form of :ref:`extern addre | |||
\I64.\CONST~\i64 \\&&|& | |||
\F32.\CONST~\f32 \\&&|& | |||
\F64.\CONST~\f64 \\ | |||
\production{(vector)} & \vecc &::=& | |||
\V128.\CONST~\i128 \\ |
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.
is there any documentation we can refer to that clarifies why this is v128.const and not i128.const for declaring an i128? Or is this possibly a bug in the spec?
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.
I guess it is a shortcut rather than declaring i128.const and then another vector instruction that produces it? nevertheless is there a plan or explicit plan against i128.const?
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.
It's just abstract syntax. It says v128.const because it represents a v128. The fact that the value itself is represented as an i128 – as opposed to e.g. some selected shape – is just a modelling choice. We made it because the interpretation of a vector's shape is per instruction, and i128 makes it easiest to specify reinterpretation as either of them. Similar to ints not being inherently signed but being explicitly reinterpreted.
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.
PS: As for documentation, that is essentially said in https://webassembly.github.io/spec/core/syntax/values.html#vectors
* [spec] Add reference types to overview (WebAssembly#1394) * [interpreter] Remove use of physical equality on characters (WebAssembly#1396) * Merge SIMD proposal (WebAssembly#1391) SIMD is [phase 5](WebAssembly/simd#507), merge all the changes back into main spec. * Remove merge conflict marker * [spec] Handle v128 in validation algorithm (WebAssembly#1399) * [spec] Fix instruction table (WebAssembly#1402) * Add tests for functions without end marker. NFC (WebAssembly#1405) Inspired by this downstream test in wabt: WebAssembly/wabt#1775 Fixes: WebAssembly#1404 * Describe correct tail call behavior across modules Whether tail calls across module boundaries would guarantee tail call behavior was previously an open question, but @thibaudmichaud confirmed that they would guarantee tail call behavior in V8 in WebAssembly/tail-call#15 (comment). * [interpreter] Fix a typo in README (WebAssembly#1406) * Add a link to the proposals repo (WebAssembly#1409) Fixes WebAssembly#1407. * [spec] Add note regarding parameter names (WebAssembly#1412) * Comments WIP * Merge upstream (WebAssembly#55) * Typo * [spec] Clarifying note on text format (WebAssembly#1420) Signed-off-by: Adrian Cole <adrian@tetrate.io> Co-authored-by: Andreas Rossberg <rossberg@mpi-sws.org> * Eps * Eps * [test] Fix section size in binary test (WebAssembly#1424) * Update document README to install six * Disallow type recursion (WebAssembly#56) * Fix import order * Add --generate-js-only flag to test runner This will return early right after generating JS from the wast test files. It will not attempt to run the tests, or do the round trip conversion from wasm <-> wast. This is convenient for proposals to add tests without having to update the reference interpreter with implementation, and generate those tests to JS to run in other Wasm engines. Fixes WebAssembly#1430. * Remove use of let from func.bind test * Add call3 * [spec] Fix missing mention of vectype (WebAssembly#1436) Fixed WebAssembly#1435. * [spec] Fix single-table limitation in module instantiation (WebAssembly#1434) * [spec] Fix missing immediate on table.set (WebAssembly#1441) * [docs] Update syntax in examples (WebAssembly#1442) * Clarification in proposals README * [interpreter] Tweak start section AST to match spec * [spec] Bump release to 2 (WebAssembly#1443) At yesterday's WG meeting, we decided to make a new release, now switching to the Evergreen model. For administrative and technical reasons having to do with W3C procedure, we decided to bump the release number to 2. From now on, the standard will iterate at version 2 from the W3C's official perspective. We use minor release numbers internally to distinguish different iterations. (@ericprud, I hope I understood correctly that the Bikeshed "level" also needed to be bumped to 2.) * Remove test cases with let * Sync wpt test (WebAssembly#1449) * [spec] Fix typo (WebAssembly#1448) * [proposals] Add missing start to example (WebAssembly#1454) * [spec] "version 2.0" -> "release 2.0" (WebAssembly#1452) * [spec] Fix typo (WebAssembly#1458) * [test] Add assert_trap for unreached valid case (WebAssembly#1460) * [interpreter] Name the type Utf8.unicode * [spec] Fix binary format of data/elem tags to allow LEB (WebAssembly#1461) * [spec] Fix typos in numeric operations (WebAssembly#1467) * [spec] Fix syntax error in element segments validation rule (WebAssembly#1465) * [spec] Fix typo in global instance syntax (WebAssembly#1466) * [spec] Fix typos in module instantiation (WebAssembly#1468) * [interpreter] Turn into a Dune package (WebAssembly#1459) * [spec] Fix typos in instruction validation rules (WebAssembly#1462) * [bib] Update latex .bib file for webassembly 2.0 (WebAssembly#1463) * [spec] Add missing default for vector types (WebAssembly#1464) * [spec] Fix typos in binary and text formats (WebAssembly#1469) * [spec] Fix various typos (WebAssembly#1470) * TypeError for Global constructor with v128 At the moment the spec requires a `LinkError` to be thrown when the `WebAssembly.Global` constructor is called for type `v128`. This was introduced in WebAssembly/simd#360, but according to the PR description, actually a `TypeError` should be thrown. The PR refers to https://github.com/WebAssembly/simd/blob/master/proposals/simd/SIMD.md#javascript-api-and-simd-values, and there a `TypeError` is required. * [spec] Fix LEB opcodes in instruction index (WebAssembly#1475) * [spec] Fix v128.loadX_splat in instruction index (WebAssembly#1477) * [interpreter] Dune test suite (WebAssembly#1478) * [interpreter] Fix warning flags for OCaml 4.13 (WebAssembly#1481) * [interpreter] Simplify lexer and avoid table overflow on some architectures (WebAssembly#1482) * [spec] Editorial nit (WebAssembly#1484) * [interpreter] Produce error messages in encoder (WebAssembly#1488) * [spec] Add missing close paren on table abbreviation (WebAssembly#1486) Also remove an unnecessary space in the previous table abbreviation. * [spec] Remove outdated note (WebAssembly#1491) * Eps * [interpreter] Factor data and element segments into abstract types (WebAssembly#1492) * [spec] Update note on module initialization trapping (WebAssembly#1493) * Fix type equality * Fix typo * [spec] Add note about control stack invariant to algorithm (WebAssembly#1498) * [spec] Tweak tokenisation for text format (WebAssembly#1499) * [test] Use still-illegal opcode (func-refs) (WebAssembly#1501) * Fix minor typos and consistency issues in the validation algorithm. (WebAssembly#61) * Add definition of defaultable types (WebAssembly#62) No rules for locals yet, since those are still being discussed. * Remove func.bind (WebAssembly#64) * Implement 1a (WebAssembly#63) * Subtyping on vector types & heap bottom check (WebAssembly#66) * [interpreter] Bring AST closer to spec * [spec] Fix typo (WebAssembly#1508) * WIP * Remove polymorphic variants * Minor syntactic consistency fix (WebAssembly#68) Change pseudo equality operator from `==` to `=`. * Bump version * [spec] Fix table.copy validation typo (WebAssembly#1511) * More fixes * Fix Latex * Adjust intro * Spec local initialization (WebAssembly#67) * Add table initialiser (WebAssembly#65) * [spec] Remove outdated note (WebAssembly#1491) * [interpreter] Factor data and element segments into abstract types (WebAssembly#1492) * [spec] Update note on module initialization trapping (WebAssembly#1493) * [spec] Add note about control stack invariant to algorithm (WebAssembly#1498) * [spec] Tweak tokenisation for text format (WebAssembly#1499) * [test] Use still-illegal opcode (func-refs) (WebAssembly#1501) * [spec] Fix typo (WebAssembly#1508) * [spec] Fix table.copy validation typo (WebAssembly#1511) * Merge fallout * Latex fixes * [spec] Minor copy edit (WebAssembly#1512) * Spec changelog * [spec] Trivial editorial fix * Update embedding * Oops * Argh * Rename Sem to Dyn * Readd match.mli * [interpreter] Build wast.js with Js_of_ocaml (WebAssembly#1507) * [interpreter] Add flag for controlling call budget * Spec zero byte * Fix table/elem expansion (WebAssembly#71) * Fix merge artefact * Restrict init from stack-polymorphism (WebAssembly#75) * [spec] Simplify exec rule for if (WebAssembly#1517) * [spec] Formatting tweak (WebAssembly#1519) * [spec] Fix typing rule in appendix (WebAssembly#1516) * [spec] Fix “invertible” typo (WebAssembly#1520) * [spec] Correct use of opdtype and stacktype (WebAssembly#1524) * [spec] Add note to instruction index (WebAssembly#1528) * Add type annotation to call_ref (WebAssembly#76) * [spec] Tweak wording to avoid first person * Eps * Eps2 * Eps3 * Remove unneeded assumption type * [spec/test] Fix scoping of non-imported globals (WebAssembly#1525) * Fix test * A couple of tests * Performance improvement * Typo * Another typo * [spec] Fix language config * Fix null subtyping being wrong way around (WebAssembly#79) * [spec] Fix naming typo (WebAssembly#1532) * Defunctorise types again * [spec] Add citation for WasmCert (WebAssembly#1533) * [test] Fix async_index.js * [test] Enable the i64 tests in imports.wast. Fixes WebAssembly#1514. * Minor tweak * [js-api][web-api] Editorial: Fix some minor issues. Fixes WebAssembly#1064. * Update README.md (WebAssembly#1540) Improve wording. * [spec] Fix typo in element execution (WebAssembly#1544) * [spec] Remove obsolete note (WebAssembly#1545) * cccccc[klghketetivvtnnhvntikigrnueuhdkkukljgjuest/meta/generate_*.js: sync upstream JS with tests (WebAssembly#1546) * [spec] Editorial tweak * [test] test segment/table mismatch and externref segment (WebAssembly#1547) * [interpreter] Remove duplicate token declarations (WebAssembly#1548) * Update Soundness appendix (WebAssembly#72) * [spec] Formatting eps * Remove oboslete note in README (WebAssembly#82) * Add `print_i64` to generated spec tests WebAssembly@82a613d added `print_i64` to the standalone test files, but not to the ones generated by the spec interpreter. * [test] Tweak binary-leb128 and simd_lane (WebAssembly#1555) * [spec] Allow explicit keyword definitions (WebAssembly#1553) Rather than describing keyword tokens as always being defined implicitly by terminal symbols in syntactic productions, describe them as being defined implicitly or explicitly. This accounts for the explicit definitions of `offset` and `align` phrases, which are lexically keywords, later in the chapter. Fixes WebAssembly#1552. * [js-api] editorial: adjust link for v128 type * Factor local init tests to local_init.wast; add more (WebAssembly#84) * Update JS API for no-frills * [spec] Add missing case for declarative elem segments Fixes WebAssembly#1562. * [spec] Hotfix last accidental commit * [spec] Fix hyperref (WebAssembly#1563) * [spec] Bump sphinx version to fix Python problem * [spec] Fix minor errors and inconsistencies (WebAssembly#1564) * Spacing * Fix a couple more superfluous brackets * [spec] Eps * [interpreter] Refactor parser to handle select & call_indirect correctly (WebAssembly#1567) * [spec] Remove dead piece of grammar * [test] elem.wast: force to use exprs in a element (WebAssembly#1561) * Fix typos in SIMD exec/instructions * Update interpreter README (WebAssembly#1571) It previously stated that the formal spec did not exist, but the spec has existed for years now. * [spec] Remove an obsolete exec step (WebAssembly#1580) * [test] Optional tableidx for table.{get,set,size,grow,fill} (WebAssembly#1582) * [spec] Fix abstract grammar for const immediate (WebAssembly#1577) * [spec] Fix context composition in text format (WebAssembly#1578) * [spec] Fix label shadowing (WebAssembly#1579) * Try bumping OCaml * Try bumping checkout * Adjust for multi-return * Tweak reduction rules * Spec return_call_ref * Fix * Text format * [spec] Fix typos in instruction index (WebAssembly#1584) * [spec] Fix typo (WebAssembly#1587) * [spec] Remove inconsistent newline (WebAssembly#1589) * [interpreter] Remove legacy bigarray linking (WebAssembly#1593) * [spec] Show scrolls for overflow math blocks (WebAssembly#1594) * [interpreter] Run JS tests via node.js (WebAssembly#1595) * [spec] Remove stray `x` indices (WebAssembly#1598) * [spec] Style tweak for cross-refs * [spec] Style eps (WebAssembly#1601) * Separate subsumption from instr sequencing * State principal types * Add statements about glbs, lubs, and disjoint hierarchies * Add missing bot * [spec] Clarify that atoms can be symbolic (WebAssembly#1602) * [test] Import v128 global (WebAssembly#1597) * Update Overview.md * [js-api] Expose everywhere * [js-api] Try to clarify NaN/infinity handling. (WebAssembly#1535) * [web-api] Correct MIME type check. (WebAssembly#1537) Fixes WebAssembly#1138. * [ci] Pin nodejs version to avoid fetching failures (WebAssembly#1603) The issues appears to be related to actions/runner-images#7002. Co-authored-by: Ms2ger <Ms2ger@igalia.com> * [spec] Add missing value to table.grow reduction rule (WebAssembly#1607) * [test] Move SIMD linking test to simd dir (WebAssembly#1610) * Editorial: Clarify the name of the instantiate algorithm. * Add notes to discourage using synchronous APIs. * [jsapi] Normative: Always queue a task during asynchronous instantiation JSC will have to do asynchronous compilation work during some instantiations. To be consistent, this PR always queues a task to complete instantiation, except through the synchronous Instance(module) API, to ensure consistency across platforms. This patch also cleans up the specification in various surrounding ways: - Include notes about APIs whose use is discouraged/may be limited Closes WebAssembly#741 See also webpack/webpack#6433 * [test] Exception -> Tag in wasm-module-builder.js The section name has changed to the tag section a few years ago. This adds the corresponding changes added in WebAssembly/exception-handling#252 and WebAssembly/exception-handling#256. * [spec] Fix reduction rule for label (WebAssembly#1612) Fix WebAssembly#1605. * [spec] Clarifying note about canonical NaNs (WebAssembly#1614) * [spec] Tweak crossref * [test] Fix invalid section ID tests (WebAssembly#1615) * [tests] Disable node run for now * [spec] Don't check in generated index, to avoid spurious merge conflicts * [spec] Rename script * [ci] deactivate node run for now * Fix uses of \to; compositionality * Fix typo in text expansion * Follow-up fix * Fix compilation errors after merge. This commit fixes the errors introduced by the merge of function-references/main into this tree. --------- Signed-off-by: Adrian Cole <adrian@tetrate.io> Co-authored-by: Andreas Rossberg <rossberg@dfinity.org> Co-authored-by: Hans Höglund <hanshoglund@users.noreply.github.com> Co-authored-by: Ng Zhi An <zhin@chromium.org> Co-authored-by: Ng Zhi An <zhin@google.com> Co-authored-by: Sam Clegg <sbc@chromium.org> Co-authored-by: Thomas Lively <7121787+tlively@users.noreply.github.com> Co-authored-by: Gabor Greif <ggreif@gmail.com> Co-authored-by: Andreas Rossberg <rossberg@mpi-sws.org> Co-authored-by: Crypt Keeper <64215+codefromthecrypt@users.noreply.github.com> Co-authored-by: Andreas Rossberg <rossberg@chromium.org> Co-authored-by: Ng Zhi An <ngzhian@gmail.com> Co-authored-by: Ben L. Titzer <ben.titzer@gmail.com> Co-authored-by: Keith Winstein <keithw@cs.stanford.edu> Co-authored-by: gahaas <ahaas@google.com> Co-authored-by: r00ster <r00ster91@protonmail.com> Co-authored-by: Timothy McCallum <tpmccallum@users.noreply.github.com> Co-authored-by: Julien Cretin <github@ia0.eu> Co-authored-by: Julien Cretin <cretin@google.com> Co-authored-by: Ole Krüger <ole@vprsm.de> Co-authored-by: Jämes Ménétrey <james@menetrey.me> Co-authored-by: Ivan Panchenko <39594356+ivan-pan@users.noreply.github.com> Co-authored-by: Ethan Jones <ictrobot@outlook.com> Co-authored-by: Ole Krüger <ole.kruger@trili.tech> Co-authored-by: aathan <aathan_github@memeplex.com> Co-authored-by: Alberto Fiori <9143617+fifofefe@users.noreply.github.com> Co-authored-by: mnordine <marknordine@gmail.com> Co-authored-by: cosine <CosineP@users.noreply.github.com> Co-authored-by: ariez-xyz <41232910+ariez-xyz@users.noreply.github.com> Co-authored-by: Surma <surma@surma.dev> Co-authored-by: Asumu Takikawa <asumu@igalia.com> Co-authored-by: Ian Henderson <ian@ianhenderson.org> Co-authored-by: Tom Stuart <hi@tomstu.art> Co-authored-by: James Browning <thejamesernator@gmail.com> Co-authored-by: whirlicote <78504913+whirlicote@users.noreply.github.com> Co-authored-by: Ms2ger <Ms2ger@igalia.com> Co-authored-by: Adam Lancaster <Adzz@users.noreply.github.com> Co-authored-by: Ömer Sinan Ağacan <omeragacan@gmail.com> Co-authored-by: B Szilvasy <beatrice.szilvasy@gmail.com> Co-authored-by: Thomas Lively <tlively123@gmail.com> Co-authored-by: Michael Ficarra <github@michael.ficarra.me> Co-authored-by: YAMAMOTO Takashi <yamamoto@midokura.com> Co-authored-by: Thomas Lively <tlively@google.com> Co-authored-by: candymate <31069474+candymate@users.noreply.github.com> Co-authored-by: Bongjun Jang <bongjun.jang@kaist.ac.kr> Co-authored-by: ShinWonho <50018375+ShinWonho@users.noreply.github.com> Co-authored-by: 서동휘 <hwidongsuh@gmail.com> Co-authored-by: Jim Blandy <jimb@red-bean.com> Co-authored-by: Heejin Ahn <aheejin@gmail.com> Co-authored-by: Daniel Ehrenberg <littledan@chromium.org>
SIMD is phase 5, merge all the changes back into main spec.