# Should we ever stabilize inline assembly?

**URL:** <https://internals.rust-lang.org/t/should-we-ever-stabilize-inline-assembly/11211>\
**Category:** language design\
**Created:** [October 31, 2019, 12:57am UTC](https://internals.rust-lang.org/t/should-we-ever-stabilize-inline-assembly/11211 "2019-10-31T00:57:17Z")\
**Posts on this page:** 10\
**Page:** 8

<div class="post-metadata">

**Author:** ![Amanieu](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/amanieu/32/4095_2.png) [@Amanieu](https://internals.rust-lang.org/u/Amanieu)\
**Post date:** [November 18, 2019, 3:50pm UTC](https://internals.rust-lang.org/t/should-we-ever-stabilize-inline-assembly/11211/143 "2019-11-18T15:50:37Z")

</div>

Yes, I'll be setting up the WG.

---

<div class="post-metadata">

**Author:** ![ckaran](https://avatars.discourse-cdn.com/v4/letter/c/f475e1/32.png) [@ckaran](https://internals.rust-lang.org/u/ckaran)\
**Post date:** [November 18, 2019, 4:08pm UTC](https://internals.rust-lang.org/t/should-we-ever-stabilize-inline-assembly/11211/144 "2019-11-18T16:08:13Z")

</div>

Good, thank you!

---

<div class="post-metadata">

**Author:** ![Serentty](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/serentty/32/6358_2.png) [@Serentty](https://internals.rust-lang.org/u/Serentty)\
**Post date:** [December 15, 2019, 3:44am UTC](https://internals.rust-lang.org/t/should-we-ever-stabilize-inline-assembly/11211/145 "2019-12-15T03:44:40Z")

</div>

Just to respond to the initial premise, I think that yes, Rust needs stable inline assembly as a matter of principle. If it can't do that, then it can't call itself a systems programming language in my opinion. I regularly use Rust's unstable inline assembly to call APIs with odd calling conventions that Rust will probably never support, among other things.

---

<div class="post-metadata">

**Author:** ![CAD97](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/cad97/32/3460_2.png) [@CAD97](https://internals.rust-lang.org/u/CAD97)\
**Post date:** [December 15, 2019, 4:46am UTC](https://internals.rust-lang.org/t/should-we-ever-stabilize-inline-assembly/11211/146 "2019-12-15T04:46:18Z")

</div>

I think it would be nice for the proposal to at least mention how inline asm might look for wasm. I see no reason it couldn't work (except, well, compiler backend support), so it'd be nice to show it in the future possibilities.

---

<div class="post-metadata">

**Author:** ![spunit262](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/spunit262/32/5677_2.png) [@spunit262](https://internals.rust-lang.org/u/spunit262)\
**Post date:** [December 15, 2019, 8:39am UTC](https://internals.rust-lang.org/t/should-we-ever-stabilize-inline-assembly/11211/147 "2019-12-15T08:39:32Z")

</div>

LLVM already supports Wasm inline assembly, so we [already get it for free](https://godbolt.org/z/h9C4KE).

---

<div class="post-metadata">

**Author:** ![josh](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/josh/32/5934_2.png) [@josh](https://internals.rust-lang.org/u/josh)\
**Post date:** [December 15, 2019, 4:46pm UTC](https://internals.rust-lang.org/t/should-we-ever-stabilize-inline-assembly/11211/148 "2019-12-15T16:46:36Z")

</div>

Interesting!

I'm trying to find documentation for that support, and in particular for what constraints LLVM supports and what they mean. I'd like to make sure we take this into account in the new inline assembly proposal.

---

<div class="post-metadata">

**Author:** ![gnzlbg](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/gnzlbg/32/3858_2.png) [@gnzlbg](https://internals.rust-lang.org/u/gnzlbg)\
**Post date:** [December 15, 2019, 5:22pm UTC](https://internals.rust-lang.org/t/should-we-ever-stabilize-inline-assembly/11211/149 "2019-12-15T17:22:19Z")

</div>

IIRC we already use LLVM inline assembly support for WASM in libcore (e.g. in `core::hint::bench_black_box`).

---

<div class="post-metadata">

**Author:** ![spunit262](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/spunit262/32/5677_2.png) [@spunit262](https://internals.rust-lang.org/u/spunit262)\
**Post date:** [December 16, 2019, 2:18am UTC](https://internals.rust-lang.org/t/should-we-ever-stabilize-inline-assembly/11211/150 "2019-12-16T02:18:31Z")

</div>

According to [this comment](http://llvm.org/doxygen/WebAssemblyAsmPrinter_8cpp_source.html#l00404) "m" constraints aren't supported. That's the only documentation I've found but I haven't look very hard.

---

<div class="post-metadata">

**Author:** ![josh](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/josh/32/5934_2.png) [@josh](https://internals.rust-lang.org/u/josh)\
**Post date:** [December 16, 2019, 4:03am UTC](https://internals.rust-lang.org/t/should-we-ever-stabilize-inline-assembly/11211/151 "2019-12-16T04:03:20Z")

</div>

That's what I found as well, and I didn't find any other documentation either.

Looks like WebAssembly only supports `"r"` constraints, and uses them to represent indexes of locals.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [March 15, 2020, 4:03am UTC](https://internals.rust-lang.org/t/should-we-ever-stabilize-inline-assembly/11211/152 "2020-03-15T04:03:22Z")

</div>

Closed on March 15, 2020, 4:03am UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

[Previous page](https://internals.rust-lang.org/t/should-we-ever-stabilize-inline-assembly/11211.md?page=7)
