make #[target_feature] work with asm register classes
This commit is contained in:
parent
d7539a6af0
commit
271da7d8bc
7 changed files with 213 additions and 112 deletions
|
|
@ -21,10 +21,6 @@ fn main() {
|
|||
//~^ ERROR asm template modifiers are not allowed for `const` arguments
|
||||
asm!("{:a}", sym main);
|
||||
//~^ ERROR asm template modifiers are not allowed for `sym` arguments
|
||||
asm!("{}", in(zmm_reg) foo);
|
||||
//~^ ERROR register class `zmm_reg` requires the `avx512f` target feature
|
||||
asm!("", in("zmm0") foo);
|
||||
//~^ ERROR register class `zmm_reg` requires the `avx512f` target feature
|
||||
asm!("", in("ebp") foo);
|
||||
//~^ ERROR invalid register `ebp`: the frame pointer cannot be used as an operand
|
||||
asm!("", in("rsp") foo);
|
||||
|
|
|
|||
|
|
@ -46,86 +46,74 @@ LL | asm!("{:a}", sym main);
|
|||
| |
|
||||
| template modifier
|
||||
|
||||
error: register class `zmm_reg` requires the `avx512f` target feature
|
||||
--> $DIR/bad-reg.rs:24:20
|
||||
|
|
||||
LL | asm!("{}", in(zmm_reg) foo);
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: register class `zmm_reg` requires the `avx512f` target feature
|
||||
--> $DIR/bad-reg.rs:26:18
|
||||
|
|
||||
LL | asm!("", in("zmm0") foo);
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: invalid register `ebp`: the frame pointer cannot be used as an operand for inline asm
|
||||
--> $DIR/bad-reg.rs:28:18
|
||||
--> $DIR/bad-reg.rs:24:18
|
||||
|
|
||||
LL | asm!("", in("ebp") foo);
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: invalid register `rsp`: the stack pointer cannot be used as an operand for inline asm
|
||||
--> $DIR/bad-reg.rs:30:18
|
||||
--> $DIR/bad-reg.rs:26:18
|
||||
|
|
||||
LL | asm!("", in("rsp") foo);
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: invalid register `ip`: the instruction pointer cannot be used as an operand for inline asm
|
||||
--> $DIR/bad-reg.rs:32:18
|
||||
--> $DIR/bad-reg.rs:28:18
|
||||
|
|
||||
LL | asm!("", in("ip") foo);
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: invalid register `k0`: the k0 AVX mask register cannot be used as an operand for inline asm
|
||||
--> $DIR/bad-reg.rs:34:18
|
||||
--> $DIR/bad-reg.rs:30:18
|
||||
|
|
||||
LL | asm!("", in("k0") foo);
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: invalid register `ah`: high byte registers cannot be used as an operand on x86_64
|
||||
--> $DIR/bad-reg.rs:36:18
|
||||
--> $DIR/bad-reg.rs:32:18
|
||||
|
|
||||
LL | asm!("", in("ah") foo);
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: register class `x87_reg` can only be used as a clobber, not as an input or output
|
||||
--> $DIR/bad-reg.rs:39:18
|
||||
--> $DIR/bad-reg.rs:35:18
|
||||
|
|
||||
LL | asm!("", in("st(2)") foo);
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: register class `mmx_reg` can only be used as a clobber, not as an input or output
|
||||
--> $DIR/bad-reg.rs:41:18
|
||||
--> $DIR/bad-reg.rs:37:18
|
||||
|
|
||||
LL | asm!("", in("mm0") foo);
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: register class `x87_reg` can only be used as a clobber, not as an input or output
|
||||
--> $DIR/bad-reg.rs:45:20
|
||||
--> $DIR/bad-reg.rs:41:20
|
||||
|
|
||||
LL | asm!("{}", in(x87_reg) foo);
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: register class `mmx_reg` can only be used as a clobber, not as an input or output
|
||||
--> $DIR/bad-reg.rs:47:20
|
||||
--> $DIR/bad-reg.rs:43:20
|
||||
|
|
||||
LL | asm!("{}", in(mmx_reg) foo);
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: register class `x87_reg` can only be used as a clobber, not as an input or output
|
||||
--> $DIR/bad-reg.rs:49:20
|
||||
--> $DIR/bad-reg.rs:45:20
|
||||
|
|
||||
LL | asm!("{}", out(x87_reg) _);
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: register class `mmx_reg` can only be used as a clobber, not as an input or output
|
||||
--> $DIR/bad-reg.rs:51:20
|
||||
--> $DIR/bad-reg.rs:47:20
|
||||
|
|
||||
LL | asm!("{}", out(mmx_reg) _);
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: register `al` conflicts with register `ax`
|
||||
--> $DIR/bad-reg.rs:57:33
|
||||
--> $DIR/bad-reg.rs:53:33
|
||||
|
|
||||
LL | asm!("", in("eax") foo, in("al") bar);
|
||||
| ------------- ^^^^^^^^^^^^ register `al`
|
||||
|
|
@ -133,7 +121,7 @@ LL | asm!("", in("eax") foo, in("al") bar);
|
|||
| register `ax`
|
||||
|
||||
error: register `ax` conflicts with register `ax`
|
||||
--> $DIR/bad-reg.rs:59:33
|
||||
--> $DIR/bad-reg.rs:55:33
|
||||
|
|
||||
LL | asm!("", in("rax") foo, out("rax") bar);
|
||||
| ------------- ^^^^^^^^^^^^^^ register `ax`
|
||||
|
|
@ -141,13 +129,13 @@ LL | asm!("", in("rax") foo, out("rax") bar);
|
|||
| register `ax`
|
||||
|
|
||||
help: use `lateout` instead of `out` to avoid conflict
|
||||
--> $DIR/bad-reg.rs:59:18
|
||||
--> $DIR/bad-reg.rs:55:18
|
||||
|
|
||||
LL | asm!("", in("rax") foo, out("rax") bar);
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: register `ymm0` conflicts with register `xmm0`
|
||||
--> $DIR/bad-reg.rs:62:34
|
||||
--> $DIR/bad-reg.rs:58:34
|
||||
|
|
||||
LL | asm!("", in("xmm0") foo, in("ymm0") bar);
|
||||
| -------------- ^^^^^^^^^^^^^^ register `ymm0`
|
||||
|
|
@ -155,7 +143,7 @@ LL | asm!("", in("xmm0") foo, in("ymm0") bar);
|
|||
| register `xmm0`
|
||||
|
||||
error: register `ymm0` conflicts with register `xmm0`
|
||||
--> $DIR/bad-reg.rs:64:34
|
||||
--> $DIR/bad-reg.rs:60:34
|
||||
|
|
||||
LL | asm!("", in("xmm0") foo, out("ymm0") bar);
|
||||
| -------------- ^^^^^^^^^^^^^^^ register `ymm0`
|
||||
|
|
@ -163,10 +151,10 @@ LL | asm!("", in("xmm0") foo, out("ymm0") bar);
|
|||
| register `xmm0`
|
||||
|
|
||||
help: use `lateout` instead of `out` to avoid conflict
|
||||
--> $DIR/bad-reg.rs:64:18
|
||||
--> $DIR/bad-reg.rs:60:18
|
||||
|
|
||||
LL | asm!("", in("xmm0") foo, out("ymm0") bar);
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 23 previous errors
|
||||
error: aborting due to 21 previous errors
|
||||
|
||||
|
|
|
|||
40
src/test/ui/asm/x86_64/target-feature-attr.rs
Normal file
40
src/test/ui/asm/x86_64/target-feature-attr.rs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
// only-x86_64
|
||||
|
||||
#![feature(asm, avx512_target_feature)]
|
||||
|
||||
#[target_feature(enable = "avx")]
|
||||
unsafe fn foo() {
|
||||
let mut x = 1;
|
||||
let y = 2;
|
||||
asm!("vaddps {2:y}, {0:y}, {1:y}", in(ymm_reg) x, in(ymm_reg) y, lateout(ymm_reg) x);
|
||||
assert_eq!(x, 3);
|
||||
}
|
||||
|
||||
unsafe fn bar() {
|
||||
let mut x = 1;
|
||||
let y = 2;
|
||||
asm!("vaddps {2:y}, {0:y}, {1:y}", in(ymm_reg) x, in(ymm_reg) y, lateout(ymm_reg) x);
|
||||
//~^ ERROR: register class `ymm_reg` requires the `avx` target feature
|
||||
//~| ERROR: register class `ymm_reg` requires the `avx` target feature
|
||||
//~| ERROR: register class `ymm_reg` requires the `avx` target feature
|
||||
assert_eq!(x, 3);
|
||||
}
|
||||
|
||||
#[target_feature(enable = "avx512bw")]
|
||||
unsafe fn baz() {
|
||||
let x = 1;
|
||||
asm!("/* {0} */", in(kreg) x);
|
||||
}
|
||||
|
||||
unsafe fn baz2() {
|
||||
let x = 1;
|
||||
asm!("/* {0} */", in(kreg) x);
|
||||
//~^ ERROR: register class `kreg` requires at least one of the following target features: avx512bw, avx512f
|
||||
}
|
||||
|
||||
fn main() {
|
||||
unsafe {
|
||||
foo();
|
||||
bar();
|
||||
}
|
||||
}
|
||||
26
src/test/ui/asm/x86_64/target-feature-attr.stderr
Normal file
26
src/test/ui/asm/x86_64/target-feature-attr.stderr
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
error: register class `ymm_reg` requires the `avx` target feature
|
||||
--> $DIR/target-feature-attr.rs:16:40
|
||||
|
|
||||
LL | asm!("vaddps {2:y}, {0:y}, {1:y}", in(ymm_reg) x, in(ymm_reg) y, lateout(ymm_reg) x);
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: register class `ymm_reg` requires the `avx` target feature
|
||||
--> $DIR/target-feature-attr.rs:16:55
|
||||
|
|
||||
LL | asm!("vaddps {2:y}, {0:y}, {1:y}", in(ymm_reg) x, in(ymm_reg) y, lateout(ymm_reg) x);
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: register class `ymm_reg` requires the `avx` target feature
|
||||
--> $DIR/target-feature-attr.rs:16:70
|
||||
|
|
||||
LL | asm!("vaddps {2:y}, {0:y}, {1:y}", in(ymm_reg) x, in(ymm_reg) y, lateout(ymm_reg) x);
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: register class `kreg` requires at least one of the following target features: avx512bw, avx512f
|
||||
--> $DIR/target-feature-attr.rs:31:23
|
||||
|
|
||||
LL | asm!("/* {0} */", in(kreg) x);
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue