From d5fe87812fc95f2699e770993848179b6c071f2c Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Sat, 4 Jan 2020 14:01:11 +0100 Subject: [PATCH 1/4] Add llvm_asm! and deprecate asm! --- text/0000-llvm-asm.md | 69 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 text/0000-llvm-asm.md diff --git a/text/0000-llvm-asm.md b/text/0000-llvm-asm.md new file mode 100644 index 00000000000..07421f19c9c --- /dev/null +++ b/text/0000-llvm-asm.md @@ -0,0 +1,69 @@ +- Feature Name: `llvm_asm` +- Start Date: 2019-12-31 +- RFC PR: [rust-lang/rfcs#0000](https://github.com/rust-lang/rfcs/pull/0000) +- Rust Issue: [rust-lang/rust#0000](https://github.com/rust-lang/rust/issues/0000) + +# Summary +[summary]: #summary + +Deprecate the existing `asm!` macro and provide an identical one called +`llvm_asm!`. The feature gate is also renamed from `asm` to `llvm_asm`. + +# Motivation +[motivation]: #motivation + +This change frees up the `asm!` macro so that it can be used for the new +`asm!` macro designed by the inline asm project group while giving existing +users of `asm!` an easy way to keep their code working. + +It may also be useful to have an inline asm implementation available +(on nightly) for architectures that the new `asm!` macro does not support yet. + +# Guide-level explanation +[guide-level-explanation]: #guide-level-explanation + +The Rust team is currently in the process of redesigning the `asm!` macro. +You should replace all uses of `asm!` with `llvm_asm!` in your code to avoid breakage when the new `asm!` macro is implemented. + +# Reference-level explanation +[reference-level-explanation]: #reference-level-explanation + +All references to `asm!` inside the compiler will be changed to refer to `llvm_asm!` instead. +`asm!` will become a simple (deprecated) `macro_rules!` which redirects to `llvm_asm!`. +The deprecation warning will advise users that the semantics of `asm!` will change in the future and invite them to use `llvm_asm!` instead. + +# Drawbacks +[drawbacks]: #drawbacks + +This change may require people to change their code twice: first to `llvm_asm!`, and then to the new +`asm!` macro once it is implemented. + +# Rationale and alternatives +[rationale-and-alternatives]: #rationale-and-alternatives + +We could skip the deprecation period and perform the renaming at the same time the new `asm!` macro +is implemented. However this is guaranteed to break a lot of code using nightly Rust at once without +any transition period. + +# Prior art +[prior-art]: #prior-art + +The D programming language also support 2 forms of inline assembly. The [first one][d-asm] provides an embedded DSL +for inline assembly, which allows direct access to variables in scope and does not require the use of clobbers, but is only available on x86 and x86_64. The [second one][d-llvm-asm] is a raw interface to LLVM's internal inline assembly syntax, which is available on all architectures but only on the LDC backend. + +[d-asm]: https://dlang.org/spec/iasm.html +[d-llvm-asm]: https://wiki.dlang.org/LDC_inline_assembly_expressions + +# Unresolved questions +[unresolved-questions]: #unresolved-questions + +- Should the deprecated `asm!` macro be under the `asm` or `llvm_asm` feature gate? + +# Future possibilities +[future-possibilities]: #future-possibilities + +When the new `asm!` macro is implemented it will replace the current one. This +will break anyone who has not yet transitioned their code to `llvm_asm!`. No +silent miscompilations are expected since the operand separator will be changed +from `:` to `,`, which will guarantee that any existing `asm!` invocations will +fail with a syntax error with the new `asm!` macro. From 088408af389020ff8ba3fae45a57eea20c06a564 Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Wed, 8 Jan 2020 09:51:42 +0000 Subject: [PATCH 2/4] Clarifications --- text/0000-llvm-asm.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/text/0000-llvm-asm.md b/text/0000-llvm-asm.md index 07421f19c9c..d7888341d49 100644 --- a/text/0000-llvm-asm.md +++ b/text/0000-llvm-asm.md @@ -9,6 +9,8 @@ Deprecate the existing `asm!` macro and provide an identical one called `llvm_asm!`. The feature gate is also renamed from `asm` to `llvm_asm`. +Unlike `asm!`, `llvm_asm!` is not intended to ever become stable. + # Motivation [motivation]: #motivation @@ -62,8 +64,10 @@ for inline assembly, which allows direct access to variables in scope and does n # Future possibilities [future-possibilities]: #future-possibilities -When the new `asm!` macro is implemented it will replace the current one. This +When the [new `asm!` macro][inline-asm-rfc] is implemented it will replace the current one. This will break anyone who has not yet transitioned their code to `llvm_asm!`. No silent miscompilations are expected since the operand separator will be changed from `:` to `,`, which will guarantee that any existing `asm!` invocations will fail with a syntax error with the new `asm!` macro. + +[inline-asm-rfc]: https://github.com/rust-lang/project-inline-asm/blob/master/rfcs/0000-inline-asm.md From 25dd57bb44caf4dacd2be5c0623fcedb235614e4 Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Tue, 25 Feb 2020 13:32:21 +0000 Subject: [PATCH 3/4] llvm_asm! is under the llvm_asm feature gate --- text/0000-llvm-asm.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/text/0000-llvm-asm.md b/text/0000-llvm-asm.md index d7888341d49..f2a11bc6ec8 100644 --- a/text/0000-llvm-asm.md +++ b/text/0000-llvm-asm.md @@ -32,7 +32,7 @@ You should replace all uses of `asm!` with `llvm_asm!` in your code to avoid bre All references to `asm!` inside the compiler will be changed to refer to `llvm_asm!` instead. `asm!` will become a simple (deprecated) `macro_rules!` which redirects to `llvm_asm!`. -The deprecation warning will advise users that the semantics of `asm!` will change in the future and invite them to use `llvm_asm!` instead. +The deprecation warning will advise users that the semantics of `asm!` will change in the future and invite them to use `llvm_asm!` instead. The `llvm_asm!` macro will be guarded by the `llvm_asm` feature gate. # Drawbacks [drawbacks]: #drawbacks @@ -59,7 +59,7 @@ for inline assembly, which allows direct access to variables in scope and does n # Unresolved questions [unresolved-questions]: #unresolved-questions -- Should the deprecated `asm!` macro be under the `asm` or `llvm_asm` feature gate? +None # Future possibilities [future-possibilities]: #future-possibilities From 9911615f81471229684b0ab704409c9fcae55ede Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Fri, 20 Mar 2020 07:12:36 +0000 Subject: [PATCH 4/4] RFC 2843 --- text/{0000-llvm-asm.md => 2843-llvm-asm.md} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename text/{0000-llvm-asm.md => 2843-llvm-asm.md} (92%) diff --git a/text/0000-llvm-asm.md b/text/2843-llvm-asm.md similarity index 92% rename from text/0000-llvm-asm.md rename to text/2843-llvm-asm.md index f2a11bc6ec8..be29b54e0ce 100644 --- a/text/0000-llvm-asm.md +++ b/text/2843-llvm-asm.md @@ -1,7 +1,7 @@ - Feature Name: `llvm_asm` - Start Date: 2019-12-31 -- RFC PR: [rust-lang/rfcs#0000](https://github.com/rust-lang/rfcs/pull/0000) -- Rust Issue: [rust-lang/rust#0000](https://github.com/rust-lang/rust/issues/0000) +- RFC PR: [rust-lang/rfcs#2843](https://github.com/rust-lang/rfcs/pull/2843) +- Rust Issue: [rust-lang/rust#70173](https://github.com/rust-lang/rust/issues/70173) # Summary [summary]: #summary @@ -70,4 +70,4 @@ silent miscompilations are expected since the operand separator will be changed from `:` to `,`, which will guarantee that any existing `asm!` invocations will fail with a syntax error with the new `asm!` macro. -[inline-asm-rfc]: https://github.com/rust-lang/project-inline-asm/blob/master/rfcs/0000-inline-asm.md +[inline-asm-rfc]: https://github.com/rust-lang/rfcs/pull/2873