Skip to content

#[target_feature(enable="...")] does not enable use of feature-specific registers  #89289

Closed
@nagisa

Description

@nagisa
Member

On x86 the following does not compile:

#![feature(asm)]

#[target_feature(enable="avx")]
pub unsafe fn foo() {
    let mut x = 0;
    asm!("vmovaps {}, {}", lateout(ymm_reg) x, in(ymm_reg) x);
}

ubt it does compile with -Ctarget-feature=+avx specified. Both should work?

Activity

added
F-asm`#![feature(asm)]` (not `llvm_asm`)
on Sep 26, 2021
nagisa

nagisa commented on Sep 26, 2021

@nagisa
MemberAuthor

I don't think this needs to block the stabilization of the feature, however. Enabling this allows more programs to compile, not fewer.

dobasy

dobasy commented on Oct 2, 2021

@dobasy

This compiles without attributes nor compiler options:

#![feature(asm)]

pub unsafe fn foo(a: &[u8; 32], b: &mut [u8; 32]) {
    asm!(
        "vmovups ymm0, ymmword ptr [{a}]",
        "vmovups ymmword ptr [{b}], ymm0",
        a = in(reg) a.as_ptr(),
        b = in(reg) b.as_mut_ptr(),
        out("ymm0") _,
    );
}
nagisa

nagisa commented on Oct 2, 2021

@nagisa
MemberAuthor
dobasy

dobasy commented on Oct 2, 2021

@dobasy

Isn't this clobber too?:

#![feature(asm)]

pub unsafe fn foo(a: &[u8; 32], b: &mut [u8; 32]) {
    asm!(
        "vmovups {ymm}, ymmword ptr [{a}]",
        "vmovups ymmword ptr [{b}], {ymm}",
        a = in(reg) a.as_ptr(),
        b = in(reg) b.as_mut_ptr(),
        ymm = out(ymm_reg) _,
    );
}

It doesn't compile.

asquared31415

asquared31415 commented on Oct 7, 2021

@asquared31415
Contributor

@rustbot claim

added a commit that references this issue on Oct 9, 2021

Rollup merge of rust-lang#89641 - asquared31415:asm-feature-attr-regs…

5ebb6a8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

F-asm`#![feature(asm)]` (not `llvm_asm`)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @nagisa@dobasy@asquared31415

    Issue actions

      `#[target_feature(enable="...")]` does not enable use of feature-specific registers · Issue #89289 · rust-lang/rust