Add features gates for experimental asm features

This commit is contained in:
Amanieu d'Antras 2021-10-27 18:37:18 +01:00
parent 3831aaa13c
commit eb32c00216
42 changed files with 243 additions and 98 deletions

View File

@ -4,7 +4,8 @@ use rustc_ast::*;
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::struct_span_err;
use rustc_hir as hir;
use rustc_span::{Span, Symbol};
use rustc_session::parse::feature_err;
use rustc_span::{sym, Span, Symbol};
use rustc_target::asm;
use std::collections::hash_map::Entry;
use std::fmt::Write;
@ -18,6 +19,27 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
struct_span_err!(self.sess, sp, E0472, "inline assembly is unsupported on this target")
.emit();
}
if let Some(asm_arch) = asm_arch {
// Inline assembly is currently only stable for these architectures.
let is_stable = matches!(
asm_arch,
asm::InlineAsmArch::X86
| asm::InlineAsmArch::X86_64
| asm::InlineAsmArch::Arm
| asm::InlineAsmArch::AArch64
| asm::InlineAsmArch::RiscV32
| asm::InlineAsmArch::RiscV64
);
if !is_stable && !self.sess.features_untracked().asm_experimental_arch {
feature_err(
&self.sess.parse_sess,
sym::asm_experimental_arch,
sp,
"inline assembly is not stable yet on this architecture",
)
.emit();
}
}
if asm.options.contains(InlineAsmOptions::ATT_SYNTAX)
&& !matches!(asm_arch, Some(asm::InlineAsmArch::X86 | asm::InlineAsmArch::X86_64))
&& !self.sess.opts.actually_rustdoc
@ -121,10 +143,30 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
out_expr: out_expr.as_ref().map(|expr| self.lower_expr_mut(expr)),
}
}
InlineAsmOperand::Const { ref anon_const } => hir::InlineAsmOperand::Const {
anon_const: self.lower_anon_const(anon_const),
},
InlineAsmOperand::Const { ref anon_const } => {
if !self.sess.features_untracked().asm_const {
feature_err(
&self.sess.parse_sess,
sym::asm_const,
*op_sp,
"const operands for inline assembly are unstable",
)
.emit();
}
hir::InlineAsmOperand::Const {
anon_const: self.lower_anon_const(anon_const),
}
}
InlineAsmOperand::Sym { ref expr } => {
if !self.sess.features_untracked().asm_sym {
feature_err(
&self.sess.parse_sess,
sym::asm_sym,
*op_sp,
"sym operands for inline assembly are unstable",
)
.emit();
}
hir::InlineAsmOperand::Sym { expr: self.lower_expr_mut(expr) }
}
};

View File

@ -692,6 +692,15 @@ declare_features! (
/// Tells rustdoc to automatically generate `#[doc(cfg(...))]`.
(active, doc_auto_cfg, "1.58.0", Some(43781), None),
/// Allows using `const` operands in inline assembly.
(active, asm_const, "1.58.0", Some(72016), None),
/// Allows using `sym` operands in inline assembly.
(active, asm_sym, "1.58.0", Some(72016), None),
/// Enables experimental inline assembly support for additional architectures.
(active, asm_experimental_arch, "1.58.0", Some(72016), None),
// -------------------------------------------------------------------------
// feature-group-end: actual feature gates
// -------------------------------------------------------------------------

View File

@ -327,6 +327,9 @@ symbols! {
as_ptr,
as_str,
asm,
asm_const,
asm_experimental_arch,
asm_sym,
assert,
assert_inhabited,
assert_macro,

View File

@ -193,6 +193,7 @@
#![feature(try_blocks)]
#![feature(unboxed_closures)]
#![feature(unsized_fn_params)]
#![cfg_attr(not(bootstrap), feature(asm_const))]
//
// Target features:
#![feature(aarch64_target_feature)]

View File

@ -75,7 +75,7 @@ are concatenated into one or assembled separately.
constants defined in Rust to be used in assembly code:
```rust,no_run
#![feature(global_asm)]
#![feature(global_asm, asm_const)]
# #[cfg(any(target_arch="x86", target_arch="x86_64"))]
# mod x86 {
const C: i32 = 1234;
@ -96,7 +96,7 @@ override this by adding `options(att_syntax)` at the end of the macro
arguments list:
```rust,no_run
#![feature(global_asm)]
#![feature(global_asm, asm_const)]
# #[cfg(any(target_arch="x86", target_arch="x86_64"))]
# mod x86 {
global_asm!("movl ${}, %ecx", const 5, options(att_syntax));

View File

@ -2,7 +2,7 @@
// compile-flags: --target aarch64-unknown-linux-gnu
// needs-llvm-components: aarch64
#![feature(no_core, lang_items, rustc_attrs, repr_simd)]
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]

View File

@ -3,7 +3,7 @@
// compile-flags: -C target-feature=+neon
// needs-llvm-components: arm
#![feature(no_core, lang_items, rustc_attrs, repr_simd)]
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]

