about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorAmanieu d'Antras <amanieu@gmail.com>2020-01-14 13:40:42 +0000
committerAmanieu d'Antras <amanieu@gmail.com>2020-03-26 15:49:22 +0000
commitd162d096ddf7972819e5b700890726a2ea85f272 (patch)
tree10aef78eb9fffb1aa127609e953204a62b18ecef /src/libcore
parent2fbb07525e2f07a815e780a4268b11916248b5a9 (diff)
downloadrust-d162d096ddf7972819e5b700890726a2ea85f272.tar.gz
rust-d162d096ddf7972819e5b700890726a2ea85f272.zip
Rename asm! to llvm_asm!
asm! is left as a wrapper around llvm_asm! to maintain compatibility.
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/hint.rs2
-rw-r--r--src/libcore/lib.rs1
-rw-r--r--src/libcore/macros/mod.rs43
-rw-r--r--src/libcore/num/dec2flt/algorithm.rs4
-rw-r--r--src/libcore/prelude/v1.rs4
5 files changed, 48 insertions, 6 deletions
diff --git a/src/libcore/hint.rs b/src/libcore/hint.rs
index 6cbd26a78de..698c97999c4 100644
--- a/src/libcore/hint.rs
+++ b/src/libcore/hint.rs
@@ -113,7 +113,7 @@ pub fn black_box<T>(dummy: T) -> T {
     // box. This isn't the greatest implementation since it probably deoptimizes
     // more than we want, but it's so far good enough.
     unsafe {
-        asm!("" : : "r"(&dummy));
+        llvm_asm!("" : : "r"(&dummy));
         dummy
     }
 }
diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs
index 0bee16f98bd..73c5e3fad47 100644
--- a/src/libcore/lib.rs
+++ b/src/libcore/lib.rs
@@ -98,6 +98,7 @@
 #![feature(is_sorted)]
 #![feature(lang_items)]
 #![feature(link_llvm_intrinsics)]
+#![feature(llvm_asm)]
 #![cfg_attr(not(bootstrap), feature(negative_impls))]
 #![feature(never_type)]
 #![feature(nll)]
diff --git a/src/libcore/macros/mod.rs b/src/libcore/macros/mod.rs
index a0873fe6b62..f67762cd043 100644
--- a/src/libcore/macros/mod.rs
+++ b/src/libcore/macros/mod.rs
@@ -1307,7 +1307,7 @@ pub(crate) mod builtin {
     /// [unstable book]: ../unstable-book/library-features/asm.html
     #[unstable(
         feature = "asm",
-        issue = "29722",
+        issue = "70173",
         reason = "inline assembly is not stable enough for use and is subject to change"
     )]
     #[rustc_builtin_macro]
@@ -1322,6 +1322,47 @@ pub(crate) mod builtin {
         };
     }
 
+    /// Inline assembly.
+    ///
+    /// Read the [unstable book] for the usage.
+    ///
+    /// [unstable book]: ../unstable-book/library-features/asm.html
+    #[cfg(bootstrap)]
+    #[unstable(
+        feature = "llvm_asm",
+        issue = "70173",
+        reason = "inline assembly is not stable enough for use and is subject to change"
+    )]
+    #[macro_export]
+    #[allow_internal_unstable(asm)]
+    macro_rules! llvm_asm {
+        // Redirect to asm! for stage0
+        ($($arg:tt)*) => { $crate::asm!($($arg)*) }
+    }
+
+    /// Inline assembly.
+    ///
+    /// Read the [unstable book] for the usage.
+    ///
+    /// [unstable book]: ../unstable-book/library-features/asm.html
+    #[cfg(not(bootstrap))]
+    #[unstable(
+        feature = "llvm_asm",
+        issue = "70173",
+        reason = "inline assembly is not stable enough for use and is subject to change"
+    )]
+    #[rustc_builtin_macro]
+    #[macro_export]
+    macro_rules! llvm_asm {
+        ("assembly template"
+                        : $("output"(operand),)*
+                        : $("input"(operand),)*
+                        : $("clobbers",)*
+                        : $("options",)*) => {
+            /* compiler built-in */
+        };
+    }
+
     /// Module-level inline assembly.
     #[unstable(
         feature = "global_asm",
diff --git a/src/libcore/num/dec2flt/algorithm.rs b/src/libcore/num/dec2flt/algorithm.rs
index c5f6903f379..aaeb4d8a22c 100644
--- a/src/libcore/num/dec2flt/algorithm.rs
+++ b/src/libcore/num/dec2flt/algorithm.rs
@@ -60,7 +60,7 @@ mod fpu_precision {
     fn set_cw(cw: u16) {
         // SAFETY: the `fldcw` instruction has been audited to be able to work correctly with
         // any `u16`
-        unsafe { asm!("fldcw $0" :: "m" (cw) :: "volatile") }
+        unsafe { llvm_asm!("fldcw $0" :: "m" (cw) :: "volatile") }
     }
 
     /// Sets the precision field of the FPU to `T` and returns a `FPUControlWord`.
@@ -78,7 +78,7 @@ mod fpu_precision {
         // `FPUControlWord` structure is dropped
         // SAFETY: the `fnstcw` instruction has been audited to be able to work correctly with
         // any `u16`
-        unsafe { asm!("fnstcw $0" : "=*m" (&cw) ::: "volatile") }
+        unsafe { llvm_asm!("fnstcw $0" : "=*m" (&cw) ::: "volatile") }
 
         // Set the control word to the desired precision. This is achieved by masking away the old
         // precision (bits 8 and 9, 0x300) and replacing it with the precision flag computed above.
diff --git a/src/libcore/prelude/v1.rs b/src/libcore/prelude/v1.rs
index c91370b2719..9b4ed4e8205 100644
--- a/src/libcore/prelude/v1.rs
+++ b/src/libcore/prelude/v1.rs
@@ -57,8 +57,8 @@ pub use crate::hash::macros::Hash;
 #[doc(no_inline)]
 pub use crate::{
     asm, assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args,
-    format_args_nl, global_asm, include, include_bytes, include_str, line, log_syntax, module_path,
-    option_env, stringify, trace_macros,
+    format_args_nl, global_asm, include, include_bytes, include_str, line, llvm_asm, log_syntax,
+    module_path, option_env, stringify, trace_macros,
 };
 
 #[stable(feature = "builtin_macro_prelude", since = "1.38.0")]