Skip to content

Commit

Permalink
Rollup merge of #103168 - Amanieu:stable_asm_sym, r=davidtwco
Browse files Browse the repository at this point in the history
Stabilize asm_sym

Tracking issue #93333

Reference PR: rust-lang/reference#1270
  • Loading branch information
Dylan-DPC authored Oct 18, 2022
2 parents b753ffd + 430bd62 commit 008a3b2
Show file tree
Hide file tree
Showing 39 changed files with 61 additions and 114 deletions.
10 changes: 0 additions & 10 deletions compiler/rustc_ast_lowering/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}
}
InlineAsmOperand::Sym { ref sym } => {
if !self.tcx.features().asm_sym {
feature_err(
&sess.parse_sess,
sym::asm_sym,
*op_sp,
"sym operands for inline assembly are unstable",
)
.emit();
}

let static_def_id = self
.resolver
.get_partial_res(sym.id)
Expand Down
9 changes: 6 additions & 3 deletions compiler/rustc_codegen_gcc/tests/run/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
// Run-time:
// status: 0

#![feature(asm_const, asm_sym)]
#![feature(asm_const)]

use std::arch::{asm, global_asm};

global_asm!("
global_asm!(
"
.global add_asm
add_asm:
mov rax, rdi
Expand Down Expand Up @@ -132,7 +133,9 @@ fn main() {
assert_eq!(x, 43);

// check sym fn
extern "C" fn foo() -> u64 { 42 }
extern "C" fn foo() -> u64 {
42
}
let x: u64;
unsafe {
asm!("call {}", sym foo, lateout("rax") x);
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ declare_features! (
(accepted, abi_sysv64, "1.24.0", Some(36167), None),
/// Allows using ADX intrinsics from `core::arch::{x86, x86_64}`.
(accepted, adx_target_feature, "1.61.0", Some(44839), None),
/// Allows using `sym` operands in inline assembly.
(accepted, asm_sym, "CURRENT_RUSTC_VERSION", Some(93333), None),
/// Allows the definition of associated constants in `trait` or `impl` blocks.
(accepted, associated_consts, "1.20.0", Some(29646), None),
/// Allows using associated `type`s in `trait`s.
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,6 @@ declare_features! (
(active, asm_const, "1.58.0", Some(93332), None),
/// Enables experimental inline assembly support for additional architectures.
(active, asm_experimental_arch, "1.58.0", Some(93335), None),
/// Allows using `sym` operands in inline assembly.
(active, asm_sym, "1.58.0", Some(93333), None),
/// Allows the `may_unwind` option in inline assembly.
(active, asm_unwind, "1.58.0", Some(93334), None),
/// Allows users to enforce equality of associated constants `TraitImpl<AssocConst=3>`.
Expand Down
13 changes: 0 additions & 13 deletions src/doc/unstable-book/src/language-features/asm-sym.md

This file was deleted.

2 changes: 1 addition & 1 deletion src/test/assembly/asm/aarch64-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// compile-flags: --target aarch64-unknown-linux-gnu
// needs-llvm-components: aarch64

#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym)]
#![feature(no_core, lang_items, rustc_attrs, repr_simd)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/arm-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// compile-flags: -C target-feature=+neon
// needs-llvm-components: arm

#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym)]
#![feature(no_core, lang_items, rustc_attrs, repr_simd)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/avr-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// compile-flags: --target avr-unknown-gnu-atmega328
// needs-llvm-components: avr

#![feature(no_core, lang_items, rustc_attrs, asm_sym, asm_experimental_arch)]
#![feature(no_core, lang_items, rustc_attrs, asm_experimental_arch)]
#![crate_type = "rlib"]
#![no_core]
#![allow(non_camel_case_types)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/bpf-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// compile-flags: --target bpfel-unknown-none -C target_feature=+alu32
// needs-llvm-components: bpf

#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)]
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]
Expand Down
6 changes: 4 additions & 2 deletions src/test/assembly/asm/global_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// compile-flags: -C llvm-args=--x86-asm-syntax=intel
// compile-flags: -C symbol-mangling-version=v0

#![feature(asm_const, asm_sym)]
#![feature(asm_const)]
#![crate_type = "rlib"]

use std::arch::global_asm;
Expand All @@ -28,4 +28,6 @@ global_asm!("lea rax, [rip + {}]", sym MY_STATIC);
// CHECK: call _RNvCsiubXh4Yz005_10global_asm6foobar
global_asm!("call {}", sym foobar);
// CHECK: _RNvCsiubXh4Yz005_10global_asm6foobar:
fn foobar() { loop {} }
fn foobar() {
loop {}
}
2 changes: 1 addition & 1 deletion src/test/assembly/asm/hexagon-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// compile-flags: --target hexagon-unknown-linux-musl
// needs-llvm-components: hexagon

#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)]
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/mips-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, asm_sym, asm_experimental_arch)]
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/msp430-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// compile-flags: --target msp430-none-elf
// needs-llvm-components: msp430

#![feature(no_core, lang_items, rustc_attrs, asm_sym, asm_experimental_arch, asm_const)]
#![feature(no_core, lang_items, rustc_attrs, asm_experimental_arch, asm_const)]
#![crate_type = "rlib"]
#![no_core]
#![allow(non_camel_case_types)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/nvptx-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// compile-flags: --crate-type cdylib
// needs-llvm-components: nvptx

#![feature(no_core, lang_items, rustc_attrs, asm_sym, asm_experimental_arch)]
#![feature(no_core, lang_items, rustc_attrs, asm_experimental_arch)]
#![no_core]

#[rustc_builtin_macro]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/powerpc-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//[powerpc64] compile-flags: --target powerpc64-unknown-linux-gnu
//[powerpc64] needs-llvm-components: powerpc

#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)]
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/riscv-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//[riscv32] needs-llvm-components: riscv
// compile-flags: -C target-feature=+d

#![feature(no_core, lang_items, rustc_attrs, asm_sym)]
#![feature(no_core, lang_items, rustc_attrs)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/s390x-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, asm_sym, asm_experimental_arch)]
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/wasm-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// compile-flags: --crate-type cdylib
// needs-llvm-components: webassembly

#![feature(no_core, lang_items, rustc_attrs, asm_sym, asm_experimental_arch)]
#![feature(no_core, lang_items, rustc_attrs, asm_experimental_arch)]
#![no_core]

#[rustc_builtin_macro]
Expand Down
2 changes: 1 addition & 1 deletion src/test/assembly/asm/x86-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, asm_sym)]
#![feature(no_core, lang_items, rustc_attrs, repr_simd)]
#![crate_type = "rlib"]
#![no_core]
#![allow(asm_sub_register, non_camel_case_types)]
Expand Down
26 changes: 18 additions & 8 deletions src/test/ui/abi/abi-sysv64-register-usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,30 @@
// ignore-arm
// ignore-aarch64
// needs-asm-support
#![feature(asm_sym)]

#[cfg(target_arch = "x86_64")]
pub extern "sysv64" fn all_the_registers(rdi: i64, rsi: i64, rdx: i64,
rcx: i64, r8 : i64, r9 : i64,
xmm0: f32, xmm1: f32, xmm2: f32,
xmm3: f32, xmm4: f32, xmm5: f32,
xmm6: f32, xmm7: f32) -> i64 {
pub extern "sysv64" fn all_the_registers(
rdi: i64,
rsi: i64,
rdx: i64,
rcx: i64,
r8: i64,
r9: i64,
xmm0: f32,
xmm1: f32,
xmm2: f32,
xmm3: f32,
xmm4: f32,
xmm5: f32,
xmm6: f32,
xmm7: f32,
) -> i64 {
assert_eq!(rdi, 1);
assert_eq!(rsi, 2);
assert_eq!(rdx, 3);
assert_eq!(rcx, 4);
assert_eq!(r8, 5);
assert_eq!(r9, 6);
assert_eq!(r8, 5);
assert_eq!(r9, 6);
assert_eq!(xmm0, 1.0f32);
assert_eq!(xmm1, 2.0f32);
assert_eq!(xmm2, 4.0f32);
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/asm/aarch64/bad-reg.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// only-aarch64
// compile-flags: -C target-feature=+neon

#![feature(asm_const, asm_sym)]
#![feature(asm_const)]

use std::arch::asm;

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/asm/aarch64/may_unwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// run-pass
// needs-asm-support

#![feature(asm_sym, asm_unwind)]
#![feature(asm_unwind)]

use std::arch::asm;
use std::panic::{catch_unwind, resume_unwind, AssertUnwindSafe};
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/asm/aarch64/sym.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// needs-asm-support
// run-pass

#![feature(thread_local, asm_sym)]
#![feature(thread_local)]

use std::arch::asm;

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/asm/aarch64/type-check-2-2.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// only-aarch64

#![feature(repr_simd, never_type, asm_sym)]
#![feature(repr_simd, never_type)]

use std::arch::{asm, global_asm};

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/asm/aarch64/type-check-2.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// only-aarch64

#![feature(repr_simd, never_type, asm_sym)]
#![feature(repr_simd, never_type)]

use std::arch::{asm, global_asm};

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/asm/generic-const.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// needs-asm-support
// build-pass

#![feature(asm_const, asm_sym)]
#![feature(asm_const)]

use std::arch::asm;

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/asm/naked-functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// ignore-wasm32

#![feature(naked_functions)]
#![feature(asm_const, asm_sym, asm_unwind)]
#![feature(asm_const, asm_unwind)]
#![crate_type = "lib"]

use std::arch::asm;
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/asm/type-check-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// ignore-spirv
// ignore-wasm32

#![feature(asm_const, asm_sym)]
#![feature(asm_const)]

use std::arch::{asm, global_asm};

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/asm/x86_64/bad-reg.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// only-x86_64
// compile-flags: -C target-feature=+avx2

#![feature(asm_const, asm_sym)]
#![feature(asm_const)]

use std::arch::asm;

Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/asm/x86_64/issue-96797.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

// regression test for #96797

#![feature(asm_sym)]

use std::arch::global_asm;

#[no_mangle]
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/asm/x86_64/may_unwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// needs-asm-support
// needs-unwind

#![feature(asm_sym, asm_unwind)]
#![feature(asm_unwind)]

use std::arch::asm;
use std::panic::{catch_unwind, resume_unwind, AssertUnwindSafe};
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/asm/x86_64/multiple-clobber-abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

// Checks that multiple clobber_abi options can be used

#![feature(asm_sym)]

use std::arch::asm;

extern "sysv64" fn foo(x: i32) -> i32 {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/asm/x86_64/sym.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// needs-asm-support
// run-pass

#![feature(thread_local, asm_sym)]
#![feature(thread_local)]

use std::arch::asm;

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/asm/x86_64/type-check-2.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// only-x86_64

#![feature(repr_simd, never_type, asm_sym)]
#![feature(repr_simd, never_type)]

use std::arch::{asm, global_asm};

Expand Down
5 changes: 2 additions & 3 deletions src/test/ui/asm/x86_64/type-check-4.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
// only-x86_64
// compile-flags: -C target-feature=+avx512f

#![feature(asm_const, asm_sym)]
#![feature(asm_const)]

use std::arch::{asm, global_asm};

use std::arch::x86_64::{_mm256_setzero_ps, _mm_setzero_ps};

fn main() {
}
fn main() {}

// Constants must be... constant

Expand Down
Loading

0 comments on commit 008a3b2

Please sign in to comment.