View File

@ -3,7 +3,7 @@
// compile-flags: --target bpfel-unknown-none -C target_feature=+alu32
// needs-llvm-components: bpf
#![feature(no_core, lang_items, rustc_attrs, repr_simd)]
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]

View File

@ -2,7 +2,7 @@
// assembly-output: emit-asm
// compile-flags: -C llvm-args=--x86-asm-syntax=intel
#![feature(asm, global_asm)]
#![feature(global_asm, asm_const)]
#![crate_type = "rlib"]
// CHECK: mov eax, eax

View File

@ -2,7 +2,7 @@
// compile-flags: --target hexagon-unknown-linux-musl
// needs-llvm-components: hexagon
#![feature(no_core, lang_items, rustc_attrs, repr_simd)]
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]

View File

@ -5,7 +5,7 @@
//[mips64] compile-flags: --target mips64-unknown-linux-gnuabi64
//[mips64] needs-llvm-components: mips
#![feature(no_core, lang_items, rustc_attrs, repr_simd)]
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]

View File

@ -3,7 +3,7 @@
// compile-flags: --crate-type cdylib
// needs-llvm-components: nvptx
#![feature(no_core, lang_items, rustc_attrs)]
#![feature(no_core, lang_items, rustc_attrs, asm_sym, asm_experimental_arch)]
#![no_core]
#[rustc_builtin_macro]

View File

@ -6,7 +6,7 @@
//[powerpc64] compile-flags: --target powerpc64-unknown-linux-gnu
//[powerpc64] needs-llvm-components: powerpc
#![feature(no_core, lang_items, rustc_attrs, repr_simd)]
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]

View File

@ -6,7 +6,7 @@
//[riscv32] needs-llvm-components: riscv
// compile-flags: -C target-feature=+d
#![feature(no_core, lang_items, rustc_attrs)]
#![feature(no_core, lang_items, rustc_attrs, asm_sym)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register)]

View File

@ -3,7 +3,7 @@
//[s390x] compile-flags: --target s390x-unknown-linux-gnu
//[s390x] needs-llvm-components: systemz
#![feature(no_core, lang_items, rustc_attrs, repr_simd)]
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]

View File

@ -3,7 +3,7 @@
// compile-flags: --crate-type cdylib
// needs-llvm-components: webassembly
#![feature(no_core, lang_items, rustc_attrs)]
#![feature(no_core, lang_items, rustc_attrs, asm_sym, asm_experimental_arch)]
#![no_core]
#[rustc_builtin_macro]

View File

@ -7,7 +7,7 @@
// compile-flags: -C llvm-args=--x86-asm-syntax=intel
// compile-flags: -C target-feature=+avx512bw
#![feature(no_core, lang_items, rustc_attrs, repr_simd)]
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]

View File

@ -7,7 +7,7 @@
//[powerpc64le] needs-llvm-components: powerpc
#![crate_type = "rlib"]
#![feature(no_core, rustc_attrs, lang_items)]
#![feature(no_core, rustc_attrs, lang_items, asm_experimental_arch)]
#![no_core]
#[lang = "sized"]

View File

@ -1,7 +1,7 @@
// only-aarch64
// compile-flags: -C target-feature=+fp
#![feature(asm)]
#![feature(asm, asm_const, asm_sym)]
fn main() {
let mut foo = 0;

View File

@ -3,7 +3,7 @@
// revisions: mirunsafeck thirunsafeck
// [thirunsafeck]compile-flags: -Z thir-unsafeck
#![feature(asm, global_asm)]
#![feature(asm, global_asm, asm_const)]
fn const_generic<const X: usize>() -> usize {
unsafe {

View File

@ -1,6 +1,6 @@
// only-aarch64
#![feature(asm, global_asm)]
#![feature(asm, global_asm, asm_const)]
fn main() {
let mut foo = 0;

View File

@ -2,7 +2,7 @@
// only-linux
// run-pass
#![feature(asm, thread_local)]
#![feature(asm, thread_local, asm_sym)]
extern "C" fn f1() -> i32 {
111
@ -75,5 +75,7 @@ fn main() {
std::thread::spawn(|| {
assert_eq!(static_addr!(S1), &S1 as *const u32);
assert_eq!(static_tls_addr!(S2), &S2 as *const u32);
}).join().unwrap();
})
.join()
.unwrap();
}

View File

@ -1,6 +1,6 @@
// only-aarch64
#![feature(asm, repr_simd, never_type)]
#![feature(asm, repr_simd, never_type, asm_sym)]
#[repr(simd)]
#[derive(Clone, Copy)]

View File

@ -1,13 +1,13 @@
// only-aarch64
// compile-flags: -C target-feature=+neon
#![feature(asm, global_asm, repr_simd, stdsimd)]
#![feature(asm, global_asm, repr_simd, stdsimd, asm_const)]
use std::arch::aarch64::float64x2_t;
#[repr(simd)]
#[derive(Copy, Clone)]
struct Simd256bit(f64, f64,f64, f64);
struct Simd256bit(f64, f64, f64, f64);
fn main() {
let f64x2: float64x2_t = unsafe { std::mem::transmute(0i128) };
@ -42,7 +42,6 @@ fn main() {
asm!("{:b}", in(vreg) 0u64);
asm!("{:d}", in(vreg_low16) f64x2);
// Template modifier suggestions for sub-registers
asm!("{}", in(reg) 0u8);

View File

@ -1,5 +1,5 @@
warning: formatting may not be suitable for sub-register argument
--> $DIR/type-check-3.rs:48:15
--> $DIR/type-check-3.rs:47:15
|
LL | asm!("{}", in(reg) 0u8);
| ^^ --- for this argument
@ -9,7 +9,7 @@ LL | asm!("{}", in(reg) 0u8);
= help: or use the `x` modifier to keep the default formatting of `x0`
warning: formatting may not be suitable for sub-register argument
--> $DIR/type-check-3.rs:50:15
--> $DIR/type-check-3.rs:49:15
|
LL | asm!("{}", in(reg) 0u16);
| ^^ ---- for this argument
@ -18,7 +18,7 @@ LL | asm!("{}", in(reg) 0u16);
= help: or use the `x` modifier to keep the default formatting of `x0`
warning: formatting may not be suitable for sub-register argument
--> $DIR/type-check-3.rs:52:15
--> $DIR/type-check-3.rs:51:15
|
LL | asm!("{}", in(reg) 0i32);
| ^^ ---- for this argument
@ -27,7 +27,7 @@ LL | asm!("{}", in(reg) 0i32);
= help: or use the `x` modifier to keep the default formatting of `x0`
warning: formatting may not be suitable for sub-register argument
--> $DIR/type-check-3.rs:54:15
--> $DIR/type-check-3.rs:53:15
|
LL | asm!("{}", in(reg) 0f32);
| ^^ ---- for this argument
@ -36,7 +36,7 @@ LL | asm!("{}", in(reg) 0f32);
= help: or use the `x` modifier to keep the default formatting of `x0`
warning: formatting may not be suitable for sub-register argument
--> $DIR/type-check-3.rs:57:15
--> $DIR/type-check-3.rs:56:15
|
LL | asm!("{}", in(vreg) 0i16);
| ^^ ---- for this argument
@ -45,7 +45,7 @@ LL | asm!("{}", in(vreg) 0i16);
= help: or use the `v` modifier to keep the default formatting of `v0`
warning: formatting may not be suitable for sub-register argument
--> $DIR/type-check-3.rs:59:15
--> $DIR/type-check-3.rs:58:15
|
LL | asm!("{}", in(vreg) 0f32);
| ^^ ---- for this argument
@ -54,7 +54,7 @@ LL | asm!("{}", in(vreg) 0f32);
= help: or use the `v` modifier to keep the default formatting of `v0`
warning: formatting may not be suitable for sub-register argument
--> $DIR/type-check-3.rs:61:15
--> $DIR/type-check-3.rs:60:15
|
LL | asm!("{}", in(vreg) 0f64);
| ^^ ---- for this argument
@ -63,7 +63,7 @@ LL | asm!("{}", in(vreg) 0f64);
= help: or use the `v` modifier to keep the default formatting of `v0`
warning: formatting may not be suitable for sub-register argument
--> $DIR/type-check-3.rs:63:15
--> $DIR/type-check-3.rs:62:15
|
LL | asm!("{}", in(vreg_low16) 0f64);
| ^^ ---- for this argument
@ -72,7 +72,7 @@ LL | asm!("{}", in(vreg_low16) 0f64);
= help: or use the `v` modifier to keep the default formatting of `v0`
warning: formatting may not be suitable for sub-register argument
--> $DIR/type-check-3.rs:66:15
--> $DIR/type-check-3.rs:65:15
|
LL | asm!("{0} {0}", in(reg) 0i16);
| ^^^ ^^^ ---- for this argument
@ -81,7 +81,7 @@ LL | asm!("{0} {0}", in(reg) 0i16);
= help: or use the `x` modifier to keep the default formatting of `x0`
warning: formatting may not be suitable for sub-register argument
--> $DIR/type-check-3.rs:68:15
--> $DIR/type-check-3.rs:67:15
|
LL | asm!("{0} {0:x}", in(reg) 0i16);
| ^^^ ---- for this argument
@ -90,7 +90,7 @@ LL | asm!("{0} {0:x}", in(reg) 0i16);
= help: or use the `x` modifier to keep the default formatting of `x0`
error: type `i128` cannot be used with this register class
--> $DIR/type-check-3.rs:73:28
--> $DIR/type-check-3.rs:72:28
|
LL | asm!("{}", in(reg) 0i128);
| ^^^^^
@ -98,7 +98,7 @@ LL | asm!("{}", in(reg) 0i128);
= note: register class `reg` supports these types: i8, i16, i32, i64, f32, f64
error: type `float64x2_t` cannot be used with this register class
--> $DIR/type-check-3.rs:75:28
--> $DIR/type-check-3.rs:74:28
|
LL | asm!("{}", in(reg) f64x2);
| ^^^^^
@ -106,7 +106,7 @@ LL | asm!("{}", in(reg) f64x2);
= note: register class `reg` supports these types: i8, i16, i32, i64, f32, f64
error: type `Simd256bit` cannot be used with this register class
--> $DIR/type-check-3.rs:77:29
--> $DIR/type-check-3.rs:76:29
|
LL | asm!("{}", in(vreg) f64x4);
| ^^^^^
@ -114,7 +114,7 @@ LL | asm!("{}", in(vreg) f64x4);
= note: register class `vreg` supports these types: i8, i16, i32, i64, f32, f64, i8x8, i16x4, i32x2, i64x1, f32x2, f64x1, i8x16, i16x8, i32x4, i64x2, f32x4, f64x2
error: incompatible types for asm inout argument
--> $DIR/type-check-3.rs:88:33
--> $DIR/type-check-3.rs:87:33
|
LL | asm!("{:x}", inout(reg) 0u32 => val_f32);
| ^^^^ ^^^^^^^ type `f32`
@ -124,7 +124,7 @@ LL | asm!("{:x}", inout(reg) 0u32 => val_f32);
= note: asm inout arguments must have the same type, unless they are both pointers or integers of the same size
error: incompatible types for asm inout argument
--> $DIR/type-check-3.rs:90:33
--> $DIR/type-check-3.rs:89:33
|
LL | asm!("{:x}", inout(reg) 0u32 => val_ptr);
| ^^^^ ^^^^^^^ type `*mut u8`
@ -134,7 +134,7 @@ LL | asm!("{:x}", inout(reg) 0u32 => val_ptr);
= note: asm inout arguments must have the same type, unless they are both pointers or integers of the same size
error: incompatible types for asm inout argument
--> $DIR/type-check-3.rs:92:33
--> $DIR/type-check-3.rs:91:33
|
LL | asm!("{:x}", inout(reg) main => val_u32);
| ^^^^ ^^^^^^^ type `u32`
@ -144,7 +144,7 @@ LL | asm!("{:x}", inout(reg) main => val_u32);
= note: asm inout arguments must have the same type, unless they are both pointers or integers of the same size
error[E0013]: constants cannot refer to statics
--> $DIR/type-check-3.rs:108:25
--> $DIR/type-check-3.rs:107:25
|
LL | global_asm!("{}", const S);
| ^
@ -152,7 +152,7 @@ LL | global_asm!("{}", const S);
= help: consider extracting the value of the `static` to a `const`, and referring to that
error[E0013]: constants cannot refer to statics
--> $DIR/type-check-3.rs:111:35
--> $DIR/type-check-3.rs:110:35
|
LL | global_asm!("{}", const const_foo(S));
| ^
@ -160,7 +160,7 @@ LL | global_asm!("{}", const const_foo(S));
= help: consider extracting the value of the `static` to a `const`, and referring to that
error[E0013]: constants cannot refer to statics
--> $DIR/type-check-3.rs:114:35
--> $DIR/type-check-3.rs:113:35
|
LL | global_asm!("{}", const const_bar(S));
| ^

View File

@ -10,7 +10,7 @@
// [aarch64_thirunsafeck] needs-llvm-components: aarch64
// [aarch64_mirunsafeck] needs-llvm-components: aarch64
#![feature(no_core, lang_items, rustc_attrs)]
#![feature(no_core, lang_items, rustc_attrs, asm_const)]
#![no_core]
#[rustc_builtin_macro]

View File

@ -7,11 +7,15 @@
#![feature(llvm_asm)]
#![feature(naked_functions)]
#![feature(or_patterns)]
#![feature(asm_const, asm_sym)]
#![crate_type = "lib"]
#![allow(deprecated)] // llvm_asm!
#[repr(C)]
pub struct P { x: u8, y: u16 }
pub struct P {
x: u8,
y: u16,
}
#[naked]
pub unsafe extern "C" fn patterns(
@ -143,21 +147,27 @@ pub unsafe fn default_abi() {
}
#[naked]
pub unsafe extern "Rust" fn rust_abi() {
pub unsafe fn rust_abi() {
//~^ WARN Rust ABI is unsupported in naked functions
asm!("", options(noreturn));
}
#[naked]
pub extern "C" fn valid_a<T>() -> T {
unsafe { asm!("", options(noreturn)); }
unsafe {
asm!("", options(noreturn));
}
}
#[naked]
pub extern "C" fn valid_b() {
unsafe { { {
asm!("", options(noreturn)); ; ; ;
} ; } ; }
unsafe {
{
{
asm!("", options(noreturn));
};
};
}
}
#[naked]

View File

@ -1,35 +1,35 @@
error: asm with the `pure` option must have at least one output
--> $DIR/naked-functions.rs:131:14
--> $DIR/naked-functions.rs:135:14
|
LL | asm!("", options(readonly, nostack), options(pure));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^
error: patterns not allowed in naked function parameters
--> $DIR/naked-functions.rs:18:5
--> $DIR/naked-functions.rs:22:5
|
LL | mut a: u32,
| ^^^^^
error: patterns not allowed in naked function parameters
--> $DIR/naked-functions.rs:20:5
--> $DIR/naked-functions.rs:24:5
|
LL | &b: &i32,
| ^^
error: patterns not allowed in naked function parameters
--> $DIR/naked-functions.rs:22:6
--> $DIR/naked-functions.rs:26:6
|
LL | (None | Some(_)): Option<std::ptr::NonNull<u8>>,
| ^^^^^^^^^^^^^^
error: patterns not allowed in naked function parameters
--> $DIR/naked-functions.rs:24:5
--> $DIR/naked-functions.rs:28:5
|
LL | P { x, y }: P,
| ^^^^^^^^^^
error: referencing function parameters is not allowed in naked functions
--> $DIR/naked-functions.rs:34:5
--> $DIR/naked-functions.rs:38:5
|
LL | a + 1
| ^
@ -37,7 +37,7 @@ LL | a + 1
= help: follow the calling convention in asm block to use parameters
warning: naked functions must contain a single asm block
--> $DIR/naked-functions.rs:31:1
--> $DIR/naked-functions.rs:35:1
|
LL | / pub unsafe extern "C" fn inc(a: u32) -> u32 {
LL | |
@ -53,7 +53,7 @@ LL | | }
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
error: referencing function parameters is not allowed in naked functions
--> $DIR/naked-functions.rs:40:31
--> $DIR/naked-functions.rs:44:31
|
LL | asm!("/* {0} */", in(reg) a, options(noreturn));
| ^
@ -61,7 +61,7 @@ LL | asm!("/* {0} */", in(reg) a, options(noreturn));
= help: follow the calling convention in asm block to use parameters
warning: only `const` and `sym` operands are supported in naked functions
--> $DIR/naked-functions.rs:40:23
--> $DIR/naked-functions.rs:44:23
|
LL | asm!("/* {0} */", in(reg) a, options(noreturn));
| ^^^^^^^^^
@ -70,7 +70,7 @@ LL | asm!("/* {0} */", in(reg) a, options(noreturn));
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: naked functions must contain a single asm block
--> $DIR/naked-functions.rs:47:1
--> $DIR/naked-functions.rs:51:1
|
LL | / pub unsafe extern "C" fn inc_closure(a: u32) -> u32 {
LL | |
@ -84,7 +84,7 @@ LL | | }
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: only `const` and `sym` operands are supported in naked functions
--> $DIR/naked-functions.rs:67:10
--> $DIR/naked-functions.rs:71:10
|
LL | in(reg) a,
| ^^^^^^^^^
@ -102,7 +102,7 @@ LL | out(reg) e,
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: asm in naked functions must use `noreturn` option
--> $DIR/naked-functions.rs:64:5
--> $DIR/naked-functions.rs:68:5
|
LL | / asm!("/* {0} {1} {2} {3} {4} {5} {6} */",
LL | |
@ -117,7 +117,7 @@ LL | | );
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: naked functions must contain a single asm block
--> $DIR/naked-functions.rs:54:1
--> $DIR/naked-functions.rs:58:1
|
LL | / pub unsafe extern "C" fn unsupported_operands() {
LL | |
@ -141,7 +141,7 @@ LL | | }
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: naked functions must contain a single asm block
--> $DIR/naked-functions.rs:80:1
--> $DIR/naked-functions.rs:84:1
|
LL | / pub extern "C" fn missing_assembly() {
LL | |
@ -153,7 +153,7 @@ LL | | }
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: asm in naked functions must use `noreturn` option
--> $DIR/naked-functions.rs:89:5
--> $DIR/naked-functions.rs:93:5
|
LL | asm!("");
| ^^^^^^^^
@ -162,7 +162,7 @@ LL | asm!("");
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: asm in naked functions must use `noreturn` option
--> $DIR/naked-functions.rs:92:5
--> $DIR/naked-functions.rs:96:5
|
LL | asm!("");
| ^^^^^^^^
@ -171,7 +171,7 @@ LL | asm!("");
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: asm in naked functions must use `noreturn` option
--> $DIR/naked-functions.rs:95:5
--> $DIR/naked-functions.rs:99:5
|
LL | asm!("");
| ^^^^^^^^
@ -180,7 +180,7 @@ LL | asm!("");
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: naked functions must contain a single asm block
--> $DIR/naked-functions.rs:86:1
--> $DIR/naked-functions.rs:90:1
|
LL | / pub extern "C" fn too_many_asm_blocks() {
LL | |
@ -202,7 +202,7 @@ LL | | }
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
error: referencing function parameters is not allowed in naked functions
--> $DIR/naked-functions.rs:106:11
--> $DIR/naked-functions.rs:110:11
|
LL | *&y
| ^
@ -210,7 +210,7 @@ LL | *&y
= help: follow the calling convention in asm block to use parameters
warning: naked functions must contain a single asm block
--> $DIR/naked-functions.rs:103:5
--> $DIR/naked-functions.rs:107:5
|
LL | / pub extern "C" fn inner(y: usize) -> usize {
LL | |
@ -225,7 +225,7 @@ LL | | }
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: the LLVM-style inline assembly is unsupported in naked functions
--> $DIR/naked-functions.rs:116:5
--> $DIR/naked-functions.rs:120:5
|
LL | llvm_asm!("");
| ^^^^^^^^^^^^^
@ -236,7 +236,7 @@ LL | llvm_asm!("");
= note: this warning originates in the macro `llvm_asm` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: naked functions must contain a single asm block
--> $DIR/naked-functions.rs:113:1
--> $DIR/naked-functions.rs:117:1
|
LL | / unsafe extern "C" fn llvm() -> ! {
LL | |
@ -252,7 +252,7 @@ LL | | }
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: asm options unsupported in naked functions: `nomem`, `preserves_flags`
--> $DIR/naked-functions.rs:124:5
--> $DIR/naked-functions.rs:128:5
|
LL | asm!("", options(nomem, preserves_flags, noreturn));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -261,7 +261,7 @@ LL | asm!("", options(nomem, preserves_flags, noreturn));
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: asm options unsupported in naked functions: `nostack`, `pure`, `readonly`
--> $DIR/naked-functions.rs:131:5
--> $DIR/naked-functions.rs:135:5
|
LL | asm!("", options(readonly, nostack), options(pure));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -270,7 +270,7 @@ LL | asm!("", options(readonly, nostack), options(pure));
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: asm in naked functions must use `noreturn` option
--> $DIR/naked-functions.rs:131:5
--> $DIR/naked-functions.rs:135:5
|
LL | asm!("", options(readonly, nostack), options(pure));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -279,7 +279,7 @@ LL | asm!("", options(readonly, nostack), options(pure));
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: Rust ABI is unsupported in naked functions
--> $DIR/naked-functions.rs:140:15
--> $DIR/naked-functions.rs:144:15
|
LL | pub unsafe fn default_abi() {
| ^^^^^^^^^^^
@ -287,13 +287,13 @@ LL | pub unsafe fn default_abi() {
= note: `#[warn(undefined_naked_function_abi)]` on by default
warning: Rust ABI is unsupported in naked functions
--> $DIR/naked-functions.rs:146:29
--> $DIR/naked-functions.rs:150:15
|
LL | pub unsafe extern "Rust" fn rust_abi() {
| ^^^^^^^^
LL | pub unsafe fn rust_abi() {
| ^^^^^^^^
warning: naked functions cannot be inlined
--> $DIR/naked-functions.rs:180:1
--> $DIR/naked-functions.rs:190:1
|
LL | #[inline]
| ^^^^^^^^^
@ -302,7 +302,7 @@ LL | #[inline]
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: naked functions cannot be inlined
--> $DIR/naked-functions.rs:188:1
--> $DIR/naked-functions.rs:198:1
|
LL | #[inline(always)]
| ^^^^^^^^^^^^^^^^^
@ -311,7 +311,7 @@ LL | #[inline(always)]
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: naked functions cannot be inlined
--> $DIR/naked-functions.rs:196:1
--> $DIR/naked-functions.rs:206:1
|
LL | #[inline(never)]
| ^^^^^^^^^^^^^^^^
@ -320,7 +320,7 @@ LL | #[inline(never)]
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: naked functions cannot be inlined
--> $DIR/naked-functions.rs:204:1
--> $DIR/naked-functions.rs:214:1
|
LL | #[inline]
| ^^^^^^^^^
@ -329,7 +329,7 @@ LL | #[inline]
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: naked functions cannot be inlined
--> $DIR/naked-functions.rs:207:1
--> $DIR/naked-functions.rs:217:1
|
LL | #[inline(always)]
| ^^^^^^^^^^^^^^^^^
@ -338,7 +338,7 @@ LL | #[inline(always)]
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: naked functions cannot be inlined
--> $DIR/naked-functions.rs:210:1
--> $DIR/naked-functions.rs:220:1
|
LL | #[inline(never)]
| ^^^^^^^^^^^^^^^^

View File

@ -11,7 +11,7 @@
// which causes less readable LLVM errors and in the worst cases causes ICEs
// or segfaults based on system dependent behavior and codegen flags.
#![feature(asm, global_asm, naked_functions)]
#![feature(asm, global_asm, naked_functions, asm_const)]
#[no_mangle]
pub static FOO: usize = 42;

View File

@ -3,7 +3,7 @@
// ignore-spirv
// ignore-wasm32
#![feature(asm, global_asm)]
#![feature(asm, global_asm, asm_const)]
fn main() {
unsafe {

View File

@ -1,7 +1,7 @@
// only-x86_64
// compile-flags: -C target-feature=+avx2
#![feature(asm)]
#![feature(asm, asm_const, asm_sym)]
fn main() {
let mut foo = 0;

View File

@ -3,7 +3,7 @@
// revisions: mirunsafeck thirunsafeck
// [thirunsafeck]compile-flags: -Z thir-unsafeck
#![feature(asm, global_asm)]
#![feature(asm, global_asm, asm_const)]
fn const_generic<const X: usize>() -> usize {
unsafe {

View File

@ -1,6 +1,6 @@
// only-x86_64
#![feature(asm, global_asm)]
#![feature(asm, global_asm, asm_const)]
fn main() {
let mut foo = 0;

View File

@ -3,7 +3,7 @@
// only-linux
// run-pass
#![feature(asm, thread_local)]
#![feature(asm, thread_local, asm_sym)]
extern "C" fn f1() -> i32 {
111
@ -76,5 +76,7 @@ fn main() {
std::thread::spawn(|| {
assert_eq!(static_addr!(S1), &S1 as *const u32);
assert_eq!(static_tls_addr!(S2), &S2 as *const u32);
}).join().unwrap();
})
.join()
.unwrap();
}

View File

@ -1,6 +1,6 @@
// only-x86_64
#![feature(asm, repr_simd, never_type)]
#![feature(asm, repr_simd, never_type, asm_sym)]
#[repr(simd)]
struct SimdNonCopy(f32, f32, f32, f32);

View File

@ -1,7 +1,7 @@
// only-x86_64
// compile-flags: -C target-feature=+avx512f
#![feature(asm, global_asm)]
#![feature(asm, global_asm, asm_const)]
use std::arch::x86_64::{_mm256_setzero_ps, _mm_setzero_ps};

View File

@ -0,0 +1,10 @@
// only-x86_64
#![feature(asm)]
fn main() {
unsafe {
asm!("mov eax, {}", const 123);
//~^ ERROR const operands for inline assembly are unstable
}
}

View File

@ -0,0 +1,12 @@
error[E0658]: const operands for inline assembly are unstable
--> $DIR/feature-gate-asm_const.rs:7:29
|
LL | asm!("mov eax, {}", const 123);
| ^^^^^^^^^
|
= note: see issue #72016 <https://github.com/rust-lang/rust/issues/72016> for more information
= help: add `#![feature(asm_const)]` to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.

View File

@ -0,0 +1,21 @@
// compile-flags: --target mips-unknown-linux-gnu
// needs-llvm-components: mips
#![feature(no_core, lang_items, rustc_attrs)]
#![crate_type = "rlib"]
#![no_core]
#[rustc_builtin_macro]
macro_rules! asm {
() => {};
}
#[lang = "sized"]
trait Sized {}
#[lang = "copy"]
trait Copy {}
unsafe fn main() {
asm!("");
//~^ ERROR inline assembly is not stable yet on this architecture
}

View File

@ -0,0 +1,12 @@
error[E0658]: inline assembly is not stable yet on this architecture
--> $DIR/feature-gate-asm_experimental_arch.rs:19:5
|
LL | asm!("");
| ^^^^^^^^
|
= note: see issue #72016 <https://github.com/rust-lang/rust/issues/72016> for more information
= help: add `#![feature(asm_experimental_arch)]` to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.

View File

@ -0,0 +1,10 @@
// only-x86_64
#![feature(asm)]
fn main() {
unsafe {
asm!("mov eax, {}", sym main);
//~^ ERROR sym operands for inline assembly are unstable
}
}

View File

@ -0,0 +1,12 @@
error[E0658]: sym operands for inline assembly are unstable
--> $DIR/feature-gate-asm_sym.rs:7:29
|
LL | asm!("mov eax, {}", sym main);
| ^^^^^^^^
|
= note: see issue #72016 <https://github.com/rust-lang/rust/issues/72016> for more information
= help: add `#![feature(asm_sym)]` to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.